Skip to content

Commit 7bf7164

Browse files
Consolidate salvaged branches: signal_mesh + MCP↔WS bridge + pomodoro demo, green CI with per-package coverage ratchet (#57)
## TLDR Consolidates all useful work salvaged from the repo's stray branches onto one branch — two new packages (`signal_mesh`, `mcp-websocket-bridge`), a pomodoro demo across the examples, CI/tooling hardening — and gets `make ci` fully green with per-package coverage that auto-ratchets up. ## What Was Added? - **`signal_mesh/`** — new Dart package: peer-to-peer encrypted mesh messenger. Kademlia DHT peer discovery, X3DH + Double Ratchet end-to-end crypto, phone-number identity + attestation, store-and-forward queue, and a transport abstraction. Ships its own test suite (crypto, node_id, kademlia, routing_table, identity, message, store_forward, transport). `publish_to: none` (path deps on `dart_node_core`/`dart_node_ws`). - **`packages/mcp-websocket-bridge/`** — new TypeScript package bridging MCP over WebSocket (bridge/transport/session/http-client/types/errors), with `SPEC.md`, README, and an `examples/chat-bridge.ts`. - **Pomodoro demo** across `examples/` — backend routes + `PomodoroService` + validation schema, mobile `pomodoro_screen`, shared `PomodoroSession` model / theme styles / HTTP client, plus backend and mobile tests. Also a `paper_demo_screen` (react-native-paper). - **Agent/dev tooling** — `.claude/skills/*` (build, ci-prep, code-dedup, fix-bug, fmt, lint, spec-check, submit-pr, upgrade-packages, website-audit), assistant rule files (`.cursorrules`, `.clinerules`, `.windsurfrules`, copilot-instructions), `.deslop.toml`, `.editorconfig`. - **`coverage-thresholds.json`** — single source of truth for per-package coverage floors that ratchet UP only. ## What Was Changed or Deleted? - **Coverage now actually enforced.** `coverage-thresholds.json` was a single `default_threshold: 70`. It now carries a per-package map seeded from the legacy GitHub Actions variable `MIN_COVERAGE=70` and **auto-ratcheted** in `tools/test.sh`: after every fully-green run each package's floor is raised to its measured coverage and never lowered (`default_threshold` raised to a 90% library floor for new packages). - **`make ci` made green** (these were real pre-existing failures, not introduced here): - `packages/dart_node_coverage/lib/src/runtime.dart` — removed all illegal `as` casts and a bare `catch`; replaced with typed `@JS` extension types (`JSON.parse`, `Object.keys`) and generic `getProperty<T>`. - `examples/backend/server.dart` — the pomodoro routes were a broken merge (missing `models/pomodoro.dart` import; calling an undefined `getAuthContext`; unmatched `Result`s). Rewrote all 10 routes to the same `getAuthContextWithService` + `getValidatedBody` pattern the task routes use. - `dart_node_mcp` / `dart_node_vsix` / `dart_node_ws` test files — cascades, the JSArray `prefer_is_empty` false-positive (`.toDart.isNotEmpty`), `unnecessary_async`, a tearoff, nullable-cast cleanup. - `cspell-dictionary.txt` — added the legitimate technical terms cspell flagged (Kademlia, HKDF/HMAC, ciphertext, otpk, prekey, pomodoro, deslop, worktree, automemory). - **Removed `tools/build/`** (`build.dart`, `add_preamble.dart`) — superseded. - `analysis_options.yaml` tightened (`strict-casts`/`strict-inference`/`strict-raw-types`); `Makefile` standardized (`lint`/`test`/`fmt`/`ci`); `.github/workflows/` updated (CI reads the coverage threshold from the JSON; `deploy-website` → `deploy-pages`); website gained pub.dev + GitHub links and a getting-started page. ## How Do The Automated Tests Prove It Works? - `make ci` is **green end-to-end** (`MAKE_CI_EXIT=0`): cspell reports `0 issues in 0 files`; `dart analyze` reports **0 errors** across every package and example; all test tiers pass with coverage enforced — `dart_node_core`/`dart_node_ws`/`dart_node_express`/`dart_node_better_sqlite3`/`dart_node_mcp`/`dart_node_react_native`/`dart_logging` at 100%, `web_counter` 98.5%, `reflux` 97.6%, `markdown_editor` 94.8%; `dart_node_react`/`frontend` browser tests pass under Chrome. - **Ratchet verified across two runs:** run #1 logged `⬆️ Ratcheted … → 100.0% (was 70%)` for every package and `Coverage thresholds raised`; run #2 produced **no** ratchet lines and still passed — proving the floor is monotonic and idempotent. A subsequent coverage drop below the stored floor now fails `make test`. - The `runtime.dart` refactor is exercised at runtime, not just statically: the Node coverage CLI uses `writeCoverageFile`/`_mergeData` to merge coverage for every `NODE_PACKAGES` run, all of which passed. ## Spec / Doc Changes - `CLAUDE.md` — TDD rule + deslop / branch-discipline / autonomy / auto-memory sections. - `coverage-thresholds.json` `_doc` rewritten to describe the auto-ratchet contract. - New `signal_mesh/README.md` and `mcp-websocket-bridge/SPEC.md` + README. ## Breaking Changes - [x] None to any published package surface. The two new packages are not published (`publish_to: none` / path deps); all other changes are examples, CI/tooling, and lint-clean refactors with no behavioral change. > Note: `signal_mesh` and `mcp-websocket-bridge` ship with their own tests but are not yet wired into the `tools/test.sh` tier runner, so they are not gated by `make ci` in this PR — a sensible follow-up. ---------
1 parent 57bbbba commit 7bf7164

115 files changed

Lines changed: 11604 additions & 755 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.claude/settings.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
{
2+
"_agent_pmo": "76596cb",
3+
"autoMemoryEnabled": false
4+
}

.claude/skills/build/SKILL.md

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
---
2+
name: build
3+
description: Builds all artifacts for this repo. Use when the user asks to build, compile, or produce artifacts, or when verifying that the project compiles cleanly.
4+
---
5+
6+
# Build
7+
8+
Build all artifacts for this repo.
9+
10+
## Steps
11+
12+
1. Run `make clean` to remove stale artifacts
13+
2. Run `make build`
14+
3. Report what was built and where the artifacts are
15+
16+
## Notes
17+
18+
This is a Dart library monorepo — `make build` verifies that all packages compile cleanly. There are no standalone build artifacts (libraries are consumed via pub.dev).
19+
20+
To build specific components:
21+
- Backend example: `dart run tools/build/build.dart backend`
22+
- VS Code extension: see `/build-extension` skill
23+
24+
## Success criteria
25+
26+
- Exit code 0 from `make build`
27+
- No warnings printed to stderr

.claude/skills/ci-prep/SKILL.md

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
---
2+
name: ci-prep
3+
description: Prepares the current branch for CI by running the exact same checks locally, fixing issues at each step. Use before pushing a branch or when the user wants to verify the branch will pass CI.
4+
---
5+
6+
# CI Prep
7+
8+
Prepare the current state for CI. Ensures the branch will pass CI before pushing.
9+
10+
## Steps
11+
12+
### Step 1 — Analyze the CI workflow
13+
14+
1. Read `.github/workflows/ci.yml`
15+
2. The CI runs these jobs in order:
16+
- **lint**: format check, spell check, dart analyze
17+
- **test**: tier 1, tier 2, tier 3 tests with coverage
18+
- **build**: `make build`
19+
- **website**: website build + Playwright tests (independent)
20+
21+
### Step 2 — Run each CI step locally, in order
22+
23+
1. **Format check**: `make fmt CHECK=1`
24+
- If fails: run `make fmt` to fix, then re-check
25+
2. **Spell check**: `cspell "**/*.md" "**/*.dart" "**/*.ts" --no-progress`
26+
- If fails: add words to cspell dictionary or fix typos
27+
3. **Analyze**: `dart analyze --no-fatal-warnings` on all packages
28+
- If fails: fix lint errors in the reported files
29+
4. **Test Tier 1**: `./tools/test.sh --tier 1`
30+
5. **Test Tier 2**: `./tools/test.sh --tier 2`
31+
6. **Test Tier 3**: `./tools/test.sh --tier 3`
32+
7. **Build**: `make build`
33+
34+
### Step 3 — Report
35+
36+
- List every step that was run and its result (pass/fail/fixed)
37+
- If any step could not be fixed, report what failed and why
38+
- Confirm whether the branch is ready to push
39+
40+
## Rules
41+
42+
- Do not push if any step fails
43+
- Fix issues found in each step before moving to the next
44+
- Never skip steps or suppress errors

.claude/skills/code-dedup/SKILL.md

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
---
2+
name: code-dedup
3+
description: Searches for duplicate code, duplicate tests, and dead code, then safely merges or removes them. Use when the user says "deduplicate", "find duplicates", "remove dead code", "DRY up", or "code dedup". Requires test coverage — refuses to touch untested code.
4+
---
5+
6+
# Code Dedup
7+
8+
Carefully search for duplicate code, duplicate tests, and dead code across the repo. Merge duplicates and delete dead code — but only when test coverage proves the change is safe.
9+
10+
## Prerequisites — hard gate
11+
12+
Before touching ANY code, verify these conditions. If any fail, stop and report why.
13+
14+
1. Run `make test` — all tests must pass. If tests fail, stop.
15+
2. `make test` already enforces the coverage threshold from `coverage-thresholds.json`. If it failed on coverage, stop.
16+
3. This is a Dart repo with static typing via `austerity` — proceed.
17+
18+
## Steps
19+
20+
### Step 1 — Inventory test coverage
21+
22+
1. Run `make test` and note coverage per package from the output
23+
2. Only packages WITH coverage are candidates for dedup
24+
25+
### Step 2 — Scan for dead code
26+
27+
1. Look for unused exports, functions, classes, variables across all packages
28+
2. Use `dart analyze` output for unused element warnings
29+
3. Grep the entire codebase for references before marking as dead
30+
4. List all dead code found. Do NOT delete yet.
31+
32+
### Step 3 — Scan for duplicate code
33+
34+
1. Look for functions with identical or near-identical logic across packages
35+
2. Check across package boundaries
36+
3. List all duplicates found. Do NOT merge yet.
37+
38+
### Step 4 — Scan for duplicate tests
39+
40+
1. Look for tests that verify the same behavior
41+
2. Look for test helpers duplicated across test files
42+
3. List all duplicate tests found. Do NOT delete yet.
43+
44+
### Step 5 — Apply changes (one at a time)
45+
46+
For each change: **change -> test -> verify coverage -> continue or revert**.
47+
48+
- After each change: run `./tools/test.sh`
49+
- If tests fail or coverage drops: **revert immediately**
50+
51+
### Step 6 — Final verification
52+
53+
1. Run `make test` — all tests must still pass
54+
2. Run `make lint` and `make fmt CHECK=1` — code must be clean
55+
3. Report: what was removed, what was merged, final coverage vs baseline
56+
57+
## Rules
58+
59+
- **No test coverage = do not touch.**
60+
- **Coverage must not drop.**
61+
- **One change at a time.**
62+
- **When in doubt, leave it.** False dedup is worse than duplication.
63+
- **Three similar lines is fine.** Only dedup substantial (>10 lines) or 3+ copies.

.claude/skills/fix-bug/SKILL.md

Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
---
2+
name: fix-bug
3+
description: Fix a bug using test-driven development. Use when the user reports a bug, describes unexpected behavior, wants to fix a defect, or says something is broken. Enforces a strict test-first workflow where a failing test must be written and verified before any fix is attempted.
4+
argument-hint: "[bug description]"
5+
allowed-tools: Read, Grep, Glob, Edit, Write, Bash
6+
---
7+
<!-- agent-pmo:76596cb -->
8+
9+
# Bug Fix Skill — Test-First Workflow
10+
11+
You MUST follow this exact workflow. Do NOT skip steps. Do NOT fix the bug before writing a failing test.
12+
13+
## Step 1: Understand the Bug
14+
15+
- Read the bug description: $ARGUMENTS
16+
- Investigate the codebase to understand the relevant code
17+
- Identify the root cause (or narrow down candidates)
18+
- Summarize your understanding of the bug to the user before proceeding
19+
20+
## Step 2: Write a Failing Test
21+
22+
- Write a test that **directly exercises the buggy behavior**
23+
- The test must assert the **correct/expected** behavior — so it FAILS against the current broken code
24+
- The test name should clearly describe the bug (e.g., `test_orange_color_not_applied_to_head`)
25+
- Use the project's existing test framework and conventions
26+
27+
## Step 3: Run the Test — Confirm It FAILS
28+
29+
- Run ONLY the new test (not the full suite)
30+
- **Verify the test FAILS** and that it fails **because of the bug**, not for some other reason (typo, import error, wrong selector, etc.)
31+
- If the test passes: your test does not capture the bug. Go back to Step 2
32+
- If the test fails for the wrong reason: fix the test, not the code. Go back to Step 2
33+
- **Repeat until the test fails specifically because of the bug**
34+
35+
## Step 4: Show Failure to User
36+
37+
- Show the user the test code and the failure output
38+
- Explicitly ask: "This test fails because of the bug. Can you confirm this captures the issue before I fix it?"
39+
- **STOP and WAIT for user acknowledgment before proceeding**
40+
- Do NOT continue to Step 5 until the user confirms
41+
42+
## Step 5: Fix the Bug
43+
44+
- Make the **minimum change** needed to fix the bug
45+
- Do not refactor, clean up, or "improve" surrounding code
46+
- Do not change the test
47+
48+
## Step 6: Run the Test — Confirm It PASSES
49+
50+
- Run the new test again
51+
- **Verify it PASSES**
52+
- If it fails: go back to Step 5 and adjust the fix
53+
- **Repeat until the test passes**
54+
55+
## Step 7: Run the Full Test Suite
56+
57+
- Run ALL tests to make sure nothing else broke
58+
- If other tests fail: fix the regression without breaking the new test
59+
- Report the final result to the user
60+
61+
## Rules
62+
63+
- NEVER fix the bug before the failing test is written and confirmed
64+
- NEVER skip asking the user to acknowledge the test failure
65+
- NEVER modify the test to make it pass — modify the source code
66+
- If you cannot write a test for the bug, explain why and ask the user how to proceed
67+
- Keep the fix minimal — one bug, one fix, one test

.claude/skills/fmt/SKILL.md

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
---
2+
name: fmt
3+
description: Formats all code in this repo using dart format. Use when the user asks to format code, fix formatting, or before committing changes.
4+
---
5+
6+
# Format
7+
8+
Format all code in this repo.
9+
10+
## Steps
11+
12+
1. Run `make fmt`
13+
2. Run `make fmt CHECK=1` to confirm clean
14+
3. Report which files were modified
15+
16+
## What it does
17+
18+
- `dart format packages/ examples/`
19+
20+
## Success criteria
21+
22+
- `make fmt CHECK=1` exits with code 0 after formatting

.claude/skills/lint/SKILL.md

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
---
2+
name: lint
3+
description: Runs all linters and format checks, then fixes any issues found. Use when the user asks to lint, check code quality, or fix linting errors.
4+
---
5+
6+
# Lint
7+
8+
Run all linters and report issues.
9+
10+
## Steps
11+
12+
1. Run `make lint` (runs format check + cspell + dart analyze on all packages)
13+
2. Report all issues found (file, line, rule, message)
14+
3. If issues found, fix them and re-run to confirm clean
15+
16+
## What `make lint` does
17+
18+
1. `dart format --set-exit-if-changed` on packages/, examples/, tools/build
19+
2. `cspell` spell check on all .md, .dart, .ts files
20+
3. `dart analyze --no-fatal-warnings` on every package and example
21+
22+
## Rules
23+
24+
- Never suppress a lint warning with an ignore comment
25+
- Fix the code to satisfy the linter
26+
- Each package uses the `austerity` lint package — do not bypass its rules
27+
- If a rule seems wrong for a specific case, document why in code comments
28+
29+
## Success criteria
30+
31+
- `make lint` exits with code 0
32+
- Zero warnings or errors output

0 commit comments

Comments
 (0)