Repository navigation
fix(qsearch): hold live v2 receipts until provider usage is final (accounting gate) - #54
Merged
Merged
Conversation
…counting promotion gate) PREDATOR_QCOMMS_J_FOLLOW_THROUGH_V1 section 2, "Remaining accounting blocker", option "defer final receipt completion until accounting is final". A live (non-dry) v2 request whose ATLAS result is DONE or FAILED but whose usage is missing or zero is held ACCEPTED: 503 ACCOUNTING_PENDING (ACCOUNTING_TIMEOUT after NANO_QSEARCH_ACCOUNTING_WINDOW_S, default 900 s; still held, never sealed pending, never NOT_RUN), nothing resubmitted. Each repeat or restart drives ATLAS recover_qsearch_submission's accounting read; the stored ATLAS receipt is merged with the ledger row's settled usage (same provider job, positive usage only) and the OK / FAILED receipt is sealed once with usage_pending false. A DONE receipt an older Nano sealed while usage was pending is never served as final: it is re-derived from the settled row with identical results (compare-and-swap; the replaced seal and usage kept in record_json["reseals"]) or answered 503 (RESEAL_MISMATCH if results would differ). FakeFez dry runs and v1 receipts (no usage field) are unchanged. Co-Authored-By: Claude Opus 5.5 <[email protected]>
AetherAI3
changed the base branch from
codex/qcomms-j-pending-ledger
to
claude/qcomms-j6-nano
October 31, 2026 22:35
…ms-j-settled-usage Co-Authored-By: Claude Opus 5.5 <[email protected]>
…ettled_usage
Recovery now takes the client view of the stored receipt from ATLAS #184's
qsearch_receipt_with_settled_usage(ledger, request_id) (the stored DONE/FAILED
receipt completed once, durably, with the row's settled usage), used only for the
same provider job; otherwise the recovered receipt stands and stays held. The
row-usage merge remains only as the fallback for ATLAS pins without the helper.
The sealed v2 usage keys stay exactly {quantum_seconds, usage_pending,
provider_sub_jobs, provider_metrics}: ATLAS's usage_settled_at and
provider_usage_at_receipt are not mapped into the receipt.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
…edger alone (#54 review) Review MEDIUM 1: a FAILED (cancelled / errored / max-time) job whose usage stays 0 is still held, never sealed with final usage, but every 503 now carries what the client can record: job_id, result, provider_status, terminal, usage_pending and (for FAILED) reason, under ACCOUNTING_PENDING_TERMINAL (ACCOUNTING_PENDING for a DONE job, ACCOUNTING_TIMEOUT after the window). A submitted request whose outcome is not known yet answers SUBMITTED_PENDING with the job id when ATLAS names it. Review MEDIUM 2: recovery first reads ATLAS's ledger-only qsearch_receipt_with_settled_usage (no provider call, no live context, no flags), so a settled row, including a historical re-seal, completes without GO / LIVE. Only an unsettled row goes on to provider recovery; without the flags it answers ACCOUNTING_NEEDS_LIVE_CONTEXT instead of ACCOUNTING_PENDING. Also: record_json notes that usage.provider_metrics is the provider's read at job completion (may show 0) while quantum_seconds is the settled usage, and keeps ATLAS's provider_usage_at_receipt. Co-Authored-By: Claude Opus 5.5 <[email protected]>
This was referenced Nov 1, 2026
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.
Closes the "Remaining accounting blocker" promotion gate (
PREDATOR_QCOMMS_J_FOLLOW_THROUGH_V1§2) with the spec's option "defer final receipt completion until accounting is final". Clients now receive final usage and never a receipt sealed with pending usage. Circuit results are untouched and nothing is resubmitted.ACCOUNTING_PENDING, which becomesACCOUNTING_TIMEOUTafterNANO_QSEARCH_ACCOUNTING_WINDOW_S(default 900 s). The request is still held after the timeout: never sealed pending, never NOT_RUN.recover_qsearch_submission's accounting read. Nano merges the ledger row's settled usage into the stored ATLAS receipt (same provider job, positive usage only) and then seals OK or FAILED once, withusage_pending: false. A zero is never finalized as a free run.record_json["reseals"]). Until then it answers 503, orRESEAL_MISMATCHif the results would differ.qsearch_receipt_with_settled_usage(b66fd91), and only for the same provider job. The row-usage merge remains as a fallback only for ATLAS pins without the helper. The sealedusagekeys stay exactly {quantum_seconds, usage_pending, provider_sub_jobs, provider_metrics}; ATLAS'susage_settled_atandprovider_usage_at_receiptare not mapped into the receipt. This branch now mergesclaude/qcomms-j6-nano, which contains fix(qsearch): keep unknown submission outcomes pending through ledger failures #53.Review fixes (commit b209605):
job_id,result,provider_status,terminal,usage_pending: trueand (for FAILED)reason, underACCOUNTING_PENDING_TERMINAL. A DONE job getsACCOUNTING_PENDING, andACCOUNTING_TIMEOUTapplies after the window. A submitted request whose outcome is not known yet answersSUBMITTED_PENDINGwith the job id when ATLAS names it. The reviewer's reproduction (cancelled job, usage 0, four POSTs) is tested with stand-ins and with real ATLAS.qsearch_receipt_with_settled_usage, so a settled row, including a historical re-seal, completes without GO or LIVE (no provider context is resolved). Only an unsettled row goes on to provider recovery; without the flags it answersACCOUNTING_NEEDS_LIVE_CONTEXT.record_jsonexplains thatusage.provider_metricsis the provider's read at job completion (it may show 0) whilequantum_secondsis the settled usage, and it keeps ATLAS'sprovider_usage_at_receipt.81b23df(#184 merged): accounting tests 13 passed; real-ATLAS tests 11 passed; accounting plus Predator parity atf3eade0221 passed; full suite 1674 passed, 6 skipped, and 7 failures, all of them thetest_provenance.pyfailures that also fail on the base.Tests:
test_qsearch_accounting.pywith stand-in delegates: pending to final, restart, repeated retrieval, terminal failure with late usage, concurrent duplicates submitting once, window, dry and already-settled results sealed at once, re-seal and refusals for old receipts, the merge rule, and Predator parity (settled and re-sealed receipts verify withusage_pendingfalse andquantum_secondsset, against Predator f3eade02).b66fd91, helper present) with a fake provider: zero usage is held until ATLAS's accounting read settles the row, then sealed once; repeated retrieval returns the same receipt; the ledger settles exactly once (finalized_seconds2.0, one row).test_provenance.pyfailures that also fail on the base.No QPU run happened.
🤖 Generated with Claude Code