Repository navigation
Park allowance-exhausted batch jobs at sync intake - #25722
Merged
Merged
Conversation
Git-on-my-level
added a commit
that referenced
this pull request
Nov 19, 2026
…ting test The [all] case reparsed the full runtime manifest on every validator call and drifted past the 1.00 s CPU guard (0.92 -> 1.04 -> 1.10 s on hosted runners). Same test-only change as #25722. Co-Authored-By: Claude Opus 5.5 <[email protected]>
This was referenced Nov 19, 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.
Change
Sync upload intake now parks a new Omi-funded GPU job when the existing batch-funded resolver returns
plan_allowance_exhaustedfrom a verified monthly usage total. The previous path created a runnable job and deferred it after the worker leased it. Intake selects the definitive refusal after routing and staging, then the admission transaction writes the existingallowance_heldshape, the owner count, and the ordinary receipt together. The scheduler omits the ready-queue link. Replay returns the earlier receipt and count.accept_uploadknows the action's lane and frozen GPU/BYOK route at the probe. The existing worker maps this same monthly refusal toallowance_exhaustedon both fresh and backfill lanes. The independent Unlimited V2 backfill day cap is enforced at sync upload under #25677. The probe uses the qualified monthly reader only, has a one-second request budget, and accepts a ready meter document without rebuilding or scanning hourly usage. Provider, BYOK, native-record, budget, consent, ambiguous, and transient cases use their existing paths. The production Cloud Run manifest enables the monthly reader on backend-sync and backend-integration and keeps it off on backend and backend-sync-backfill.The admission transaction compares the controller's release fence and the UTC usage month. A raced generation check or rollover returns the unit to ordinary admission. The existing controller owns capture-ordered release and every released unit meets the same lease-time authorization. Existing privacy, staging, receipt, and purge fences protect the new entry path.
Flags and mixed versions
BATCH_ALLOWANCE_INTAKE_PARK_ENABLEDdefaults to enabled. The dev and prod Cloud Run manifests rendertrueforbackend-syncandbackend-integration, andfalseforbackendandbackend-sync-backfill. Intake also requiresBATCH_ALLOWANCE_PARK_ENABLED. Set the intake switch tooffon upload roles to restore new upload queueing followed by ordinary worker parking. Re-enable withtrue. The original switch controls the existing gradual drain for rollback past the parking protocol. Keep a parking-aware controller until that drain finishes.The frozen
ef42ee8scheduler walks owner queue links for pulls and only recovers leased or retry rows. Its pending queries requiremerge_pending=true. New held rows have no queue link andmerge_pending=false. On mixed intake revisions, older hosts create the existing runnable shape and newer hosts can create the existing held shape. Both reuse the same receipt ownership, privacy, and release paths.Expected savings (inferred)
Each direct park avoids the initial GPU lease and defer for that unit, along with its associated queue work. The intake probe adds an owner-fence read and a bounded funded lookup per qualifying upload. Net Firestore reads, upload latency, and time from upgrade to release require an authorized serving comparison. Existing all-reason deferral and recovery-park counters describe different event streams. Compare the committed
batch_intakedecision series with allowance-specificbatch_gpurefusals, lease rates, held-owner depth, and release latency.Verification
backend/test.shwith selected lists, nine unit files passed across the original run and the flag-budget rerun. Covered normal upload routing, definitive and transient answers, BYOK, switch-off, replay, scheduler and lifecycle guards, and verified-only monthly reads.On the rebased head,
backend/test.shpassed 432 tests across the five selected files for upload routing, allowance holds, batch unit policy, verified monthly usage, and the independent upload day cap.python -m pytest -m integration tests/integration/test_batch_allowance_holds.py tests/integration/test_conversation_batch_purge_emulator.py, filtered to the new cases. Passed two simulator cases, two Postgres 16 cases, and three loopback Firestore cases. Verified pending and lease exclusion, ordered release, release-generation fencing, replay, audio erasure and purge count idempotency.bash backend/scripts/pre-deploy-check.shpassed all 632 tests and the dev/prod source validators. Flag registry, parser, policy guard, and rendered runtime manifest drift checks passed.PYTHONPATH=backend python backend/scripts/cross_service_contract.pypassed with zero new violations and zero stale gaps. The local cross-service unit file hit its wall limit under shared host load. Its fixture now reuses the native safe manifest reader and the existing reader inventory for a chart-only mutation. The test matrix and timeout are unchanged. The isolatedpython -m pytest -m 'not integration and not slow' tests/unit/test_cross_service_deploy_contract.pycompleted on the rebased head with 34 passed and 3 opt-in replay cases skipped.The local push hook passed all 49 shared preflight checks, including the async and Firestore guards. Full
backend/scripts/typecheck.shreported zero errors. The metadata check passed with this PR body. Local proofs used synthetic fixtures and no GCP tier.The first GitHub run failed the call-phase CPU guard in two upload suites and one existing record-seal suite. The upload probe now checks eligibility in intake and performs billing imports inside the bounded executor call. A pytest setup fixture initializes the legacy seal helpers. The test assertions and timing threshold remain the same. The focused suites passed 549 upload and batch-policy tests and 219 record-seal tests. Backend unit workflow
Scope panel
scope-20261118t145633-d607returned DeepSeek. Luna and GLM timed out on the shared launch journal and both returned in the replacement panelscope-20261118t150434-f81d. Scope dossiers have no finding IDs and the triage CLI rejects F1 for this role.Review panel
review-20261118t200614-bd83reviewed6ff70f8446de. Luna's F1 was accepted and triaged. DeepSeek returned an empty terminal result and GLM failed to launch. F1 now checks for an eligible new GPU unit in a mixed upload. The regression reproduced the missed probe and verified that an exhausted new unit parks, the reused unit becomesresult_ready, and the transaction increments the held count once. Both selected suites passed all 272 tests. The panel identified batch custody as lead2-owned for any later merge decision.Round 2 review and CI fix
review-20261118t205848-2fcereviewed56c9d518c14. Both findings were recorded withomi-panel triage review-20261118t205848-2fce F1=accept F2=accept.backend-syncandbackend-integration. A rendered-state test pins the explicit values for all four Cloud Run roles in dev and prod.batch_intake; a unit test compares the documented inventory with the emitter enum.test_control_sync_routing_validates_deployed_values_without_changing_manifest[all]call used 1.07 seconds of CPU against a 1.00-second guard. The test now reuses the parsed manifest across its validator calls and keeps its assertions and guard. Prior shard logbackend/scripts/pre-deploy-check.shwith the 1.00-second CPU guard (636 tests),backend/test.shon five selected STT, upload and flag suites,backend/deploy/compose_runtime_env.py --check, andscripts/check_feature_flag_registry.py.Product invariants affected
This feature introduces intake parking. Pre-publication changes corrected flag wiring. GitHub CI then exposed cold imports inside the timed upload and record-seal test calls.
Failure-Class: FC-test-cold-import-in-call-budget
Line-Count-Exception: backend/utils/subscription.py | 1858 -> 1874 | The bounded intake read shares the resolver and launch-date policy. Moving the billing module would widen this change.
Implemented by a delegated agent for the batch owner-state program.