Repository navigation
Description
Context
Drew's directive, 2026-11-23: improve fleet placement dispatch along the
hybrid lines agreed in chat — dispatch stays decentralized (each
seat's fleet binary decides placement locally; that resilience is
deliberate and was proven the same night, when dispatch kept working
while the queue broker's session-proxy leg was down), and only the
decision state gets centralized.
Today the placement session records (the fp_… handles) live only in a
per-seat JSON file, ~/.local/state/fleet-place/sessions.json
(pkgs/fleet/crates/fleet-queue/src/placement.rs). The intake design
(doc/placement-intake/placement.md, absorbed under #5413) labeled
that store a stopgap and carried DDL for a dedicated session table.
The queue backend has since consolidated on Turso behind the
queue-broker, so the table lands there as placement_sessions (the
Supabase agent. schema in the intake DDL is historical). Dispatch
itself was verified end to end on 2026-11-23; the sandbox-seat gap is
#13122. #4986 (placement records on dispatches) is related but
distinct — this issue is the session store only.
Design (slice 1)
Schema — one new table in the Turso queue backend, added to the
SCHEMA set in turso_queue/core.rs so ensure_schema creates it
with CREATE TABLE IF NOT EXISTS on every broker start:
CREATE TABLE IF NOT EXISTS placement_sessions (
handle TEXT PRIMARY KEY, -- 'fp_' || 32 hex chars
record TEXT NOT NULL, -- the full session record JSON;
-- the client record shape is the contract
state TEXT, -- extracted: queued|running|succeeded|failed|cancelled|dispatched
surface TEXT, -- extracted: registry surface id
submitted_by TEXT, -- extracted: for list --mine
run_id INTEGER, -- extracted: correlated Actions run
created_at TEXT NOT NULL,
updated_at TEXT NOT NULL
);
CREATE INDEX IF NOT EXISTS placement_sessions_created
ON placement_sessions(created_at);Broker verbs — new turso_queue verbs, dispatched and
authenticated exactly like the existing queue verbs (the broker shell
does not change):
/placement-put{record}— upsert by handle (a seat refreshing a
session's state is the authority for that update)./placement-get{handle}— the stored record, or null./placement-list{submitted_by?, limit?}— newest first, bounded./placement-sync{records}—INSERT OR IGNOREbatch; the
migration path. Never overwrites a row the backend already holds.
Client (placement.rs + one transport helper):
- The local JSON store stays the always-available store and the
only input to placement decisions:build_ctxand the
Blacksmith budget reconcile read local state exactly as today.
Decisions never depend on the backend. - Session records additionally mirror to the backend, best-effort,
through a bounded broker roundtrip (new helper in the client
transport: same routes as the queue client — direct broker URL /
broker socket, else the session proxy — with short timeouts, no
broker auto-spawn, and errors returned, never a process exit). - Write path: local commit first (unchanged semantics, unchanged
lock), then a best-effort/placement-put. Any failure is silent —
a dispatch can never fail or stall because the backend is down. - Read paths (
session status/session result, the--followup
lookup,session list): consult the backend, prefer the record
with the newerupdated_atacross the two stores, refresh state
from GitHub exactly as today, and persist the refreshed record to
both stores. - Migration of existing local sessions: after a successful dispatch
commit, and onsession list, a best-effort/placement-sync
pushes local records the backend lacks (bounded, most recent
first). Pre-existing per-seat stores converge into the backend
without an operator step. - Escape hatch:
FLEET_PLACE_REMOTE=offdisables the remote mirror
(operator + test use).
Acceptance criteria
- Dispatch on seat A;
fleet queue session status <fp_ handle>on
seat B (empty local store) returns the session. - With the broker unreachable, dispatch + status/result/list behave
exactly as today (local store only). - A pre-existing local
sessions.jsonmigrates: after one dispatch
or list against a reachable backend, its records are readable
from another seat, and sync never overwrites a backend row. - Placement decisions (dry-run output, Blacksmith budget accounting)
are unchanged with the backend up, down, or disabled. - Tests name their oracles: backend verb tests against the stub
pipeline (SQL + reply mapping), client fallback/merge tests
against a fake remote, and a boundedness test for the transport
helper.
Breakdown
- Slice 1 (this issue): schema + broker verbs + client mirror
with local fallback + opportunistic migration + runbook update
(the broadcast string gains the binary-acquisition block). - Later slice (recorded, not in scope): a fleet-wide Blacksmith
minute ledger — only if Blacksmith spend grows; the per-seat local
ledger stays until then. - Later slice (recorded, not in scope): hard cap enforcement at
decision time (admission control against the caps placement
currently only steers by).
Activity
developing-today commentedon Nov 23, 2026
CODE-4796
feat(fleet): mirror placement sessions to the queue backend (placemen…
Merge pull request #13169 from developing-today/lane-placement-sessions
dezren39 commentedon Nov 23, 2026
Slice 1 landed — PR #13169, merged 15b2ac8
What shipped (head eca57d1):
placement_sessionsadded to the SCHEMA set inturso_queue/core.rs(created byensure_schemaon brokerstart; no separate migration step). New module
turso_queue/placement_sessions.rs:session_rowextraction(the client record is the contract; scalars extracted for
queries) + the four verbs, routed in
stacks_outbox.rs:/placement-put(upsert),/placement-get,/placement-list,/placement-sync(insert-or-ignore batch).broker_roundtrip_boundedinclient/transport.rs— the queue client's routes with acaller-set budget on every leg, HTTP errors as Err, no
session-broker auto-spawn, bad URL degrades to Err.
placement/remote.rs(SessionRemotetrait,BrokerRemoteat a 5 s budget,NullRemote,FLEET_PLACE_REMOTE=offescape hatch, pick/merge/sync helpers).placement.rswiring: commit stays local-first, mirror putafter; refresh re-mirrors; status/result/followup reads take
the newer of local vs backend by
updated_at(a backend hitalso seeds the local store);
session listunions both storesand runs the migration sweep; dispatch runs the sweep after the
local commit.
fallback; the broadcast string gained the approved
binary-acquisition block (bootstrap pin route + the
release-asset route for non-Muse machines, tag read from the
FLEET_URL/FLEET_SHA256pin block inscripts/muse/bootstrap.sh,.sha256verification, post-installchecks
fleet queue dispatch --help+fleet queue surfaces).Verification
cargo check -p fleet-queue --features client,queue-broker:clean.
all 15 new tests pass by name (7 backend verb tests against the
stub pipeline, 4 remote pick/merge/sync tests, the commit-mirror
wiring test, 2 bounded-transport tests).
new tests; chunked_list 2; person_wait_cli 5; doc-tests 0) —
run on the laptop worktree. The remote dispatch route was tried
first (runs 45150362527, 45151395564, 45154863900, 45156432278)
and is currently unusable for Rust: the fleet-build image has
no cargo on PATH and no assembled sysroot on a stable path —
filed as fix(fleet): fleet-command Run step lacks the toolchain on PATH — dispatched cargo commands fail 127 #13170 with probe evidence.
identically); the change follows house style.
Acceptance criteria status
rollout (broker gains the verbs and seats gain the client
from main, same as every fleet change; no deploy-profile or
seat changes were made by this slice). This issue stays open
for that record.
mirror-failure wiring test + NullRemote/fake-remote tests.
/placement-syncinsert-or-ignore + the sync sweep test.build_ctxand the reconcile read thelocal store exactly as before; full placement suite green.
names its oracle).
Next slices (unchanged, in order): live cross-seat
verification once the rollout lands a broker + two seats on the
new build; then the conditional Blacksmith minute ledger (only
if spend grows); then hard cap enforcement at decision time.
dezren39 commentedon Nov 23, 2026
Criterion 1 verified live — cross-seat session status (rollout completion, 2026-11-23)
Criterion 1: Dispatch on seat A;
fleet queue session status <fp_ handle>on seat B (empty local store) returns the session.Setup, all on the bcc8043 build (
fleet-static-bcc8043, source revbcc8043b59ab97c20b639db473f2055c9961d43e):--registry(artifact/nix/store/dlvq6vkxhcv9bicjqvv90a6kwpi320rn-fleet-0.1.0, activated 2026-11-23T14:05:46Z; generation 5 kept as rollback). The broker process (MainPID 3065738) runs that artifact'sbin/fleet, whosefleet versionreports source revbcc8043b59ab…. Broker/healthzok; sandbox-seatfleet queue healthanswers against it.~/tools/fleetboth updated to the same build via the bootstrap flow (pinned release fetch, sha25633c1b5d0…verified);fleet-static-3cb241akept beside them as rollback.Evidence:
fleet queue dispatch --repo developing-today/code --ref bcc8043b59ab97c20b639db473f2055c9961d43e --command true --dispatch --json→ handlefp_0903fa1bd9ebe524ace8f23ade78ecc8,submitted_by: user@amd,created_at: 2026-11-23T14:15:04Z, surfacefleet-org-blacksmith, statedispatched.grep -c fp_0903fa1bd9ebe524ace8f23ade78ecc8 ~/.local/state/fleet-place/sessions.json→0before the read.fleet queue session status fp_0903fa1bd9ebe524ace8f23ade78ecc8 --jsonreturned the full record (repo/command/ref, decision reasoning,submitted_by: user@amd, statedispatched).2.Criteria 2–5 were already recorded as covered by the slice-1 landing (PR #13169, comment 7099021294). Criterion 1 was the last open criterion; closing this issue as completed.