refactor(daemon): stop the client value-importing daemon internals (#2559) - #2594
Conversation
…2559) src/daemon-client composed the daemon over the network yet still value-imported its module graph: state-dir resolution (config.ts), pidfile liveness (daemon-process.ts), the repair tombstone, and the request-progress framing. Move those process-root contracts out from under src/daemon/ so both sides reach them at the composition root, narrow src/daemon/config.ts to re-export only the state helpers its own importers read (it keeps the daemon-only request-scoping rules), and repoint the client's remaining imports at the relocated modules. The client keeps reading the canonical DaemonRequest/DaemonResponse vocabulary from daemon-request.ts, which is a type-only read. Repoint scripts/clean-daemon.ts and the ios-snapshot-benchmark cell-admission at the relocated daemon-process. No behavior change: renames are content-preserving and the wire protocol is unchanged (wire-compat reports 8 moved, 0 changed, digests identical). Co-Authored-By: Apex <noreply@callstack.com>
…ient rows from daemon-modularity (#2559) Declare the daemon-entry surface the client is allowed to see. R78 names every measured src/daemon-client -> src/daemon edge: a runtime (value or dynamic) import of daemon internals is always red, an unrecorded type import is red, and a recorded edge the tree no longer imports is red, so the set can only shrink and a repair cannot leave a stale entry that lets an edge back in. The only residue is the five type-only reads of daemon-request.ts: the canonical DaemonRequest/DaemonResponse vocabulary that anchors the ADR 0006 wire surface, recorded with that rationale. daemon-modularity now skips src/daemon-client/ so the two gates never own one edge: its externalDaemonTypesImporters list drops the five client rows it used to cover, leaving the two importers R78 does not reach. Move the two fallow health baseline keys off the relocated daemon-process/request-progress-protocol paths (the move did not carry their high-impact finding, so they are dead, not relocated). Co-Authored-By: Apex <noreply@callstack.com>
Size Report
Startup median (7 runs, lower is better):
|
|
The moves at 5a350b4 keep content and wire digests the same, and R78 covers every client-to-daemon edge that Coverage fails because of this change.
Also, the body says net −336 production lines, but the diff is about +294/−129 without tests and docs. Please correct it after the fix. |
Re-exporting the shared leaf through src/daemon/config.ts cost every importer that only needs a state dir one extra evaluated module, and src/cli.ts crossed the ADR 0019 eager-closure ratchet (296 against the merge-base's 295). Point the CLI, client, daemon, scripts, and test importers of resolveDaemonPaths/DaemonPaths/ resolveDaemonServerMode straight at src/daemon-resolution.ts and drop the re-export, so src/daemon/config.ts keeps only the request-scoping rules the daemon applies. Co-Authored-By: Apex <noreply@callstack.com>
…tion lane (#2559) daemon-process-takeover.test.ts moved to src/__tests__/ with the module it covers, but the mutation lane's subprocess exclusion still named the old path, so thousands of mutant reruns would have paid its real per-case daemon spawn again (#1545). Co-Authored-By: Apex <noreply@callstack.com>
|
All three addressed at
Full |
|
All three points are fixed at 3e7bd6f. One small thing: the production figure in the body still does not match the diff. |
|
…tle-on-exit-2522 * origin/main: perf(scroll-until): answer every candidate from one visibility index (#2596) refactor(daemon): resolve device interactors through a composed capability (#2593) refactor(daemon): stop the client value-importing daemon internals (#2559) (#2594) refactor(shell-quote): one implementation, reached through the runner host port (#2595) docs(agents): delete the file-size tiers nobody enforces (#2597) fix(daemon): key the implicit session by workspace and platform (#2587) refactor(cli-schema): orient the schema layer above commands (#2543 step 3) (#2590)
Summary
src/daemon-client/**composed the daemon over the network but still value-imported its module graph —config.ts(state-dir),daemon-process.ts(pidfile liveness),session-repair-tombstone.ts, andrequest-progress-protocol.ts. This moves those process-root contracts out from undersrc/daemon/so both sides reach them at the composition root and repoints the client at the relocated modules. The client keeps reading the canonicalDaemonRequest/DaemonResponsevocabulary fromdaemon-request.tsas a type-only import.Adds gate R78
daemon-client-entry: a runtime (value/dynamic) import of a daemon module by the client is red, an unrecorded type import is red, and a recorded edge the tree no longer imports is stale — so the residue (five type-onlydaemon-request.tsreads) can only shrink.daemon-modularitynow skipssrc/daemon-client/so the two gates never own one edge.Review follow-ups:
src/daemon/config.tsno longer re-exports the shared leaf and every importer readssrc/daemon-resolution.tsdirectly (the re-export grewsrc/cli.ts's eager closure 295→296 against ADR 0019), and the mutation lane's subprocess exclusion followsdaemon-process-takeover.test.tstosrc/__tests__/.62 files touched. Production sources (
src+scripts, excluding tests and fixtures, rename-aware): +194 / −389, net −195. No behavior change; renames are content-preserving. Part of #2542. Closes #2559.Validation
Head
3e7bd6f15a, merge-base730b20149e. Green:eager-closure-budgets(610,src/cli.tsback to 295),check:layering(incl. R78 planted + stale proofs),check:fallow(0 issues in changed files, 0 stale),check:daemon-wire-compat+ wire-compat vitest (protocol unchanged, 8 moved, 0 changed — digests identical), fulltest:unit(1299 files / 10033 tests),typecheck,lint,build. The CI Size report shows +320 B unpacked and slightly faster startup.pnpm check:affected --runfails on two steps, both external to this change:lintemits no findings and aborts under the parallel fan-out (pnpm lintis exit 0), andmutation-model("a kernel is owned by tests that reach it indirectly") is already red at merge-basemain— a capture-kitscroll-edge-statereachability issue unrelated here. No rebase: the only file upstream also touched ischeck.ts, in a comment block. A serialized CI run is authoritative.