Skip to content

id(world_caps): parse_wants validates a last-wins collapse — duplicate keys bypass the version check and the 64-entry bounds (residual door of #6501/#6520) #7621

Closed

Description

@dezren39

Problem

parse_wants — the checked gate for a world program's wants document — parses with a bare serde_json::from_str, so duplicate object keys collapse last-wins before any of its checks run. It is the one program-output gate in pkgs/id that was not migrated to the duplicate-key-refusing helper built for exactly this class.

Evidence (main 0a27a7f19fab91b9489932a64fc03479f46bcba5):

Verified reproduction

Probe on the laptop, ~/git/fleet/probe-wants-dupkeys (byte-identical copies of the real world_caps.rs and json_unique.rs, md5 b1b98dcde602952c946e9213b86d0797 / eecf91f884b0f833a019c03c8920f190 at the main commit above; controls pass):

  • Control {"v":2} → Err(unsupported wants version 2); control 65 subscriptions → Err(wants has more than 64 subscriptions); control valid document → Ok. The gates work on documents without duplicate keys.
  • {"v":2,"v":1} → parse_wants = Ok — the version gate never sees the v:2 the document as written declares first; it validates only the collapsed v:1. (Reverse order {"v":1,"v":2} errors — the verdict depends on key order, i.e. on the collapse, not on the document.)
  • {"subscribe":[<65 entries>],"subscribe":["players"]} → parse_wants = Ok(subscribe=1) — the 64-entry bound counts only the collapsed second array; the 65-entry array in the document as written is never counted.
  • {"requests":[{"id":"r1","cap":"time.now","cap":"chat.say"}]} → parse_wants = Ok — inside one request object the cap collapses, so the capability the host acts on is not the only capability the document names; a strict reader and this gate disagree about what was requested.
  • Contrast: parse_json_without_duplicate_keys rejects every duplicate-key text above with duplicate JSON object key "v" / "subscribe" / "cap".

Why it matters

This is the residual door of #6501/#6520 in the capability path: parse_records was hardened because a collapsed document lets a program publish records the caps never counted; the same program's wants document still gets validated, counted, and granted from a collapse. A wants document that two readers parse differently is a grant-confusion primitive — audits, logs, or a second implementation that reads the document as written (or first-wins) see different subscriptions, a different version, and different request caps than the host executes — and the entry-count bounds that exist to bound program requests can be hidden behind a duplicate key.

Acceptance criteria

  • parse_wants refuses any document containing a duplicate object key at any depth, in the module's existing error vocabulary (parse through crate::json_unique::parse_json_without_duplicate_keys, as parse_records does).
  • Regression tests in world_caps cover at least: duplicate v in both orders, duplicate subscribe hiding an over-limit array, duplicate cap inside a request object — each must error; the existing valid/invalid single-key controls keep their current verdicts.
  • Audit the sibling program-output gate parse_surface (pkgs/id/crates/id-core/src/world_presentation.rs:435, same bare-from_str + version-check shape) and either migrate it in the same change or record why it is out of scope on this issue.

Activity

  1. added
    kind/bugSomething isn't working (prefixed form of the classic bug label)
    task/small-fixQueue packet kind: bounded fix with reproduction and targeted tests
    on Nov 8, 2026
  2. developing-today commented on Nov 8, 2026

    @developing-today
    Contributor
  3. added
    source/creatorFiled by the new-issue-creator job
    priority/normalOrdinary priority (the default)
    app/idPackage/app: id (pkgs/ or apps/ in this repo)
    effort/xsTrivial: expected under 30 minutes of work
    on Nov 8, 2026
  4. dezren39 commented on Nov 8, 2026

    @dezren39
    MemberAuthor

    🤖 Agent note · filed

    • Agent: new-issue-creator (new-issue-creator-code-a)
    • Session / ID: cron new-issue-creator-code-a run 2026-11-08T09:57Z
    • Found via: filed this run
    • Task: parse_wants duplicate-key collapse — verified this run on the laptop at main 0a27a7f (probe ~/git/fleet/probe-wants-dupkeys, real modules md5-checked; controls pass, duplicate "v"/"subscribe"/"cap" all accepted by the gate, all rejected by the Design: a duplicate key is a parse error — one duplicate-key refusal contract for pkgs/id's checked JSON gates #6520 helper)
    • Expectation: effort/xs — one-line gate migration to parse_json_without_duplicate_keys plus regression tests; self-solving this run under the guarded trivial-fix protocol
    • Links: probe ~/git/fleet/probe-wants-dupkeys (laptop)
  5. dezren39 commented on Nov 8, 2026

    @dezren39
    MemberAuthor

    🤖 Agent note · picked up

    • Agent: new-issue-creator (new-issue-creator-code-a)
    • Session / ID: cron new-issue-creator-code-a run 2026-11-08T09:57Z
    • Found via: self-assigned during new-issue-creator-code-a run (filed this run; guarded trivial self-solve, lifecycle protocol §4 — no safety labels, no queue task created)
    • Task: migrate parse_wants to parse_json_without_duplicate_keys and add the duplicate-key regression tests named in the acceptance criteria
    • Expectation: effort/xs — done = PR merged with the world_caps tests green on the laptop and on merged main
    • Links: branch creator-a/7621-wants-dupkeys (laptop worktree)
  6. added
    work/self-assignedAn agent grabbed this item directly, outside the queue
    and removed on Nov 8, 2026
  7. dezren39 commented on Nov 8, 2026

    @dezren39
    MemberAuthor

    🤖 Agent note · picked up (audit record for acceptance criterion 3)

    • Agent: new-issue-creator (new-issue-creator-code-a)
    • Session / ID: cron new-issue-creator-code-a run 2026-11-08T09:57Z
    • Found via: self-assigned during new-issue-creator-code-a run
    • Task: sibling-gate audit — parse_surface (pkgs/id/crates/id-core/src/world_presentation.rs:435) is recorded OUT OF SCOPE for this fix, deliberately: it is a presentation decoder, not a checked gate in the Design: a duplicate key is a parse error — one duplicate-key refusal contract for pkgs/id's checked JSON gates #6520 sense. It validates no grant, counts nothing, stores and forwards nothing; unrecognized or malformed documents fall back to legacy plain-text rendering (Ok(None)) by design, for compatibility with untagged program views. Routing it through the duplicate-key helper would silently change that compat contract (a duplicate-key screen document would render as text, or error where the fallback promises text) — a rendering-compat decision of its own, not a rider on a capability-gate fix. If that decision is ever taken, it should be filed and decided on its own evidence.
    • Expectation: effort/xs — this issue's fix covers parse_wants only
    • Links: branch creator-a/7621-wants-dupkeys
  8. added a commit that references this issue on Nov 8, 2026
  9. dezren39 commented on Nov 8, 2026

    @dezren39
    MemberAuthor

    🤖 Agent note · done

    • Agent: new-issue-creator (new-issue-creator-code-a)
    • Session / ID: cron new-issue-creator-code-a run 2026-11-08T09:57Z
    • Found via: filed this run; self-assigned during new-issue-creator-code-a run
    • Task: parse_wants now parses through parse_json_without_duplicate_keys; duplicate-key regression test added (duplicate v both orders, duplicate request cap, duplicate args key, over-limit subscribe array hidden behind a duplicate key)
    • Expectation: met — PR fix(id): parse_wants refuses duplicate JSON keys (#7621) #7623 merged as 165b652; cargo test -p id-core 329 passed on the branch, fmt clean, and the new test re-verified green on merged main (165b652). Issue auto-closed by the PR's Fixes marker. parse_surface audit outcome is recorded in the earlier note on this issue (out of scope, with rationale). No queue packet (guarded self-solve, lifecycle protocol §4).
    • Links: PR fix(id): parse_wants refuses duplicate JSON keys (#7621) #7623 · probe ~/git/fleet/probe-wants-dupkeys (laptop)
  10. dezren39 commented on Nov 8, 2026

    @dezren39
    MemberAuthor

    🤖 Agent note · done (correction: duplicate of #6499)

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    app/idPackage/app: id (pkgs/ or apps/ in this repo)effort/xsTrivial: expected under 30 minutes 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 jobstatus:donetask/small-fixQueue packet kind: bounded fix with reproduction and targeted tests

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions