Skip to content

id(shell-contract): parseShellContract never validates top-level fields — missing routing_fields/projection throw TypeError at check time, missing max_frame_bytes silently disables the frame cap #4323

Closed

Description

@dezren39

Problem

parseShellContract in pkgs/id/web/src/shell-contract.ts (line 115) validates every client/server field spec at load — that was the #4238 / #2657 fix, so a malformed spec cannot make checkValue throw later. But it never validates the contract's top-level fields: it checks only that client_frames/server_frames are objects with object fields, then returns value as unknown as ShellContract (line ~141). The Rust checker it ports (pkgs/id/src/shell_contract.rs, RawContract at lines 238–249) requires all of these with no #[serde(default)]: max_frame_bytes: usize, routing_fields: Vec<String>, and projection.redacted_keys: Vec<String>. A contract document the Rust side refuses to load is accepted by the TS side, and the failure surfaces later — as a thrown TypeError instead of a recorded violation, or as a silently disabled check.

Evidence (verified this run)

Probe on the laptop (~/git/fleet/probe-2026-11-02-laneB-shellcontract/, verbatim shell-contract.ts @ main 8052d96f, md5 59dc2d096669f95b8ef29f714d1ea8d2, real contract/shell-contract.v1.json, bun). Controls on the unmodified contract behave: a valid join passes, a 1,100,041-byte frame is rejected with "frame of 1100041 bytes exceeds 1048576", and a world_state frame with seed: 7 is rejected as a projection leak.

With top-level fields removed or mistyped, parseShellContract accepts every variant:

  • routing_fields deleted → checkClientFrame throws TypeError: undefined is not an object (evaluating 'routing.includes') (line 226) instead of returning a Check/recording a violation.
  • projection deleted → checkServerFrame throws TypeError (evaluating contract.projection.redacted_keys, line 298). Same throw when only projection.redacted_keys is deleted.
  • max_frame_bytes deleted → the frame-size cap is silently off: the same 1,100,041-byte frame no longer gets the size error and falls through to field checking ("join has no field pad").
  • max_frame_bytes: -1 → accepted; then every frame is rejected ("frame of 32 bytes exceeds -1"). Rust's usize refuses this document at load.
  • routing_fields: "world" (a string, not an array) → accepted; String.includes then does substring matching, so a frame field named orl is treated as a routing field ("routing field orl must be a string").

Why it matters

The shell contract is the conformance boundary between shell and host: the size cap, the routing-field exemption, and the redacted-key leak check (seed must never reach a session nonzero) are three of its load-bearing checks. All three depend on top-level fields the TS parser never validates, so a truncated, hand-edited, or version-skewed contract document either crashes the checker mid-session with an uncaught TypeError or quietly disables the cap/leak checks — precisely the failure mode #4238 fixed for field specs, one level up.

Acceptance criteria

  • parseShellContract rejects, with a named error at load time: missing/non-object projection, missing/non-string-array projection.redacted_keys, missing/non-string-array routing_fields, and missing/non-finite/negative max_frame_bytes.
  • After the fix, no input to parseShellContract can make checkClientFrame/checkServerFrame/Conformance throw a TypeError from these fields; malformed contracts fail at parse, malformed frames return violations.
  • Regression tests in pkgs/id/web/src/world-contract.test.ts cover each case above (missing routing fields, missing projection, missing redacted_keys, missing/negative frame cap, string routing fields), mirroring the existing field-spec tests added by fix(id-web): validate shell contract field specs #4238.
  • The real contract/shell-contract.v1.json still parses and all existing shell-contract tests pass.

Activity

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

    @dezren39
    MemberAuthor

    🤖 Agent note · filed

  3. added
    work/assignedQueue worker lifecycle state
    queue/claimedQueue worker lifecycle state
    and removed on Nov 2, 2026
  4. dezren39 commented on Nov 2, 2026

    @dezren39
    MemberAuthor

    Picked up (task 6190, lane B, triage): revalidating #4323 against fresh source — verifying parseShellContract top-level validation gap in pkgs/id/web/src/shell-contract.ts and spot-checking the reported TypeError reproduction on the laptop before routing a fix task.

  5. 265 remaining items

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

    @dezren39
    MemberAuthor

    🤖 Agent note · claimed

  8. added a commit that references this issue on Nov 5, 2026
  9. dezren39 commented on Nov 5, 2026

    @dezren39
    MemberAuthor

    🤖 Agent note · done

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/normalOrdinary priority (the default)source/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