Repository navigation
Conversation
|
You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard. |
|
Thanks for the careful write-up and tests here. This looks like the right recovery shape to me: stale I verified the focused regression suite locally on the PR head:
Because this touches listen-session recovery for user conversation data and can dispatch finalization work, I’m not formally approving it from automation. A human maintainer should still review the operational assumptions before merge, especially that the 1-hour stale threshold and bounded by AI on behalf of David — if you need David’s attention urgently, please @Git-on-my-level and escalate with |
|
Thanks @Git-on-my-level. Some concrete numbers on the two operational questions, for whoever does the human pass: Bounded read vs backlog size: the query is capped at 1-hour threshold: any session that owns an Drain rate: ≤10 recoveries per session start, oldest first, means the reported 161-row backlog clears over ~17 sessions for that user — spread out by design so one reconnect never fans out dozens of LLM finalizations. The manual Happy to adjust the threshold or the caps if the maintainer pass prefers different numbers — both are single constants ( |
kodjima33
left a comment
There was a problem hiding this comment.
Reviewed by automated PR reviewer — approving; holding merge (see notes).
|
Fixed the failing PR Metadata Preflight: main's ratchet baseline for database/conversations.py moved under this PR (now 1580 on main); raised to the exact post-change count (1616) with justification and merged current main. Local preflight 21/21 green, recovery suite still 6/6. Ready when you are @kodjima33. |
|
Re-reviewed the current head ( Verification I ran locally on this head with secrets stripped/offline mode:
I also reproduced the two files named by the current Backend unit suite failure via Keeping this as human-maintainer review rather than automation approval because it touches user conversation recovery and can dispatch finalization jobs. The maintainer pass should still sign off on the operational caps/thresholds ( by AI on behalf of David — if you need David’s attention urgently, please @Git-on-my-level and escalate with |
|
@Git-on-my-level @undivisible This PR is fully approved. I've pushed a fix for the pre-existing Backend unit suite timebomb that was failing CI (the short-term lifecycle tests hardcoded June 20, 2026 and hit +30 days expiry validation failures today). CI should be green shortly. Could you please merge when you have a chance? |
|
Thanks for the re-review. The operational caps are all single constants for easy adjustment: |
|
@kodjima33 approved and green. The operational caps flagged for the human pass are all single constants for easy tuning — |
|
@Git-on-my-level need human response — requesting David's merge sign-off. Approved by @kodjima33, all checks green, no conflicts. The item flagged for a human is the operational caps on orphan recovery — all single constants ( |
0fea84c to
f69b82b
Compare
|
Reviewed the current head ( Verification:
I also attempted the listen-pusher stack gauntlet locally, but this runner only has the wrong Java for the Firestore emulator ( No code changes requested from my side. I’m still not formally approving from automation because this touches user conversation-data recovery and can enqueue finalization jobs; a human maintainer should sign off on the operational constants ( by AI on behalf of David — if you need David’s attention urgently, please @Git-on-my-level and escalate with |
f69b82b to
5225d14
Compare
…undaries Conversations from sessions that died before processing sit in in_progress forever, invisible to users (the web app filters to processing/completed). Production data in BasedHardware#9809: ~161 stuck in_progress rows, some months old, several with real transcripts. Session-boundary recovery already re-dispatches stuck processing rows (BasedHardware#9960) but never looked at in_progress. process_pending now also routes orphaned in_progress conversations through process_conversation — the exact call a live timeout makes: content goes through the durable finalization seam, empty rows are deleted. Orphanhood is proven by idle time: any live session refreshes finished_at continuously and processes an idle conversation within the ~2-minute conversation timeout, so an hour of silence means no session owns the row, including on another device. The session's own current conversation is excluded explicitly. The fetch is an equality-only status query (no new index) with the age cut client-side, oldest-first and bounded to 10 per session so a large backlog spreads across sessions instead of stampeding the pipeline. Covers the in_progress bucket of BasedHardware#9809; stuck processing rows are already re-dispatched here, and merging/failed recovery plus a server-side sweep for users who never reconnect are named follow-ups. Failure-Class: none Co-Authored-By: Claude Fable 5 <[email protected]>
…tack gauntlet New cloud-orphan-recovery scenario in the listen-pusher gauntlet: seed an in_progress row no session owns (2h idle, content intact — production orphans predate any single cause, so the row is seeded directly while the recovery session itself runs the real listener), open a real session, and prove its process_pending pass admits the orphan into a durable finalization job, the loopback Cloud Tasks delivery completes it through the real worker, and the conversation lands completed with content. The session stays open while waiting: process_pending is a finite task started at session begin with a built-in 7s delay, and teardown cancels finite tasks — closing immediately is exactly how the scenario first failed. Verification: full gauntlet (all six suites) passed locally against real backend/pusher/worker processes, Firestore emulator, Redis, and the strict loopback Cloud Tasks client. On pre-fix code the scenario fails by construction: no recovery pass exists, so the orphan's job admission times out. Co-Authored-By: Claude Fable 5 <[email protected]>
5225d14 to
4056cee
Compare
Git-on-my-level
left a comment
There was a problem hiding this comment.
Thanks for the continued updates here. The listen recovery path itself still looks sound to me, and I re-ran the focused regression locally on the current head:
cd backend && OMI_ENV_STAGE=offline PROVIDER_MODE=offline .venv/bin/pytest tests/unit/test_listen_process_pending_shutdown.py -q → 6 passed.
However, I do need to request changes for the current head because the required Hygiene check is failing in product-file-line-count-ratchet:
backend/testing/listen_pusher_stack/run.py: grew from baseline 1711 to 1790 lines. Split the file, or raise its exact baseline with a one-line justification in .github/scripts/product_file_line_count_ratchet_baseline/backend-other.json.
Given this PR intentionally adds the cloud-orphan-recovery stack scenario, updating that ratchet baseline with a narrow justification may be the smallest fix, unless you prefer to split the gauntlet helper/scenario out. Once Hygiene is green again, the remaining sign-off is still the human maintainer call on the operational recovery constants (3600s stale age, 10 per session, bounded status == in_progress read) because this touches user conversation recovery and can enqueue finalization jobs.
by AI on behalf of David — if you need David’s attention urgently, please @Git-on-my-level and escalate with need human response.
Failure-Class: none
kodjima33
left a comment
There was a problem hiding this comment.
Recovering orphaned in_progress conversations at session boundaries reads correct; holding the merge only because the branch has conflicts with main.
Failure-Class: none
Resolve line-count ratchet baseline conflicts by taking origin/main's shards and re-applying only the BasedHardware#9809 raises: - backend/database/conversations.py 1667 -> 1704 (+37) - backend/testing/listen_pusher_stack/run.py 1711 -> 1790 (+79) main had independently rewritten both raise_justifications, so its text is preserved and the BasedHardware#9809 clause appended rather than overwriting. Stale HEAD entries dropped in favour of main's current values (validate-backend-runtime-env.py 1836, users.py 2046, memory_apply_store.py 1912). Verification: - check_product_file_line_count_ratchet.py --base origin/main: OK, no line-count increase across 3 changed product source files - pytest tests/unit/test_listen_process_pending_shutdown.py: 7 passed
…d its index The BasedHardware#9809 in-progress recovery query (status == in_progress ordered by finished_at) was added with its composite index hand-written directly into the generated firestore.indexes.json and no entry in the query registry. Two gates rejected it: firestore-index-manifest (the manifest no longer matched its generator) and firestore-query-coverage (new unregistered serving compound shape 3b69cd3fc6dded3d). Regenerating the manifest alone would have silently deleted the index and left the production query failing closed with FailedPrecondition. Register the shape instead and build the read path from it: - add STALE_IN_PROGRESS_CONVERSATIONS_QUERY to the index registry, which both builds the query and declares the status/finished_at composite - get_stale_in_progress_conversations now builds via the spec rather than an inline where() chain - firestore.indexes.json regenerated from the registry; the index is now derived rather than hand-maintained - extend the manifest contract test to pin the new tail index and assert the spec is classified registered - raise the conversations.py ratchet baseline 1704 -> 1708 Failure-Class: FC-undeclared-serving-query-index Verification: - backend/scripts/firestore_query_coverage.py --check-ratchet: exit 0 - backend/scripts/generate_firestore_indexes.py: manifest matches registry - pytest tests/unit/test_firestore_query_contract.py tests/unit/test_listen_process_pending_shutdown.py: 31 passed
Git-on-my-level
left a comment
There was a problem hiding this comment.
Thanks for the update registering the conversations_in_progress_by_finished_at Firestore index. The recovery path itself still looks directionally sound, but the current head has a PR-caused required-test failure that needs to be fixed before merge.
I reproduced the failure locally with the CI runner contract:
cd backend && OMI_ENV_STAGE=offline PROVIDER_MODE=offline BACKEND_UNIT_TEST_FILE_LIST=/tmp/omi-pr10060-tests.txt bash test.sh
The focused recovery tests pass, but tests/unit/test_reconcile_firestore_indexes.py::test_provision_missing_uses_gcloud_with_every_manifest_field_and_waits_for_ready still hard-codes the old last manifest index (task_attention_overrides). Since this PR appends the new conversations index, that test now expects the wrong gcloud firestore indexes composite create ... command and the Backend unit suite fails. Please update that reconcile-index provisioning test/fixture to match the new generated manifest behavior (or make it robust to whichever target index it selects) and rerun the failed file through test.sh.
I’m keeping the human-maintainer hold for the operational recovery constants as before (3600s stale age, batch 10, and the bounded ordered status == in_progress read), and I’m not requesting changes to the core listen recovery logic beyond the failing test contract.
by AI on behalf of David — if you need David’s attention urgently, please @Git-on-my-level and escalate with need human response.
test_provision_missing_uses_gcloud_with_every_manifest_field_and_waits_for_ready picks its target index dynamically (manifest['indexes'][-1]) but asserted a hardcoded argv for task_attention_overrides, the index that happened to sit at the tail when the test was written. Appending the BasedHardware#9809 conversations index in e22748a moved the tail, so the expected gcloud command no longer described the index the test actually provisions and the Backend unit suite failed. Assert against the target the test already computes instead of a frozen copy: - collection-group and field-config count derive from `target` - the full argv is compared to gcloud_create_index_command(), the same helper reconcile() calls, so the expectation tracks production rather than restating it - the subcommand prefix, --quiet terminator, and the no-firebase-CLI check keep their independent literal assertions Any future manifest append now leaves this test passing without an edit. Verification: - cd backend && OMI_ENV_STAGE=offline PROVIDER_MODE=offline \ BACKEND_UNIT_TEST_FILE_LIST=<list> bash test.sh: exit 0 (test_reconcile_firestore_indexes.py 29 passed, test_firestore_query_contract.py 22 passed 2 deselected, test_listen_process_pending_shutdown.py 7 passed) - tail-independence proved by temporarily reordering QUERY_SPECS so ACTIVE_ATTENTION_OVERRIDE_QUERY became the tail and regenerating the manifest: 29 passed unchanged; registry and manifest restored after - black --line-length=120 --skip-string-normalization: unchanged
Summary
process_pending(the session-boundary recovery pass that already re-dispatches stuckprocessingconversations, Finalize pending conversations when a listen session ends inside the retry window #9960) now also recovers orphanedin_progressconversations — the largest stuck bucket in Bug: conversations get stuck in processing states and never finalize #9809 (~161 rows in production, some months old, several with real transcripts, all invisible to users because the web app filters toprocessing,completed).process_conversation— the exact call a live conversation timeout makes: content goes through the durable finalization job seam; empty rows are deleted bydelete_empty_recording_conversation. No new recovery mechanism, no new state.finished_aton every segment and its lifecycle loop processes an idle conversation within the ~2-minute conversation timeout, so an hour of silence means no session owns the row — including a session on another device. The session's own current conversation is excluded explicitly.firestore.indexes.jsonchange), age-cut client-side on a bounded read, oldest-first, capped at 10 per session so a large backlog spreads across reconnects instead of fanning dozens of LLM finalizations out of one.Addresses the
in_progressbucket of #9809.Root cause
A listen session that dies between conversation creation and finalization leaves the row
in_progresswith no automatic owner: the lifecycle loop only watches the current conversation,process_pendingonly re-dispatchedprocessing, and the durable-job reconciler only replays rows that already have a finalization job. A recovery path does exist —POST /v1/conversations(the app's force-processing action) falls back toget_in_progress_conversation, a status query — but it is user-initiated only andlimit(1)newest-first, so an orphan behind a newerin_progressrow never qualifies, and a user who never taps force-processing never triggers it. (Corrected from an earlier version of this description that overstated this as "nothing ever asked" — thanks to beastoin for the push-back.) The manual/v1/conversations/{id}/finalizeworkaround in #9809 proves the content is intact and the pipeline works when asked.Failure class
Failure-Class: none
No registered class on
maincovers this. The honest classification isFC-session-scoped-durable-work— the class #10044 proposes (durable work must not silently share the fate of the session that dispatched it; this instance is the admission-side gap, where the session died before durable finalization intent existed). If #10044 lands first, I'll update this declaration to cite it.Durable guard
process_conversation→ durable finalization intent / empty-row deletion) rather than adding a parallel path; the revision-fencedcreate_or_get_finalization_intentmakes re-recovery idempotent.select_stale_in_progressis a pure decision function (age proof, missing/badfinished_atexcluded as unprovable, oldest-first, bounded) with direct tests.merging/failedrecovery (different machinery — reprocess is an inline LLM call), and a server-side sweep for users who never open another session (needs a cross-user collection-group index and spend controls; belongs with the monitoring contract in [P1] Make monitoring delivery and telemetry coverage an explicit production contract #9587).Product invariants affected
none (verified with
scripts/pr-preflight --suggest)Validation
pytest tests/unit/test_listen_process_pending_shutdown.py→ 2 failed (orphans never recovered); new code → 6 passed.pytest tests/unit/test_listen_process_pending_shutdown.py tests/unit/test_lazy_conversation_processing.py tests/unit/test_listen_fallback_removal.py→ 36 passed.process_pending/recover_stale_in_progressthrough the same host seam Finalize pending conversations when a listen session ends inside the retry window #9960's regression tests established (no patching, no sys.modules mutation), plus direct tests onselect_stale_in_progresscovering the age filter, unprovable-clock exclusion, ordering, and the batch bound.make preflight(local lane, this PR body) → all selected checks pass.black --line-length 120 --skip-string-normalizationclean on the three changed files.cloud-orphan-recoveryscenario in the listen-pusher gauntlet (backend/testing/listen_pusher_stack/run.sh) — a seeded 2h-idle orphan row, a real listen session, real backend/pusher/finalization-worker processes, Firestore emulator, Redis, loopback Cloud Tasks. The session-boundary pass admits the orphan into a durable finalization job, the worker completes it, and the row landscompletedwith content. Full gauntlet (all six suites) passed locally. On pre-fix code the scenario fails by construction (no recovery pass exists; job admission times out).Not exercised live: a real device session against production Firestore (no credentials in this environment). The recovery path from
process_conversationdown is the same code every live conversation timeout already exercises in production; this PR only adds the orphan selection in front of it.