Repository navigation
Description
Summary
The TypeScript port of the shell contract checker (pkgs/id/web/src/shell-contract.ts) never validates the contract document itself. The Rust original parses the document eagerly — ShellContract::parse runs every field of every frame through Field::try_from and refuses the whole document, naming frame.field, if any field type is unknown. The TS port has no parse/validate entry point at all: consumers JSON.parse the document and cast it to ShellContract (as world-contract.test.ts does), and the only validation is parseField, called lazily inside checkFields for the fields of the one frame being checked — where it throws an uncaught Error instead of returning a Check result or failing at load.
So a contract document with one bad field type (a typo like u65 in a future revision) is silently accepted by the TS checker: frames of every other type check normally, and the first frame of the affected type crashes the checker (the throw propagates straight out of checkClientFrame / checkServerFrame, and out of Conformance.client() / .server(), which call them without a guard) instead of producing a violation or a load error.
Evidence (verified this run, main 06be46dd)
Probe on the laptop (~/git/fleet/probe-2026-10-30-laneA-shellcontract/, Bun; verbatim shell-contract.ts sha256 02baac39…, identical to main, plus the real contract/shell-contract.v1.json; one field type mutated to u65 in client_frames.join.capability and server_frames.view.sequence):
baseline join: {"ok":true,"type":"join"}
unrelated chat vs broken contract: {"ok":true,"type":"chat"}
join vs broken THREW: unknown field type `u65`
view vs broken THREW: unknown field type `u65`
Code facts:
- TS:
parseField(web/src/shell-contract.ts:69) throwsunknown field type; its only caller ischeckFields(:165), per-field, per-frame-check. No exported parse/validate function exists;ShellContractis a bare type, so a malformed spec for a frame type that is never checked never surfaces at all. - TS:
Conformance.client(:257) and.servercall the checkers unguarded, so the throw escapes the session checker rather than landing inviolations. - Rust:
ShellContract::parse(src/shell_contract.rs:305) →frames()(:273) →Field::try_from(:164) validates every field of every client and server frame at load and fails withframe.field: unknown field type \…`before any frame is checked. The embedded contract goes through the same parse (ShellContract::embedded`).
Scope honesty: like #1441 (the u64-cap parity defect in the same file), no production web code imports the TS checker today — only world-contract.test.ts. This is a correctness/parity defect in the conformance library before it gains consumers, not a live outage — hence priority/low. It is distinct from #1441: that is about integer ranges at check time; this is about when and how a malformed contract document is rejected.
Why it matters
The contract's purpose (module docs, both ports) is that a new shell proves conformance by running a check instead of reading host code. A checker that accepts a broken contract document and then crashes mid-session — on exactly the frame type whose spec is broken, with a raw exception instead of a recorded violation — makes a contract-authoring error look like a shell bug and can take down the whole conformance run. The Rust side's fail-fast-at-load behaviour is the contract author's safety net; the port should offer the same.
Acceptance criteria
- The TS port exposes a load-time validation step (e.g.
parseContract/validateContract) that checks every field spec of every client and server frame — type names, and the shorthand?forms — and reports an unknown type naming the frame and field, mirroringShellContract::parse's error shape. -
checkClientFrame,checkServerFrame, andConformancenever throw for a malformed field spec: with an unvalidated contract they return/record a{ ok: false }violation naming the bad spec instead of propagatingparseField's exception (or the checkers validate up front — either way, no uncaught throw). - Regression tests in
world-contract.test.ts: a contract with one field type replaced by an unknown name (a) is rejected by the load-time validation naming that frame/field, (b) does not crash aConformancesession that checks an unrelated frame first and the affected frame second — the affected frame becomes a violation. - The real
shell-contract.v1.jsonstill passes validation and all existing world-contract tests pass unchanged; the Rust checker and the contract JSON are unchanged.
Activity
dezren39 commentedon Oct 30, 2026
🤖 Agent note · filed
36 remaining items
dezren39 commentedon Nov 2, 2026
🤖 Agent note · parked
fix(id): validate shell-contract constraint types at load (#2657)
dezren39 commentedon Nov 2, 2026
Task 5412 resumed by lane A. Prior park premise corrected: PR #4238 is fleet-owned (branch queue/5412-2657-shell-contract-validation for task 5412) — author metadata alone is not Drew-ownership. Fresh review found one undispositioned Codex P2 (malformed enum constraint passes load, then checkValue throws); fixed in 04af08e with regression tests, 21/21 world-contract tests pass on laptop. Awaiting a clean Codex round on the new head before merge.
fix(id-web): validate shell contract field specs (#4238)
dezren39 commentedon Nov 2, 2026
Task 5412 done: PR #4238 squash-merged (8052d96), #2657 closed. Codex P2 from the first round (malformed enum constraint) fixed in 04af08e with regression tests; second Codex round at that head completed with no findings. Laptop: bun run test -- src/world-contract.test.ts 21/21 pass. CI checks were still QUEUED at merge (known runner backlog); merged under standing merge authority on laptop-verified tests + clean Codex.