Repository navigation
fix(transcripts): join late word pieces, drop repeats, hide below-floor rows - #24214
Conversation
…or rows Soniox emits one segment per word and leaves joining to the live tail merge. Sync and late-audio intake only sort segments in, so late words stayed one stored line each, and the live merge never joined words landing behind a newer line. One account showed 11,974 of 12,802 one-word Soniox segments on 10-31. - Join fresh one-word pieces into the same speaker's preceding piece on sync intake, and anchor the live merge on the same provider stream. - Drop retried pieces by ID or by a word the same stream already covers. - Drop runs repeating a line another provider wrote within ten minutes. - Leave closed captures under a minute with no notes off the Home list, behind kill switch HOME_HIDE_BELOW_FLOOR_ROWS. Failure-Class: none Co-Authored-By: Claude Opus 5.5 <[email protected]>
Failure-Class: none Co-Authored-By: Claude Opus 5.5 <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>
There was a problem hiding this comment.
8 issues found across 12 files
Confidence score: 3/5
test_flag_budget.pywill fail because the new registry-backed kill switch is missing fromHELPER_KILL_SWITCHES. Add it to the test registry list.join_word_piecescan change a stored line’s text and end time when appending new words, contrary to its documented history-preserving behavior. Restrictpreviousto appendable lines.home_read.pycan triggerneeds_composeon every Home read because filtered members remain incomposer._members. Keep the filtered list and composer membership in sync.word_pieces.pycan drop uncovered words when a run is 70–99% repeated. Preserve words that another provider’s phrase does not cover.
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/config/flag_budget.json">
<violation number="1" location="backend/config/flag_budget.json:110">
P2: This registry-backed kill switch is not in `HELPER_KILL_SWITCHES` in `tests/unit/test_flag_budget.py`, so `test_helper_kill_switch_budget_entries_match_the_default_on_registry` fails on set equality. Add `'HOME_HIDE_BELOW_FLOOR_ROWS'` to that set in the same PR.</violation>
</file>
<file name="backend/tests/unit/test_episode_home_read.py">
<violation number="1" location="backend/tests/unit/test_episode_home_read.py:315">
P3: The curation-protection parametrize list omits `photos` and `folder_user_set`, two of the signals `is_user_curated` checks. Add cases so a regression in either one is caught.</violation>
</file>
<file name="backend/utils/sync/assignment.py">
<violation number="1" location="backend/utils/sync/assignment.py:838">
P2: `join_word_pieces` can absorb a new word into a stored line from `existing`, changing that line’s text and end time in place. Its docstring says an append leaves stored history alone. Either restrict `previous` to appended segments, or update the docstring to state that stored lines can be extended.</violation>
</file>
<file name="backend/utils/episodes/home_read.py">
<violation number="1" location="backend/utils/episodes/home_read.py:241">
P2: This check recognizes only `structured.overview` as notes, so short captures with action items, events, or app-result content can still be hidden from Home. Count the other summary fields and fetch `apps_results` before applying the below-floor filter.
(Based on your team's feedback about counting all summary body fields.) [85f9e605-c40f-490e-96f3-79cefb8c89ca]</violation>
<violation number="2" location="backend/utils/episodes/home_read.py:252">
P2: This filter makes the compose safety net see a permanent mismatch. Below-floor members drop out of the list `wires`, but `composer._members` still includes them, so `needs_compose` fires on every Home read after the 600s throttle. The unchanged compose never persists the new member set. The fix needs to be on the composer side: `_members` should skip the same below-floor rows, or the list path should stop treating them as visible for the mismatch check.</violation>
</file>
<file name="backend/utils/conversations/word_pieces.py">
<violation number="1" location="backend/utils/conversations/word_pieces.py:12">
P2: The join guard recognizes only ASCII sentence terminators, so long non-English sentences can absorb the next piece. Include the project’s supported Unicode sentence endings.</violation>
<violation number="2" location="backend/utils/conversations/word_pieces.py:134">
P2: A run that is 70% repeated is dropped in full, so its uncovered words are lost too. Keep only the words that are not covered by another provider's phrase, or add a test that pins the intended loss for a 70-99% repeat.</violation>
<violation number="3" location="backend/utils/conversations/word_pieces.py:185">
P2: This branch leaves the prior same-stream anchor active across an unplaced segment, so a later word can be merged before that segment and reorder the transcript. Clear the stream’s anchor when an unplaced segment is encountered.</violation>
</file>
Reply with feedback, questions, or to request a fix.
View guided diff | Turn on auto-fix | Re-trigger cubic
| segment['audio_capture_run'] = None | ||
| receipt = result.get('manual_speaker_assignments') or {} | ||
| # Capture receipts name segment IDs, so a batch that carries them keeps its pieces. | ||
| segments = join_word_pieces( |
There was a problem hiding this comment.
P2: join_word_pieces can absorb a new word into a stored line from existing, changing that line’s text and end time in place. Its docstring says an append leaves stored history alone. Either restrict previous to appended segments, or update the docstring to state that stored lines can be extended.
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/sync/assignment.py, line 838:
<comment>`join_word_pieces` can absorb a new word into a stored line from `existing`, changing that line’s text and end time in place. Its docstring says an append leaves stored history alone. Either restrict `previous` to appended segments, or update the docstring to state that stored lines can be extended.</comment>
<file context>
@@ -829,10 +833,19 @@ def plan(
segment['audio_capture_run'] = None
+ receipt = result.get('manual_speaker_assignments') or {}
+ # Capture receipts name segment IDs, so a batch that carries them keeps its pieces.
+ segments = join_word_pieces(
+ segments,
+ joinable_ids=(
</file context>
| episode: dict[str, Any] | None, | ||
| *, | ||
| members: dict[str, dict[str, Any]] | None = None, | ||
| list_row: bool = False, |
There was a problem hiding this comment.
P2: This filter makes the compose safety net see a permanent mismatch. Below-floor members drop out of the list wires, but composer._members still includes them, so needs_compose fires on every Home read after the 600s throttle. The unchanged compose never persists the new member set. The fix needs to be on the composer side: _members should skip the same below-floor rows, or the list path should stop treating them as visible for the mismatch check.
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/episodes/home_read.py, line 252:
<comment>This filter makes the compose safety net see a permanent mismatch. Below-floor members drop out of the list `wires`, but `composer._members` still includes them, so `needs_compose` fires on every Home read after the 600s throttle. The unchanged compose never persists the new member set. The fix needs to be on the composer side: `_members` should skip the same below-floor rows, or the list path should stop treating them as visible for the mismatch check.</comment>
<file context>
@@ -226,8 +229,27 @@ def schedule_missed_composes(uid: str, rows: list[dict[str, Any]], wires: list[d
+ episode: dict[str, Any] | None,
+ *,
+ members: dict[str, dict[str, Any]] | None = None,
+ list_row: bool = False,
) -> dict[str, Any] | None:
if episode is None:
</file context>
| provider = run[0].get('stt_provider') | ||
| text = ' '.join(segment.get('text') or '' for segment in run) | ||
| if not ( | ||
| provider and _is_word(run[0]) and repeats_another_provider(text, provider, float(run[0][clock]), phrases) |
There was a problem hiding this comment.
P2: A run that is 70% repeated is dropped in full, so its uncovered words are lost too. Keep only the words that are not covered by another provider's phrase, or add a test that pins the intended loss for a 70-99% repeat.
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/word_pieces.py, line 134:
<comment>A run that is 70% repeated is dropped in full, so its uncovered words are lost too. Keep only the words that are not covered by another provider's phrase, or add a test that pins the intended loss for a 70-99% repeat.</comment>
<file context>
@@ -0,0 +1,208 @@
+ provider = run[0].get('stt_provider')
+ text = ' '.join(segment.get('text') or '' for segment in run)
+ if not (
+ provider and _is_word(run[0]) and repeats_another_provider(text, provider, float(run[0][clock]), phrases)
+ ):
+ kept.extend(run)
</file context>
| return False | ||
| if is_user_curated(row) or (row.get('status') or 'completed') != 'completed': | ||
| return False | ||
| if ((row.get('structured') or {}).get('overview') or '').strip(): |
There was a problem hiding this comment.
P2: This check recognizes only structured.overview as notes, so short captures with action items, events, or app-result content can still be hidden from Home. Count the other summary fields and fetch apps_results before applying the below-floor filter.
(Based on your team's feedback about counting all summary body fields.) [85f9e605-c40f-490e-96f3-79cefb8c89ca]
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/episodes/home_read.py, line 241:
<comment>This check recognizes only `structured.overview` as notes, so short captures with action items, events, or app-result content can still be hidden from Home. Count the other summary fields and fetch `apps_results` before applying the below-floor filter.
(Based on your team's feedback about counting all summary body fields.) [85f9e605-c40f-490e-96f3-79cefb8c89ca]</comment>
<file context>
@@ -226,8 +229,27 @@ def schedule_missed_composes(uid: str, rows: list[dict[str, Any]], wires: list[d
+ return False
+ if is_user_curated(row) or (row.get('status') or 'completed') != 'completed':
+ return False
+ if ((row.get('structured') or {}).get('overview') or '').strip():
+ return False
+ started, finished = row.get('started_at'), row.get('finished_at')
</file context>
|
|
||
| _MAX_GAP_SECONDS = 3.0 | ||
| _MAX_JOINED_CHARS = 125 | ||
| _SENTENCE_ENDERS = ('.', '?', '!') |
There was a problem hiding this comment.
P2: The join guard recognizes only ASCII sentence terminators, so long non-English sentences can absorb the next piece. Include the project’s supported Unicode sentence endings.
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/word_pieces.py, line 12:
<comment>The join guard recognizes only ASCII sentence terminators, so long non-English sentences can absorb the next piece. Include the project’s supported Unicode sentence endings.</comment>
<file context>
@@ -0,0 +1,208 @@
+
+_MAX_GAP_SECONDS = 3.0
+_MAX_JOINED_CHARS = 125
+_SENTENCE_ENDERS = ('.', '?', '!')
+_SAME_CLOCK_SLOP_SECONDS = 0.01
+_MIN_REPEAT_WORDS = 5
</file context>
| last: dict[tuple[str, str], dict] = {} | ||
| for segment in segments: | ||
| stream = _stream(segment) | ||
| if stream is None or segment.get('audio_alignment') == 'unplaced': |
There was a problem hiding this comment.
P2: This branch leaves the prior same-stream anchor active across an unplaced segment, so a later word can be merged before that segment and reorder the transcript. Clear the stream’s anchor when an unplaced segment is encountered.
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/word_pieces.py, line 185:
<comment>This branch leaves the prior same-stream anchor active across an unplaced segment, so a later word can be merged before that segment and reorder the transcript. Clear the stream’s anchor when an unplaced segment is encountered.</comment>
<file context>
@@ -0,0 +1,208 @@
+ last: dict[tuple[str, str], dict] = {}
+ for segment in segments:
+ stream = _stream(segment)
+ if stream is None or segment.get('audio_alignment') == 'unplaced':
+ joined.append(segment)
+ continue
</file context>
| [ | ||
| {'starred': True}, | ||
| {'user_title': 'mine'}, | ||
| {'has_photos': True}, |
There was a problem hiding this comment.
P3: The curation-protection parametrize list omits photos and folder_user_set, two of the signals is_user_curated checks. Add cases so a regression in either one is caught.
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/tests/unit/test_episode_home_read.py, line 315:
<comment>The curation-protection parametrize list omits `photos` and `folder_user_set`, two of the signals `is_user_curated` checks. Add cases so a regression in either one is caught.</comment>
<file context>
@@ -269,3 +269,62 @@ def test_partly_shared_episodes_both_stay(store, monkeypatch):
+ [
+ {'starred': True},
+ {'user_title': 'mine'},
+ {'has_photos': True},
+ {'sync_relevance_user_kept': True},
+ {'finished_at': START + timedelta(seconds=60)},
</file context>
| {'has_photos': True}, | |
| {'has_photos': True}, | |
| {'photos': ['p']}, | |
| {'folder_user_set': True}, |
Co-Authored-By: Claude Opus 5.5 <[email protected]>
… stream Repeated-ID dedupe now applies only to provider streams, so a receipt-only replay of an unscoped line still reappends as the recovery tests require. Counts the Home hide kill switch in the flag budget. Failure-Class: none Co-Authored-By: Claude Opus 5.5 <[email protected]>
…ple cap (#24228) ## Summary Train safety for the GMP sidecar's per-scrape `samples` cap (lead ruling 3d124a). Above the cap, GMP drops the instance's **whole** scrape, not just the new series. Backend Cloud Run max scrape, read-only GMP aggregates (`scrape_samples_scraped`, job `omi-cloud-run-application-metrics`): | Service | Max scrape | Note | |---|---|---| | backend | 9,339 now; 9,873 24h max | 3 instances, median 9,224 | | backend-sync | 7,704 | | | backend-sync-backfill | 6,769 | | | backend-integration | 6,042 | | | desktop-backend | 3,151 | | The next train adds to backend, beyond the write probe: - #24211 stage histogram: 96 - #24223: up to 18, behind a default-off flag - #24214: 2 - #24212: up to 2 That is up to about 118 samples against roughly 127 of headroom. Two changes: 1. **`OMI_FIRESTORE_WRITE_PROBE_ENABLED` kill switch** for the #24218 write probe. It is on unless the literal `false`. Off means `database._client` never wraps the transport, so no labelled write series exist in that process. That leaves 2 unlabelled counter samples. It is registered in `config/feature-flags.yaml` as `ops_kill`, and the registry doc is re-rendered. 2. **Shared Cloud Run sidecar cap 10,000 → 15,000** (`backend/deploy/cloud_run_gmp_sidecar.yaml`: backend, desktop-backend, notifications-job). Today backend is about 1% from losing all metrics on any new series; this restores headroom. GMP bills per sample emitted, so the cap itself costs nothing. The sync sidecar (`cloud_run_gmp_sync.yaml`, max 7,704) is unchanged. Series behaviour: - **Write probe series are per instance.** They grow with code-path diversity (distinct caller × collection × op an instance has executed, capped), not with write volume. - **At batch 100%**, instance count may grow and each instance sees more batch callers. Per-instance cardinality rises toward the caps, not with load. Recommended for the train: merge this. If the cap raise is not wanted in this train, set `OMI_FIRESTORE_WRITE_PROBE_ENABLED=false` on backend Cloud Run only. Sync, listen and pusher keep the probe. ## Product invariants affected none. Observability config only; no data path. ## Verification All runs used `backend/test.sh` under `bin/omi-heavy` + `nice -n 19`, at the unit layer: - `test_firestore_write_probe.py`: 16 passed, including the kill switch (literal `false` and ` FALSE ` leave `FirestoreClient.commit` unwrapped; unset, empty, `true`, `0`, `off` stay on). - The other tests that read the sidecar config: `test_attach_cloud_run_gmp_sidecar` (117), `test_external_list_cache`, `test_fleet_deployment`, `test_parakeet_request_metrics`, `test_relevance_metric_is_scraped`, `test_sync_absorption_metrics`. All pass. - `scripts/check_feature_flag_registry.py`: OK. ## Rollback Set the switch to `false` on any service, or revert. The cap can return to 10,000 only if the max scrape is well below it. 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/24228?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/24228?returnTo=https%3A%2F%2Fgithub.com%2FBasedHardware%2Fomi%2Fpull%2F24228&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. -->
Transcripts on one account showed one word per line, some words twice, and Home showed noise rows from a few seconds of speech.
What was wrong
Soniox emits one segment per word and leaves joining to the live tail merge. Three things went wrong from there:
On that account, 11,974 of 12,802 Soniox segments on 10-31 were one word (at most 386 on any earlier day since 10-11), and 4,750 stored segments were repeats, nearly all with the same ID twice. Oversized transcripts also inflate notes prompts and can push conversations toward the sync size rollover.
What changed
join_word_pieces: fresh one-word pieces join the same speaker's preceding piece from the same provider stream on sync intake. A batch carrying capture receipts keeps its pieces, because receipts name segment IDs._live_merge_anchor: the live merge anchors on the same stream, not the timeline tail, and keeps capture proofs for both the anchor and the tail.drop_replayed_words: retries are dropped by ID, or by a word the same stream already covers. A joined word no longer has its own exact range for the existing dedupe to match.drop_repeated_word_runs: a run of 5+ words is dropped when 70% of it repeats a line another provider wrote within ten minutes.HOME_HIDE_BELOW_FLOOR_ROWS(on unless set off). The env is read per request, but changing it takes a new backend revision, so rollback is a revision, not instant.omi_episode_home_members_total{outcome}counts shown and hidden members, with no IDs or text.Trade-offs and what this leaves
Verified: 1,378 unit tests across every file touching these writers pass. Luna reviewed three times. Seven findings are fixed. Two are accepted: a genuine repeat within ten minutes that arrives late from a second provider can be dropped, and the
showncount includes episodes later removed as duplicates. Not yet run against production traffic.Failure-Class: none
UI-Evidence: none -- backend only; rows and lines render through existing UI
🤖 Generated with Claude Code