Repository navigation
fix(backend): complete empty JIT snapshot when admitted owner has no memory head - #12391
Merged
Merged
Conversation
…memory head An admitted owner whose memory_state/head is proven absent (never initialized memory v3) now gets a complete, empty watchlist with a deterministic revision instead of an incomplete generation_unavailable receipt. Desktop Beta reconciles only complete snapshots, so dogfood accounts on dev Firestore (no head, no generation) could GET the snapshot but never persist a receipt. Absence is still certified only after it is proven: a trailing head re-read must still show the head missing, and unproven absence (read failure, malformed head) keeps the incomplete receipt. The generation fence stays monotonic: when a real head later appears at a higher account_generation, reconcile treats it as a new authority epoch. Non-admitted owners keep the rollout_not_enabled stub. Verified against Swift JITTriggerMirror.reconcile: head_commit_id is never validated (empty string is stored as-is); complete=true, non-empty snapshot_revision, owner match, and generation/sequence >= 0 are the acceptance preconditions. Co-authored-by: multica-agent <[email protected]>
Git-on-my-level
added a commit
that referenced
this pull request
Aug 31, 2026
## What changed and why Bind JIT admission on every GCP `dev` evaluator (GKE listen, Cloud Run listen, maintenance), then make first-open, ledger writes, empty-watchlist suppress, drain, and public-docs hygiene correct before flipping `jit-processing-v1` to 100% of Omi Beta / TestFlight. Empty-extraction 500s already landed in #12410. Production `api.omi.me` PostHog is unchanged. ## Product invariants affected - INV-AGENT-* - INV-DATA-1 - INV-MEM-1 - INV-MEM-4 - INV-TASK-2 ## How it was verified - `backend/.venv/bin/python -m pytest backend/tests/unit/test_backend_runtime_env_validator.py backend/tests/unit/test_conversation_jit_processing.py backend/tests/unit/test_first_open_effect_resume.py` — 131 passed after rebase onto `origin/main`. - `python3 .github/scripts/check_agent_doc_references.py` and `check_agents_md_lean.py` — OK. - `python3 backend/deploy/compose_runtime_env.py` — generated `runtime_env.yaml` matches overlays (dev TZ recon on, prod off). - Did not deploy to GCP `dev` or flip PostHog in this PR. After merge: probe a non-allowlist Beta UID, then operators flip `jit-processing-v1` to 100% on the **dev** PostHog project only. Keep the two-UID allowlist until soak. ## Tests - Runtime-env compose requires PostHog + `OMI_FIRESTORE_DATA_PLANE_PROJECT` on listen/maintenance. - `force_process=True` still defers folders/apps when rollout admits; `bypass_jit_first_open` is the explicit reprocess hatch. - Empty folders initialize then assign; first-open never `complete('folder_assignment')` on a skip. - Ledger writes use the data-plane client; unknown preference slots stay unslotted. - macOS/Windows: complete empty watchlist suppresses; incomplete snapshot consumes the visit; Insight stays gated. - Cron skips `writer_mode=ledger` dreaming; sweep continues after one unknown slot. ## Failure class (fixes) Failure-Class: FC-rollout-flag-absent-from-a-cohost-of-its-code-path Enabling `jit-processing-v1` while GKE/Cloud Run listen and maintenance lacked `POSTHOG_PROJECT_API_KEY` (and GKE listen lacked the data-plane overlay) would have produced two behaviours for the same UID: Cloud Run chat/sync admitted, listen finalized as `configuration_missing`. ## Test plan After merge, deploy this PR to GCP `dev`. Probe a **non-allowlist** Beta UID: 1. `GET /v1/jit/rollout-decision` on desktop-backend and Cloud Run `backend` → same `effective=enabled` once the flag is on for that UID (PostHog override before 100% is fine). 2. Live-finalize via GKE listen: logs are not `configuration_missing`; first-open attaches. 3. Kill-switch drill on **dev** PostHog, including allowlist, then off. 4. Chat `create_standing_trigger` appears on Mac **and** Windows snapshots. 5. Empty ledger: no ambient nano/full; Windows does not run Insight. 6. Empty extraction conversation is 200. Then flip `jit-processing-v1` to 100% on the **dev** PostHog project. Watch writer_mode drain; do not claim extraction is off until `ledger` is the majority. Keep the two-UID allowlist until soak. Windows TestFlight floor is builds that include #12381 / #12391 / #12397; older apps keep the legacy loop and cannot be remotely disabled. ## Line-count exceptions Oversized files grew by the JIT admission/sweep patches; splitting them is out of scope for this Beta-readiness PR. Line-Count-Exception: backend/routers/conversations.py | 1955 -> 1956 | pass bypass_jit_first_open through create/finalize without splitting the router Line-Count-Exception: backend/utils/conversations/process_conversation.py | 2561 -> 2572 | add bypass_jit_first_open so force_process stays a lazy-desktop hatch, not a JIT bypass Line-Count-Exception: backend/utils/memory/canonical_memory_adapter.py | 3491 -> 3496 | keep empty replace_conversation_source a no-op after #12410 rebase Line-Count-Exception: backend/utils/memory/daily_memory_sweep.py | 4994 -> 5008 | unknown-slot ValueError skips that candidate instead of aborting the day Line-Count-Exception: backend/utils/sync/pipeline.py | 2527 -> 2528 | reprocess path sets bypass_jit_first_open <!-- This is an auto-generated description by cubic. --> <a href="https://cubic.dev/pr/BasedHardware/omi/pull/12452?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="Review in cubic" src="https://www.cubic.dev/buttons/review-in-cubic-dark.svg"></picture></a> <!-- End of auto-generated description by cubic. -->
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Admitted JIT trigger snapshot must be complete even with no memory head
Problem
Desktop Beta (0.12.241 / 12241) on the dev data plane:
GET /v1/jit/rollout-decisionreturns 200 and the client treats the lane as on, butGET /v1/jit/trigger-snapshotreturns a 748B incomplete envelope and the localjit_trigger_snapshot_receiptstable stays at 0 rows.Dev Firestore has no
memory_state/headfor these dogfood accounts (Beta Auth is prod, the data plane for this API is dev).read_authoritative_trigger_snapshottreated the missing head asgeneration_unavailable→complete=false, empty ids, default policy. The Swift clientJITTriggerMirror.reconcilediscards incomplete snapshots on purpose (requirescomplete == trueand non-emptysnapshotRevision), so an admitted user could fetch the snapshot but never persist a receipt — dev Beta can never exercise the JIT lane.Change
When the rollout admits work (
permits_work) and thememory_state/headdocument is proven absent (MISSING_STATE_HEAD— the query ran and the doc does not exist),read_authoritative_trigger_snapshotnow returns a complete empty watchlist instead of the incompletegeneration_unavailablestub:complete=true,rows=[],failure_reason=nullowner_id= authenticated uidaccount_generation=0,commit_sequence=0,head_commit_id=""snapshot_revision= deterministic sha256 ofempty-watchlist:{uid}:0(64 hex, stable across serves)Certification discipline is preserved:
authority_changedfence): if a head appeared mid-read, the snapshot stays incomplete (generation_unavailable) and the client picks up the real snapshot on the next poll.generation_unavailablereceipt. No fake complete.rollout_not_enabledincomplete stub (router gating unchanged).account_generation, Swiftreconciletreats it as a new authority epoch and accepts it.Verified against the Swift client contract (
JITTriggerMirror.reconcile):headCommitIDis decoded as a plainStringand never validated for emptiness; acceptance requirescomplete, matching non-emptyownerID, non-emptysnapshotRevision,accountGeneration >= 0,commitSequence >= 0, and a valid policy — all satisfied. Same(generation, sequence, revision)on repeated syncs is idempotent (noconflictingRevision).Tests
head_reads == 2)generation_unavailable(no certification of a torn absence)generation_unavailabletest_jit_trigger_snapshot.py(16),test_jit_rollout.py(34, incl.rollout_not_enabledstub),test_jit_first_open_policy.py+test_jit_ledger_snapshot.py(52),test_jit_proactivity_store.py+test_jit_proactivity_eval.py(26)Failure-Class: new
Adds
FC-proven-empty-rendered-as-denial— the mirror ofFC-denial-rendered-as-empty-success: a proven-empty authoritative state (the head query ran and the document is absent) was served as an indeterminate incomplete receipt that correctness-gated clients must discard, so a legitimately empty account could never persist its snapshot receipt. Guard artifact: the reader plus its behavioral tests.Product invariants affected
Unblocks SCA-372 (dev Beta dogfood: allowlisted users can GET the snapshot but cannot persist a receipt).