Skip to content

feat(backend): share internal Gateway across model services - #21473

Merged
Git-on-my-level merged 1 commit into
BasedHardware:mainfrom
Git-on-my-level:lane/shared-internal-gateway
Oct 14, 2026
Merged

Git-on-my-level merged 1 commit into
BasedHardware:mainfrom
Git-on-my-level:lane/shared-internal-gateway

Conversation

@Git-on-my-level

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

Copy link
Copy Markdown
Member

Add a shared regional internal Gateway for embeddings, batch diarization, Parakeet, VAD and NLLB. Environment values enable per-service routes and policies on separate -gw Services selecting existing pods; default values leave them off. Batch uses its own route with its Ingress disabled. Existing embedding/STT/VAD/NLLB Services, Ingresses and BackendConfigs keep their rendered content, and no caller URL changes in this PR.

LLM gateway is excluded because its deployment verification derives the existing Ingress endpoint. The runbook stages dev before prod, installs/qualifies batch first, then NLLB → VAD → embeddings → Parakeet; it includes exact full URL changes for all current caller bindings, including VAD's /v1/vad suffix and Parakeet's embedding fallback, and caller/Helm rollback commands.

Validation:

  • Helm renders both environments, checks rewrites, separate selectors, health/policy attachment, 30s/120s/900s timeouts and Parakeet's 130s draining, defaults and missing configuration errors.
  • 65 pre-existing rendered documents matched the origin/main baseline across eight renders; original Service/Ingress template files are unchanged.
  • backend/.venv/bin/python -m pytest -q backend/tests/unit/test_internal_gateway_helm.py backend/tests/unit/test_diarizer_batch_prereqs.py — 22 passed.
  • Expanded adjacent Helm/deployment/workflow contracts — 143 passed. Runbook bash blocks passed bash -n.
  • OMI_PR_BODY_FILE=/tmp/omi-internal-gateway-pr.md make preflight — all 31 selected checks passed.
  • Read-only GCP inspection confirms both GKE 1.35.8 clusters, their VPC-native networks and active proxy-only subnets, and Cloud Run backend's private-ranges-only egress. No cluster mutations or live Gateway qualification performed; lead owns live qualification.

Runbook: backend/charts/internal-gateway/README.md.

Why isn't this a shared primitive instead? The shared Gateway is the primitive; service charts retain ownership of their distinct routes and policies. Tests execute Helm rendering and are registered in the existing workflow-contract selector, rather than adding a new checker or CI workflow.

Failure-Class: none

Existing chart versions are retained to preserve legacy rendered labels byte-for-byte; the new Gateway chart starts at 0.1.0. This is the lead-approved infrastructure refactor, not a reactive incident fix. No product source file exceeds the line-count ceiling; no line-count exception is needed.

View guided diff

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 14, 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-14T09:40:49.240775Z e4bd937 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: e4bd937e7a

ℹ️ 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 +214 to +216
# On failure, retain the job for lead diagnosis; never advance to the next service.
gcloud run jobs execute "$probe" --project="$ML_PROJECT" --region="$ML_REGION" --wait --quiet
gcloud run jobs delete "$probe" --project="$ML_PROJECT" --region="$ML_REGION" --quiet

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 Propagate failed probes before deleting evidence

When an earlier python3 Gateway/HTTPRoute assertion returns nonzero, this helper is still running under ordinary bash without set -e, so execution continues and an eventual successful gcloud ... delete becomes the function's zero status. The rollout can therefore advance despite a failed control-plane gate, while the unconditional deletion also defeats the stated intent to retain evidence; make the helper and its callers propagate every nonzero status and delete only after all checks succeed.

Useful? React with 👍 / 👎.

Comment on lines +2175 to +2178
The optional [shared model Gateway](../charts/internal-gateway/README.md) adds
`/diarizer`, `/diarizer-batch`, `/parakeet`, `/vad` and `/nllb` routes through
separate Services while preserving existing Ingresses. This chart change leaves
caller URLs unchanged; the lead switches one service at a time, including every

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 Retire the standalone batch Ingress rollout instructions

