Skip to content

Scope STT cap enforcement by user cohort and lane - #22494

Merged
Git-on-my-level merged 15 commits into
mainfrom
feat/stt-cap-cohort-lanes
Oct 19, 2026
Merged

Git-on-my-level merged 15 commits into
mainfrom
feat/stt-cap-cohort-lanes

Conversation

@Git-on-my-level

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

Copy link
Copy Markdown
Member

Scope funded STT execution to a UID cohort and its original audio lane, for both legacy and ladder-only budget enforcement. Empty/unset cohort enforces nobody; all, uid:<uid> and stable pct:<0..100> tokens reuse the retired free-tier grammar and hash bucket. Unset or blank lanes default to live only. Batch is code-fenced off until lane8 writes provider_reason=byok into binding.policy at batch admission; configured batch warns once per process while preserving live/sync selection. Checked-in dev/prod values are false / empty / live.

Live receiver admission, sync v1/v2, segment processing, per-owner queued GPU work and cap-hold recovery share the policy. Recovery follows encrypted original provenance (missing legacy origin = sync; unknown origin stays paused). Generated/text work uses batch. Flag-off and custom-STT receivers bypass admission before identity access. Mixed-owner batches check every owner.

Excluded backlog work preserves consent and cursor resumability. An atomic choice-owner/month/source/debit fence refunds a selected estimate only for provably never-started work. Any claim, checkpoint, receipt or uncertain proof retains the reservation, including empty released lease tokens. Same-month authorized pending upgrades can advance without losing skipped work. No usage-ledger refund is introduced.

Owner dazheng expands coordinator test accounts → 1% → 5% for 3 hours → 25% → 100%, checking held-audio count, backlog stalls, live STT error rate and client 5xx at every step. The registry/runbooks require a checkpoint and report missed expansion as blocked. Sync/batch remain excluded pending the separate GPU-lock authorization move behind #22352. No production flag was changed.

First cohort configuration, after supplying confirmed test-account UIDs:

STT_CAP_DISPATCH_ENFORCEMENT=true
STT_CAP_DISPATCH_COHORT=uid:<COORDINATOR_TEST_UID>
STT_CAP_DISPATCH_LANES=live

The UID placeholder is deliberately unresolved; no production account data was read. Both legacy and ladder-only admission use this same cohort and lane scope.

Validation at e60c268396faecd080aea43764b14a81533f0080: serial backend/test.sh passed 2,462 tests across 19 files, including the 1,754-case production cohort/lane readiness matrix, recovery/VAD cases, and 26 preview validation cases. Changed-file isolation checked 53 files with zero violations; runtime-image source closure passed all 14 registered images. All four metadata checks passed with the documented dispatch line-count justification, and the full backend typecheck passed with zero errors. The approved future-ready cap_rollout.py fixture remains restricted to legacy enforcement suites; production-readiness tests do not import it and assert the real batch constant is false.

The main integration preserves original hold-lane forwarding and VAD file-clock offsets while adopting main #22539 speaker and preview validator helpers. Independent source comparison expands only the two dispatch helpers, verifies every argument binding and the absence of discarded executable statements, and obtains the exact prior pipeline AST. The preview file is byte-identical to main and adds no feature delta. The other 115 previously changed paths and all 32 fixture consumers retain their previously reviewed bytes. Cap policy, readiness tests and dispatch documentation match 77e02e21; the approved fixture and two legacy suite wirings match 92aeb268.

Four test-only compatibility repairs retain stronger coverage against current APIs: request-ID validation imports the real module, transcript mocks assert CLIENT_FINALIZE, external-tool tests retain all five secret-sanitization assertions with real package imports, and Joan tests bind the registered followup route while retaining all access assertions and checking blocked side effects. Main already contains the batch vector-cleanup fixture repair.

The normal gated push passed all required local checks at this exact published head. Grok extended its review to this exact published head and returned NoActionableFindings, with 1,993 tests passing across ten files. Full GitHub CI passed at this exact head: all six backend shards, guardrails and aggregate, plus the Listen/Pusher stack gauntlet passed. The rollup was terminal with 41 successful and 24 skipped checks, zero pending or failed checks. The PR remains unmerged and no deployment was performed. The PR remains open; no merge or deployment is authorized.

The repository-wide isolation audit has two unchanged baseline violations (test_apps_exception_hardening.py:26, test_task_integrations_sanitization.py:9); the required changed-file guard passes. No allowlist, bypass or workflow was added. Tests use synthetic storage/provider boundaries; no live deploy, GPU inference or external STT acceptance is claimed. No GCP tier or credentials were used. No scheduler job or Firestore index was added. The GPU-lock relocation remains separate.

The shared policy and alias-aware call-site regression guard prevent admission checks without a UID/lane subject.

Line-Count-Exception: backend/utils/sync/pipeline.py | 3580 -> 3592 | Keep the UID/lane admission closure and original hold-origin metadata at the existing segment dispatch boundary; these 12 lines preserve scoped authorization through recovery and provider retries.

Failure-Class: FC-cohort-gate-consulted-without-its-subject

Product invariants affected

  • INV-DATA-1: existing desktop deployment bindings gain scope values; routing authority is unchanged.
  • INV-MEM-1 and INV-MEM-3: memory admission passes UID/batch; existing tier and canonical authority remain intact.
  • INV-MEM-4: execution scope does not change canonical promotion or intake contracts.
  • INV-TASK-2: conversation processing supplies its subject/lane to existing admission; capture retains its suggestion policy.

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 19, 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-19T18:50:31.922378Z e60c268 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: 14ca1f0b96

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

