Skip to content

Reduce redundant background episode composition - #24579

Merged
Git-on-my-level merged 10 commits into
mainfrom
lane/epcompose
Nov 4, 2026
Merged

Git-on-my-level merged 10 commits into
mainfrom
lane/epcompose

Conversation

@Git-on-my-level

@Git-on-my-level Git-on-my-level commented Nov 4, 2026 •

Copy link
Copy Markdown
Member

Requested by David

Closed-episode composition currently pays roughly 19 times per episode close because every member finalize can reschedule it, including sync updates that only regenerate summaries or speaker labels. Gate finalizers using their already-loaded member: only retained membership, speech text, resolved person names, discard state, or visible-note repair needs trigger composition. Keep the full fingerprint, prompt inputs and paid-once lease unchanged.

Background composes wait for 10 quiet minutes, capped at 25 minutes from the first pending arrival. A tracked async task requeues due work without holding composer workers. Persist pending timestamps so restart recovery preserves the cap; foreground reads promote deferred work immediately. Background stale/superseded paid attempts wait through a fresh quiet window before retrying. The attachment path is unchanged.

EPISODE_COMPOSE_SETTLE_ENABLED is on by default; set off to restore previous triggering and immediate retries. No composer-version bump or eager recompose wave. The deferred queue is process-local, like existing scheduling: finalizes and the read safety net recover pending work after instance restart; this is not a durable background execution SLA.

Legacy rollout: episodes without the new narrow stamp backfill it for free when their full fingerprint still matches. If that full fingerprint changed, one conservative compose is necessary because the old hash cannot distinguish label drift from real late speech. That successful compose seeds the narrow stamp and subsequent label-only updates skip. No historical-data migration or eager recompose wave.

Review follow-up

  • P2-1: exhausted CAS retries or storage errors while writing settle state no longer drop finalizer work. Finalizers still schedule; if the worker cannot persist the retry either, it bypasses settling and uses the existing fingerprint/paid-once lease. Shared fallback telemetry records this cost-over-staleness choice.
  • P2-2: persisted compose_pending_since remains read-eligible with either switch setting after a restart. With the switch off, the recovered work runs immediately; a reverted transcript clears the marker without paying. With the switch on, reads bypass debounce and later triggers retain the original 25-minute cap, including continued new speech.
  • Round 3 P2: when the 10,000-entry settle queue is full, newly pending work falls through to immediate composition using the existing fingerprint and paid-once lease. Queued work stays intact. Shared omi_fallback_total records saturation with reason="capacity_full" for the settling-to-immediate path. Regression cases cover both first composition and late speech, pending-state clearing, queue preservation and subsequent deduplication.
  • P3: phase-shadow mismatches during settling are expected: needs_compose detects pending freshness work while the read-only phase projection still reports COMPOSED. These mismatches do not change the phase decision.

Backend train coordination

Ride the same backend train as #24582 and uicleanup's #24544. #24544 shares service.py's finalize region. It was still open at the follow-up merge check. Main at 7f271cfcb110d187d0d90ba5315d81d9504efe27 was merged to resolve a feature-flag registry conflict, preserving both entries and regenerating the registry. Re-check #24544 before landing and merge main again if it has merged. This follow-up does not change the finalize or attachment path.

Validation

  • 240 targeted tests passed, each suite in its own pytest process through omi-heavy: test_episode_composer.py (88), test_episodes_service.py (100), test_episode_home_read.py (28), test_episodes_finalizer_hook.py (5), test_episodes_finalize_paths.py (18), test_episodes_metrics_export.py (1).
  • Covers label/summary-only no-spend sync updates, real late members/speech/name changes, discard/delete/membership repair, quiet-window extension and cap, restart recovery with either switch setting, exhausted pending-write retries and storage errors, Home read promotion, paid-once leases, stale/superseded retry delay, rollback, cancellation, full settle-queue immediate composition and bounded metric labels.
  • Round 3 passed all 39 make preflight checks through omi-heavy with OMI_CHECKS_JOBS=1, including the async-blocker scan and runtime-image source closure. The normal pre-push gate passed, including backend type checking (zero errors), 88 composer tests and pinned formatting. No hooks were skipped.
  • The reason-enum guard plus metrics export passed (20 tests); the separately reported audio-outbox capacity case passed in isolation.
  • Local fake-store/provider validation only. No production reads or writes; no GCP tier used. No PR merge or deploy.