During a production batch rollout, this document's authoritative later section (backend/docs/listen_pusher_pipeline.mdx:4562-4572) still directs the lead to scripts/diarization_eval/batch_install.md, which reserves prod-diarizer-batch-ilb-ip-address, validates a standalone Ingress, and cuts HOSTED_DIARIZATION_API_URL to http://diarizer-batch.omi.me:80 (lines 98-147). The overlay now disables that Ingress and only serves /diarizer-batch on a different shared VIP, so following those still-linked “exact” gates sends cohort traffic to an unused address or no matching route; update or retire the older section and runbook in this migration.

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

Useful? React with 👍 / 👎.

@Git-on-my-level
Git-on-my-level merged commit b8770bc into BasedHardware:main Oct 14, 2026
52 checks passed
Git-on-my-level added a commit that referenced this pull request Oct 14, 2026
…21482)

## Summary

Single runtime-env PR for the shared model Gateway rollout. Two
independently revertible commits:

1. David-only batch diarization shadow on backend, backend-sync and
pusher through `http://172.16.160.20/diarizer-batch`. Both cohort
percentages 0, authoritative false, sync false. Strict scope/parity
checks accept only a complete reviewed ramp stage. The pyannote adapter
appends `/v2/diarization`.
2. NLLB → `/nllb`, VAD → `/vad/v1/vad`, and every speaker-embedding
caller → `/diarizer` in dev/prod, including Parakeet's embedding
fallback. Parakeet STT endpoints remain unchanged.

**Reserved addresses:** dev `172.16.48.49` (fresh ro-dev lookup after
reservation appeared), prod `172.16.160.20` (ro-prod lookup). Both
environments use concrete IPs. Reservation is not serving qualification:
lead must probe Gateway programming, routes and caller reachability
before deploying. No production user API calls, merge, deploy or ramp
were performed.

## Exact ramp data

Complete env sets: `config/diarization-cohort-stages.json`. Common
values on backend/backend-sync/pusher:

```text
HOSTED_DIARIZATION_API_URL=http://172.16.160.20/diarizer-batch
TRANSCRIPTION_FINAL_PASS_DIARIZER=pyannote_shadow
TRANSCRIPTION_FINAL_PASS_BACKEND=pyannote
TRANSCRIPTION_FINAL_PASS_UID_ALLOWLIST=vi7SA9ckQCe4ccobWNxlbdcNdC23
TRANSCRIPTION_FINAL_PASS_SYNC_ENABLED=false
TRANSCRIPTION_SHADOW_ENABLED=true
TRANSCRIPTION_SHADOW_KILL_SWITCH=false
TRANSCRIPTION_SHADOW_UID_ALLOWLIST=vi7SA9ckQCe4ccobWNxlbdcNdC23
```

Combine these constants with this exact stage data (column names
abbreviate `TRANSCRIPTION_`; values are strings):

| Stage | FINAL_PASS_PERCENT | SHADOW_PERCENT | FINAL_PASS_AUTHORITATIVE
| SHADOW_DAILY_AUDIO_HOURS | One-line prod overlay change, then redeploy
all three |
|---|---:|---:|---|---:|---|
| A David shadow | 0 | 0 | false | 1 | `&batch_cohort` line: percentages
`"0"`, authoritative `"false"`, hours `"1"` |
| B David authoritative | 0 | 0 | true | 1 | Same line: authoritative
`"true"` |
| C 1% authoritative + David | 1 | 1 | true | 80 | Same line: both
percentages `"1"`, hours `"80"` |
| D 5% authoritative + David | 5 | 5 | true | 400 | Same line: both
percentages `"5"`, hours `"400"` |

`backend/deploy/runtime_env/prod.overlay.yaml` owns the shared mapping.
After that one-line data edit, recompose `runtime_env.yaml`, align
pusher chart literals with the selected stage, validate, and redeploy.
No runtime code or guard changes per stage. Do not exceed 5%; wait
**≥12h at D** before proposing expansion. Hold every stage for
sufficient gate samples.

At **each A/B/C/D** check failure rate
(`omi_transcription_final_pass_total`, failed:*;
`omi_transcription_shadow_total`), p95 latency
(`omi_transcription_final_pass_latency_seconds`,
`omi_transcription_shadow_latency_seconds`), speaker agreement
(`omi_transcription_final_pass_agreement`) and word distance
(`omi_transcription_shadow_word_distance`), owner parity
(`omi_transcription_shadow_owner_delta_ratio`), remap correctness
(`omi_transcription_shadow_remap_success_rate`,
`omi_transcription_shadow_remap_safe_total`), and out-of-profile /
determined language rate (`omi_stt_output_language_segments_total`
conformance labels; `live_stt_language_summary` logs). Also inspect
`event=transcription_shadow`, scalar v2 results, batch queue
`omi_diarization_v2_queue_depth`, 429/5xx, GPU load and
current-revision/manual-annotation promotion receipts. Empty series do
not pass; use matched baselines and review parity before B. No UID
labels exist in aggregate metrics.

