Skip to content

feat: narrow held-audio recovery with an optional cohort - #22991

Merged
Git-on-my-level merged 2 commits into
mainfrom
lane/recovery-cohort-narrow
Oct 21, 2026
Merged

Git-on-my-level merged 2 commits into
mainfrom
lane/recovery-cohort-narrow

Conversation

@Git-on-my-level

@Git-on-my-level Git-on-my-level commented Oct 21, 2026 •

Copy link
Copy Markdown
Member

Change

Held-audio recovery follows the same effective dispatch cohort as listen (prod: pct:25). A one-account production recovery receipt would therefore wake other in-cohort owners with existing consent. (Correction: staging is isolated. All four staging services run FIRESTORE_DATABASE_ID=staging in based-hardware-dev with in-cluster Redis, and the integration data-plane fence in database/_client._firestore_database_id() refuses to boot against prod Firestore, prod buckets or omi.me hosts. On staging this variable is defence in depth; for the prod probe it is the guard.)

Add STT_CAP_RECOVERY_COHORT as an optional intersection with effective dispatch membership, enforcement and original lanes. It reuses the dispatch uid:, pct:N, and sole all grammar. Absent preserves existing behavior; malformed (including empty) denies all recovery and emits one warning per process without private tokens. Listen hold admission and backlog display remain unchanged. omi_stt_cap_recovery_cohort_narrowed{state="unset|set|malformed"} is a one-hot configuration gauge with no UID labels.

Gate the processing-backlog API and manual/upgrade consent, durable-redrive owner visits, worker entry/continuation, direct wakes, selected manifests, recovery rows, and new sync provider attempts. Custody sealing/cleanup remains active. No held-audio recovery entry path was found that could not be gated.

This uses shared admission primitives and the existing parser rather than a second cohort resolver or a new control document. Extend the existing subject-bearing gate check to cover the recovery predicates.

Validation

  • make setup passed in the dedicated worktree.
  • Backend tests run through omi-heavy, from backend, with BACKEND_PYTEST_WORKERS=4 BACKEND_UNIT_TEST_FILE_LIST=<private test-path list> nice -n 10 ./test.sh.
  • Initial focused suite: 2,287 passed across 10 files. Final expanded recovery/pipeline checks: 373 passed across four files, including 173 new recovery-cohort cases. The two runs cover 2,390 distinct cases across 11 files (overlapping reruns counted once).
  • make preflight: 36 checks passed. PR metadata validation: 4 checks passed. Standalone async-blocker scan: zero blocking findings.
  • HTTP coverage uses FastAPI TestClient against the production route with synthetic owners and mocked persistence; no staging, production, provider or GCP calls. No GCP tier was used.

Staging probe plan (separate deployment/window authorization)

  1. Deploy the reviewed SHA to based-hardware-dev services backend-staging and backend-sync-staging. Through the private-values path, set STT_CAP_RECOVERY_COHORT=uid:<test> on every API/sync recovery executor before enabling recovery. Never commit the value or include the identity in a public receipt. Staging data isolation comes from the data-plane fence; still audit serving revisions and scheduler targets.
  2. Keep the shared rollout_cohorts/stt-cap-dispatch document and listen hold admission unchanged. Privately verify that the agent-owned test account belongs to the effective dispatch cohort; this env cannot add it. Verify the running release identity and fresh state="set" metric on every participant. A state gauge does not attest the private UID, so inspect the effective value privately.
  3. Update the private qualification driver's config attestation to verify this intersection; its previous probe-only shared-dispatch requirement is insufficient for this new setup. Reserve the agent-owned account exclusively, preserve its preexisting state, and use the existing held-audio qualification procedure to capture/seal synthetic held audio, fund recovery and give explicit consent.
  4. Require held-to-published content, exactly one stable metering debit, same-key replay without another debit/provider attempt, source cleanup and a completed receipt. Use hermetic negative-owner tests and aggregate metrics; do not read or change other owners' accounts. Stop on capture-integrity/reconciliation errors, backlog stalls or a sync 5xx regression. Retain evidence and resolve the qualification runbook's other receipt/claims prerequisites before proceeding.

