Repository navigation
Description
Problem
RecordsStore receipt path read_records (pkgs/id/src/world_records.rs:242) re-checks the MAX_RECORD* caps on replicated records — that was the #6483 fix — but it parses each record's value with plain serde_json::from_slice (world_records.rs:269-270) and measures the value's size from the parsed value (world_records.rs:271: serde_json::to_vec(&value) length). serde_json::Value keeps only the last value for a repeated object key, so a duplicate key inside a replicated value silently collapses before the cap is measured:
- A value whose raw bytes exceed
MAX_RECORD_VALUE_BYTES(8192,pkgs/id/src/world/mod.rs:1937) hidden behind a duplicate key — e.g.{"k":"<8292 x's>","k":"small"}(raw 8,3xx bytes) — collapses to{"k":"small"}and passes the receipt cap. - The same bytes are refused on the publish path:
parse_records(world/mod.rs:1946) parses throughid_core::json_unique::parse_json_without_duplicate_keys(id(world): parse_records silently collapses duplicate JSON keys — an oversized value hidden behind a duplicate passes MAX_RECORD_VALUE_BYTES, and the record-count cap is checked after collapse #6473, design Design: a duplicate key is a parse error — one duplicate-key refusal contract for pkgs/id's checked JSON gates #6520: a duplicate key is a parse error at every depth), so the identical duplicate inside a published record is a hard error there.
So the replica receipt gate — the one path that exists because a replicated doc is not trusted (#6483) — accepts a value shape and size the publisher can never produce, and the size it enforces is the collapsed size, not the size of the bytes actually received and stored in the blob. This is the #6473 exploit surviving on the one receipt path #6483 hardened for caps but not for duplicate keys.
Evidence
pkgs/id/src/world_records.rs:269-271—let value: serde_json::Value = serde_json::from_slice(&bytes)...; let size = serde_json::to_vec(&value)...— no duplicate-key refusal; the cap is measured post-collapse.pkgs/id/src/world/mod.rs:1946-1950—parse_recordsroutes throughparse_json_without_duplicate_keyswith the comment "the caps below must see the document as written, never a last-wins collapse of it" (id(world): parse_records silently collapses duplicate JSON keys — an oversized value hidden behind a duplicate passes MAX_RECORD_VALUE_BYTES, and the record-count cap is checked after collapse #6473). That reasoning applies verbatim to receipt.pkgs/id/crates/id-core/src/json_unique.rs— the shared helper already exists inid-core(design Design: a duplicate key is a parse error — one duplicate-key refusal contract for pkgs/id's checked JSON gates #6520);read_recordsdoes not use it. This site should also be dispositioned as a gate in the Phase 4 of #6520 — closing JSON-parse inventory: disposition every serde_json parse site in pkgs/id against the duplicate-key refusal contract #6521 closing inventory.- Existing receipt tests (
world_records.rs,read_records_refuses_an_oversized_valueetc.) cover caps on duplicate-free values only — no duplicate-key case.
Verification (this run, laptop @ de90338)
Probe test added in a laptop worktree (~/git/fleet/probe-readrecords-wt, test probe_read_records_collapses_duplicate_keys_in_a_value, using the module's own write_raw harness against a real in-memory iroh-docs doc):
- Raw duplicate value
{"k":"<8292 x's>","k":"small"}written under keydup:read_recordsreturns Ok withdup = {"k":"small"}— the oversized first value vanished and the collapsed size passed the 8192 cap. - Control:
parse_recordson the same value nested in a records document returns Err (duplicate key refusal). - Control (pre-existing test): a duplicate-free oversized value is refused by
read_records(read_records_refuses_an_oversized_value), so the cap itself works — only the duplicate collapse bypasses it.
Why it matters
read_records is the trust boundary for replicated world state: its whole purpose (#6483) is that a non-conforming or hostile doc cannot smuggle over-cap records into a follower. A duplicate key reopens exactly the hole #6473 closed on the publish side — the checker and the byte stream disagree about the value — and it also means two readers of the same blob can disagree about a record's content (the #6520 contract's core concern).
Acceptance criteria
read_recordsrefuses a record value containing a duplicate object key at any depth, with an error naming the record key (routing the parse throughid_core::json_unique::parse_json_without_duplicate_keysover the value bytes, or an equivalent checked parse).- A duplicate-hidden oversized value (raw bytes >
MAX_RECORD_VALUE_BYTES, collapsed size under) is refused; the value-size cap is evaluated against the document as written, never a collapsed form. - Duplicate-free conforming values — including values at exactly
MAX_RECORD_VALUE_BYTES— still read back unchanged; all existingworld_recordsreceipt tests stay green. - A regression test in the
world_recordstests uses the existingwrite_rawharness with a duplicate-key value and asserts the refusal. - The site is recorded as a gate disposition for the Phase 4 of #6520 — closing JSON-parse inventory: disposition every serde_json parse site in pkgs/id against the duplicate-key refusal contract #6521 inventory.
Activity
developing-today commentedon Nov 6, 2026
CODE-2040
dezren39 commentedon Nov 6, 2026
🤖 Agent note · filed
dezren39 commentedon Nov 7, 2026
Picked up by
repo-worker-code-a— working this now. (Fleet queue fallback mode: the queue backend is down, so this issue's comments carry the claim. The claim stays live whilerepo-worker-code-aposts progress markers; after 30 minutes of silence any other worker may pick this up.)dezren39 commentedon Nov 7, 2026
🤖 Agent note · picked up
repo-worker-code-a(issue id(world_records): read_records collapses duplicate keys inside a replicated value — the #6483 receipt caps measure the collapsed value, so an oversized value hidden behind a duplicate passes, unlike parse_records (#6473) #6634 is the task in fallback mode)queue/queueditems in scan order)read_recordsvalue parsing inpkgs/id/src/world_records.rsthroughid_core::json_unique::parse_json_without_duplicate_keysso duplicate-key values are refused at receipt and the size cap measures the document as written; add thewrite_rawregression testqueue/6634-read-records-duplicate-keys(laptop worktree~/git/fleet/fb-6634), to be created this shiftdezren39 commentedon Nov 7, 2026
Progress from
repo-worker-code-a: verified: read_records still parses with plain serde_json::from_slice on current main (0b8afc9) — issue #6634 live, not landed. Implementing in laptop worktree ~/git/fleet/fb-6634 (branch queue/6634-read-records-duplicate-keys): route the value parse through id_core::json_unique::parse_json_without_duplicate_keys (mirroring parse_records) + write_raw regression tests for a duplicate-hidden oversized value and a small nested duplicate.dezren39 commentedon Nov 7, 2026
Progress from
repo-worker-code-a: targeted_tests_failed (harness, under diagnosis): all 12 world_records tests incl. pre-existing ones fail at write_raw with iroh-docs 'author not found' on the laptop — failure is in the shared test harness before read_records runs, not in the patch. Running the identical suite on a clean-main control worktree (fb-6634-control) to prove pre-existing/environmental vs patch-caused.dezren39 commentedon Nov 7, 2026
Progress from
repo-worker-code-a: targeted_tests_passed: serial run of the full world_records module on the laptop — 15 passed, 0 failed, including both new duplicate-key tests; the parallel-run 'author not found' harness failures reproduce identically on clean main (pre-existing race, not this patch). Committed d4d8cee, branch pushed; opening PR.Merge pull request #6678 from developing-today/queue/6634-read-record…
dezren39 commentedon Nov 7, 2026
🤖 Agent note · done
repo-worker-code-a(issue id(world_records): read_records collapses duplicate keys inside a replicated value — the #6483 receipt caps measure the collapsed value, so an oversized value hidden behind a duplicate passes, unlike parse_records (#6473) #6634 is the task in fallback mode)read_recordsnow routes its value parse throughid_core::json_unique::parse_json_without_duplicate_keys(mirroringparse_records), so a duplicate key at any depth is refused at receipt naming the record key, and theMAX_RECORD_VALUE_BYTEScap measures the document as written. Twowrite_rawregression tests added: a duplicate hiding an oversized value, and a small nested duplicate.2b426f7d0645b22a8f4131f07435f6851be224b0), closing issue id(world_records): read_records collapses duplicate keys inside a replicated value — the #6483 receipt caps measure the collapsed value, so an oversized value hidden behind a duplicate passes, unlike parse_records (#6473) #6634. Codex review on headd4d8cee8d1: completed, zero findings. PR CI checks stayed QUEUED (runner backlog) — merged under standing criteria on laptop verification:cargo test -p id --lib world_records -- --test-threads=1= 15 passed, 0 failed.Node-harness tests intermittently fail atwrite_rawwith iroh-docs "author not found" — reproduced identically on a clean-main control worktree (6 failures there too; serial runs green). Filed separately for the harness race.queue/6634-read-records-duplicate-keys· commitd4d8cee8d1dezren39 commentedon Nov 7, 2026
Released by
repo-worker-code-a(outcome: done). Done: read_records now parses via id_core::json_unique::parse_json_without_duplicate_keys — duplicate keys refused at receipt naming the record key, cap measures the document as written. PR #6678 merged (2b426f7), closing #6634. Laptop: cargo test -p id --lib world_records serial = 15 passed/0 failed (incl. 2 new tests); Codex zero findings; PR CI QUEUED (runner backlog).