Skip to content

harden: add in-cluster Parakeet rollback and batch safety observations - #23441

Merged
Git-on-my-level merged 6 commits into
mainfrom
m1/incluster-guards-20261023
Oct 23, 2026
Merged

Git-on-my-level merged 6 commits into
mainfrom
m1/incluster-guards-20261023

Conversation

@Git-on-my-level

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

Copy link
Copy Markdown
Member

Production Parakeet rollback currently depends on the P77 laptop process surviving. Add an independent Kubernetes CronJob that can perform only the pre-approved drift-checked HPA rollback, plus a batch observer that clearly reports incomplete coverage.

Behavior and deployment

  • Every 5m, Forbid overlap, 240s deadline, no retries; small non-root CPU-only Python Job using the existing digest-pinned monitoring image.
  • Arm only workloadOnly floors 5/8 without the latency metric, after a full 15m observed HPA configuration/generation and image window. Ordinary autoscaling replica changes preserve the arming clock. Persist the clock and K=3 consecutive blind readings in one name-scoped ConfigMap. Missing/stale/nonfinite data never passes as clean. Fresh low-count samples, including successful undefined idle histogram/ratio arithmetic, report LOW_SAMPLE without tripping quiet hours; missing series/query errors remain blind.
  • Preserve P77 thresholds and exact step_fast.build(old,12,True) patch/drift assertions. JSON Patch tests the entire observed /spec; sets min=12 and restores parakeet_request_latency_p99 Value=3. No serving Deployment writes.
  • The mounted entrypoint uses the shared dependency-free structured logger. Add an explicit ConfigMap launch binding to the logging guard, verifying source/mount wiring and byte equality of the generated logging-module copy; no logging exemption or pending allowance.
  • Dedicated KSA: named HPA get/patch, named deployment get, namespace events list, named state ConfigMap get/patch. No secrets, exec, cluster RBAC or GCP WI annotation.
  • Existing batch queue metrics are scraped through a PodMonitor installed by this release. Fresh oldest uncommitted age >30m emits TRIP/log/annotation and fails the Job. This is a historical-inclusive proxy, not proof of a new projection wedge.

Lead dispatch after merge: workflow gcp_incluster_guards.yml (Deploy In-cluster Safety Guards) on main, inputs environment=prod, source_sha=<full merged SHA>, dry_run=false, enabled=true. Dev: environment=development, same merged SHA; workflow forces dry-run. This installs only prod-omi-incluster-guards in prod-omi-backend; it never invokes the Parakeet rollout workflow. Kill switch: same dispatch with dry_run=true; remove resources with enabled=false. Inspect scheduled readings and full-window arming before retiring the P77 owner.

After this exact head is merged, the lead can dispatch:

gh workflow run gcp_incluster_guards.yml --repo BasedHardware/omi --ref main \
  -f environment=prod -f source_sha=4d712a5b8a22eae0395774b5ac2428d0a1c7327e \
  -f dry_run=false -f enabled=true

