Skip to content

feat: resolve rollout cohorts from Firestore with a bounded cache - #22075

Merged
Git-on-my-level merged 58 commits into
mainfrom
lane/sol-allowlist-secret
Oct 18, 2026
Merged

Git-on-my-level merged 58 commits into
mainfrom
lane/sol-allowlist-secret

Conversation

@Git-on-my-level

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

Copy link
Copy Markdown
Member

Move rollout membership to environment-scoped Firestore user documents with a bounded cache, while preserving every live dev/prod cohort through deployment. Missing fields retain legacy env membership; explicit false revokes it. Missing or empty lineage env retains its legacy allow-all behavior, including dev. Parent switches and percentage ramps keep their existing behavior.

All four listen/pusher Helm charts retain their existing allowlist values and GKE declarations. This includes prod live demand, mobile Standard batch, Dream, lineage and speaker detail, dev audio coalesce, and the dev pusher transcription-shadow probe. Cloud Run omits private UID bindings and the complete prod messaging policy so its env merge preserves live iMessage membership. Env removal is a later, separate PR after seed and verification.

The lead-only operator supports --seed-live --dry-run, --seed-live --apply, and read-only --verify-live. It reads currently serving Cloud Run revisions and installed Helm values on prod-operator, prints counts only, compares exact environment-scoped sets, rejects divergent host lists/extra grants/source changes, and atomically merge-writes finite cohorts. Universal legacy cohorts retain their fallback without user enumeration. Cutover order: seed, verify, switch reads, verify live behavior, then remove env in a separate PR. Exact commands and the no-membership-change contract are in backend/docs/runbooks/rollout-cohorts.md.

One cached point read retrieves every cohort for a UID. Warm checks add zero Firestore reads; active resident users cost approximately one read/process/minute. Cold/expired async admission is warmed off the event loop. Account deletion erases the cohort document. Existing fail-closed behavior and the 60-second membership cache remain covered. Live archive phase admission is stable for an already-admitted connection and sees cohort changes on reconnect.

Validation: targeted file-isolated tests under nice -n 19 cover each listed gate in dev and prod, with both missing and identically seeded Firestore fields; operator tests cover counts-only output, exact-set comparison, atomic merge masks and no writes on drift. Deployment prechecks, make preflight, normal pre-push checks and exact-head GitHub CI are recorded in the task receipt after completion. No GCP tier, live account read, seed, deploy, or canary was run by this task. Keep this PR open and unmerged.

Failure-Class: FC-runtime-binding-contract

Guard artifacts: backend/tests/unit/test_rollout_cohort_membership_parity.py, test_rollout_cohort_deploy.py, and test_rollout_cohort_migration.py enforce the staged migration. This extends the existing Firestore adapter and runtime policy boundaries.

INV-MEM-4: preserved. Canonical memory authority is unchanged; the user-data document joins account-deletion erasure.

Product invariants affected

  • INV-DATA-1: preserved. The listen Helm chart-only lane gains a fail-closed check that the running image's commit contains the Firestore cohort resolver. This PR retains legacy UID env keys; removal is a later PR; no routing authority, Firebase/Firestore project, or serving endpoint changes.
  • INV-MEM-4: preserved. Canonical memory authority is unchanged; the user-data document joins account-deletion erasure.

Line-Count-Exception: backend/routers/sync.py | 2921 -> 2924 | Await cached membership at the OIDC boundary before rollout decisions; real coordinator regression covers cold/expired routing.
Line-Count-Exception: backend/utils/sync/pipeline.py | 3511 -> 3515 | Warm inline and Cloud Tasks coordinators before lineage selection; cache policy remains in the small helper.

Line-Count-Exception: backend/database/announcements.py | 625 -> 630 | Preserve main's runtime string validation for legacy announcement targets at an explicit Iterable[object] boundary; resolves the upstream Pyright error without changing filtering or suppressing a check.

Current main integration also fixes its announcement-target normalization typecheck while retaining the same runtime string validation.

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 18, 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-18T17:20:05.337796Z b96b619 New commits
ℹ️ 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: 5f35541c5d

