Repository navigation
perf(episodes): compose from notes with bounded transcript excerpts - #25075
Git-on-my-level wants to merge 17 commits into
Conversation
…ew surface" This reverts commit 1e50925.
|
Preview deployment for your docs. Learn more about Mintlify Previews.
💡 Tip: Enable Automations to automatically generate PRs for you. |
Codex Review Summary: ✅ CompletedThis 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. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: fa02849547
ℹ️ 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".
| episode = result.data; | ||
| _mergeOpened(episode); | ||
| if (episode.live || !episode.composeDeferred) break; |
There was a problem hiding this comment.
Reconcile opened snapshots with subsequent episode refreshes
When a non-deferred episode is opened before composition finishes, _readOpened caches the unfinished response and immediately stops polling. EpisodePage.build now prefers this _openedEpisodes snapshot over homeEpisodes, but neither _readHome nor episodeFor updates that snapshot. Consequently, even a successful Home refresh containing the finished notes cannot update the open page; it continues showing the unfinished version until reopened or explicitly invalidated. Reconcile the opened cache when newer episode data arrives, or avoid letting it unconditionally override refreshed data.
Useful? React with 👍 / 👎.
| 'compose_deferred_at': None, | ||
| } | ||
|
|
||
| written = _write(uid, episode_id, c, finish) |
There was a problem hiding this comment.
Guard single-member writes against changed membership
If a member is discarded or moved after _members reads it but before this write, the new single-member shortcut can restore that member's title, lede and follow-ups onto the updated episode. _write rereads the latest state/version and retries conflicts, but this call supplies no guard against the membership change; the database merge only clears aggregate notes when a discard is newly introduced by that update, not when the member is already discarded. Unlike the paid path's finish_guard, this path can therefore overwrite the cleared or newer notes with content from a removed member. Validate the retained membership and evidence before committing, including on the fallback write.
Useful? React with 👍 / 👎.
|
|
||
| def schedule_opened_compose(uid: str, episode: dict[str, Any] | None) -> bool: | ||
| """The episode page was opened: a deferred late episode composes now, at most once per window.""" | ||
| from utils.episodes import composer |
There was a problem hiding this comment.
Move the new function-local import to module scope
The new helper imports composer inside its function body, contrary to the explicit rule in backend/AGENTS.md: “All imports at module top level — never inside functions.” Move this import to module scope, restructuring the dependency if necessary to preserve the documented import hierarchy. The newly added function-local imports in the backend tests should follow the same rule.
AGENTS.md reference: backend/AGENTS.md:L166-L174
Useful? React with 👍 / 👎.
| def _curated(conversation: Any) -> bool: | ||
| return any(bool(_field(conversation, name)) for name in _CURATED_FIELDS) |
There was a problem hiding this comment.
Preserve explicit keep authority through L1 admission
For a short conversation explicitly restored or kept by its owner, this exemption cannot see sync_relevance_user_kept: extract_memories receives a Conversation, whose schema declares neither that field nor folder_user_set, and deserialize_conversation drops those unknown fields. The processing path carries user_kept separately and writes it into the persistence payload without setting it on the conversation passed to extraction. Consequently, a kept conversation with fewer than 30 owner words and no other curation marker is silently skipped despite the intended curated-row exemption. Carry the keep authority into the typed extraction input or pass it explicitly to admission, and cover the actual deserialization/reprocess path in the regression test.
Useful? React with 👍 / 👎.
| fd = os.open(path, os.O_WRONLY | os.O_CREAT | os.O_TRUNC, 0o600) | ||
| with os.fdopen(fd, 'w', encoding='utf-8') as handle: | ||
| handle.write(text) |
There was a problem hiding this comment.
Enforce private permissions when overwriting an existing report
When --out names an existing file, the 0o600 argument does not change its permissions: os.open applies that mode only when creating a file. An existing report with mode 0644 therefore remains readable by other local users after being overwritten with private conversation notes, despite the script reporting that it wrote a mode-0600 file. This is reproducible by calling _write_private on an existing 0644 file. Enforce restrictive permissions on the opened descriptor before writing, or refuse to overwrite an existing destination.
Useful? React with 👍 / 👎.
## What/why L8a: preserve successful notes/L1 work across unrelated deploys and skip L1 for deterministic noise or fewer than 30 owner words. Unknown attribution uses the whole transcript as an upper bound; curated/imported content retains extraction. Stack order: L8a (this PR) → L8b #25065 → L9 #25075. Base main; L8a has no dependency. Normal merges only. Supersedes #25046. ## Flags, ramp and rollback `EPISODE_COMPOSER_REUSE` is default ON (unset=on). Off restores source-key writes and L1 extraction. Both directions accept compatible successful stable and pre-deploy keys; unchanged eligible work does not regenerate on deploy/rollback/toggles. Model routing changes and installed pydantic/langchain-core version changes invalidate keys. Installed versions are snapshotted once at import; historical aliases require their recorded locks (pydantic 2.11.10, langchain-core 1.3.3). A future dependency bump intentionally costs one successful notes recomputation and one admitted L1 recomputation per unchanged effective input on next processing, then reuse resumes. The population is bounded to work actually reprocessed; no proactive backfill. Existing provider retries and concurrent processing can add calls before success is persisted. No spend estimate is claimed. L8b and L9 have independent switches. Normal gates, then watch notes/L1 miss/skip ratios, checkpoint errors, memory yield and processing failures. Refactor-lead owns expansion/rollback. No measured margin claim. Rollback: `EPISODE_COMPOSER_REUSE=off`, or revert this PR; compatibility reads remain enabled during flag rollback so rollback does not re-buy stored work. ## Product invariants INV-MEM-4: preserves canonical promotion authority. No new memory writer; admission only avoids extraction, with successful checkpoint validation unchanged. INV-TASK-2: preserves capture suggestion authority, no task creation changes. ## Dispositions - Cost P1 / tests-merge P1-4: compatible pre-deploy source aliases and cross-mode reads prevent toggle-driven reciprocal invalidation. Exact effective inputs, content revision and successful output validation remain required. - Luna FIX-FIRST at c704ac9: installed dependency versions now participate in stable keys and gate every historical alias. Tests change either dependency independently, reject all historical aliases at a mismatch in both flag modes, preserve locked-version aliases, and verify one notes recomputation followed by reuse across flag flips. Metadata is never queried per call. - Correctness P2-7: independent model-routing digest invalidates both stable keys and historical aliases. - Tests-merge P0-1: based on current main; separate owned flag-budget entry and live name count. Each stack member merges current main normally before publication. - Split correction: the L1-dependent Hermetic E2E and Parakeet stack fixtures belong here. Their speech now clears the 30-word floor, preserving the real memory and exactly-once assertions. Correction 8cf55aa was carried at earlier head c704ac9 with normal main merges. Full Hermetic E2E, Listen Pusher Stack Gauntlet and the isolated lifecycle runner pass locally; assertions and admission thresholds remain intact. David approved one corrective full-hook push after the initial split publication exposed these fixture omissions. - L8b findings stay in #25065; notes-first findings stay in L9. No source PR is closed or merged. ## Tests For the dependency correction: all 13 focused backend files pass (47 dedupe tests, including 23 new dependency cases) through file-isolated backend/test.sh (3600s per-file budget); make preflight passes all 44 checks. At earlier head c704ac9, full Hermetic Backend E2E passed (202 passed, 3 existing skips, 2 existing xfails), and all three formerly failing CI checks passed; the new head will run CI again. The fixture correction also passes the full Listen Pusher Stack Gauntlet and 13 emulator contention tests, plus the separately isolated lifecycle runner (31 passed, 3 existing xfails). Regression tests cover pre-deploy checkpoints through on/off/on/off, changed model route, exact changed inputs, invalid output, admission and flag budget. Line-Count-Exception: backend/utils/conversations/process_conversation.py | 3394 -> 3398 | Four-line admission at the existing canonical memory-extraction boundary; extraction authority stays in its existing owner. UI-Evidence: none -- backend only Failure-Class: none Non-test diff versus main merge base: +359 / -23 (382 changed). Own stack delta: +359 / -23 (382 changed), excluding tests and render evidence.
…en (#25065) ## What/why L8b keeps paid composer results, maps eligible single-member notes without another call, labels compose triggers, and composes late deferred episodes on first open. It preserves paid notes while a newly joined member is processing and retains the guarantee that late members eventually appear in episode notes. L8a #25073 is merged into main as 7ec9a04. Under lead2 1c606e, this branch merges origin/main without rebasing and preserves main’s L8a dependency-version fencing alongside L8b. L9 #25075 remains separate. No PR is merged or closed by this work. ## Flags and defaults - `EPISODE_COMPOSER_THRIFT`: default ON, unset=on. Controls keep-paid/repair, single-member mapping and late deferral/read trigger. Off restores paid single-member composition, discard/retry and finalize scheduling; detail reads schedule no compose. Durable deferrals still drain through ordinary recovery. - Dependency `EPISODE_COMPOSER_REUSE`: independently default ON; its deploy/rollback compatibility preserves successful notes/L1 work. Thrift rollback never changes reuse keys or L1 admission. - L9's `EPISODE_COMPOSER_NOTES_FIRST` is absent from this PR's final tree and stays default OFF in its separate PR until David's side-by-side verdict. Numeric late age/grace settings remain tuning. Late age means episode recorded-start age (48h), not individual member upload age. Read recovery exits after seven days. Notes gain an additive bounded gist in their existing call; older successful notes remain eligible without buying gists in a regeneration wave. ## Ramp L8b may serve after normal gates. Refactor-lead watches failures/conflicts, paid logical calls/repairs, input/output tokens, waiting-member retention, deferred/open/grace completion and notes freshness. Roll back on a regression. L9 stays OFF until David compares content and cumulative billed input/output, retries and failures on the same episodes; no paid side-by-side or deployment is run here. No variable-margin attainment claim. ## Product invariants INV-MEM-4: canonical memory promotion stays the authority; the L8a dependency only avoids extraction. INV-TASK-2: episode follow-ups show existing open actions and create no tasks. INV-UI-1 / INV-UI-3: existing mobile primitives and styling retained. Visibility fences discard a paid result if an original member is hidden/removed, including during a waiting-member race. Ownership tokens fence stale paid writes and lease release. ## Dispositions - Tests/merge P0-1: normal main merge, preserved HOME_EMPTY_OUTPUT_NOISE, exact live flag-budget count. Separate helper entries for reuse and thrift. - Tests/merge P0-2: removal is checked against retained episode ids and original-member visibility, not the empty waiting-member result. A present processing member keeps paid output pending; regression asserts one paid call and later waiting without re-buy. - Cost P1 lease: size for both 90s provider attempts plus retry headroom for every permitted turn and repair, plus final-write margin. Refuse a turn without remaining headroom; fence completion and release by claim token. Two-replica repair regression crosses 240s. L9 extends/tests this bound for tool turns. - Correctness P1-1: shortcut fingerprint includes complete structured notes, action completion, cited segment ids/end times and recorded span; member-final notes-only changes reach the shortcut. - Correctness P1-2: shortcut requires a readable lede or points; title-only and previously stamped empty bodies fall through to paid composition and later notes can refresh. - Correctness P1-3 / tests P1-5: schedule_opened requires THRIFT on and a durable deferral. Ordinary processing pages cause one detail read, without foreground paid work or extra polling. - Tests P1-1/P1-2: close and member-final regressions cover re-deferral after a new member; deferral write faults emit fallback telemetry and fall through to normal scheduling. - Tests P1-3 / siblings: supersedes #25062. #25053's attach-time guarantee is preserved through the same two attach funnels, under THRIFT, with durable deferral plus first-open/grace recovery even if finalization is memoized. Keep #25053 open for lead reconciliation; do not merge both implementations blindly. #25022 lands second and must resolve its page/provider overlap by retaining this small refresh contract. No page redesign or task affordance is added here. - Waiting first open: persist the opened deferral epoch. A member completing after the bounded client poll schedules normally on any replica and bypasses the seven-day unopened hold; completing compose clears the epoch. A read that finds waiting members releases its local read throttle so a later bounded poll can finish. - Client polling: server `compose_deferred` signal; one initial read plus at most eight 5s polls, each read <=4s and total deadline 45s. Concurrent opens coalesce; page exit/account change/disposal fence results and stop further reads. Home retains its filtered membership; opened cache is invalidated with Home/delete visibility. - Correctness P2-2/P2-11/P2-12: kept-pending output waits for the settle timer; trigger stamping clears deferral; unused call label removed. - Correctness P2-4/P2-5/P2-9: detail cache is separate from Home, invalidated on delete, bounded and refreshed on open; only explicit deferrals poll. Cache eviction remains insertion order with a cap of 16, acceptable bounded storage rather than an LRU promise. - Tests P2: unknown duration cannot justify short sectionless output; positive/finite grace settings and single-member window-refusal retry are tested. Prompt digest guard remains live. Gist is an additive prompt/schema capability, not an extra paid call or rollback gate (correctness P2-6). - Metrics: reported billed input/output is counted on every reply, including terminal malformed/repair outcomes; logical paid calls, repairs and failures are labeled. Hidden SDK retry attempts/billing remain an explicit usage-ledger follow-up. Update dashboard/recording-rule aggregations for `trigger`; refresh the measured production inventory after these families serve. The inventory is not fabricated from unserved code. L9 enablement requires the authoritative ledger, not these counters alone. - Remaining L9 tool/failure findings are disposed in its PR. No test is skipped or weakened. ## Tests At earlier head d7a1112, merge-main validation passed: backend/test.sh passed 1,398 tests across 43 files, covering every episode/composer suite, test_flag_budget.py and the seven L8a unit suites (dedupe, dependency upgrades and aliases, prompt versions, L1 admission, usage context, short-clip rollout and owner-memory admission). Tests use file isolation and BACKEND_UNIT_FILE_BUDGET_SECONDS=3600. backend/scripts/typecheck.sh reports zero errors. make preflight passes all 75 selected checks on the clean merge commit. Regenerated with owning scripts: scripts/render_feature_flag_registry.py, backend/scripts/generate_firestore_indexes.py --write, backend/scripts/openapi_runner.sh with export_openapi.py --surface app-client --write, generate_dart_models.py --all and generate_swift_openapi_types.py. All outputs reproduce the merged tree. At earlier head 78a6c22, the full hook and the original backend/Flutter/render verification passed. At earlier head bb6907c, the copyWith regression, 108 Flutter episode tests, 138 spine tests, backend typing, preflight and the full hook passed; CI was terminal green. Those are historical receipts, not validation claims for this merge. ## UI-Evidence Real Flutter widget renders from app/test/widgets/episode_composed_render_test.dart, fictional fixtures, light/dark composed pages and lede-only detail result. Client layout is unchanged by the split; refresh behavior is exercised by provider/widget regressions.    UI-Evidence: .agent-artifacts/ui-evidence/composer-thrift/ (tracked PNGs and evidence.json). Failure-Class: none ## Rollback `EPISODE_COMPOSER_THRIFT=off` independently restores finalize composition; existing deferrals drain through ordinary read recovery. `EPISODE_COMPOSER_REUSE=off` restores source-key writes/L1 admission while compatibility reads avoid buying stored work. L9's separate switch restores full-transcript input. No data migration. Salvage: restored composed-episode re-deferral with an explicit client signal; completed the stamp-fault and client lifetime gaps. Dropped only redundant late-compose and L9-percentage switches, replaced by the independent stack controls. No incomplete salvage feature remains. Supersedes #25039 #25046 #25048 #25057 #25062 (L9 source #25039 moves to the separate L9 PR; #25046 moves to #25073). Line-Count-Exception: backend/utils/episodes/composer.py | 1105 -> 1734 | Preserve the existing canonical lifecycle, CAS, visibility and lease authority; scoped additions delegate admission/attach signaling to small helpers. Line-Count-Exception: backend/utils/episodes/service.py | 2222 -> 2223 | Preserve the existing canonical lifecycle, CAS, visibility and lease authority; scoped additions delegate admission/attach signaling to small helpers. Luna FIX-FIRST disposition (earlier head 78a6c22): fixed the stale single-member write and the same empty-result clearing race with an atomic episode/member revision fence; newer member or episode snapshots return superseded without retrying the stale payload. Both the normal write and window-only fallback retain the guard. Regression tests exercise real episode persistence with StrictFirestore. At that earlier head, other pre-read writes (paid compose gap, provisional deferral title, scheduling stamps) were explicitly listed in backend/docs/listen_pusher_pipeline/changes/2026-11-10-composer-snapshot-fence.md; the paid gap is closed by the disposition below. Validation at that earlier head: all 36 episode suites passed through backend/test.sh; the final focused rerun passes 33 single-member tests and 126 composer tests; make preflight passes all 77 selected checks; the full hook and CI results are reported separately. Luna #25075 review disposition (earlier head fa02849, L8b-owned schema): added an optional composeDeferred override to Episode.copyWith. Omitted overrides preserve the current value; an explicit false clears a deferred episode. app/test/unit/episode_schema_test.dart covers both behaviors. Validation at earlier head bb6907c: app/test.sh passes all 108 selected episode tests plus its 138 spine tests; backend scripts/typecheck.sh passes with zero errors; make preflight passes all 77 selected checks. The stale single-member/empty-result transactional fence and regression coverage are included at that earlier head and preserved in the merge. L8a and L9 branches are untouched. Merge-main disposition (lead2 1c606e): merged origin/main at 9ca056a, including L8a merge 7ec9a04, without rebasing. The sole conflict was adjacent appended tests in backend/tests/unit/test_conversation_llm_input_dedupe.py: retained main’s dependency-version tests verbatim and L8b’s additive-gist checkpoint test. Main’s installed-dependency compatibility guard remains in place; the L8b notes-2/gist aliases remain inside that guard. No new scope or L9 branch changes. David authorized one full-hook fast-forward push for this merge; the PR remains unmerged. Luna FIX-FIRST disposition (earlier head d7a1112): paid multi-member completion and its window-only fallback now pass canonical member revisions captured at the final visibility reads to the existing episode/member transaction fence. Any subsequent member revision change or deletion refuses publication; the episode CAS guard also rejects original-member removal. Hidden originals refuse unconditionally, including a hide during the final visibility pass after the evidence fingerprint check. Refused paid notes are discarded, never published or stamped current, and the lease is released under its ownership token. Existing superseded scheduling provides bounded recomposition: background settling buys one call before the quiet timer; settling rollback remains capped at three attempts. No L8a or L9 branch changes, new flags, or paid retry loop. The snapshot-fence change doc now describes the closed paid-write gap. At earlier head ef71cfa, validation: backend/test.sh passed every episode/composer suite plus flag-budget and the seven L8a suites: 1,413 tests across 44 files (43 files passed initially; the flag-budget file passed after the merge-count reconciliation). The 15 new strict-transaction regressions cover hard/soft deletion, discard, merge-away, revision changes, unchanged publication, both paid-write variants, hiding during the final visibility pass, and bounded recompose scheduling with settling on/off. backend/scripts/typecheck.sh passed with zero errors. make preflight passed all 75 selected checks on the clean commit. No live account data or production calls were used. Main reconciliation at earlier head ef71cfa: merged origin/main at 4e9c704 without rebasing. The sole conflicted file was backend/tests/unit/test_flag_budget.py; retained main's projection-debt entry and L8b's thrift entry, with the shared owner checks. Reconciled the declared count to the actual merged inventory (269). Regenerated feature-flag-registry.md and firestore.indexes.json with their owning scripts. No OpenAPI/wire sources changed in this fix or main reconciliation. The PR remains unmerged. Luna FIX-FIRST disposition (earlier head ef71cfa): removed the visibility loop's revision overwrite. The post-call _members fingerprint snapshot supplies the only expected revisions. The visibility pass now compares against that unchanged map; a revision difference, a missing snapshot entry, or a missing/hidden/discarded member refuses publication before the notes write. Both normal and window-only publishing transactions continue to validate the same snapshot map. The unsafe paid result is discarded, its lease is released under the existing token guard, and superseded uses the existing bounded recompose scheduling. No new retry path, scheduler, flag, or unrelated production change. Current validation: backend/test.sh passed 1,416 tests across 44 files (all episode/composer suites, flag budget, and the seven L8a suites). The three added cases failed against the earlier implementation and pass with this fix: visible notes changing between the fingerprint snapshot and visibility reread never publish, and recompose remains bounded with settling on/off. Existing unchanged-member and fallback transaction tests still pass. backend/scripts/typecheck.sh passed with zero errors. make preflight passed all 75 selected checks on the clean commit. Full hook and CI results are reported separately. The snapshot-fence change doc describes the immutable snapshot revision rule. GitHub reported CONFLICTING/DIRTY before this work, so origin/main at 6d45be4 was merged without rebasing. The sole conflict was the flag-budget count: main declares 268 entries, while this branch includes the thrift entry and correctly declares 269; retained 269, verified against the actual entries and test_flag_budget.py. The merge has no other tree changes. No generated sources or registry inputs changed. L8a/L9 branches are untouched; this PR remains unmerged.
# Conflicts: # backend/config/flag_budget.json # backend/tests/unit/test_flag_budget.py
|
When this PR returns to the merge queue, please update its branch against current |
|
Closing under the approved stale PR disposition. This conflicting composition branch has no demonstrated incremental savings with acceptable output quality on current main. Reopen if the Episodes owner can show both. |
|
Hey @Git-on-my-level 👋 Thank you so much for taking the time to contribute to Omi! We truly appreciate you putting in the effort to submit this pull request. After careful review, we've decided not to merge this particular PR. Please don't take this personally — we genuinely try to merge as many contributions as possible, but sometimes we have to make tough calls based on:
Before your next PR, please skim:
If this was declined for direction or taste, maintainers should cite an invariant ID or open a proposed one — ask if that citation is missing. Your contribution is still valuable to us, and we'd love to see you contribute again in the future! If you'd like feedback on how to improve this PR or want to discuss alternative approaches, please don't hesitate to reach out. Thank you for being part of the Omi community! |
Head: 8d6108d
Earlier head: ded1e64
What/why
L9 composes from member notes with an optional bounded transcript-excerpt tool. It follows the reuse and composer-thrift changes, while preserving full-transcript composition as the default.
L8a #25073 merged into main as 7ec9a04 and L8b #25065 as bb90438. Under lead2 1c606e, this branch merges that main snapshot without rebasing. The final diff is the L9 notes-first implementation, bounded excerpt tool, tests and registry/docs only. Supersedes #25039. The PR remains unmerged.
Flags, ramp and rollback
EPISODE_COMPOSER_NOTES_FIRSTis default OFF; missing/unknown values stay off. Independent of default-onEPISODE_COMPOSER_THRIFTandEPISODE_COMPOSER_REUSE. Each has its own registry/budget entry. L9 can run with thrift killed; thrift can serve with L9 off. Switching modes does not force recomposition of stored episodes.L8a/L8b may serve after normal gates. L9 stays OFF until David records a side-by-side content verdict on the same episodes and cumulative billed input/output, paid calls, retries and failed-compose spend do not regress versus full mode. Tool bytes alone do not establish savings: all logical input resends are bounded, while provider-attempt billing remains part of the enablement comparison. No paid comparison or deployment is run here. After approval, refactor-lead applies the recorded cohort ramp and watches those measures, error/conflict rates and notes freshness; review due 2026-12-10. No verdict means OFF; report an unexpanded gate at review. Provider-attempt billing must be joined from the authoritative usage ledger before enablement.
Rollback:
EPISODE_COMPOSER_NOTES_FIRST=offrestores full-transcript input on the next paid compose. The L8 switches remain independent. Reuse compatibility avoids a rollback re-buy wave.Product invariants
INV-MEM-4: canonical memory promotion remains unchanged. INV-TASK-2: episode follow-ups present existing actions; no task creation. Visibility retains the same retained-member boundary; excerpts expose only transcript already available to full mode. Client schema, layout and refresh behavior come unchanged from main, including L8b; #25022 remains sequenced after L8b.
Dispositions
Tests
At Earlier head cd165fc, merge validation: backend/test.sh passes all 1,442 tests across 46 isolated files, including all episode/composer suites, test_episode_composer_notes_first.py, test_flag_budget.py, the L8a reuse/admission/prompt/usage suites and notes gist. BACKEND_UNIT_FILE_BUDGET_SECONDS=3600; no bare pytest or skipped guards. app/test.sh passes all 108 selected episode tests across eight files plus its 138 spine tests. This includes the copyWith deferred override regression inherited from main. backend/scripts/typecheck.sh passes with zero errors. make preflight passed all 42 selected checks on the clean merge commit. The full hook and exact-head CI results are reported separately.
Regenerated with scripts/render_feature_flag_registry.py, backend/scripts/generate_firestore_indexes.py --write, backend/scripts/openapi_runner.sh with export_openapi.py --surface app-client --write, generate_dart_models.py --all, generate_swift_openapi_types.py and generate_ts_openapi_types.py. Flag count is computed from the owned JSON entries. OpenAPI/index/wire outputs reproduce main; only the L9 registry entry adds generated flag-doc output.
UI-Evidence
UI-Evidence: none — backend-only notes-first composition and bounded excerpts. All client code and render artifacts come unchanged from main.
Failure-Class: FC-character-budget-misses-secondary-text
Line-Count-Exception: backend/utils/episodes/composer.py | 1734 -> 2058 | Preserve the existing canonical lifecycle, visibility, CAS and lease authority; L9 adds bounded inputs under the same paid-compose owner after L8b.
Merge-main disposition (lead2 1c606e, from Earlier head fa02849): merged origin/main at bb90438 with --no-ff. Only backend/config/flag_budget.json and backend/tests/unit/test_flag_budget.py conflicted. Retained both main's SUMMARY_PROJECTION_DEBT_ENABLED and L9's EPISODE_COMPOSER_NOTES_FIRST in the shared owner assertions and regenerated the count to 270. The composer auto-merge preserves main's post-call fingerprint snapshot revisions as the only expected revisions, final visibility comparisons, publishing transaction/fallback fence, lease release and bounded scheduling exactly. Existing composer helpers other than _compose match main by AST; changes inside _compose are L9's mode selection, bounded lease/turn limit and tool loop. Main's database fence, L8a reuse helper, episode service and client schema/test match byte-for-byte. No new scope or default changes.
Luna FIX-FIRST disposition (Earlier head fa02849, copyWith composeDeferred): the fix is now inherited unchanged from merged L8b in main. Episode.copyWith accepts an optional override, explicit false clears the deferred flag, and an omitted override preserves it; the inherited Dart regression passes in this merge. No duplicate schema patch is added.
EPISODE_COMPOSER_NOTES_FIRST remains default OFF, including absent/unknown values. Existing notes-first and bounded-excerpt behavior and the recorded verdict/ramp requirement are preserved. No paid side-by-side, flag enablement or deployment was run.
Luna FIX-FIRST disposition (Earlier head cd165fc, aggregate prompt/resend budget P2): all notes fields and missing-note transcript fallbacks share the full-mode COMPOSER_MAX_TRANSCRIPT_CHARS limit (240,000 serialized characters), including system text, framing/escaping and tool schema. Member shares reserve min(512, available // (2 * member_count)) characters, then allocate proportionally; prefix truncation uses a clear marker and stable recording order. Every logical tool/history resend and the optional repair count against the same 240,000-character per-compose ceiling. The loop goes tool-free when another round would exceed the allowance; oversized history/repair is refused before invocation and uses existing bounded failure/backoff. A truncated notes prompt may use the existing full-transcript request only if strictly smaller, without tools. The off path and main's post-call privacy/revision fences are unchanged. Character bounds do not claim token or hidden SDK retry billing bounds. Default OFF and the recorded ramp remain unchanged.
Earlier head a4473ea — budget-fix validation: backend/test.sh passes 1,459 tests across 46 isolated files, including 37 notes-first tests, all episode/composer suites, test_flag_budget.py and L8a dedupe/admission/prompt/usage suites. Regressions cover 1/5/20/60 members with oversized notes or absent-note transcripts, proportional allocation and a shrinking floor, deterministic truncation/order, cumulative tool resends, refusal of oversized history and repair before a second paid call, cheaper-only full fallback, and exact off-path payload equality. backend/scripts/typecheck.sh passes with zero errors. No main merge was needed: GitHub reported MERGEABLE/CLEAN after fetching. No generated schema, flag declaration, wire or index inputs changed in this fix. Full-hook and exact-head CI results are reported separately.
The failure-class guard adds backend/tests/unit/test_episode_composer_notes_first.py to the existing prevention artifacts for FC-character-budget-misses-secondary-text: every variable-length note field and resend is charged to the advertised aggregate allowance. No class lifecycle or allowlist relaxation is made.
Follow-up disposition (lead2 b562a4; approved by refactor-lead): reapplied the verified patch from Earlier head bb3912d6e19ba7c488d116d79679fa0a56e85fc0 onto Earlier head a4473ea. No main merge: after fetching, GitHub reports MERGEABLE, not CONFLICTING. Notes-first remains OFF until David records the required verdict.
Fallback comparison: the comment “compare complete serialized requests” includes the messages, their serialized framing/escaping, and the tools actually sent. For the large truncated notes prompts covered here, the notes-first request does NOT send TRANSCRIPT_EXCERPT_TOOL. Its near-cap input makes
with_tools * 2 + COMPOSER_EXCERPT_MAX_TOTAL_CHARS > remainingtrue on the first loop turn, solast=True,tools=None, and the invocation is tool-free.invoke_modelonly binds a tool schema for a truthy tools argument. The full fallback is also tool-free. Therefore_input_chars(full) < _input_chars(messages)compares these two complete tool-free requests; including the unused schema on the notes side could incorrectly accept a larger fallback. Smaller untruncated prompts may send the schema, and every such actual tool-enabled request continues to charge it to the per-compose ceiling. The schema-free comparison is conservative even if tools could otherwise be offered. Boundary tests capture actual invocation arguments and verify tools=None, with fallback accepted at one character smaller and refused at equal or one character larger.CI fixture disposition (Earlier head a4473ea): all 37 assertions passed, but the 60-member stress fixture exceeded the unchanged 1-second CPU guard at 1.25 seconds. Fixture size now stays constant as member count grows, while an explicit assertion ensures title/action text alone exceeds the real 240,000-character cap for all 1/5/20/60-member cases. The truncation marker assertion is strengthened; no timing limit, cap, marker selection or test skip is relaxed.
Earlier head ded1e64 — follow-up validation: backend/test.sh passes all 40 focused notes-first tests with BACKEND_UNIT_FILE_BUDGET_SECONDS=3600. The reapplied source tree exactly matches Earlier head bb3912d6e19ba7c488d116d79679fa0a56e85fc0, whose 1,462 tests across 46 isolated files, zero-error typing and 43-check preflight receipts are historical evidence. That head passed all 43 clean-tree preflight checks and zero-error typing; its full-hook push completed. Its inherited notes prompt digest failure is addressed by the merge below. No paid comparison, flag enablement, deployment or PR merge is run.
Merge-main disposition (lead2 1c606e): merged origin/main at 8fa2cbd (#25108) into Earlier head ded1e64 using --no-ff, without rebasing. The merge had no conflicts or manual resolutions. Main's notes-3 version and pinned digest 5307871ec67f0f81cafbca8d9aa209dd4fdc3fe9eec9d13139156fd0706ac766, legacy notes compatibility and dedupe implementation match main exactly. L9's composer, aggregate cap/fallback comparison, stress fixture and all 40 notes-first tests match Earlier head ded1e64 exactly. No new implementation scope.
Re-ran scripts/render_feature_flag_registry.py and backend/scripts/generate_firestore_indexes.py --write after the automatic merge; both outputs were already canonical and the tree stayed clean. The focused backend/test.sh set contains the notes-first cap/fallback suite, episode composer, prompt-version guard and conversation input dedupe tests. Fresh focused validation passed 222 tests across four isolated files: 40 notes-first cap/fallback tests, 126 composer tests, six prompt-version tests and 50 conversation input-dedupe tests. The notes-3 pinned digest assertion passes. Fresh backend typing has zero errors. Clean-tree make preflight passed all 43 selected checks before the single push. The inherited digest failure must clear on exact-head CI. The unchanged stress-fixture CPU guard remains enforced; no budgets or skips are relaxed.
EPISODE_COMPOSER_NOTES_FIRST stays OFF until David. No serve/ramp work, paid comparison, deployment, PR merge or bus message from m1. One full-hook fast-forward push only, with the credential environment variables removed and BACKEND_UNIT_FILE_BUDGET_SECONDS=3600.