Skip to content

Build: fleet kv phase 1 — local verbs, scoped SQLite and backup #13314

Open

Description

@dezren39

Phase 1 — local verbs (fleet kv get/set/list/delete/clear-override/revert, namespaces, tombstones)

  • Parent issue: Design: fleet kv — namespaced key-value store (local + global), blob offload to content-addressed R2 #10359 (fleet kv design owner; items 1–3: verb family, local store, namespaces).
  • Parent design: reviewed decision record (§1 local store + logical identity, §2 namespaces/registry, §3 verbs). Stable decision IDs: D001, D003, D004, D005, D015 (envelope versions kv:raw-v1 accepted, kv:ref-v1 refused as unimplemented_central_in_phase1).
  • Prerequisite: design PR docs(fleet): settle namespaced KV storage, sweep and blob design (#10359) #13294 must merge before this phase starts. No dependency on other phases (this is the first).
  • Scope: local-only. One SQLite file per host (WAL) with kv_local keyed by the full identity tuple (owner_user_id, context_id, partition_id, namespace, key), cached kv_namespaces + kv_grants, durable outbox, backup manifest row. Local identity source (explicit, proposed): the existing pkgs/fleet/crates/fleet/src/session_state.rs binds the session ID only (session-ID validation + liveness) — it carries no owner/context. Phase 1 therefore requires a new trusted launch-identity accessor that supplies (owner_user_id, context_id) at session start; offline identity comes from the validated persisted launch record, never from a client-supplied user override (fail closed when absent). Merged list shows local rows only; any central-origin mark is deferred to Phase 2 (this phase must not display or imply central state).
  • Scope: local-only. One SQLite file per host (WAL) with kv_local keyed by the full identity tuple (owner_user_id, context_id, partition_id, namespace, key), cached kv_namespaces + kv_grants, durable outbox, backup manifest row. Verbs get/set/list/delete/clear-override/revert + --namespace; --global flag parsed but refused as unimplemented_central_in_phase1 (typed refusal, never silent local fallback). Strict CLI/registry/docs updates: multicall registration, --help text for every verb, registry entries, and the command reference updated in the same diff. Unknown arguments are a strict usage error before any I/O (argument contract: parse and validate the whole command line first; no subprocess, file write, or DB touch on unknown/malformed args). No central, no sweep, no blobs. LOCAL working bytes vs central inline distinguished: the threshold governs central rows only — locally, over-threshold bytes live as a streamed working file plus an atomic local DB ref (never fully buffered above the 1 MiB resident budget), so no local value is ever rejected for size.

Acceptance

  1. fleet kv set/get/list/delete/clear-override/revert round-trip locally; list --include-tombstones shows tombstones with masked origin. Merged list marks only local origins; central marks (shadowed-by-central) are deferred — assert they never appear in Phase 1 output.
  2. clear-override drops the overlay row, advances the local generation fence (cancelling unsent intents; bounded-wait/clear_busy_try_again per the design), and reveals central-nothing (local-only). delete writes a masking tombstone that still sweeps later; revert NS KEY --to V appends a restoring version, where --to V is a positive monotone version ID (never a value). The three are never conflated in help text, errors, or reads.
  3. --namespace selects scope; unknown namespace or malformed key is a typed refusal naming the registry/scope (unknown_namespace, malformed_key). No (ns, key)-only cross-identity read path exists: reads filter by the caller's full identity tuple.
  4. --global on any verb fails closed with the typed refusal (documents Phase 2 ownership).
  5. Crash recovery: killed mid-set leaves either the old row or the full new row + exactly one unacked outbox entry — never a half-row or half-file (re-run the verb sequence after kill -9 in test).
  6. File backup: snapshot of file + WAL + manifest row restores on a fresh host to the same reads; the manifest pins every live working file (content id + length + hash) and the snapshot includes them, so a restore re-links working bytes; 6 h snapshot cadence and WAL-replay RPO documented in the runbook entry this phase adds.
  7. CLI/registry/docs: fleet kv --help documents every verb + --namespace/--global/--force-blob (refused where unimplemented); registry and command reference updated; unknown envelope versions refused, not ignored.
  8. Proposed test home (no code in this design run): new crate pkgs/fleet/crates/fleet-kv with modules overlay, outbox, backup, cli. Done check from repository root: cargo test --manifest-path pkgs/fleet/Cargo.toml -p fleet-kv passes with a nonzero test count asserted in CI (fail if 0 tests ran); fleet kv --help output snapshot matches the registry doc; kill -9 crash-recovery script exits 0. If implementation uses an existing crate instead, record the exact equivalent runnable command in this issue and preserve the named oracles/nonzero-count requirement.

Oracles

  • Property: tombstone convergence — interleaved set/delete/clear-override/revert sequences on one key always read as the last version's value-or-absent; deleted keys never resurrect except via revert, and clear-override revealing central state is not resurrection (it removes the overlay; the revealed value was never deleted).
  • Property: outbox durability — every acknowledged local set/delete has exactly one unacked outbox row until Phase 2 consumes it or until terminal cancellation by clear-override (cancelled is a terminal state, not a leak and not "pending until Phase 2 forever"). (PBT over crash-point injection.)
  • Model: verbs as a state machine against an in-memory map oracle (get/set/delete/clear-override/revert/list incl. tombstone flags).
  • No F12.5 confusion: assert a 100 KiB local value succeeds (local working bytes + atomic ref, not a world-sandbox entry under id: F12.5 first new providers — kv, blob, http.fetch, notify #1062 caps; the 16 KiB partition ceiling governs central inline placement only, which is Phase 3's concern).
{
  "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:21: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": "any-n",
    "stamped_by": "fleet 0.1.0 (native)"
  }
}

Related program: #10359

Activity

  1. added
    kind/feature
    priority/normal
    effort/m
    on Nov 23, 2026
  2. developing-today commented on Nov 23, 2026

    @developing-today
    Contributor
  3. dezren39 commented on Nov 23, 2026

    @dezren39
    MemberAuthor

    Triage verdict: VALID — blocked on design PR #13294 (lane code-j)

    Task: triage packet repo-health-code-pilot/21316 (repo = code, lane code-j).

    Validation:

    • Handoff body is well-formed: parent Design: fleet kv — namespaced key-value store (local + global), blob offload to content-addressed R2 #10359, reviewed decision record §1–§3 with stable IDs D001/D003/D004/D005/D015, explicit prerequisite (#13294 must merge first), local-only scope, 8 acceptance items with named oracles, proposed test home pkgs/fleet/crates/fleet-kv.
    • Checked 2026-11-23: pkgs/fleet/crates/fleet-kv does not exist; no fleet kv verbs in fleet/src — implementation not started, as expected for a pre-merge handoff.
    • No duplicates: #13314 is the sole Phase 1 issue. #13316 (Phase 2) and #13318 (Phase 3) are sequenced siblings, not dupes.
    • Labels kind/feature + priority/normal + effort/m fit the scope (6 verbs, SQLite/WAL + outbox + backup, crash-recovery + PBT/model oracles). No label change needed.

    Prerequisite status (blocking):

    Disposition:

    • Not a small fix — effort/m with new crate + SQLite + backup + crash tests. No code change in this triage pass.
    • Returned to the queue for real build work once #13294 merges. Recommended resume condition for the build task: #13294 merged AND fleet-kv crate (or recorded equivalent) absent/present as applicable — implement from the merged decision record, not from this pre-merge text alone.

    Done check for this triage: this comment posted; no PR (nothing small to close with a keyword).

  4. dezren39 commented on Nov 23, 2026

    @dezren39
    MemberAuthor

    Filed by lane any-n under #10359, design task 21123 / parent 20571. Same-pass pilot coverage: repo-health-code-pilot task 21316 (queued); do not implement before design PR #13294 and the phase prerequisites are merged. This run publishes design/build handoffs only.

  5. dezren39 commented on Nov 23, 2026

    @dezren39
    MemberAuthor

    Related program: #10359. This phase delivers one of the three implementation stages from the accepted fleet-kv design.

  6. dezren39 commented on Nov 23, 2026

    @dezren39
    MemberAuthor

    Progress update: opened PR #13362 for the first identity-scoped SQLite set/get slice. It adds the full-identity primary key, local WAL-backed storage, validation, and tests. It does not complete Phase 1 acceptance: tombstones, outbox, CLI verbs, namespace registry/grants, crash recovery, and backup/restore remain deferred follow-up work. The remote test dispatch was accepted but Fleet has not correlated a run ID; local compilation timed out, so test status remains unresolved.

  7. dezren39 commented on Nov 23, 2026

    @dezren39
    MemberAuthor

    Progress update: PR #13362's identity-scoped SQLite set/get slice now passes its named test command. Fleet run 45197429113 completed successfully on commit c43ce08d94d: cargo test --manifest-path pkgs/fleet/Cargo.toml -p fleet-kv reported 4 passed, 0 failed. The run first found invalid PartialEq/Eq derives on KvError; the follow-up commit removed those derives.

    PR #13362 remains open and does not complete Phase 1. CLI verbs, tombstones/outbox, namespace registry/grants, crash recovery, and backup/restore remain follow-up work. The current queue task will resume when PR #13362 merges and select the next independently buildable Phase 1 slice.

  8. added a commit that references this issue on Nov 23, 2026
  9. dezren39 commented on Nov 23, 2026

    @dezren39
    MemberAuthor

    Progress update (lane oc-code-08, queue task 21319): addressed both Codex review findings on PR #13362 with a new commit on lane-code-j/13314-kv-core.

    • P2 (space in keys): validate_key now accepts printable ASCII spaces per the design's Key syntax contract; added a space-key set/get round-trip regression test.
    • P1 (grammar coverage): added generated key/namespace tests checked against independent oracles transcribed from the design text, plus byte-length and grammar boundary unit tests.

    Local verification: cargo test -p fleet-kv passes 9/9 (includes the 2 new property tests). PR #13362 remains open; this task resumes after merge for the next Phase 1 slice.

  10. dezren39 commented on Nov 23, 2026

    @dezren39
    MemberAuthor

    PR #13362 remains open, so Phase 1 is not complete. Its current head has a completed Codex review with no unresolved findings, and the issue records the passing 9/9 fleet-kv test result. The next Phase 1 slice can be selected after PR #13362 merges; this task is parked on that condition.

  11. dezren39 commented on Nov 23, 2026

    @dezren39
    MemberAuthor

    Triage verdict: VALID — unblocked by merging PR #13362

    • Dependency check: design PR docs(fleet): settle namespaced KV storage, sweep and blob design (#10359) #13294 merged 2026-11-23T13:37Z; the review-blocking SQLite core slice PR fleet-kv: add identity-scoped SQLite core #13362 was MERGEABLE/CLEAN with a completed Codex review (no unresolved findings on head f6580c5c683) and the recorded 9/9 fleet-kv test result. Rather than park a third time on "PR open", this lane merged it: merge commit 375b974d4a0.
    • No labels/cleanup needed: kind/feature, priority/normal, effort/m still fit.
    • Phase 1 is still not complete. Landed so far: fleet-kv crate with host-local SQLite WAL storage keyed by the full (owner_user_id, context_id, partition_id, namespace, key) tuple, validated set/get, identity isolation and reopen-persistence tests.

    Next independently buildable slice (selected, not started here)

    CLI verbs over the landed store — this task's packet was a 45-minute triage packet, so it stops here.

    • Scope: fleet kv set/get/list/delete/clear-override/revert + --namespace, --global typed refusal (unimplemented_central_in_phase1), strict whole-command-line argument parsing before any I/O, multicall registration + --help text + registry/command-reference entries in the same diff.
    • Test oracles: verb state-machine model test against an in-memory map; list --include-tombstones shows tombstones; --global refusal; fleet kv --help snapshot matching the registry doc; nonzero test count asserted.
    • Still deferred after that: tombstones/outbox durability, namespace registry/grants, crash recovery (kill -9), oversized working-file storage, backup/restore runbook entry.
  12. dezren39 commented on Nov 24, 2026

    @dezren39
    MemberAuthor

    Second-pass verdict (oc-code-07, 2026-11-24)

    Fresh state: open. The SQLite core landed (PR #13362, merge 375b974; design PR #13294 merged). Phase 1 is not complete.

    Remaining work is the CLI verbs slice recorded by lane oc-code-05: fleet kv set/get/list/delete/clear-override/revert with --namespace, the --global typed refusal (unimplemented_central_in_phase1), strict argument parsing, and registry/help entries. Tombstones, namespace grants, crash recovery and backup are deferred after that.

    Verdict: real build, not done here. It is routed as the next phase-1 implement packet against this issue. This lane did not start it, because it needs a worktree and fleet-shell build runs. Tracked under #14158.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    effort/mkind/featurepriority/normal

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions