Skip to content

test(listen): cover durable finalization recovery through Cloud Tasks - #10000

Merged
Git-on-my-level merged 1 commit into
mainfrom
codex/hermetic-conversation-recovery
Jul 19, 2026
Merged

Git-on-my-level merged 1 commit into
mainfrom
codex/hermetic-conversation-recovery

Conversation

@Git-on-my-level

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

Copy link
Copy Markdown
Member

Summary

  • Add a process-isolated listen → pusher finalization gauntlet beginning at the real /v4/listen endpoint, with isolated Redis and Firestore, the real pusher/router, and the local Parakeet protocol stub.
  • Preserve production Cloud Tasks task construction, capture it with a strict loopback client, and deliver it to a separate process running the real protected finalization route.
  • Cover pending-finalization recovery, retry-to-completion, terminal dead-letter/fencing, and fanout-only retry without replaying completed processing.

Closes #9985
Refs #9809, #9440, #9995

Confidence gap closed

Before this change, tests did not execute the durable handoff as one composed path: real listener admission → production tasks_v2.Task construction → protected worker route → Firestore lease/finalizer transitions. That left transport shape, retry headers, handler authentication, and durable processing/fanout behavior insufficiently coupled. The new harness rejects invalid task shape locally while blocking cloud credentials and non-loopback providers.

Scope note

The inline compatibility scenario triggers stale live-session finalization before source close. A clean source close immediately after opcode 104 exposed a separate inline/BYOK cancellation gap, tracked by #9995; this PR does not claim to fix it. Clean-close durability is exercised through the detached Cloud Tasks worker path.

Verification

  • npm run test:listen-pusher-stack:emulator
  • JAVA_HOME=/opt/homebrew/opt/openjdk@21/libexec/openjdk.jdk/Contents/Home PATH="$JAVA_HOME/bin:$PATH" npm run test:listen-lifecycle:emulator
  • cd backend && .venv/bin/python -m pytest -q tests/unit/test_conversation_finalization_jobs.py tests/unit/test_listen_finalization_cloud_tasks.py tests/unit/test_listen_process_pending_shutdown.py tests/unit/utils/test_listen_pusher_session.py (101 passed)
  • BACKEND_PYTEST_WORKERS=4 bash backend/test.sh
  • make preflight
  • scripts/pr-preflight --pr-body-file /tmp/pr-body-9985.md

Review in cubic

@Git-on-my-level
Git-on-my-level merged commit 7157d8e into main Jul 19, 2026
38 of 41 checks passed
@Git-on-my-level
Git-on-my-level deleted the codex/hermetic-conversation-recovery branch July 19, 2026 05:26
Git-on-my-level added a commit that referenced this pull request Jul 19, 2026
## Summary

