Repository navigation
refactor(cli): fold cli-schema into commands/schema, move batch-steps into commands/batch (#2679) - #2678
Conversation
… into commands/batch Implements move 1 (+ batch-steps.ts) from the collocation plan in #2677: cli-schema was a rank-0.0003-modularity, 37.5%-legible eight-file zone that existed only to render the command facets commands/ already owns, and batch-steps.ts's only relative import and only importer both already live under commands/. Folding both in removes a family the coupling/legibility measures called out as a clear placement miss, without changing behaviour. - git mv src/cli-schema/* -> src/commands/schema/* - git mv src/cli/batch-steps.ts -> src/commands/batch/batch-steps.ts - update every import site, the literal command-explain.ts owner-files path, the layering model's now-absorbed cli-schema rank entry (folded files resolve to the commands zone by directory), fallow-baselines/ health.json's path-keyed findings, and the AGENTS.md / cli-flags.md pointers Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01EmJYA9V4uKcAGBqedwXbwD
Size Report
Startup median (7 runs, lower is better):
|
Measured before/after, and one enforcement gapThe rebase is not blocked. Merging
Families 39 → 38. Enforcement gap. The PR leaves two rules naming a zone that no longer exists and calls them inert. They are not equivalent:
AGENTS.md asks to complete migrations and remove superseded paths, and to colocate claims with their enforcement. Suggested fix, small: replace R2 row 2 with a folder-scoped rule (commands outside Generated by Claude Code |
…ed into it Review on #2678 found a real enforcement gap: folding cli-schema into commands/schema/ put both sides of the #2543 "commands never imports cli-schema back" direction into the same commands zone, which checkLayeringRules's ZONE_POLICIES table cannot see (it skips every same-zone edge before the table ever runs). The R2 zone-policy row that used to declare the direction became silently unenforceable, not just harmlessly dead like the daemon-side check. - add scripts/layering/commands-schema-boundary.ts: a folder-scoped check (commands outside schema/ must not import commands/schema/) wired into check.ts's rule registry, replacing the lost R2 row - drop the now-unenforceable R2 row from zone-policy.ts's table and its test, and the header comments that described it - delete the actually-dead checkDaemonCliSchemaBoundary from daemon-modularity.ts (the daemon side stays covered generically by R2's daemon/core -> commands row) and its tests Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01EmJYA9V4uKcAGBqedwXbwD
|
Thanks for the measurement and the catch. Rebase/measurement: noted — merge instead of rebase avoids the stale-base conflict, and the numbers you posted confirm the move lands as the plan predicted (Q 0.251 → 0.255, cross-family 64.3 → 62.2%, matches the what-if within rounding). Nothing for this PR to change there; it stays based on Enforcement gap: fixed in
Generated by Claude Code |
|
Reviewed at b03e8cf. No blocking findings: the moves are renames with import-path edits only, no live import of |
Summary
Implements the move tracked in #2679 ("PR A" from the collocation plan in #2677 (comment)) — filed as its own issue per this scope note: #2677's guard 9 keeps that issue tooling-only, so the
src/-touching moves it inspired belong outside it.cli-schemawas a standalone 8-file zone withQ ≈ 0, out/in flow 30, touching 29 of 39 families — the plan's clearest "wrongly-a-family" candidate. It exists only to render the command facetscommands/already owns (refactor(cli-schema): orient the schema layer below commands #2543 declared that direction), so it folds intocommands/schema/.src/cli/batch-steps.ts's only relative import and only real importer already live undersrc/commands/, so it moves tosrc/commands/batch/batch-steps.tsin the same PR per the plan's move-4 bundle.targetDagZoneclassifies zones by top-levelsrc/<folder>/name, so the moved files automatically re-zone from the retiredcli-schemazone intocommands— no new zone-policy needed.Rebase status (see #2679 for detail)
The scope-note comment asked this move to rebase onto
apex/module-shape-measures(the #2677 tooling branch) so before/afterpnpm coupling/pnpm legibilitynumbers are attributable to the move alone. I tried it:apex/module-shape-measures(86741f2) is 4 commits behindmainand is missing #2665, which also touchessrc/cli/parser/command-suggestions.ts. Rebasing onto it as-is conflicts there for real (apex has nosuggestFlagFor/flag-suggestion code at all, so the conflict can't be resolved by picking a side without either dropping this move's fix for that file or pulling in unrelated feature work). This PR stays based onmainfor now, green and ready; I'll rebase it ontoapex/module-shape-measuresand add the coupling numbers once that branch is refreshed against currentmain.Changes
git mv src/cli-schema/*(8 production + 8 colocated test files) →src/commands/schema/*git mv src/cli/batch-steps.ts→src/commands/batch/batch-steps.ts'src/cli-schema/command-overrides.ts'owner-files path insrc/cli/command-explain.ts(and its test), and a self-referencingimport.meta.urlpath in the movedcommand-schema-guards.test.ts['cli-schema', 3]entry fromscripts/layering/model.ts'sTARGET_DAG_RANK, and swapped a hardcodedcli-schemazone out of amodel.test.tsfixture (formcp, another rank-3 zone, preserving the same back-edge-detection shape)src/cli-schema/...-keyed entries infallow-baselines/health.jsonAGENTS.mdanddocs/agents/cli-flags.mdpointer linesLeft deliberately unchanged (dead/inert but harmless, not required for correctness):
scripts/layering/zone-policy.ts/.test.tsandscripts/layering/daemon-modularity.ts/.test.tsstill namecli-schemain a policy rule that will simply never fire again (thedaemon -> commandsR2 rule already covers the same boundary); a comment inscripts/layering/check.tsandscripts/help-conformance-cases.mjs; two historical/append-only docs (docs/dependency-graph-findings.md,docs/adr/0019-...).Verification
pnpm lint,pnpm typecheck,pnpm format:check,pnpm check:layering(244/244),pnpm depgraph:test(24/24),pnpm check:gate-manifest— all cleanpnpm test:unit(10,522 tests) — 3 pre-existing failures inpackages/capture-kitandsrc/daemon, confirmed to reproduce identically onorigin/main(unrelated to this change, verified via a throwaway worktree)Test plan
pnpm check:layeringpnpm lint/pnpm typecheck/pnpm format:checkpnpm test:unit(pre-existing unrelated failures confirmed onmain)apex/module-shape-measures+pnpm couplingbefore/after (blocked, see above)🤖 Generated with Claude Code
https://claude.ai/code/session_01EmJYA9V4uKcAGBqedwXbwD