ℹ️ 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 thread backend/docs/feature-flag-registry.md Outdated
| `BATCH_PIPELINE_SPEECH_EMPTY_MULTILINGUAL_ENABLED` | Default off; speech-positive empty batch ASR uses one independent multilingual recovery call within its paid intent | backend | env | closed | {value: 'false', category: rollout} | false (backend-listen (chart)); {value: 'false', category: rollout} (cloud_run/backend, cloud_run/backend-integration, cloud_run/backend-sync, cloud_run/backend-sync-backfill, gke/backend-listen) | false (backend-listen (chart), cloud_run/backend, cloud_run/backend-sync, cloud_run/backend-sync-backfill); true (cloud_run/backend-integration); {value: 'false', category: rollout} (gke/backend-listen) | — | pending | 2026-11-16 | dazheng |
| `BATCH_PIPELINE_TERMINAL_EMPTY_DISPOSITION_ENABLED` | Default off; positive strict VAD with exhausted GPU padded and multilingual recognition completes with distinct no_recoverable_speech result | backend | env | closed | {value: 'false', category: rollout} | false (backend-listen (chart)); {value: 'false', category: rollout} (cloud_run/backend, cloud_run/backend-integration, cloud_run/backend-sync, cloud_run/backend-sync-backfill, gke/backend-listen) | false (backend-listen (chart)); true (cloud_run/backend-integration); {value: 'false', category: rollout} (cloud_run/backend, cloud_run/backend-sync, cloud_run/backend-sync-backfill, gke/backend-listen) | — | pending | 2026-11-16 | dazheng |
| `BATCH_PIPELINE_UID_ALLOWLIST` | Explicit durable batch admission owner cohort; default empty and requires global enable; prod David-only rollout, dev off | backend | env | closed | — | '' (backend-listen (chart), cloud_run/backend, cloud_run/backend-integration, cloud_run/backend-sync, cloud_run/backend-sync-backfill, gke/backend-listen) | — | — | pending | 2026-11-14 | dazheng |
| `BATCH_PIPELINE_UID_ALLOWLIST` | Explicit durable batch admission owner cohort; default empty and requires global enable; prod David-only rollout, dev off | backend | env | closed | — | '' (backend-listen (chart), cloud_run/backend, cloud_run/backend-integration, cloud_run/backend-sync, cloud_run/backend-sync-backfill, gke/backend-listen) | secret (gke/backend-listen); valueFrom (backend-listen (chart)) | — | pending | 2026-11-14 | dazheng |

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Include Cloud Run secret bindings in the registry

Include service-level secrets when rendering deployment declarations. This row now reports the production allowlist only on GKE, although prod.overlay.yaml binds BATCH_PIPELINE_UID_ALLOWLIST on all four Cloud Run services; the same omission makes other migrated flags such as SYNC_LEGACY_FRESH_UID_ALLOWLIST and OMI_MESSAGING_CHANNEL_POLICY appear absent. Because scripts/render_feature_flag_registry.py::_manifest_envs reads only each host's env map, regeneration preserves the inaccurate operational catalog rather than exposing the secret-backed declarations.

AGENTS.md reference: backend/AGENTS.md:L134-L134

Useful? React with 👍 / 👎.

Comment on lines +515 to +517
if name in {'TRANSCRIPTION_SHADOW_UID_ALLOWLIST', 'TRANSCRIPTION_FINAL_PASS_UID_ALLOWLIST'}:
# Membership is private. Verify its exact source; the lead verifies payload equality.
return entry.value is None and entry.secret_name == 'prod-omi-backend-secrets' and entry.secret_key == name

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Remove cohort members from the reviewed-stage data

The new branch treats transcription membership as private but only stops comparing the value: config/diarization-cohort-stages.json still stores the exact UID under both allowlist keys in every stage, and this module's PROD_SHADOW_VALUES/PROD_FINAL_PASS_SHADOW_VALUES retain the same UID. Consequently, moving the deployment bindings to Secret Manager does not make this cohort membership private to anyone who can read the repository. Remove the UID-bearing fields from the reviewed-stage data and constants, and validate only the secret source for those fields.

Useful? React with 👍 / 👎.

Comment on lines +238 to +241
SYNC_LINEAGE_RESOLVE_UID_ALLOWLIST:
value: vi7SA9ckQCe4ccobWNxlbdcNdC23
secret:
name: prod-omi-backend-secrets
key: SYNC_LINEAGE_RESOLVE_UID_ALLOWLIST

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 Reject an empty lineage secret before deployment

If the newly provisioned secret version is empty or whitespace-only, this binding replaces the previous nonempty owner cohort with a value that config/sync_lineage.py::sync_lineage_resolve_uid_allowed interprets as admitting every user. Secret Manager permits payloads without a documented minimum size (SecretPayload contract), while preflight-cloud-run-deploy.py --check-secrets only describes the secret resource and verify_k8s_secret_keys.py only checks that the Kubernetes key exists, so both deployment gates pass this rollout-widening state. Validate a nonempty parsed cohort without logging its members before installing either binding.

