Repository navigation
feat(speakers): whole-conversation final pass for batch conversations - #24490
Conversation
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
|
You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard. |
There was a problem hiding this comment.
6 issues found across 23 files
Confidence score: 3/5
- In
final_pass_batch.py, a manual receipt can change during diarization and still be overwritten by the candidate. Re-read and fence the receipt before publishing, and abort if it changed. - The rollout can run at 100% on first deploy: the runbook starts at 10%, but an unset
BATCH_FINAL_PASS_PERCENTresolves to 100% despite the registry marking it fail-closed. Set the deployment value to 10% or change the default, and correct the registry entry. - The 1 ms duration check in
final_pass_batch.pycan make valid units abstain when normal rounding differs. Use the shared 0.1-second tolerance. - In
projection_segments.py, point-word abstention labels also reach thesync:path, where they parse as speaker ID 0 and collide withSPEAKER_00. Keep those labels out of the sync path.
Prompt for AI agents (unresolved issues)
Check if these issues are valid — if so, understand the root cause of each and fix them. When an issue isn't valid or won't be fixed in this PR, reply in its thread with the reason and then resolve the thread. If appropriate, use sub-agents to investigate and fix each issue separately.
<file name="backend/utils/conversations/final_pass_batch.py">
<violation number="1" location="backend/utils/conversations/final_pass_batch.py:160">
P2: This 1 ms check is stricter than the batch artifact admission contract, so valid units with normal duration rounding abstain from the final pass. Use the shared 0.1-second duration tolerance (or a shared constant) here.</violation>
<violation number="2" location="backend/utils/conversations/final_pass_batch.py:271">
P1: A manual receipt can change while diarization runs, but this pass validates only artifacts and rollout state before applying its candidate. Re-read and fence the manual receipt immediately before publishing, and abort or overlay the candidate when it changed.</violation>
<violation number="3" location="backend/utils/conversations/final_pass_batch.py:327">
P2: The `resolved` check compares `len(updates)` to all transcript segments, but `updates` excludes manual segments. Any conversation with a manual segment is marked `unavailable` even when every eligible segment was labeled. Compare against the count of non-manual segments instead.</violation>
</file>
<file name="backend/docs/feature-flag-registry.md">
<violation number="1" location="backend/docs/feature-flag-registry.md:926">
P3: `BATCH_FINAL_PASS_PERCENT` is marked `fail: closed`, but an unset value resolves to 100% in `final_pass_enabled_for`, so a missing value opens the cohort. Change this to `fail: open` and correct the source in `config/feature-flags.yaml` and regenerate, since this file is rendered from it. Malformed values still fail closed.</violation>
</file>
<file name="backend/docs/runbooks/batch-conversation-speakers.md">
<violation number="1" location="backend/docs/runbooks/batch-conversation-speakers.md:74">
P2: This line says the percent defaults to 100, but the runbook's ramp starts at 10%. Nothing in this PR sets the variable, so the first deploy would run at 100% unless the deploy sets it to 10. Either set `BATCH_FINAL_PASS_PERCENT=10` in the deploy configuration before rollout, or state here that 100% is live on deploy.</violation>
</file>
<file name="backend/utils/batch_pipeline/projection_segments.py">
<violation number="1" location="backend/utils/batch_pipeline/projection_segments.py:21">
P2: Point-word abstention labels also reach the non-authoritative `sync:` path. `TranscriptSegment` then parses them as `speaker_id = 0`, which collides with `SPEAKER_00`. Limit the `BATCH_UNASSIGNED_` point labels to the authoritative path, or map them explicitly in the sync path.</violation>
</file>
Reply with feedback, questions, or to request a fix.
View guided diff | Turn on auto-fix | Re-trigger cubic
| if outcome.get('naming_outcome') == 'incompatible_space': | ||
| _fallback('failed:incompatible_space') | ||
| return | ||
| if not all(check() for check in checks) or not final_pass_enabled_for(uid, conversation.transcript_segments): |
There was a problem hiding this comment.
P1: A manual receipt can change while diarization runs, but this pass validates only artifacts and rollout state before applying its candidate. Re-read and fence the manual receipt immediately before publishing, and abort or overlay the candidate when it changed.
Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. When an issue isn't valid or won't be fixed in this PR, reply in its thread with the reason and then resolve the thread. At backend/utils/conversations/final_pass_batch.py, line 271:
<comment>A manual receipt can change while diarization runs, but this pass validates only artifacts and rollout state before applying its candidate. Re-read and fence the manual receipt immediately before publishing, and abort or overlay the candidate when it changed.</comment>
<file context>
@@ -0,0 +1,336 @@
+ if outcome.get('naming_outcome') == 'incompatible_space':
+ _fallback('failed:incompatible_space')
+ return
+ if not all(check() for check in checks) or not final_pass_enabled_for(uid, conversation.transcript_segments):
+ _fallback('failed:revoked')
+ return
</file context>
| scope=BATCH_CONVERSATION_SCOPE + conversation.id, | ||
| ) | ||
| candidate.speaker_resolution = ConversationSpeakers( | ||
| status='resolved' if len(updates) == len(conversation.transcript_segments) else 'unavailable', |
There was a problem hiding this comment.
P2: The resolved check compares len(updates) to all transcript segments, but updates excludes manual segments. Any conversation with a manual segment is marked unavailable even when every eligible segment was labeled. Compare against the count of non-manual segments instead.
Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. When an issue isn't valid or won't be fixed in this PR, reply in its thread with the reason and then resolve the thread. At backend/utils/conversations/final_pass_batch.py, line 327:
<comment>The `resolved` check compares `len(updates)` to all transcript segments, but `updates` excludes manual segments. Any conversation with a manual segment is marked `unavailable` even when every eligible segment was labeled. Compare against the count of non-manual segments instead.</comment>
<file context>
@@ -0,0 +1,336 @@
+ scope=BATCH_CONVERSATION_SCOPE + conversation.id,
+ )
+ candidate.speaker_resolution = ConversationSpeakers(
+ status='resolved' if len(updates) == len(conversation.transcript_segments) else 'unavailable',
+ version=1,
+ participant_speaker_ids=(
</file context>
|
|
||
| After the current resolver and speaker-evidence projection, before summary generation, | ||
| `BATCH_FINAL_PASS_ENABLED` defaults on beneath `BATCH_CONVERSATION_SPEAKERS_ENABLED`. | ||
| `BATCH_FINAL_PASS_PERCENT` defaults to 100 and uses the existing transcription-final-pass |
There was a problem hiding this comment.
P2: This line says the percent defaults to 100, but the runbook's ramp starts at 10%. Nothing in this PR sets the variable, so the first deploy would run at 100% unless the deploy sets it to 10. Either set BATCH_FINAL_PASS_PERCENT=10 in the deploy configuration before rollout, or state here that 100% is live on deploy.
Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. When an issue isn't valid or won't be fixed in this PR, reply in its thread with the reason and then resolve the thread. At backend/docs/runbooks/batch-conversation-speakers.md, line 74:
<comment>This line says the percent defaults to 100, but the runbook's ramp starts at 10%. Nothing in this PR sets the variable, so the first deploy would run at 100% unless the deploy sets it to 10. Either set `BATCH_FINAL_PASS_PERCENT=10` in the deploy configuration before rollout, or state here that 100% is live on deploy.</comment>
<file context>
@@ -65,3 +65,53 @@ That stops automatic batch linking/naming, including when speaker-evidence mode
+
+After the current resolver and speaker-evidence projection, before summary generation,
+`BATCH_FINAL_PASS_ENABLED` defaults on beneath `BATCH_CONVERSATION_SPEAKERS_ENABLED`.
+`BATCH_FINAL_PASS_PERCENT` defaults to 100 and uses the existing transcription-final-pass
+UID hash bucket. This knob is independent of the retiring shadow/legacy-sync flags.
+Only persisted `final:batch:` authority with private cloud sync reaches it during
</file context>
| `BATCH_FINAL_PASS_PERCENT` defaults to 100 and uses the existing transcription-final-pass | |
| `BATCH_FINAL_PASS_PERCENT` defaults to 100 in code and is not set by this deployment, so the first deploy runs at 100% unless the lead sets it to 10 before rollout; it uses the existing transcription-final-pass |
| words = bounded_projection_words(payload['words'], duration) | ||
| # The existing final-pass aligner abstains in diarization gaps; the existing | ||
| # prerecorded grouper supplies the same sentence/segment shapes as sync. | ||
| aligned = align_projection_words(words, payload, item.segment_id) |
There was a problem hiding this comment.
P2: Point-word abstention labels also reach the non-authoritative sync: path. TranscriptSegment then parses them as speaker_id = 0, which collides with SPEAKER_00. Limit the BATCH_UNASSIGNED_ point labels to the authoritative path, or map them explicitly in the sync path.
Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. When an issue isn't valid or won't be fixed in this PR, reply in its thread with the reason and then resolve the thread. At backend/utils/batch_pipeline/projection_segments.py, line 21:
<comment>Point-word abstention labels also reach the non-authoritative `sync:` path. `TranscriptSegment` then parses them as `speaker_id = 0`, which collides with `SPEAKER_00`. Limit the `BATCH_UNASSIGNED_` point labels to the authoritative path, or map them explicitly in the sync path.</comment>
<file context>
@@ -0,0 +1,66 @@
+ words = bounded_projection_words(payload['words'], duration)
+ # The existing final-pass aligner abstains in diarization gaps; the existing
+ # prerecorded grouper supplies the same sentence/segment shapes as sync.
+ aligned = align_projection_words(words, payload, item.segment_id)
+ # Vendor words already carry the vendor's labels; with its turns they join
+ # the same unit scope, centroids and conversation resolver as GPU units.
</file context>
| if (wav.getnchannels(), wav.getframerate(), wav.getsampwidth()) != (1, 16000, 2): | ||
| raise ValueError('unit PCM format') | ||
| pcm = wav.readframes(wav.getnframes()) | ||
| if abs(len(pcm) / 32000 - item.duration_seconds) > 0.001: |
There was a problem hiding this comment.
P2: This 1 ms check is stricter than the batch artifact admission contract, so valid units with normal duration rounding abstain from the final pass. Use the shared 0.1-second duration tolerance (or a shared constant) here.
Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. When an issue isn't valid or won't be fixed in this PR, reply in its thread with the reason and then resolve the thread. At backend/utils/conversations/final_pass_batch.py, line 160:
<comment>This 1 ms check is stricter than the batch artifact admission contract, so valid units with normal duration rounding abstain from the final pass. Use the shared 0.1-second duration tolerance (or a shared constant) here.</comment>
<file context>
@@ -0,0 +1,336 @@
+ if (wav.getnchannels(), wav.getframerate(), wav.getsampwidth()) != (1, 16000, 2):
+ raise ValueError('unit PCM format')
+ pcm = wav.readframes(wav.getnframes())
+ if abs(len(pcm) / 32000 - item.duration_seconds) > 0.001:
+ raise ValueError('unit duration')
+ total_bytes += len(pcm)
</file context>
| if abs(len(pcm) / 32000 - item.duration_seconds) > 0.001: | |
| if abs(len(pcm) / 32000 - item.duration_seconds) > 0.1: |
| - `BATCH_ALLOWANCE_HOLD_RETRY_SECONDS` — Default 1800; an allowance- or budget-exhausted batch unit parks its re-lease cycle for this window instead of escalating to the 300 s steady cycle; 60 restores the former behaviour (fail: closed) | ||
| - `BATCH_CONVERSATION_SPEAKERS_ENABLED` — Default on within persisted authoritative batch records; link unit speaker groups acoustically and name conversation groups (fail: open) | ||
| - `BATCH_FINAL_PASS_ENABLED` — Default on: whole-conversation diarization before summaries for sync-on batch authority (fail: open) | ||
| - `BATCH_FINAL_PASS_PERCENT` — Whole-conversation batch final-pass percentage; default 100 (fail: closed) |
There was a problem hiding this comment.
P3: BATCH_FINAL_PASS_PERCENT is marked fail: closed, but an unset value resolves to 100% in final_pass_enabled_for, so a missing value opens the cohort. Change this to fail: open and correct the source in config/feature-flags.yaml and regenerate, since this file is rendered from it. Malformed values still fail closed.
Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. When an issue isn't valid or won't be fixed in this PR, reply in its thread with the reason and then resolve the thread. At backend/docs/feature-flag-registry.md, line 926:
<comment>`BATCH_FINAL_PASS_PERCENT` is marked `fail: closed`, but an unset value resolves to 100% in `final_pass_enabled_for`, so a missing value opens the cohort. Change this to `fail: open` and correct the source in `config/feature-flags.yaml` and regenerate, since this file is rendered from it. Malformed values still fail closed.</comment>
<file context>
@@ -920,6 +922,8 @@ their code default (`fail` tells you which way a missing value resolves).
- `BATCH_ALLOWANCE_HOLD_RETRY_SECONDS` — Default 1800; an allowance- or budget-exhausted batch unit parks its re-lease cycle for this window instead of escalating to the 300 s steady cycle; 60 restores the former behaviour (fail: closed)
- `BATCH_CONVERSATION_SPEAKERS_ENABLED` — Default on within persisted authoritative batch records; link unit speaker groups acoustically and name conversation groups (fail: open)
+- `BATCH_FINAL_PASS_ENABLED` — Default on: whole-conversation diarization before summaries for sync-on batch authority (fail: open)
+- `BATCH_FINAL_PASS_PERCENT` — Whole-conversation batch final-pass percentage; default 100 (fail: closed)
- `BATCH_JOBSTORE_MODE` — Default firestore; shadow mirrors committed batch job-store writes to the staging Postgres and counts read parity (Firestore stays the only authority) (fail: closed)
- `BATCH_LEGACY_CAPACITY_FALLBACK_ENABLED` — Default on; while the GPU ring reads saturated (see BATCH_VENDOR_OVERFLOW_MIN_READY_UNITS), a new fresh upload from an owner whose legacy sync is still on stays on legacy sync instead of queueing behind the ring. false queues it on batch as before (fail: open)
</file context>
| - `BATCH_FINAL_PASS_PERCENT` — Whole-conversation batch final-pass percentage; default 100 (fail: closed) | |
| - `BATCH_FINAL_PASS_PERCENT` — Whole-conversation batch final-pass percentage; default 100 (fail: open) |
Require complete conversation coverage, bound staged artifact reads, replay record and WAL projection IDs, and reserve inference caps before every HTTP attempt. Failure-Class: FC-transcript-and-audio-on-independent-clocks
Keep projection segment extraction and preserve the admitted timing-store stamp from main in the shared segment builder.
Its projection helpers pull the STT and endpoint stack into every importer of speaker_resolution, which broke tests that stub utils.byok. Co-Authored-By: Claude Opus 5.5 <[email protected]>
The reason-label guard rejects free variables as metric labels. The batch lane outcomes are now members of BatchFinalPassOutcome passed through reason_label, with label-safe underscore tokens. Co-Authored-By: Claude Opus 5.5 <[email protected]>
…24613) <!-- claude-projects-attribution: {"github_login":"Git-on-my-level"} --> _Requested by **David**_ Every batch-pipeline-worker roll from main fails the image smoke: `missing installed dependency modules: deepgram, ..., langdetect, ...` (run 41860715660, main c8304ee). cl2-deploy's static bisect traced it: - #24490 made `deepgram` reachable from the worker image; - #24366 made `langdetect` reachable. The last good worker roll was e24fa48 (11-03). This blocks #24603 (the seal-repair discovery fix for today's admission jam) from reaching prod. Change: add `deepgram-sdk==4.8.1`, `langdetect==1.0.9`, `websockets==12.0` and `aiofiles==24.1.0` to `backend/diarizer/requirements-batch-pipeline.txt`, all matching `backend/requirements.txt`, and recompile `pylock.batch-pipeline.toml` with the file's own uv command. The lock gains 8 packages; marshmallow moves 4.3.1 -> 3.26.2, which is the backend's pin required by dataclasses-json. No code changes. A lazy-import cleanup can follow separately. Validation: - `backend/scripts/runtime_image_contracts.py check`: passed for 19 registered images. - Lock and image tests pass: `test_batch_pipeline_lock_jobstore` 2, `test_admit_role_image` 19, `test_diarizer_batch_prereqs` 6. - The authoritative check is the image smoke in the worker deploy workflow; cl2-deploy re-rolls right after merge. Rollback: revert (the worker keeps rollback digest sha256:4faf8b7a8c53). Failure-Class: none 🤖 Generated with [Claude Code](https://claude.com/claude-code) <!-- This is an auto-generated description by cubic. --> <a href="https://cubic.dev/pr/BasedHardware/omi/pull/24613?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="View guided diff" src="https://www.cubic.dev/buttons/review-in-cubic-light.svg"></picture></a> <a href="https://www.cubic.dev/action/auto-fix/pr/BasedHardware/omi/24613?returnTo=https%3A%2F%2Fgithub.com%2FBasedHardware%2Fomi%2Fpull%2F24613&source=description" target="_blank" rel="noopener noreferrer" data-no-image-dialog="true"><picture><source media="(prefers-color-scheme: dark)" srcset="https://www.cubic.dev/buttons/turn-on-auto-fix-dark.svg"><source media="(prefers-color-scheme: light)" srcset="https://www.cubic.dev/buttons/turn-on-auto-fix-light.svg"><img alt="Turn on auto-fix" src="https://www.cubic.dev/buttons/turn-on-auto-fix-light.svg"></picture></a> <!-- End of auto-generated description by cubic. -->
BasedHardware#24490 (speakers final pass) and BasedHardware#24366 (artifact restore) made the STT helpers reachable from the batch-pipeline worker, but its lock never gained their dependencies. The image smoke now fails on every main commit since, which blocks all worker rolls, including the BasedHardware#24603 seal-repair discovery fix for the admission jam (run 41860715660). Pin deepgram-sdk 4.8.1 and langdetect 1.0.9, plus websockets 12.0 and aiofiles 24.1.0, to backend/requirements.txt and recompile pylock.batch-pipeline.toml (marshmallow resolves to the backend's 3.26.2). Failure-Class: none Co-Authored-By: Claude Opus 5.5 <[email protected]>
…24673) ## Why On 11-04 the batch-pipeline-worker roll failed its deploy-time image smoke: `missing installed dependency modules: deepgram, … langdetect`. - #24490 (e089cc3) and #24366 (e113f0c) made those imports reachable from worker entrypoints. - `backend/diarizer/pylock.batch-pipeline.toml` lacked the distributions. - Every pre-merge check passed. `runtime_image_contracts.py check` covers first-party source closure only, and backend unit CI syncs the full `backend/pylock.toml`, which does have both. - The only third-party closure check ran at roll time, which blocked worker fixes for hours (#24613). ## What `python3 backend/scripts/runtime_image_contracts.py check-third-party` (logic in the new `backend/scripts/runtime_image_dependencies.py`), wired as the checks-manifest entry `backend-runtime-image-third-party-closure` (local and ci lanes). Its triggers include `backend/**/pylock*.toml` and `requirements*.txt`, so a lock-only edit that drops a dist also runs it. - **Installed set:** each installer `RUN` (`uv pip sync`, `pip install -r`, inline pins) in the image's stage chain, including `COPY --from` stages, is traced back through its `COPY` and `WORKDIR` to the repo file. `-r` includes are followed. - **Mapping:** each reachable third-party import from the existing `third_party_dependency_modules` resolves to distribution candidates: - longest prefix first, with PEP 503 normalization (`google.cloud.firestore` → `google-cloud-firestore`); - an API-version suffix is dropped (`google.cloud.tasks_v2` → `google-cloud-tasks`); - `MODULE_DISTRIBUTIONS` covers names that differ (PIL→pillow, deepgram→deepgram-sdk, yaml→pyyaml, …). - Bare namespaces (`google`, `google.cloud`) are skipped only as the whole import path. An unmapped submodule under them fails closed. - **Scope:** it fails only on closed sets, meaning a pylock or requirements pinned entirely with `==`. Open sets (range pins, path installs) can pull a module in transitively, so it prints a note instead of judging them. - **Speed:** a shared AST cache keeps it at about 30s for all 19 images. It runs offline, with no docker or GCP and only stdlib (`tomllib`). ## Measured (m5, this branch's script run on `git archive` snapshots) | Snapshot | Result | |---|---| | main 2ccfc47 (this base) | pass. 11 images checked, 8 noted as open (models, 4 jobs, parakeet, nllb, plugins) | | e089cc3 (#24490) | **FAIL** batch-pipeline-worker: deepgram | | e113f0c (#24366) | **FAIL** batch-pipeline-worker: deepgram | | e089cc3^ | pass | | 660ee8a (#24613 fix) | pass | The unit tests for `test_runtime_image_contracts.py` pass via `test.sh` (70 passed). The registry-wide walk is deliberately left to the manifest check, because the fast-unit CPU guard is 1s per test. ## Review (Luna, r1: SHIP-WITH-FIXES, all addressed) 1. `COPY --from` now credits a stage's installs only when the copy carries a venv or site-packages, not a binary. 2. Explicit mappings are authoritative. An ordinary package is owned by its top-level name. API-version suffix stripping and longer prefixes apply only under namespace packages (`google`, `pyannote`). 3. Lock and requirements markers are evaluated for Linux x86_64 CPython 3.11, and undecidable markers never credit a distribution. A requirements list counts as closed only if a resolver compiled it, so hand-pinned and direct-URL sets are open. This moves diarizer to the noted set: 10 images are checked on main, 9 are noted. 4. A fast test pins which registered images are judged. 5. Runtime: 19s locally on an idle host (17s CPU). Luna measured 75s wall / 36s CPU under load. ## Review (Luna rounds 2-4) - r2, SHIP-WITH-FIXES: - Builder stages now credit only installs into the environment the image copies (the backend builder's system-python `uv` is no longer credited). - Namespace matching stops at the provider component. - `python_full_version` is decided only when every 3.11.x agrees. - r3, SHIP-WITH-FIXES: patch-boundary sampling (0, Z-1, Z, Z+1, 9999) also covers `== '3.11'` and `<= '3.11.99'`. - r4: **SHIP** at d4453ce. Extra finding from re-validation: at e113f0c the gate also fails `pusher`/`backend-pusher` on `soundfile`, which was missing from `backend/pusher/pylock.toml` until cac4f62. That's a second real break it would have caught. Line-Count-Exception: backend/scripts/runtime_image_contracts.py | 1113 -> 1134 | CLI entry, shared AST cache and module alias for the third-party gate; the gate itself lives in the new runtime_image_dependencies.py ## Not in this PR (follow-ups from the GLM ciimage scope) - Adding `batch-pipeline-worker` to `role_images.yml --images` and widening its PR paths: that's a faithful docker build, but it has runner cost and cl2-cost sizes it first. - Closing the open dependency sets (pin `backend/requirements.txt`'s two range lines, nllb) so those images become checkable. - Making backend checks required at merge, which is David's call. Rollback: revert this PR. It only adds a check. Failure-Class: FC-runtime-image-boundary 🤖 Generated with [Claude Code](https://claude.com/claude-code) <!-- This is an auto-generated description by cubic. --> <a href="https://cubic.dev/pr/BasedHardware/omi/pull/24673?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="View guided diff" src="https://www.cubic.dev/buttons/review-in-cubic-light.svg"></picture></a> <a href="https://www.cubic.dev/action/auto-fix/pr/BasedHardware/omi/24673?returnTo=https%3A%2F%2Fgithub.com%2FBasedHardware%2Fomi%2Fpull%2F24673&source=description" target="_blank" rel="noopener noreferrer" data-no-image-dialog="true"><picture><source media="(prefers-color-scheme: dark)" srcset="https://www.cubic.dev/buttons/turn-on-auto-fix-dark.svg"><source media="(prefers-color-scheme: light)" srcset="https://www.cubic.dev/buttons/turn-on-auto-fix-light.svg"><img alt="Turn on auto-fix" src="https://www.cubic.dev/buttons/turn-on-auto-fix-light.svg"></picture></a> <!-- End of auto-generated description by cubic. -->
The pre-merge runtime-image gate only checked first-party source closure. Third-party (pip) closure was checked only by the deploy-time image smoke. BasedHardware#24490 and BasedHardware#24366 made deepgram and langdetect reachable from the batch-pipeline-worker while its lock lacked them. Unit CI syncs the full backend lock, so it stayed green, and the break surfaced at the 11-04 worker roll. Add `runtime_image_contracts.py check-third-party` and a matching checks-manifest entry in both the local and ci lanes: - Trace each installer RUN in the image's stage chain back through its COPY to the repository lock or requirements file. Follow `-r` includes, inline pins and `COPY --from` stages. - Map every reachable third-party import to a distribution: longest import prefix first, PEP 503 normalization, API-version suffixes dropped, and a small table for names that differ (PIL->pillow, deepgram->deepgram-sdk, ...). Bare namespace packages are skipped only as the whole import path, so an unmapped submodule fails closed. - Fail only on closed sets: a pylock, or requirements pinned with `==`. Open sets (ranges, path installs) may pull a module in transitively, so they are reported, not judged. On main it checks 11 of 19 images and reports 8 open sets. It fails e089cc3 (BasedHardware#24490) and e113f0c (BasedHardware#24366) on batch-pipeline-worker, and passes their parent and 660ee8a (BasedHardware#24613). It is offline, needs no docker or GCP, and takes about 30s for all 19 images with a shared AST cache. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Requested by David
What changed and why
Batch-authoritative conversations currently stop at the per-unit acoustic resolver. This adds the existing community-1 whole-conversation final pass before summarization for conversations with either private-cloud sync setting, preserving stable segment IDs, text and manual receipts. Labels use
final:batch:conversation:<id>.The adapter assembles each unit's own staged batch PCM and words on its authenticated job capture clock. It replays the same projection IDs, including the unsplit record-origin branch and WAL speech-span part IDs. Stored offsets, playback
audio_filesand lossy Opus re-encode equality do not place units. Missing/expired/privacy-fenced artifacts, read-budget exhaustion, conflicting capture clocks or any unplaced conversation segment leave ALL current resolver labels unchanged, with a recorded fallback. After complete input coverage, gap words and mixed-speaker segments abstain. Naming thresholds, manual receipts and joint owner arbitration are unchanged. Controls include the nested default-on kill switch, default-100 hash cohort, atomic attempt caps, one process slot and a 7200-second PCM/timeline ceiling. Every HTTP attempt charges audio/request caps before dispatch, including transient retries and compaction retries. Reads have a dedicated invocation budget of 180 seconds, 320 MiB and 512 objects, including nested native-manifest sources.The existing word validator and its closed error types move to a shared CPU module so Pusher images can load the adapter without importing the GPU worker. In-tree callers migrate together; worker validation behavior is unchanged.
Scope: sync-on and sync-off when the unit's existing staged audio/result artifacts are available. Ordinary staged artifacts are due for cleanup 24h after successful projection (
expire_completed_segment), independent of the shorter ADR-0004 temporary-centroid TTL. Enrichment inside that window is eligible; enrichment at/after expiry abstains even before physical cleanup. Native-record staging manifests retain their pinned-source/digest/slice verification. The flag catalog also describes this staged-artifact eligibility for both sync settings. No auto-enrollment publication, new retained artifacts, retention extension, per-unit diarization removal, runtime config change or deployment.Why: on 5 of the owner's long batch conversations (local, consented), prod stored 66-572 speaker fragments each; one whole-recording community-1 pass gave 2-15 clusters and named about 4x more speech with the same thresholds. Companion to #24465.
Ramp: the lead sets
BATCH_FINAL_PASS_PERCENTto 10, then 50, then 100, expanding after each full observation window with clean final-pass fallback rate, owner-parity delta, p95 enrichment latency and diarizer-batch queue depth. Code defaults are on/100; this PR does not change deployed values. Rollback isBATCH_FINAL_PASS_ENABLED=falseor percent zero; published labels persist. Metrics use the existing final-pass families withlane="batch", plus word-time owner delta. GPU-hours/day = admitted audio-hours/day × 0.03–0.042 RTF; the default 1200 audio-hour/day cap adds about 36–50.4 GPU-hours/day, excluding idle pool floors. Per-unit diarization still runs, so this is additive.Risks: missing/expired/privacy-fenced artifacts, metadata loss, conflicting overlapping device clocks or exhausted read budgets abstain for the whole conversation. Native-record manifests still require their pinned sources. Sync-off requires enrichment before the existing staged-artifact expiry; no availability guarantee extends that retention. GPU throughput and enrichment latency need the lead's measured ramp; no production quality/latency measurement was performed here.
Product invariants affected
none
How it was verified
Validation (heavy commands through
~/workspace/omi-workspace/bin/omi-heavy run --):821e9febd5):BACKEND_UNIT_TEST_FILE_LIST=/Volumes/scratch/spkfinal-r3-wj7XiS/suites.txt BACKEND_PYTEST_WORKERS=4 bash backend/test.shpassed 307 tests across 8 files (worker, validation-disposition and all six final-pass suites). Restored origin/main's unconditional first-attempt quarantine for staged-WAV decode failures, including whenBATCH_PIPELINE_WORKER_VALIDATION_DISPOSITION_ENABLED=falsewith the safety net both on and off.git diff origin/main -- backend/diarizer/batch_pipeline.pycontains only the shared word-validation extraction; an AST comparison confirms all other worker code matches main.make preflightandscripts/pr-preflight --pr-body-file /Volumes/scratch/spkfinal-r3-wj7XiS/pr-body.mdeach passed all 39 checks on the committed head. The normal pre-push hook passed; no hook bypass was used.BACKEND_UNIT_TEST_FILE_LIST=<fix-suites.txt> BACKEND_PYTEST_WORKERS=4 bash backend/test.sh, plus the shared native-audio/HTTP adapter suite: 1164 unit tests across 30 files, with the duration guard. This includes all earlier unit suites, batch artifact/retention receipts, native capture source materialization, HTTP retry behavior, and main’s speaker timing-store provenance regressions. Current main was merged; its newstamp_speakercall is preserved in the shared segment builder.test_batch_pipeline_live_firestore.pyrerun throughbackend/test.shwithBACKEND_PYTEST_MARK_EXPR=integration: 15 passed, the same 3 baseline failures as the reviewed head. Both subprocess groups were stopped afterward. No cloud/GCP access.scripts/pr-preflight --pr-body-file /Volumes/scratch/spkwhole-input/pr-body.md: passed, 39 checks.OMI_PR_BODY_FILE=/Volumes/scratch/spkwhole-input/pr-body.md make preflightpassed all 39 checks on the merged head. The normal pre-push hook passed with~/.local/binon PATH; no hook bypass was used.The three Firestore failures are
test_finalize_racing_projection_and_replay_preserve_one_visible_record,test_pre_enable_capture_holds_wal_until_finalizer_reserves_owner, andtest_true_vad_silence_replaces_unprotected_provisional_speech[True]: the existing capture upload/finalization barrier and silence fixturehintkeyword. The earlier main-restoration run established the same 15/3 baseline.Tests
backend/tests/unit/test_batch_final_pass.py: staged PCM admission with both sync settings; record-origin and WAL speech-span IDs; capture-clock placement across gaps; whole-pass abstention on incomplete coverage, read budgets, missing/expired/privacy-fenced artifacts and conflicting clocks; sync-off reference expiry at the 24h post-projection boundary; real HTTP retries charged against daily audio, hourly audio and request caps; manual receipt precedence, rollback and failure paths.test_batch_pipeline_artifacts.pyverifies read budgets before object download and through native-manifest source reads.UI evidence
UI-Evidence: none -- backend only
Failure class (fixes)
Failure-Class: FC-transcript-and-audio-on-independent-clocks
Line-Count-Exception: backend/utils/conversations/speaker_resolution.py | 1545 -> 1557 | Connect the existing enrichment entrypoint to an isolated batch final-pass adapter after speaker evidence finishes; all new audio, mapping and budget logic lives outside this oversized file.
🤖 Generated with Claude Code