- Add a non-production Rewind artifact/recovery bridge gauntlet covering
privacy admission, HEVC, SQLite, readback, recovery, and cleanup.
- Make memory-read fixtures inject their reference time so CI never
expires a fixed visibility window.
- Keep the shared vector-fixture seam signature-aligned with
production's explicit `now` snapshot, including callers that inject a
custom fixture clock.
- Fix Rewind lifecycle ownership: cleanup, writes, and finalization are
generation-fenced; concurrent shutdown flushes join the active trailer
write, cancellation surfaces failure, and chunk paths are
collision-proof and recover at their absolute capture time.
- Extend the upstream two-process Listen Cloud Tasks gauntlet with a
deterministic public REST finalization race: four stale-read requests
create one outbox job and one named task, prove the three
`AlreadyExists` handoffs, then rehydrate that task after listener
restart and prove exactly-once worker completion.
- Repair the Firestore contention the new REST race exposed in CI:
recreate the transaction and SDK wrapper for bounded `Aborted` retries,
preserve the atomic outbox boundary, and return the existing retryable
503 contract only after that budget is exhausted. Failed gauntlet jobs
now retain and tail their synthetic backend logs for actionable
diagnosis.
- Adopt the stronger upstream Sync (#10008) and Listen (#10000)
gauntlets during rebase instead of restoring the older overlapping
harnesses.

## Final verification (rebased onto current `origin/main`)

- `BACKEND_PYTEST_WORKERS=4 bash backend/test.sh` — all 675 backend unit
test files passed
- `backend/testing/listen_pusher_stack/run.sh --keep --state-dir
/tmp/omi-listen-pusher-final-head.X326dN` — passed all inline and Cloud
Tasks scenarios, including the deterministic REST/restart case
- `bash backend/test.sh` — all 675 backend unit test files passed again
after the contention repair
- `backend/testing/listen_pusher_stack/run.sh --state-dir
/tmp/omi-listen-pusher-contention-fix` — passed all inline and Cloud
Tasks scenarios after the contention repair
- `bash backend/scripts/typecheck.sh` — 0 errors
- `cd desktop/macos && bash test.sh` — launcher tests, Rust tests, and
isolated Swift suites passed
- `make preflight` — deterministic CI manifest passed
- `scripts/pr-preflight --pr-body-file /tmp/omi-gauntlet-pr-body.md` and
`scripts/failure-class validate --base origin/main --head HEAD
--pr-body-file /tmp/omi-gauntlet-pr-body.md` — passed

The former PR head was GitHub-conflicted, which suppressed normal
`pull_request` runs. This branch is rebased cleanly onto current
`origin/main`; these are the final-head checks before its fresh CI run.

## Guard scope

The four-party read barrier intentionally lives only in the Listen
gauntlet entrypoint, rather than in a shared or production primitive. It
coordinates a controllable harness race after the real authenticated
lookup; the production route, Firestore transaction, Cloud Tasks task
construction, listener restart, and worker all remain unmodified. It
extends the recovery surface introduced by merged
[#10000](#10000).

## Product invariants affected

- INV-MEM-1
- INV-MEM-2

## Failure class

Failure-Class: none

The Rewind lifecycle defects and bounded Firestore
transaction-contention recovery have behavioral regression guards, but
no existing semantic failure class describes either failure boundary.
cursor Bot pushed a commit that referenced this pull request Jul 21, 2026
Combine the merge-gate wiring contract from this branch with main's
listen-pusher gauntlet assertions (state-dir retention, failure logs,
and #10000 REST admission/restart tripwires). Drop main's obsolete
package.json path-filter checks superseded by the scope job.

Verification: backend/.venv/bin/python -m pytest -q \
  tests/unit/test_listen_pusher_stack_ci_wiring.py \
  tests/unit/test_sync_cloud_tasks_stack_ci_wiring.py (3 passed)

Co-authored-by: David Zhang <[email protected]>
Git-on-my-level added a commit that referenced this pull request Jul 21, 2026
## Summary

- Start the backend hermetic workflow for every pull request and
merge-queue batch.
- Calculate backend scope inside the workflow: backend, lockfile, and
workflow changes run the hermetic E2E harness plus both emulator
gauntlets; other changes still report one explicit successful gate.
- Add a fail-closed final `Backend Hermetic Merge Gate`, static wiring
contracts, and contributor documentation.

Refs #10021

## Guard rationale

PR #10000 added the durable-finalization emulator gauntlet, but
path-filtered workflows can leave a required check pending or let a
later workflow edit silently decouple that coverage from the merge
decision. This workflow-local gate is the narrow owner of those three
existing jobs: it requires every selected job to succeed and accepts
skipped jobs only when the scope job explicitly proves the pull request
is out of scope. The static tests are tripwires; the actual hermetic
behavior is exercised by the existing E2E harness and emulator gauntlets
in CI.

## Follow-through after merge

#10021 remains open until this workflow is merged, `Backend Hermetic
Merge Gate` is configured as a strict required check on `main`, admin
bypass is disabled, and the live branch-protection API confirms both
settings.

## Verification

- `cd backend && BACKEND_PYTEST_WORKERS=4 bash test.sh` (675 isolated
unit test files)
- `cd backend && .venv/bin/python -m pytest -q
tests/unit/test_listen_pusher_stack_ci_wiring.py
tests/unit/test_sync_cloud_tasks_stack_ci_wiring.py` (3 passed)
- `actionlint -shellcheck='' .github/workflows/backend-hermetic-e2e.yml`
- Extracted and executed the workflow scope and final-gate shell scripts
for selected, out-of-scope, and selected-child-failure cases.
- Independent implementation review approved the workflow semantics.

<!-- This is an auto-generated description by cubic. -->
<a
href="https://cubic.dev/pr/BasedHardware/omi/pull/10024?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="Review in cubic"
src="https://www.cubic.dev/buttons/review-in-cubic-dark.svg"></picture></a>
<!-- End of auto-generated description by cubic. -->
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.

test(listen): cover durable finalization recovery through Cloud Tasks

1 participant