Expected savings and post-deploy verification

Estimated overlap-adjusted savings: $60–150/day in LLM spend and 0.3–0.7M conversation reads/day from avoiding redundant composer evaluations. These are handoff estimates, not measured post-deploy results; pending-state operations must be included in the net read comparison.

After the serving revision has a complete settle window, compare equal windows using omi_episode_compose_total by outcome: composed per omi_episode_closed_total, paid attempts (composed|superseded|error|stale), superseded, and new settling. Confirm omi_episode_compose_trigger_skipped_total{reason="evidence_unchanged"} rises and late-evidence/discard repair plus foreground bypass remain correct.

For aggregate Firestore validation from the workspace: source ~/.local/bin/gcp-agent-env.sh ro-prod, then python3 avo/firestore-reads/measure.py --hours 3. Compare caller rows conversations:get_conversation, conversations:get_conversation_photos and episodes:get_episode by service/collection, with caller coverage and overflow healthy. These callers are shared: normalize by finalize volume and the skipped-trigger counter before attributing savings. Detailed follow-up is in the pipeline change note.

CI status

Round 3 head cf371e1be0a82a82674bb75187f75486b5f2162c is pushed normally; CI is pending. The prior-head failure below is historical, not a result for this new head.

CI on follow-up head 55eb517cfe38e4546b3ff818a92c22ef1f81e91d hit the same inherited Soniox mismatch: test_soniox_refusal_at_submission_is_typed_and_not_submitted[503-error_5xx] expects submitted=False, while the implementation records an uncertain 503 paid POST as submitted=True. See current failing shard 3/8. Both that test and the implementation are identical between this head and main at a5ccd17d67e3ccc4382b9401cd5ea6330e95a6a6. The prior reviewed head failed the same assertion; its isolated mock-transport probe against main reproduced it without vendor or production IO. Soniox code and tests are outside this composer diff. Other CI jobs were still running when the first-failure waiter exited; this is not an all-green CI claim.

Product invariants affected

none

Failure-Class: none

Line-Count-Exception: backend/utils/episodes/service.py | 1974 -> 1978 | Pass the already-loaded finalized member to the composer gate; attachment logic remains unchanged.

View guided diff Turn on auto-fix

🤖 Generated with Claude Code

@cubic-dev-ai cubic-dev-ai 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.

1 issue found across 11 files

Confidence score: 4/5

  • backend/utils/episodes/ARCHITECTURE.md overstates the retry contract: foreground read promotions retry stale and superseded attempts immediately, without a quiet window. Clarify that the quiet window applies to background retries, or change foreground retry handling.
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/episodes/ARCHITECTURE.md">

<violation number="1" location="backend/utils/episodes/ARCHITECTURE.md:277">
P2: This overstates the retry contract: foreground read promotions retry `stale`/`superseded` attempts immediately without creating a quiet window. Say this applies to background retries, or change foreground retry handling to defer too.</violation>
</file>

Reply with feedback, questions, or to request a fix.

View guided diff | Turn on auto-fix | Re-trigger cubic

Comment thread backend/utils/episodes/composer.py Resolved
Comment thread backend/utils/episodes/ARCHITECTURE.md Outdated
A tracked async task requeues process-local due work without occupying composer
workers; shutdown cancels it. Finalizes and reads recover pending work after
restart using the persisted window (no new durable queue or sweeper). A paid
`stale`/`superseded` result starts a fresh quiet window before its retry, including

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: This overstates the retry contract: foreground read promotions retry stale/superseded attempts immediately without creating a quiet window. Say this applies to background retries, or change foreground retry handling to defer too.

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/ARCHITECTURE.md, line 277:

<comment>This overstates the retry contract: foreground read promotions retry `stale`/`superseded` attempts immediately without creating a quiet window. Say this applies to background retries, or change foreground retry handling to defer too.</comment>

<file context>
@@ -264,7 +268,22 @@ episode's final notes in one `episode_composer` call (gpt-6-luna, low effort):
+  A tracked async task requeues process-local due work without occupying composer
+  workers; shutdown cancels it. Finalizes and reads recover pending work after
+  restart using the persisted window (no new durable queue or sweeper). A paid
+  `stale`/`superseded` result starts a fresh quiet window before its retry, including
+  when the previous window reached its cap. Read-side schedules (`throttle=True`)
+  promote pending work immediately; direct `compose` and `force=True` bypass
</file context>
Suggested change
`stale`/`superseded` result starts a fresh quiet window before its retry, including
A paid background `stale`/`superseded` result starts a fresh quiet window before its retry, including

