refactor(sync): channel-based structure, split oversized modules - #247
Merged
Conversation
Contributor
|
🎉 PR Validation ✅ PASSED Commit: Checks:
Ready to merge! ✨ 🔗 View workflow run |
vreshch
marked this pull request as ready for review
July 7, 2026 22:34
vreshch
added a commit
that referenced
this pull request
Jul 7, 2026
## Review-readiness sweep (post #238-#247) Fresh-reviewer pass over the whole repo after the 10-PR merge burst. The repo held up well; this PR carries the one actionable finding, plus a clean bill of health on the rest. ### Fixed - **`src/commands/memory.ts` was 207 lines** (over the 200 bar). Split along its natural seam: the six `run*` verb flows + their helpers move to `src/commands/memory-verbs.ts` (133 lines); `memory.ts` keeps the commander wiring + error `guard` (81 lines). Test import retargeted to `./memory-verbs.js`. No behavior change. ### Checked, nothing to fix - **Cross-PR seams:** no stale path refs (e.g. no lingering `src/sync/cycle.ts`), no duplicated helpers (`redactRemoteUrl` lives once in `sync/git/remote-url.ts`, imported by all five callers). - **File/naming bar:** all other src files <=200 lines, all kebab-case, no default exports, no `any` outside tests. - **Comments:** no `TODO`/`FIXME`/`XXX`, no commented-out code. Multi-line comment blocks that remain are load-bearing security/concurrency WHY notes (e.g. the `ext::` transport-helper RCE guard, the cross-process `mutateVaultsConfig` invariant) - collapsing them would lose signal, left as-is. - **Docs accuracy:** README, `docs/architecture.md` (vs `architecture.svg`), and CLAUDE.md layout all cross-checked against source - 20+ claims (flags, env vars, `4243` port, `0600` auth.json, six MCP tools, conflict-file naming) all verified, zero mismatches, zero typos, zero em dashes. - **CLI surface:** ran the built `dist/cli.js` help for every subcommand in an isolated HOME - consistent tone, no typos. `npm run verify` green; `test:coverage` green (85.5% stmts, above the 65/70/70/70 thresholds).
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Pure structure/readability refactor of
src/sync/. Zero behavior change - only file moves, import-path rewrites, and function extraction. Same tests pass (405), coverage floors met.1. Channel-based sync tree
The git channel was mixed at the
src/sync/root alongside thecouch/anddiscover/subfolders. Now every channel is its own folder; the root holds no logic.Before
After
All imports updated across
daemon-entry,daemon/server,lib/daemon-client,lib/vault-registry,commands/vault,commands/vault-sync(+ test), and the intra-couchrefs to../git/*. No sharedtypes.tswas invented - the cross-channel types are channel-specific and stay with their channel (re-exported fromcouch/manager.tsto keep the public import surface stable).2. Split oversized modules (house bar <200 lines)
src/sync/couch/manager.tswas 363 lines. Split along its natural seams into siblings, manager becomes thin composition:couch/manager.tscouch/manager.types.tsCouchRuntime, results, deps,TargetState)couch/cycle.tscouch/wire.tsgetState/ensureWire/pendingCount(wire + token setup)couch/push-on-write.tscouch/mutation-target.tscouch/local-commit.tscouch/manager.test.tswas 399 lines, split along the same seams:couch/manager.test.tscouch/push-on-write.test.tscouch/mutation-target.test.tscouch/manager.fixtures.tsThe extracted seams stay tested through the composed manager (integration level - they are implementation details, not a widened public API). Crash-recovery / durability tests are moved intact, semantics untouched.
3. Consistency sweep (light)
.types.ts,.fixtures.ts).src/root.src/commands/,src/lib/left untouched per scope (commands/memory.tsat 207 is out of scope).vitest.config.ts:*.fixtures.tsadded to the coverageexclude(test support, not product code);src/sync/**floor glob still matches the newsrc/sync/git/**+src/sync/couch/**paths.4. Docs
CLAUDE.mdLayout section rewritten to describe the per-channel tree (one-line-per-path, same terseness).Verify
npm run verifygreen (type-check, e2e type-check, lint, format, 405 tests, build).npm run test:coveragegreen - per-directory floors met (sync/git,sync/couch,sync/discoverall present under the new paths). No dependency changes, no README changes.