Explicit v1 blockers / lead and David asks

  1. Batch is partial. No Prometheus metric exists for new projection obligations >15m, pinned-object custody loss or VAD-proven speech loss. Those are recorded as unavailable, never clean. Retain the P90 guard until the missing signals are implemented and verified. Queue age includes historical/deep obligations, so it is alert-only and never rolls back admission.

  2. Alert delivery needs activation verification. Existing monitoring disables Alertmanager; Grafana owns pages. This chart emits structured JSON, failed Jobs and state annotations but cannot assert a page is delivered. The runbook includes a bounded-age failed-Job query; lead must wire/verify the Grafana route before unattended reliance. Verify live backend -> monitoring TCP/9090 network policy too; the committed policy selects only listen-edge pods.

  3. Future Cloud Run rollback requires David's specific access approval. batch.cloudRunRollbackEnabled=false is reserved and fails rendering if enabled in v1; no Cloud Run read or write path exists. Proposed GSA [email protected]; on it bind roles/iam.workloadIdentityUser to serviceAccount:based-hardware.svc.id.goog[prod-omi-backend/prod-omi-incluster-guards], then annotate only that KSA with iam.gke.io/gcp-service-account=<GSA>. Bind custom projects/based-hardware/roles/omiBatchAdmissionGuard (run.services.get, run.services.update, run.revisions.get) to the GSA on each us-central1 service backend, backend-sync, backend-sync-backfill, backend-integration; grant run.operations.get via a separate project-scoped custom role, and roles/iam.serviceAccountUser only on each actual runtime SA if required for actAs. Reads need Cloud Run IAM too. Separate metadata-read approval is needed for Firestore/GCS if the missing P90 signals are not exported first. None of these access changes is made by this PR. A follow-up must verify every traffic-serving revision, preserve unrelated config/custody/recovery, set only BATCH_PIPELINE_PERCENT=0, and honor the P90 fresh-state clocks.

  4. CI timing blocker: on final head 4d712a5b8a22eae0395774b5ac2428d0a1c7327e, backend shard 1 completed its assertions but failed its wall-time gate: 722s versus 720s. All other checks passed. Evidence: failed shard. No duration budget or check was weakened. A prior head also exceeded by one second and passed a failed-only rerun; this final-head timing failure remains open.

The proposed identity bindings apply Google's GKE impersonation procedure and Cloud Run IAM permissions; the actual project/service bindings remain an approval-gated proposal.

Why isn't this a shared primitive instead? This is the reusable in-cluster implementation of the existing P77 process, removing laptop liveness from the rollback boundary; it does not add another developer checklist. The real instance is the 2026-10-23 P77 workloadOnly floor ramp protected by guard_fast.py/step_fast.py. Related merged autoscaling incident: #21673 (GPU metrics were scoped to unrelated workloads). The original drift assertions protect that autoscaling boundary; we do not silently rewrite its metrics on unexpected drift.

Verification

All commands run through /Users/david/workspace/omi-workspace/bin/omi-heavy run -- ... with ambient Google/Firebase/Kubernetes credential paths unset for tests. No kubectl/helm/gcloud cluster calls, deployment, workload env reads, or production API requests were made.

  • cd backend && .venv/bin/python -m pytest tests/unit/test_incluster_guards.py tests/unit/test_logging_entrypoint_guard.py tests/unit/test_backend_unit_selector_output.py -q — 186 passed (1.02s); production one-shot path with fake APIs, ± thresholds, low samples, blind persistence, arming resets, drift refusal, frozen P77 patch equivalence, Prometheus failures, dev/prod Helm rendering and exact RBAC/CPU placement. Monitor URLs and release labels are checked against the existing adapter and Parakeet values, including the distinct dev stack name.
  • actionlint .github/workflows/gcp_incluster_guards.yml — passed.
  • python3 .github/scripts/check-deployment-concurrency.py — passed (31 persistent writers).
  • python3 .github/scripts/check_ci_budget.py --refresh — reviewed: manual-only guard deploy, zero PR runs, 5m p50, Backend infrastructure owner.
  • make preflight with OMI_PR_BODY_FILE=/tmp/incluster-guards-pr-body.md — 44 checks passed in 191.21s, including the mounted-script logging inventory. The normal pre-push gate also passed: 44 manifest checks (180.20s), full backend typing with 0 errors, runtime source closure, selected unit tests, and the remaining bounded hooks. Full typing reports 0 errors.

Product invariants affected

  • INV-DATA-1 — the workflow selects the existing environment/cluster deploy identity and installs only guard resources. It introduces no client, Firebase, Firestore, or serving-authority routing change.

Failure-Class: none

View guided diff Turn on auto-fix

🤖 Generated with Claude Code

Git-on-my-level and others added 2 commits October 23, 2026 14:02
…d CronJob

Port the approved atomic HPA rollback with a persisted full-window clock and
blind counter; expose explicit partial batch coverage without Cloud Run IAM.
Deploy independently of serving charts and verify ConfigMap logging provenance.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
The enforced pre-push typecheck inherits seven unnecessary-isinstance errors
from main. Describe the supported None input in turn-ref annotations, and use
the dict config directly after owner() has already validated it. Keep tool
RunnableConfig injection annotations and all fail-closed owner/ref checks.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 23, 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-23T19:26:39.787909Z 4d712a5 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: b249a24ef9

ℹ️ 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 +3 to +6
prometheusUrl: http://dev-omi-kube-prometheus-s-prometheus.dev-omi-monitoring.svc:9090
dryRun: true
batch:
monitoringRelease: dev-omi-kube-prometheus-stack

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 Point the dev guard at the actual Prometheus release

The development monitoring stack is installed as dev-kube-prometheus-stack, whose Prometheus service is dev-kube-prometheus-stack-prometheus (also used by backend/charts/monitoring/prometheus-adapter/dev_omi_prometheus_adapter.yaml), not the dev-omi-* names configured here. Consequently every dev Prometheus request resolves to a nonexistent service, while the mismatched monitoringRelease label prevents the real Prometheus instance from selecting this PodMonitor, so development guard runs remain BLIND and cannot validate the rollout before production.

Useful? React with 👍 / 👎.

@Dimank92

Copy link
Copy Markdown
Contributor

💰 Payout Details

  • Bounty Recipient Wallet: 0xC345C07229307d4f1c7935aD2cAe48e390215808
  • Networks: Polygon / Base / Arbitrum / Stellar
  • Token: USDC

Resolve dev Prometheus and PodMonitor labels from the established dev stack
rather than assuming the production release prefix. Assert both environments'
rendered references against adapter and Parakeet values, and select this suite
when those dependencies change.

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

@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: 5568ba1ee3

ℹ️ 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 +59 to +62
'no_text_deadline': inc(
'omi_stt_window_session_outcome_total',
'{job="backend-listen-metrics",outcome="no_text",reason="first_text_deadline"}',
),

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 Initialize the deadline-error series before requiring its presence

When no session has hit a first-text deadline since the listen processes started, this query returns no series rather than zero. WINDOW_SESSION_OUTCOME in backend/utils/stt/live_metrics.py has no preinitialized label children, and parakeet_window.py creates this particular child only when recording that failure. Consequently, otherwise healthy traffic produces missing_or_nonfinite_no_text_deadline on every reading and automatically rolls back after the 15-minute warmup. Initialize the bounded error-counter child in the exporter, or distinguish its legitimate absence from unavailable telemetry using independently verified scrape health.

Useful? React with 👍 / 👎.

Comment on lines +188 to +189
deployment['metadata'].get('generation'),
[c['image'] for c in deployment['spec']['template']['spec']['containers']],

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 Exclude ordinary autoscaling from the arming identity

When the Parakeet HPA changes the Deployment's replica count, Kubernetes also increments the Deployment generation, so including that generation here resets the full arming window during ordinary autoscaling even though the HPA policy and serving image are unchanged. Every such reset suppresses existing latency, scheduling, and readiness trips for another 15 minutes; repeated scaling can keep the guard in WARMUP throughout a degraded period. Identify serving changes through the pod template or another rollout-specific identity instead of the Deployment generation that also tracks replica changes.

Useful? React with 👍 / 👎.

Git-on-my-level and others added 3 commits October 23, 2026 15:09
Deployment generation changes on replica writes as well as rollouts. Exclude
it from the tuning-state identity so autoscaling and scheduling shortfalls
cannot perpetually restart warmup. Retain HPA spec/generation and image resets,
and cover a desired-replica increase with the original 15-minute deadline.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Resolve the two incidental typing-prerequisite conflicts using main's #23440
implementation. The final guard PR diff no longer changes retrieval behavior.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Luna P1 on #23441: source_sha pinned the chart files but not the workflow
definition, so a prod dispatch from an unmerged branch could run modified
auth/Helm steps. Gate the prod deploy job on refs/heads/main.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@Git-on-my-level
Git-on-my-level merged commit 8cb72df into main Oct 23, 2026
58 checks passed
@Git-on-my-level
Git-on-my-level deleted the m1/incluster-guards-20261023 branch October 23, 2026 20:13
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