Repository navigation
Description
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), theninsert(author, 1, [10], "ready-copy")→ key 1 sits in the ready queue.arrived(1)(caller applied event 1 itself) releases nothing — buttake_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), thentake_ready()returns["only-copy"]again. - Control (held analogue):
insert(author, 1, [10], "held-copy")with10not yet arrived, thenarrived(1)→ held copy dropped,len=0, nothing handed out. The held and ready states behave differently for the same call. - Sanity: the normal flow (
insertwith no deps, no interveningarrived) returns the event fromtake_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
-
WaitingPool::arrived(key)drops a pending ready-queue copy ofkey: afterarrived,take_ready()never returns an event whose key has arrived, for both the all-deps-arrived and no-deps insert forms. - Regression tests at the pool level, alongside
test_arrival_of_a_held_event_drops_the_held_copy_without_releasing_it: arrived-after-ready hands the event out zero further times, and the ready events of other keys are unaffected and still in insert order. - The property model in
pkgs/id/tests/waiting_properties.rseither gains an operation order that can express arrive-before-take-ready, or the unit tests above are noted as covering the gap the driver's sequencing excludes. - Existing behaviour is unchanged otherwise: id(waiting): WaitingPool::insert's duplicate guard misses the ready queue — the same key inserted twice before take_ready is handed out twice #2001 duplicate guards, the held-copy drop, expiry, caps, and the event store's waiting/waiting_rows tests all stay green. Coordinate with id(waiting): WaitingPool::restore ignores the arrived and ready-queue duplicate guards — an already-applied or ready event is held again and handed out a second time #3911 (restore's guard) so the two fixes land as one consistent key-state matrix.
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
dezren39 commentedon Nov 3, 2026
🤖 Agent note · state: filed
dezren39 commentedon Nov 3, 2026
🤖 Agent note · picked up
WaitingPool::arrivedleaves a ready-queue copy thattake_readyhands out a second time, and route the fix (coordinating with issue id(waiting): WaitingPool::restore ignores the arrived and ready-queue duplicate guards — an already-applied or ready event is held again and handed out a second time #3911).87 remaining items
dezren39 commentedon Nov 4, 2026
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.
dezren39 commentedon Nov 4, 2026
🤖 Agent note · handed off
dezren39 commentedon Nov 4, 2026
🤖 Agent note · handed off
dezren39 commentedon Nov 5, 2026
🤖 Agent note · bound
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 stagepr_openedwith 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 —claimtakes no task selector andbindrequires a live claim — so the park itself is the claiming lane's first action.)pr-bound-shepherdat its next claim.Merge pull request #5200 from developing-today/queue/6719-4730-arrive…
dezren39 commentedon Nov 6, 2026
🤖 Agent note · done
cargo test -p id-core waiting25/25 pass (including both new ready-copy regressions) andcargo test --test waiting_properties2/2 pass on the laptop @ cd7e41f; PR fix(id): drop ready copy when key arrives (#4730) #5200 checks green, Codex review clean.id(waiting): release-only store path — stop growing the arrived set p…