## Capacity / limits

The existing Redis daily cap is configurable and charges all selected
stored audio, not just multi-speaker GPU work. At planning load 6,300
h/day, C/D select ~63/315 h; 80/400 h provide headroom. D's ~140
multi-speaker h/day × supplied T4 RTF .06 = **8.4 GPU-h/day**, ~35%
average occupancy on one T4. This is planning arithmetic, not a new T4
load-test receipt; queue/latency/bursts gate the ramp. Two-hour
worker/API cap remains bounded: ~432s inference at .06 RTF versus 600s
worker deadline and 900s Gateway timeout. ASR/decoding/queue consume the
same worker budget. Longer calls retain legacy attribution; inspect
`failed:too_long` metadata and excluded duration share. Sync stays false
through D. Cloud Run process-local shadow dispatch is not durable: equal
env does not prove Cloud Run receipt completion; durable shadow dispatch
remains required for reliable Cloud Run coverage.

## Deploy order / rollback

See `backend/docs/diarizer-batch-cohort.md`,
`backend/docs/internal-gateway-callers.md` and
`backend/charts/internal-gateway/README.md` for lead operations. Qualify
Gateway/routes from GKE and Cloud Run first. Dev caller migration first,
then prod; NLLB/VAD readouts and ≥30m hold, followed by coordinated
embedding switches across all six speaker-ID hosts plus Parakeet
fallback. Use listen/pusher workflows, `gcp_backend.yml`,
`gcp_parakeet.yml`. Then independently deploy batch A and advance
through gates. Listen carries NLLB/VAD/embedding together; qualify every
route before that workflow and review NLLB/VAD separately before
finishing the embedding cohort.

Rollback caller commit alone and redeploy every affected caller,
including Parakeet fallback; restore legacy hostnames/cluster-local
fallback from the runbook. Keep the Gateway while batch still uses it.
After either revert, recompose `runtime_env.yaml` from the retained
overlays (this also resolves generated-manifest conflicts without
undoing the other commit). Rollback cohort commit alone and redeploy
backend/backend-sync/pusher, or return to A to stop promotion; incident
stop sets shadow kill switch true plus final-pass diarizer legacy.
Disable batch callers before removing its capacity. Keep legacy
Ingress/DNS ≥7d. No historical record rewriting.

## Validation

- `backend/scripts/pre-deploy-check.sh`: dev/prod manifest and
workflow/render validation passed; 305 deploy-safety tests passed.
- `BACKEND_UNIT_TEST_FILE_LIST=/tmp/cohort-fast-tests.txt bash
backend/test.sh` (run from backend with its local Python): 65 tests
passed across cohort, caller, co-host guard and adapter contracts; CPU
duration guard enabled.
- `backend/test.sh` with `test_verify_pusher_config_references.py`: 28
rendered binding contract tests passed, CPU duration guard enabled.
- `python scripts/test_check_feature_flag_registry.py`: 24 tests passed,
including shared-map resolution.
- `make preflight`: 41 selected checks passed; final pre-push passed the
manifest checks, typecheck (0 errors), source closure (16 images) and
changed backend tests.
- Independent rollback verified with a temporary Git index and
recomposed overlays: each configuration preserves the other migration.
Cohort revert requires regenerating the shared manifest as documented.

Runtime-only changes exercise rendering and hermetic adapters rather
than calling production user APIs. Lead-owned serving probes and
acceptance are not performed by this PR.

## Product invariants affected

- INV-MEM-4 — runtime manifest changes preserve the existing canonical
memory authority bindings.

Why isn't this a shared primitive instead? The shared final-pass policy,
Redis cap and adapter already exist (#21424); this PR binds them and
reuses the shared Gateway (#21473). Stage data and the existing co-host
guard prevent the obsolete endpoint or widened/mixed cohorts prepared in
3ec0377. Registry rendering resolves the shared overlay mapping so
documented effective bindings remain accurate.
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