Skip to content

Bump HOST_DAEMON_PROTOCOL_VERSION to 289 and guard wire schemas against unbumped drift - #8575

Open
lanjak wants to merge 1 commit into
get-bb:mainfrom
lanjak:lanjak/fix-8565-bump-protocol-version-and-add-wire-sche-thr_v5srfbpjsf
Open

lanjak wants to merge 1 commit into
get-bb:mainfrom
lanjak:lanjak/fix-8565-bump-protocol-version-and-add-wire-sche-thr_v5srfbpjsf

Conversation

@lanjak

@lanjak lanjak commented Dec 2, 2026 •

Copy link
Copy Markdown
Contributor

Human comments

What was wrong

HOST_DAEMON_PROTOCOL_VERSION (protocol.ts#L1) is the only wire-compatibility gate between the server and enrolled host daemons, and contract.test.ts only asserted the hardcoded version literal (288). Wire schema and constant changes could therefore merge without bumping HOST_DAEMON_PROTOCOL_VERSION, leaving enrolled daemons passing the version check and failing Zod validation without triggering self-update. Investigation report: https://get-bb.github.io/reports/issues/8565.html

What changed

  • packages/host-daemon-contract/src/protocol.ts: bumped HOST_DAEMON_PROTOCOL_VERSION from 288 to 289 so any drifted <= 288 daemons trigger self-update.
  • packages/host-daemon-contract/test/wire-contract-hash.ts: added WIRE_CONTRACT_BASELINE ({ version: 289, hash }), createDefaultWireContractInput(), and computeWireContractHash() computing a deterministic SHA-256 over a recursively key-sorted JSON snapshot of:
    • every hostDaemonCommandRegistry entry (type, transport, retryable, flushEventsBeforeResult, envLane, request schema, resultSchema),
    • HOST_DAEMON_SETTLED_COMMAND_TYPES and HOST_DAEMON_ONLINE_RPC_COMMAND_TYPES,
    • all exported ZodType schemas from src/index.ts, src/workspace.ts, serverMoveCommandSchemas, serverMoveResultSchemas, desktopBrowserCommandSchemas, and desktopBrowserResultSchemas (using z.toJSONSchema(..., { unrepresentable: "any", io: "input", override }) with "x-zod-custom": true so Uint8Array / custom schemas serialize safely and stay distinct from z.unknown()),
    • wire constants (HOST_ARTIFACT_MAX_BYTES, HOST_FILE_CHUNK_MAX_BYTES, HOST_FIND_GIT_REPOS_*, HOST_DAEMON_TERMINAL_EXIT_RETENTION_MS, error codes, WS resume constants), excluding HOST_DAEMON_PROTOCOL_VERSION itself.
  • packages/host-daemon-contract/test/contract.test.ts: updated version assertions to 289 (288 rejected), added the baseline drift guard asserting WIRE_CONTRACT_BASELINE.version === HOST_DAEMON_PROTOCOL_VERSION and computeWireContractHash() === WIRE_CONTRACT_BASELINE.hash, and added mutation tests proving field, enum, and constant edits change the hash.
  • Docs: none updated; AGENTS.md already specifies bumping HOST_DAEMON_PROTOCOL_VERSION on wire changes.

Wire change: HOST_DAEMON_PROTOCOL_VERSION bumped 288 -> 289. node packages/plugin-sdk/scripts/check-npm-version-guard.mjs passed with no PLUGIN_SDK_VERSION bump needed.

Design choice: hash the full wire surface named in AGENTS.md (session payloads, WebSocket messages, host RPC commands/results, and wire constants) inside contract.test.ts with a checked-in { version, hash } baseline and no separate --check script or generated module. Precedent: AGENTS.md (wire-bump rule and no generated/--check modules), packages/plugin-sdk/scripts/check-npm-version-guard.mjs (guarding the full effective surface rather than a narrow literal), and fba25ee0bc (plain Vitest drift test). Trade-off: additive optional fields also trip the hash, forcing an explicit decision to either bump HOST_DAEMON_PROTOCOL_VERSION or intentionally update the baseline alongside a compatibility test; pure semantic-only changes that leave schemas and constants identical cannot be caught by a schema hash. The alternative is comparing against the published npm package (like check-npm-version-guard.mjs) or hashing only breaking fields/registry entries. A maintainer can ask for a different choice in a comment or push commits to this branch.

How you verified

Base commit: origin/main f5af70c9c5.

Case Before (origin/main) After (9de996be30)
Wire schema field/enum or wire constant changed without bumping HOST_DAEMON_PROTOCOL_VERSION contract.test.ts passes silently Fails drift guard with computed hash and bump instructions
Mutating command request field, WS enum value, or HOST_FILE_CHUNK_MAX_BYTES Untested Proven to change computeWireContractHash()
Daemon at protocol 288 Accepted Rejected (isCompatibleHostDaemonProtocolVersion(288) === false)

CI parity command:
pnpm exec turbo run typecheck test lint lint:type-aware --filter=@bb/host-daemon-contract --continue

  • typecheck, lint, lint:type-aware: 0 warnings, 0 errors.
  • test: 6/7 files passed (99/100 tests, including 58/58 in contract.test.ts; only payload-size.test.ts failed locally due to Node 26 zlib gzip byte-count mismatch).
  • node packages/plugin-sdk/scripts/check-npm-version-guard.mjs: passed.

Fixes #8565

AGENT GENERATED

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

host-daemon-contract: wire schema changes merged without HOST_DAEMON_PROTOCOL_VERSION bumps; literal-only guard misses drift

1 participant