Repository navigation
Closed
Labels
Description
Purpose
Five daemon files import src/runtime.ts, which imports the command barrel with a value import:
// src/runtime.ts
import { bindCommands, type BoundAgentDeviceCommands } from './commands/index.ts';The value closure of src/runtime.ts is 122 files, 48 of them under src/commands/. The daemon's total value closure is 717 files and carries 121 src/commands/** files — roughly the entire commands zone (140 files, 21k LOC) — plus 17 root flat files. The daemon loads a command surface it does not dispatch through, and every change in commands is potentially a daemon-restart-cost event.
Umbrella: #2545. Chosen first because it is the only child that changes what the daemon actually loads, and because #2469 (eager-closure budget tolerance) is unblocked by cutting closure, not by adding budget.
Required behavior
src/runtime.tskeeps its public shape:AgentDevice,createAgentDevice,createMemorySessionStore,localCommandPolicy,restrictedCommandPolicy, and the re-exported command types. No consumer-side API change is part of this issue.- Daemon consumers of
src/runtime.tstake the specific declarations they use through their owning module or contract, not through the runtime facade. Determine the used symbol set per importer before choosing the seam; do not invent an interface wider than the symbols in use. - The barrel
src/commands/index.tseither stops being the value entry for runtime binding, or the binding moves to the composition root that needs it. One construction path, no second registry.
Completion conditions
- Value-only transitive closure from
src/daemon/**contains zero files undersrc/commands/. Measured with a probe overscripts/layering/model.tsas described in the parent, and reported in the PR. src/runtime.tshas no value edge intosrc/commands/**, or is no longer reachable fromsrc/daemon/**at all.- No new eager work: the eager-import-closure budgets for the daemon entry surfaces do not rise.
- R4 stays 0, R5 stays 0, R6 does not grow past the ratchet.
Out of scope
- Repackaging
src/commandsas a workspace package. That decision needs thecli-schemaorientation settled first (sibling child). - Any change to the command descriptor registry or the
command-registrypackage.
Dependencies
- None. Wave A, independent branch.
Activity
thymikee commentedon Sep 13, 2026
Closure measurement: the runtime.ts cut alone does not reach the completion condition
Probe over
scripts/layering/model.ts(value edges only, static, fromsrc/daemon/**) ate6f288012b:src/commands/**filessrc/runtime.ts → commands/index.tsonlycli-schema/command-schema.tsimportsThe second path is
src/daemon → src/cli-schema/command-schema.ts → src/commands/command-metadata.ts → src/commands/family/registry.ts → every command family. Two daemon files hold it, one symbol each:src/daemon/request-execution-scope.tstakesapplyCommandDefaults. It resolves the full per-command schema, which is authored inside the command facets. Exactly one command declaresdefaultstoday (app,appsFilter), andsrc/cli/parser/args.tsalready applies the same defaults on the CLI side.src/daemon/session-action-recorder.tstakesrecordedFlagKeys. That function lives insrc/commands/cli-grammar/flag-registry.tsand its closure is only the fourflag-definitions-*.tsfiles plusflag-types.ts.So "zero
src/commands/**files" needs these two edges cut as well. Either this issue owns them (importrecordedFlagKeysfrom the flag registry directly and take the daemon-side defaults application through something that does not resolve the whole facet table), or the condition is relaxed here and #2543 owns it. I have posted the same data on #2545 and #2543 so the sequencing is decided in one place.thymikee commentedon Sep 13, 2026
Completion contract: the achievable floor is 34, not 0 — needs a decision before #2548 can close this
PR #2548 ships the
src/runtime.tscut. Measured value-only closure fromsrc/daemon/**, with the change in place:src/commands/**9aa6465768)command-schema.tsedgesThe issue's probe of 75 assumed nothing replaces the barrel. It cannot: the daemon calls
capture.snapshot/diffSnapshot/screenshot,selectors.find/get/is/waitandinteractions.gesture/click/press/fill/hover/settleObservation, so the 33-34 files implementing those three families return the moment a scoped binder replacescreateAgentDevice. That residue is the daemon's own dispatch surface, not accidental coupling.Two consequences:
src/commands/**in the daemon closure" is only reachable if the daemon stops executing commands in-process. Proposed replacement condition: the daemon reaches only the command families it dispatches through (capture,selectors,interactions), imports no all-family barrel, and holds 0src/commandsfiles outside those families plus whatever refactor(cli-schema): orient the schema layer below commands #2543 resolves.recordedFlagKeyscannot be imported fromcommands/cli-grammar/flag-registry.tsby the daemon. That is a directdaemon → commandsvalue edge and R2commands-floorrejects it (scripts/layering/zone-policy.ts:47). The symbol has to move down topackages/command-registry, which is refactor(cli-schema): orient the schema layer below commands #2543's "flag grammar goes down" step — so this issue should not own that edge.Suggest: #2548 merges as the runtime split, the condition above replaces the zero, and the remaining 74-file path is #2543's.
refactor(daemon): bind only the command families the daemon dispatche…
thymikee commentedon Sep 14, 2026
Closing on the decision above: the completion condition is the dispatched-families invariant, not zero. #2548 delivered the runtime split, #2562 cut the second path through
cli-schema/command-schema.ts. At775163bb35the daemon reachessrc/commandsonly throughsrc/runtime-command-surface.ts, and the closure holds 34 files (30 under*/runtime/**, 4 shared runtime helpers), no facet, reader, formatter, or barrel.src/runtime.tskeeps its public shape. Umbrella body updated with the same wording.