refactor(mcp): project command output schemas from their owning family

Merged
TH
2mo ago
+222-75

Summary

src/mcp/command-output-schemas.ts — 912 lines of hand-authored per-command MCP outputSchemas, churned 11 times in 200 commits because a result-shape change is edited three layers from the command owning it. Its docblock promised that "selected executable contracts can project their colocated schema into this map"; the seam did not exist. This builds it and migrates one family.

The replay schemas now live in src/commands/replay/index.ts — the descriptors' ownerFiles for both commands — projected in via a trailing spread; deriveSettleObservationSchemas is untouched and still runs last. Shared builders moved to src/commands/command-input.ts, which already exported three. Not placed in @agent-device/contracts: JsonSchema is declared in host-layer command-contract.ts, which contracts may not import. File drops 912 → 863; net repo +114.

Validation

Tested d8c74058e0. All 32 published schemas sha256-identical to origin/main. Non-vacuity, each reverted: renaming a family key yields TS2561 and TS2741 against Record<keyof CommandResultMap, JsonSchema>; a re-hand-authored entry before the spread yields TS2783; a second family claiming replay, or a hand entry shadowing it after the spread, fails the new family test.

Eager closure measured per placement: all 341 entry surfaces unchanged. A +22 on one non-entry intermediate was already-eager at origin/main. No allowlist or baseline added. check:quick, mcp-metadata, daemon-wire-compat, layering, command-docs, production-exports, bundle-owner-files and check:affected --run pass at this SHA.

Risks: no live MCP client validated structuredContent — GitHub owns that lane. Cross-family shadowing is guarded by a test enumerating the projected families and asserting reference-equality into the composed map; registering there is the migration step, and a family skipping it is unchecked.