Skip to content

fold(backend): consolidate PRs 22025, 23063, 23334, 23370, 23464 onto the age-gate survivor branch - #24602

Merged
Git-on-my-level merged 41 commits into
mainfrom
lane/freshtitles-agegate
Nov 4, 2026
Merged

Git-on-my-level merged 41 commits into
mainfrom
lane/freshtitles-agegate

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

Fold of five open PRs onto one branch, successor to #24580 (the enrichment age-gate survivor, which merged separately at 11:59Z without these folds):

Every behavior change from each PR is preserved. Where main evolved past a stale PR base, the fold reconciles: orphan terminalization lives in conversation_processing_recovery.py (decorators, kept_row_terminal_update threading and the oversized-terminal receipt ported there); the sync-intake keep-provenance stamp applies to newly created rows while replays retain their assessed verdict and promotions keep clearing the receipt (main's newer replay/promotion contracts); capture_group joined the decision-trigger vocabulary; the sync-lineage parity fixture is re-pinned to the merged live sources with a documented expectation update; the restore tool's fixture fake accepts the canonical apply control read's explicit retry/timeout kwargs and anchors gate liveness to the real clock. Focused suites for all five areas and the survivor's enrichment age-gate tests pass locally.

#24580's changes are the base of this branch (its age-gate work is included and was merged to main separately); this PR carries only the five folds on top of current main.

Folded PRs: #22025, #23063, #23334, #23370, #23464.

Product invariants affected

  • INV-MEM-4
  • INV-MEM-1
  • INV-TASK-2

Failure-Class: none

Line-Count-Exception: backend/database/conversation_finalization_jobs.py | 3167 -> 3176 | PR 23370 fold: calendar-probe pre-read, terminal-visibility decorators and shared recover-deferred txn, net of orphan helpers moved to conversation_processing_recovery
Line-Count-Exception: backend/database/conversations.py | 4607 -> 4623 | PR 23370 fold: failed-status exclusion in is_visible_conversation and lifecycle_terminal decision stamping in claim_conversation_status
Line-Count-Exception: backend/database/firestore_index_registry.py | 2282 -> 2327 | PR 23334 fold: restore/revert scan query requirements for the stale-planner archive tool
Line-Count-Exception: backend/utils/sync/assignment.py | 1515 -> 1522 | PR 23370 fold: explicit sync-intake keep provenance stamp for newly created rows

UI-Evidence: none

View guided diff Turn on auto-fix

Git-on-my-level and others added 30 commits October 17, 2026 21:25
…read

A transient Firestore fault on the apply-control read was converted
straight into CanonicalApplyStateUnavailable (memory_system.py:64),
failing the whole apply gate for one blip. _read_snapshot now gives
store faults classified transient by transient_store_error the same
three-attempt backoff budget as the MCP OAuth refresh rotation before
failing closed; permanent faults and exhausted retries keep the
existing fail-closed behavior.

Failure-Class: none
… add emulator proof

Review feedback on the canonical apply-control transient retry:

- Each attempt now disables the SDK's own (default 300s deadline) retry and
  passes an explicit per-attempt timeout (CANONICAL_APPLY_READ_TIMEOUT_SECONDS,
  default 5s), mirroring the MCP OAuth refresh-rotation boundary that owns its
  three-attempt budget. An exhausted SDK Retry policy would raise RetryError,
  which the transient classifier does not treat as retryable, so the typed
  error must surface at this boundary directly.
- The deletion fence is re-read before the first-write provisioning path: a
  wipe that completes while the retry loop waits can no longer re-enroll a
  wiped account as a fresh generation-1 control document.
- New Firestore-emulator proof (canonical_apply_control_retry_emulator_test.py)
  wired into run-emulator-proofs.sh: fault injection at the client API layer
  proves transient recovery, exhausted fail-closed (3 bounded attempts), the
  deletion race, and that every retried read passes retry=None plus a bounded
  timeout. Hermetic fakes updated to accept the new get() kwargs.
The apply-control boundary now passes retry=None and a bounded timeout on
every document read; the shared canonical_memory_fakes._DocRef and the
WS-B _Document fake rejected those kwargs, and the resulting TypeError was
swallowed by the production except-Exception fail-closed path, failing 34
tests across five unit shards. Mirror the real SDK get() signature.
…ead kwargs

Same fix as the shared fakes for the two per-file fakes CI rounds reach:
canonical_consolidation_apply._FakeDocumentRef and the ws_j_delete_privacy
_DocRef. The apply-control read boundary passes retry=None plus a bounded
timeout on every document read; rejecting those kwargs fails closed through
the swallowed TypeError path.
…reads; one budget per control read

Review round 2 on the apply-control retry boundary:

- The post-retry deletion-fence recheck now also guards the existing-state
  branch (it previously ran only on the first-write path), so a deletion that
  starts during transient backoff cannot admit work or touch the maintenance
  registry under a running/completed wipe.
- The fence helper threads through optional retry/timeout read kwargs via an
  UNSET sentinel (other callers keep the SDK-default read), and the
  apply-control boundary passes its bounded per-attempt policy to every fence
  read, so the added safety check cannot pin a worker for the default 300 s.
- The exists-branch validates the recovered snapshot directly instead of
  re-reading the control document with a second fresh three-attempt budget;
  the create-race path likewise reads once and validates from that snapshot.
- Emulator proof: module-scope import per the backend import rule; fence stub
  accepts the new read kwargs.
… test imports

Review round 3:

- With the SDK retry disabled for the bounded fence read, a single transient
  blip on account_deletions/{uid} would fail the whole apply gate — the very
  failure mode this PR fixes. Both fence reads now run through the same
  three-attempt transient budget as the control read (one shared helper).
- Hoist the three retry tests' imports to module scope per the backend
  import rule.
…onfigured

delete_atom_keyword_doc returned False whenever the shared Typesense env was
absent or empty (lazy client construction raises, the generic except swallows
it), so _run_immediate_privacy_cleanup raised 'canonical keyword privacy
cleanup unavailable' and every explicit memory delete failed closed on
deployments that never write the keyword projection — the keyword recurrence
of FC-privacy-delete-fails-on-unprovisioned-derived-store (#15097 classified
the vector-store sibling but not this one). Classify the unconfigured state as
the trivially-confirmed desired absence before any client I/O; a configured
client that raises still fails closed, and empty uid/memory_id still returns
False.

Failure-Class: FC-privacy-delete-fails-on-unprovisioned-derived-store
…ypesense

Review repair for #23063: delete_atom_keyword_doc confirmed absence whenever
typesense_configured() was False, i.e. also when exactly one of
TYPESENSE_HOST/TYPESENSE_API_KEY was bound. A partial binding does not prove
the projection absent — backend-listen binds only TYPESENSE_HOST while
backend-sync and memory-maintenance-job hold both against the same cluster —
so a rollout losing one variable would acknowledge the privacy deletion with
plaintext keyword documents still stored. Confirm absence only when neither
binding is present (Cloud Run backend, desktop), let partial bindings fail
closed through the client call, and instrument the fail-open with
record_fallback(reason=unconfigured, outcome=recovered) per the fallback
telemetry contract.
Dry-run-first operator tool re-applying incident-archived memory_items as
short_term-visible decisions through the canonical apply ledger
(apply_long_term_patch_firestore) with the remediation=stale-planner-2026-10-22
audit marker, reversible via --revert. Per-user COLLECTION-scope scan with
read budget, keyset cursor, legal-hold/deletion-gate/deleted-user exclusions,
and payload-free count-only output. Registers the two memory_items query
drivers and regenerates the composite-index manifest. Prod writes remain
gated on the plan's explicit GO.

Co-Authored-By: GLM-5.3 <[email protected]>
Close decision gaps in dead-letter, orphan, BYOK, imports, external text, sync promotion, merge rollback, and legacy restore paths. Preserve calendar, photo, wake-word, rule-keep, and tombstone protections; keep mandatory decisions through terminal size guards.

Failure-Class: FC-contentless-recovery-surfaced-visible
Keep the large conversation modules below their existing line budgets by moving snapshot status storage, deferred retry storage, pure terminal payload serialization, and bounded metric vocabulary to their owning modules. Migrate callers and behavioral/static coverage together.

Failure-Class: FC-contentless-recovery-surfaced-visible
Cover the direct batch fixture writer with an explicit fixture-seed policy and bounded telemetry vocabulary. Preserve the local/offline account fence and extract the payload builder to keep its owner below the existing line budget.

Failure-Class: FC-contentless-recovery-surfaced-visible
Invalidate people-stats and refresh search after terminal discards or document-ceiling failures commit. Isolate observer failures and publish no effects on aborted transactions. Document terminal relevance and size behavior in the lifecycle owner guide.

Failure-Class: FC-contentless-recovery-surfaced-visible
Narrow prior decision before subscripting, return str-keyed entries from
the preserve path, and expose a public accessor for the post-write search
index convergence instead of touching the private name.
…le dev planner, dry-run default) into fold survivor
- finalization jobs: thread calendar_probe through the shared dead-letter helper
- sync intake: stamp explicit keep provenance only on newly created rows;
  replays retain their assessed verdict and promotions keep clearing the
  receipt (main's replay/promotion contracts)
- decision triggers: accept main's capture_group trigger
- parity fixture: re-pin frozen sources to the merged live files with a
  documented expectation update
- folded PR tests: point at the recovery module that now owns orphan
  completion, match current helper arities, RULES_VERSION, and the
  real-clock fence liveness window
@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-04T17:20:58.324759Z 7982e9a 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.

37 issues found and verified against the latest diff

Confidence score: 2/5

  • Account deletion can abort the wipe when the Typesense client is unconfigured because purge_user_atom_keyword_index raises on failure. Make the account-deletion path tolerate an unavailable index.
  • The --apply and --revert paths in restore_stale_planner_archives.py crash before remediation because os is not imported. Add the import so those commands can run.
  • The archive classifier in restore_stale_planner_archives.py can reopen legitimate route="review" rows. Require the retry-exhausted rationale for both supported incident routes.
  • Control creation in memory_system.py can race with deletion: the fence check is not atomic with creation, and the lost-create path skips a follow-up check. Guard creation against the deletion fence on both paths.
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/conversation_relevance_labels.py">

<violation number="1" location="backend/utils/conversation_relevance_labels.py:69">
P2: `TERMINAL_METRIC_REASONS` omits `repeated_asr_outro`, although terminal transcript assessment emits it for repeated ASR outros. These discarded terminal decisions are therefore recorded with `reason='other'`, losing the metric attribution; add this reason to the allowlist.</violation>
</file>

<file name="backend/tests/unit/test_conversation_finalization_jobs.py">

<violation number="1" location="backend/tests/unit/test_conversation_finalization_jobs.py:1777">
P2: This assertion no longer verifies `discarded=False` or the complete relevance decision, so an invalid terminal patch can pass. Assert the full decision payload, including `verdict`, `decided_by`, `trigger`, and `rules_version`.</violation>
</file>

<file name="backend/utils/conversations/terminal_relevance.py">

<violation number="1" location="backend/utils/conversations/terminal_relevance.py:153">
P2: This wake-word guard can never fire because the matcher requires segment IDs, but `_has_wake_word` removes them before matching. Pass segment-shaped inputs with stable IDs (and timing when cross-segment matching is needed), or use a text-only matcher so terminal assessment actually skips wake-word captures.</violation>
</file>

<file name="backend/tests/unit/test_recovery_rule_skip.py">

<violation number="1" location="backend/tests/unit/test_recovery_rule_skip.py:244">
P2: This test leaves the `external_integration` terminal path uncovered, so a regression that omits its policy decision would pass the suite. Parameterize `source` over both `workflow` and `external_integration`.</violation>
</file>

<file name="backend/tests/unit/test_byok_abandonment_reconciliation.py">

<violation number="1" location="backend/tests/unit/test_byok_abandonment_reconciliation.py:392">
P2: These replacements weaken both path-specific contracts to checking only the decision reason, so regressions can remove `discarded` or other relevance fields without failing the tests. Keep exact payload assertions, including the new metadata, for the existing-structured and document-limit cases.</violation>
</file>

<file name="backend/tests/unit/test_conversation_terminal_effects.py">

<violation number="1" location="backend/tests/unit/test_conversation_terminal_effects.py:33">
P2: This fake transaction never executes the production transaction callback, so the test passes even if any terminal path stops staging visibility refreshes. Invoke each callback with representative transaction data, or separate this decorator test from real-entrypoint tests that use transaction fixtures.</violation>
</file>

<file name="backend/tests/unit/test_people_stats_cache.py">

<violation number="1" location="backend/tests/unit/test_people_stats_cache.py:712">
P2: This test no longer exercises `transition_conversation_status`, even though that legacy path remains callable and is used by the replay tool. Restore the direct-helper call here, or add a separate test for it while keeping the CAS coverage in its own test, so regressions in both invalidation paths are detected.</violation>
</file>

<file name="backend/tests/unit/test_terminal_relevance.py">

<violation number="1" location="backend/tests/unit/test_terminal_relevance.py:319">
P2: This repository-wide AST scan is an unmarked fast unit test, contrary to the backend test contract for exact-set guardrails. Mark it `slow` and add it to `tests/slow_guardrail_manifest.txt` so the scan does not inflate or destabilize the normal unit lane.</violation>
</file>

<file name="backend/scripts/canonical_apply_control_retry_emulator_test.py">

<violation number="1" location="backend/scripts/canonical_apply_control_retry_emulator_test.py:211">
P2: This proof does not exercise a deletion starting during the retry window: the injected wipe happens only when the post-retry fence re-check begins, after the control read has already returned. Inject the wipe from the first failed `batch_get_documents` callback (or otherwise before the retry backoff) so the test proves the fence re-check closes the actual interleaving it describes.</violation>
</file>

<file name="backend/tests/unit/test_restore_stale_planner_archives.py">

<violation number="1" location="backend/tests/unit/test_restore_stale_planner_archives.py:372">
P2: These apply/revert tests bypass the CLI validation that enforces the exact remediation marker, positive write budget, and operator-tier credentials, so a regression in the safety gate would leave the suite green. Add focused `main()` tests for missing, incorrect, and correct marker/budget combinations.</violation>
</file>

<file name="backend/docs/released-memory-change-projection.md">

<violation number="1" location="backend/docs/released-memory-change-projection.md:122">
P2: This run instruction does not actually run the new retry test through `backend/test.sh`: the runner’s default marker excludes `integration` tests, so it can report success without executing either retry case. Include `BACKEND_PYTEST_MARK_EXPR=integration` and an explicit `BACKEND_UNIT_TEST_FILE_LIST` command, as the list-projection emulator instructions do.</violation>
</file>

<file name="backend/database/conversation_merge_jobs.py">

<violation number="1" location="backend/database/conversation_merge_jobs.py:268">
P2: This stamps metrics inside a retryable Firestore transaction, so contention can count one recovered source multiple times. Compute the decision in the transaction, but emit its metric only after the transaction commits successfully.</violation>
</file>

<file name=".github/failure-classes/FC-derived-cache-commit-replay.json">

<violation number="1" location=".github/failure-classes/FC-derived-cache-commit-replay.json:3">
P2: This new failure-class entry is not declared correctly in the PR metadata: the supplied PR body has no `Failure-Class:` directive, and the validator sees two added definitions, so `Failure-Class: new` cannot pass either. Add the required declaration only after keeping one new definition in this PR, or split the registry additions into separate PRs.</violation>
</file>

<file name="backend/database/conversations.py">

<violation number="1" location="backend/database/conversations.py:2833">
P2: This records the relevance metric inside a retriable Firestore transaction. Contention or an aborted transaction can execute `stamp_terminal_decision` multiple times before any write commits, inflating decision counters; compute the decision inside the transaction but emit its metric only after a successful commit.</violation>
</file>

<file name="backend/utils/conversations/terminal_calendar.py">

<violation number="1" location="backend/utils/conversations/terminal_calendar.py:36">
P1: This provider probe can run inside a Firestore transaction, holding the transaction for the 10-second timeout and repeating external calls on transaction retries. Resolve calendar evidence before entering every terminal transaction and pass the precomputed, window-fenced result into the transaction.</violation>
</file>

<file name="backend/tests/unit/test_sync_lineage_flags_off_parity.py">

<violation number="1" location="backend/tests/unit/test_sync_lineage_flags_off_parity.py:5">
P2: This test does not have a literal, helper-independent expected decision despite the docstring claiming it does. Changes that make `stamp_terminal_decision` emit the wrong sync-intake decision will update both comparison sides and still pass; add explicit expected decision assertions or snapshot the expected payload separately.</violation>
</file>

<file name="backend/utils/memory/atom_keyword_index.py">

<violation number="1" location="backend/utils/memory/atom_keyword_index.py:395">
P1: This unconfigured check only fixes per-memory deletes; account deletion still calls `purge_user_atom_keyword_index(..., raise_on_failure=True)`, which constructs the unconfigured Typesense client and aborts the wipe. Apply the same confirmed-absence handling to the user-wide purge (and preserve its strict behavior for partial/configured failures).</violation>
</file>

<file name="backend/docs/audits/discard-decision-paths.md">

<violation number="1" location="backend/docs/audits/discard-decision-paths.md:30">
P2: This inventory overstates sync-intake coverage: promoted existing survivors can clear `relevance_decision`, while `assignment.py` only stamps newly created rows. Narrow the claim to created survivors, or document the separate downstream writer that guarantees promotion stamping.</violation>
</file>

<file name="backend/database/conversation_finalization_jobs.py">

<violation number="1" location="backend/database/conversation_finalization_jobs.py:2957">
P1: This BYOK terminal path performs calendar provider I/O inside the Firestore transaction because it supplies `byok_abandoned` without a precomputed calendar probe. Prepare the probe before starting the transaction and pass it through, as `mark_finalization_dead_letter` does, so transaction retries never repeat external I/O.</violation>
</file>

<file name="backend/utils/memory/memory_system.py">

<violation number="1" location="backend/utils/memory/memory_system.py:38">
P2: The configurable timeout is not validated, so a bad or excessively large deployment value can either break every apply-control read or defeat the seconds-level fail-fast bound. Validate it as a finite positive value within the intended upper bound before using it.</violation>

<violation number="2" location="backend/utils/memory/memory_system.py:143">
P1: The final fence check is not atomic with the following control creation, so deletion can start between the read and `create(payload)` and still admit a fresh generation-1 control state. Make the fence assertion and first write one transaction or conditional authority gate, coordinating the registry write as well.</violation>

<violation number="3" location="backend/utils/memory/memory_system.py:164">
P2: The lost-create branch skips the post-read deletion-fence check used by the existing-control branch. If deletion starts after the pre-create check, this path can recreate the maintenance registry after the wipe; recheck the fence before registering the winner.</violation>
</file>

<file name="backend/utils/conversations/deterministic_minimum.py">

<violation number="1" location="backend/utils/conversations/deterministic_minimum.py:195">
P2: This deferred placeholder needs the server-minimum provenance marker; otherwise `merge_before_processing` mistakes its non-empty title for completed enrichment and can prevent later captures from merging into it. Set `title_provenance='server_minimum'` on the returned `Structured` (or make the merge classifier recognize deferred rows).</violation>
</file>

<file name="backend/utils/sync/assignment.py">

<violation number="1" location="backend/utils/sync/assignment.py:925">
P2: A created row with a truthy but malformed `relevance_decision` skips this branch and persists an invalid receipt. Invoke `stamp_terminal_decision` for every created row; it already preserves valid decisions and repairs invalid ones.</violation>

<violation number="2" location="backend/utils/sync/assignment.py:930">
P2: This call records relevance metrics inside a retryable Firestore transaction. Retries or a failed encode/commit can emit multiple decisions for one row, or emit a decision for no row; defer metric emission until the successful post-commit path.</violation>
</file>

<file name="backend/database/conversation_processing_recovery.py">

<violation number="1" location="backend/database/conversation_processing_recovery.py:102">
P2: Photo-only unstampable orphans get a UTC fallback title even when the user's configured timezone is available. Pass a `user_time_zone(client, uid)` resolver, as the regular and oversized terminal paths do.</violation>
</file>

<file name="backend/database/released_memory_projection.py">

<violation number="1" location="backend/database/released_memory_projection.py:177">
P1: `card_coverage` must fail closed when `OMI_LIST_PROJECTION_WRITER_ENABLED` is unset. With the current `true` default, a writer rollback or omitted flag leaves conversation versions unchanged while MCP cards reuse stale snapshots; default this lookup to `false`.</violation>
</file>

<file name="backend/database/conversation_terminal_title.py">

<violation number="1" location="backend/database/conversation_terminal_title.py:261">
P1: Non-dead-letter terminal transactions perform calendar reads and provider I/O inside the retryable Firestore callback. Prefetch calendar evidence before the transaction and pass a probe, as the `dead_letter` path already does, so retries remain bounded and deterministic.</violation>

<violation number="2" location="backend/database/conversation_terminal_title.py:279">
P2: This relevance counter is incremented inside retryable Firestore transaction bodies, so contention retries record duplicate decisions for one committed terminal. Emit the metric after commit or stage a deduplicated post-commit effect to preserve one increment per conversation.</violation>

<violation number="3" location="backend/database/conversation_terminal_title.py:388">
P3: This adds a duplicate path parser beside the existing canonical `database.conversation_finalization_values.uid_from_conversation_path`. Import the canonical helper instead so path parsing has one authority.</violation>
</file>

<file name="backend/scripts/restore_stale_planner_archives.py">

<violation number="1" location="backend/scripts/restore_stale_planner_archives.py:40">
P2: Read-ledger records from this standalone tool are not attributed to `restore-stale-planner-archives` as documented. Set `FIRESTORE_READ_LEDGER_SERVICE` before importing the backend modules, or require that variable in the invocation, so remediation reads remain auditable.</violation>

<violation number="2" location="backend/scripts/restore_stale_planner_archives.py:205">
P3: Malformed ISO arguments bypass the documented usage-error path and raise an uncaught `ValueError`. Catch invalid timestamps and return the CLI's usage exit code 2.</violation>

<violation number="3" location="backend/scripts/restore_stale_planner_archives.py:266">
P1: The classifier restores every archived `route="review"` row in the window, regardless of rationale, so legitimate review archives can be reopened. Require the retry-exhausted rationale for both supported incident routes.</violation>

<violation number="4" location="backend/scripts/restore_stale_planner_archives.py:311">
P2: The read budget is enforced after each page is fetched, so a small `--max-reads` value can still read an entire 300-document page. Bound each query to the remaining budget before streaming, and stop cleanly when no budget remains.</violation>

<violation number="5" location="backend/scripts/restore_stale_planner_archives.py:590">
P2: `--progress-file` does not resume a run: the tool only appends progress and never consumes it. Load the checkpoint and advance `_iter_user_ids` past completed users, otherwise a stopped fleet run can repeatedly rescan the same prefix without reaching the remaining accounts.</violation>

<violation number="6" location="backend/scripts/restore_stale_planner_archives.py:639">
P2: `--max-writes` limits successful results instead of write attempts, so repeated failures can drive unbounded remediation calls past the safety budget. Stop when `writes_attempted` reaches `max_writes`.</violation>

<violation number="7" location="backend/scripts/restore_stale_planner_archives.py:726">
P1: The CLI write path crashes before it can validate credentials because `os` is never imported. Add the missing `os` import so `--apply` and `--revert` can reach the remediation flow.</violation>
</file>

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

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

token = integration.get('access_token')
if not token:
return None
events = asyncio.run(

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: This provider probe can run inside a Firestore transaction, holding the transaction for the 10-second timeout and repeating external calls on transaction retries. Resolve calendar evidence before entering every terminal transaction and pass the precomputed, window-fenced result into the transaction.

Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. When an issue isn't valid or won't be fixed in this PR, reply in its thread with the reason and then resolve the thread. At backend/utils/conversations/terminal_calendar.py, line 36:

<comment>This provider probe can run inside a Firestore transaction, holding the transaction for the 10-second timeout and repeating external calls on transaction retries. Resolve calendar evidence before entering every terminal transaction and pass the precomputed, window-fenced result into the transaction.</comment>

<file context>
@@ -0,0 +1,50 @@
+    token = integration.get('access_token')
+    if not token:
+        return None
+    events = asyncio.run(
+        asyncio.wait_for(
+            get_google_calendar_events(
</file context>

"""Remove one keyword doc and report whether the desired absence was confirmed."""
if not uid or not memory_id:
return False
if not os.getenv("TYPESENSE_HOST") and not os.getenv("TYPESENSE_API_KEY"):

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: This unconfigured check only fixes per-memory deletes; account deletion still calls purge_user_atom_keyword_index(..., raise_on_failure=True), which constructs the unconfigured Typesense client and aborts the wipe. Apply the same confirmed-absence handling to the user-wide purge (and preserve its strict behavior for partial/configured failures).

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/memory/atom_keyword_index.py, line 395:

<comment>This unconfigured check only fixes per-memory deletes; account deletion still calls `purge_user_atom_keyword_index(..., raise_on_failure=True)`, which constructs the unconfigured Typesense client and aborts the wipe. Apply the same confirmed-absence handling to the user-wide purge (and preserve its strict behavior for partial/configured failures).</comment>

<file context>
@@ -391,6 +392,32 @@ def delete_atom_keyword_doc(uid: str, memory_id: str, *, db_client: Any = None)
     """Remove one keyword doc and report whether the desired absence was confirmed."""
     if not uid or not memory_id:
         return False
+    if not os.getenv("TYPESENSE_HOST") and not os.getenv("TYPESENSE_API_KEY"):
+        # Neither Typesense binding is present, so the deployment is durably
+        # unprovisioned for the keyword projection (the Cloud Run ``backend``
</file context>

conversation_ref,
terminal,
time_zone_for_uid,
path='byok_abandoned',

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: This BYOK terminal path performs calendar provider I/O inside the Firestore transaction because it supplies byok_abandoned without a precomputed calendar probe. Prepare the probe before starting the transaction and pass it through, as mark_finalization_dead_letter does, so transaction retries never repeat external I/O.

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/database/conversation_finalization_jobs.py, line 2957:

<comment>This BYOK terminal path performs calendar provider I/O inside the Firestore transaction because it supplies `byok_abandoned` without a precomputed calendar probe. Prepare the probe before starting the transaction and pass it through, as `mark_finalization_dead_letter` does, so transaction retries never repeat external I/O.</comment>

<file context>
@@ -2948,7 +2948,15 @@ def _abandon_byok_finalization_job_txn(
+            conversation_ref,
+            terminal,
+            time_zone_for_uid,
+            path='byok_abandoned',
+            transaction=transaction,
+        )
</file context>

card_coverage = (
card_epoch.startswith('v2:')
and bool(card_epoch[3:].strip())
and os.environ.get('OMI_LIST_PROJECTION_WRITER_ENABLED', 'true').strip().lower()

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: card_coverage must fail closed when OMI_LIST_PROJECTION_WRITER_ENABLED is unset. With the current true default, a writer rollback or omitted flag leaves conversation versions unchanged while MCP cards reuse stale snapshots; default this lookup to false.

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/database/released_memory_projection.py, line 177:

<comment>`card_coverage` must fail closed when `OMI_LIST_PROJECTION_WRITER_ENABLED` is unset. With the current `true` default, a writer rollback or omitted flag leaves conversation versions unchanged while MCP cards reuse stale snapshots; default this lookup to `false`.</comment>

<file context>
@@ -158,9 +170,13 @@ def projected_stream_list(query: Any, budget: Any = None, *, surface: str, _sour
+        card_coverage = (
+            card_epoch.startswith('v2:')
+            and bool(card_epoch[3:].strip())
+            and os.environ.get('OMI_LIST_PROJECTION_WRITER_ENABLED', 'true').strip().lower()
+            not in {'0', 'false', 'off'}
+        )
</file context>
Suggested change
and os.environ.get('OMI_LIST_PROJECTION_WRITER_ENABLED', 'true').strip().lower()
and os.environ.get('OMI_LIST_PROJECTION_WRITER_ENABLED', 'false').strip().lower()

)
if cursor is not None:
query = query.start_after(cursor)
snapshots = list(query.stream())

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: The read budget is enforced after each page is fetched, so a small --max-reads value can still read an entire 300-document page. Bound each query to the remaining budget before streaming, and stop cleanly when no budget remains.

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/scripts/restore_stale_planner_archives.py, line 311:

<comment>The read budget is enforced after each page is fetched, so a small `--max-reads` value can still read an entire 300-document page. Bound each query to the remaining budget before streaming, and stop cleanly when no budget remains.</comment>

<file context>
@@ -0,0 +1,760 @@
+        )
+        if cursor is not None:
+            query = query.start_after(cursor)
+        snapshots = list(query.stream())
+        ledger.charge_query(len(snapshots))
+        if not snapshots:
</file context>

continue
applied_for_user = 0
for item in scan.matched:
if max_writes is not None and report.writes_committed + report.writes_idempotent >= max_writes:

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: --max-writes limits successful results instead of write attempts, so repeated failures can drive unbounded remediation calls past the safety budget. Stop when writes_attempted reaches max_writes.

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/scripts/restore_stale_planner_archives.py, line 639:

<comment>`--max-writes` limits successful results instead of write attempts, so repeated failures can drive unbounded remediation calls past the safety budget. Stop when `writes_attempted` reaches `max_writes`.</comment>

<file context>
@@ -0,0 +1,760 @@
+                continue
+            applied_for_user = 0
+            for item in scan.matched:
+                if max_writes is not None and report.writes_committed + report.writes_idempotent >= max_writes:
+                    report.writes_stopped_early = True
+                    break
</file context>

return True


def uid_from_conversation_path(path: str) -> str | 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.

P3: This adds a duplicate path parser beside the existing canonical database.conversation_finalization_values.uid_from_conversation_path. Import the canonical helper instead so path parsing has one authority.

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/database/conversation_terminal_title.py, line 388:

<comment>This adds a duplicate path parser beside the existing canonical `database.conversation_finalization_values.uid_from_conversation_path`. Import the canonical helper instead so path parsing has one authority.</comment>

<file context>
@@ -217,3 +365,29 @@ def user_time_zone(client: Any, uid: str) -> str | None:
+    return True
+
+
+def uid_from_conversation_path(path: str) -> str | None:
+    """Return the uid from a ``users/{uid}/conversations/{conversation_id}`` path."""
+    parts = path.split('/')
</file context>



def _coerce_utc(value: str, flag: str) -> datetime:
parsed = datetime.fromisoformat(value.replace("Z", "+00:00"))

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: Malformed ISO arguments bypass the documented usage-error path and raise an uncaught ValueError. Catch invalid timestamps and return the CLI's usage exit code 2.

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/scripts/restore_stale_planner_archives.py, line 205:

<comment>Malformed ISO arguments bypass the documented usage-error path and raise an uncaught `ValueError`. Catch invalid timestamps and return the CLI's usage exit code 2.</comment>

<file context>
@@ -0,0 +1,760 @@
+
+
+def _coerce_utc(value: str, flag: str) -> datetime:
+    parsed = datetime.fromisoformat(value.replace("Z", "+00:00"))
+    if parsed.tzinfo is None or parsed.utcoffset() is None:
+        raise SystemExit(f"{flag} must include a UTC offset: {value}")
</file context>

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

ℹ️ 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 on lines +395 to +399
if not os.getenv("TYPESENSE_HOST") and not os.getenv("TYPESENSE_API_KEY"):
# Neither Typesense binding is present, so the deployment is durably
# unprovisioned for the keyword projection (the Cloud Run ``backend``
# service and the desktop backend deploy without either binding) and
# never writes it: the desired absence is trivially confirmed, and

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 Keep keyword deletion unconfirmed when credentials are absent

When a memory indexed by backend-sync or memory maintenance is deleted through a service without Typesense bindings, this branch reports success without removing the shared keyword document. The inspected production runtime manifest gives backend and backend-sync the same canonical_memory_atoms collection, while only backend-sync has the Typesense credentials; missing credentials in the deleting process therefore do not establish provider-side absence. _run_immediate_privacy_cleanup in canonical_memory_adapter.py trusts this return value to acknowledge privacy cleanup, and the outbox projection-delete callback also treats it as successful delivery. Keep deletion unconfirmed or dispatch it to a credentialed executor rather than returning confirmed absence.

Useful? React with 👍 / 👎.

Comment on lines +276 to +277
if item.updated_at is not None and item.updated_at > processed_at:
return "edited_after_processing"

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 Distinguish archive commit timestamps from subsequent edits

For incident rows produced by the canonical consolidation path, updated_at > processed_at does not establish a later edit: _promotion_audit in canonical_consolidation.py stores the caller's now as processed_at, then _apply_update_memory_item in models/memory_apply.py obtains a fresh datetime.now() for updated_at while applying that same archive operation. Consequently, ordinary unedited incident rows are excluded as edited_after_processing, preventing the remediation from restoring them. The unit fixtures conceal this by defaulting both timestamps to exactly the same value. Use the archive commit/revision provenance to detect subsequent edits instead of comparing these independently generated timestamps.

Useful? React with 👍 / 👎.

Comment on lines +182 to 184
calendar_probe=calendar_probe,
)
return fit_document_limit(conversation, conversation_ref, base, extras)

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 Suppress processing-attention entries for rule discards

When a failed finalization now deterministically discards a filler-only transcript, the caller _dead_letter_finalization_job still unconditionally creates a processing-attention item, and summary_retryable can remain true because it was calculated before this relevance decision. processing_attention.unresolved() checks only deletion and the presence of an overview, so the discarded row remains in /v1/attention-items, increments /v1/pending-work's unseen-failure count, and is eligible for Retry All. This presents an intentional no-content discard as failed work requiring recovery and can reprocess noise. Skip or resolve the attention item, and clear retry eligibility, when the terminal verdict is discard.

Useful? React with 👍 / 👎.

Comment on lines +109 to +113
and not (
row.get('imported')
or row.get('has_photos')
or row.get('photos')
or row.get('user_title')

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 Protect existing summaries from transcript-only terminal discards

For a legacy processing row without a valid relevance receipt, an existing overview, sections, action items, or events do not prevent this transcript-only assessment from discarding the conversation. For example, an orphan with a substantive stored summary and an absent transcript now receives discarded=True once the photo/calendar probes return no protection; previously orphan completion kept it visible. This also bypasses the protected-content safeguard used by persist_processing_result_with_lifecycle for recovery discards. The terminal path already detects existing protected structured content when calculating retry eligibility, but does not carry that protection into the relevance decision. Preserve rows containing substantive structured content rather than treating an empty or filler transcript as proof that the entire conversation is disposable.

Useful? React with 👍 / 👎.

The refresh merge kept the survivor lineage's real-monotonic clock lines
without the import time that went with them, so the proof died on
NameError: time at line 111. The fold stack does not intentionally
change this script; take origin/main's blob wholesale. No retry or lease
behavior changes.
- lifecycle state table: the blocked_byok stock dwell alert is agent tier
  (omi-finalization-byok-dwell-info) since #24595 moved the page to fresh
  cohort dwell; re-point the inventory row and declare the folded writer
  moves (recover_deferred_processing_failure_txn and the dead-letter title
  helpers now live in conversation_terminal_title)
- crash-window orphans: an absent transcript is not evidence the user said
  nothing, so the orphan terminal recovery paths stage the path's policy
  keep as a prior verdict; dead_letter and BYOK abandonment keep their
  calendar-protected rule assessment of content-free audio
- run-emulator-proofs: drop the daily-sweep entry (main retired that proof)
- strict firestore fixture: model the canonical apply control read's
  retry kwarg, and default its per-attempt timeout to the modeled 3s bound
- folded tests: match the folded terminal receipt (replay exhaustion) and
  keep the size-rollover fixtures stamp-agnostic
The size-ceiling terminal's failed-status visibility exclusion is a
conversation-list contract; the episode member surface renders a failed
member with its 'Couldn't transcribe' wire status so the user keeps the
bounded recovery exit. Exempt that surface from the exclusion instead of
weakening the shared predicate.
#24600 converted the declared field builders to a site inventory; the
fold's writer moves (recover_deferred_processing_failure_txn and the
dead-letter title helpers into conversation_terminal_title, the home-read
member visibility override, and the chat-first fixture capture module)
are declared there now.

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

ℹ️ 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 on lines +150 to +151
def _has_wake_word(texts: Sequence[str]) -> bool:
from utils.conversations.wake_word import find_wake_word_matches

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 Move the new helper imports to module scope

The new module imports find_wake_word_matches inside _has_wake_word and record_conversation_relevance inside stamp_terminal_decision. This violates backend/AGENTS.md's explicit requirement: “All imports at module top level — never inside functions.” Move these imports to the module import block; the wake-word module is already dependency-light, so this import does not require a lazy-loading exception.

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

Useful? React with 👍 / 👎.

Comment on lines +3010 to +3013
Failure terminals publish completed rows with an explicit relevance verdict in
the same transaction. Valid prior decisions survive. Missing decisions use
strict transcript decoding and audio-source deterministic rules; ambiguous
content gets a bounded path-specific policy keep. Calendar, photos (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.

P1 Badge Add the required lifecycle pipeline change note

This commit changes dead-letter, BYOK-abandonment, orphan-recovery, and oversized-terminal behavior, but its changed-file list contains no note under backend/docs/listen_pusher_pipeline/changes/. The updated contract section and separate writer audit do not satisfy backend/AGENTS.md's requirement to add a note in that directory in the same PR. Add the dated note describing the lifecycle changes, rollout state, and verification evidence.

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

Useful? React with 👍 / 👎.

Comment on lines +886 to 890
if (
is_soft_deleted(conversation)
or getattr(conversation.get('status'), 'value', conversation.get('status')) == 'failed'
):
return False

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 Preserve explicit detail access to failed recordings

When fit_document_limit terminalizes an oversized recording with status='failed', this unconditional exclusion also rejects explicit detail reads, not just default-list membership. The inspected get_conversation_by_id route in backend/routers/conversations.py calls this predicate even with include_discarded=True and consequently returns 404 for the retained recording. Limit the failed-status exclusion to default-list visibility, or provide an explicit recovery/detail exception, so retaining the original content does not make it inaccessible.

Useful? React with 👍 / 👎.

Comment on lines +370 to +374
remediation = (item.promotion or {}).get("remediation") or {}
if remediation.get("marker") != MARKER or remediation.get("reverted_at") is not None:
scan.exclusions["marker_stale"] += 1
continue
scan.matched.append(item)

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 Exclude subsequently edited memories from remediation rollback

If a user edits a restored memory before --revert, update_canonical_memory_content preserves promotion.remediation, leaves the item active in Short-term, and records the user's correction. This selector therefore still includes it, and _apply_row uses the newly scanned revision/hash to successfully archive the edited memory rather than rejecting the intervening change. Record the restore's resulting revision or commit and require it to remain unchanged before rollback; the remediation marker alone does not establish that the row is still safe to revert.

Useful? React with 👍 / 👎.

#24583 landed utils/stt/diarization_eval.py with seven lifecycle write
sites but no inventory entry; declare the reviewed sites so the writer
guard matches the real payload writes.

@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: 7982e9a0bc

ℹ️ 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 on lines +77 to +80
def get(self, transaction=None, **kwargs):
if self.path not in self.db.docs:
return _Snapshot(None, exists=False, doc_id=self.path.rsplit("/", 1)[-1], reference=self)
return _Snapshot(self.db.docs[self.path], doc_id=self.path.rsplit("/", 1)[-1], reference=self)

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 Enforce Firestore ordering in the remediation transaction fake

The apply/revert tests execute the canonical ledger through this fake, but _Document.get() ignores the supplied transaction and permits reads after _Transaction.set() or delete() has staged writes. Consequently, these tests can report successful remediation commits for transaction sequences that production Firestore rejects. backend/AGENTS.md requires transaction fakes to enforce ordering and constraint semantics: use the strict fixture for document transactions, with emulator coverage for the query/delete behavior needed here.

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

Useful? React with 👍 / 👎.

@Git-on-my-level
Git-on-my-level merged commit f3642cf into main Nov 4, 2026
77 of 79 checks passed
@Git-on-my-level
Git-on-my-level deleted the lane/freshtitles-agegate branch November 4, 2026 17:54
Git-on-my-level added a commit that referenced this pull request Nov 5, 2026
…24726)

Adds a strict AST inventory of terminal conversation statuses
(`completed`, `failed`) and terminal finalization-job statuses
(`completed`, `dead_letter`). `TERMINAL-WRITER-OWNER` rejects new
`(file, function)` sites and stale exceptions. The intended owners are
`utils/conversations/lifecycle.py` plus
`database/conversations.py:claim_conversation_status`, and
`database/conversation_finalization_jobs.py` for jobs.

Test-only phase 3, approved by lead2 decision 923dd2. No runtime,
`.github`, GCP, merge, or deploy changes. The existing lifecycle writer
test is selected for every backend Python change. The scanner runs
offline, excludes test trees, follows local aliases/payload mutation and
patch builders, and inventories dynamic CAS/full-conversation
persistence conservatively. It is a static tripwire, not proof of
runtime lifecycle behavior or arbitrary whole-program dataflow.

Baseline: freshly fetched `origin/main` at
`148bf4c1c57073dba4ec9a750415f2c72f5adb87`; the November 5 sweep was
verified against current source. Builders and storage callbacks are
separate sites. The finalization inventory includes conversation-merge
jobs because they use the same `conversation_finalization_jobs`
collection. `record_partial.py` reopens the audio barrier but does not
write a terminal conversation status, so it adds no terminal exception.

Allowlist: conversation **37**, finalization **13**. Includes
conservative opaque whole-document/dynamic-key candidates whose status
cannot be resolved locally.

Unclassified current sites (no reason guessed):

- `conversation`:
`database/conversation_finalization_jobs.py:_apply_snapshot_bound_projection`
- `conversation`:
`database/conversation_recorded_time.py:create_if_absent.create`
- `conversation`:
`database/conversations.py:release_share_email_recipients`
- `conversation`:
`database/review_transcript_changes.py:record_change.build.write`
- `conversation`:
`database/review_transcript_changes.py:set_undone.build.write`
- `conversation`:
`database/screen_frames.py:bump_conversation_screen_frames_revision`
- `conversation`:
`database/screen_frames.py:mark_conversation_screen_frames_adjudicated`
- `conversation`: `database/stuck_backfill.py:_restore_txn`
- `conversation`: `utils/sync/assignment.py:assign_in_transaction`
- `conversation`:
`database/conversation_finalization_jobs.py:_complete_server_batch_capture_txn`
- `conversation`:
`database/conversation_merge_jobs.py:finish_recovery.commit`
- `conversation`:
`database/conversation_terminal_title.py:recover_deferred_processing_failure_txn`
- `conversation`:
`database/conversations.py:persist_processing_result_with_lifecycle._persist`
- `conversation`:
`database/conversations.py:transition_conversation_status`
- `conversation`:
`database/conversations.py:upsert_conversation_with_lifecycle._write_processing_result`
- `conversation`: `database/stuck_backfill.py:_close_txn`
- `conversation`:
`utils/conversations/late_meeting_notes.py:refresh_notes_after_evidence`
- `conversation`:
`utils/conversations/process_conversation.py:_store_budget_waiting`
- `conversation`:
`utils/conversations/process_conversation.py:process_conversation`
- `conversation`:
`scripts/staging/replay.py:StagingFirestoreSeeder.seed_capture`
- `conversation`: `utils/dream_canary.py:seed`
- `conversation`: `utils/imports/limitless.py:process_limitless_import`
- `conversation`:
`utils/imports/transcript_files.py:build_imported_conversation`
- `conversation`: `utils/sync/late_audio.py:ingest_late_transcript`
- `conversation`:
`utils/sync/minimal_redrive.py:_title_new_conversation`
- `finalization`:
`database/conversation_merge_jobs.py:begin_recovery.commit`
- `finalization`: `database/conversation_merge_jobs.py:finish.commit`
- `finalization`:
`database/conversation_merge_jobs.py:finish_recovery.commit`

Why isn't this a shared primitive instead? Runtime convergence is phase
2 of the one-writer redesign and is outside this approved test-only
scope. This extends the existing lifecycle AST/state-table gate while
that migration proceeds; it does not add a competing mutation API.
Concrete precedent: [merged
#24602](#24602) includes the
oversized terminal escape now inventoried outside the lifecycle owner;
the ratchet requires that kind of additional terminal writer to be
reviewed explicitly rather than silently growing the writer set. The
existing module allowlist in `check_conversation_lifecycle_writes.py`
does not constrain new terminal functions inside already allowed
modules.

## Product invariants affected

none

## Validation

- Canonical `backend/test.sh` via `omi-heavy`, writer/invariant/selector
file list, cloud credential/project vars unset: **1,896 passed, 71
strict xfailed**, normal CPU timing guard enabled.
- **203** alias/string regression cases exercise update/set/merge/claim
payloads, imported class aliases, qualified modules, indexed enum
members, `.value`, non-terminal statuses, and reads/comparisons.
Discovery is exercised through synthetic source files, without a
conversation collection literal.
- Full scan: **2.645 s wall / 2.620 s CPU**, with the same **37
conversation candidates / 13 finalization-job sites**. No allowlist
relaxation, serving imports, network, or Firestore.
- `make preflight`: **36 checks passed in 83.58 s**.
- Full `scripts/pr-preflight --pr-body-file`: **36 checks passed in
88.93 s**.
- Original normal push passed after parameterizing source modules to fit
the unchanged one-second per-test CPU guard; no timing exception,
bypass, cap override, or slow marker was added. Alias-fix push through
the normal hook **passed in 116.95 s**, without bypasses, cap overrides,
or a Firestore timeout.
- Grok reviewed the original scanner and per-module scheduling change,
finding no remaining blockers. Luna r1 identified an enum-alias false
negative; this follow-up fixes it inline with the regression cases
above. The candidate prefilter now selects status-write syntax without
depending on terminal enum spelling, and the AST resolves
imported/qualified ConversationStatus members.

Head: `1b82c1d62089c2df2d8b5ee4b3d3e261c6b3a040`. CI status is tracked
in the [PR
checks](https://github.com/BasedHardware/omi/pull/24726/checks); no
merge or deploy is authorized by this lane.


<!-- This is an auto-generated description by cubic. -->
<a
href="https://cubic.dev/pr/BasedHardware/omi/pull/24726?utm_source=github"
target="_blank" rel="noopener noreferrer"
data-no-image-dialog="true"><picture><source
media="(prefers-color-scheme: dark)"
srcset="https://www.cubic.dev/buttons/review-in-cubic-dark.svg"><source
media="(prefers-color-scheme: light)"
srcset="https://www.cubic.dev/buttons/review-in-cubic-light.svg"><img
alt="View guided diff"
src="https://www.cubic.dev/buttons/review-in-cubic-light.svg"></picture></a>
<a
href="https://www.cubic.dev/action/auto-fix/pr/BasedHardware/omi/24726?returnTo=https%3A%2F%2Fgithub.com%2FBasedHardware%2Fomi%2Fpull%2F24726&source=description"
target="_blank" rel="noopener noreferrer"
data-no-image-dialog="true"><picture><source
media="(prefers-color-scheme: dark)"
srcset="https://www.cubic.dev/buttons/turn-on-auto-fix-dark.svg"><source
media="(prefers-color-scheme: light)"
srcset="https://www.cubic.dev/buttons/turn-on-auto-fix-light.svg"><img
alt="Turn on auto-fix"
src="https://www.cubic.dev/buttons/turn-on-auto-fix-light.svg"></picture></a>
<!-- End of auto-generated description by cubic. -->
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