Skip to content

fix(queue): broker never re-serves condition parks or completed work (#13091) - #13143

Merged
dezren39 merged 1 commit into
mainfrom
xaltha/13091-broker-double-serve
Nov 23, 2026
Merged

dezren39 merged 1 commit into
mainfrom
xaltha/13091-broker-double-serve

Conversation

@dezren39

@dezren39 dezren39 commented Nov 23, 2026 •

Copy link
Copy Markdown
Member

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

  1. Condition parks were timer-released by the pick. verb_park stamps a not_before on every park (default +1200s), and default_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 in core.rs exists to release) or a person's answer (person_answer, releasable only via /wake when 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_before is the designed release path (FDR-0008), and no automated /wake caller exists.

  2. Completed work was re-served through enqueue. A done row 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: new PARKED_TERM_EXCLUSION constant (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 of default_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_sql parked_due) in lifecycle.rs. Expired-claim re-serve (expire_leases) is untouched.
  • claim.rs verb_enqueue: a done predecessor on the same dedupe key is now a dedupe hit (the completed row is returned; no INSERT, no revive) unless the packet declares dedupe_override. Failed/cancelled predecessors still revive.
  • work_identity.rs + claim.rs: new done_identity_holder — a completed holder of the packet's work identity absorbs a differently-keyed filing the same way a live holder does, with work_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 with revived_from: {task_id: 4242, status: "done"}; the pick test showed a task_terminal park servable):

  • enqueue_after_completion_on_the_same_key_files_no_new_task_13091
  • enqueue_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: UnknownIssuer on 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.


See it in action
Open in [code]smith · Need help on this PR? Tag @codesmith-bot with what you need.

…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.
@coderabbitai

coderabbitai Bot commented Nov 23, 2026

Copy link
Copy Markdown

Warning

Review limit reached

You'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.

Check out review usage here.

View limit details

Limit details: You’ve used the included review currently available.

Learn how review limits work.

Review configuration:

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: defaults
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 8d9a9eed-d06b-4ce6-8bcd-09c543fa6df5
Commits

Reviewing files that changed from the base of the PR and between 1d2cfed and f7f45d6.

Files selected for processing: 4

  • pkgs/fleet/crates/fleet-queue/src/turso_queue.rs
  • pkgs/fleet/crates/fleet-queue/src/turso_queue/claim.rs
  • pkgs/fleet/crates/fleet-queue/src/turso_queue/lifecycle.rs
  • pkgs/fleet/crates/fleet-queue/src/turso_queue/work_identity.rs
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

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.

Share

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 23, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-23T09:13:10.002086Z f7f45d6 PR opened
ℹ️ 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" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 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".

Comment on lines +114 to +118
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));

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge 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 👍 / 👎.

Comment on lines +2215 to +2216
pub(crate) const PARKED_TERM_EXCLUSION: &str = "COALESCE(json_extract(ready_condition, '$.kind'), 'time') \
NOT IN ('task_terminal', 'task_status', 'event_seen', 'person_answer')";

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge 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 👍 / 👎.

@dezren39
dezren39 merged commit f7f45d6 into main Nov 23, 2026
2 checks passed
@dezren39
dezren39 deleted the xaltha/13091-broker-double-serve branch November 23, 2026 10:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

fix(queue): broker re-serves parked and completed tasks (double-serve)

1 participant