Production probe and ramp (separately authorized after staging passes)

  1. Deploy the reviewed SHA and set the same private uid:<test> narrowing on all production API/sync recovery executors before activating recovery. Verify release identities, traffic/scheduler targets, the private effective values, effective dispatch membership and fresh state="set" metrics. Keep listen and the shared cohort unchanged.
  2. Execute exactly one approved recovery receipt on the agent-owned account, with the same acceptance and replay/metering checks as staging. Do not automatically rerun a failed prod attempt. No broader user consent, hold or data changes.
  3. Owner: dazheng / subscription rollout lead. Ramp: staging probe → one prod receipt → unset by 2026-10-23, after reviewing clean receipts, capture-integrity/reconciliation, backlog and 5xx metrics. Remove the variable through the private-values path to widen to the full existing effective dispatch cohort, then verify state="unset". This may resume other owners' already-consented holds. A missed deadline is a blocker; no automatic widening. The registry records this ramp.
  4. Stop new recovery with pct:0 on every API/sync executor, retaining custody/redrive and listen behavior. In-flight accepted calls may finish. Emptying the variable fails closed; removing it widens and is not rollback.

No environment calls, flag flips, secret writes, deploys or merge were performed by this PR task.

Product invariants affected

none

View guided diff Turn on auto-fix

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 21, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-21T06:31:54.286615Z 6473716 PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 6473716f43

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment on lines +110 to +112
raw = os.getenv('STT_CAP_RECOVERY_COHORT')
state = _recovery_cohort_state(raw)
return state == 'unset' or state == 'set' and cohort_admits(uid, raw)

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Wire the recovery cohort into deployed executors

When the documented probe sets STT_CAP_RECOVERY_COHORT=uid:<test>, the repository's Cloud Run deployment path cannot propagate that value to the backend and backend-sync recovery executors: the key is absent from backend/deploy/runtime_env/_base.yaml and its overlays, and it is not an approved live-managed setting in check_cloud_run_env_drift.py (the only private-values path found targets the GKE listen chart). Those revisions therefore read None here, which line 112 deliberately interprets as unrestricted, allowing recovery for the entire effective dispatch cohort instead of only the probe account. Add a private runtime binding for every API/sync recovery executor before making the unset state fail open.

AGENTS.md reference: backend/AGENTS.md:L151-L153

Useful? React with 👍 / 👎.

@Git-on-my-level
Git-on-my-level merged commit ed1d9c8 into main Oct 21, 2026
56 checks passed
@Git-on-my-level
Git-on-my-level deleted the lane/recovery-cohort-narrow branch October 21, 2026 07:14
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]>
Git-on-my-level added a commit that referenced this pull request Oct 21, 2026
Held-audio recovery for the original-live cap cohort runs only when API and
backend-sync declare STT_CAP_DISPATCH_ENFORCEMENT=true. The base manifest pins
it false, so every Cloud Run deploy reset recovery off. Pin it on in the prod
overlay. Merge with the 100% cap step, when the #22991 narrowing is removed.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Git-on-my-level added a commit that referenced this pull request Oct 24, 2026
* feat(deploy): keep STT cap enforcement on for prod API and sync

Held-audio recovery for the original-live cap cohort runs only when API and
backend-sync declare STT_CAP_DISPATCH_ENFORCEMENT=true. The base manifest pins
it false, so every Cloud Run deploy reset recovery off. Pin it on in the prod
overlay. Merge with the 100% cap step, when the #22991 narrowing is removed.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* docs: regenerate feature flag registry for the prod cap enforcement overlay

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* chore(deploy): recompose runtime_env.yaml for the prod cap enforcement overlay

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* test(deploy): prod API and sync enforce STT cap dispatch in the runtime manifest

The manifest guard still asserted the pre-rollout dark-everywhere state
after this branch flipped STT_CAP_DISPATCH_ENFORCEMENT to 'true' for the
prod backend and backend-sync Cloud Run services. Encode the new intended
state instead: enforcement on for exactly those two prod services, dark
everywhere else, cohort runtime-doc driven (empty in the manifest), lanes
live-only.

Fixes the Backend unit shard 2/6 failure (and the aggregated Backend unit
suite) on run 39604250788.

* chore(deploy): describe STT cap dispatch enforcement in the prod overlay accurately

The overlay comment described held-audio recovery, which is one consumer
of the gate, not what the flag does. State the actual behavior: funded
STT cap dispatch admission, cohort- and lane-gated, with the cohort
resolved from the runtime rollout document.

---------

Co-authored-by: Claude Opus 5.5 <[email protected]>
Co-authored-by: David Zheng <[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