Useful? React with 👍 / 👎.

@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: 48ce5c3972

ℹ️ 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 +105 to +106
# Private rollout cohorts; provision before deploying consumers.
- secretKey: BATCH_PIPELINE_RECOVERY_UID_ALLOWLIST

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Prevent bulk sync from installing cohorts on every service

When an operator runs the documented backend/scripts/sync_cloudrun_secrets_from_chart.sh prod helper, it builds SECRETS_FLAG from every entry in this chart and applies that complete set to backend, backend-sync, and backend-integration. These additions therefore install GKE-only and service-specific cohorts on Cloud Run hosts where prod.overlay.yaml intentionally omits them, while also bypassing the literal-removal handling added to the normal deployment renderer. Filter the helper's bindings using each service's manifest contract, or exclude these private rollout entries from its bulk path.

Useful? React with 👍 / 👎.

@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: 5234072b79

ℹ️ 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 +516 to +518
if name in PROD_PRIVATE_COHORT_NAMES:
# Membership is private. Verify its exact source; the lead verifies payload equality.
return entry.value is None and entry.secret_name == 'prod-omi-backend-secrets' and entry.secret_key == name

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Validate shared secret refs in the co-host gate

Expand this source check to the newly secret-backed values shared by pusher and backend-listen, especially DREAM_AGENT_UID_ALLOWLIST and SPEAKER_GROUPING_SHADOW_UID_ALLOWLIST. Their parsed literal values are both None, so the generic shared-value loop skips them; changing one chart's secret name or key still lets verify_pusher_cohost_env_diff.py pass and allows the two finalization hosts to serve different cohorts.

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

Useful? React with 👍 / 👎.

Comment on lines +32 to +37
if name == 'OMI_MESSAGING_CHANNEL_POLICY':
try:
policy = json.loads(payload)
except (ValueError, TypeError):
return False
return isinstance(policy, dict) and bool(policy)

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Reject malformed messaging policy objects

Validate the policy schema rather than accepting every nonempty JSON object. For example, {"imessage":[]} passes this preflight and the Kubernetes payload gate, but config.messaging.channel_policy() rejects it and silently returns a disabled policy; a malformed secret can therefore pass deployment checks while disabling production messaging. Reuse the runtime channel shape checks here, without logging the payload.

Useful? React with 👍 / 👎.

Comment on lines +172 to +175
- name: DREAM_AGENT_UID_ALLOWLIST
value: 'vi7SA9ckQCe4ccobWNxlbdcNdC23'
valueFrom:
secretKeyRef:
name: prod-omi-backend-secrets

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Validate cohort payloads in standalone pusher deploys

Add the decoded private-cohort payload gate to the standalone production pusher workflow before its canary Helm install. I checked .github/workflows/gcp_backend_pusher.yml: its pre-canary check uses verify_pusher_config_references.py --render-only, and the later live check verifies only object/key metadata, so an empty value introduced by secret rotation still starts the canary and is then rolled into the main pusher deployment. These new bindings would consequently drop the explicit Dream, speaker-grouping, and transcription cohort members without any deployment failure.

Useful? React with 👍 / 👎.

@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: 9e3c7e53e4

ℹ️ 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".

except (ValueError, TypeError):
return False
return isinstance(policy, dict) and bool(policy)
return any(member.strip() for member in payload.split(','))

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Validate recovery cohorts with the runtime UID rules

When BATCH_PIPELINE_RECOVERY_UID_ALLOWLIST contains only nonempty but invalid members (for example / or a value longer than 256 bytes), this generic check lets both deployment gates pass, but config/batch_pipeline.py::recovery_owners filters every member out. On the production integration host, where recovery mode is enabled, the rollout would therefore silently stop all cohort recovery despite a successful preflight; validate this payload using the same slash and byte-length rules as the runtime.

Useful? React with 👍 / 👎.

@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: 0e04126c3d

ℹ️ 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 +505 to +507
BATCH_PIPELINE_UID_ALLOWLIST:
secret: BATCH_PIPELINE_UID_ALLOWLIST
version: latest

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 Pin cohort secrets to immutable versions

When a cohort secret is rotated while an existing revision remains live, binding it as latest can split the cohort within that revision: Cloud Run resolves secret-backed environment variables whenever an instance starts, so newly scaled instances can receive the new allowlist while existing instances—and existing GKE pods—retain the old one. This can make lineage, batch, and transcription routing vary by instance despite the manifest requiring aligned hosts. Google explicitly recommends pinning environment-variable secrets to a particular version rather than latest; use immutable version numbers and advance Cloud Run and the ExternalSecret through a coordinated rollout. Cloud Run secret documentation

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

Useful? React with 👍 / 👎.

@Git-on-my-level Git-on-my-level changed the title fix(backend): source production UID allowlists from Secret Manager feat: resolve rollout cohorts from Firestore with a bounded cache Oct 18, 2026

@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: 46c2c8702b

ℹ️ 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 thread backend/database/rollout_cohorts.py Outdated
entry = _Entry(Future())
self.entries[key] = entry
if background:
from utils.executors import get_rollout_executor

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 Remove the reverse database-to-utils import

On an asynchronous cache miss, the database module imports utils.executors from inside this method. This violates both the required module-top import convention and the strict layering that permits utilities to depend on database modules, not the reverse; it makes a low-level persistence module dependent on serving infrastructure and risks circular or import-order failures as these cohort helpers are imported broadly through config. Move the scheduling responsibility above the database layer or inject a submitter, with imports remaining at module scope.

AGENTS.md reference: backend/AGENTS.md:L163-L169

Useful? React with 👍 / 👎.

Comment thread backend/database/rollout_cohorts.py Outdated

TTL_SECONDS = 60
MAX_USERS = 4096
COLLECTION = 'rollout_cohorts'

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 Namespace cohort membership by deployment environment

Both dev and prod declare based-hardware as their Firestore data-plane project, so this unscoped collection and its identically named boolean fields are shared across environments. The removed manifests had different memberships—for example, dev pusher admitted omi-release-probe to TRANSCRIPTION_SHADOW_UID_ALLOWLIST while prod admitted a different owner—and the runbook instructs operators to preserve every removed list. Seeding both therefore forms a union that admits the dev-only member in production whenever the production parent switch is enabled; namespace documents or fields by environment, or point dev runtime and its operator command at a genuinely separate data plane.

Useful? React with 👍 / 👎.

Git-on-my-level and others added 5 commits October 18, 2026 20:08
- Expose keyword-only firestore_client seams on both cohort Firestore
  adapters (read_memberships/read_cohort_members) and resolve the
  data-plane client at call time, per the persistence contract.
- Erase rollout_cohorts membership through the data-plane client during
  account deletion so split-plane dev wipes reach the real document.
- Bind the cached cohort resolver in the dedicated diarizer batch worker
  so live-reuse admission works when reuse-live is enabled.
- Fail closed the chart-only listen Helm lane when the running image's
  commit predates the Firestore cohort resolver, preventing the removed
  legacy env allowlist from admitting every user on an old image.

@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: e61ffaa741

ℹ️ 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 +49 to +50
legacy_all = not allowlist
return isinstance(uid, str) and in_rollout_cohort(uid, 'sync-lineage-resolve', legacy_all=legacy_all)

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 Preserve lineage scope when removing the legacy binding

When the staged cutover reaches the documented env-removal step, an absent SYNC_LINEAGE_RESOLVE_UID_ALLOWLIST is parsed as an empty set and therefore sets legacy_all=True. The migration writes only True fields for the currently listed members, so every other user lacking a sync-lineage-resolve field then falls through to this fallback and is admitted; a freshly recreated service without the preserved env has the same widening immediately. Distinguish the post-cutover absence from the legacy empty-means-all state, or install an explicit global policy before removing the binding.

Useful? React with 👍 / 👎.

Comment thread backend/config/audio_archive.py Resolved
Git-on-my-level and others added 2 commits October 18, 2026 21:04
Per-packet admission consulted the TTL cohort cache; an expiry window
schedules a refresh but misses until it completes, dropping archive
packets once per TTL on long connections. Snapshot the resolved
decision per phase at first use; listen warms membership at connection
start, so the snapshot is taken while warm.

@Git-on-my-level Git-on-my-level left a comment

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Deferred by design for this PR. Env removal is explicitly staged as a later, separate PR after seed and verification (see PR body), and every env binding — including SYNC_LINEAGE_RESOLVE_UID_ALLOWLIST — is retained here. The runbook already pins the exact constraint for that future step (backend/docs/runbooks/rollout-cohorts.md): "Do not remove this fallback in the later env-removal PR without an explicit representation of allow-all," and universal cohorts are reported as legacy_all=1 rather than enumerated. Absent-key-preserves-legacy is the intended migration contract (test_absent_keys_preserve_each_legacy_contract).

@Git-on-my-level

