GeezerVison is showing github.com — Build: fleet kv phase 2 — central CAS, shared namespaces and session sweep · Issue #13316 · developing-today/code
Build: fleet kv phase 2 — central CAS, shared namespaces and session sweep #13316DescriptionPhase 2 — shared primary + session sweep + grants (global reads, CAS conflicts, supported auth)
- Parent issue: Design: fleet kv — namespaced key-value store (local + global), blob offload to content-addressed R2 #10359 (items 2/4/5: central store, sweep survival, five-agent workload).
- Parent design: reviewed decision record (§1 hybrid central D014, §4 sweep, §5 CAS, §6 five-agent topology D008, §9 auth D011). Stable decision IDs: D003, D004, D005, D006, D007, D008, D011, D014 (D002 reversed/superseded — do not implement row-scopes-only).
- Prerequisite: design PR docs(fleet): settle namespaced KV storage, sweep and blob design (#10359) #13294 must merge before this phase starts. Depends on: Phase 1 Build: fleet kv phase 1 — local verbs, scoped SQLite and backup #13314 (local verbs + full-identity overlay + durable outbox); its implementation PR must be merged before Phase 2 implementation begins.
- Scope: shared Turso primary over the queue-style libSQL HTTP pipeline at configurable
FLEET_KV_URL (no hardcoded or fake deployed hostname); proposed migrations/handler paths (no code in this issue): pkgs/fleet/crates/fleet-kv/migrations/ for kv_namespaces, kv_heads, kv_versions, kv_conflicts, idem_receipts, kv_grants, and pipeline handlers beside the existing queue HTTP handlers. Central key derivation per write/read: from the explicitly selected scope — the shared scope_id of the namespace for authorized agents, or the private scope_id of the owning (user, context) — resolved via kv_namespaces + kv_grants; no implicit extra fallback scope exists.
- Scope: shared Turso primary over the queue-style libSQL HTTP pipeline; central key
(scope_id, registry_id, namespace, key) with one shared scope per shared namespace (shared-scope tombstones affect all shared readers; private scopes separate); kv_namespaces with designation-only global_flag; kv_grants with explicit-grant group DBs under fail-closed admission/provisioning policy (no default per-session proliferation; group DBs inline-only — no blob refs, ceiling checked before any group-DB write, blob-needing group writes refuse with blob_requires_shared_primary); --global now serves central (authoritative bypass); local-first reads (ordinary cache ≤ 1 s; miss/expiry refreshes or typed unavailable/stale, --allow-stale opt-in with age; overlay reads immediate offline) with local-override + merged list; durable sweep keyed (owner_user_id, context_id, session_id) via outbox + per-key CAS (≤ 5 attempts, jittered exp backoff capped at 1 s), receipts keyed (authenticated_writer, host_incarnation_UUID, outbox_UUID) + immutable fingerprint; tombstones sweep through CAS; five-agent rule (single-writer-per-key CAS; KV CAS is not a queue lease — no leases/expiry/steal); 15-minute archive checkpoint TARGET (unbounded loss when offline/unarchived; archive carries inline payloads only up to the effective threshold — no Phase 3 upload here). Auth: RP/agent JWT or route-scoped service token to the trusted endpoint; secrets-broker fetch path is not request auth; per-user Turso data-plane tokens refused (data_plane_credential_refused). v1 operational integration ships here: migrations, credential wiring, grant-policy implementation, backup/restore runbook, health probes.
Acceptance
--global get/set round-trips against central; plain get merges local + central with stated origin marks and never silently hides the shadowed row; --global bypasses the 1 s cache.
- Sweep: session dirty set merges idempotently (re-run safe; retransmit with same key+fingerprint returns the stored result); two sessions racing one key produce one winner + one typed
conflict {expected, actual} with both versions retrievable — never silent last-writer-wins, never Turso Sync last-push-wins; rebase after conflict is a new intent/new id, never silent overwrite. CAS-before-ack order: receipt written atomically with CAS, ack after; crash between CAS and ack replays the recorded result, never a spurious new conflict.
- Archive carries inline payloads only (≤ effective threshold) via the archive owner command
fleet kv backup (equivalently fleet kv sync --archive mode) plus the 15-minute online-checkpoint-target sweeper; over-threshold local-working bytes are reported protection_unavailable_needs_phase3, never uploaded — no blob upload exists before Phase 3. Over-ceiling bytes addressed to central before Phase 3 land typed pending_needs_phase3 (queued intent, not a row), never silently buffered inline. Crash before ack re-sweeps fully.
- Grants: a group DB exists iff a
kv_grants row authorizes it; unknown group/namespace refuses fail-closed; with no grant, everything lands on the shared primary. No per-session DB is provisioned by default. Group DBs accept inline bytes only: over-ceiling bytes addressed to a group scope refuse with blob_requires_shared_primary (shared-primary placement required, no auto-move), so no unrestricted write bypasses the ceiling.
- Data-plane credential presented to the endpoint is refused with the typed rule, not an incidental signature failure; central access reuses the hosted RP/agent JWT or route-scoped service token path only.
- Load probe (REQUIRED, correctness-only fixture — not a latency/perf promise, and no billing claim): five writers × ~1–10 keys/min on a ~10k-key namespace all converge;
list polling observes at most the documented 1 s staleness.
- Done check from repository root:
cargo test --manifest-path pkgs/fleet/Cargo.toml -p fleet-kv central runs the proposed central_* model/property/integration suite with a nonzero test count. It must include the five-agent fixture, scope isolation, clear-versus-sweep, same-ID/different-body refusal, duplicate delivery, archive restore, and expired-cache refusal. Also run cargo test --manifest-path pkgs/fleet/Cargo.toml -p fleet-kv to preserve Phase 1 behavior. A zero-match filter is failure, not evidence.
Oracles
- Property: CAS linearity — concurrent same-key writers serialize; the central head always equals one writer's full intent, never a blend; losers get typed conflicts. (PBT over concurrent CAS attempts.)
- Property: sweep idempotence — sweeping the same outbox twice changes central once. (PBT over duplicate deliveries.)
- Property: tombstone sweep convergence — delete-vs-write races resolve to a retrievable conflict or a tombstoned head, never resurrection-by-replay.
- Model: central head machine (version, parent_version, writer) against a sequential CAS oracle; sweep as an outbox-draining refinement of it.
{
"direct_parent": null,
"links": [],
"lineage": {
"design": null,
"roadmap_item": null,
"priority": null
},
"pm_meta": 1,
"provenance": {
"queue_id": null,
"scheduled_start": null,
"picked_up_at": null,
"work_started_at": null,
"created_at": "2026-11-23T13:22:18Z",
"session_id": "ses_e5df79277fdffep9u8FJIv4AqN",
"lane": null,
"host": "amd",
"worktree": "/home/user/.local/share/opencode/worktree/7c7733/lane-any-n-12892-fleet-kv-design",
"model": null,
"lane_start_issues": [],
"workspace_ref": {
"kind": "worktree",
"id": "/home/user/.local/share/opencode/worktree/7c7733/lane-any-n-12892-fleet-kv-design",
"repo": "developing-today/code",
"branch": "lane-any-n/12892-fleet-kv-design",
"sha": "5ac3ddcec60017b05b655b8fe665b06c61369ec3"
},
"auth_subject": "oc-code-06",
"stamped_by": "fleet 0.1.0 (native)"
}
}
Related program: #10359 Activitydeveloping-today commented on Nov 23, 2026 dezren39 commented on Nov 23, 2026 Filed by lane any-n under #10359, design task 21123 / parent 20571. Same-pass pilot coverage: repo-health-code-pilot task 21317 (queued); do not implement before design PR #13294 and the phase prerequisites are merged. This run publishes design/build handoffs only. dezren39 commented on Nov 23, 2026
Triage verdict (task 21317, lane oc-code-02): valid build handoff, not yet implementable.
- Build: fleet kv phase 2 — central CAS, shared namespaces and session sweep #13316 OPEN, effort/l, kind/feature. Parent Design: fleet kv — namespaced key-value store (local + global), blob offload to content-addressed R2 #10359 items 2/4/5; design record D003/D004/D005/D006/D007/D008/D011/D014 referenced.
- Prerequisites unmet, verified just now: design PR docs(fleet): settle namespaced KV storage, sweep and blob design (#10359) #13294 OPEN (unmerged); phase-1 Build: fleet kv phase 1 — local verbs, scoped SQLite and backup #13314 OPEN with no implementation PR merged. Packet explicitly forbids implementation before both merge, and scope excludes unrelated KV phases.
- No hold label on Build: fleet kv phase 2 — central CAS, shared namespaces and session sweep #13316 (hold check: available). Assignee/authorship are not holds per FDR-0012.
- No code change in this triage. Returning to queue as fix follow-on; implement phase 2 only after docs(fleet): settle namespaced KV storage, sweep and blob design (#10359) #13294 merge + phase-1 implementation merge, per acceptance criteria in issue body.
dezren39 commented on Nov 23, 2026 Triage verdict (lane code-g, queue task 21320, 2026-11-23): valid phased build handoff under #10359 with concrete acceptance + oracles. NOT startable now: gate design PR #13294 is OPEN/unmerged, and phase-1 prerequisite #13314 is OPEN. Per the issue's own prerequisite clause, phase-2 implementation must wait for both. Parking the queue task with a ready-condition on #13294 merge; re-validate #13314's implementation PR at resume before any code work. No code changes made. dezren39 commented on Nov 23, 2026
Triage refresh (queue task 21320, lane agent-next-22-local, 2026-11-23): valid Phase 2 build handoff; still not startable.
This updates the earlier triage note that said design PR #13294 was open; the design gate has cleared, but Phase 1 has not. dezren39 commented on Nov 23, 2026 Related program: #10359. This phase delivers one of the three implementation stages from the accepted fleet-kv design. dezren39 commented on Nov 23, 2026
Triage refresh (queue task 21320, lane xaltha, 2026-11-23 ~14:30 UTC): valid Phase 2 build handoff; still not startable.
- Design PR docs(fleet): settle namespaced KV storage, sweep and blob design (#10359) #13294 MERGED at 13:37 UTC — that gate is now satisfied.
- Phase 1 Build: fleet kv phase 1 — local verbs, scoped SQLite and backup #13314 remains OPEN. Its first slice is in flight as PR fleet-kv: add identity-scoped SQLite core #13362 (open, identity-scoped SQLite set/get), which by its own note does NOT complete Phase 1 acceptance (tombstones, outbox, CLI verbs, namespace registry/grants, crash recovery, backup still open).
- Phase 2 must wait for Phase 1 to be implemented and merged. Not duplicating the in-flight Phase 1 work; recheck after Build: fleet kv phase 1 — local verbs, scoped SQLite and backup #13314 closes.
dezren39 commented on Nov 25, 2026
Claim-check (lane xaltha, hourly work-loop 2026-11-25 ~14:47 CST): fleet agent next handed #13316 to this lane, but it is already actively in flight by lane 8 — claimed 2026-11-25T19:43Z, slices 1-3 merged in #15214, slices 4-5 merged in #15222/#15228, and slices 6/7/9 (grants, survival archive, rebase + five-agent probe; acceptance 3/4/6) open as PR #15235 (opened 20:36Z today). The shortlist why ("no open PR found") is stale.
No code touched by xaltha on this issue — duplicating lane 8 would collide. Remaining per lane 8 notes: hosted pipeline route with credential refusal (acceptance 5). Returning this lane to agent next for a different item. dezren39 commented on Nov 25, 2026 Progress from lane 8: #15235 merged (slices 6 to 9).
- Grants (acceptance 4): group databases exist only behind a
kv_grants row, take inline bytes only, and refuse fail-closed otherwise.
- Survival archive (acceptance 3):
fleet kv backup / sync --archive checkpoint unswept writes to central kv_archive (migration 2), and fleet kv restore --archive adopts them on a fresh host.
- Rebase and five-agent probe (acceptance 6):
fleet kv rebase clears a lost CAS, and the correctness probe drives five agents over a 10k-key namespace.
- Hosted kv door:
fleet-hosted serves POST /v1/kv/v2/pipeline and forwards only statements in catalog.rs (mirrored as hosted-worker/src/kv-catalog.json, with a drift test). It binds owner and writer to the caller, checks private prefixes and namespace scope, and gates namespace and grant changes on kv-admin. Runbook: book/operations/kv-central.md.
Verified remotely: the full fleet Rust workspace and the hosted-worker suite (269 pass, typecheck clean).
Still open on this issue:
- There is no
fleet kv namespace define verb yet. Namespaces are defined through the library or an admin service token.
- Group databases are not reachable through the hosted door. Granted group writes still need direct libSQL credentials.
- The door answers 503
kv_primary_not_configured until KV_LIBSQL_URL and KV_LIBSQL_AUTH_TOKEN are set on the deployed Worker.
Generated by Claude Code dezren39 commented on Nov 25, 2026 Lane 8: #15260 merged, adding fleet kv namespace define NS (--shared SCOPE | --private) and fleet kv namespace list for operators (admin credential, no local store needed; shared/private changes refused with namespace_scope_change). That closes the namespace-definition gap from the last note. What is left here is deployment wiring (KV_LIBSQL_URL and its token on fleet-hosted) and group databases through the door.
Generated by Claude Code developing-today-fleet commented on Nov 27, 2026
Triage refresh (queue task 21320, 2026-11-27): the Phase 2 handoff remains valid, but its full acceptance is not yet complete.
- Gates: design PR docs(fleet): settle namespaced KV storage, sweep and blob design (#10359) #13294 is MERGED; Phase 1 Build: fleet kv phase 1 — local verbs, scoped SQLite and backup #13314 is CLOSED.
- Implemented slices are merged: fleet kv: central plane, durable sweep and libSQL pipeline client (#13316 slices 1-3) #15214 (central CAS, durable sweep and libSQL pipeline client), fleet kv: sync, host namespace cache and --global verbs (#13316 slice 4) #15222 (sync/cache/global verbs), fleet kv: local-first merged reads with a 1 s central cache (#13316 slice 5) #15228 (local-first merged reads), fleet kv: grants, survival archive, rebase, five-agent probe and hosted door (#13316) #15235 (grants/archive/rebase/five-agent probe/hosted KV door), and fleet kv: namespace define and list verbs (#13316) #15260 (namespace define/list).
- The latest progress note on Build: fleet kv phase 2 — central CAS, shared namespaces and session sweep #13316 still identifies two concrete gaps: granted group databases are not reachable through the hosted door, and the door returns
kv_primary_not_configured until KV_LIBSQL_URL and KV_LIBSQL_AUTH_TOKEN are wired on the deployed Worker. No open PR referencing Build: fleet kv phase 2 — central CAS, shared namespaces and session sweep #13316 was found. I did not perform provider deployment or credential changes.
- Verdict: no small isolated fix is justified by this triage packet. Keep Build: fleet kv phase 2 — central CAS, shared namespaces and session sweep #13316 OPEN for the remaining implementation/operational work; do not claim full acceptance from the merged slices alone. No code changed.
developing-today-fleet commented on Nov 28, 2026 Progress — lane oc-code-02 (shortlist slice, #13316)
PR open: #16384 — fleet kv grant list GROUP / grant revoke GROUP DB NS (branch oc-code-02-13316-central-cas-storage).
Why this slice: grants::admit/revoke/write/read/place had zero callers outside grants.rs tests — acceptance 4 ("a group DB exists iff a kv_grants row authorizes it; unknown group/namespace refuses fail-closed") was library-only with no operator surface. The new verbs mirror namespace define/list (central admin, kv-admin, no local store): list prints grant rows, unknown/empty groups refuse unknown_group, revoking an ungranted namespace refuses namespace_not_granted.
Verification: new fail-closed CLI test passes; cargo test -p fleet-kv 180 lib + 3 integration green; central filter 111 green; cargo fmt --check clean. (Clippy unrunnable in this lane: nightly cargo-clippy missing librustc_driver; noted on the PR.)
Left for follow-ups: CLI grant admit needs a group-membership directory (no source wired yet — admit stays with the kv-admin door grants.upsert); granted group DBs through the hosted door + KV_LIBSQL_URL deployment wiring remain per the 11-27 triage refresh.
MetadataMetadataDevelopmentNo branches or pull requestsIssue actions
|