Skip to content

Episode-join variant F behind a runtime flag - #24730

Merged
Git-on-my-level merged 11 commits into
mainfrom
claude/project-thread-fb5dp4
Nov 6, 2026
Merged

Git-on-my-level merged 11 commits into
mainfrom
claude/project-thread-fb5dp4

Conversation

@Git-on-my-level

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

Copy link
Copy Markdown
Member

Requested by David · project thread

What changed and why

Production path for episode-join variant F (David, 2026-11-05: ship under the $0.5/user/mo cap, est. ~1.5¢; ramp 5→25→100% as soon as each step is safe). Today, with recorded-time episodes on, every join to a live owner inside 30 minutes is decided by time alone and Jev never runs (the boundary counters read 0).

  • Mark (attach): in _attach_once's recorded-time owner branch, an admitted user's join to a live owner 2 to 30 minutes after its last speech still joins by time (Home hides it under the live row), and is marked pending_boundary[cid] = {variant: 'f', ...}. Shorter gaps, overlaps, late audio and closed owners keep today's rules.
  • Settle (first moment): _settle_boundary asks Jev with the F state only: the previous member's transcript (last 12,000 chars) and the new speech (first 8,000 chars), rendered as in the offline F run; no summary, time features or voice flag. p < 0.2 (MOVED_ON_THRESHOLD) splits the conversation into a new episode (moved_on, or source_change). No answer, error, timeout or out-of-range answer keeps today's join. F calls use their own Jev lane, episode_boundary_f (same gateway model omi:auto:jev-decisions → pinned typesafe/jev-1.13 as the offline run). Client timeout 3.0 s, one attempt; the gateway's 2.5 s provider deadline is authoritative.
  • Flag: Omi flag store rule episode_f_join is the ramp and the instant kill (scripts/omi_flags.py set episode_f_join --rollout 5 | --inactive, propagates in 15–60 s, no deploy). With no rule or an unconfigured store, EPISODE_F_JOIN_PERCENT (default 0) buckets uids. EPISODE_F_JOIN_ENABLED=off overrides both. Admission is checked at attach and again at settle, so a kill also stops already-marked joins from calling Jev. Merging ships F dark.
  • Known difference from the scored offline run: offline F saw the candidate's whole transcript. In production the join settles at the conversation's first moment, so Jev sees the speech so far (the first moment, up to 8,000 chars). This is not a timeout limit. A full transcript exists only after the conversation finalizes, and by then its moments have been folded into the joined episode's live notes. Settling later would mean splitting after notes were written, which this PR does not do. The ramp's share-closed and size guardrails measure the effect. Settling at finalize would be a follow-up.
  • Guardrail metrics: omi_jev_decision_total{lane="episode_boundary_f",outcome} + latency histogram (error and timeout rate); omi_episode_boundary_total{outcome=f_pending|f_continue|f_close|f_no_answer|f_disabled|f_pending_conflict|f_pending_error|f_later_member} (share Jev closes; f_later_member counts joins kept without a question because another member recorded later); new omi_episode_closed_members{arm} and omi_episode_closed_span_seconds{arm} (episode size; histogram count ÷ arm percent compares episodes per user, arm = f|control).
  • Bug fix found on the way: database.episodes._close computed a closed episode's recorded window from its pre-detach membership, so after any split-off the successor failed the recorded_window_overlap check and the moment was dropped as skipped_closed. Only an admitted F split now opts into the post-detach membership (merged). Ordinary closes, including flag-off legacy pending detaches, retain main's membership reads and recorded-end evidence. Without this fix F's moved-on splits could never succeed under recorded time.

Line-Count-Exception: backend/utils/episodes/service.py | 1967 -> 2037 | F call sites in _attach_once/_settle_boundary; the F logic lives in utils/episodes/f_join.py
Line-Count-Exception: backend/utils/metrics.py | 1673 -> 1674 | one bounded Jev lane label (episode_boundary_f)