@Git-on-my-level
Git-on-my-level marked this pull request as draft November 4, 2026 11:37
@Git-on-my-level

Copy link
Copy Markdown
Member Author

episodes batch 1: ships together as one train, CI red

@Git-on-my-level
Git-on-my-level marked this pull request as ready for review November 4, 2026 12:59
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 4, 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-11-04T13:11:19.076094Z 14af0bc 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.

@cubic-dev-ai cubic-dev-ai 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.

5 issues found across 11 files

Confidence score: 3/5

  • backend/utils/episodes/composer.py can skip composing when only segment start times change, leaving chapter clock labels and moment offsets stale. Include segment start times in evidence_trigger.
  • The trigger rule in backend/docs/listen_pusher_pipeline.mdx contradicts itself about discard, visible-note repair, and regeneration updates. Clarify which updates actually trigger a recompose.
  • The verification guidance in backend/docs/listen_pusher_pipeline/changes/2026-11-04-episode-compose-settle.md can count pre-invocation read errors as paid model calls. Track errors separately and count only outcomes that prove a model invocation.
  • The same change note presents the $60–150/day savings figure as an expectation despite being unmeasured. Label it as a pre-deploy estimate.
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/episodes/metrics.py">

<violation number="1" location="backend/utils/episodes/metrics.py:180">
P3: The module docstring lists the composer metrics but omits the new `omi_episode_compose_trigger_skipped_total` counter. Add a bullet for it next to the `omi_episode_compose_total` entry so the docstring stays the metric inventory.</violation>
</file>

<file name="backend/docs/listen_pusher_pipeline/changes/2026-11-04-episode-compose-settle.md">

<violation number="1" location="backend/docs/listen_pusher_pipeline/changes/2026-11-04-episode-compose-settle.md:56">
P3: The verification guidance treats every `error` outcome as paid, but `compose()` records errors from pre-invocation episode/member reads too. Track `error` separately and use only outcomes that prove a model invocation when estimating paid calls.</violation>

<violation number="2" location="backend/docs/listen_pusher_pipeline/changes/2026-11-04-episode-compose-settle.md:69">
P3: The $60–150/day savings figure is written as an expectation with no caveat. The PR says it is unmeasured, so mark it as a pre-deploy estimate like the read-savings figure.</violation>
</file>

<file name="backend/utils/episodes/composer.py">

<violation number="1" location="backend/utils/episodes/composer.py:145">
P2: `evidence_trigger` ignores segment `start` times, so a sync upgrade that only re-times speech won't trigger a compose. The chapter `start`/`end` clock labels and moment offsets come from those starts, so they stay stale. Consider adding the rounded `start` to the hashed tuple.</violation>
</file>

<file name="backend/docs/listen_pusher_pipeline.mdx">

<violation number="1" location="backend/docs/listen_pusher_pipeline.mdx:9081">
P3: The 'Only ... trigger' wording says discard, visible-note repair, and regeneration do not trigger a recompose, but the next clause says they do. State the actual rule: summary-only and speaker-label-only updates skip the recompose, while the listed changes still trigger it.</violation>
</file>

Reply with feedback, questions, or to request a fix.

View guided diff | Turn on auto-fix | Re-trigger cubic

