Repository navigation
Offload large transcripts to the encrypted object lake (default off) - #24811
Conversation
…ffline Co-Authored-By: Claude Opus 5.5 <[email protected]>
The rebase onto main picked up upstream body changes; the C2 codec additions still add no query. Co-Authored-By: Claude Opus 5.5 <[email protected]>
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 6c6c33e932
ℹ️ 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 self.currsize - previous_bytes + self.getsizeof(value) > self.maxsize: | ||
| raise TranscriptMemoBudgetExceeded('Transcript exceeds bounded decoded memo byte budget') |
There was a problem hiding this comment.
Evict unneeded memo entries during nontransactional reads
For pointer-backed lists or exports whose decoded transcripts cumulatively exceed 64 MiB within 120 seconds, this check raises even when every individual transcript fits the budget. Ordinary readers such as get_conversations and iter_all_conversations resolve transcripts sequentially without clearing the memo, so previously consumed entries cause the entire list/export to fail; retrying the same export encounters the same limit. Preserve the fail-on-budget behavior for transcripts required by a transaction attempt, but allow eviction or release of consumed entries outside transactions so the cache does not impose a cumulative size limit on otherwise readable results.
Useful? React with 👍 / 👎.
| segments = decode_transcript_segments_blob( | ||
| uid, raw, bool(data.get('transcript_segments_compressed')), require_decryption=True | ||
| ) | ||
| data['transcript_segments'] = transcript_pointer.offload_or_inline( | ||
| uid, data.get('id'), segments, lambda _: raw, conversation_state=data, current_state=current |
There was a problem hiding this comment.
Stabilize processing upload identity before sidecar encryption
With lake writes admitted, processing an existing shared/public conversation fails when the oversized incoming transcript carries grouping sidecars such as provider_speaker. Both lifecycle processing writers call _reapply_current_manual_assignments on every attempt, which reveals the sidecars and re-encrypts them with fresh nonces. This helper then decodes only the outer storage wrapper, so offload_or_inline computes its source digest from randomized sidecar ciphertext. Every replay therefore requests another upload instead of reusing the previous candidate, eventually raising TranscriptPointerFetchError('Transcript changed during bounded upload retries') without committing the processing result. Compute the retry identity from stable, revealed content before sidecar encryption while retaining the exact protected upload bytes.
Useful? React with 👍 / 👎.
# Conflicts: # backend/database/review_changes.py # backend/docs/people-generation-writers.json
… for the object lake (#24883) <!-- claude-projects-attribution: {"github_login":"Git-on-my-level"} --> _Requested by **David**_ ## What changed and why Give each new object-lake payload a random 256-bit DEK, wrapped locally with AES-KW under its versioned space key in the immutable 61-byte v2 header. Retain v1 reads, pointer schema, create-only retry semantics, shredding and rotation without re-wrap; add no per-object KMS calls. Allow dev deployment admission with real bucket/KMS bindings. Move the binding check into shared admission so runtime manifest validation enforces it. Production deployment still refuses enabled writes or positive percentages until C4 wipe coverage is green. No deployment values or flag defaults change. Persist content-free, create-only sweep candidates before each lake upload so a refused replay, superseded candidate, ambiguous response or worker loss cannot lose orphan discovery. Candidate-store failures refuse uploads. The serving path never deletes a replay candidate that another writer might reference. Follows #24811 (merged). Closes the fix-before-enable item lead2 recorded on #24811: replay-refused uploads no longer lose orphan discovery. ## Product invariants affected none ## How it was verified - Rebased on main after #24811: six focused lake, pointer, lifecycle, config, runtime-env and offload files, **612 passed, zero failed**. - Initial three focused files: **318 passed, zero failed**; environment preflight: **18 passed, zero failed**, eight optional warnings. Async scan: zero blocking findings. - Current C2-stack metadata validation: **4/4 passed**; full C2-stack preflight: **36/36 passed**. The broad selector is incomplete: **305/2,684 files have verified passing coverage; 2,379 remain uncovered**. Own broad test processes were stopped under sustained shared-host overload. No full-suite green claim. - Required main-base `make preflight`: **15 passed, one failed, three cancelled, 26 not reached**. The sole failure is the inherited synthetic-merge conflict in `backend/database/review_changes.py` and `backend/docs/people-generation-writers.json`. No rebase or unrelated conflict resolution is included. Main-base metadata: three passed, same one failure. Hermetic tests used this worktree's Python 3.11 venv with GOOGLE_APPLICATION_CREDENTIALS and CLOUDSDK_* unset before launch. GCP tier: none. No real KMS/GCS or deployed runtime acceptance claimed. ## Tests Real AES-GCM/AES-KW and filesystem storage cover v2 format, v1 compatibility, independent DEKs under forced equal nonces, corrupted/swapped wraps, unknown/truncated envelopes, warm-cache shredding, rotation without rewriting and unchanged KMS decrypt counts. Config/runtime/lifecycle tests cover dev admission, real bindings and the C4 production gate. Codec tests cover offload round trips, absent/shredded states and upload-fence replay. Orphan regressions cover both inline-refusal checks, privacy/lock/tombstone and kill-switch changes, domain refusal/error, bounded upload/preload exhaustion, superseded sources, deferred CAS failure, preservation of already-referenced objects, write-ahead ordering, invalid/missing candidate storage and ambiguous upload completion. ## UI evidence UI-Evidence: none -- backend only ## Failure class (fixes) Failure-Class: none ## Enable conditions The #24811 replay-refusal orphan item is closed by durable write-ahead sweep candidates: every put records its content-addressed bucket/key in `lake_upload_candidates` before upload, and candidate-store failures prevent the upload. Refused or superseded replays retain discovery without deleting an object another writer may reference. C3 must consume candidates only after fencing writers and proving absence of all live/historical references. The janitor is not implemented here; production enablement still requires C4 wipe coverage and the existing authorized provisioning/ramp conditions. ## Review fixes (round 1) - Bindings check parses `OBJECT_LAKE_WRITE_PERCENT` numerically: `0`, `0.0` and ` 0 ` admit no writes and need no bindings; unparseable values still require them (`test_enabled_write_binding_check_parses_percent_numerically`, contract file 63 passed). - Upload-candidate change note now states the extra read on the `AlreadyExists` race path. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
Requested by David
What changed and why
Long transcript_segments can be stored as encrypted object-lake pointers inside the existing field, through one codec shared by backend, listen, pusher, MCP, export and search. API responses still contain segment lists. Small or unadmitted transcripts retain the existing encoding.
Admitted transactional writes upload candidates outside Firestore, then replay the entire transaction and recompute the logical source digest before randomized grouping protection, from a fresh snapshot before publishing a pointer. The pointer hash and decoded memo always describe the actual uploaded JSON; transaction candidate puts cannot mask cold reads of existing pointers. This lets live in_progress transcripts cross Firestore's 1 MiB ceiling without an oversized inline commit. The boundary permits 32 read preloads plus 32 candidate uploads and three shared content changes (68 outer attempts). Its plaintext memo has a 32-entry/120-second cap and a 64 MiB decoded-object budget; budget failures are typed and retryable.
Transport/key availability errors abort reads and decisions; absent blobs are deleted transcripts and destroyed keys retain a distinct shredded state. Missing/shredded transcripts preserve photos and durable has_content signals during empty-recording cleanup. Malformed dictionaries, including empty ones, remain unreadable content and cannot authorize empty deletion. Missing bucket/release bindings close write admission; unset KMS deliberately selects the existing offline FakeKMS. Deep object verification returns False for destroyed keys and raises SpaceKeyUnavailable for unavailable keys; shallow verification checks metadata only.
O1: OBJECT_LAKE_WRITE_ENABLED stays off in prod until C4's wipe-coverage test is green. Ramp is dev-first via OBJECT_LAKE_WRITE_PERCENT and C1's existing registry plan. This PR adds no env binding, dependency upgrade, schema migration or index. The pusher and batch worker carry the required KMS dependency; existing lock versions are preserved.
C3 reuses offload_inline_transcript for revision-checked backfill and owns legacy re-encryption, orphan GC and registry/receipt; it must account for the memo ceilings before ramping backfill. C4 owns quiescing puts, prefix purge and key destruction last, preserving tombstones. B/W2 carries pointer changes as content-free doc changes. A6 ports the seam after C2. Public-chat's bounded decoder excludes pointer docs; treatment of existing long shared conversations remains a product decision before backfill.
Product invariants affected
none
How it was verified
Hermetic/local checks only; GCP tier: none. Every test command unsets GOOGLE_APPLICATION_CREDENTIALS, CLOUDSDK_* and inherited customer-service-account bindings. No production/customer-data access, api.omi.me calls, push, PR or deploy. Exact commands, source identities and individual receipts are in .agent-artifacts/pgf/c2-result.md.
Final focused verification: 243 tests passed, including all five round-3 review requirements. Full type checking reported 0 errors (75,544 warnings). Loopback checks passed listen lifecycle and 14 privacy tests; all owned emulator ports were verified closed. Runtime source closure passed all 19 registered images, third-party closure passed, all six locks regenerated without Git changes, and Black 26.5.1 passed all 50 changed backend Python files. Import-purity, test-isolation and async-blocker scans passed; the async scan's first 180-second agent deadline was insufficient, and its 900-second retry passed.
The full CI contract ran all 2,681 files: 2,679 exited 0 / 2 exited 1. The two unchanged live-provider files then passed in the same guarded runner with one worker: 134 passed / 3 slow cases deselected. The earlier Parakeet failure did not recur. After the final codec/cleanup corrections, 2,410 tests passed across 58 related source/caller files, in addition to the 243 focused tests. This reports cumulative coverage and isolated recovery of the timing failures, not a green exit from the original full-CI command. Rebase changed only two upstream firmware-CI files; the backend tree was byte-identical before/after. Frozen preflight passed all 43 checks in 110.16 s on
b937e5183f5274c2e6e3c78ccb526ae077a203d5; metadata validation passed 4 checks. Final codec type checking passed 0 errors / 258 warnings, and pinned Black rechecked all 50 changed backend Python files. Existing app edits were temporarily shelved for the gate and restored byte-for-byte. Docker image smoke is waived by fix-r1.md. The Docker offline-stack round trip remains unverified; real-router ASGI tests exercise pointer detail reads with 200/404/500 outcomes.Tests
backend/tests/unit/test_transcript_pointer.py pins round trips, flag-off golden encodings, compressed-byte thresholds, missing bindings, no lake IO inside transaction bodies, bounded read/upload retries, failed-upload non-commit, decode states, aggregate memo bytes, consent and C3 CAS.
backend/tests/unit/test_conversation_transcript_offload.py covers the transaction owners and reader surfaces, live writes above 1 MiB, source changes during upload, randomized grouping sidecars, exact memo/blob equality, invalid optional sidecars, kill-switch rechecks, photo/has_content retention, malformed-pointer cleanup, and destroyed/unavailable verifier keys. backend/tests/unit/test_object_lake_config.py retains the deterministic cohort contract with a configured bucket.
Decode/encode audits were rerun. Brief rows 1-19 use preload owners; finalization admission uses the approved contention wrapper; terminal cosmetics enforce a local no-IO guard. Recovery, agent-capability, projection and F-join reads are nontransactional. The voice_profiles encode is receipt-only, and transcript_files uses an id-less inline size measurement; neither can offload. Protection migration retains existing pointers. No reader is left relying on inline-only decoding except deliberately bounded public chat.
UI evidence
UI-Evidence: none -- backend only
Failure class (fixes)
Failure-Class: none
Scoped cleanups
Line-Count-Exception: backend/database/conversations.py | 4855 -> 4938 | Preserve domain transaction structure while adding pointer decoding and narrow unavailable-content refusals; codec mechanics live in transcript_pointer.py.
Line-Count-Exception: backend/database/conversation_finalization_jobs.py | 3549 -> 3551 | Wrap the existing admission owner in the transcript preload boundary without changing lead2 queue state.
Line-Count-Exception: backend/database/users.py | 2516 -> 2517 | Preserve the voice publication transaction and move its runner to the shared preload boundary.
Line-Count-Exception: backend/utils/sync/assignment.py | 1527 -> 1536 | Validate lake-pointer availability at the existing transaction load boundary before candidate or canonical selection.
Scope provenance: C1-result.md Review disposition assigned tombstones, decompression bounds and authority-read budgeting to C2; those inherited library changes remain in this branch. The inherited .github dead-code allowlist removal follows its own instruction to remove the entry when C2 adds its first caller; round 3 makes no .github edits. Round 3 extends scope only to config/object_lake.py admission and the existing cohort test setup, as required by fix-r2.md. Deep verification returns False for destroyed keys and raises SpaceKeyUnavailable for temporarily unavailable keys; shallow verification checks metadata only. C3 must account for both the 32-reference and 64-MiB operation ceilings before backfill.
Lead fix after review round 2: write admission now also requires OBJECT_LAKE_KMS_KEY unless OMI_ENV_STAGE is local/offline, so a deployed service can never write under FakeKMS. Remaining W5 notes: bounded parse before the memo budget check for very large transcripts; C1-owned object_lake/space_keys edits are lead-authorized C1 deferrals.
Enable conditions (lake writes stay refused outside local/offline until all hold)
🤖 Generated with Claude Code