Copy link
Copy Markdown
Member Author

Monitor run summary — context a1376f285b

Review threads addressed this run (5 resolved, 1 acknowledged):

  • Firestore client seam — read_memberships/read_cohort_members now expose keyword-only firestore_client and resolve get_data_plane_firestore_client() at call time (persistence contract).
  • Account deletion data-plane routing — rollout_cohorts/{uid} erasure now goes through the data-plane client, so split-plane (dev) wipes reach the real document; the tombstone-wipe test injects the customer plane explicitly.
  • Batch worker cohort init — diarizer/batch_pipeline_runtime.py binds configure_rollout_runtime() so live-reuse admission resolves membership when reuse-live is enabled.
  • Chart-only old-image guard — the listen Helm chart-only lane fails closed unless the running image's commit contains backend/config/rollout_cohorts.py, preventing the removed legacy env allowlist from admitting every user on a pre-cohort image (workflow-contract tests cover both the pre-cohort and unresolvable-tag lanes).
  • Live archive admission stability — per-packet admitted() re-queried the TTL cohort cache; an expiry window scheduled a refresh but missed until it completed, dropping archive packets once per TTL on long connections. Admission is now snapshotted per phase at first use (regression test included).
  • Lineage env-removal widening — acknowledged on-thread as deferred by design: env removal is staged as a later PR and the runbook already forbids dropping the legacy_all fallback without an explicit allow-all representation.

Verification: targeted suites via the repo runner on the final head — test_rollout_cohorts (29), test_batch_pipeline_privacy (11), test_workflow_contracts (98), test_batch_pipeline_runtime (16), test_sync_ingest_archive (38), plus adjacent deploy/contract files (30+10+127+49+169 earlier in the run). PR-body ledger updated with the Line-Count-Exception/INV-DATA-1 entries the pre-push preflight reads. CI on head a8bf454e: all checks green, no new 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: c92269bff3

