Skip to content

id(waiting): WaitingPool::arrived does not drop a ready-queue copy — an event applied through another path is handed out again by take_ready #4730

Closed

Description

@dezren39

Summary

WaitingPool::arrived (pkgs/id/crates/id-core/src/waiting.rs:385) drops a held copy of the arriving key — its doc says so: "If key was itself held, that copy is dropped without being returned, because the caller now holds the event" (waiting.rs:383-384). It does not drop a ready-queue copy of the same key. An event whose dependencies had all arrived at insert time sits in the ready queue (ready / ready_keys, waiting.rs:170-176); if the caller applies that event through another path and calls arrived(its key) before take_ready() — the documented step-2 call in the module's caller loop (waiting.rs:21-27) — the ready copy survives, and the next take_ready() (waiting.rs:421-424) hands the same event out a second time.

Every other entry point treats the ready queue as a real state a key can be in: the duplicate guards in insert (waiting.rs:243-246) and park (waiting.rs:281-284) check ready_keys, and that index exists precisely because a key in the ready queue is otherwise invisible (#2001, closed). arrived is the one transition that never looks at it. The sibling gap in restore is already tracked as #3911; this is the remaining cell in the same matrix — #3911's criteria cover restore's guard only, and fixing #3911 does not make arrived drop a ready copy.

Verified this run (laptop probe, origin/main f961fb8)

Probe crate on the laptop (~/git/fleet/probe-2026-11-02-laneA-arrivedready/) #[path]-includes the real waiting.rs extracted from origin/main (md5 9654300d490a030f3f5513c79692e717, matching the origin/main blob) and exercises WaitingPool<u32, &str>:

  • Case A: arrived(10) (dependency present), then insert(author, 1, [10], "ready-copy") → key 1 sits in the ready queue. arrived(1) (caller applied event 1 itself) releases nothing — but take_ready() afterwards still returns ["ready-copy"]: the already-applied event is handed out a second time.
  • Case B (no-deps form): insert(author, 7, [], "only-copy") → ready immediately. arrived(7), then take_ready() returns ["only-copy"] again.
  • Control (held analogue): insert(author, 1, [10], "held-copy") with 10 not yet arrived, then arrived(1) → held copy dropped, len=0, nothing handed out. The held and ready states behave differently for the same call.
  • Sanity: the normal flow (insert with no deps, no intervening arrived) returns the event from take_ready() exactly once.

The property suite (pkgs/id/tests/waiting_properties.rs) cannot see this: its driver calls take_ready() immediately after every single insert, so a ready copy is never pending when an Arrive op runs, even though the file's stated invariant is "each event is output at most once, by release, by take_ready, or by expiry".

Why it matters

The pool's contract is that a key is in exactly one state — held, ready, or arrived — and is handed out at most once. A caller that applies an event it obtained elsewhere (a duplicate delivery decided as already-applied, a batch that resolves an event before draining the ready queue) and dutifully calls arrived will still receive that event from take_ready and apply it twice, or route it through a second decision as if it were new. The asymmetry with the held case — which the code and its tests explicitly pin — makes this easy to rely on wrongly: test_arrival_of_a_held_event_drops_the_held_copy_without_releasing_it promises a behaviour the ready state does not share.

Note on fix shape (why this is filed-only, not a trivial self-solve): ready is a Vec<E> with keys kept separately in ready_keys, so there is currently no key→position mapping with which arrived could remove one specific ready event; the fix needs a small data-structure decision (e.g. storing (K, E) pairs in the ready queue) plus care that take_ready's insert-order guarantee and the #2001 guard keep holding.

Acceptance criteria

Dedup

Open/closed searches for "WaitingPool arrived", "take_ready", and "waiting pool ready arrived duplicate" (2026-11-02) return: #2001 (closed — insert's ready-queue duplicate guard), #3911 (open — restore ignores the arrived/ready guards; its acceptance criteria cover restore only), #1730 (open — arrived-set growth, a different defect), and #4000 (open design umbrella on restore guards). No issue covers arrived failing to drop a ready-queue copy.

Activity

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

    @dezren39
    MemberAuthor

    🤖 Agent note · state: filed

  3. added
    work/assignedQueue worker lifecycle state
    queue/claimedQueue worker lifecycle state
    and removed on Nov 3, 2026
  4. dezren39 commented on Nov 3, 2026

    @dezren39
    MemberAuthor

    🤖 Agent note · picked up

  5. 87 remaining items

  6. dezren39 commented on Nov 4, 2026

    @dezren39
    MemberAuthor

    agent-note:v1
    task: 6719
    lane: code-y
    stage: handed_off
    execution_lane: opencode
    Issue #4730 verified OPEN, no hard stops; parked labels resynced to queue/claimed + status/in-progress. Task 6719 re-claimed (attempt 18/24) and handed off to the opencode claimant. RESUME, do not restart: PR #5200 is OPEN on branch queue/6719-4730-arrived-ready-copy — disposition its checks and Codex findings, merge when verified, then complete task 6719.

  7. dezren39 commented on Nov 4, 2026

    @dezren39
    MemberAuthor

    🤖 Agent note · handed off

  8. dezren39 commented on Nov 4, 2026

    @dezren39
    MemberAuthor

    🤖 Agent note · handed off

  9. dezren39 commented on Nov 5, 2026

    @dezren39
    MemberAuthor

    🤖 Agent note · bound

    • Agent: fleet monitor (repo-fleet-monitor)
    • Session / ID: task 6719 · repo-fleet-monitor run 2026-11-04 20:12 CST
    • Found via: monitor reconciliation (Duty 1B PR↔queue join)
    • Task: Verified open PR fix(id): drop ready copy when key arrives (#4730) #5200 implements this issue and was opened from the task's own branch (queue/6719-…). The queue task is currently QUEUED and unclaimed — the original claim evaporated after the PR was opened — so this issue's claimed/assigned labels are being reset to the truth (queue/queued + status/needs-triage) in the same pass. The lane that claims task 6719 must BIND to PR fix(id): drop ready copy when key arrives (#4730) #5200: checkpoint stage pr_opened with the PR as artifact, park as its shepherd (review CI, merge when green), and NOT re-implement the work. (The monitor cannot claim a specific task through the fleet CLI — claim takes no task selector and bind requires a live claim — so the park itself is the claiming lane's first action.)
    • Expectation: task 6719 parked on PR fix(id): drop ready copy when key arrives (#4730) #5200 as pr-bound-shepherd at its next claim.
    • Links: PR fix(id): drop ready copy when key arrives (#4730) #5200 · queue task 6719 (repo-health-code-pilot)
  10. added and removed
    queue/claimedQueue worker lifecycle state
    work/assignedQueue worker lifecycle state
    on Nov 5, 2026
  11. added a commit that references this issue on Nov 6, 2026
  12. dezren39 commented on Nov 6, 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

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 job

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions