From 7d305e4048cae5c3b3ce39c42f1aa1fadbce97e6 Mon Sep 17 00:00:00 2001 From: Drewry Pope Date: Mon, 23 Nov 2026 12:04:13 -0600 Subject: [PATCH] docs(fleet): align operator guidance with placement and broker handlers --- pkgs/fleet/book/concepts/placement.md | 14 ++++++----- pkgs/fleet/book/concepts/secrets.md | 14 ++++++----- .../book/getting-started/installation.md | 15 +++++++----- pkgs/fleet/book/library/placement.md | 12 ++++++---- .../book/operations/health-and-healing.md | 2 +- pkgs/fleet/book/operations/troubleshooting.md | 4 ++-- pkgs/fleet/book/reference/queue-dispatch.md | 16 ++++++------- pkgs/fleet/book/tutorials/dispatch-a-build.md | 24 ++++++++++--------- pkgs/fleet/book/tutorials/resolve-a-secret.md | 13 +++++----- pkgs/fleet/book/tutorials/run-the-brokers.md | 13 +++++----- 10 files changed, 68 insertions(+), 59 deletions(-) diff --git a/pkgs/fleet/book/concepts/placement.md b/pkgs/fleet/book/concepts/placement.md index a94a02c02f..9b3725cb7f 100644 --- a/pkgs/fleet/book/concepts/placement.md +++ b/pkgs/fleet/book/concepts/placement.md @@ -236,10 +236,10 @@ handle, despite the workflow describing it as one. A dispatched job gets a session handle: `fp_` plus 16 random bytes from `/dev/urandom`, hex-encoded — `fp_` plus 32 lowercase hex characters, 128 -bits. Records live in the local store at `$FLEET_PLACE_STATE/sessions.json`, -default `~/.local/state/fleet-place/sessions.json` — a labelled stopgap with -the reference implementation's path and record shape, so records migrate -when the designed queue-backend table lands. The store is guarded by a lock +bits. The local store at `$FLEET_PLACE_STATE/sessions.json` defaults to +`~/.local/state/fleet-place/sessions.json`. Dispatch commits locally and then +mirrors the record to the queue broker’s `placement_sessions` table. The +placement decision uses the local session history. The store is guarded by a lock directory (waiters poll every 50 ms up to 15 s; a lock older than 120 s is stale and is broken) and written by rename of a temp file, with keys recursively sorted. @@ -253,11 +253,13 @@ recorded-field caveat, stated as the source behaves: `actor` is hardcoded to `developing-today[bot] (GitHub App dispatch)` even for surfaces that dispatch as the user. -`fleet queue session status|result|list` reads the store: `status` refreshes +An `fp_` lookup for status, result or follow-up selects the newer copy by +`updated_at` across the local store and the broker mirror. Status and result +can seed the local store from that record. The session verbs then work as follows: `status` refreshes the record from GitHub and prints its state, surface, and run URL; `result` adds `terminal` (true exactly for `succeeded|failed|cancelled`) and, when not terminal, the note "not terminal yet — reconnect with the same handle"; -`list` prints stored records newest first without refreshing (`--mine` +`list` combines local records with up to 200 from the mirror, then prints them newest first without refreshing GitHub (`--mine` filters to the current `USER@hostname`). Anywhere a handle is accepted, the portable `OWNER/REPO#RUN_ID` is accepted too and is resolved **directly against GitHub without the local store** — the repo must be a registered diff --git a/pkgs/fleet/book/concepts/secrets.md b/pkgs/fleet/book/concepts/secrets.md index c22955b5f9..8aa19fc7c3 100644 --- a/pkgs/fleet/book/concepts/secrets.md +++ b/pkgs/fleet/book/concepts/secrets.md @@ -41,9 +41,10 @@ TTL, 3 for a token-file or bind failure. The broker's own token file is ## The serving gate: 503 until loaded `serving` is true only once at least one refresh has _succeeded_. Before -that, `/health` answers **503** with `ok:false, serving:false` (plus -`refresh_error` when a refresh has failed), and `GET /secret/` -answers 503 `{error: "secrets not loaded yet", …}`. A live process whose +that, public `/health` answers **503** with `ok:false, serving:false`. +An authenticated `GET /secret/` answers 503 with +`error: "secrets not loaded yet"` and includes `refresh_error` when a +refresh has failed. A live process whose `bws` cannot run is _not_ serving, and health says so: not-loaded is a distinct, diagnosable state, not a 404. Clients key on this gate. @@ -76,9 +77,10 @@ during a refresh, and a failed refresh keeps the old values. One refresh is loudly rather than silently dropping a secret), then one `bws secret get` per secret, fetched **8-way parallel** (an 8-worker pool over the name list). Each `bws` child has a deadline, so a hung child fails its fetch -instead of wedging the refresh — and the `refreshing` flag — forever. A -second refresh requested while one is in progress is refused -(`refresh already in progress`). +instead of wedging the refresh — and the `refreshing` flag — forever. The authenticated +`POST /refresh` acknowledges the request with 202. If a sweep is already +running, the worker skips the overlapping sweep. Use `last_refresh_unix` +and `refreshing` on `/health` to follow progress. A refresh installs **per secret**, not all-or-nothing: fetches that succeed land immediately with the batch's install time; a secret whose fetch fails diff --git a/pkgs/fleet/book/getting-started/installation.md b/pkgs/fleet/book/getting-started/installation.md index 0224fd322c..25e72823e4 100644 --- a/pkgs/fleet/book/getting-started/installation.md +++ b/pkgs/fleet/book/getting-started/installation.md @@ -40,16 +40,19 @@ failed (the message names it), 2 usage. Phases are selectable with `--only ` / `--skip `; `--all` additionally restores `~/git` and `~/agents`. -**The pin.** Two lines near the top of the script, both overridable from the -environment, pin the release: +**The pin.** Read the matched asset URL and SHA-256 from the same checkout of +`scripts/muse/bootstrap.sh` that you intend to run: ```sh -FLEET_URL="${FLEET_URL:-https://github.com/developing-today/code/releases/download/fleet-static-b8bbcc0/fleet-x86_64-linux-musl}" -FLEET_SHA256="${FLEET_SHA256:-}" +grep -E '^FLEET_(URL|SHA256)=' scripts/muse/bootstrap.sh ``` -The URL is exactly the publish tag scheme (`fleet-static-<7-char short sha>`) -plus the asset name. `FLEET_AGENT` (default `muse`) and `FLEET_AGENT_GROUPS` +Bootstrap uses those defaults and verifies the downloaded binary. When +overriding the release, supply both `FLEET_URL` and `FLEET_SHA256` for the +same published asset. After installation, check `fleet version` and +`fleet capabilities` on the seat. + +`FLEET_AGENT` (default `muse`) and `FLEET_AGENT_GROUPS` select the seat identity; groups are never hardcoded for another agent kind. **The phases**, in the order `PHASES="tools token restore tailnet fleet persist init check"`: diff --git a/pkgs/fleet/book/library/placement.md b/pkgs/fleet/book/library/placement.md index df4f3c98d9..c9250529d1 100644 --- a/pkgs/fleet/book/library/placement.md +++ b/pkgs/fleet/book/library/placement.md @@ -225,11 +225,13 @@ order, Tier 3 Codespaces, then exhaustion — is walked step by step in ## The session store format -Placement sessions are a labelled **stopgap**: a local JSON store at -`$FLEET_PLACE_STATE/sessions.json`, defaulting to -`~/.local/state/fleet-place/sessions.json` — the same path and record -shape the reference implementation used, so records migrate rather than -being redesigned when the designed backend table lands. +The local store at `$FLEET_PLACE_STATE/sessions.json` defaults to +`~/.local/state/fleet-place/sessions.json`. Its existing record shape +remains readable. Dispatch commits locally before its best-effort mirror +write to the broker’s `placement_sessions` table. Listing merges local +records with up to 200 broker records and attempts to insert missing local +records into the mirror. Status, result and follow-up prefer the record +with the newer `updated_at` and select the broker copy on ties. Store shape: diff --git a/pkgs/fleet/book/operations/health-and-healing.md b/pkgs/fleet/book/operations/health-and-healing.md index aaaaf6b6b3..bd6a17276c 100644 --- a/pkgs/fleet/book/operations/health-and-healing.md +++ b/pkgs/fleet/book/operations/health-and-healing.md @@ -8,7 +8,7 @@ Fleet has no single health endpoint; it has a health _surface_ per layer, and th | ------------------------------- | ------------------------------------------------------------------------------------------ | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | Queue as a client sees it | `fleet queue health [--queue ] [--worker ]` | The queue client can reach the broker (`POST /health`) and the broker's health rows come back. `--worker` scopes the answer to that worker's view. Distinct from the broker's own unauthenticated probe, below. | | Queue-broker liveness | `GET /healthz` on the queue-broker (port 4801 on the laptop) | The broker process answers. Unauthenticated — the only unauthenticated queue-broker route. It answers before the Turso backend is up (the backend starts on a separate thread), so it proves liveness, not readiness. | -| Secrets-broker readiness | `GET /health` on the secrets-broker (port 4800) | Returns `{ok, serving, secrets, last_refresh_unix, refreshing, oldest_secret_age_seconds}`. **503 while `serving` is false** — `serving` becomes true only once at least one refresh has succeeded. Before that, the body carries `refresh_error` when a refresh has failed. A live process whose `bws` cannot run is _not_ serving, and this endpoint says so. | +| Secrets-broker readiness | `GET /health` on the secrets-broker (port 4800) | Returns `{ok, serving, secrets, last_refresh_unix, refreshing, oldest_secret_age_seconds}`. **503 while `serving` is false** — `serving` becomes true only once at least one refresh has succeeded. The public response exposes readiness and timing. An authenticated not-loaded secret read can include `refresh_error` after a failed refresh. A live process whose `bws` cannot run is _not_ serving, and this endpoint says so. | | Session-broker (proxy) liveness | `fleet proxy` broker hello via `fleet init`'s probe; the broker also self-checks its peers | The session proxy answers on its socket and speaks the hello/capability handshake. `fleet init` reporting the proxy role as live is the practical check. | | Bridge health | `fleet bridge health` | The message bridge's `/healthz` answers. No token needed. Proves the bridge service, not your seat's mailbox access — for that, read a mailbox (`fleet bridge inbox --agent --limit 1`). | | Seat health, all legs | `fleet agent doctor [--agent ]` | Four independent probes issued together — the **legs**: **bridge** (`bridge inbox --agent A --limit 1` with a name, else `bridge health`), **queue** (`queue health`), **github** (`gh api rate_limit` via `fleet gh`, falling back to plain signed-in `gh`), **shell** (`laptop-agent health`). There is no secrets leg: secrets is folded into the bridge leg's stated need. From the legs, doctor derives the **rungs** map (which intake rungs this seat still has: push = bridge leg, queue = queue leg, shortlist = always true, priority = github leg) and the `builds` line. Exit 0 when any intake rung is live, else 3. | diff --git a/pkgs/fleet/book/operations/troubleshooting.md b/pkgs/fleet/book/operations/troubleshooting.md index 9634eb7829..d0c6635e9c 100644 --- a/pkgs/fleet/book/operations/troubleshooting.md +++ b/pkgs/fleet/book/operations/troubleshooting.md @@ -12,8 +12,8 @@ Symptom → cause → fix. Each entry names the check that confirms the cause be ## Secrets broker stuck refreshing (503, very many `bws` fetches) - **Symptom:** `fleet secrets get ` fails or reports the broker not serving; `GET /health` on the secrets-broker answers 503 with `serving=false` for a long time; the broker's refresh appears to run constantly (the shape recorded as issue #13081 involves on the order of 220 `bws` fetches in a refresh cycle). -- **Cause:** The broker's full-vault refresh has not yet _succeeded_. `serving` only becomes true once a refresh completes (`last_refresh_unix` is set); a refresh that keeps failing or being restarted keeps the broker in the not-serving state, and `/health` reports `refresh_error` when a refresh has failed. -- **Confirm:** `GET /health` — check `refreshing`, `last_refresh_unix`, and `refresh_error`. A cached read that succeeds carries `source: "cache"` and an `age_seconds`; that tells you the broker once served and how stale the value is. +- **Cause:** The broker's full-vault refresh has not yet _succeeded_. `serving` only becomes true once a refresh completes (`last_refresh_unix` is set); a refresh that keeps failing or being restarted keeps the broker in the not-serving state, and public `/health` continues to return 503. +- **Confirm:** `GET /health` — check `refreshing` and `last_refresh_unix`. An authenticated secret read while the cache is unready can return a 503 body with `refresh_error` after a failed refresh. A cached read that succeeds carries `source: "cache"` and an `age_seconds`; that tells you the broker once served and how stale the value is. - **Fix:** Fix the refresh's cause (the `bws` route and its token, by name — never by pasting a value anywhere), then let **one** refresh complete. **Do not restart-loop the broker:** every restart discards refresh progress and restarts the clock, converting a slow recovery into a permanent 503. A process that is alive and returning 503-with-`serving=false` is in a known state, not crashed. ## Queue double-serve: a parked, completed, or cancelled task is served again (#13091) diff --git a/pkgs/fleet/book/reference/queue-dispatch.md b/pkgs/fleet/book/reference/queue-dispatch.md index c4ab5f5081..15b3ad12d7 100644 --- a/pkgs/fleet/book/reference/queue-dispatch.md +++ b/pkgs/fleet/book/reference/queue-dispatch.md @@ -40,10 +40,10 @@ Known discrepancy: the help line says `[--ref REF]`; the placement module's froz Exit codes: 0 decision printed (dry run) or dispatched · 2 usage / unknown surface / bad flag value (this family's errors are exit 2). ```text -$ fleet queue dispatch --repo developing-today/code --command 'nix build .#fleet' --json -{"surface": "fleet-org", "provider": "github", "platform": "linux", "dry_run": true, "reason": "owner capacity available; sticky threshold not reached"} -$ fleet queue dispatch --repo developing-today/code --command 'nix build .#fleet' --dispatch -fp_9f2c41aa07b34d5e8c01aa22334455 +$ fleet queue dispatch --repo developing-today/code --command 'nix build .#fleet' --json | jq -r .mode +dry-run (no session written; pass --dispatch to submit) +$ fleet queue dispatch --repo developing-today/code --command 'nix build .#fleet' --dispatch --json | jq -r .handle +fp_d0a842c9bd33aa2999f5a12393397ab9 ``` ## fleet queue session status @@ -59,7 +59,7 @@ usage: repo-queue session [HANDLE|OWNER/REPO#RUN_ID] [--min | `--json` | boolean | off | Print the record as JSON instead of the one-line text form. | | `--registry` | file path | resolution order (see `surfaces`) | Placement registry file. | -**Behaviour.** Session records are a labeled **STOPGAP**: a local JSON store at `~/.local/state/fleet-place/sessions.json` (same path/shape as the reference implementation, so records migrate when the designed placement-sessions table lands). The store is lock-guarded on write. `session status ` refreshes the record from GitHub and prints `: state= surface= run=` (or the record as JSON with `--json`). +**Behaviour.** Dispatch commits the session locally, then mirrors it to the queue broker on a best-effort basis. For an `fp_` handle, status selects the newer local or broker record by `updated_at` (the broker wins ties). A broker record can seed an empty local store on a second seat. Status then refreshes the provider state and prints the handle, state, surface and run URL. A failed mirror read leaves the local path available. Help: a help flag after the subcommand prints the session usage and exits 0 — `session status --help` asks for help; it does not look up a session named `--help` (#13175). The flags documented here come from source. @@ -107,7 +107,7 @@ usage: repo-queue session [HANDLE|OWNER/REPO#RUN_ID] [--min | `--json` | boolean | off | Print `{"sessions": […]}` instead of one status line per session. | | `--registry` | file path | resolution order (see `surfaces`) | Placement registry file. | -**Behaviour.** Lists all session records in the local store, newest first. Text form is one status line per session, or `no sessions`; `--json` gives `{"sessions": […]}`. Group-level behaviour: `session` with no subcommand prints the usage and returns 2; `session --help` prints usage and returns 0; an unknown subcommand dies exit 2. +**Behaviour.** Combines the local store with up to 200 broker records, deduplicates by handle and sorts by creation time, newest first. A failed broker read leaves the local records available. Listing shows the recorded state without polling GitHub. Text form is one status line per session, or `no sessions`; `--json` gives `{"sessions": […]}`. Group-level behaviour: `session` with no subcommand prints the usage and returns 2; `session --help` prints usage and returns 0; an unknown subcommand dies exit 2. Exit codes: 0 ok · 2 usage / unknown subcommand. @@ -119,14 +119,14 @@ fp_d0a842c9bd33aa2999f5a12393397ab9: state=running surface="fleet-org" run=https ## fleet queue surfaces ```text -usage: repo-queue surfaces [--registry PATH] +usage: repo-queue surfaces [--json] [--registry PATH] ``` | Flag | Argument | Default | Meaning | | ------------ | --------- | -------------------------------- | ----------------------- | | `--registry` | file path | resolution order (see Behaviour) | Registry file to print. | -**Behaviour.** Prints the resolved placement registry verbatim as pretty JSON, exit 0. `surfaces --help` prints a short usage instead of the registry. Registry resolution order: `--registry ` or env `FLEET_PLACE_REGISTRY` → a home copy → the source-tree relative path → the registry **embedded in the binary**. Registry shape (version 2): `{comment, version, laptop: {busy, busy_source, note}, owners: {: {concurrent_jobs_cap, concurrent_macos_cap, plan, private_minutes_monthly}}, surfaces: […]}`. +**Behaviour.** Prints the resolved placement registry as pretty JSON, exit 0. The optional `--json` flag selects the same output. `surfaces --help` prints a short usage instead of the registry. Registry resolution order: `--registry ` or env `FLEET_PLACE_REGISTRY` → a home copy → the source-tree relative path → the registry **embedded in the binary**. Registry shape (version 2): `{comment, version, laptop: {busy, busy_source, note}, owners: {: {concurrent_jobs_cap, concurrent_macos_cap, plan, private_minutes_monthly}}, surfaces: […]}`. The shipped surfaces: `fleet-personal` (github-actions, dezren39/fleet, App installation, active), `fleet-org` (github-actions, developing-today/fleet, user-token dispatch, active; also the Blacksmith host), `fleet-forks` (github-actions, developing-today-forks/fleet, **public targets only**, active), `org-run` (standby, retained for manual use; placement prefers fleet-org), `fleet-org-blacksmith` (kind `blacksmith`, Linux-only fallback; budget 3000 free min/mo, paid cap 0 — paid overage disabled unless a dispatch explicitly supplies `--allow-paid-blacksmith`), `codespace-overflow` (kind `codespace`, status `pending-scope`, max 3 live, 180 core-hours/mo budget; uses existing codespaces only, never creates them), `laptop` (kind `laptop`, `handoff-only` — a placement record only; this adapter never runs shell commands on the laptop). Targets accept exact `owner/repo`, `owner/*`, or `*`. `sticky_queue_threshold: 2` and `selection_priority` (10 for the active runners, 20 for org-run) drive the cascade. diff --git a/pkgs/fleet/book/tutorials/dispatch-a-build.md b/pkgs/fleet/book/tutorials/dispatch-a-build.md index 9f5bebf2d4..1922fe84ec 100644 --- a/pkgs/fleet/book/tutorials/dispatch-a-build.md +++ b/pkgs/fleet/book/tutorials/dispatch-a-build.md @@ -105,12 +105,14 @@ has the form `fp_` followed by 32 lowercase hex characters, for example: fp_d0a842c9bd33aa2999f5a12393397ab9 ``` -Keep it. The handle is how you poll (Step 3), how a follow-up finds this -run (Step 5), and how the session is recorded in the local store at -`~/.local/state/fleet-place/sessions.json` (override the store directory -with `$FLEET_PLACE_STATE`). That store is a labelled stopgap with the -reference implementation's record shape, kept so records migrate when -the designed backend table lands. +Keep the handle. Use it to poll (Step 3) and to submit a follow-up (Step 5). +Dispatch records it in `~/.local/state/fleet-place/sessions.json` (override +the directory with `FLEET_PLACE_STATE`) and mirrors it to the queue broker. +On a second seat with access to that broker, inspect the same handle: + +```bash +fleet queue session status --json +``` How dispatch actually happens, so the output makes sense: for the chosen surface's host repo, the client snapshots existing workflow runs, POSTs @@ -172,16 +174,16 @@ fleet queue session list fleet queue session list --mine ``` -`list` prints every record in the local store, newest first — from the -stored state, **without** refreshing. `--mine` keeps only records whose +`list` merges the local store with up to 200 broker records and shows their +stored state, newest first. `--mine` keeps only records whose `submitted_by` is the current user on this host. What can go wrong, and the fix: - `repo-queue: no session with handle in `, exit `2`: - the handle is not in this seat's local store. Handles are local — - another seat's store does not have your record. Use the portable - reference instead (Step 4), which resolves live without the store. + neither the local store nor the broker supplied the session. Check broker + access on both seats. Once the run ID is known, use the portable reference + (Step 4) to read the run directly from GitHub. - Passing `--help` to `session status` or `session result` is safe: a help flag after the subcommand prints the session usage and exits 0 — it is never taken as a handle. diff --git a/pkgs/fleet/book/tutorials/resolve-a-secret.md b/pkgs/fleet/book/tutorials/resolve-a-secret.md index e402bbec85..e63b34cebe 100644 --- a/pkgs/fleet/book/tutorials/resolve-a-secret.md +++ b/pkgs/fleet/book/tutorials/resolve-a-secret.md @@ -183,11 +183,10 @@ last_refresh_unix, refreshing, oldest_secret_age_seconds}`. `oldest_secret_age_seconds` tells you the stalest value it can serve. A resolution failure against a serving broker is a `404` problem (Step 4), not a health problem. -- HTTP `503` with `serving: false`: no refresh has succeeded yet. If the - body carries `refresh_error`, that is the diagnosis — the refresh's - `bws` leg is failing (credential, missing `bws`, malformed vault - entry). Fix that leg; the broker keeps answering health honestly - while it cannot serve. +- HTTP `503` with `serving: false`: no refresh has succeeded yet. + Check `refreshing` and `last_refresh_unix`. A failed authenticated + secret read during startup can include `refresh_error` in its 503 + response. Use that diagnostic when available. - No answer at all: the broker process is not running, or this seat cannot reach it. On a sandbox seat, run `fleet init` (it starts the local loopback broker copy the sandbox uses) or see @@ -201,8 +200,8 @@ the broker's `X-Agent-Token` header — supply the token through your normal operator tooling for the daemon-side token file (`~/.config/secrets-broker/token` on the laptop), without printing its contents or placing them in a command line. It answers -`202 {"ok": true, "refresh": "started"}`; a refresh requested while one -is already in progress is refused with "refresh already in progress". +`202 {"ok": true, "refresh": "started"}`. This acknowledges the request. +If a refresh is already running, the worker skips the overlapping sweep. Then re-read `/health`: a successful refresh sets `last_refresh_unix` and clears the recorded refresh error. diff --git a/pkgs/fleet/book/tutorials/run-the-brokers.md b/pkgs/fleet/book/tutorials/run-the-brokers.md index d8b6dfc9a1..73d8ee120c 100644 --- a/pkgs/fleet/book/tutorials/run-the-brokers.md +++ b/pkgs/fleet/book/tutorials/run-the-brokers.md @@ -186,11 +186,10 @@ refreshing, oldest_secret_age_seconds}`. cached name count; `oldest_secret_age_seconds` is the stalest value the broker can currently serve; reads are cache-first, with a read-through to Bitwarden on a miss. -- HTTP `503` with `serving: false` (and `refresh_error` when a refresh - has failed): the process is alive and its `bws` leg is not — the - single most useful diagnosis this broker gives. Fix the refresh's - Bitwarden credential or `bws` availability, then watch - `last_refresh_unix` appear. +- HTTP `503` with `serving: false` means the first successful refresh is + pending. Follow `refreshing` and `last_refresh_unix` on public health. + An authenticated secret read while unready can return a 503 with + `refresh_error` when a refresh has failed. - The client-side cross-check is `fleet secrets list`, which lists the broker cache's names and never falls back (see [Tutorial: resolve a secret](resolve-a-secret.md)). @@ -236,8 +235,8 @@ What can go wrong, and the fix: which point the broker exits `3` and your supervisor (or you) restarts it. - A restarted secrets broker serves `503` longer than a refresh should - take: read `refresh_error` in the health body (Step 4) — the process - is honestly reporting a dead refresh leg, not hiding it. + take: check the readiness fields in Step 4 and the most recent refresh + failure in the broker logs or the authenticated not-loaded response. ## You are done when