Repository navigation
fix(lifecycle): reversible no-speech storage with exact restore (L6a) - #25060
Conversation
… custody Failure-Class: new
Codex Review Summary: ✅ CompletedThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 41e031adf5
ℹ️ 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".
| class Transaction: | ||
| def __init__(self, client): | ||
| self.client = client | ||
| self.has_written = False | ||
| self.write_results = [] |
There was a problem hiding this comment.
Use the required shared Firestore transaction fixture
These storage-boundary tests introduce a separate Firestore fake instead of the required tests.unit.fixtures.strict_firestore_transaction.StrictFirestore. Although this fake checks read-before-write ordering, it omits the shared fixture's value constraints and reference-ownership checks, creating a parallel transaction model that can certify behavior the repository's canonical guard rejects. Build these tests on the shared fixture; any additional revision/write-result semantics should be covered with the emulator before extending that fixture.
AGENTS.md reference: backend/AGENTS.md:L232-L232
Useful? React with 👍 / 👎.
| # Reversible no-speech terminal: hidden completed shape with a prior-value | ||
| # marker and an operator undo. No deletion, no content rewrite. | ||
| 'backend/database/no_speech_terminal.py', |
There was a problem hiding this comment.
Register the new storage entrypoints in the lifecycle call guard
The new storage module is allowlisted, but close_no_speech and restore_no_speech are missing from LIFECYCLE_METHODS, which is what visit_Call uses to reject storage calls outside the lifecycle owner. Checking violations with either new method called from backend/services/operator.py returns no errors, whereas the equivalent existing close_noise and restore_noise calls are rejected. Consequently, the guard does not enforce lifecycle ownership for the newly introduced transitions. Add both storage entrypoints to the guarded method set and cover their rejection outside utils/conversations/lifecycle.py.
Useful? React with 👍 / 👎.
Failure-Class: FC-irreversible-terminal-hide
Failure-Class: FC-irreversible-terminal-hide
…25063) ## What / why Supersedes #25042 (split per custody review). Depends on L6a #25060, now merged into main. Current origin/main (85de198) was merged normally before this coverage fix (both independently added feature flags retained in the merge conflict); no rebase or force-push. Strict local VAD, bounded newest-first discovery and digest-approved plan/apply/undo close stale batch-live captures reversibly. The operator requires complete versioned audio coverage before silence classification, isolates row refusals and recovers receipt loss while keeping undo independent of audio secrets/clients. No automatic caller or production operation is authorized. ## Product invariants Preserve row/audio/content bytes, prior-field presence snapshots, exact revision/run/shape fences, row/user privacy and the approved privacy generation inside the close transaction, counts-only CLI output, bounded newest-first pages and content-free dispositions. Known committed revisions keep their original exact fence. Complete sample coverage and byte-identical overlap deduplication precede VAD. Only missing/unknown receipts resolve the current matching marker before a current-revision-fenced restore. An edit between that read and restore refuses the write. Undo never starts audio, transcription or new cloud work. ## Pre-review dispositions - Second Luna FIX-FIRST at f13bab4 / DeepSeek P2-4 fixed: generation/metageneration-fenced raw listing snapshots must prove the entire timezone-aware row started_at/finished_at interval from versioned capture_start/capture_end, explicit gap_count=0 and decoded mono 16 kHz PCM frame counts. Canonical filename timing is the fallback for capture_start. The retained sample-range union helper limits total missing coverage (boundaries plus interior holes) to 20 ms / 320 frames. Identical overlap samples are included once; conflicting overlaps, unknown timing, gaps and unexpected out-of-range objects return coverage_incomplete with operator_review exit and aggregate counts. VAD only runs on the proven timeline. Apply reproof repeats the proof on its fresh listing, including added objects, before ledger preparation. Empty raw/legacy listings also refuse; historical no_retained_audio plans are non-actionable. Missing listing size/metageneration and failed download preconditions also refuse coverage. The first local Luna delta found the metadata race; it is fixed by passing the listing snapshot to canonical read_reference, with tests using the actual reader to assert both generation preconditions. Tests exercise gaps with no write, complete coverage, identical and conflicting/contained overlaps, numeric-string/filename timing, missing timing/internal gaps, cumulative tolerance and added/missing objects between plan and apply. - Luna FIX-FIRST at 2fc15c2 fixed: the operator passes the approved privacy generation through the lifecycle intent into close_no_speech/_close_txn. The transaction reads the canonical hashed privacy authority before writing and refuses privacy_changed on mismatch, including consent revoke/re-enable after reproof. Optional None preserves L6a direct-caller behavior. Regression runs actual reproof, changes generation at ledger preparation, and proves no conversation write/receipt. Matching, absent-generation-zero and omitted-generation contracts are also tested. - B P1-1 fixed: upload_pending and privacy_skipped have exits. Disposition/exit validation is inside the row failure boundary; unknown labels normalize to proof_refused. Mixed-page tests preserve later actionable rows and counts-only reporting. - B P1-2 / custody P2#1 / A P2-1 fixed: storage returns committed_revision_unknown when the SDK omits its result, and the ledger records it distinctly. Undo includes prepared-only entries, re-reads the row, proves marker.run_id plus completed/discarded/terminal_no_derived_effects, and fences restore on the current revision. Known receipts remain exact-revision fenced. Tests cover actual empty write_results, prepared-only crash recovery, foreign/changed shapes and a concurrent edit after resolution. - Custody P2#2 / B P2-6 fixed: undo requires neither ENCRYPTION_SECRET nor a storage client. The CLI loads planning/audio dependencies only after choosing the non-undo path. Restore uses the lightweight lifecycle-owned intent. Fresh-process tests remove the secret and block all network/audio dependency loading. - B P2-7 fixed by an explicit one-ledger-per-page contract: exclusive creation remains, reuse cannot overwrite a partial ledger, and recovery uses the old page's ledger before replanning with a new path. No append/resume behavior is added. - B P2-14 fixed: table tests cover wrong tiers, emulator refusal, page/pace bounds, missing apply approval/ledger, forbidden undo cursors, identical cursor files, undo dry-run, ledger mode/symlink/existing-path refusals. - A P1-1/P1-2 and P2-5 are included through L6a: canonical close privacy, lifecycle tripwire, and deliberately privacy-unblocked owner restore. A's improved no-delete assertions also resolve B P2-12's ineffective mock. Follow-ups (non-blocking review P2s): B P2-1 absent-owner-document defense; P2-2 discovery age cutoff; P2-3 last-scanned cursor progress; P2-5 pre-extend memory budget; P2-8 undo offsets if ledger bounds ever change; P2-9 restored-event receipts; P2-10 finished_at convention; P2-11 server close timestamp; P2-13 end-to-end raised-privacy fidelity; remaining P2-15 broad unexpected/receipt-fsync error classification (prepared recovery is now available); P2-16 re-decode duration/cost disclosure. L6a's remaining P2-2/3/4/6/7/8 are listed in #25060. These are not implemented by this batch. ## Tests This coverage batch runs backend/test.sh through omi-heavy with credential overrides removed and offline providers: test_no_speech_coverage.py, test_no_speech_operator.py, test_no_speech_terminal.py, test_record_partial.py, test_source_audio_listing.py and test_record_orphan_repair.py. Result: 270 passed (19 coverage, 57 operator, 32 storage, 67 partial-retained, 8 source listing, 87 orphan repair). Both fresh-process secret-free undo modes remain covered. Full local preflight passed all 43 checks. Luna delta on 93ac677: SHIP, no concrete remaining findings; read-only source review, no tests run by the reviewer and no merge approval. Full pre-push hook passed, including all 108 storage/operator/coverage tests. Exactly one normal push in this coverage batch; no force or hook skips. ## UI-Evidence none — no UI code change; existing Home filtering is covered with actual closed rows. Failure-Class: FC-irreversible-terminal-hide FC-irreversible-terminal-hide is defined by merged L6a and guarded by both no-speech suites, including the transaction privacy-generation race regression. ## Rollback Disable new closes with NO_SPEECH_TERMINAL_ENABLED=false. Keep it false while using --undo --apply with each private page ledger. Prepared-only/unknown receipts resolve the matching marker; known revision conflicts require separately reviewed manual recovery, preserving unrelated edits and all audio/content. Revert code only after restoring rows. No production apply is authorized here. ## Capacity numbers and state exits Operator bounds carried from #25042: MAX_AUDIO_SECONDS initial 7200; MAX_RAW_OBJECTS initial 4096; discovery limit initial 128 (range 1..128); GCS page_size initial 200; pace initial 0.5 seconds (range 0.1..60). Speech threshold remains strictly below 10 seconds. New fixed coverage policy: TOLERANCE_FRAMES initial 320 (20 ms at 16 kHz), cumulative across boundaries and interior gaps; zero prior coverage checks are replaced by mandatory complete-coverage proof. No runtime tuning flag is added. No serving capacity change. State no_speech exits through restore_no_speech. Outcome committed_revision_unknown exits through private-ledger marker resolution and fenced restore. coverage_incomplete exits by operator review and only a fresh coverage-proven plan can become actionable; empty-list no_retained_audio plans no longer close rows. Upload-pending rows stay untouched for operator review; privacy-skipped rows exit by operator rerun after consent.
What / why
Supersedes #25042 (split per custody review). L6a provides the lifecycle-owned reversible no_speech storage transition, exact restore, existing Home hiding and writer inventory. L6b #25063 supplies the operator. No decoder, automatic caller or production operation is included here.
Product invariants
Preserve all row/audio/content bytes. Snapshot lifecycle field presence and values; close requires expected update_time and canonical row/user privacy. Restore refuses foreign runs, changed generations and invalid closed shapes. Quiet checks remain untouched by close/restore. Existing Home discarded filtering hides closed rows; compliance/export retains access.
Pre-review dispositions
Follow-ups (non-blocking review P2s): A P2-2 storage-level kill switch; P2-3 full recovery-admission/protected-content/account-deletion parity; P2-4 deterministic orphan-finalization-job fence; P2-6 prior-marker value validation; P2-7 bounded uid/cid validation; remaining P2-8 malformed snapshot, wrapper, repeated-restore and RFC3339 fidelity cases. These are not implemented by this batch.
Tests
Repository backend/test.sh via omi-heavy, offline with credential overrides removed: test_no_speech_terminal.py, test_check_conversation_lifecycle_writes.py, test_lifecycle_state_table_writers.py, test_batch_privacy_conversation_fence.py and test_conversation_quiet_finalization.py. Final result: 1,920 passed across five files, including 28 storage cases and 18 lifecycle guard cases. Full preflight and full pre-push hook passed; exactly one normal push for this fix batch, without force or skipped hooks.
UI-Evidence
none — no UI code change; actual closed-row visibility is covered locally.
Failure-Class: new
FC-irreversible-terminal-hide is introduced by the overall PR and guarded by the storage and lifecycle suites.
Rollback
Stop new callers; restore unchanged closed rows with their matching run/revision (L6b can resolve missing receipts from the private ledger), then revert code. Never delete rows/audio. Restore stays available after privacy opt-out and does not initiate cloud work.