Skip to content

Park allowance-exhausted batch jobs at sync intake - #25722

Merged
Git-on-my-level merged 16 commits into
mainfrom
lane/bos-allowance-intake-park
Nov 19, 2026
Merged

Git-on-my-level merged 16 commits into
mainfrom
lane/bos-allowance-intake-park

Conversation

@Git-on-my-level

@Git-on-my-level Git-on-my-level commented Nov 18, 2026 •

Copy link
Copy Markdown
Member

Change

Sync upload intake now parks a new Omi-funded GPU job when the existing batch-funded resolver returns plan_allowance_exhausted from 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 existing allowance_held shape, the owner count, and the ordinary receipt together. The scheduler omits the ready-queue link. Replay returns the earlier receipt and count.

accept_upload knows the action's lane and frozen GPU/BYOK route at the probe. The existing worker maps this same monthly refusal to allowance_exhausted on 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_ENABLED defaults to enabled. The dev and prod Cloud Run manifests render true for backend-sync and backend-integration, and false for backend and backend-sync-backfill. Intake also requires BATCH_ALLOWANCE_PARK_ENABLED. Set the intake switch to off on upload roles to restore new upload queueing followed by ordinary worker parking. Re-enable with true. 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 ef42ee8 scheduler walks owner queue links for pulls and only recovers leased or retry rows. Its pending queries require merge_pending=true. New held rows have no queue link and merge_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_intake decision series with allowance-specific batch_gpu refusals, lease rates, held-owner depth, and release latency.

Verification

  • backend/test.sh with 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.sh passed 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.sh passed 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.py passed 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 isolated python -m pytest -m 'not integration and not slow' tests/unit/test_cross_service_deploy_contract.py completed 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.sh reported 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-d607 returned DeepSeek. Luna and GLM timed out on the shared launch journal and both returned in the replacement panel scope-20261118t150434-f81d. Scope dossiers have no finding IDs and the triage CLI rejects F1 for this role.

  • Accepted the bounded same-policy probe and ordinary path on failures. A verified-only monthly meter read avoids intake rebuilds and scans. The independent day cap stays with sync upload admission.
  • Accepted avoiding queue or control writes on the held path. The shared writer keeps one shape and one transactional count increment for a new job. The path stays within the lead2-owned batch-custody family and its existing Store transaction and release fences.
  • Accepted separating intake and lease telemetry, preserving the no-BYOK/no-provider exclusions, keeping billing imports lazy in upload intake, and testing rollback, replay, privacy, and store compatibility.
  • Accepted release-controller capacity and stale usage correction as rollout risks. A separate owner-led canary can measure the added load. Mid-period usage corrections follow the existing release generation semantics.
  • Chose an independent intake rollback switch. That gives operators the old create-then-park path without draining existing holds. Controller changes, fleet changes, source-ledger migration and changes to policy or custody are outside the lane.

Review panel

review-20261118t200614-bd83 reviewed 6ff70f8446de. 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 becomes result_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-2fce reviewed 56c9d518c14. Both findings were recorded with omi-panel triage review-20261118t205848-2fce F1=accept F2=accept.

  • F1 accepted. The shared manifest restricts the switch to backend-sync and backend-integration. A rendered-state test pins the explicit values for all four Cloud Run roles in dev and prod.
  • F2 accepted. The STT cap dispatch guide lists batch_intake; a unit test compares the documented inventory with the emitter enum.
  • The previous backend shard 5/8 passed all 296 pytest cases. The 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 log
  • Round 2 local verification passed backend/scripts/pre-deploy-check.sh with the 1.00-second CPU guard (636 tests), backend/test.sh on five selected STT, upload and flag suites, backend/deploy/compose_runtime_env.py --check, and scripts/check_feature_flag_registry.py.

Product invariants affected

  • INV-MEM-4. The batch receipt owns audio custody through scheduling. The existing projection and canonical promotion paths own memory mutation.

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.

View guided diff Turn on auto-fix

Implemented by a delegated agent for the batch owner-state program.

@Git-on-my-level
Git-on-my-level merged commit deef3b2 into main Nov 19, 2026
64 checks passed
@Git-on-my-level
Git-on-my-level deleted the lane/bos-allowance-intake-park branch November 19, 2026 06:56
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]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant