GeezerVison is showing github.com — 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) · Issue #7621 · developing-today/code
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) #7621DescriptionProblem
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 (the v version check, the MAX_WANTS_ENTRIES = 64 subscription/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_records carries 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 through id_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:274 uses the helper too. The module doc in json_unique.rs states the rule: "Every checked JSON gate in pkgs/id parses through this helper so no gate ever validates, counts, stores, or forwards a collapsed (last-wins) document."
- Callers:
pkgs/id/src/world/actor.rs:662 and :1209 feed program output (plaza_wants) through parse_wants. The program is sandboxed, untrusted code; its wants document 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 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.
Activitydeveloping-today commented on Nov 8, 2026 dezren39 commented on Nov 8, 2026 🤖 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)
dezren39 commented on Nov 8, 2026 🤖 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)
dezren39 commented on Nov 8, 2026 🤖 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
dezren39 commented on Nov 8, 2026 🤖 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)
dezren39 commented on Nov 8, 2026 🤖 Agent note · done (correction: duplicate of #6499)
- Agent: new-issue-creator (new-issue-creator-code-a)
- Session / ID: cron new-issue-creator-code-a run 2026-11-08T09:57Z (remediation pass, same run)
- Found via: filed this run
- Task: correction to this issue's filing record — this issue duplicates the already-open id(world_caps): parse_wants collapses duplicate JSON keys before its checks — a forbidden version, cap, id, or list size hidden behind a duplicate is accepted #6499 ("id(world_caps): parse_wants collapses duplicate JSON keys before its checks"), filed earlier from the Design: a duplicate key is a parse error — one duplicate-key refusal contract for pkgs/id's checked JSON gates #6520 design inventory. This run's dedup search naming id(world_caps): parse_wants collapses duplicate JSON keys before its checks — a forbidden version, cap, id, or list size hidden behind a duplicate is accepted #6499 completed after 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 had been filed and its guarded self-solve was under way, so the duplicate was only caught when the search result landed. The fix that closed this issue (PR fix(id): parse_wants refuses duplicate JSON keys (#7621) #7623) is the fix id(world_caps): parse_wants collapses duplicate JSON keys before its checks — a forbidden version, cap, id, or list size hidden behind a duplicate is accepted #6499 asked for; the three acceptance pins unique to id(world_caps): parse_wants collapses duplicate JSON keys before its checks — a forbidden version, cap, id, or list size hidden behind a duplicate is accepted #6499 were added in PR test(id): pin the #6499 duplicate-key forms for parse_wants #7627, and id(world_caps): parse_wants collapses duplicate JSON keys before its checks — a forbidden version, cap, id, or list size hidden behind a duplicate is accepted #6499 is now closed complete. This issue remains closed — as the duplicate; id(world_caps): parse_wants collapses duplicate JSON keys before its checks — a forbidden version, cap, id, or list size hidden behind a duplicate is accepted #6499 is the canonical record. One related correction: the sibling
parse_surface gate 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.
- Expectation: met — canonical issue id(world_caps): parse_wants collapses duplicate JSON keys before its checks — a forbidden version, cap, id, or list size hidden behind a duplicate is accepted #6499 closed with full evidence
- Links: id(world_caps): parse_wants collapses duplicate JSON keys before its checks — a forbidden version, cap, id, or list size hidden behind a duplicate is accepted #6499 · PR fix(id): parse_wants refuses duplicate JSON keys (#7621) #7623 · PR test(id): pin the #6499 duplicate-key forms for parse_wants #7627 · 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
MetadataMetadataDevelopmentNo branches or pull requestsIssue actions
|