From 145cf04fcdfcc49efd88f89f3cd3e81863696c5f Mon Sep 17 00:00:00 2001 From: Drewry Pope Date: Tue, 24 Nov 2026 04:23:16 -0600 Subject: [PATCH] fix(fleet-queue): staleness retire no longer eats dispatch/slice packets; retirements visible in history (#14268) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Mechanism (verified against the fleet-queue DB, not just the client): all four eaten packets (22913, 22927, 22966, 22984) were retired by the claim-time staleness check (#10626) exactly as designed — result outcome `already_done` with tier-1 evidence and a `staleness_autocomplete` event are on every row. The check keys only on the packet's linked issue/PR state; it cannot tell a task ABOUT an issue from a task whose work ARISES from one: - 22913/22927 (triage): the packet's work was filing five NEW issues from the #5834 design record. #5834 was closed 38 s before the packet was even created — by the lane that then filed the packet with a `dedupe_override` deliberate-parallel reason. - 22966/22984 (feature_slice): the #12428 NixOS handoff slices; their parent issue had been closed (2026-11-22) while the work stayed live under it. Fix, in staleness_verdict (shared by the claim-time and filing-time checks): - A packet carrying a non-empty `dedupe_override` reason is never auto-retired: the override is the filer's recorded assertion that the packet is not the issue's canonical task. (A boolean `true` still parses as no override, matching work_identity.) - A feature slice (CompletionClass::Slice) is never retired on an issue link alone: a slice delivers an artifact and its parent issue's state is not its completion. The slice's own linked PR landing still retires it. The legitimate #10626 behaviour is unchanged: a plain triage / second-pass / fix packet for a verifiably closed issue or merged PR still retires at claim with its result + event paper trail. Visibility (why four lanes all "verified" zero history and no result): both client surfaces that assemble a task's history (cmd_show, cmd_timeline) queried a fixed event-kind list that omitted `staleness_autocomplete` — the one event a retirement writes — and show never surfaces the result column. The retire was therefore invisible through every client read path. Both lists now query the kind, with a source-assertion test beside the #6985 precedent. Oracle: staleness_verdict unit tests with a stubbed landing lookup — the eaten shapes (override triage, parent-closed slice) now claim; the boolean-override and merged-PR slice shapes still retire; the pre-existing #10626/#12966 verdict tests stand unchanged. Full suite: cargo test -p fleet-queue --features client,queue-broker — 641 passed, 0 failed. --- pkgs/fleet/crates/fleet-queue/src/client.rs | 30 +++++ .../fleet-queue/src/client/commands_query.rs | 2 + .../fleet-queue/src/turso_queue/staleness.rs | 106 ++++++++++++++++++ 3 files changed, 138 insertions(+) diff --git a/pkgs/fleet/crates/fleet-queue/src/client.rs b/pkgs/fleet/crates/fleet-queue/src/client.rs index 5897aa146f..cda236faa4 100644 --- a/pkgs/fleet/crates/fleet-queue/src/client.rs +++ b/pkgs/fleet/crates/fleet-queue/src/client.rs @@ -221,6 +221,36 @@ mod tests { } } + #[test] + fn timeline_surfaces_staleness_autocomplete_14268() { + // #14268: a claim-time staleness retirement writes exactly + // one event, `staleness_autocomplete`, and no `claimed` + // event. While the history kind lists omitted it, four + // retired tasks read as "zero history events, no result" + // through every client surface and were misdiagnosed as + // silent completions. Both surfaces that assemble a task's + // history query the kind now. + let src = include_str!("client/commands_query.rs"); + let timeline_seg = src + .split("fn cmd_timeline(") + .nth(1) + .and_then(|s| s.split("let resp = call(").next()) + .unwrap_or(""); + assert!( + timeline_seg.contains("\"staleness_autocomplete\""), + "cmd_timeline queries staleness_autocomplete so retirements are visible" + ); + let show_seg = src + .split("fn cmd_show(") + .nth(1) + .and_then(|s| s.split("fn cmd_timeline(").next()) + .unwrap_or(""); + assert!( + show_seg.contains("\"staleness_autocomplete\""), + "cmd_show queries staleness_autocomplete so retirements are visible" + ); + } + #[test] fn collapse_timeline_9046_drops_only_duplicate_writes() { // #9046 oracle: same (kind, session, leaf, trigger) inside diff --git a/pkgs/fleet/crates/fleet-queue/src/client/commands_query.rs b/pkgs/fleet/crates/fleet-queue/src/client/commands_query.rs index cf768488c7..1e2455be90 100644 --- a/pkgs/fleet/crates/fleet-queue/src/client/commands_query.rs +++ b/pkgs/fleet/crates/fleet-queue/src/client/commands_query.rs @@ -376,6 +376,7 @@ pub(super) fn cmd_show(rest: &[String]) -> i32 { let mut events = Vec::new(); for kind in [ "claimed", + "staleness_autocomplete", "session_bound", "lane_session_bound", "model_stamp", @@ -937,6 +938,7 @@ pub(super) fn cmd_timeline(verb: &str, rest: &[String]) -> i32 { let mut events: Vec = Vec::new(); for kind in [ "claimed", + "staleness_autocomplete", "session_bound", "lane_session_bound", "model_stamp", diff --git a/pkgs/fleet/crates/fleet-queue/src/turso_queue/staleness.rs b/pkgs/fleet/crates/fleet-queue/src/turso_queue/staleness.rs index 5450a25b97..a7272b11bb 100644 --- a/pkgs/fleet/crates/fleet-queue/src/turso_queue/staleness.rs +++ b/pkgs/fleet/crates/fleet-queue/src/turso_queue/staleness.rs @@ -30,6 +30,17 @@ //! latency to every claim. `FLEET_STALENESS_CHECK=0` turns the //! whole check off; a packet with `staleness_check: false` opts out. //! +//! Two packet shapes are exempt by construction (#14268): a packet +//! carrying a `dedupe_override` reason is a deliberate parallel +//! filing — the filer recorded that its work arises from the +//! linked issue rather than being the issue's own canonical task, +//! so the issue's state cannot complete it; and a feature slice +//! (CompletionClass::Slice) delivers an artifact against a parent +//! issue whose state is not the slice's completion — only the +//! slice's own linked PR landing retires it. Both exemptions fail +//! open the same way as the rest of the check: the claim proceeds +//! exactly as before. +//! //! Only the default pick runs the check. A by-id claim, a transfer //! and the handoff pick name their row deliberately — the override //! path #9178 keeps — so they claim as before. @@ -239,10 +250,34 @@ pub fn staleness_verdict( if payload.get("staleness_check").and_then(|v| v.as_bool()) == Some(false) { return None; } + // #14268: a deliberate-parallel filing is never retired on its + // linked issue's state. `dedupe_override` is the filer's + // recorded assertion that this packet is not the issue's + // canonical task — its deliverables arise from the issue + // (follow-on filings, dispatched work), so the issue closing + // does not complete it. (Tasks 22913/22927: the #5834 + // follow-on filing packet, eaten at claim because #5834 had + // just been closed by the lane that filed the packet.) + if dedupe_override(row).is_some() { + return None; + } let links = task_links(row); if links.is_empty() { return None; } + // #14268: a feature slice delivers an artifact; its parent + // issue's state is not the slice's completion + // (CompletionClass::Slice — the parent issue stays open by + // design and slices recur against it, #12233 F2c). An issue + // link alone never retires a slice; the slice's own PR + // landing still does, through the PR links. (Tasks + // 22966/22984: the #12428 NixOS handoff slices, eaten at + // claim because their parent issue was closed.) + if completion_class(&payload) == CompletionClass::Slice + && links.iter().all(|l| l.kind == LinkKind::Issue) + { + return None; + } let created_at = row .get("created_at") .and_then(|v| v.as_str()) @@ -567,6 +602,77 @@ mod tests { ); } + #[test] + fn deliberate_parallel_override_is_never_retired() { + // #14268 (tasks 22913/22927): a triage packet filed with a + // dedupe_override reason carries NEW work arising from its + // already-closed issue — filing the design record's + // follow-ons. The override is the filer's recorded + // assertion that the packet is not the issue's canonical + // task, so the claim proceeds even though the issue landed + // before the task was created. + let t = row( + json!({"kind": "triage", "repo": "developing-today/code", + "issue": {"number": 5}, + "dedupe_override": "deliberate parallel: files the record follow-ons"}), + "2026-11-10T00:00:00Z", + ); + assert!( + staleness_verdict(&t, NOW, true, &mut |_| landed("2026-10-01T00:00:00Z")).is_none() + ); + // A boolean `true` is not an override (work_identity's + // parsing, asserted there too): the packet retires as + // before. + let t = row( + json!({"kind": "triage", "repo": "developing-today/code", + "issue": {"number": 5}, "dedupe_override": true}), + "2026-11-10T00:00:00Z", + ); + assert!( + staleness_verdict(&t, NOW, true, &mut |_| landed("2026-10-01T00:00:00Z")).is_some() + ); + } + + #[test] + fn feature_slice_is_not_retired_by_its_parent_issue() { + // #14268 (tasks 22966/22984): a slice packet whose parent + // issue is closed still has its artifact to deliver — the + // parent's closure is not the slice's completion. + let t = row( + json!({"kind": "feature_slice", "repo": "developing-today/code", + "issue": {"number": 5}}), + "2026-11-10T00:00:00Z", + ); + assert!( + staleness_verdict(&t, NOW, true, &mut |_| landed("2026-10-01T00:00:00Z")).is_none() + ); + // The slice's own PR landing still retires it: with a PR + // link present the PR decides, as for a shepherd. + let t = row( + json!({"kind": "feature_slice", "repo": "developing-today/code", + "issue": {"number": 5}, "pr": {"number": 9}}), + "2026-11-10T00:00:00Z", + ); + let mut look = |l: &Link| match l.kind { + LinkKind::Pr => landed("2026-10-01T00:00:00Z"), + LinkKind::Issue => Landing::Open, + }; + assert!(staleness_verdict(&t, NOW, true, &mut look).is_some()); + } + + #[test] + fn filing_check_honours_the_same_exemptions() { + // The filing-time re-check shares the verdict, so a + // stamped slice packet with an old stamp files live even + // when its parent issue has landed. + let t = row( + json!({"kind": "feature_slice", "repo": "developing-today/code", + "issue": {"number": 5, "state_checked_at": "2026-11-18T09:00:00Z"}}), + "2026-11-18T11:30:00Z", + ); + assert!(filing_verdict(&t, NOW, true, &mut |_| landed("2026-11-17T00:00:00Z")).is_none()); + } + #[test] fn a_linked_pr_decides_over_its_issue() { let t = row(