Repository navigation
fix(queue): broker never re-serves condition parks or completed work (#13091) - #13143
Conversation
…13091) Two serve-path holes let the broker hand out work that was already dispositioned, five times on 2026-11-23: - verb_park stamps a (possibly default) not_before on every park, and the default pick released every park on that timer — including parks whose recorded term is a broker-owned condition (task_terminal/task_status/event_seen, released by the park-revalidation sweeper) or a person's answer (person_answer, released by /wake). Lanes receiving those rows could only re-park them. The pick predicate now ANDs PARKED_TERM_EXCLUSION into the parked branch (mirrored in the budget-skip and no-claim-count diagnostics); all other parks keep timer release, and expired-claim re-serve is untouched. - A done row is unservable, but a re-filing for the same work manufactured a fresh servable row: revive-on-enqueue fired for any terminal predecessor, and the #10627 work-identity rule ignored terminal holders, leaving detection to the fail-open claim-time staleness probe. Enqueue now treats a completed predecessor (same key) and a completed identity holder (any key) as dedupe hits, exactly like live ones. Failed/cancelled predecessors still revive, and dedupe_override still files a deliberate parallel. Regression tests pin both halves: enqueue after completion on the same key and under a dispatch key files no new task, the override and failed-predecessor controls still file, and the pick predicate evaluated per-row never serves broker/person condition parks or a completed row.
|
Warning Review limit reachedYou've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository. Next included review available in 58 minutes. View limit details
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. |
Codex Review Summary: ✅ CompletedThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: f7f45d6792
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| if let Some(row) = terminal | ||
| .as_ref() | ||
| .filter(|r| r.get("status").and_then(|v| v.as_str()) == Some("done")) | ||
| { | ||
| return Ok((row.clone(), None, None)); |
There was a problem hiding this comment.
Preserve triage recovery when its fix follow-on fails
When a triage task completes and its fix follow-on later fails or is cancelled while the issue remains open, this returns the completed triage instead of restoring live coverage. admin.rs explicitly treats triage completion as unfinished issue work and creates the follow-on; /coverage excludes completed tasks, and scripts/fleet/queue-reconcile/check_coverage.py files uncovered issues using the original triage key without dedupe_override. Every subsequent reconciliation therefore succeeds without creating claimable work. Preserve this recovery path in both the key-level and completed-identity checks rather than treating completed triage as completed issue work.
AGENTS.md reference: AGENTS.md:L69-L71
Useful? React with 👍 / 👎.
| pub(crate) const PARKED_TERM_EXCLUSION: &str = "COALESCE(json_extract(ready_condition, '$.kind'), 'time') \ | ||
| NOT IN ('task_terminal', 'task_status', 'event_seen', 'person_answer')"; |
There was a problem hiding this comment.
Enable condition release before removing the timer fallback
With the repository's default sweeper configuration, these condition parks now remain parked even after their conditions are satisfied. home/common/default.nix configures fleet-queue-sweeper to send observe_only=true unless an external revalidator-mode file contains enabled, and core.rs::revalidate_parked explicitly skips task mutations in that mode. Removing claim-time eligibility therefore removes the only automatic release path in the default configuration. Enable mutating revalidation as part of this change, or otherwise provide a condition-aware release path before excluding these rows from picks.
Useful? React with 👍 / 👎.
What
Fixes the broker double-serve behind the five 2026-11-23 incidents: tasks that were already parked with a recorded stand-down, or completed with a verified disposition, were served to lanes again.
Closes #13091
Root cause — two broker-local holes
Condition parks were timer-released by the pick.
verb_parkstamps anot_beforeon every park (default +1200s), anddefault_pick_predicate's parked branch released every park on that timer — including parks whose recorded term is a broker-owned condition (task_terminal/task_status/event_seen, which the park-revalidation sweeper incore.rsexists to release) or a person's answer (person_answer, releasable only via/wakewhen the person acts). Task 21123's ~23-minute re-serve cycle is exactly the default park timer. Genuine waits (time/ci/review/capacity/triage/external) keep timer release — for them, claim-at-not_beforeis the designed release path (FDR-0008), and no automated/wakecaller exists.Completed work was re-served through enqueue. A
donerow itself is unservable in every claim path, but a re-filing for the same work manufactured a fresh servable row: revive-on-enqueue (fleet-queue (turso): no revive/requeue verb — dead-at-cap tasks can only be reset via direct SQL; enqueue dedupe ignores status #6838) fired for any terminal predecessor, and the fleet queue: duplicate-task suppression at filing time on the (repo, issue, kind) work identity #10627 work-identity rule ignores terminal holders by design, leaving detection to the claim-time staleness probe — which fails open by standing rule. Task 21296 (duplicate of completed 17123 for Separate historical signature validity, current key status and local trust #10283) is this shape.Fix
claim.rs: newPARKED_TERM_EXCLUSIONconstant (ready_condition.kind NOT IN ('task_terminal','task_status','event_seen','person_answer'), literals only — the predicate's pinned placeholder count is unchanged), ANDed into the parked branch ofdefault_pick_predicate, so the pick SELECT and the claim UPDATE re-check both carry it. Mirrored in the two documented diagnostic mirrors (budget_skip_sql,no_claim_counts_sqlparked_due) inlifecycle.rs. Expired-claim re-serve (expire_leases) is untouched.claim.rsverb_enqueue: adonepredecessor on the same dedupe key is now a dedupe hit (the completed row is returned; no INSERT, no revive) unless the packet declaresdedupe_override. Failed/cancelled predecessors still revive.work_identity.rs+claim.rs: newdone_identity_holder— a completed holder of the packet's work identity absorbs a differently-keyed filing the same way a live holder does, withwork_identity_collision.rule = "done_work_identity". Module doc updated: failed/cancelled never block; completion does, because the broker knows its own completions locally (no probe, nothing to fail open).Tests
Five regression tests in
turso_queue.rs(fail-before verified: the same-key test reproduced the incident exactly — the broker returned a fresh task withrevived_from: {task_id: 4242, status: "done"}; the pick test showed atask_terminalpark servable):enqueue_after_completion_on_the_same_key_files_no_new_task_13091enqueue_after_completion_under_another_key_files_no_new_task_13091(dispatch-suffixed key)enqueue_done_predecessor_with_override_files_a_deliberate_parallel_13091(control)enqueue_failed_predecessor_still_revives_13091(control)claim_pick_never_serves_broker_or_person_condition_parks_13091(the pick predicate evaluated per-row in rusqlite: queued/timed/ci-condition/legacy parks stay servable; task_terminal/person_answer/event_seen parks and done rows do not)Full crate suite: 540 passed / 0 failed (
cargo test -p fleet-queue --features queue-broker --lib), run in the sandbox before the remote-only directive landed; clippy (1.99) reports no warnings in the new code.Remote verification — dispatch attempted, blocked by tooling
Per the remote-only build directive I attempted dispatch three ways; all three are blocked outside this change:
fleet queue dispatch --repo developing-today/code --ref xaltha/13091-broker-double-serve --command 'cd pkgs/fleet && cargo test -p fleet-queue --features queue-broker --lib' --dispatch --json— the installed fleet build's internal GitHub client fails from this sandbox (FLEET_GH_RAW=1:invalid peer certificate: UnknownIssueron the direct leg; without it, the pre-fix(fleet): parse the personal token on the cache-daemon path too #12500 hosts-yml token bug:failed to parse header value).gh workflow run fleet-command.yml --repo developing-today/fleet …— GitHub API rate limit for the dispatching identity (403 at 2026-11-23 09:08–09:09 UTC, request IDs in the progress note on fix(queue): broker re-serves parked and completed tasks (double-serve) #13091).fleet shell --target actions— not present in this build.This PR's own CI is the remote run of record until the dispatch path clears; the dispatch command above can be re-run verbatim by any lane to reproduce it.
Open in [code]smith · Need help on this PR? Tag
@codesmith-botwith what you need.