refactor(layering): rank every root module so R5 sees through (root)

Merged
TH
2mo ago
+509-66

Summary

Closes #3280. (root) holds only bin.ts, cli.ts, daemon.ts, ranked above the spine.

  • scripts/layering/root-module-zones.ts declares every other src/*.ts module's zone; a test rejects undeclared, stale or duplicate rows.
  • Scope: this reduces (root) in the logical graph only. The modules stay under src/; classifying them is not collocating them. The table is a bridge: rows go as groups move into zone folders or packages, until a rename inside an owner needs no table edit while forbidden dependencies still fail. Outstanding moves start with #3294.
  • New R80 zone-value-dag rejects zone-level static value cycles, invisible to R5 within one rank.
  • remote ⇄ daemon-server broken by moving the remote temp-path helpers into @agent-device/contracts/daemon-http, with shared extension normalization.
  • Dynamic imports stay out of R5/R80; reason recorded at R5.

sdk/ai-sdk rank 6 (cli 7): their entries publish the daemon client; platform-runtime-host ranks 8, so a static import of the lazy host is an R5 back-edge. R6 reports 10 type-only inversions, 7 previously hidden. 12 files.

Validation

At 66029dd82: pnpm check:affected --run passed all runnable checks.

Planted scripts/layering/check.ts runs (outputs in the review thread):

  • declaration with the old ranks: exactly the 2 known R5 inversions
  • empty declaration: 65 R5 back-edges plus an R80 cycle through (root)
  • pre-fix remote/daemon files: R80 daemon-server -> remote -> daemon-server
  • static host import from platform-runtime.ts or sdk/index.ts: R5

root-module-zones.test.ts pins the sdk rank and generates one static host importer per ranked zone.

šŸ¤– Generated with Claude Code