Review round 1 (cubic, codex)

  • EPISODE_F_JOIN_ENABLED: an unrecognised value (e.g. disabled) now turns F off. Only unset or an on-value keeps it on.
  • The predecessor is recorded at mark time (pending_boundary[cid].previous) and settled against, so a member that attached later is never used as the predecessor.
  • Joins are marked only where the meeting authority (boundary_runtime.decision) asks a question, so a meeting it keeps whole is never F's.
  • A moment too short to commit (MOMENT_MIN_WORDS / FINALIZE_MIN_WORDS) never asks Jev and never splits; the join stays unchanged until a moment long enough to commit.
  • The arm is stamped on the episode when it opens (f_join_arm), so closed-size metrics use the arm live at open, not the arm at close. Episodes opened before this change carry no arm and are not counted.
  • No-answer and error fallbacks report through record_fallback (component episode_f_join, outcome degraded) as well as the episode-domain counter.
  • commit_moment failures other than EpisodeConflict count as f_pending_error, not f_pending_conflict.
  • The span histogram is in seconds: omi_episode_closed_span_seconds.
  • The Jev timeout comes from the shared JEV_CLIENT_TIMEOUT_SECONDS.
  • Speech carried from an F-marked member waits for its own boundary instead of folding into another conversation's moment.

