Repository navigation
Description
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):
pkgs/id/crates/id-core/src/world_caps.rs:733—pub fn parse_wants(text: &str);:738—let value: serde_json::Value = serde_json::from_str(text).context("wants is not JSON")?;Every check after this line (thevversion check, theMAX_WANTS_ENTRIES = 64subscription/request counts at:752/:771, per-entry id/cap validation, args bounds) observes only the collapsed document.- The sibling gate was migrated:
pkgs/id/src/world/mod.rs:1951-1953—parse_recordscarries the comment "A duplicate key is a parse error (Design: a duplicate key is a parse error — one duplicate-key refusal contract for pkgs/id's checked JSON gates #6520): the caps below must see the document as written, never a last-wins collapse of it" and parses throughid_core::json_unique::parse_json_without_duplicate_keys(pkgs/id/crates/id-core/src/json_unique.rs:13; design Design: a duplicate key is a parse error — one duplicate-key refusal contract for pkgs/id's checked JSON gates #6520, first landed for id(world_session): first-frame and joined-frame parsers collapse duplicate JSON keys before their checks — a hidden first type/world/capability value is never seen, and the sibling session paths reject the same bytes #6501).pkgs/id/src/world_records.rs:274uses the helper too. The module doc injson_unique.rsstates the rule: "Every checked JSON gate inpkgs/idparses through this helper so no gate ever validates, counts, stores, or forwards a collapsed (last-wins) document." - Callers:
pkgs/id/src/world/actor.rs:662and:1209feed program output (plaza_wants) throughparse_wants. The program is sandboxed, untrusted code; itswantsdocument decides which capabilities the host grants and executes.
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 thev:2the document as written declares first; it validates only the collapsedv: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 thecapcollapses, 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_keysrejects every duplicate-key text above withduplicate 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_wantsrefuses any document containing a duplicate object key at any depth, in the module's existing error vocabulary (parse throughcrate::json_unique::parse_json_without_duplicate_keys, asparse_recordsdoes).- Regression tests in
world_capscover at least: duplicatevin both orders, duplicatesubscribehiding an over-limit array, duplicatecapinside 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
developing-today commentedon Nov 8, 2026
CODE-2288
dezren39 commentedon Nov 8, 2026
🤖 Agent note · filed
dezren39 commentedon Nov 8, 2026
🤖 Agent note · picked up
dezren39 commentedon Nov 8, 2026
🤖 Agent note · picked up (audit record for acceptance criterion 3)
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.parse_wantsonlyMerge pull request #7623 from developing-today/creator-a/7621-wants-d…
dezren39 commentedon Nov 8, 2026
🤖 Agent note · done
dezren39 commentedon Nov 8, 2026
🤖 Agent note · done (correction: duplicate of #6499)
parse_surfacegate recorded as an open audit item in an earlier note on this issue is already tracked as id(world_presentation): parse_surface collapses duplicate JSON keys before its checks — a forbidden version, width, lines, or rows hidden behind a duplicate is accepted #6491.