Repository navigation
feat: globally pace held-audio recovery - #22970
Merged
Merged
Conversation
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
Git-on-my-level
added a commit
that referenced
this pull request
Oct 21, 2026
Picks up #22995 (P17 capture_live_recovery fix) and main through 31756b9, which includes #22877 episodes (d6b734b; prod deploy freeze until the EPISODES_PERCENT=0 overlay lands, staging allowed per lead 88c5cd). Conflicts: - utils/sync/cap_hold_recovery.py: main's optional recovery cohort (#22991) and pacing metrics (#22970); module gates on recovery_admission_enabled. Kept integration's lane-returning _selected_lane, funded-processing reservation and batch hand-off. - main.py / app_roles.py: kept the B8 role-map mount; Mount(episodes) added in main's position (between pending_work and commitment_followup). - .github/ci-budget.yaml: six rationale strings carry both sides' notes. - config/feature-flags.yaml: both sides' rows; registry re-rendered. Adaptations: 8 label-debt entries (episodes/memory-source/held-content metrics, owner lane 14); test_summary_delivery first-import case allowlisted. Co-Authored-By: Claude Opus 5.5 <[email protected]>
This was referenced Oct 21, 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.
Recovery can currently create provider intents without a shared audio budget. This adds an always-on, fail-closed Redis Lua token bucket immediately before each new intent, including persisted retries. Pacing denials durably defer the hold without creating a provider attempt or metered charge.
Redis is the existing cross-pod rate-limit pattern (
database/redis_db.py), with server-clock Lua also used by import quotas and messaging pacing; a dedicated bounded client uses the same Redis bindings without adopting fail-open behavior. One atomic, global key spends audio seconds and intent tokens together using Redis TIME. Plain env defaults are 60 audio-hours/hour and 12,000 provider intents/hour (pieces/retries count conservatively toward the holds ceiling), with one minute of burst credit. Missing/evicted state starts empty. Invalid config, unavailable Redis, ambiguous replies and oversized pieces defer; uncertain tokens are never refunded.The existing durable owner cursor stays in place. The sweep now gives each discovered owner one newest-first candidate per round, up to 100 turns/owner within the existing 900-second budget. Holds retain fenced claims/receipts, consent, cutoff, original-lane and allowance checks. Release preserves durable retry deadlines, claim respects them, and sealing/cleanup plus cached-result settlement stay independent of pacing.
Metrics expose intent decisions and requested audio tokens with only
outcome=granted|deferred|refused, plus sampled age since first durable pacing deferral. The deferred-age histogram is not a fleet maximum; existing fleet custody gauges remain authoritative.Validation:
BACKEND_PYTEST_WORKERS=4 BACKEND_UNIT_TEST_FILE_LIST=/Volumes/Ephemeral/scratch/recovery-pacing/focused-tests.txt /Users/dazheng/workspace/omi/bin/omi-heavy run -- nice -n 10 bash backend/test.sh(equivalent environment placement used in the actual run).144c0ecbf7d3287f46113db6362b53180f59585e.Lessons and debt: release previously overwrote retry timestamps, so durable pacing needs both a fenced defer checkpoint and a claim/release contract. Ambiguous writes conservatively waste credits. Round-robin candidates add lease/query overhead and do not guarantee equal audio shares for multi-piece holds. The one-minute burst plus the nominal two-minute sweep cadence can underfill the configured rate when visits finish quickly; the configured rate is a ceiling, not demonstrated drain throughput. Frozen pieces larger than the burst envelope remain held for operator diagnosis/replanning (ordinary VAD defaults to 300 seconds). All recovery hosts must share the Redis endpoint and capacity values; mixed runtime config is unsupported. Live throughput/activation, unsupported-language and explicit-consent/restart acceptance remain prerequisites for STT cap 100%. No production writes, account reads, Cloud Logging, deployment or merge; no GCP tier used. Ready for Grok review.