Repository navigation
fix(cron): distinguish fire-claim ownership loss from shutdown in ledger - #108912
Open
duanyangformxa wants to merge 3 commits into
Open
duanyangformxa wants to merge 3 commits into
duanyangformxa wants to merge 3 commits into
Conversation
…ger (K3 case-1) Delivered-then-lost runs now record completed-with-warning; pre-delivery loss gets a distinct reason string; heartbeat interval configurable (fail-closed default).
…antics 5 cases: delivered-then-lost / pre-delivery distinct reason / shutdown-string semantics preserved / delivery-error bookkeeping / heartbeat config fail-closed.
|
Heads-up: the source of the false |
This was referenced Sep 13, 2026
13 tasks done
12 tasks done
13 tasks done
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What does this PR do?
Cron runs that lose their fire-claim ownership (per-job fire-fence lock timeout under long-running delivery) were recorded in
executions.dbasfailedwith the error string"Interrupted by shutdown before terminal completion."— indistinguishable from real shutdown kills, even when the delivery had already succeeded.A 20-case investigation across 4 profiles (2026-09-12, executions.db × agent.log cross-verification) showed:
Root cause:
_under_fire_fencelock timeout (30s, fail-closed) → heartbeatheartbeat_fire_claim=False→ 180s grace exhausted →lost_ownership→_record_fire_ownership_lostunconditionally writes the shutdown string. This PR makes the ledger reflect what actually happened; it complements #108359 (which prevents the false ownership loss at the heartbeat layer) — if the heartbeat no longer times out, this ledger layer still correctly classifies genuine losses (real cancellation, dashboard drain, actual shutdown).Related Issue
Addresses #108341 (ledger-accuracy layer; #108359 covers the heartbeat-prevention layer).
Type of Change
Changes Made
cron/scheduler.py:mark_job_run(success, "Fire claim ownership lost after successful delivery; recorded as completed (delivery confirmed).")— never overwrite a healthy delivered run with the shutdown string;"Fire claim ownership lost before delivery; run result discarded (not a shutdown)."(owner-fenced write kept; discard fallback on fence rejection) — a pre-delivery loss must never read as a shutdown;cron.heartbeat_secondsthrough_cron_heartbeat_seconds()— default 60s unchanged, fail-closed on invalid config.How to Test
New regression file
tests/cron/test_fire_claim_ownership_lost_ledger_20260912.pycovers 5 cases: delivered-then-lost → completed-with-warning; pre-delivery loss → distinct reason; genuine heartbeat loss (non-fence) → shutdown-string semantics preserved; delivery-error bookkeeping;cron.heartbeat_secondsfail-closed default.Compatibility
The only known executions.db consumer parsing these rows aggregates by
status='completed'and never matches error text — new strings are zero-blocking; post-fix, delivered-run counting becomes more accurate.Evidence appendix (abridged)