Repository navigation
fix(reprocess): keep restored discarded rows hidden until restore commits - #24927
Conversation
/reprocess persisted a kept verdict with discarded=False inside process_conversation, before the router's restore registered the recording obligation. A selected-app failure after that persist raised and skipped the restore, leaving a visible, kept recording with no obligation. process_conversation now takes restores_discarded from the router. For a discarded row being restored, the persist keeps discarded=True, so visibility waits for restore_discarded, which registers the obligation before it commits the metadata. The router flips the response's discarded flag from the restore result. Tests run the real router and real processor against the strict store, with only the model, app, Redis, and dream-marker boundaries stubbed. A selected-app failure leaves the row hidden with no obligation; a successful reprocess registers exactly one obligation and becomes visible. The failure case fails on the pre-fix code.
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.
1 issue found across 3 files
Confidence score: 4/5
test_reprocess_restore_visibility.pyraisesfailing_appduring ordinary reprocessing, so it does not cover the selected-app request it appears to target. Pass a valid selected app through the router and stub app validation as needed.
You’re at about 98% of the monthly reviewed-line limit. You may want to disable incremental reviews to conserve quota. Reviews will continue until that limit is exceeded. If you need help avoiding interruptions, please contact [email protected].
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/tests/unit/test_reprocess_restore_visibility.py">
<violation number="1" location="backend/tests/unit/test_reprocess_restore_visibility.py:95">
P2: This test never supplies an `app_id`, so `failing_app` is raised during ordinary reprocessing rather than a selected-app request. Pass a valid selected app through the router, stubbing app validation as needed, so the regression covers the explicit-app failure path it claims to test.</violation>
</file>
Reply with feedback, questions, or to request a fix.
View guided diff | Re-trigger cubic
| assert reprocess.rows[JOB_PATH]['state'] == 'record_pending' | ||
|
|
||
|
|
||
| def test_failed_selected_app_leaves_the_row_hidden_without_visibility(reprocess, monkeypatch): |
There was a problem hiding this comment.
P2: This test never supplies an app_id, so failing_app is raised during ordinary reprocessing rather than a selected-app request. Pass a valid selected app through the router, stubbing app validation as needed, so the regression covers the explicit-app failure path it claims to test.
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/tests/unit/test_reprocess_restore_visibility.py, line 95:
<comment>This test never supplies an `app_id`, so `failing_app` is raised during ordinary reprocessing rather than a selected-app request. Pass a valid selected app through the router, stubbing app validation as needed, so the regression covers the explicit-app failure path it claims to test.</comment>
<file context>
@@ -0,0 +1,107 @@
+ assert reprocess.rows[JOB_PATH]['state'] == 'record_pending'
+
+
+def test_failed_selected_app_leaves_the_row_hidden_without_visibility(reprocess, monkeypatch):
+ registrations = _count_restore_registrations(monkeypatch)
+
</file context>
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 9e7d543206
ℹ️ 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".
| if restores_discarded: | ||
| payload['discarded'] = True |
There was a problem hiding this comment.
Keep pending restores hidden across repeated reprocess attempts
If a selected-app failure leaves the first attempt unfinished, this write stores discarded=True together with sync_relevance_user_kept=True. On the next reprocess, persist_processing_result_with_lifecycle() in backend/database/conversations.py:1476-1479 unconditionally forces discarded=False when the existing row has that marker, overriding this new guard. A second selected-app failure therefore leaves a visible batch_live_v1 row with no recording obligation again. Keep pending restore authority distinct from a committed restore, or update the persistence merge rule, and cover two consecutive failing attempts.
Useful? React with 👍 / 👎.
| conversation, | ||
| trigger=ProcessingTrigger.USER_REPROCESS, | ||
| user_kept=was_discarded or user_kept, | ||
| restores_discarded=was_discarded, |
There was a problem hiding this comment.
Replay capture linking after the restore becomes visible
For an ungrouped discarded legacy capture that overlaps an already-completed recording from another device, this option keeps the stored row hidden while report_persistence() invokes link_duplicate_captures(). Both the duplicate-link transaction (backend/database/conversations.py:2925-2927) and capture-group join predicate (backend/database/capture_groups.py:89-90) reject discarded rows. The later restore_discarded() only restores metadata and does not replay the linker, so a successful reprocess now leaves an otherwise groupable pair as separate cards; a legacy restore also creates no batch obligation that could retry this work. Defer or replay the visibility-dependent completion hooks after the restore commits.
Useful? React with 👍 / 👎.
…essor (#24930) <!-- claude-projects-attribution: {"github_login":"Git-on-my-level"} --> _Requested by **David** · [project thread](https://claude.ai/code/project/chan_01DkCywHd8HiN61t59mu7kXF?thread=cmsg_01DkCywHd8HiN61t59mu7kXFReBVorHLQv1x1Xmz4fgMU8)_ ## What changed and why Test-only follow-up to #24927 (merged). This responds to cubic comment 4506407770 on #24927, which said the failing-app test in `tests/unit/test_reprocess_restore_visibility.py` never reached the explicit selected-app path. That was valid. The test never passed an `app_id`, and it replaced `trigger_conversation_apps` with a stub that raised `ExplicitAppSelectionFailedError` directly. The only raise site of that error is inside `if app_id:` in the processor, so the test was not exercising the explicit branch. The test now: - passes the selected app through the router (`app_id`); - stubs only the external boundaries: app validation and catalog lookups, the app model call (`get_app_result`), and the Firestore user timezone read that the app prompt needs; - lets the processor's real explicit-selection check raise, and asserts the HTTP error is chained to `ExplicitAppSelectionFailedError`. No production code changes. ## Product invariants affected - INV-MEM-4 - INV-TASK-2 ## How it was verified - The test file passes on the fixed code (origin/main at 5d6e9f9). - On the pre-fix code (2ca7a20, before #24927), the failing-app test fails with `assert False is True`, meaning the row was left visible. The success test still passes there. So the corrected test catches the bug it was meant to catch. - Unit gate (a): 39 files including this test, all passed. - `scripts/pr-preflight`: see the result below. ## Tests `tests/unit/test_reprocess_restore_visibility.py`, two tests: - Successful reprocess of a discarded batch row with a selected app: exactly one restore registration, the row becomes visible, and a `record_pending` job exists. - Selected app returns no summary: the real explicit-selection branch raises; the row stays hidden, with no restore registration and no recording job. ## UI evidence UI-Evidence: none -- backend change only <!-- This is an auto-generated description by cubic. --> <a href="https://cubic.dev/pr/BasedHardware/omi/pull/24930?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> <!-- End of auto-generated description by cubic. -->
Requested by David · project thread
What changed and why
This is a follow-up to #24896 (merged), per lead2's 812335 ruling, option B.
On
/reprocess, the processing persist wrotediscarded=Falsefor a kept verdict before the router's restore registered the recording obligation. A selected-app failure raised after that persist and skipped the restore. The result was a visible, kept recording with no recording obligation.The fix keeps visibility behind the restore:
process_conversationtakesrestores_discardedfrom the router. For a discarded row being restored, the persist keepsdiscarded=True.restore_discarded(registers the obligation, then commits the metadata). The response'sdiscardedflag reflects the restore result.Only the restore writes visibility for a discarded row. A selected-app failure now leaves the row hidden with no obligation, and a successful reprocess registers exactly one obligation.
Out of scope, per lead2's ed3b20: P2 C (the admission-time discarded fence in
batch_pipeline_intakeand thereplace_recorddiscard clearing). It is tracked separately for #24893's owner.Files:
backend/utils/conversations/process_conversation.py,backend/routers/conversations.py, and the newbackend/tests/unit/test_reprocess_restore_visibility.py.Product invariants affected
How it was verified
Gates ran on the exact head
9e7d5432061(on top of the #24896 merge commit2ca7a20228b):BACKEND_PYTEST_FILE_ISOLATION=1. 39 of 39 passed.backend/scripts/typecheck.sh): 0 errors.npm run test:listen-lifecycle:emulator): PASS.scripts/pr-preflight: see the result line below.Tests
tests/unit/test_reprocess_restore_visibility.pyruns the real/reprocessroute and the realprocess_conversationagainst the strict store. Only the model, selected-app, Redis, dream-marker, and app-output-write boundaries are stubbed.discardedread asFalse), so it catches the bug.record_pendingjob exists.The existing reprocess and restore suites (
test_reprocess_app_selection.py,test_restore_recording_obligation.py,test_discarded_fanout_replay.py) still pass unchanged.UI evidence
UI-Evidence: none -- backend change only
Failure class (fixes)
Failure-Class: FC-rule-discard-left-visible
The reprocess shortcut must persist a discard decision and its visibility atomically. Here the persist made a discarded row visible before the restore committed its obligation.
Line-Count-Exception: backend/routers/conversations.py | 2588 -> 2590 | 2-line restore-visibility change for the /reprocess fix (lead2 812335 option B); split deferred so the reviewed fix lands unchanged
Line-Count-Exception: backend/utils/conversations/process_conversation.py | 3403 -> 3408 | 5-line restores_discarded kwarg and persist guard for the /reprocess fix (lead2 812335 option B); split deferred so the reviewed fix lands unchanged
🤖 Generated with Claude Code