Repository navigation
fix(backend): restore Store recovery cancellation (SCA-1689; fixes #23761) - #23806
Conversation
b8b4984 to
9e0b1a6
Compare
|
Verdict: the fix direction is right and the implementation is faithful — this resolves the #23761 AttributeError by giving every Store a bounded, revocation-only Correctness, verified statically on 9e0b1a6:
One regression to fix before merge:
Tests and docs:
Coordination: this test file will conflict with open #23763 (same file with strict xfails); since this PR supersedes the fix plus un-xfail, #23763 should be closed or rebased. Minor: the PR summary lists Security: privacy-positive — deletion durably cancels prepared/running recoveries on every backend before paid work or result upload, and the write stays revocation-only and fenced. Blast radius: recovery-coordinator cancellation path only; ordinary job writes are unaffected. USER IMPACT: none today (Firestore already cancelled correctly); this prevents deleted-account audio from being re-processed once the Postgres store goes live. Still wanted before merge: the Leaving for human maintainer review: the privacy-fenced recovery-cancellation semantics and the A2 shadow-mirror behavior change on the production Firestore path need maintainer sign-off. AI-generated feedback on behalf of the maintainers. by AI on behalf of David — if you need David’s attention urgently, please @Git-on-my-level and escalate with |
|
Thanks for the thorough review @Git-on-my-level!
|
|
Verdict: the production fix is correct, tightly scoped, and implements exactly the resolution #23761 asks for; two coordination/verification notes for maintainers below. Correctness, per file:
Security: the new paths are revocation-only. Both methods re-run the privacy fence and write only the cancel marker when the fence blocks; they cannot bypass the fence, mutate other fields, or perform external IO. Verification: Backend Emulator Proofs on this head includes the new suite (sim + emulator green) and the unit, hermetic-merge, formatting and hygiene checks all pass. The Postgres leg skips in CI by design ( Coordination: the test file, docs section and proof-script line overlap the still-open #23763; whichever lands second will need a rebase. The production fix here is the piece #23761 actually requires, so maintainers should pick the landing order deliberately. USER IMPACT: none — internal backend change. The user-visible effect is privacy correctness: deleting an account mid-recovery now durably cancels the in-flight recovery on every backend instead of erroring out on Postgres. Leaving for human maintainer review: landing-order decision versus #23763 and sign-off on the privacy-fenced recovery write path. by AI on behalf of David — if you need David’s attention urgently, please @Git-on-my-level and escalate with |
|
Hi @Git-on-my-level @kodjima33 |
aryanorastar
left a comment
There was a problem hiding this comment.
Approved ad38c720c1de8e2af13603b5289f9b18598129a4. backend/database/jobstore/postgres_store.py on main has no cancel_fenced_recovery. This head adds the store method and Hygiene succeeded.
Carry PL-057, PL-072 and PL-086 through the shared Store matrix. Keep the new-store cancellation gap strict and linked to issue BasedHardware#23761. Co-Authored-By: Claude Opus 5.5 <[email protected]>
30020a9 to
9f393e2
Compare
|
Since my last review: addressed (shadow-mirror regression — mirror_refresh is restored inside FirestoreStore.cancel_fenced_recovery, verified on the current head) · still open (no attached OMI_REQUIRE_STORE_BACKENDS=all run output; landing order vs still-open #23763) · newly observed (branch history was rewritten on Oct 31 via automated "ARIA" self-healing pushes — I re-verified the current head directly rather than relying on those messages). Verdict: the production fix is correct, tightly scoped, and implements exactly what #23761 asks for. What is still missing is runnable proof of the new conformance suite on this head. Re-verified on the current head, per file:
Security: both new paths are revocation-only — the privacy fence is re-run inside the transaction and the only write is the cancel marker; no external IO, no fence bypass, no new data exposed. Verification gap: no check on this head executes test_recovery_admission_conformance.py. The unit shards run tests/unit only, the guardrails leg is deferred on fork PRs until a maintainer adds ci:full, and the Postgres backend skips in CI by design — so the "42/42" local result and the ARIA self-healing messages are currently the only evidence, and neither is verifiable from CI. USER IMPACT: deleting your account mid-recovery now durably cancels that in-flight recovery on every backend instead of erroring out on Postgres; no other visible change. Still wanted before merge:
Leaving the merge decision to a human maintainer: the open calls are the #23763 landing order and final sign-off on the privacy-fenced cancellation write. by AI on behalf of David — if you need David’s attention urgently, please @Git-on-my-level and escalate with |
## Summary Canonical re-cut of #24042 on current `main` (`72d5dfdc671a2ccb0ffbb983785e995d8bdaa507`). Head: `6a634c9706cd4f84d20cc492be8662f8ef5dc1b4`. This replaces f-string interpolation at all 13 assigned composition sites with `psycopg.sql` identifiers, literals, and typed literal SQL fragments. Runtime values remain query parameters. A single public `database.jobstore.connection.sql()` accessor preserves the lazy-postgres-driver invariant, and `_fenced_update` now types its SQL fragments as `LiteralString`. This is defense in depth, not a claim of a live exploit: the existing call paths already gate table/column choices through fixed allowlists, validated priorities/pools, or internal constants, as the reviewers of the overlapping PRs noted. Failure-Class: none ## Sites fixed - `backend/database/jobstore/postgres_store.py:261` — `due()`: quote the selected due column in both predicate and ordering. - `backend/database/jobstore/postgres_store.py:404` — `control_candidates()`: quote every priority/pool-derived column reference. - `backend/database/jobstore/postgres_store.py:508` — typed `read_doc()`: compose the table identifier and lock suffix. - `backend/database/jobstore/postgres_store.py:541` — `write_doc()`: quote the typed table identifier. - `backend/database/jobstore/postgres_store.py:556` — `delete_doc()`: quote the typed table identifier. - `backend/database/jobstore/postgres_store.py:569` — `service_frontier_in()`: quote the priority-derived column. - `backend/database/jobstore/postgres_store.py:593` — `purge_namespace()`: quote every cleanup table identifier. - `backend/database/jobstore/backfill.py:60` — `postgres_keys()`: quote the typed table identifier. - `backend/database/jobstore/outbox_pg.py:169` — `claim()`: compose the fixed `RETURNING` column list. - `backend/database/jobstore/outbox_pg.py:202` — `claim_key()`: compose the fixed `RETURNING` column list. - `backend/database/jobstore/outbox_pg.py:255` — `_fenced_update()`: compose only `LiteralString` set/guard fragments; keep claim data bound. - `backend/testing/pipeline_sim/postgres_store.py:35` — `PgRows._all()`: compose each typed table as `Identifier` and its projected name as `Literal` across the `UNION ALL`. - `backend/testing/pipeline_sim/postgres_store.py:210` — simulator `delete()`: quote the typed table identifier. `backend/database/jobstore/connection.py:28` adds the single lazy `psycopg.sql` accessor. The two simulator hunks are folded in from #24015. None of #24042's unrelated `commit_message.txt`, `test_sql.py`, or `.agent-brief/firestore-index-guard/tests.txt` files are carried over. ## Tests New hermetic behavioral coverage exercises every site above with hostile identifiers/values, verifies parameter tuples never enter rendered statement text, checks the outbox produces real `psycopg.sql.Composable` statements, and imports every changed module in clean subprocesses where `psycopg` is explicitly unavailable. Focused pytest runs (one process per file): | Test file | Result | | --- | ---: | | `test_jobstore_sql_composition.py` | 18 passed | | `test_jobstore_backfill.py` | 11 passed | | `test_jobstore_dual_store.py` | 68 passed | | `test_jobstore_migrations.py` | 7 passed | | `test_jobstore_postgres_locking.py` | 10 passed | | `test_jobstore_projection_mirror.py` | 8 passed | | `test_jobstore_protocol_parity.py` | 69 passed | | `test_jobstore_shadow_seams.py` | 23 passed | | `test_jobstore_codec.py` | 2 passed | | `test_batch_pipeline_lock_jobstore.py` | 2 passed | Total: **218 passed**. No full-suite or live-service run was used. - `bash backend/scripts/typecheck.sh`: **0 errors**. - `scripts/backend-python-format --check ...`: **7 files unchanged**. ## Supersedes and follow-up - Supersedes the original #24042 and overlapping #24015, #24023, and #24037; #24015's unique simulator coverage is retained here. - #24037's module-level psycopg import and #24015's private `_psycopg()` access are both avoided by the public lazy accessor. - #23806 must rebase after this merges and obtain fresh exact-head review; its recovery work is otherwise orthogonal. <!-- This is an auto-generated description by cubic. --> <a href="https://cubic.dev/pr/BasedHardware/omi/pull/25116?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/25116?returnTo=https%3A%2F%2Fgithub.com%2FBasedHardware%2Fomi%2Fpull%2F25116&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. -->
Co-authored-by: multica-agent <[email protected]>
Fixes #23761
Restores the recovery-cancellation prerequisite tracked by SCA-1689. Account deletion during recovery now durably cancels the prepared or running recovery through the shared Store interface before paid work or result upload on Firestore, Postgres, and the simulator.
The coordinator delegates to
cancel_fenced_recovery; each adapter rechecks the privacy fence and changes only the cancellation marker when blocked. Firestore refreshes the shadow after commit. Main is merged into the existing branch without rewriting its history, retaining the SQL identifier hardening from #25116 and the newer privacy-defer methods. The overlapping #23763 is already closed.Verification
Run from
backend/under a loopback Firestore emulator, with a throwaway local Postgres cluster and synthetic customer authority:OMI_REQUIRE_STORE_BACKENDS=all .venv/bin/python -m pytest -v -rxX -p no:cacheprovider tests/integration/test_recovery_admission_conformance.py: exit 0, 27 passed; all three adapters, no skips or xfails. PL-057/072/086 cover cancellation before recovery and after download, restart/redelivery, no paid calls or result uploads, and unrelated-owner progress. Only the PL-072 strict xfails whose contract now passes were removed.OMI_REQUIRE_STORE_BACKENDS=all .venv/bin/python -m pytest -q -rxX -p no:cacheprovider tests/integration/test_store_conformance.py tests/integration/test_recovery_custody_conformance.py: exit 0, 267 passed, 6 adapter-specific not-applicable skips; every adapter available.backend/.venv/bin/python -m pytest -q -p no:cacheprovider backend/tests/unit/test_batch_pipeline_scheduler.py: exit 0, 62 passed.This source repair books $0/day. Production serving parity, cross-database privacy safety, physical erasure, reverse migration/rollback, pooler readiness, deployment/readback, production-fence decisions, and a full settled before/after day of normalized net cost remain separate gates owned by the pipeline driver and SCA-1683. Existing dark/staging selectors and production fences remain in force.
Product invariants affected
none
Failure-Class
Failure-Class: none
UI-Evidence
UI-Evidence: none -- internal recovery Store integration and conformance evidence.