Repository navigation
feat(storage): per-object DEK envelopes and durable upload candidates for the object lake - #24883
Merged
Merged
Conversation
Deployment validation alone left drifted runtime settings able to write in production before the C4 wipe-coverage gate. Runtime admission now allows only local, offline and dev stages; unknown stages are refused. Co-Authored-By: Claude Opus 5.5 <[email protected]>
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.
All reported issues were addressed across 11 files
You’re at about 94% of the monthly reviewed-line limit. You may want to disable incremental reviews to conserve quota. Reviews will continue until that limit is exceeded. If you need help avoiding interruptions, please contact [email protected].
Reply with feedback, questions, or to request a fix.
View guided diff | Turn on auto-fix | Re-trigger cubic
A zero cohort written as 0.0 no longer demands bucket and KMS bindings; unparseable values still do. Document the extra candidate read when concurrent first puts race. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Git-on-my-level
added a commit
that referenced
this pull request
Nov 11, 2026
…conversation deletion (#24897) <!-- claude-projects-attribution: {"github_login":"Git-on-my-level"} --> _Requested by **David**_ Builds on the merged per-object DEK foundation (#24883). ## What changed and why Account wipe requires a verified lake prefix purge after the cell/directory step and before Firestore deletion. Its final key step cancels every pending upload session and verifies terminal storage status, repeats the current-bucket prefix purge, then repeats session fencing and deletes each candidate's object in its recorded bucket with verified absence before transactional compare-and-delete. It verifies candidate absence and destroys wrapped space keys LAST. Failures retain discovery and keys for retry, including when current bucket configuration is unset. Explicit conversation deletion durably fences the conversation and merge donors and purges objects before document deletion. It synchronously cancels pending sessions, queries terminal status, deletes each recorded bucket binding, verifies absence, and compare-and-deletes unchanged candidate rows. Storage/discovery failures return retryable 503; success stays HTTP 204. Former buckets remain covered. Fenced writers retain their post-upload authority checks and transactional settlement; create-only retries preserve reused referenced objects for the deleting orchestrator. Each upload attempt uses a separate GCS resumable session initiated with exact size, fixed metadata and generation-zero precondition before any payload bytes. Its session URI is persisted with the candidate attempt under the same transactional deletion fences. A refused candidate transaction cancels the empty session best-effort. One PUT sends the complete encrypted payload, capped at 8 MiB, without SDK retries. 412 at initiation or finalization follows the create-only replay path. A five-second pointer-success budget splits remaining time between connect/read waits; deletion authority comes from storage session fencing, never elapsed time. Fencing sends DELETE to the recorded session URI, followed by the documented status query: a zero-byte PUT with `Content-Range: bytes */<declared size>` (the attempt records its size). The terminal set is an allowlist measured against GCS in a dev bucket on 2026-11-09: - 200/201: finalized. Status and cancel both return 200 once the upload has finalized. - 412: a generation-0 finalize was refused. This is sticky: every later status, cancel or upload returns 412, and the session cannot create the object even after it is deleted. - 499: cancelled. Every later status, cancel or upload returns 499, including the final chunk of a partly uploaded session. - 404/410: the service no longer knows the session. Any other response fails closed and retains discovery: 308 (open), 400 (a malformed request, which poisons the session with 400 without proving its state), auth errors, throttling, 5xx and transport errors. Every retry cancels and queries again. [GCS resumable upload protocol](https://cloud.google.com/storage/docs/performing-resumable-uploads) supplies the storage fence. The session URI is a sensitive capability: it is stored only in candidate state and excluded from pointers, logs, metrics and raised exception messages. Local/offline uses persistent filesystem sessions with the same transport path and cancel/finalize locking. Legacy timestamp-only attempts, including the `legacy` key and candidates predating `in_flight`, fail closed at any age because they have no recorded session to cancel. Lake writes have never been admitted outside local/offline/dev (`_WRITE_STAGES`); no production legacy rows exist. Production admission remains closed. No age-based erasure, delayed re-purge, Cloud Tasks scheduling, internal re-purge handler or wipe-drain setting remains. No new infrastructure or production configuration changes. ## Product invariants affected [INV-DATA-1](product/invariants/data-plane-continuity.md): deletion markers, candidates and key authority use the customer data-plane Firestore client. [INV-CUTOVER-1](product/invariants/account-cohort-cutover.md) and [INV-MEM-3](product/invariants/memory-canonical-fail-closed.md) cover B2/C2 dependencies against main; C4 retains their admission and continuity contracts. ## How it was verified Round 12 passed 860 distinct targeted tests (0 failures/skips), including 12 loopback Firestore tests. Runtime Pyright passed with 0 errors / 530 warnings; expanded changed test/support typing remains red with 99 errors / 2999 warnings. The route-policy baseline, async-blocker gate and formatting passed. Exact commands and exclusions are recorded in `.agent-artifacts/pgf/c4-fix-r12-result.md`. Tests use local encrypted storage, strict synthetic Firestore transactions, real HTTP deletion serialization, scrubbed agent credentials and the prescribed synthetic encryption secret. No GCP tier, production data or api.omi.me access. Full selector/preflight and repository-wide typecheck are excluded by this fix-round brief. No push, merge or deployment. ## Tests Regressions cover lost-writer sessions cancelled by conversation deletion/account wipe, rejected late finalization after key destruction, finalization immediately before cancellation, terminal-status classification, nonterminal/transport failure retention and key preservation, legacy attempts at arbitrary ages, fenced candidate transactions, capability redaction, initiation/finalization 412 replay, independent same-key settlement, and existing owner/conversation settlement races. Existing former-bucket deletion, absent current configuration, delete/absence-check failures, wipe ceremony and HTTP deletion contracts remain covered. Session persistence across local client restart and generation-zero finalization are tested. Erasure APIs accept no clock/expiry arguments. Candidate range drivers remain single-field automatic-index maintenance queries (`serving=False`); obsolete clock/expiry/scheduling driver arguments are removed. The route-policy baseline is checked after route removal. ## UI evidence UI-Evidence: none -- backend only ## Failure class (fixes) Failure-Class: none ## Scoped cleanups (optional) The artifact orchestrator reads raw donor inventory and performs candidate cleanup even with the bucket unset. The developer delete endpoint shares this orchestrator and retains its existing HTTP 500 failure behavior. Merge-internal donor deletion and pre-existing orphans remain C3 scope. The accepted seven-day wrapped-key PITR tail remains. Object/candidate purges remain pinned to release v1. Activation remains separately authorized and requires the wipe-coverage gate and deployed session-aware writers and deletion handling. Line-Count-Exception: backend/routers/conversations.py | 2590 -> 2599 | Preserve the existing delete route and its retryable storage/discovery failure mapping; session mechanics live in the lake modules. Measured against merge-base 697e744. ## Review fixes (round 15) - 307c4f: with `BUCKET_CANONICAL_AUDIO` set, the conversation delete route's donor-inventory read (`get_conversation_raw_snapshot`, now narrowed to `sync_merged_from`) ran outside the 503 mapping. A failure there now returns the retryable 503, before any audio or lake purge is scheduled. - fd278c: the single payload PUT now carries its full `Content-Range: bytes 0-(n-1)/n`. Measured in GCS: it finalizes with 200 for 5 B and 300 KB payloads. The local session model accepts that exact range (or none, as GCS also does) and rejects any other range. ## Review fixes (round 14) - dffbc2: a finalize that returns 412 now fences its own session (cancel, then a terminal status check through the session's client) before settlement drops the URI. A status that is not terminal keeps the attempt discoverable. Measured in GCS: 412 is sticky and terminal. - babf78: the deletion protocol doc now records `size` and describes the sized status query and the measured allowlist. ## Review fixes (round 13) - c47184: the fence now uses an allowlist (200/201/404/410/499) instead of a 4xx denylist, and the status query names the session's declared size. Both were confirmed against GCS behavior measured in a dev bucket. CI: local session records no longer use the lifecycle field name `status`. ## Review fixes (round 12) - Replaced elapsed-time upload assumptions with per-attempt GCS resumable-session cancellation and terminal-status verification before recorded-bucket deletion, absence checking and candidate erasure. - Removed age-based cleanup, delayed scheduling/handler/policy entry, the drain setting and registry entry, and their obsolete tests. Erasure has no `now` parameter. - Retained final key destruction, post-upload checks, create-only replay and transactional settlement fences. Finalize responses populate the blob generation so conditional fenced-writer deletion retains the SDK behavior. Initiation-time 412 records settled discovery without a session capable of committing. - Legacy attempts fail closed indefinitely; malformed candidate state is rejected. Session capabilities never appear in returned references or raised messages. - Updated persistent local session transport, query-driver signatures, deletion protocol documentation and the required regression suites. ## Earlier review fixes retained - Import `FieldFilter` from the public `google.cloud.firestore_v1` seam for isolated test imports. - Settlement re-reads conversation and account deletion fences in its transaction and refuses a pointer after fenced object cleanup. Conversation deletion always writes the durable tombstone, including bucketless revisions. - The R14 test guard retains quarantine behavior for legacy account markers without `wipe_status`; no task claim or reconciliation re-drive is admitted.
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.
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
make preflight: 15 passed, one failed, three cancelled, 26 not reached. The sole failure is the inherited synthetic-merge conflict inbackend/database/review_changes.pyandbackend/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_candidatesbefore 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)
OBJECT_LAKE_WRITE_PERCENTnumerically:0,0.0and0admit no writes and need no bindings; unparseable values still require them (test_enabled_write_binding_check_parses_percent_numerically, contract file 63 passed).AlreadyExistsrace path.🤖 Generated with Claude Code