Repository navigation
fix(backend): release a daily-sweep model fence whose claim provably never dispatched - #14338
Merged
Merged
Conversation
…never dispatched The sweep claims its at-most-once fence before building the request, and any later failure tombstoned it forever, including failures before a provider request could have been sent. Those spend-free failures were also the only ones the repair operator could not repair, because it required a gateway accounting row. Certified pre-dispatch failures now release the exact pending claim (three times, then a named exhausted state); anything at or after dispatch stays indeterminate. Repair accepts an explicit, lease-expired, fully-read no_recorded_attempt proof, and the accounting read pages to exhaustion. Failure-Class: FC-daily-memory-sweep-fence Co-Authored-By: Claude Fable 5.1 <[email protected]>
…ery states live in the runbook Failure-Class: FC-daily-memory-sweep-fence Co-Authored-By: Claude Fable 5.1 <[email protected]>
|
Preview deployment for your docs. Learn more about Mintlify Previews.
💡 Tip: Enable Automations to automatically generate PRs for you. |
Git-on-my-level
marked this pull request as draft
September 17, 2026 10:39
…claim did not dispatch Review follow-up. llm_gateway_attempts is a best-effort ledger written after the provider call, and the durable JIT reservation exists only on the QA contract path, so neither absence can authorize reopening an invocation. Replace the no_recorded_attempt repair with an explicit, attributed, claim-bound, single-use operator attestation; reject the withdrawn receipt shape; add the missing stale-claim regressions for finalize and generation close. Failure-Class: FC-daily-memory-sweep-fence Co-Authored-By: Claude Fable 5.1 <[email protected]>
This branch was successfully 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.
Summary
The daily memory sweep claims its at-most-once model-invocation fence before it builds the request. Any failure after the claim tombstoned the fence (
pending/indeterminate, "closed forever unless an operator repair receipt reopens one attempt"), including failures that happened before any provider request could have been sent. Measured on the isolated JIT QA plane on 2026-09-17:llm_gateway_attemptsrow exists for that claim and no request reached the QA gateway.source_incomplete:2026-09-10without the agent ever running: the claim transaction returnedblockedon the old tombstone, and every later day queues behind it.QA sweep repair could not join the tombstoned claim to a sweep run id in gateway accounting— it required an accounting row carrying ajit_run_id, which a claim that never dispatched cannot have.So the failures that provably spent nothing were the only ones that could never be repaired. In production the same shape means any failure between claim and first provider request (prompt build, input budget, request serialization, client construction) permanently stops that user's sweep, with no operator path at all, since the repair tool is QA-only.
Design
pre_dispatch_released; the next run may claim again, counter and content-free reason recordedpre_dispatch_exhausted,blocked_reason=pre_dispatch_release_limit(visible, repairable)indeterminateindeterminate, blockedmodels/daily_sweep_dispatch.pyopens a claim-local scope around the builder. The summary agent sets an irreversible latch immediately before it records request evidence and enters the provider call. A failure is pre-dispatch only if it is the exact exception object the instrumented agent issued inside the current claim's scope while the latch is still clear. Constructing the exception type, clearing the mutable QA evidence list, or replaying an earlier certified exception after dispatch all stayindeterminate. If the scope is not visible (another thread, another caller), nothing is certified — the default is today's behaviour.claim_id. Release, finalize, and indeterminate writes require statepending, matching identity, matchingclaim_id, and open deletion/generation fences, with all reads before writes. A deleted or foreign user payload is never recreated. Overlapping runners still dispatch at most once.memoriesattempt. An independent review showed that is unsafe:llm_gateway_attemptsis a best-effort, asynchronous ledger written after the provider call (queue overflow, a dead process, or a failed write all leave no row), so a request the provider consumed could be "proven" absent and dispatched again. The gateway's durable JIT reservation is written before dispatch, but only for requests carrying the QA JIT contract headers, production sweeps do not send them, and legacy fences record no run or request binding to check it against. So absence — of accounting rows or of reservations — is never repair authority. The narrower shape isoperator_attested_no_dispatch: the exact assertionATTEST_NO_PROVIDER_DISPATCH_AND_WORKER_TERMINATED, the operator's identity, a content-free reference to independently reviewed evidence, the full claim identity, claim token, claim time and attestation time, an expired lease plus margin, transactional issuance, and single-use consumption. It validates attribution and claim binding, not the truth of the human assertion, and nothing is ever labelled "no spend". Receipts of the withdrawnno_recorded_attemptshape are rejected. The tool remains QA-plane-only.Review
Designed and implemented with an independent model (Codex), reviewed line by line, then attacked by a second independent read-only review. That review found the release half sound (no path where a request could have been sent and the failure still certifies; the scope is visible on the production call path; reads precede writes; the release budget cannot be reset) and rejected the original absence-based repair, which is why it was redesigned as above. It also asked for two missing regressions — a claim whose fence token changed before finalize, and the same for the generation-close path — both added, and both verified to fail when the corresponding check is removed. Line-by-line points: the latch placement (before evidence recording and
model.invoke, after every local preparation step), the claim-bound transactions, legacy tombstones without aclaim_id(repairable: the receipt'sprior_claim_idand the fence's absentclaim_idcompare equal), and the in-thread call path from the completed-day builder to the agent.Failure-Class: FC-daily-memory-sweep-fence
Product invariants affected
Cited because the change edits files those invariants lock. Candidate admission, authority ranking, memory writes, and the cursor are untouched; the change is confined to the model-invocation fence's failure transitions and the QA repair operator.
Line-Count-Exception: backend/utils/memory/daily_memory_sweep.py | 5814 -> 5984 | claim-bound release/exhaust transitions and validated operator-attestation repair on the existing fence
Evidence
Hermetic local runs (Google credentials blanked), Python 3.11:
New tests cover: release with reason and re-claim on the next run; the fourth failure exhausting the budget; release refused when the fence changed (state, identity, claim id); a forged pre-dispatch exception staying indeterminate; a post-dispatch failure staying blocked; an operator-attested repair reopening exactly once and consuming its receipt; refusal while the lease is unexpired; refusal of absence-based receipts, including the dropped-accounting and late-insertion cases; a stale claim unable to finalize or close over a newer claim; the accounting read pinned with more than 50 foreign rows ahead of the matching row.
Layer measured: unit tests, typecheck, and the Firestore emulator. Not yet observed: a successful
sweep-verifyon the QA plane. The two wedged QA claims are legacy fences; one of them did reach the provider and is only repairable through the recorded-attempt path, the other needs an operator attestation backed by independent evidence (the QA gateway's Cloud Run request log for the claim window and the terminated job execution).🤖 Generated with Claude Code