Repository navigation
SCA-2015: add durable owner cursor for ready-result discovery - #25266
Conversation
Persist pass ceilings, stop discovery at the tick deadline, and retain undrained progress. Correct error/count telemetry and keep saturation tests within the existing timing budgets. Failure-Class: FC-backlog-release-shares-lane-with-fresh-work
Co-Authored-By: Claude Fable 5.2 <[email protected]>
…ssify permanent errors Review of 89e69ef1: a slow cursor read could be followed by the ceiling query after the tick budget expired. Permanent API errors are logged as errors. Smaller saturation fixture for the unit time budget. Co-Authored-By: Claude Fable 5.2 <[email protected]>
…the cursor page key 'cursor' Merges lane/tx-fresh-gate at 953ce1e (one test-inventory commit) and renames the page dict key state to cursor in ready_discovery.py, which a CI-only lifecycle writer guard reads as a job state payload. No behaviour change. Co-Authored-By: Claude Fable 5.2 <[email protected]>
…dget CI measured 1.16 s CPU for the switch-off case against a 1.00 s limit. Two held owners with 51 rows each still fill the old 100-row page, and the switch-off case needs one tick to show the miss, not three. Co-Authored-By: Claude Fable 5.2 <[email protected]>
…r and the row sweep With the owner cursor on by default, maintenance finds owners by key and reads no job to learn its owner, so the memo count this test asserted is zero. The test now runs both: zero owner reads with the cursor, the original memoised counts with the switch off. Co-Authored-By: Claude Fable 5.2 <[email protected]>
Co-authored-by: multica-agent <[email protected]>
Co-authored-by: multica-agent <[email protected]>
|
Independent exact-head review. Reviewer model: DeepSeek V4.1 Flash (M1 Studio OpenCode, via Multica). Reviewed commit: VERDICT: FIX
|
Co-authored-by: multica-agent <[email protected]>
|
Round-two exact-head review. Reviewer model: DeepSeek V4.1 Flash (M1 Studio OpenCode, via Multica). Reviewed commit: VERDICT: FIX
|
Failure-Class: FC-bounded-discovery-pinned-by-blocked-page Co-authored-by: multica-agent <[email protected]>
|
Independent exact-head review, round three (gpt-6-luna via agentctl review pool; last commits authored by Sol): no BLOCKER or SHOULD-FIX. |
…25283) An unready fresh or unstamped GPU head can leave a later ready fresh result stuck indefinitely when an intervening ready provider backlog row is held. The expired head-wait path repeatedly selects the held row, while the existing transactional fresh selector only runs for catch-up or held-provider heads. After that head-wait path hits held provider stock, retry fresh selection and commit in one transaction. The selected fresh row must satisfy its own head wait. The provider backlog remains held; stored classes, privacy checks, result-log predecessors and projection fences are preserved. This shared merge path runs in backend-integration and the GKE batch worker. ## Proof limits and release order This fixes the three-row selection shape above. The production metadata read at 2026-11-14 08:38Z matched this shape directly for **one owner**. It is not the fix for the 62 stalled owners: 60 were outside the 36-hour nudge window. The durable discovery cursor in #25266 must release first, followed by a counts-only re-count after a full wrapped pass; report remaining owners' head shapes before proposing further code. The claim that uploads under a day late are fixed remains open until that production check passes. The Firestore and Postgres conformance cases **skip** on this host because their backends are unavailable. The simulator passes do not establish real-store behavior or production acceptance. ## Validation - Unmodified main reproduces 2 failures (fresh and unstamped heads), with 1 stored-false control pass. - Selection regression, transactional fresh gate and bounded head-wait suites: 208 passed. - Existing fresh-first: 59 passed; provider merge membership: 46 passed. - New conformance cases: 8 simulator passes, 16 Firestore/Postgres skips. Covers 40 unready predecessors, disabled head wait and privacy refusal. - Repository preflight passed all 38 selected checks before publication. CI is reported separately on the final head. No endpoint or deployment configuration changes. Synthetic tests invoke the real OrderedMerge.commit_next path. No production writes or customer content reads were performed. ## Review and rollback Author model: GPT-6.1 Sol. Current head: `5a0bb5abe6550792fe891eabe97074f986ab2c63`. Requested independent reviewer: DeepSeek V4.1 Flash through Multica. Round-two independent review: DeepSeek V4.1 Flash, VERDICT: SHIP for this exact head, recorded at #25283 (comment). CI and cursor-first release prerequisites remain separate. No earlier SHIP applies to this change. Record the actual reviewer model and reviewed SHA here before release. Rollback: BATCH_PIPELINE_MERGE_TX_FRESH_GATE_ENABLED=false disables the additional selection. Missing transactional indexes fail closed with backoff. No knobs, queue budgets or lifecycle states are added or retuned. Part of SCA-2015; this PR alone does not complete the metered-release contract. Failure-Class: FC-backlog-release-shares-lane-with-fresh-work ## CI conformance repair on this successor The provider conformance tests were intercepting only fresh_pending, which the default transactional gate never calls. The privacy revoke and predecessor settlement therefore did not occur in the failing CI cases. The tests now parameterize the outside-probe and transactional modes, inject each race at the boundary used by that mode, and assert the interleaving actually executed. Privacy still requires no result and unchanged custody; the predecessor must commit first or prevent the later result from passing. No production code changes in this successor. Local provider conformance: 18 simulator passes, 36 real-store skips; full real-store proof remains with CI. This commit invalidates any confirmation of the previous head. Prior exact-head review: **DeepSeek V4.1 Flash, SHIP at 45a802b**, recorded at #25283 (comment). That verdict does not cover current head 5a0bb5a; round-two exact-head confirmation is now recorded above. Cost: the target head shape now uses three transactions per drain attempt rather than two, adding one transactional fresh-selection attempt and its reads/contention; no backlog budget is increased. CI receipt: at 2026-11-14 11:32Z, the GitHub API reported 66 terminal outcomes on 5a0bb5a: 41 SUCCESS and 25 SKIPPED, with no pending or failed checks. DeepSeek V4.1 Flash SHIP names this same head. The PR remains draft while cursor-first release and verification prerequisites are unresolved.
The 100-oldest ready-result page can be filled with held backlog and never offer a quiet owner's fresh work. Discover distinct ready owners in a durable, ceiling-bounded pass. Seek above the saved owner key and at or below the pass ceiling; advance only after an attempted drain, and reset the cursor/ceiling at wrap. New owners behind the cursor or beyond the ceiling wait for the next pass. Existing merge, privacy, result-chain and provider-backlog gates remain enforced.
Current head: 5a67d5a, source tree 00b128d161dd59371a06c86bf0fd609359cf5245. Integration/fix author model: GPT-6.1 Sol. No SHIP exists for this head. SCA-2166 remains held.
Shared cursor and stored-field contract
Cursor recovery: after_owner_key advances only after attempted drains or counted missing ids. At the pass ceiling or an empty seek, the pass ends and both cursor and ceiling reset to null; the next tick starts a new pass.
Serving and the GPU pump use separate maintenance leases, so their discovery pages can overlap. Each page captures the full stored cursor snapshot. Its finish transaction reads the cursor again and writes only if that snapshot is unchanged. Accepted finishes increment the new nonnegative integer
revision; missing means 0. This distinguishes repeated positions across passes even whenpass_started_atrepeats. A stale finish writes nothing and cannot claim a published wrap; the next tick resumes the newer progress. Malformed revisions and datastore errors retain the old-page fallback without a cursor write.Readers/writers:
ReadyDiscoveryin backend-integration serving maintenance and the GKE worker pump, on Firestore/Postgres, plus simulator clients. Pre-cursor versions ignore this document. Earlier cursor versions preserve unknown fields but write unconditionally and do not increment revision; every cursor writer must run the conditional code before protection is an acceptance claim. No job/result schema changes.Owner budget defaults to 20, clamped 1..100. Cooperative tick deadline defaults to 10 seconds, clamped 1..60; it is checked between queries/drains and cannot interrupt an in-flight synchronous operation. Normal maintenance cadences remain 20 seconds for serving and 5 seconds for the pump. Cursor read/write/query failures fall back to the old page; missing indexes back off 300 seconds. Durable marker re-offer remains active on the cursor path.
Cost per tick: owner seek rows and drain reads, two cursor-document reads, one ceiling query per pass, plus empty-query minimums. Accepted ticks write one cursor document; stale ticks write none. Transactions/retries add RPCs. Duplicate concurrent drains remain possible and transaction-fenced. With no clipping or arrivals within the ceiling, a pass needs max(1, ceil(O/B)) accepted ticks; elapsed time depends on successful shared progress, not either advisory lease alone.
Validation and CI repairs
fresh_pending, which default transactional selection never calls. They now cover both modes, assert each race executed, and retain custody/predecessor assertions. Local result: 18 simulator passes, 36 real-store skips.The deliberate flood re-pin was verified with the documented updater and then without it, with all acceptance assertions unchanged. On source 202448d, the same held_15 counterfactual with the cursor off/on projects the same 396 GPU rows in 138.020/67.980 seconds: 172.149/349.515 rows per minute.
flood_metricsdivides by max(60, last_projection-flood_at)/60, so the denominator changes 2.300333→1.133000 minutes; neither hits the floor. Distinct-owner discovery shortens completion of the eligible GPU subset. Both runs retain 7,524 held provider rows, zero fresh pending and valid chains. This is observed projection throughput, not a provider release rate, and authorizes no metering-rate increase.Golden metric groups: held arms change p50 126.16→126.56 s (ratio 1.002→1.005), backlog ahead 16→5, with p90 unchanged at 198.979 s (0.995 baseline ratio). Unmetered FIFO p50/p90 move 171.769/423.5→168.004/417.65 s (ratios 1.364/2.118→1.334/2.088), retaining the >2x incident counterfactual. Unmetered fair-queue throughput moves 450.987→451.87 rows/min and p50/p90 134.897/208.71→134.71/207.073 s (ratios 1.071/1.044→1.07/1.035). Baselines, route mix, pending/held counts, chain validity and guard shares are unchanged. Workload, capacity, clock formula and acceptance thresholds were not changed.
Independent review and release prerequisites
Actual reviewer model: DeepSeek V4.1 Flash. Round one returned FIX on 2894ae8; round two returned FIX on 202448d for stale cursor writes: #25266 (comment). The current conditional-write fix addresses that finding, but these verdicts do not approve the new head. The issue Limits cap review at two rounds; owner disposition is pending. No third review, self-authorized release, merge or deploy is authorized.
This cursor addresses the 62-owner discovery population. After both committing services serve it and a full pass wraps, run the counts-only
infra/rollout/provider-stt-drain/stalled_fresh_owners.pyre-count. Baseline: 62 stalled owners / 1,317 ready fresh rows; 60 owners outside the 36-hour nudge window. Record serving identities and remaining head shapes before proposing more code. “Under a day late is fixed” remains open until that read shows the owners draining. The separate selection patch directly matched one owner and is not the fix for this population.Release owner dispatches the carried Firestore index definitions as step 0.
0007_ready_owners.sqluses plain CREATE INDEX inside a transaction and is not online-safe under PostgreSQL write traffic; production Postgres serving status remains unverified. Missing-index fallback is not acceptance proof. Rollback:BATCH_PIPELINE_READY_DISCOVERY_CURSOR_ENABLED=falserestores the old page and retains cursor state. No production action was performed.Failure-Class: FC-bounded-discovery-pinned-by-blocked-page