ℹ️ 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 +31 to +35
HOSTS = {
'stt-live-demand': {'helm/backend-listen'},
'mobile-standard-batch': {'helm/backend-listen'},
'sync-lineage-resolve': ALL_HOSTS - {'helm/pusher'},
'sync-legacy-fresh': {'cloud-run/backend-sync', 'cloud-run/backend-sync-backfill'},

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 Model host-specific cohorts before requiring a global seed

With the checked-in dev charts, TRANSCRIPTION_SHADOW_UID_ALLOWLIST contains omi-release-probe on pusher but is empty on backend-listen, while this map defaults that cohort—and other service-specific final-pass/recovery cohorts—to ALL_HOSTS. Consequently, the required --seed-live operation always reports a source conflict and exits before seeding any cohort, making the documented seed/verify-before-deploy sequence impossible. Scope these cohorts to their owning hosts (and environment where necessary), or represent host-specific membership in the stored schema.

AGENTS.md reference: backend/AGENTS.md:L169-L169

Useful? React with 👍 / 👎.

@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: b96b6194b6

ℹ️ 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 +151 to +153
rows = list(client.collection(COLLECTION).limit(LIMIT + 1).stream(timeout=10.0, retry=None))
if len(rows) > LIMIT:
raise ValueError('stored cohort inventory exceeds migration bound')

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Validate stored documents without a global cohort cap

Once the collection contains more than 450 legitimate user documents across all cohorts, both --seed-live and --verify-live fail here before performing their per-cohort comparisons. This can happen well within the supported model—for example, two disjoint cohorts with 226 members each—because the member queries support up to 499 users per cohort and the single-member CLI enforces no collection-wide limit. Paginate the schema validation rather than applying the atomic seed batch limit to the entire collection, otherwise routine cohort growth permanently disables the documented migration and verification commands.

Useful? React with 👍 / 👎.

@Git-on-my-level
Git-on-my-level merged commit e60c717 into main Oct 18, 2026
57 checks passed
@Git-on-my-level
Git-on-my-level deleted the lane/sol-allowlist-secret branch October 18, 2026 17:25
Git-on-my-level added a commit that referenced this pull request Oct 18, 2026
Prod backend-listen currently uses cost routing even though the
independent routing-off canary had better aggregate outcome rates. Set
only `STT_ROUTING_MODE=off` in prod listen values and the prod runtime
overlay, regenerate the runtime manifest, and keep dev unchanged. Static
selection, fallback/recovery, capacity rescue and account quarantine
remain enforced. No UID or account cohort is added; cohort work is
separate (#22075 / existing private operator mechanism).

The rollout config is commit `d8caeef8ae5`; lifecycle guard corrections
are a separate commit. No merge or deployment is part of this PR.

## Evidence and decision

Lead decision, 2026-10-18 16:08Z: proceed on pooled runs 4b+5b, same
image/config, 173 classified canary outcomes; rollback routing on.
Image:
`gcr.io/based-hardware/backend@sha256:be7f0fc660261f428b87fcd07f2b70f7ce63c78ac4f5e48bdf37e97d4e7a12f2`.
The canary override is exactly `STT_ROUTING_MODE=off`.

Values below are **canary routing off / simultaneous control routing
on**. Rates use accepted sessions except transcript success, which
excludes too_short. Earlier runs provide context; only 4b+5b supply the
approved pooled qualification.

| Run | Classified canary outcomes | Transcript success | Exhausted
chains / accepts | Terminal after text / accepts | Window first-text p95
| Historical stop |
|---|---:|---|---|---|---|---|
| 1 | 50 | 49/50 = 98.00% / 89.04% | 0/190 = 0% / 7.04% | 2/190 = 1.05%
/ 3.52% | 14.70s / 60.00s | 14/15 rolling success tripped the original
<95% absolute gate |
| 3 | 15 | 15/15 = 100% / 93.50% | 0/68 = 0% / 6.01% | 0/68 = 0% / 3.60%
| 40.51s / 9.78s | Rolling p95 41.26s on ~5 observations tripped the
retained latency gate |
| 4b | 105 | 101/105 = 96.19% / 93.16% | 0/314 = 0% / 4.26% | 4/314 =
1.27% / 2.33% | 20.75s / 22.47s | 3 combined failures among ~17 rolling
outcomes |
| 5b | 68 | 66/68 = 97.06% / 94.44% | 0/243 = 0% / 4.57% | 4/243 = 1.65%
/ 3.49% | 14.93s / 17.16s | Lifecycle accounting artifact |
| **Approved pool: 4b+5b** | **173** | **167/173 = 96.53% / ~93.92%** |
**0/557 = 0% / 275.53/6194.77 = 4.45%** | **8/557 = 1.44% /
187.35/6194.77 = 3.02%** | **No pooled quantile; both trials beat
control** | Lead accepted pooled evidence |

Canary totals are raw counters; control denominators/counts are
Prometheus extrapolated estimates. The pooled control success is
weighted from the reported trial estimates. p95 values cannot be
averaged or pooled without merging histograms; 4b/5b had 57/62 canary
first-text observations. First-text is Parakeet-window only, not
fleet-wide Modulate/Soniox timing. Exhaustion and terminal counters are
event proxies, not deduplicated user failure rates. Completion lags
acceptance. The overflow query was empty, so no zero-overflow claim is
made. These observations are not a randomized/provider-specific causal
proof. Run 3 latency was worse; the approved pool's outcome rates and
per-run first-text p95 beat control. Run 5b POST p95 was 0.667s versus
0.648s control.

Run 5b replay: `29 opened - 24 settled - 4 open = 1`. The same old guard
fired on routing-on MAIN 11 times: canary 1/279 opened legs (0.358%)
versus MAIN 11/~4303 (0.256%); three MAIN discrepancies predated the
trial by >8h. Transport release and settlement are independent. A
released pending leg produces +1; a settled transport still open
produces -1. The missing settlement's exact owner/session remains
unproven. The lead classified this abort as ARTIFACT, not evidence of a
routing-off serving regression.

The duplicate-settlement alert retains its stable UID and `settled >
opened` invariant with Grafana `for: 2m`. The additional
`omi-stt-leg-settlement-omission` warning evaluates `opened - settled -
currently_open` per instance/target. It requires a positive gap above
the nonnegative same-series carry-in one hour earlier for **15
minutes**. Run 5b `(29, 24, 4)` fires above a zero baseline; ordinary
in-flight legs, negative gaps, unchanged positive control carry-in and
shorter transients remain clear. Missing current components reset
pending via the existing no-data policy; new instances without hour-old
samples use a label-matched zero baseline.

The rolling one-hour baseline detects new debt and eventually ages
unchanged debt out of the alert. Keep the discrepancy recorded for
investigation after the warning resolves. This accounting warning means
HOLD/investigation, never automatic serving rollback. Direct
released-AND-unsettled counts/oldest age and pending ownership are still
needed for complete omission detection. Existing real outcome, latency,
readiness and coverage guards remain.

Merged `origin/main` (merge commit, no rebase), preserving both the
routing paragraph and projection-discovery section. The exhausted-chain
watch now sums each side before dividing, including an exact scoped
query in the query pack. The new warning is in both exports and the
existing import/coverage allowlists; the query inventory was regenerated
with the repository tool. The prod runtime diff remains only
`STT_ROUTING_MODE` on to off.

## Rollback

**Set `STT_ROUTING_MODE=on` in prod listen values and prod runtime
overlay, run `python3 backend/deploy/compose_runtime_env.py`, then
deploy through the normal prod listen Helm workflow with the same
image.** Alternatively revert config-only commit `d8caeef8ae5` and
deploy. This rolls/drains WebSockets. Avoid reverting an old entire Helm
revision and losing capacity fixes. The same one-line rollback is in the
ops runbook.

## Post-deploy watch

Before deploy pin the serving release SHA/image and exact main pods;
save a 30-minute pre-deploy baseline. After deploy verify the running
artifact's release identity, routing-off on all main pods, Ready/public
NEG/scrape coverage. Compare matched 15m and 30m windows against that
baseline through >=60 minutes and >=150 classified outcomes:

- Exhausted chains / accepted sessions, with both counts.
- Terminal-after-text / accepted sessions, with both counts.
- Transcript success = transcribed / (transcribed + no_transcript),
excluding too_short.
- First-text p95 with its observation count, noting Parakeet-window
scope; retain sampled latency safety gates.

Investigate any outcome-rate regression immediately and roll routing on
for sustained serving regression. Missing series are HOLD. Inspect
language/provider mix, fallback/exhaustion, scrape health and accounting
separately. Exact queries and rollback are in
`backend/docs/runbooks/live-stt-routing.md` and
`listen-stt-canary-queries.promql`.

## Validation

All tests and Helm checks ran through `omi-heavy` at `nice -n 19` in the
dedicated product worktree.

- Revised fleet alert behavior, monitoring rule contracts, alert
import/coverage and byte-identical export checks: **209 passed**. This
includes 15-minute Run 5b persistence, transient/missing-sample resets,
control carry-in, normal in-flight/negative states and mismatched-label
exhaustion operands.
- `backend/scripts/pre-deploy-check.sh`: **320 passed**, plus
runtime/workflow, frame storage and source-admission checks.
- Canary package gate suite: **30 passed**, including historical Run 5b
replay, real elapsed persistence, missing/stale scrape reset and
counter-reset coverage.
- `helm lint` and prod/dev `helm template`: passed with an explicit
render tag; prod was also rendered using the exact canary digest. Source
checks confirm only the prod routing mode changed.
- Monitoring query inventory regenerated; alert backtest lint passed
(existing unrelated legacy debt unchanged).

These are local source/config/fixture checks, not production deployment
or notification delivery. No GCP tier was used for this PR task and no
production account data was read. The canary execution evidence above
came from the recorded prod-operator runs.

Invariants: INV-MEM-4 — memory admission/promotion behavior is
preserved; the broad runtime manifest path selects this citation.

Failure-Class: FC-lifecycle-close-classified-by-transport-phase

The same contract applies at the alert boundary: expected transport
lifecycle state must not be classified as a serving fault. The
prevention artifact is
`backend/tests/unit/test_live_stt_alert_behavior.py`, covering expected
pending/open states alongside a true settlement invariant violation. The
sustained arithmetic warning is an accounting HOLD/investigation signal,
not a serving-loss classifier.

UI-Evidence: none -- backend deployment configuration and aggregate
alert logic only.


<!-- This is an auto-generated description by cubic. -->
<a
href="https://cubic.dev/pr/BasedHardware/omi/pull/22195?utm_source=github"
target="_blank" rel="noopener noreferrer"
data-no-image-dialog="true"><picture><source
media="(prefers-color-scheme: dark)"
srcset="https://www.cubic.dev/buttons/review-in-cubic-dark.svg"><source
media="(prefers-color-scheme: light)"
srcset="https://www.cubic.dev/buttons/review-in-cubic-light.svg"><img
alt="View guided diff"
src="https://www.cubic.dev/buttons/review-in-cubic-light.svg"></picture></a>
<a
href="https://www.cubic.dev/action/auto-fix/pr/BasedHardware/omi/22195?returnTo=https%3A%2F%2Fgithub.com%2FBasedHardware%2Fomi%2Fpull%2F22195&source=description"
target="_blank" rel="noopener noreferrer"
data-no-image-dialog="true"><picture><source
media="(prefers-color-scheme: dark)"
srcset="https://www.cubic.dev/buttons/turn-on-auto-fix-dark.svg"><source
media="(prefers-color-scheme: light)"
srcset="https://www.cubic.dev/buttons/turn-on-auto-fix-light.svg"><img
alt="Turn on auto-fix"
src="https://www.cubic.dev/buttons/turn-on-auto-fix-light.svg"></picture></a>
<!-- End of auto-generated description by cubic. -->
Git-on-my-level added a commit that referenced this pull request Oct 18, 2026
…t edges, hosts, audiences, ratchet

- task edges validate the configured route: full-URL edges must land on the
  handler route; recovery/worker edges must be bare origins (production
  appends its path) so a doubled path cannot pass
- service identity is canonical: a new canonical-host invariant requires all
  literal URLs naming a service to agree on one host, and task edges resolve
  against that mapping, so a typo'd project/hash no longer validates itself
- audiences are modeled as a pair: the dispatcher's minted audience must
  equal the target's verified audience (with the documented
  'AUDIENCE or handler URL' fallbacks), or every task is rejected 403
- the UID ratchet folds a non-sensitive count (uids=N) into the gap key, so
  appending to an accepted cohort fails instead of staying known
- the env-read scanner resolves named module-level token sets (_TRUTHY et
  al.), so flags like LIVE_SPEAKER_SPAN_RESOLUTION get boolean-token checks
- --ref loads both renderers from the archived tree instead of the checkout
- hermetic rendering unsets defaulted env_var bindings so ambient shell/CI
  values cannot mask a broken manifest default
- workflow contract sources now include the scanned reader entrypoints so
  reader-code PRs select this suite

Known gaps regenerated for the fingerprinted keys and the cohorts removed
from the manifest by upstream #22075; 0 new / 0 stale on dev and prod.

Test and harness code only; no production behavior change.
Git-on-my-level added a commit that referenced this pull request Oct 18, 2026
Prod listen stays `STT_ROUTING_MODE=on`, `STT_ROUTING_ON_PERCENT=100`.
This PR ships only the first-text instrumentation and runbook,
preserving production allocation. A separate draft stage-1 PR will carry
on/95 after the instrumented image has served on/100 for at least 60
minutes, with `image_tag` pinned to that same image.

Adds `omi_stt_routing_cohort_window_first_text_seconds{routing_arm}` at
the existing Parakeet-window first-emitted-text seam. The window socket
pins the managed session's arm before background work; only `off`,
`shadow`, and `on` labels exist. Existing histograms retain their schema
and semantics. This is window-leg latency, not all-provider end-to-end
timing; unmanaged sockets are excluded.

The runbook specifies 95→90→75→50→0, stage sample/dwell floors,
concurrent-control gates, operator review, and rollback to on/100 on the
same image. Chart, prod overlay, generated runtime manifest and flag
documentation retain on/100. The pipeline contract describes the
separate stage-1 change. No merge or deployment is included.

Image investigation: the canary/rollback image `5bb18b1` was not
identical to `ecd1f40`. #22134's metrics are exception-isolated, and
global off skips the scheduled score/cost writes; its backoff correction
preserves the deadline when no Redis write is attempted. #22075 adds one
cohort document read per account/pod/cache lifetime (60s), awaited up to
1.25s before the listen session, with a separate 4-worker/64-queue
executor. That is an admission confound, but the late first-text metric
begins after VAD speech, and rollback did not uniformly restore metrics.
Neither hunk is causally established as the regression, so this PR
contains no speculative health/cohort revert.

Validation: 255 focused tests passed (187 window, 27 cohort, 12
health-write fault/backoff, 29 resolver), plus 320 hermetic pre-deploy
tests. Tests used nice -n 19 through omi-heavy. Full repository
preflight passed all 38 checks after a serial rerun resolved a
concurrent temporary OpenAPI-directory cleanup race. Normal
pre-commit/pre-push hooks passed, including selected unit tests, Pyright
(zero errors), 17-image source closure, and runtime/deployment
contracts. The tests exercise real window/VAD/POST/receiver seams with
synthetic providers; production acceptance awaits a separately
authorized rollout.

Failure-Class: none
Product-Invariants: INV-MEM-4

INV-MEM-4: preserved. The generated runtime manifest retains listen
routing allocation at on/100; canonical intake, promotion receipts,
memory authority and projections retain their existing configuration and
behavior.

This is bounded observability and the runbook for a separately gated
allocation experiment; it does not change account migration authority,
credentials, data-plane routing, or user data. No GitHub workflow
change.
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.

2 participants