Skip to content

fix(pusher): bound delivery and runtime failure handling - #10678

Merged
undivisible merged 12 commits into
mainfrom
codex/pusher-audit-optimization
Jul 29, 2026
Merged

undivisible merged 12 commits into
mainfrom
codex/pusher-audit-optimization

Conversation

@undivisible

@undivisible undivisible commented Jul 26, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

  • preserve transcript, audio, speaker-sample, and finalization delivery across cancellation, reconnect, and transient send failures
  • validate Pusher wire frames and sample rates, bound per-session buffered audio by bytes, and expose closed-label drop metrics
  • split protocol/buffer ownership and durable finalization into utils/ without router cross-imports or compatibility aliases
  • document the validated wire-frame, bounded buffering, replay, and durable finalization contracts
  • run the Pusher container without Kubernetes API credentials, root, privilege escalation, or Linux capabilities
  • pin the native LC3 source, correct the dev GCP project, remove redundant credential injection, and qualify .dockerignore changes
  • delete the obsolete mirrored batch-upload suite and broken unused Helm connection hook

Root cause

The legacy Pusher path had independent queue, reconnect, shutdown, image, and deployment-config owners without one enforced failure boundary. Buffers were cleared before sends completed, item-count limits did not bound variable-size audio memory, malformed frames reached application paths, and deployment defaults retained stale privilege and credential assumptions.

Impact

Transient failures no longer silently discard buffered work, malformed clients fail with protocol close codes, one connection cannot retain unbounded queued audio, and the runtime has a smaller credential and container privilege surface. The router is reduced from 1,056 to 753 lines, with protocol and finalization behavior isolated behind existing production seams.

Validation

  • 148 focused Pusher runtime, transcript-dispatch, finalization, and infrastructure tests passed
  • bounded pre-push backend selection: 82 passed
  • backend typecheck: 0 errors
  • python3 backend/scripts/validate_rendered_deployment_contract.py
  • Pusher rollout, source-closure, config-reference, and observability preflights
  • make preflight: 26 checks passed

Failure-Class: none

Related: #6060, #6752, #6800, #9237, #9786

Review in cubic

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

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Thanks for the careful pusher hardening work here. The direction looks valuable: bounding the runtime buffers, reducing container/Kubernetes privilege, pinning the LC3 source, preserving pending deliveries across transient send failures, and adding focused regression coverage all fit the reliability/security goals for this surface.

I don't think this is ready to mark review-complete yet, mainly because this PR changes the listen/pusher protocol/runtime boundaries and the current shape conflicts with the repo's backend ownership rules:

  1. backend/routers/pusher.py now imports routers.pusher_finalization and routers.pusher_protocol. backend/AGENTS.md defines the backend import hierarchy as database -> utils -> routers -> main.py and explicitly warns that cross-importing between routers will break. These extracted helpers are not route handlers, so they should live under an appropriate utils//service module (or another non-router helper package) before this lands.

  2. This changes the listen/pusher WebSocket protocol behavior and finalization semantics (frame validation, opcode handling, durable finalization handoff, buffering/retry behavior), but docs/doc/developer/backend/listen_pusher_pipeline.mdx was not updated. The backend guide specifically requires that doc to move with changes to the listen/pusher WebSocket protocol.

The CI/check coverage is encouraging, and I did not see a security/supply-chain attack pattern in the diff. Because the PR is still draft and touches workflow/deployment-sensitive pusher runtime paths, I’m leaving this as changes requested rather than approval; a maintainer should still review the deployment/runtime implications after the module boundary and docs are fixed.


by AI on behalf of David — if you need David’s attention urgently, please @Git-on-my-level and escalate with need human response.

@undivisible

Copy link
Copy Markdown
Collaborator Author

Addressed both review blockers in 364b1189cb: Pusher protocol/finalization helpers now live under utils/, and the listen/Pusher pipeline documentation now records the validated frame, bounded buffering, replay, and durable finalization contracts. Current-main preflight passes all 26 checks.

@mintlify

mintlify Bot commented Jul 27, 2026

Copy link
Copy Markdown

Preview deployment for your docs. Learn more about Mintlify Previews.

Project Status Preview Updated (UTC)
omi 🟢 Ready View Preview Jul 27, 2026, 3:15 AM

💡 Tip: Enable Workflows to automatically generate PRs for you.

@mintlify

mintlify Bot commented Jul 27, 2026

Copy link
Copy Markdown

Preview deployment for your docs. Learn more about Mintlify Previews.

Project Status Preview Updated (UTC)
omi 🟡 Building – Jul 27, 2026, 3:14 AM

💡 Tip: Enable Workflows to automatically generate PRs for you.

@undivisible
undivisible marked this pull request as ready for review July 27, 2026 04:11
@cursor

cursor Bot commented Jul 27, 2026

Copy link
Copy Markdown

Bugbot is not enabled for your account, so this pull request was not reviewed.

Enable Bugbot in the Cursor dashboard to get automatic reviews on future PRs.

@Git-on-my-level Git-on-my-level added the needs-maintainer-review Needs a human maintainer to sign off before merge label Jul 28, 2026

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

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Thanks for the follow-up here. I re-reviewed the current head and the two blockers from my previous review look resolved: the protocol/finalization helpers now live under backend/utils/, and docs/doc/developer/backend/listen_pusher_pipeline.mdx now documents the validated frame handling, bounded buffering/replay behavior, and durable finalization handoff.

