Repository navigation
fix(backend): fail keyword privacy cleanup open when Typesense is unconfigured - #23063
Git-on-my-level wants to merge 2 commits into
Conversation
Codex Review SummaryThis 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: 4114fe6731
ℹ️ 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".
…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.
…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.
bf1005d to
d88a443
Compare
|
Review repair pushed for both Codex threads on
Verification: |
|
Autonomous repair exhausted (review failed 3x (timeout)); 0 fixup rounds, attempt 3/3. PR left OPEN for human triage.\n\nLast findings excerpt:\nreview failed 3x (timeout) |
1 similar comment
|
Autonomous repair exhausted (review failed 3x (timeout)); 0 fixup rounds, attempt 3/3. PR left OPEN for human triage.\n\nLast findings excerpt:\nreview failed 3x (timeout) |
|
Folded into #24602 (the consolidation of this batch onto the age-gate survivor branch |
|
Hey @Git-on-my-level 👋 Thank you so much for taking the time to contribute to Omi! We truly appreciate you putting in the effort to submit this pull request. After careful review, we've decided not to merge this particular PR. Please don't take this personally — we genuinely try to merge as many contributions as possible, but sometimes we have to make tough calls based on:
Before your next PR, please skim:
If this was declined for direction or taste, maintainers should cite an invariant ID or open a proposed one — ask if that citation is missing. Your contribution is still valuable to us, and we'd love to see you contribute again in the future! If you'd like feedback on how to improve this PR or want to discuss alternative approaches, please don't hesitate to reach out. Thank you for being part of the Omi community! |
… the age-gate survivor branch (#24602) * fix(memory): retry transient store faults on canonical apply control 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 * fix(memory): bound each retry attempt and recheck the deletion fence; 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. * fix(tests): shared Firestore fakes accept the retry/timeout read 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. * fix(tests): remaining per-file Firestore fakes accept retry/timeout read 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. * fix(memory): recheck fence before existing-state return; bound fence 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. * fix(memory): give fence reads the same transient budget; module-scope 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. * fix(backend): fail keyword privacy cleanup open when Typesense is unconfigured 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 * fix(backend): scope keyword privacy fail-open to fully-unconfigured Typesense 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. * feat(memory): stale-planner archive restore operator tool (2026-10-22) 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]> * fix(conversations): require relevance decisions on terminal rows 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 * refactor(conversations): extract terminal storage and relevance labels 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 * fix(conversations): stamp local fixture capture decisions 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 * fix(conversations): refresh terminal visibility after commit 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 * fix(conversations): preserve positive evidence during terminal repair * fix(conversations): retain recovery provenance when repairing keeps * fix(conversations): preserve terminal verdicts and bound calendar probes * fix(conversations): satisfy type checker on terminal decision sites 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. * test: allowlist structural first-test CPU in terminal-decision suites * test: allowlist the 70-minute narration fixture's first-test CPU * fix(conversations): compose terminal decisions with wave-2 lifecycle * style: pin the pinned formatter on test_recovery_rule_skip * test(sync): align frozen parity with mandatory intake decisions * fix(memory): invalidate projections on every committed retry * Reconcile fold interactions with current main contracts - 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 * Restore origin/main's enrichment recovery emulator script 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. * Fix CI-red fold interactions against current main contracts - 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 * Classify the crash-window keep flag in the firestore query driver * chore: retrigger PR workflows after a missed synchronize event * Match the folded dead-letter keep receipt in the exhausted-requeue test * Keep transcription-failed episode members in the home member projection 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. * Declare the diarization eval lifecycle writers in the site inventory #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. --------- Co-authored-by: David Zheng <[email protected]> Co-authored-by: GLM-5.3 <[email protected]>
Error group
Root cause
_run_immediate_privacy_cleanup(backend/utils/memory/canonical_memory_adapter.py:3382) raisesRuntimeError: canonical keyword privacy cleanup unavailablewheneverdelete_atom_keyword_docreturns False. That helper constructs the shared Typesense client lazily from
TYPESENSE_HOST/TYPESENSE_API_KEY; on a deployment where those env vars are absent or empty(this repo's deploy matrix produces such deployments — e.g.
gcp_notifications_job.ymlexplicitly strips
TYPESENSE_HOST/TYPESENSE_HOST_PORT/TYPESENSE_API_KEY, and the backendworkflows bind
vars.TYPESENSE_HOST, which renders empty when unset), client constructionraises, the generic
exceptswallows it, and the delete returns False. Privacy cleanup thenfails closed forever on a projection that deployment never writes, so every explicit memory
delete / privacy purge on that deployment raises.
This is the keyword-projection recurrence of
FC-privacy-delete-fails-on-unprovisioned-derived-store: #15097 gave the vector-store sibling
(
delete_canonical_memory_vectors, called one line above) the "unconfigured store = triviallyconfirmed absence" classification, but the Typesense keyword delete never got it — the module
even defines
typesense_configured()without using it on this path.Fix
delete_atom_keyword_doc(backend/utils/memory/atom_keyword_index.py) now classifies"Typesense not configured" as the trivially-confirmed desired absence: log and return True
before any client I/O, mirroring the #15097 vector-store fix. A configured client that raises
still fails closed (returns False → RuntimeError → durable outbox retries), and the empty
uid/memory_id input check still returns False.
All callers treat the return value as "the projection converged to absence", which is
trivially true when the projection is never provisioned:
_run_immediate_privacy_cleanup(this error group),sync_atom_keyword_index_for_item, andshort_term_promotion._delete_atom_projection_and_citations.Verification
The regression test deletes
TYPESENSE_HOST/TYPESENSE_API_KEYand stubs the client handleto raise if constructed, asserting the delete confirms absence — per the failure class's
canonical prevention (stub the handle to its unconfigured state, don't remove it).
Product invariants affected
Neither invariant is violated: the keyword projection stays a non-authoritative projection,
and this change only converges it to absence on deployments that never write it; no restricted
content is sent to any provider.
Failure-Class: FC-privacy-delete-fails-on-unprovisioned-derived-store