Skip to content

Design: a duplicate key is a parse error — one duplicate-key refusal contract for pkgs/id's checked JSON gates #6520

Open
1 of 6 issues completed

Description

@dezren39

A duplicate key is a parse error — one duplicate-key refusal contract for pkgs/id's checked JSON gates

Design-architect pass 61 (2026-11-06), audit at origin/main 6046e1d7b.
Full design doc: files/designs/code-duplicate-json-keys.md in the
keep-the-four-repos-healthy goal workspace.

Problem

pkgs/id's checked JSON gates parse first and validate second, and
every parse they use — serde_json::Value, BTreeMap, map-shaped
derived decodes — collapses duplicate object keys last-wins. The
checks therefore run on a collapsed document that is not the document
as written: a forbidden value placed first, hidden behind a benign
duplicate, passes the version gate, the size cap, the count cap, the
control-character refusal and the canonical-form check.

Six filings in three days are one defect: #6473 (parse_records —
oversized value and the MAX_RECORDS count both checked post-collapse),
#6474 (world_fixture::decode — check_keys/check_window see only
the surviving world/fixture/sequence; the header records
object collapses twice), #6491 (parse_surface — even the kind
dispatch is last-wins), #6499 (parse_wants — version, subscription
cap, entry id/cap all read from the collapsed map), #6501 (session
frames — landed via PR #6508), #6504 (Registry::load —
validate_persisted checks the collapsed registry). Decode shapes
even disagree in-tree: #6504's struct decode collapsed a duplicate
world that #6501's sibling derived paths refused. Outside the crate
the stance is already refusal: #6384 (deploy.py) and #6390 (atlas-eval),
both closed.

The contract

A duplicate key is a parse error. A checked JSON gate in pkgs/id
never validates, counts, stores or forwards a collapsed document.

  1. Refusal, naming the key — in the gate's own error vocabulary,
    with the surface's context (fixture line, publications file).
  2. Every depth — not only levels with checked fields: what a gate
    forwards/stores/compares onward is the collapsed Value, so a
    deeper duplicate is the same ambiguity one step later; and no
    serializer can emit a duplicate key, so no legitimate producer is
    affected. This pin supersedes 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's checked-positions-only
    scoping for args interiors (its required refusals are subsumed).
  3. One mechanism — promote fix(id): refuse duplicate JSON keys in world_session first/joined frames (#6501) #6508's landed
    parse_json_without_duplicate_keys (world_session/mod.rs:880:
    every-depth refusal, duplicate JSON object key "k") into one
    shared home in id-core and route every phase through it;
    struct-first gates parse through it and convert. Serde's derived
    duplicate-field behaviour is never the defence (fields-only,
    inconsistent, absent on Value/BTreeMap paths).
  4. Checks see the written document — no check's own logic changes;
    duplicate-free documents parse identically.

Phases (adopt the origins — no parallels)

#6501 is cited as the landed embodiment, not a phase. Open questions
stay in the design doc.

🤖 Filed by the repo design architect (fleet) — origins verified with
laptop probes by their filers; audit and pins are this pass's, against
origin/main 6046e1d7b.

Acceptance criteria

Activity

  1. added
    app/idPackage/app: id (pkgs/ or apps/ in this repo)
    epicMeta-issue grouping multiple items (org Project Type=Epic)
    kind/designA design proposal (design-architect): multi-step, phased, decision-bearing
    on Nov 6, 2026
  2. developing-today commented on Nov 6, 2026

    @developing-today
    Contributor
  3. dezren39 commented on Nov 6, 2026

    @dezren39
    MemberAuthor

    🤖 Agent note · design-architect pass 61 — design filed

  4. added
    priority/highImportant and time-sensitive
    effort/mMedium: expected under 1 day of work
    meta/enrichedIntake review done: acceptance criteria, links, and normalized labels added
    on Nov 6, 2026
  5. dezren39 commented on Nov 6, 2026

    @dezren39
    MemberAuthor

    Intake review

    🤖 Fleet monitor intake (repo-fleet-monitor), 2026-11-06.

  6. added
    queue/queuedHas a queued task in the Supabase agent queue
    task/triageQueue packet kind: verify, reproduce, and route this item
    on Nov 7, 2026
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/mMedium: expected under 1 day of workepicMeta-issue grouping multiple items (org Project Type=Epic)kind/designA design proposal (design-architect): multi-step, phased, decision-bearingmeta/enrichedIntake review done: acceptance criteria, links, and normalized labels addedpriority/highImportant and time-sensitivequeue/queuedHas a queued task in the Supabase agent queuesource/design-architectFiled by the repo design architect jobstatus/needs-triageNot yet triaged; needs a first looktask/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