I’m leaving this as a positive maintainer signal rather than a formal approval because the PR is still a large backend runtime/deployment change touching the pusher WebSocket protocol, durable finalization ownership, container privilege, Kubernetes credential mounting, and deploy-trigger paths. Those are the right areas to have a human maintainer look over before merge even though the automated checks are now green.

I did not see a serious security/supply-chain attack pattern in the current diff. The security hardening direction is good: pinned LC3 source, non-root pusher container, disabled service-account token automount, explicit frame validation, and bounded per-session buffering are all improvements. Main thing left is human review of the rollout/runtime implications before landing.


by AI on behalf of David — if you need David’s attention urgently, please @Git-on-my-level and escalate with need human response.

@Git-on-my-level
Git-on-my-level dismissed their stale review July 28, 2026 01:00

Current head moved protocol/finalization helpers under backend/utils and updated the listen/pusher pipeline documentation, resolving the two blockers from this automation review.

Retain transcript and audio buffers until WebSocket sends succeed, release cancelled half-open probes, and isolate transcript sinks so one integration cannot suppress another.

Verification: focused Pusher tests (51 passed); backend typecheck (0 errors); Pusher rollout gate passed.

Failure-Class: none
Build liblc3 from an exact reviewed commit and remove the unused Helm test that probed a nonexistent root route with a mutable image.

Verification: source-closure tests passed; Pusher rollout and source-closure gates passed.
Restore cancelled sends, bound shutdown retries, validate wire inputs, expose queue drops, and dispatch transcript sinks independently.

Delete the mirrored private-cloud test suite in favor of production-handler coverage.

Verification: 128 focused tests passed; backend typecheck reported 0 errors.

Failure-Class: none
Use a Dockerfile environment constant instead of an overridable build argument and enforce that contract in the source-closure test.

Verification: source-closure tests and runtime-image contract passed.
Disable Kubernetes service-account token automount in both environments and verify the rendered pod contract.

Verification: rendered contracts, rollout gates, and config-reference preflights passed.

Failure-Class: none
Verification: python3 backend/scripts/validate_rendered_deployment_contract.py; python3 backend/scripts/verify_pusher_config_references.py --environment dev --namespace dev-omi-backend --render-only; python3 backend/scripts/verify_pusher_config_references.py --environment prod --namespace prod-omi-backend --render-only; python3 -m pytest -q --noconftest backend/tests/unit/test_pusher_auto_deploy_paths.py backend/tests/unit/test_verify_pusher_source_closure.py backend/tests/unit/test_rendered_deployment_contract.py backend/tests/unit/test_verify_pusher_config_references.py (43 passed)

Failure-Class: none
Verification: python3 backend/scripts/validate_rendered_deployment_contract.py; python3 backend/scripts/verify_pusher_rollout_gate.py preflight; python3 backend/scripts/verify_pusher_rollout_budget.py; python3 backend/scripts/verify_pusher_source_closure.py; python3 -m pytest -q --noconftest backend/tests/unit/test_pusher_auto_deploy_paths.py backend/tests/unit/test_verify_pusher_source_closure.py backend/tests/unit/test_rendered_deployment_contract.py backend/tests/unit/test_verify_pusher_config_references.py (43 passed)

Failure-Class: none
Bound variable-size buffered audio and private-cloud pending work, preserve terminal upload failure telemetry, and reject malformed opcode payloads.

Verification: 65 focused Pusher tests passed; backend typecheck passed; Black and git diff --check passed.

Failure-Class: new
Serialize buffer flush ownership, keep stale connection success from bypassing breaker cooldown, validate and encode the Pusher URL, and retain failed speaker-sample replay.

Verification: 55 focused tests passed; backend typecheck completed with 0 errors.

Failure-Class: none
Verification: 98 focused Pusher/finalization tests passed; backend typecheck passed; Black and diff checks passed.
Verification: authoritative backend test.sh runner passed test_async_http_infrastructure.py (48 tests).
Move Pusher protocol and finalization helpers into utils and document the validated wire and durable ownership contracts. Verification: 146 focused tests passed; production Pyright passed; Black and diff checks passed.
@undivisible
undivisible force-pushed the codex/pusher-audit-optimization branch from 91ad6d2 to 6e14885 Compare July 29, 2026 04:48

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

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Review: Bounded Delivery & Failure Handling

✅ APPROVE

Well-structured pusher refactor with sound safety properties:

Queue Bounding — Correct

  • ByteBudget (20MB/session) tracks all in-flight audio correctly
  • Item-count limits + byte budget work in tandem
  • Dropped items properly release budget

Error Handling — Solid

  • Categorized failure modes (timeout, HTTP status, network vs logic)
  • Durable Firestore finalization for delivered-but-unacked items
  • Graceful degradation when backend is unavailable

Minor Observations (non-blocking)

  • Container UID change and removed service-account token — confirm rollout implications before deploy
  • Consider adding a max-retry cap to the reconnection loop

LGTM — safe to merge once CI fully completes.

@undivisible
undivisible merged commit 471f438 into main Jul 29, 2026
38 checks passed
@undivisible
undivisible deleted the codex/pusher-audit-optimization branch July 29, 2026 05:02

This branch was successfully deployed

1 active deployment
staging - docs — 6e148856 Deployed Jul 29, 2026 by mintlify[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

documentation Improvements or additions to documentation maintainer Lane: High-risk, cross-system changes needs-maintainer-review Needs a human maintainer to sign off before merge

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants