diff --git a/doc/2026-11-24T01-23-30Z_design_secrets-plane-sync/2026-11-24T01-23-30Z_design_secrets-plane-sync.md b/doc/2026-11-24T01-23-30Z_design_secrets-plane-sync/2026-11-24T01-23-30Z_design_secrets-plane-sync.md new file mode 100644 index 000000000..e38e418c7 --- /dev/null +++ b/doc/2026-11-24T01-23-30Z_design_secrets-plane-sync/2026-11-24T01-23-30Z_design_secrets-plane-sync.md @@ -0,0 +1,33 @@ +# Secrets plane — delta refresh, broker peer sync, dual-store puts + +Design record for [#13948](https://github.com/developing-today/code/issues/13948) (direction: Drew, 2026-11-23). Extends [#13893](https://github.com/developing-today/code/issues/13893) (cold-refresh batching + client fallback bound) and [#13894](https://github.com/developing-today/code/issues/13894) (broker performance under load); where the batching-only proposal and this design overlap, this design supersedes the batching-only framing. Companion future-work to-dos: [#13950](https://github.com/developing-today/code/issues/13950) (embed both stores in the fleet binary) and [#13952](https://github.com/developing-today/code/issues/13952) (`fleet init` bootstrap command). Related: [#10358](https://github.com/developing-today/code/issues/10358) (secrets scoping), [#9158](https://github.com/developing-today/code/issues/9158) (canonical secrets model). + +## The problem + +The sandbox secrets broker refreshes by shelling out to `bws secret get` once per secret — ~242 spawns, ~160–220s cold (measured 2026-11-23). During the refresh the broker is present-but-not-serving and clients hang instead of falling back (>120s observed), so every sandbox restart wedges every secrets consumer for minutes. The estate's two brokers (sandbox + laptop) hold the same set but cannot learn from each other, and `fleet secrets` is read-only, so writes propagate only when a refresh happens to notice them. + +## Verified premises (2026-11-24, filing lane) + +- `fleet secrets` today has exactly two verbs, `get` and `list`, and is read-only (installed binary's help). `refresh` and `put` are new surface. +- `bws secret list ` returns the whole set in one call, including values and a per-secret `revisionDate` (bws 2.1.0, verified live: 244 secrets; fields `creationDate, id, key, note, organizationId, projectId, revisionDate, value` — count and field names only inspected). Delta-by-`revisionDate` is supported by the CLI today. +- bws write verbs exist (`create / edit / delete`). +- 1Password CLI (`op` 2.41.0) is installed on both machines; `op item create/edit` and `op service-account ratelimit` exist (help verified). NOT live-verified: `op item list` JSON field shape — documented to carry `created_at`/`updated_at` with metadata-only list results; the laptop's `op` has no account configured in a plain shell. The design's Slice 5 includes a capability spike to verify before building on it. + +## The design (summary; full text on #13948) + +1. **Delta refresh.** Each broker keeps a watermark (last refresh start, minus a skew overlap). A refresh is one `bws secret list`; only entries with a newer `revisionDate` are applied, deletions come from the id-set diff, and a partial list applies nothing (the #5504 lesson). +2. **Broker peer sync.** On startup and each tick a broker asks its trusted peer for `{set_hash, last_upstream_refresh_at, count}`. Equal hashes mean synced. If the peer refreshed more recently, pull the peer's full set (v1 payload = everything, Drew's explicit simplification; selective pull-back deferred until requirements diverge). Peer down → upstream refresh. A sandbox broker needs a full upstream refresh only if the laptop is down AND it restarted with no cache. +3. **Set hash.** Sorted, keyed (HMAC) hashes over `(name, value)` pairs — the sync proof, exchanged only between authenticated brokers, truncated in logs, so a leaked hash doesn't enable offline guessing. +4. **Client surface.** `get --upstream`, `get --no-cache`, `secrets refresh` (reports which leg served it), and `secrets put`. The #13893 client bound (~2–5s, then fall through) rides along as Slice 1. +5. **Put semantics.** The receiving node writes the primary store first — that write is the commit point — then pushes the value directly to the peer broker and writes the mirror store; the peer never re-fetches. A node holding only one store escalates the put upstream to the laptop, which always has both. +6. **Dual-store, one primary.** Puts go to BOTH Bitwarden Secrets and 1Password, kept in sync by construction plus a periodic reconcile that repairs drift from the primary. **Recommendation: Bitwarden Secrets primary, 1Password mirror** — against Drew's initial lean, on evidence (the broker stack already runs headless on Bitwarden machine tokens; Bitwarden's list is the only one-call delta source; 1Password list is metadata-only and its service accounts are rate-limited; 1Password keeps its human custody/escrow strength as mirror and recovery path). Ratification is an open question on #13948, decider Drew. A Bitwarden-only node bootstraps store access via the canonical Bitwarden path (its access token is itself a vaulted secret, fetched by name). + +## Build slices (dependency-ordered; acceptance criteria on #13948) + +S1 client bound + one-call refresh (closes #13893) · S2 delta refresh + watermark · S3 keyed set hash + peer status · S4 peer pull sync · S5 client surface (`refresh`, get flags, `put`; includes the 1Password capability spike) · S6 reconcile + drift repair. Rollout is laptop-first, peer verbs behind a config flag, `put` dark until reconcile is live. Verification includes the two timed cold starts Drew's framing implies — peer up (serving in seconds, zero bws calls) and peer down (serving via upstream, one list call) — plus hash-equality proof, put propagation from each node class, a drift-repair drill, and a log audit proving a canary value appears nowhere. + +## Security shape + +No new trust root: peer sync rides the existing fleet enrollment and broker tokens. Values move only on the existing tailnet broker channel (WireGuard-encrypted) and broker↔store TLS. Logs carry names, counts, timings, truncated hashes — never values. Put requires enrollment-grade auth and is audit-logged by name + actor + timestamp. + +*Secrets are referenced by name only throughout this record; no values appear here or on the linked issues.* diff --git a/doc/README.md b/doc/README.md index a439e7868..9e3357c60 100644 --- a/doc/README.md +++ b/doc/README.md @@ -59,6 +59,7 @@ Folders are named `__`. The kinds in use are `feature` - [Code Book programme — Census B merged priority list](2026-11-24T00-55-23Z_research_code-book-census-priorities/2026-11-24T00-55-23Z_research_code-book-census-priorities.md) — research record for #13905 (census 2026-11-23/24): the merged, dependency-ordered priority list for the Code Book programme — 30 items ordered execution substrate (fleet) first, then physical substrate (lab), data substrate, search intelligence (Atlas×ID), the ID platform build-out, gateway/PM/fork surfaces, and the record itself — each item with its type, status and evidence, most-related issues, and ordering rationale, plus a per-book assignment table (fleet 4 · atlas 8 · id 9 · mcpx 1 · pm 4 · lab 4), timing notes that invent no dates, and the census gaps carried forward (service-worker/offline and switches have no owning issue; the #10706/#10708 discovery blocker is unverified). - [CNCF landscape — the slice this estate will actually need](2026-11-23T22-33-41Z_research_cncf-landscape/2026-11-23T22-33-41Z_research_cncf-landscape.md) — research record (2026-11-23): ~150 cloud-native projects across the seven areas this estate will need, each with CNCF status (graduated / incubating / sandbox / not CNCF) and an estate verdict — observability (OpenTelemetry as the contract; Prometheus as the language, VictoriaMetrics as the store; Grafana stays; no open-source Datadog exists), networking (Cilium yes; Gateway API after ingress-nginx's March 2026 retirement; MetalLB is the remembered LAN LoadBalancer; no service mesh yet), platform & GitOps (Flux over Argo CD for us; Cozystack fits with the caveat that it decides storage/tenancy/GitOps for you; Crossplane graduated but not now), data (TiKV no — a storage layer, not a database, and its Jepsen record is honest; CloudNativePG + replicas; NATS yes with a JetStream shape; LINSTOR over Rook), security & identity (Keycloak ≠ OpenBao; cert-manager and Kyverno when Kubernetes lands; SPIRE later, chained under the fleet CA; OPA management-plane only), runtimes (no OCI runtime is "much faster"; KubeVirt graduated and is the VMs-in-Kubernetes answer; Wasm apps designed to the Component Model, not WasmEdge), and registries & builds (GHCR until friction, then Zot; Harbor is a registry and Dragonfly a distribution layer, not alternatives; Nix + Actions already win the build category). Includes the Oct–Nov 2026 status-correction list (Crossplane, KubeVirt, NATS, Dragonfly graduated; CloudNativePG, OpenFGA promoted) and the uncertain-name identifications (Argonize doesn't exist; Trimmer→Tremor; Yuki→youki; Percy→Pixie; Spiffy→SPIFFE). - [Multi-transport reach — any protocol as a carrier](2026-11-24T01-04-53Z_design_multi-transport-reach/2026-11-24T01-04-53Z_design_multi-transport-reach.md) — programme direction record (Drew, 2026-11-23) for epic #13926 and head design #13929: the P2P/ID/fleet stack reachable over many alternate transports and proxied systems (Spritely-style relays, Tor, Noise, ActivityPub, ATProto, email, MQTT, HTTP/REST, MCP, IRC, Zulip, Slack, Discord bots, Gopher, Gemini, telnet, physical media), each adapter at a declared level (read / bidirectional / write-capable / sync-equivalent), with asymmetric send/receive paths as a first-class design requirement. +- [Secrets plane — delta refresh, broker peer sync, dual-store puts](2026-11-24T01-23-30Z_design_secrets-plane-sync/2026-11-24T01-23-30Z_design_secrets-plane-sync.md) — design record for #13948 (Drew, 2026-11-23): the secrets broker refresh becomes delta-first (one `bws secret list`, apply only entries whose `revisionDate` moved), brokers sync peer-to-peer behind a keyed set hash (v1 peer payload is the full set; a full upstream refresh is needed only when the laptop is down and the broker restarted with no cache), `fleet secrets` gains `refresh`, `get --upstream/--no-cache`, and a `put` that commits to the primary store then pushes to the peer and the mirror, and the two stores are kept in sync with Bitwarden Secrets recommended as primary and 1Password as mirror on the evidence in the design. Companion to-dos: #13950 (embed both stores in the fleet binary), #13952 (`fleet init` bootstrap command). - [Roc ecosystem research](2026-11-23T22-00-25Z_research_roc-ecosystem/2026-11-23T22-00-25Z_research_roc-ecosystem.md) — research record (2026-11-23): the state of the Roc language ecosystem — the new Zig compiler (feature parity July 2026; 0.1.0-RC1 shipped 2026-11-21, promotion to 0.1.0 still open), platforms (basic-cli, basic-webserver, Joy, roc-ray, roc-gui, Cloudflare Workers, native Android), the new-compiler package canon, real projects and production use (Joy/roc-deflate, roc-chat), a 30-day Zulip digest (linear types decided against FBIP; the LLM-generated-code conversation, no policy adopted; tooling and distribution progress), and the talks/releases/showcases worth watching. - [Actions exec — build and tiered-extension proof material](2026-11-24T00-39-49Z_report_actions-exec-proof-material/2026-11-24T00-39-49Z_report_actions-exec-proof-material.md) — raw proof scripts and run logs for #13774: the ACTIONS-EXEC-2 build (broker verbs, OIDC RS256 gate, fleet actions family; handoff proven end to end twice; the second run failed at the agent-install step and its diagnosis is held behind a flag hold) and the ACTIONS-EXEC-3 tiered lease-extension policy (design amendment and completion record on the issue; fleet-queue 616 and fleet bin 141 tests passing; live tier proof on the generation-8 broker; push delivery blocked by the PM intake 401, #13902). Backfilled from lane /tmp under the work-product landing rule. - [OpenRouter post-reset through-route probe](2026-11-24T00-22-00Z_report_openrouter-route-probe/2026-11-24T00-22-00Z_report_openrouter-route-probe.md) — verification record for #13677 (2026-11-24): two post-reset probe sessions through the openrouter-free-plan route completed, but the server session records show both were served by other providers (claude-payg and _muse), not by OpenRouter :free models, so the owed verification stays open in substance and the next diagnostic is named. Backfilled from the goal workspace under the work-product landing rule.