GeezerVisonThe World Wide Web, restored to 800 pixels of glory. | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Home|About|Gaming cabinet|Archives|How it works|Starter sites | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
GeezerVison is showing developing-today.github.io — The queue: tasks, lanes and leases - fleet The queue: tasks, lanes and leasesThe queue is the fleet’s shared work queue: one queue of tasks (units of
repo work), served by the queue broker over a dedicated Turso store, with a
GitHub-issue-comment fallback queue behind it. The client surface is
Source: https://github.com/developing-today/code/blob/main/pkgs/fleet/crates/fleet-queue/src/client.rs The task modelA task is created from a packet: a JSON document validated against
Envelope rules: Two stored-priority exceptions: at enqueue, a payload whose Dedupe. Enqueue dedupes on Enqueue has no default queue. The queue resolves from States and transitionsLive states:
Every transition writes an event row; Lanes and workersA worker is the claiming identity stamped on a row (default
The claim pick is atomic: highest priority first ( A claim may instead name several tasks at once: An enqueue may set the task’s top-level Leases and heartbeatA lease is the claim’s expiry. Claim’s default lease is 2700 s
(45 minutes), range 1..=86400, rejected outside it; a zero or negative
lease is born expired.
Holder verbs are holder-checked: the row must be claimed by this worker
(and lane, when supplied) and non-terminal, else exit 5 with “no matching
claimed row”. Park, wake, and ready-conditions
The ready-condition is a JSON object. Kinds a database sweeper can verify
from store state: A park (or block) that waits on a person — a Block and dependencies (
|
| Verdict | Derived when | Gate requires |
|---|---|---|
merged_verified | some pull in the readback is merged | at least 1 merged pull in the readback |
closed_verified | issue closed and no unfinished pulls | the issue state actually closed |
open_draft_with_followup | unfinished pulls exist, nothing merged, issue not cleanly closed | a recorded follow_up |
open_draft_superseded | operator-asserted, same family | a recorded follow_up |
invalid_no_work | none of the above | rejected if any linked pull still carries work |
A pull is unfinished when it is not merged and not closed. A follow-up is
exactly one of --follow-up-task <id> (checked by the broker at completion —
only the queue knows if it is live), --follow-up-issue <n|url> (same-repo,
open, must link the completed issue and every unfinished PR), or
--follow-up-pr <n> (must be in the readback and merged); any follow-up
target requires --reason. One exception: a closed issue may leave related
work open when the close was a deliberate act by a person (the readback’s
closed_by is checked against automation) and a verified follow-up owns
the remainder.
complete’s other rules: --result/--result-file must be a JSON object
(the file wins when both are given); --telemetry accepts only the keys
pool, model, effort, cost_usd; --queue is parsed but never used — a dead
flag, stated here because the source says so.
The fallback queue is a queue with no database: all state lives in GitHub
issue comments. Work items are open issues carrying the labels
queue/queued (waiting), queue/claimed (held), or queue/blocked
(blocked) — the same labels the broker-backed system maintains. The sweep
covers five repos in pilot order: developing-today/code,
developing-today-forks/opencode, developing-today-forks/openchamber,
dezren39/darwin-nix, dezren39/fleet (shortcuts code, opencode,
openchamber, nix, fleet).
A claim is the first line of a comment, exactly
<!-- fleet-claim v1 kind=claim worker=<id> ts=<rfc3339-utc> --> (kinds:
claim, heartbeat, release, unblock), with a human-readable line
under it. Because every fleet worker posts to GitHub as the same account,
the marker’s worker id is the only identity the lease can be keyed on, so
--worker is required, never defaulted (or the FLEET_FALLBACK_WORKER
environment variable). The lease window is 30 minutes by default
(--lease-min per verb, or FLEET_QUEUE_FALLBACK_LEASE_MIN). Folding an
issue’s markers in comment order gives its claim state: free, released,
live, stale (older than the lease — any worker may claim, superseding),
or contested (a claim posted during another’s live claim; hands-off for
everyone while the contest is younger than the lease). Claimable = free,
released, or stale. Fallback complete runs the same offline disposition
gate as the broker path before posting anything; a rejection posts nothing
and exits 1.
The fallback switch is permanently armed. For the work verbs — claim,
heartbeat, checkpoint, complete, health — any primary-store failure
(broker unreachable, or an {ok:false} envelope) switches the caller to the
GitHub fallback for that work instead of dying: a message on stderr, one
JSON object on stdout with "fallback": true, "switch_to": "github-fallback" and a hint naming the fallback verbs, and exit code
6, so a worker loop can branch on it without parsing prose. The escape
hatch REPO_QUEUE_NO_FALLBACK_SWITCH=1 restores plain die-on-error. The
primary claim path also guards the other direction: it refuses to
double-serve an issue the fallback currently holds (see the claim path in
Architecture).
Queue client exit codes, in full: 0 success; 1 gate failure / task not
found; 2 usage; 3 transport or broker-path failure; 4 a broker {ok:false}
envelope carrying no exit of its own (and broker-side store failures); 5 no
matching claimed row / no claimable task; 6 the fallback switch.
Creating GitHub objects (issues, PRs, comments) must survive crashes and
rate limits, so creation goes through the creation outbox: producers
enqueue, a single serial drainer creates through gh, verifies by
read-back, and resolves. There is no dual-write and no automatic fallback to
direct creation — a broker failure stops the drain visibly.
Entry kinds: issue, pull_request, issue_comment, pr_comment. States:
pending, leased, uncertain, done, blocked. Constants: claim lease
120 s, minimum gap between creates 2 s, hourly create budget
300, retry backoff base 30 s capped at 3600 s, a circuit breaker
that opens after 3 consecutive rate limits for 300 s, default max
attempts 8. Entries carry a fleet-outbox:<id> marker in the created
object’s body so the drainer can reconcile by search and read-back. The
verbs are outbox enqueue|list|metrics|claim|resolve|drain; drain
defaults to at most 20 items (--max, floored at 1), and an uncertain
entry is reconciled by marker first — a lookup that could not check keeps
the entry uncertain and never re-creates.
A stack is a recorded, ordered set of merge intents — finished branches
with their authoring lane, worker, and session — stored in the broker’s
merge_intents table, unique on (stack_id, position) and (repo, branch). Intent states: intended → replaying → landed, plus conflicted
and abandoned; the legality of every move is decided by a pure transition
table, never in SQL, and a conflicted intent returns only through its
recorded authoring lane.
The verbs are stack record|list|transition|restack|replay. record
requires --stack, --repo, --branch, and --lane. A transition to
conflicted requires --conflict-detail naming what the authoring lane
must resolve. replay is the executor: it walks the stack’s recorded merge
order bottom-up — rebase onto new main, push (force-with-lease pinned to the
verified pre-rebase tip), open PR, merge, mark landed, post the outcome note
— one intent at a time. Replay never resolves a conflict itself. Its exit
codes: 0 landed or idle, 4 a conflict was recorded conflicted and
routed to its authoring lane, 3 any other step failure (the intent is
left replaying and a later replay resumes it).
Alongside the task-row model above, the queue crate carries a pure
reference model for session resumption: the journal checkpoint and the
handoff snapshot, in crates/fleet-queue/src/work/journal.rs (JRN-03
of #9465, PR #14346; design §3.4 of the #9208
typed-dependencies / notes / journal field-authority component). The
module is a pure model — no I/O, no storage, no queue — and it is
not the checkpoint verb: the verb records progress and a stage on a
task row, while a journal checkpoint is the durable snapshot a later
session resumes a work item from. It is not a transcript and not a
completion claim.
A checkpoint (wire schema fleet.journal-checkpoint/v1) carries the
work reference and the per-work journal stream sequence it was taken
at, the objective, the steps done and still outstanding, the important
paths, the branch and head commit it was taken at, the test state at
that moment, the hard blocker edges in force, the per-source activity
cursor refs and the hydration ref it was hydrated from, and one
suggested next action. Both halves of the commit identity are
required — a snapshot that cannot name its commit cannot be resumed
or audited. The test state’s passed / pending / failed buckets are
disjoint by validation: a test recorded in two buckets is a typed
rejection, so a pending test is never shown passed. Cursor refs
(#9207), hydration generations (#9207) and blocker-edge targets are
carried as opaque typed references; their formats stay with their
owners, and the lifecycle command that writes checkpoints is #9206’s,
not this module’s.
Checkpoints are private by construction: visibility is always
private, validated rather than assumed, and a payload presenting any
other visibility is rejected, never silently projected. Important
paths are screened the same way — a path naming a secret-bearing
location is a typed rejection. Every rejection is a typed
CheckpointError (invalid_schema, unsupported_version,
non_private_visibility, secret_path, missing_commit_identity,
conflicting_test_state) that mutates nothing. Checkpoints are
append-only: editing one produces a new checkpoint whose supersedes
names the original, which stays addressable and unchanged.
Freshness is explicit. A checkpoint is current only when nothing has superseded it and the journal stream has not moved past the sequence it was taken at; every other case projects as stale, carrying the checkpoint sequence, the current sequence and the superseding checkpoint, when one exists. The resume projection a new session starts from carries that freshness on its face, so a stale checkpoint never projects as current.
A handoff (wire schema fleet.journal-handoff/v1) records an
ownership transfer only: the work reference, the checkpoint the new
owner resumes from, the previous and new owners, and the lease
transfer result — released, takeover confirmed, or pending (neither
release nor takeover confirmed). It deliberately has no completion
field, and projecting it over a workflow state returns that state
unchanged: a handoff never implies completion. This is a different
record from the broker’s handoff sink that claim --handoff picks
from: the sink routes a task, the handoff reference attests a
transfer.
The broker creates its schema at backend start. The tasks table carries:
id, queue, title, body, payload (default '{}'), dedupe_key,
priority, status (default 'queued'), not_before, worker_id,
claimed_at, lease_until, lane_id, platform, attempts (default 0),
max_attempts (default 1000), the claim stamps (claim_provider,
claim_model, claim_variant, claim_session_id), progress and result
(default '{}'), last_error, the park columns (park_kind, wait_kind,
ready_condition, required_budget_minutes, last_checked_at,
check_outcome), the dep-block columns (blocked_deps,
dep_next_recheck_at, dep_blocked_until, dep_recheck_seconds),
timestamps, and completed_at. Its (queue, dedupe_key) index is
deliberately not unique — enqueue dedupe is a read-then-insert check.
Alongside: leases (one row per task), lanes (seeded with the 156
canonical lanes when empty), workers, checkpoints, repo_task_lane_ledger,
events, creation_outbox (+ its circuit singleton), and merge_intents.
Broker protocol facts: every verb is one POST /<command> with a JSON args
object; the response envelope is {ok:true, ...} or {ok:false, exit, error}. The only unauthenticated route is GET /healthz. The broker binds
first and brings the Turso backend up on a startup thread, so /healthz
and /validate answer immediately while other verbs answer exit 3 with a
turso_pending reason until the backend is ready. A transient store error
carrying PostgREST code 57014 or PGRST002 is retried client-side with
exponential backoff and jitter: base 500 ms, doubling, cap 20 s, at most 6
attempts.