def evidence_trigger(row: Mapping[str, Any]) -> str:
"""Only speech and resolved names buy a new compose; labels and summaries remain prompt inputs."""
raw = json.dumps(
[(str(s.get('text')).strip(), str(s.get('person_name') or '').strip()) for s in _segments(row)],

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: evidence_trigger ignores segment start times, so a sync upgrade that only re-times speech won't trigger a compose. The chapter start/end clock labels and moment offsets come from those starts, so they stay stale. Consider adding the rounded start to the hashed tuple.

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/composer.py, line 145:

<comment>`evidence_trigger` ignores segment `start` times, so a sync upgrade that only re-times speech won't trigger a compose. The chapter `start`/`end` clock labels and moment offsets come from those starts, so they stay stale. Consider adding the rounded `start` to the hashed tuple.</comment>

<file context>
@@ -132,6 +139,30 @@ def fingerprint(members: Sequence[Mapping[str, Any]]) -> str:
+def evidence_trigger(row: Mapping[str, Any]) -> str:
+    """Only speech and resolved names buy a new compose; labels and summaries remain prompt inputs."""
+    raw = json.dumps(
+        [(str(s.get('text')).strip(), str(s.get('person_name') or '').strip()) for s in _segments(row)],
+        ensure_ascii=False,
+        separators=(',', ':'),
</file context>
Suggested change
[(str(s.get('text')).strip(), str(s.get('person_name') or '').strip()) for s in _segments(row)],
[(round(float(s.get('start') or 0), 1), str(s.get('text')).strip(), str(s.get('person_name') or '').strip()) for s in _segments(row)],

COMPOSE_SKIP_REASONS = frozenset({'evidence_unchanged'})
EPISODE_COMPOSE_TRIGGER_SKIPPED_TOTAL = reuse_or_create(
Counter,
'omi_episode_compose_trigger_skipped_total',

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P3: The module docstring lists the composer metrics but omits the new omi_episode_compose_trigger_skipped_total counter. Add a bullet for it next to the omi_episode_compose_total entry so the docstring stays the metric inventory.

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/metrics.py, line 180:

<comment>The module docstring lists the composer metrics but omits the new `omi_episode_compose_trigger_skipped_total` counter. Add a bullet for it next to the `omi_episode_compose_total` entry so the docstring stays the metric inventory.</comment>

<file context>
@@ -173,6 +174,13 @@ def reuse_or_create(factory, name: str, documentation: str, labelnames: list[str
+COMPOSE_SKIP_REASONS = frozenset({'evidence_unchanged'})
+EPISODE_COMPOSE_TRIGGER_SKIPPED_TOTAL = reuse_or_create(
+    Counter,
+    'omi_episode_compose_trigger_skipped_total',
+    'Composer triggers skipped before scheduling or paying, by bounded reason. Never labeled by uid.',
+    ['reason'],
</file context>

savings using skipped triggers and a stable finalize volume, not their raw
totals alone. No account documents are needed.

Expected overlap-adjusted savings: $60–150/day in model spend. The design handoff

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P3: The $60–150/day savings figure is written as an expectation with no caveat. The PR says it is unmeasured, so mark it as a pre-deploy estimate like the read-savings figure.

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/listen_pusher_pipeline/changes/2026-11-04-episode-compose-settle.md, line 69:

<comment>The $60–150/day savings figure is written as an expectation with no caveat. The PR says it is unmeasured, so mark it as a pre-deploy estimate like the read-savings figure.</comment>

<file context>
@@ -0,0 +1,72 @@
+  savings using skipped triggers and a stable finalize volume, not their raw
+  totals alone. No account documents are needed.
+
+Expected overlap-adjusted savings: $60–150/day in model spend. The design handoff
+estimates 0.3–0.7M fewer conversation reads/day from gating roughly 108k no-op
+composer evaluations; treat that as a pre-deploy estimate, not measured savings.
</file context>
Suggested change
Expected overlap-adjusted savings: $60–150/day in model spend. The design handoff
Pre-deploy estimate, not measured savings: $60–150/day in model spend. The design handoff

Comment on lines +9081 to +9083
Only changed retained membership, speech text or resolved person names trigger a
paid recompose; discard, visible notes drift and explicit regeneration remain
repair triggers. Summaries and speaker labels remain prompt inputs, and the full

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P3: The 'Only ... trigger' wording says discard, visible-note repair, and regeneration do not trigger a recompose, but the next clause says they do. State the actual rule: summary-only and speaker-label-only updates skip the recompose, while the listed changes still trigger it.

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/listen_pusher_pipeline.mdx, line 9081:

<comment>The 'Only ... trigger' wording says discard, visible-note repair, and regeneration do not trigger a recompose, but the next clause says they do. State the actual rule: summary-only and speaker-label-only updates skip the recompose, while the listed changes still trigger it.</comment>

<file context>
@@ -9070,3 +9070,16 @@ loss. [Details and verification](listen_pusher_pipeline/changes/2026-11-03-recov
+full-fingerprint triggering and immediate retries. When enabled, background
+composes wait for 10 quiet minutes, with a 25-minute cap from the first pending
+arrival. Foreground read-side schedules and forced composes bypass this window.
+Only changed retained membership, speech text or resolved person names trigger a
+paid recompose; discard, visible notes drift and explicit regeneration remain
+repair triggers. Summaries and speaker labels remain prompt inputs, and the full
</file context>
Suggested change
Only changed retained membership, speech text or resolved person names trigger a
paid recompose; discard, visible notes drift and explicit regeneration remain
repair triggers. Summaries and speaker labels remain prompt inputs, and the full
Summary-only and speaker-label-only updates skip paid recompose. Changed retained membership, speech text, or resolved person names trigger it, and so do
discard, visible-note repair, and explicit regeneration. Summaries and speaker labels remain prompt inputs, and the full

- `sum(increase(omi_episode_compose_total{outcome="composed"}[24h])) /
sum(increase(omi_episode_closed_total[24h]))`: currently about 19; should fall
substantially. Also sum paid outcomes `composed|superseded|error|stale`.
- Compare `superseded`, `stale`, `error` and new `settling` outcomes. Confirm the

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P3: The verification guidance treats every error outcome as paid, but compose() records errors from pre-invocation episode/member reads too. Track error separately and use only outcomes that prove a model invocation when estimating paid calls.

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/listen_pusher_pipeline/changes/2026-11-04-episode-compose-settle.md, line 56:

<comment>The verification guidance treats every `error` outcome as paid, but `compose()` records errors from pre-invocation episode/member reads too. Track `error` separately and use only outcomes that prove a model invocation when estimating paid calls.</comment>

<file context>
@@ -0,0 +1,72 @@
+- `sum(increase(omi_episode_compose_total{outcome="composed"}[24h])) /
+  sum(increase(omi_episode_closed_total[24h]))`: currently about 19; should fall
+  substantially. Also sum paid outcomes `composed|superseded|error|stale`.
+- Compare `superseded`, `stale`, `error` and new `settling` outcomes. Confirm the
+  skipped-trigger counter increases for `reason="evidence_unchanged"`.
+- Check real late speech, membership and discard changes still update notes;
</file context>

#24579 added a keyword-only row= to composer.after_finalized; the #24582
review test's lambda double rejected it (TypeError -> outcome=error).

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@Git-on-my-level

Copy link
Copy Markdown
Member Author

Ship note (cl2-helper fork, 2026-11-04 ~13:10Z). Authorization, David in chat: ~12:55Z "skip pre-push and skip CI to get them merged in. I need to ship ASAP"; ~13:05Z "Anything that's not obviously owned by a lane you can take over. Be as fast and loose as possible to get these savings live and the next train shipped."

🤖 Generated with Claude Code

@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: 0774a05313

ℹ️ 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 thread backend/main.py
validate_account_deletion_dispatch_configuration()
validate_streaming_stt_env()
start_background_task(log_executor_health(), name='executor_health')
start_background_task(retry_settled_composes(), name='episode_compose_settle')

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 Start the settle queue drainer in Pusher as well

For live recordings finalized by Pusher, the new background compose is deferred into Pusher's process-local _deferred dictionary, but this retry task is started only in the backend entrypoint. Pusher calls finalize_persisted_conversation (backend/utils/pusher_finalization.py:204), which invokes the episode finalization hook, while backend/pusher/main.py:58–66 never starts retry_settled_composes. Consequently, these composes never run automatically after the 10-minute quiet window or 25-minute cap, even while Pusher remains healthy; they depend on a subsequent foreground read or another host's trigger. Start the tracked drainer in every serving process that can defer composition, including Pusher.

Useful? React with 👍 / 👎.

conversation_id,
_on_finalized(uid, conversation_id, row, trigger, absorbed_from, c),
c,
row=row if not absorbed_from else None,

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 Update existing finalization mocks for the new row keyword

The existing discard regression tests replace composer.after_finalized with lambda uid, cid, outcome, c: outcome in backend/tests/unit/test_episode_attach_review.py:68 and backend/tests/integration/test_recorded_episode_timeline_emulator.py:852. Passing the new row keyword raises TypeError in both mocks; on_conversation_finalized catches it and returns 'error', so both tests fail their expected 'skipped_discarded' assertions for each parametrized mutation. Update these existing test doubles alongside the signature change so the discard regression suites remain usable.

AGENTS.md reference: AGENTS.md:L34-L34

Useful? React with 👍 / 👎.

@Git-on-my-level
Git-on-my-level merged commit 52f1879 into main Nov 4, 2026
26 of 27 checks passed
@Git-on-my-level
Git-on-my-level deleted the lane/epcompose branch November 4, 2026 13:07
Git-on-my-level added a commit that referenced this pull request Nov 4, 2026
)

<!-- claude-projects-attribution: {"github_login":"Git-on-my-level"} -->
_Requested by **David**_

Batch captures previously stayed outside episodes until transcription
finished. Audio close now attaches retained captures by committed audio
bounds before queueing finalization, through the shared fenced
recorded-time membership transaction. Arrival and processing clocks
never select the episode or change its live pointer.

The membership transaction stamps a fixed pending-transcription entry
time and two-hour deadline. Replays preserve the deadline. Home shows
“Transcribing…” while awaiting the durable batch projection; a dead
letter, failed upload/status or elapsed deadline shows “Couldn't
transcribe” with the committed audio finish time. A later successful
projection restores ordinary member metadata. Audio and retry work
remain retained.

`EPISODE_BATCH_CLOSE_ATTACH_ENABLED` defaults on. Setting it to
false/off/0/no restores attach-after-transcription. Episode/cohort,
privacy, custom-STT, retention, lock, deletion and donor guards remain
authoritative. Attachment adds no model calls and does not require a
client-seen marker. Failure emits shared degraded-fallback telemetry and
leaves finalization as the repair path. The overdue metric is an
unlabeled read-observation counter; the info alert remains in the
pending catalog, with no monitoring provisioning in this PR.

Refreshed with merge commits through main `563e6c240944` (#24577,
#24579, #24582/#24604 and subsequent main changes, including #24509).
The resolution keeps batch 1's shared transaction/fence, attempt-local
candidate reuse, current canonical partition proof, visibility
validation, deduplicated memberships and recovery memo. Pending close
writes its deadline inside that transaction without claiming/resetting
completed transcript recovery. Close replay validates current committed
archive bounds, normalized through the same datetime conversion used at
admission, and is a true no-op with attach optimizations on or off.
Changed bounds still update the episode without renewing the deadline.
Composer settling, foreground promotion, Home read cuts and
recording-speaker carry remain intact.

The five original conflicts were in `episode_recorded_components.py`,
`episode_timeline.py`, `service.py`, the Firestore query-driver registry
and the generated feature-flag catalog. The sync callback and affected
tests now use the public `attach_recorded` helper. The final speaker-tip
merge was clean; the core episode resolution is unchanged.

Validation at `817784dced26`: **858 passed across 21 focused backend
files** through `backend/test.sh` with an explicit file list and four
workers; **4 real Firestore emulator replay cases passed**, covering
integer/fractional archive epochs and attach optimizations on/off. All
tests/build gates run through `omi-heavy` at low priority, with no
production credentials.

Emulator limitation: the full 28-case episode suite alternated SDK
transaction-lock timeouts between two old concurrency cases. Its last
full run was **27 passed / 1 failed**, not all green. Both concurrency
cases then passed together in a targeted run on exact main
`cf601889c67b` and exact candidate `b8633977345c`. All 28 cases have
passing candidate executions across full plus targeted runs; this does
not establish a cause for the intermittent timeout. Core
episode/emulator source is byte-identical after the final main merge,
and the four new replay cases were rerun on the final head. Firestore
clients now close at fixture teardown; test concurrency and transaction
retry budgets are unchanged.

Final hermetic e2e at `817784dced26`: **205 passed, 3 skipped, 2 xfailed
in 101.14s**, within the unchanged **120s** limit. Native-library
threads were capped at one; `--disable-warnings` suppressed only the
console warning summary, without filtering warnings or changing warning
assertions. Two earlier final-head attempts reached the wall limit (one
at 100% test progress while rendering warnings). The lead authorized a
documented 300s diagnostic if necessary, but it was **not used**.
Committed and remote-CI budgets remain 120s. `make preflight` passed
**43/43** before the final clean main merge; the normal push hook runs
the final required gates again.

Failure-Class: FC-finalize-hook-allowlist-omits-ingestion-path

Product invariants: INV-MEM-4 and INV-TASK-2. Canonical episode
ownership and task/enrichment authority remain unchanged.

No PR merge, deploy, production account access or GCP calls. GCP tier:
none. No rebase, force-push, workflow additions or firmware edits. The
lead owns merge and the backend/listen release train.

UI-Evidence: none -- backend response projection; related mobile fixture
evidence belongs to #24541.
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.

1 participant