refactor(contracts): own the daemon HTTP wire contract so clients stop importing src/daemon - #2322
Conversation
…p importing src/daemon Move the pure wire vocabulary (base path, header names, URL/auth/tenant builders, /health payload) from src/daemon into @agent-device/contracts as the daemon-http subpath, so src/remote and src/cli stop importing daemon server internals. buildDaemonHealthPayload takes the version its caller advertises (R18 keeps host mechanics out of contracts); both callers pass readVersion(). Wire-compat surface, mutation, and ledger references follow the package path.
Size Report
Startup median (7 runs, lower is better):
|
|
Sentinel at 5fc60de: coordinator + independent Terra/high review confirmed a P2 wire-compat gate regression in scripts/wire-compat/model.ts:137-145. Move matching is independent per baseline declaration and does not reserve destinations. Reproduced with the exact-head comparator: released a.ts#sendJson and b.ts#sendJson both digest X; current c.ts#sendJson digest X. Result: both moved, removed=[], failures=[], bumped=false. One destination therefore hides loss of another declaration, weakening the removal/bump rule. Require unambiguous one-to-one matching (or conservatively classify ambiguous sources as removals), plus a regression for two sources/one destination that is red on this head. Preserve the existing unique move and changed-move acknowledgement tests. HTTP constants/builders, health version injection and call sites otherwise preserve wire behavior; exact-head CI is green (17 successful, one skipped), size +14 B. No readiness label until the gate is corrected; no source fixes or merge performed. |
…leased-baseline check file moves Exports map + snapshot gain the daemon-http subpath. The wire ledger re-keys the eight moved declarations (buildDaemonHealthPayload moves with its new caller-supplied version parameter, acked additive). The released-baseline comparison now classifies a baseline declaration that re-appears unchanged at exactly one new path as a move instead of a removal: a file move is not wire surface a released peer stopped sending. A move that changes shape is a change acked at the destination path, and a name still owned by the baseline stays a removal.
5fc60de to
2398c78
Compare
|
Fixed at 2398c78 (amended into the gates commit). Move matching is now one-to-one: Regressions added, red on the prior head:
Verified: 14/14 model fixtures, |
|
Summary
Moves the daemon HTTP wire vocabulary (base path, header names, URL/auth/tenant builders,
/healthpayload) fromsrc/daemoninto@agent-device/contracts/daemon-http, sosrc/remoteandsrc/clistop importing daemon server internals.buildDaemonHealthPayloadnow takes the caller's version (callers passreadVersion()); the moved file imports nothing and the CLI startup closure shrinks by one file. Wire-compat surface, mutation, and ledger follow the package path;DAEMON_RPC_PROTOCOL_VERSIONstays2. Two disclosed gate corrections:scripts/wire-compat/model.ts) now classifies a baseline declaration that re-appears unchanged at exactly one new path as a move; without it the move reads as 8 removals against v0.20.10 and would force the bump the issue forbids. A move that changes shape is an ackable change at the destination key; a name still owned by the baseline remains a removal.node:http(its list is child_process/fs/timers + timers). Anode:httpvalue import is instead caught red bycli-startup-import-closure.test.ts, since the proxy command eagerly evaluates this subpath — verified red both directions.28 files, +282/−106.
Validation
pnpm check:affected --rungreen atb61aff8ba3(all runnable checks passed).5fc60de8d7:pnpm typecheck,pnpm check:layering,pnpm check:daemon-wire-compat(172 declarations, 0 removed, 7 moved),pnpm vitest run packages/contracts test/wire-compat src/__tests__/cli-startup-import-closure.test.ts src/__tests__/upload-client.test.ts src/daemon/__tests__ src/remote(all pass),fallow audit --base origin/main(no issues in 28 changed files), lint/format clean.session-sim-1xcodebuildpkillfromrunner-disposal.tsattributed to an unrelated test by the hermetic-signal guard under high host load. Reproduced identically on pristineorigin/main(4 of 5 full runs fail the same test); passes in isolation — CI's serialized gate is authoritative.Closes #2318