Repository navigation
docs(fleet): settle namespaced KV storage, sweep and blob design (#10359) - #13294
Conversation
Compat: threshold subordinate to shared partition policy (#9084 16KiB), Part A preserved, hosted data-plane refusal, F12.5 not-this-surface, Turso embedded-replica vs Sync distinguished, fixture figures labelled.
|
Warning Review limit reachedYou've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository. Next included review available in 16 minutes. View limit details
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. |
…mal human-review Adopts readonly investigator outcomes dated 2026-11-23: D001 retained (standalone Turso local-only steelmanned/rejected), D002 reversed/superseded by D014 hybrid placement (shared primary default + explicit-grant group DBs, fail-closed policy, v1 ops integration required), D008 retained (5 attempts/jitter cap 1s, ordinary cache age 1s, --global bypass, KV != queue lease), D013 reversed/superseded by D015 (blob-only phase 3, versionable envelope seam). Human-review reduced to None per minimal policy. Phase drafts (tmp/opencode) updated: standalone #10359 links, decision IDs, #13294 prereq, blob-only phase 3.
…s, publication= CAS (1) Central key is (scope_id, registry_id, ns, key); shared scope per shared namespace, private scopes separate, plain read checks overlay then one selected scope only. (2) clear-override advances a generation fence cancelling pending intents; in-flight CAS states linearization. (3) 15m is a checkpoint TARGET; Phase 2 archives inline-only, over-threshold reports protection_unavailable_needs_phase3; local working files streamed + atomic ref. (4) cache miss/expiry refreshes or typed stale; --allow-stale opt-in. (5) GC roots incl. versions/conflicts/ archive refs/pins. (6) group DBs inline-only; blob_requires_shared_primary. (7) idem key (writer, incarnation, outbox UUID) + fingerprint; rebase is new intent. Final re-challenge recorded (D001/D008/D014/D015 sound).
…on, RPO wording Full (scope_id, registry_id, namespace, key) in every CAS/history/ conflict/receipt/fingerprint/schema reference. clear-override holds the per-key local lock against sweeper network submission (5s bounded wait, typed busy); in-flight = irrevocably submitted only. 15-min is an online checkpoint target; unarchived offline loss unbounded (line71, Consequences, D006). Phase drafts: pinned design URL, Phase1 identity accessor/session_state.rs bound, --to version ID, terminal cancellation, working-file backup, proposed fleet-kv test crate + nonzero-count done checks; Phase2 FLEET_KV_URL, scope-derived central key, backup/archive command, REQUIRED correctness-only probe, pending_needs_phase3; Phase3 effective=min formula, scope-policy jurisdiction/tier, shared-primary partition_fences, no lists/tables.
Append dated delivery section: build issues #13314/#13316/#13318 (subissues of #10359, pilot tasks 21316-21318, tier crucial, hard chain #13314 -> #13316 -> #13318, all gated on #13294), reviewer signoff (Mustfix NONE at 5ac3ddc), challenge final, truthful no-runtime-tests statement. Phase-2 draft ref -> live issue; human-review link clickable. Bookkeeping only, no arch change.
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: 7be310b318
ℹ️ 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".
| - **Upload safety:** `put_staged → verify (length + BLAKE3-256 recomputed on receipt, streaming) → publish`. Upload→verify yields a staged/verified object held only by a temporary staging pin/lease — staging state, never an accepted object (same invariant as A-9120.1 and component-F staging). **Publication is the CAS + authoritative ref-registration transaction** (publish-CAS, §4–§5): only that transaction makes the reference row writable/readable. Crash before CAS leaves a staging-pinned object that staging TTL may safely reap (no read path can reference it). Crash after CAS leaves a retained ref root that only grace/GC may retire. An object marked "published" anywhere before its CAS is an orphan: it is retained under grace/GC rules, never reaped by staging TTL — there is no gap between the ref check and the deletion fence because both run against the same primary (§10 ordering below). Multipart completion is not publication; only the service verification step plus the publish-CAS makes the reference row writable. | ||
| - **GC safety:** mark-and-sweep per partition exactly as component F §6. GC roots are the full retained set: **published** rows in `kv_heads`/`kv_blobs`, plus retained `kv_versions` rows, proposed refs recorded in `kv_conflicts`, archive/snapshot refs until their actual expiry, dedup active pins, and every other DB root that names a content id. Intermediate `staged`/`verified` states live only in the endpoint's staging area under the staging pin, never in central rows — central accepts `published` only, and only via publish-CAS. The sweep shares component F's per-partition serialization point concretely: KV reference creation (publish-CAS) and the GC delete fence are transactions against the same central primary, ordered by the per-partition sequence the primary assigns. A reference created during candidate/grace/re-verify races is thereby ordered: a publish-CAS landing before the fence's re-verify is seen and clears candidacy; one landing after finds no verified replica under the fence and the writer re-stages from its held bytes (a re-upload, not data loss). Per-jurisdiction dedup partitions from #3401 bound every sweep (D012); the derived index is a cache; re-verify at grace expiry; epoch-fenced delete; audit event per delete. |
There was a problem hiding this comment.
Retain losing blob proposals when the head CAS fails
When an over-threshold write loses CAS, §5 requires its proposed value to remain retrievable in kv_conflicts, but that value must be a blob reference and this protocol only publishes the blob when the head CAS succeeds. The losing object therefore remains staged and eligible for staging-TTL deletion; listing conflict references as GC roots does not protect it from that separate cleanup path. After staging expiry and loss of the source host, the conflict record cannot recover the losing bytes. Define a failed-CAS transaction that also publishes/registers the retained conflict reference, or another durable retention path, before acknowledging the conflict.
Useful? React with 👍 / 👎.
| **Backup/restore (§7, D001 detail; numbers are defaults in effect).** Two destinations, both concrete: | ||
|
|
||
| 1. **Local file snapshot** (survives process death, not disk loss): SQLite backup API or filesystem snapshot of file + WAL into `~/.local/share/fleet/kv/backups/` every **6 h**, plus a `backup manifest` row (host, file hash, WAL frame, timestamp) in the outbox. RPO for process-death recovery: last write (WAL replay). | ||
| 2. **Survival archive** (survives disk loss when reachable): the sweeper uploads the session dirty set to the central archive scope on session end and every **15 min** during a live session. The 15-minute figure is an online successful-checkpoint TARGET, not an unconditional RPO: with no network, no successful checkpoint, or disk destruction before the next upload, the loss window for unarchived writes is unbounded, and the CLI must report that plainly. The Phase 2 archive carries inline payloads only, up to the effective threshold (§8); over-threshold bytes stay local-working (§8) until Phase 3 exists, and the archiver explicitly reports them as `protection_unavailable_needs_phase3` instead of pretending they are archived. Large working blobs are part of the snapshot only once reference placement exists: the manifest lists staged content ids, and restore re-publishes or re-links them. |
There was a problem hiding this comment.
Include cleared overrides in survival-archive checkpoints
If an inline override is archived and then removed with clear-override, later successful checkpoints have no removal to upload: §3 deletes the overlay and cancels its unsent intents without creating replacement work, while §4 obtains the dirty set from the outbox. Restoring the archive after disk loss can therefore resurrect the cleared override and shadow central state again, even after a successful post-clear checkpoint. Specify an archive-only removal/generation record or a complete overlay snapshot so archive restoration preserves the clear without modifying central heads.
Useful? React with 👍 / 👎.
Final handoff — lane any-n, task 21123 / parent 20571PR remains OPEN, not merged. Parent lane any-n owns diff verification, merge to main and terminal queue disposition. SHA gate (2026-11-23 13:30 UTC)
Validation and artifacts
Non-blocking implementation evidence gapsTurso group-DB limits/pricing, production grant/admission wiring, actual workload performance, true-delete retention and future list/table schemas remain implementation-owned evidence or explicitly deferred scope, not owner-approval gates. Offline/unarchived disk loss has an unbounded loss window; 15 minutes is an online checkpoint target only. |
Summary
Standalone design-mill record for #10359, coordinated with #9107, #9120 and #9084. Human-review: None; defaults are agent-preliminary, not human-confirmed.
Build sub-issues (all require this design merge): #13314 → #13316 → #13318. GitHub blocked-by edges and same-pass pilot coverage are recorded (tasks 21316 / 21317 / 21318). Phase 3 is blob-only; lists/tables remain later expansion.
Lane any-n, task 21123, parent 20571. Sole document writer on the supplied worktree; fresh independent compatibility, primary-source, challenge and spec reviews. Parent lane retains queue completion and merge to main.
Closes #10359. Closes #12892.
Evidence
After: cohesive decision record and human-review sheet; Design: fleet kv — namespaced key-value store (local + global), blob offload to content-addressed R2 #10359 acceptance updated with reviewed source and three concrete build handoffs. Fresh spec reviewer reports Must fix: none at
5ac3ddcec60017b05b655b8fe665b06c61369ec3; later changes are only delivery bookkeeping plus merges from main. Challenge/re-investigation/re-challenge completed (D001/D008 retained, D002→D014 and D013→D015); published-issue zero-context reader reports blocking questions: NONE.git diff --check;prettier --checkon both new documents;python3 -I scripts/research_workflow.py check --path <design-record> --path <human-review>(workflow/link/profile validator). Final head/base/SHA gate recorded in the PR comment before handoff..github/ci-policy.md: no automatic PR CI or required PR checks. No runtime suite dispatched for this documentation-only design; the future phase commands/oracles are requirements, not claimed passes.Merge Danger
Door: two-way
Documentation only; design choices remain agent-preliminary and reversible.
Blast Radius: planning
Actual main merge belongs to parent lane any-n after its own diff verification and fresh SHA-gate check. This executor leaves the PR open, not merged.