Review round 2 (codex)

  • Delayed candidate, later member: if a member recorded after the candidate's first moment started (for example c3 attached at 10:14 before c2's first moment at 10:12), an F split of c2 would leave the old episode's recorded end past the successor's start and fail recorded_window_overlap. F now keeps such a join without asking Jev (f_later_member). Splitting several members together is a possible follow-up; this keeps today's join.
  • Fallback on a failed marker: when the F marker write raises EpisodeConflict or another error, the join stays unmarked (today's join) and now also reports through record_fallback (component episode_f_join, outcome degraded).

Product invariants affected

none

How it was verified

  • backend/tests/unit/test_episode_f_join.py: 20 tests, recorded-time mode, StrictFirestore. The first 13 cover: marks only admitted 2–30 min joins to a live owner; moved-on splits into a new episode with the right membership and links; same-occasion keeps the join and clears the marker; None / exception / out-of-range answer keeps the join even past the 15 min fallback gap with a device change; kill switch after marking settles without calling Jev; env bucket stability and invalid percent; flag-store rule ramp (5% ≈ 5%), inactive, env override, store error admits nobody; state caps and rendering; closed-size metric by arm. Round 1 added: typo fails closed, short moment never calls Jev, predecessor recorded at mark, arm persisted at open. Round 2 adds: a later member keeps the candidate with no model call, and a failed marker records the shared fallback.
  • scripts/backend-python-format --check on the four changed files: unchanged.
  • scripts/backend-ratchet-preflight: 7 files, 21s, passed.
  • Earlier: backend/test.sh 117-file list over episode, recorded, flag, metric, and fallback suites passes (round 1); make preflight locally (round 1); pyright reports no new errors on the production files.
  • Not verified: live Jev latency for F-sized inputs (the offline run measured P/PT/S at 860 ms median, 988 ms p95; F's ~1,010 input tokens per call was not timed). The 5% step's timeout-rate guardrail measures it.

Tests

Feature: backend/tests/unit/test_episode_f_join.py covers the core path (mark → settle → split/keep) and the error paths (no answer, exception, kill switch, conflict fallback, later member). The detach-window bug is covered by test_uncertain_recorded_join_is_marked_for_f_and_moved_on_splits_it_off, which fails on origin/main's close_episode.

Ramp plan (for lead2 / the deploy owner)

  1. Merge and deploy (dark: no rule, env default 0).
  2. scripts/omi_flags.py --project <flag-project> set episode_f_join --rollout 5 --reason "F ramp 5%" (prod-operator tier).
  3. Advance to 25, then 100, only after each lookback window is clean on: F Jev error rate and timeout rate, share of F joins Jev closes (offline: 10 of 70), f_later_member share, closed-episode members and span by arm, and closed episodes per arm normalized by percent.
  4. Any regression: set episode_f_join --inactive --reason "rollback" (or EPISODE_F_JOIN_ENABLED=off). No user data is deleted on any path; a split only re-links the new conversation to a new episode.

UI-Evidence: none -- backend-only grouping decision; no client change

Failure class (fixes)

Failure-Class: none

🤖 Generated with Claude Code

https://claude.ai/code/session_017CeWxzjTgBhSMjSKfALVqL

Scoped safety delta (fjoin-fix)

  • Predecessors exclude episode-discarded and duplicate members. At settle, recheck retained membership and the current owner-scoped conversation snapshot before decoding or naming. Reuse the composer/build visibility predicates (hidden_member, is_visible_conversation) and processing privacy/lock/hold gates. Deleted, discarded, duplicate/merged-away, failed, locked, deferred, local-only, private data-protection, held and other-owner content cannot reach F Jev; unknown metadata, failed reads/checks or undecodable content keep today's join without Jev. Ordinary owner-only sharing visibility private remains eligible (lead2 clarification, bus 438037).
  • A killed, inactive, zero-percent or absent-rule/default-zero F arm adds no episode field. The explicit env kill does not consult the flag store or resolve admission. Control-arm stamps remain available only during a positive rollout.
  • Only an admitted F split opts into retained-member close windows. Flag-off and legacy pending closes keep main's reads and recorded_end, including the no-span activity fallback.
  • Percentage admission uses a strict threshold with an explicit zero guard. Hash zero cannot enter a zero-percent rollout; 100 percent includes hash one. Existing explicit allow/deny overrides and the per-UID hash remain unchanged.
  • The predecessor text tail is selected before collecting people IDs. Naming reads at most 8 distinct people name documents; no photo query or person-learning projection is invoked.
  • Lead2's follow-up directive is included: the author's unchanged 118de9715e post-Jev race recheck is the base. After an actual committed F detach, observe the candidate's owner once after record_moment retries. A missing/non-live/non-member successor increments omi_episode_boundary_total{outcome="f_orphan"} and logs event=episode_f_join_orphan outcome=no_live_successor without content or identifiers. Unknown observation reads have their own f_orphan_check_error counter and log. Successful retry recovery does not count as an orphan; off/non-split paths make no observation reads.

Per eligible F settle at 100%: +1 predecessor conversation document read, +0–8 people-name document reads, +1 F Jev call. A moved-on answer additionally makes +1 episode recheck read (author race fix); an actual committed F split makes at most +2 owner-link/episode observation reads once after the bounded retry loop. Thus a close is at most +12 document reads and +1 F Jev call; across the existing two-attempt CAS sequence it is at most +22 document reads and +2 F Jev calls (+2 predecessor, +16 people names, +2 post-Jev episode checks, +2 final owner observation). Ineligible/unknown predecessors make no F Jev call. Flag snapshot refresh reads are shared/amortized and separate. This is a code-path bound, not measured vendor spend or a new dollar estimate.

Focused local verification: 8 targeted backend files, 340 tests passed on corrective head 4693d6a41ea, through backend/test.sh under omi-heavy, nice -n 19, four workers and a 900-second file budget. Includes the author's transactional close race test; all twelve full serialized pre-persistence opening payload comparisons; legacy flag-off close read/end parity; visibility/unknown checks; zero/hash-zero and stable cohorts; name/metadata read bounds; orphan fault injection, peer recovery and post-close exception logging. Main byte reference is pinned to 50cea7200a9209ff6fd74bcf590fc4aefbc17eb1. An initial new test expected wall finished_at instead of the fixture's recorded speech end; that assertion was corrected and the integrated shard passed. The subsequent normal push caught conditional keyword-dictionary type inference; the call now uses an explicit f_detaches keyword, and the complete shard was rerun.

One focused read-only Luna delta review was collected (exec-teach-expand-derive-evil-tackle-liberty). Its one P2 (explicit previous=None falling back to a later attachment) was fixed with an exact regression. The subsequent author race commits and lead2-requested orphan telemetry were integrated and verified by the local shard; no second review round was launched. The original author commits 118de9715e, beec4f095eb and e55d0a689ed remain unchanged in ancestry.

Remaining limitation: close and successor creation are separate transactions. A failed successor write after a committed detach can leave the old closed link and be observed as f_orphan; this telemetry does not repair account data. Lead2 owns remaining acceptance/repair decisions, merge, deployment, and the episode_f_join 5→25→100% runtime ramp, targeting about 23:40Z on 2026-11-06 only while the lookback guardrails remain clean. No production account access, cloud tier, deploy, flag flip or workflow change occurred in this lane.

@Git-on-my-level Git-on-my-level self-assigned this Nov 5, 2026
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 5, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-06T21:36:24.629411Z b26122e 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.

All reported issues were addressed across 11 files

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

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

Comment thread backend/config/episodes.py Resolved
Comment thread backend/utils/episodes/service.py Resolved
Comment thread backend/utils/episodes/f_join.py Resolved
Comment thread config/feature-flags.yaml Resolved
Comment thread backend/utils/episodes/metrics.py Resolved
Comment thread backend/config/episodes.py Resolved
Comment thread backend/utils/episodes/f_join.py Resolved

@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: b52a006307

ℹ️ 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/utils/episodes/service.py Resolved
Comment thread backend/utils/episodes/f_join.py Resolved
Comment thread backend/utils/episodes/f_join.py Resolved
Comment thread backend/utils/episodes/service.py Resolved
Uncertain recorded-time joins (a live owner 2 to 30 minutes after its
last speech) are marked at attach for the F cohort and settled at the
conversation's first moment by Jev over the previous member's transcript
tail and the new speech (variant F, no summary or time features). No
answer, an error or a timeout keeps today's time-only join.

Cohort: Omi flag store rule episode_f_join (ramp with --rollout, kill
with --inactive), env EPISODE_F_JOIN_PERCENT fallback (default 0),
EPISODE_F_JOIN_ENABLED=off overrides both. F calls use their own Jev
lane (episode_boundary_f) and boundary outcomes; closed-episode size is
recorded by arm for the ramp guardrails.

Also fixes close_episode computing a closed episode's recorded window
from its pre-detach membership, which made every split-off successor
fail the recorded-window overlap check.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_017CeWxzjTgBhSMjSKfALVqL
Keeps service.py's growth to the call sites; regenerates the flag
registry doc for the new F rows.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_017CeWxzjTgBhSMjSKfALVqL
- Unrecognised EPISODE_F_JOIN_ENABLED values fail closed (only unset or an on-value keeps F).
- Record the predecessor at mark time; settle against it, not the latest member.
- Mark joins only where the meeting authority asks a question, not on the legacy gap alone.
- Skip F for a moment too short to commit; it keeps the join unchanged.
- Stamp the arm live at episode open; closed-size metrics use that arm, not the arm at close.
- Report no-answer and error fallbacks through record_fallback (component episode_f_join).
- Count only EpisodeConflict as f_pending_conflict; other errors are f_pending_error.
- Span histogram in seconds: omi_episode_closed_span_seconds.
- Timeout from the shared JEV_CLIENT_TIMEOUT_SECONDS; notes point to f_join.settle.
- Carried speech of an F-marked member waits for its own boundary.

Co-Authored-By: Claude Haiku 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_017CeWxzjTgBhSMjSKfALVqL
@Git-on-my-level
Git-on-my-level force-pushed the claude/project-thread-fb5dp4 branch from b52a006 to e631af1 Compare November 6, 2026 04:47

@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: e631af19b6

ℹ️ 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/utils/episodes/service.py Resolved
Comment thread backend/utils/episodes/f_join.py Resolved
claude and others added 3 commits November 6, 2026 17:49
… fallback on mark failure

- A marked F candidate with another member recorded past its start keeps
  today's join without asking Jev. Splitting only the candidate would leave
  the episode's recorded end past the successor's start and fail
  recorded_window_overlap. Counted as f_later_member.
- A failed F marker (EpisodeConflict or any other error) now also reports
  through record_fallback (component episode_f_join), as the new-fallback
  rule requires, alongside the domain counters.
- Tests: a later member keeps the candidate with no model call; a failed
  marker records the shared fallback and leaves the join unchanged.

Co-Authored-By: Claude Haiku 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_017CeWxzjTgBhSMjSKfALVqL
settle checked for a later member before asking Jev, but Jev takes seconds.
A member that attached during the call was missed, so the close detached
only the candidate and the successor then overlapped the closed episode's
recorded window (recorded_window_overlap). Re-read the episode after the
answer and keep the join when it is no longer live or a member recorded
past the candidate's start. An unreadable episode keeps today's join and
records the shared fallback.

Co-Authored-By: Claude Haiku 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_017CeWxzjTgBhSMjSKfALVqL
get_episode returns None for a missing episode; treat that like an
unreadable one instead of passing None on to later_member.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

@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: beec4f095e

ℹ️ 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/utils/episodes/service.py Outdated
Comment on lines +905 to +910
short = (
not recovered
and moment.trigger != 'session_end'
and text.words < (FINALIZE_MIN_WORDS if moment.trigger == 'finalize' else MOMENT_MIN_WORDS)
)
settled = _settle_boundary(uid, episode, moment, facts, text.text, c, now, named, short=short)

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 Keep short F candidates unconsumed when carried speech commits

When an F-marked conversation has fewer than MOMENT_MIN_WORDS of its own speech but carries enough unconsumed speech from an unmarked episode member, this check skips F settlement. _select_carried_segments() then adds that member's words, making the combined moment long enough to commit, and the successful update clears the candidate's pending marker. Consequently, the candidate's speech enters the joined notes without any F decision and cannot be split later. Keep the candidate's speech and marker pending when settlement is deferred, even if carried speech independently qualifies for an update.

Useful? React with 👍 / 👎.

Comment on lines +259 to +260
start, end = policy.utc(closed.get('started_at')), policy.utc(closed.get('closed_at'))
span = (end - start).total_seconds() if start and end 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 Measure closed episode spans using their recorded end

For idle closes and F splits, closed_at is not the retained speech's recorded end: idle closure adds the silence timeout, while an F split closes at the candidate's start. database.episodes._close() separately computes recorded_end from retained members. Using closed_at here therefore includes different amounts of trailing silence by close reason and arm, biasing the new recorded-span ramp guardrail. Prefer recorded_end for this histogram, with a fallback for older episode documents.

Useful? React with 👍 / 👎.

Comment on lines +727 to +731
# was marked only where the meeting authority asked a question, and a moment too short to commit
# keeps the join unchanged.
if decision.action == policy.CONTINUE and not short:
decision = f_join.settle(
uid,

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 Add the required conversation-lifecycle change note

This introduces a new live-conversation grouping and split lifecycle, but the commit contains no note under backend/docs/listen_pusher_pipeline/changes/. Searching the pipeline documentation for episode_f_join, EPISODE_F_JOIN, and variant F also finds no corresponding documentation. Add the required note describing the new lifecycle, dark default, rollout/kill controls, and verification evidence; the feature-flag registry alone does not satisfy the backend guide's explicit same-PR change-note requirement.

AGENTS.md reference: backend/AGENTS.md:L164-L164

Useful? React with 👍 / 👎.

claude and others added 4 commits November 6, 2026 19:23
The split was planned from a snapshot read before a long Jev call and a
separate close read, so a member that attached in between could be erased
from the episode's membership, or left in the episode after its candidate
was detached, and the successor could then overlap the closed window.

close_episode now takes the membership the split was planned from and the
candidate's start. Inside the close transaction it raises EpisodeConflict
when the stored membership differs from the plan, or when a member that
stays recorded past the candidate's start. The moment recorder already
retries a conflict from a fresh read, so the join is decided again on the
new membership. Only F-marked splits pass the guard; legacy provisional
joins are unchanged.

Test: a member attaching between the split plan and the close fails the
split without the guard and is kept with it (22 F tests pass).

Co-Authored-By: Claude Haiku 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_017CeWxzjTgBhSMjSKfALVqL
Keep killed/inactive/zero-rollout opening payloads unchanged, scope retained
close windows to admitted F splits, strictly exclude zero-percent buckets,
and bound predecessor naming to eight document reads after truncation.
Recheck retained membership and processing visibility before F Jev; preserve
an explicitly pinned absent predecessor rather than selecting a later member.

Failure-Class: none
Reject processing_deferred values other than boolean false before reading predecessor text for Jev. Cover completed deferred rows and malformed values with no-provider regressions.

Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
F join predecessor naming: read-only, capped at 8 distinct person ids

Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
@Git-on-my-level
Git-on-my-level merged commit 34125cc into main Nov 6, 2026
60 checks passed
@Git-on-my-level
Git-on-my-level deleted the claude/project-thread-fb5dp4 branch November 6, 2026 22:16
Git-on-my-level added a commit that referenced this pull request Nov 7, 2026
<!-- claude-projects-attribution: {"github_login":"Git-on-my-level"} -->
_Requested by **David** · [project
thread](https://claude.ai/code/project/chan_01DkCywHd8HiN61t59mu7kXF?thread=cmsg_01DkCywHd8HiN61t59mu7kXFJgw6sqNwiEHdyUMJyStka4)_

## What changed and why

Variant F decided only live joins. Synced (WAL) conversations and late
live batches joined the recorded-time owner by time alone, so F never
saw them. Since streaming was retired on 11-04, most conversations
arrive through sync intake, so at the 5% ramp F saw almost no decisions.

A sync or late conversation whose join to an admitted live owner is
ambiguous (a 2 to 30 minute gap after the owner's last speech) now asks
F with its full transcript before it is placed:

- **Moved on:** the owner closes where the conversation begins
(`moved_on`), and the conversation opens its own occasion. The split
uses the same member guard as the live path.
- **Anything else keeps today's join:** outside the cohort or killed
(checked before any owner read), too little speech, a short gap, a
conversation already placed, a member that attached meanwhile, or any
error. Errors report through the shared `episode_f_join` fallback.

Two guards from review:

- **Privacy:** every candidate and its predecessor pass the same
predicate (`f_join.may_feed_llm`: locked, discarded, deleted, deferred,
local-only or held conversations, another owner's conversation, any
missing required field, and private cloud sync consent that is not an
explicit `true` on the row). The candidate is checked on intake before
any name lookup. The last reads before the Jev question are, in order:
the candidate's stored document, then the user's current private cloud
sync toggle (`users/{uid}`), which fails closed when the document or
field is missing. A lock, deletion, discard or consent change in between
keeps today's join.
- **Reads:** the window query for F reads at most 2 conversations and
keeps control placement when full. The candidate is named only over the
spec's first 8,000 characters of speech and at most 2 voices, and the
predecessor names at most 2 voices. A sync decision is capped at 24
document reads. Measured on this head: 12 on continue, none and timeout
paths in the default configuration and 13 in the optimization-off and
owner-reuse-off configurations (the non-close assertion is 13 pending
lead2's ruling on the bound), and 21-24 on the close path. One Jev call
across all placement retries.

Admission runs before the owner lookup, so users outside the cohort add
no candidate query on sync attach.

The flag, thresholds and Jev lane are unchanged from #24730
(`episode_f_join`, `MOVED_ON_THRESHOLD` = 0.2).

Known gap: a late attach through `_attach_once` (not the synced intake)
still skips F. Late live batches go to the sync intake, so they are
covered. The late `_attach_once` path has no transcript, and no moments
follow it, so there is nothing to ask about.

Line-Count-Exception: backend/utils/episodes/service.py | 2037 -> 2217 |
F for synced and late joins; the F logic lives in
utils/episodes/f_join.py

## Product invariants affected

none

## How it was verified

Repository `BasedHardware/omi`, branch `claude/project-thread-fb5dp4` on
`origin/main` (head `f74c0d34b3`: `a5bed255b9`, plus the row-level
consent and ordering fix, plus the user-level consent read). Backend
venv (Python 3.11), unit layer (hermetic, StrictFirestore fakes):

- `tests/unit/test_episode_f_join.py`, `test_episode_f_join_guards.py`,
`test_episode_attach_cost.py`, `test_episode_attach_review.py`,
`test_episode_live_integrity.py`, `test_episode_finalize_owed.py`,
`test_late_audio_recorded_time.py`,
`test_people_generation_inventory.py` → 368 passed.
`test_episode_f_join.py` alone → 107 passed.
- The eight new regression tests (no consent, predecessor without
consent, locked, deleted or consent-off during the predecessor reads)
fail on `a5bed255` and pass here.
- The user-level consent tests (missing user document, missing field,
off, and off while the predecessor is read) fail on the previous code
and pass here.
- The episode and inventory set (above, with the new tests): 372 passed.
- Wide episode/sync set (44 files that import the episodes, timeline or
sync-attach modules): 112 failures and errors, identical to the same run
on untouched `origin/main` (`test_sync_v2.py`,
`test_sync_reprocess_coalesce.py`, two wave2 tests fail on main too). No
new failures.
- `scripts/backend-python-format --check` on the three changed files:
clean.
- `pyright utils/episodes/service.py utils/episodes/f_join.py`: 0
errors. The warnings are pre-existing partially-unknown types outside
the changed lines.
- `check_product_file_line_count_ratchet.py` against `origin/main`:
passes with the exception above.

Not run here: `make preflight`, the full backend unit CI, the emulator
suites, and a live rollout. CI on this PR covers the first two.

## Tests

- Synced path: each excluded class (locked, discarded, deleted,
deferred, processing-deferred, local-pending, client-processing,
local-only, held, another owner, failed status, unknown protection
level, private cloud sync off) never reaches Jev, and today's join
stands (a discarded or deleted conversation is refused by placement
itself, as before).
- Consent: a candidate with the consent field missing or false is never
named or asked, and a predecessor without consent is never sent to Jev.
- Ordering: a candidate that becomes locked, deleted or consent-off
during the predecessor and name reads never reaches Jev.
- Live path: the same excluded classes never reach Jev at settle, and a
candidate whose document is missing fails closed.
- Reads: a 40-voice candidate names at most 8 voices and only its first
8,000 characters; `candidate_head` keeps the spec head and drops names
beyond the limit.
- Earlier: moved-on opens its own occasion; same-occasion stays one
episode; killed, outside-cohort, short speech, short gap and later
member each keep today's join; a failing decision keeps the join and
reports the fallback; a split refused by the member guard keeps the
join; an already placed conversation is never asked about again.
- Existing cost and live-integrity guards still pass: unchanged attaches
make no owner or candidate reads.

## UI evidence

UI-Evidence: none -- backend only; no product UI changes.

Failure-Class: none

🤖 Generated with [Claude Code](https://claude.com/claude-code)
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.

2 participants