if not await save(updates):
return False
continue
if not await _selected(uid, item):

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 Defer when the selection lookup is unavailable

When _selected() catches a transient manifest or metadata read failure, it returns None, but this condition treats None like a definitive scope exclusion, advances the durable cursor, and sets scope_skipped. The current run therefore skips an eligible audio item and only revisits it after finish() rewinds the cursors and a later external sweep or user trigger starts another run. Handle None separately by returning from the current attempt, as the reserved-item path already does, rather than persisting an exclusion.

Useful? React with 👍 / 👎.

@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.
To continue using code reviews, add credits to your account and enable them for code reviews in your settings.

@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: 924fcd4be1

ℹ️ 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 +393 to +394
if not await selected_for_recovery(uid, row):
return False

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 Settle completed holds before enforcing dispatch scope

When a recovery writes state=completed but crashes before _settle_and_erase, a later live-only rollout causes an existing sync-origin hold to return here before settlement, even though no further provider dispatch is required. The content ledger and held audio then remain indefinitely until the sync lane is re-enabled; check state == 'completed' and perform settlement before applying the cohort/lane gate to unfinished work.

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

Useful? React with 👍 / 👎.

Comment on lines +72 to 73
if not funded_processing.enabled(uid):
return None

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 Persist paid upgrades for paused cohort members

When a user already has an active processing choice but is temporarily removed from the cohort, this early return also rejects automatic=True calls from the payment upgrade handlers. If the user upgrades while the rollout is paused and is later re-enrolled, the durable choice retains its old allowance and cutoff because no pending_upgrade was recorded, so newly purchased backlog capacity is never applied; automatic upgrade intents for an existing active choice need to be persisted independently of current dispatch membership.

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

Useful? React with 👍 / 👎.

Comment on lines +2384 to 2385
if any_execution_admission_enabled(uid):
processing_backlog.remove(uid, conversation_id)

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 stale backlog rows after cohort exclusion

When a UID has a processing_backlog_items row from an earlier rollout and is subsequently excluded or the cohort is cleared, deleting its conversation now skips removal of that sibling row. The backlog summary continues counting deleted content and the orphan remains until the UID is re-enrolled and a worker happens to encounter it; conversation deletion should clean an existing backlog row regardless of whether new dispatches are currently admitted.

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

Useful? React with 👍 / 👎.

aryanorastar and others added 5 commits October 19, 2026 22:16
Replace retired JIT-budget imports with current request-ID behavioral coverage. Refresh the audio-copy fixture's vector cleanup dependency without changing production code or test gates. Refs #22552. Failure-Class: none
Assert CLIENT_FINALIZE in processor fakes. Replace collection-time package mutation with real tool imports, current async invocation and valid caller context; retain all sanitization assertions. Refs #22552. Failure-Class: none
@Git-on-my-level
Git-on-my-level merged commit 80ad1f9 into main Oct 19, 2026
69 checks passed
@Git-on-my-level
Git-on-my-level deleted the feat/stt-cap-cohort-lanes branch October 19, 2026 19:14
aryanorastar added a commit that referenced this pull request Oct 21, 2026
…tate (#22595)

## Summary

Makes three backend test files independent of deployment state and the
fast-unit CPU budget. Main's backend CI is green, and most of the drift
this PR first repaired has since been fixed on main (#22494, #22539);
those edits were dropped in favor of main. What remains:

- `test_developer_from_segments_idempotency.py`: a `segment_api_client`
fixture builds the FastAPI router and auth overrides once, outside the
request being measured, so router setup no longer counts against the
fast-unit CPU guard.
- `test_modulate_stt.py`: the "Deepgram disabled" cases patch
`PROVIDER_SERVING_SURFACES` explicitly instead of relying on whichever
providers the current policy happens to disable. They are renamed from
"retired" to "disabled" to say what they test.
- `test_streaming_deepgram_backoff.py`: adds coverage that a configured
cloud Deepgram serves the available streaming languages, alongside the
existing refusal cases.

## Verification

- All three files pass on the merged tree (66 + 104 + 86 passed), each
in its own pytest process.
- Test-only; no production code, flag, deployment or data change.

Failure-Class: none

## Product invariants affected

none

🤖 Generated with [Claude Code](https://claude.com/claude-code)
ZhaZhaBei pushed a commit to ZhaZhaBei/omi that referenced this pull request Oct 22, 2026
…re#22494 cohort/lane cap scope)

Conflicts, each kept from both sides:
- rollout_cohorts.valid_uid: main's UnicodeError guard plus the _ramp doc-prefix exclusion.
- runtime_percent/legacy_sync_mode: kept alongside parse_cohort/cohort_admits.
- batch admission: (owner, 'batch') scope, then the BYOK skip, then sync_allowed(lane='batch').
- imports: storage_executor plus cap_hold_reservations; rate card plus hold_lane.

Silent semantic conflict fixed: the batch hand-off in recover_selected
called _new_dispatch_allowed(uid), but main made it (uid, lane), which would
have raised a TypeError at runtime. It now gates on the hold's original lane
through _selected_lane(), the same scope as the legacy path.

Test adaptations for main's (uid, lane) APIs: the cap-hold batch tests use
main's cap_rollout fixture and stub lane selection. Main's
backlog-reservation test stubs lane 6's open_units, which reads Firestore.

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.

2 participants