Skip to content

id(tag_claims): compacted_claims returns a claim twice when the applied list repeats an ID — the production fold diverges from live_claims on duplicate input #4359

Closed

Description

@dezren39

Summary

compacted_claims — the fold production actually uses — returns a claim twice when its input contains two Applied entries with the same event ID, while the reference fold live_claims returns it once. The module header promises the two folds always agree: "Both give the same result (P5.3, #184)" (pkgs/id/src/tag_claims.rs:21).

Evidence (verified this run, laptop fuzz probe)

  • live_claims (tag_claims.rs:182) collects sets into a BTreeMap keyed by claim ID (:192), so a duplicated ID collapses to one claim (last entry wins).
  • compacted_claims (tag_claims.rs:232) builds its result by iterating applied directly (:281 ff.) and filtering only on the removed set — it never dedupes by ID. Its internal by_id map (:233) dedupes, but the output list does not.
  • Probe (laptop, verbatim tag_claims.rs @ 3d6deeae7, only the Hash/AuthorKey imports stubbed; probe dir ~/git/fleet/probe-2026-11-02-laneB-tagfold/):
    • Randomized DAG fuzz, duplicate-free inputs: 50,000 cases, 0 divergences — the folds agree on well-formed input.
    • Same fuzz with duplicate Applied entries injected: divergences on iteration 4 already — compacted_claims emits the duplicated claim twice, live_claims once.
    • Equivocation case (same ID, values Some("A") then Some("B")): live_claims → 1 claim ("B"); compacted_claims → 2 claims with the same ID, one per spelling.

Why it matters

EventStore::tag_claims (pkgs/id/src/event_store/claims.rs:76) returns compacted_claims output verbatim, and it feeds TagIndex and alias display. A duplicated claim in that output is not cosmetic: aliases_of (pkgs/id/src/aliases.rs) counts claims, so one real claim appearing twice reads as two claims and the view shows the alias as Contested instead of Only — and the tag index carries a phantom second claim. Today the store's caller happens to build applied from a table keyed by event, so duplicates should not occur; but the fold's documented contract is unconditional, nothing in either function states a no-duplicates precondition, and the reference fold already tolerates duplicates. The production fold should not be the fragile one. (Related: #1421 asks for a mutation/planted-bug check for this fold; this is a concrete divergence such a check would catch.)

Acceptance criteria

  • compacted_claims returns at most one claim per claim ID for any input, matching live_claims on duplicate and equivocating inputs (state the chosen winner — the reference fold's last-wins — in the doc comment).
  • The module docs state the input precondition or the dedup behaviour explicitly, so "both give the same result" is true as written.
  • Regression tests in tag_claims.rs: verbatim duplicate Applied set entry, and same-ID entries with different values, asserting both folds agree.
  • Existing tag-claims and event-store claim tests still pass (cargo test for the id lib on laptop/CI).

Activity

  1. added
    kind/bugSomething isn't working (prefixed form of the classic bug label)
    priority/normalOrdinary priority (the default)
    source/creatorFiled by the new-issue-creator job
    task/triageQueue packet kind: verify, reproduce, and route this item
    app/idPackage/app: id (pkgs/ or apps/ in this repo)
    effort/sSmall: expected under 2 hours of work
    on Nov 2, 2026
  2. dezren39 commented on Nov 2, 2026

    @dezren39
    MemberAuthor

    🤖 Agent note · filed

    • Agent: new-issue-creator job (new-issue-creator-code-b, Lane B)
    • Session / ID: cron new-issue-creator-code-b run 2026-11-02 06:20 CST
    • Found via: filed this run
    • Task: Filed after verifying on the laptop (verbatim tag_claims.rs @3d6deeae7, probe ~/git/fleet/probe-2026-11-02-laneB-tagfold/): 50,000 duplicate-free fuzz cases show live_claims and compacted_claims agree, but any repeated Applied ID makes compacted_claims (the production fold, event_store/claims.rs:76) emit the claim twice while live_claims emits it once; an equivocating same-ID pair yields two claims with one ID. Enqueued as a repo-task/v1 triage packet on queue repo-health-code-pilot.
    • Expectation: effort/s — triage confirms the reproduction, then the fix dedupes compacted_claims' output by claim ID (last-wins, matching the reference fold), documents the contract, and adds the two regression tests.
    • Links: issue body (probe output), packet creator-b-2026-11-02-0620/packets/packet-4359-triage.json
  3. dezren39 commented on Nov 2, 2026

    @dezren39
    MemberAuthor

    Picked up: OpenChamber scheduled lane claimed triage task 6227.

  4. added
    work/assignedQueue worker lifecycle state
    queue/claimedQueue worker lifecycle state
    and removed on Nov 2, 2026
  5. 5 remaining items

  6. dezren39 commented on Nov 2, 2026

    @dezren39
    MemberAuthor

    Done: Triage task 6227 completed as triaged; scoped fix task 6236 is queued.

    • Agent: repo-worker-code (OpenChamber scheduled lane; session ses_e5e63b9e96dffetVlKEI4z5b0H)
    • Finding: Current-main reproduction passed at 97e3e8e0ac2fb829afa0b8e2eb0645678c22f3fd: duplicate/equivocating IDs make compacted_claims return two claims while live_claims returns one (last-wins).
    • Verification: Targeted temporary test passed (1/1); temporary test removed afterward. Task worktree is clean; no implementation or PR was created. Existing full tag_claims/event_store test suite was not run.
    • Routing/labels: Follow-up id(web): redirect to clean URL after bootstrap token exchange (#5746) #6236 adds the dedupe/documentation/regression-test fix; issue labels now show the queued fix (queue/queued, task/fix) with in-progress labels cleared.
    • Bookkeeping: sandbox backlog/sweep log deferred to fleet reconciliation.
  7. added
    work/assignedQueue worker lifecycle state
    queue/claimedQueue worker lifecycle state
    and removed on Nov 2, 2026
  8. dezren39 commented on Nov 2, 2026

    @dezren39
    MemberAuthor

    🤖 Agent note · picked up

  9. dezren39 commented on Nov 2, 2026

    @dezren39
    MemberAuthor

    🤖 Agent note · done

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/sSmall: expected under 2 hours 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 jobtask/fixhas a fix task queued

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions