Skip to content

id(web): TS shell-contract checker never validates the contract document — one bad field type passes silently for every other frame and throws uncaught on its own #2657

Closed

Description

@dezren39

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) throws unknown field type; its only caller is checkFields (:165), per-field, per-frame-check. No exported parse/validate function exists; ShellContract is a bare type, so a malformed spec for a frame type that is never checked never surfaces at all.
  • TS: Conformance.client (:257) and .server call the checkers unguarded, so the throw escapes the session checker rather than landing in violations.
  • 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 with frame.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, mirroring ShellContract::parse's error shape.
  • checkClientFrame, checkServerFrame, and Conformance never throw for a malformed field spec: with an unvalidated contract they return/record a { ok: false } violation naming the bad spec instead of propagating parseField'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 a Conformance session that checks an unrelated frame first and the affected frame second — the affected frame becomes a violation.
  • The real shell-contract.v1.json still passes validation and all existing world-contract tests pass unchanged; the Rust checker and the contract JSON are unchanged.

Activity

  1. added
    kind/bugSomething isn't working (prefixed form of the classic bug label)
    task/triageQueue packet kind: verify, reproduce, and route this item
    source/creatorFiled by the new-issue-creator job
    priority/lowNice to have; do when convenient
    app/idPackage/app: id (pkgs/ or apps/ in this repo)
    effort/sSmall: expected under 2 hours of work
    on Oct 30, 2026
  2. dezren39 commented on Oct 30, 2026

    @dezren39
    MemberAuthor

    🤖 Agent note · filed

    • Agent: new-issue-creator-code-a (new-issue-creator, lane A)
    • Session / ID: cron new-issue-creator-code-a run 2026-10-30 04:05 CDT
    • Found via: filed this run
    • Task: TS shell-contract port never validates the contract document — a bad field type passes silently for other frames and throws uncaught on its own; Rust original refuses the document at load. Triage packet enqueued for the fix shape (load-time validation + no-throw checkers).
    • Expectation: effort/s — done when the TS port validates the whole contract at load (naming frame/field) and the checkers record violations instead of throwing, with regression tests in world-contract.test.ts.
    • Links: packet packet-2657-triage.json (goal hidden_files); probe on laptop ~/git/fleet/probe-2026-10-30-laneA-shellcontract/; related id(web): TS shell-contract checker rejects valid u64 values above 2^53-1 that the Rust checker accepts (seed, sequence, offset) #1441 (distinct: u64 range parity)
  3. added
    work/assignedQueue worker lifecycle state
    queue/claimedQueue worker lifecycle state
    and removed on Nov 1, 2026
  4. 36 remaining items

  5. added
    queue/parkedQueue task is parked (waiting on CI, time, or an event)
    status/parkedDeliberately paused with a recorded resume condition
    on Nov 2, 2026
  6. dezren39 commented on Nov 2, 2026

    @dezren39
    MemberAuthor

    🤖 Agent note · parked

  7. added
    queue/claimedQueue worker lifecycle state
    and removed
    status/parkedDeliberately paused with a recorded resume condition
    queue/parkedQueue task is parked (waiting on CI, time, or an event)
    on Nov 2, 2026
  8. dezren39 commented on Nov 2, 2026

    @dezren39
    MemberAuthor

    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.

  9. dezren39 commented on Nov 2, 2026

    @dezren39
    MemberAuthor

    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.

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

Metadata

Metadata

Assignees

Labels

app/idPackage/app: id (pkgs/ or apps/ in this repo)effort/sSmall: expected under 2 hours of workkind/bugSomething isn't working (prefixed form of the classic bug label)priority/lowNice to have; do when convenientsource/creatorFiled by the new-issue-creator jobtask/triageQueue packet kind: verify, reproduce, and route this item

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions