Repository navigation
Description
Design: one door, one home per fact — the fleet tool owns every route and every fallback
Direction from Drew (2026-11-11): the fleet tool is used for most interactions; it must handle all known and future edge cases and fallback itself. There must be a written plan for each failure scenario: GitHub write failure, GitHub read failure, and database failure.
Problem
The queue grew two durable stores for the same facts: the broker database (task outcomes, parked/blocked state, attempt history) and GitHub (issues, labels, PRs). Keeping them in sync is a permanent tax, and its failures are the fleet's top infra problem: lane registrations dropped mid-shift (unknown lane_id verdicts), claims evaporating or stamped with the wrong lane, parked handoffs re-served immediately, and a standing broker-to-label reconciliation backlog. The broker concept itself is not the flaw — a database is the right tool for coordination. The flaw is that the database also holds durable truth that GitHub holds too.
Principle: one home per fact, tested by the wipe test
- Coordination (claims, leases, heartbeats, checkpoints, merge-order lists) lives in the database. It is ephemeral by design: wiping the database tonight may lose only in-flight leases; lanes re-claim in the morning.
- Durable truth (what a task is, whether it is done) lives on GitHub: the issue, its labels at durable transitions only, the outcome agent note, the close. About three writes per task.
- Labels stop mirroring claim state. The queue/claimed-style labels were the database copied onto GitHub — that mirroring is the sync traffic. Labels change only at durable moments: triaged, done, blocked on the user.
- Every field in the database must pass the wipe test: if wiping it would lose what was decided or done, it does not belong there.
The fleet tool is the only door
Lanes never call GitHub or the database directly. Every fleet verb routes per current health, names the mode it is operating in, and carries its degraded behavior as part of the verb contract — a lane never improvises a fallback mid-shift. New edge cases get absorbed into the tool, not into lane instructions.
Pieces
- GitHub mirror in the database: the DB keeps a cached copy of most GitHub details (issues, labels, PR state, latest notes), fed by a GitHub webhook to a Cloudflare Worker that writes the DB. The webhook-to-Worker-to-Turso sink pattern is already live for CI events (design: move ci.events webhook ledger from Supabase to Turso staging #5693); this extends it. A slow backfill sweep repairs missed webhooks. The cache is a read model, rebuildable from GitHub at any time — never a second truth.
- Tool-side caching: the fleet tool caches a significant number of issues from the DB, so a shift's working set (a few hundred issues) is local-fast and spends almost no GitHub reads.
- Always-fresh local clone: a fetcher keeps the laptop clones updated at all times, so branching off current main never needs the network.
- Local stack discipline: finished work stacks — each branch based on the previous branch's tip, with the intended merge order recorded in the database. Worth having even when GitHub is healthy: it makes ordering explicit instead of twenty lanes racing off the same main.
Scenario plans
- GitHub writes fail (outage or rate limit): work continues. Lanes keep claiming from the database, keep working known items, and stack branches locally. Merge intents and outcome notes queue in the database (the outbox pattern, moved server-side) and replay on recovery, walking the stack bottom-up: push, open, merge, rebase the next branch onto the new main. The lane that wrote a change owns its conflicts at replay.
- GitHub reads fail: lanes run off the database copy. The tool surfaces mirror staleness (time of last webhook received) on every read. Discovery of brand-new items pauses; everything already mirrored keeps moving.
- Database fails: the laptop holds a local replica of the coordination tables (Turso embedded replica), so claiming continues on the laptop alone. Behind that, the existing GitHub-marker fallback mode is the last resort. On recovery the replica syncs up and the GitHub mirror backfills.
- Backups: Turso gets a scheduled export into D1 (same SQLite family, restorable; doubles as the analytics copy). The repos get a mirror push to a second home plus bundles in R2. Open question: whether Cloudflare repo hosting is the right second home for the repos — evaluate before committing.
Non-goals
- No better reconciler between two durable stores. That is the sync burden with extra steps.
- No lane-instruction fallback logic. Fallback lives in the tool.
Implementation slices (to be broken out as child issues)
- Wipe-test audit of the current queue schema: classify every table/field as coordination (stays) or truth (moves to GitHub / becomes derived cache).
- GitHub mirror: extend the design: move ci.events webhook ledger from Supabase to Turso staging #5693 webhook Worker to issues/PRs/comments/labels into the DB, plus the backfill sweep and a staleness readout.
- Fleet verb contract v2: every verb declares its route order and degraded behavior per scenario; lanes' instructions shrink to calling the verbs.
- Merge-intent queue and stack replay: local stacking, recorded merge order, bottom-up replay with conflict ownership.
- Local coordination replica on the laptop and the DB-down drill.
- Backups: Turso-to-D1 scheduled export with a restore drill; repo mirror plus R2 bundles; evaluate Cloudflare repo hosting as the second home.
- Label de-mirroring: stop writing queue-state labels; one final reconciliation pass over the parked backlog, then the reconciliation backlog itself is retired.
Activity
developing-today commentedon Nov 11, 2026
CODE-2563
dezren39 commentedon Nov 11, 2026
Rulings from Drew (2026-11-11) — design approved, implement in full
Staleness: never stop working. There is no staleness threshold at which lanes stop. When GitHub reads are down, the tool surfaces how stale the database mirror is, and work continues anyway — claimed items and new claims alike. The coordination database, not the mirror's freshness, is what prevents two lanes from colliding on one item. A blind window is a risk to note on the item, never a reason to idle the fleet.
Repo backups: all three. The repos get (a) Cloudflare rehosting, AND (b) a plain mirror elsewhere, AND (c) R2 bundles. This replaces the evaluate-first open question in the design: do all three.
Drew's instruction: "Just do it all." Implementation slices are being broken out as child issues of this design.
dezren39 commentedon Nov 11, 2026
Implementation slices (child issues, all filed 2026-11-11)
Each carries status/needs-triage so the triage sweep picks it up and it enters the fleet queue as a fix packet.
dezren39 commentedon Nov 11, 2026
🤖 Agent note · slice 1 audit delivered (task 14907)
doc/2026-11-11_design_id8579_queue_schema_wipe_test_audit.md— every table and field of the fleet-queue Turso store classified (coordination / durable truth / GitHub mirror cache) with evidence, a named GitHub home or derivation for every durable-truth item, and the migration order naming which of slices 2–7 (Fleet unification slice 2: GitHub mirror in the database via webhook Worker #8580–Fleet unification slice 7: label de-mirroring and the final reconciliation #8585) owns each move. No schema changes.tasks.result+ terminal status and therepo_task_lane_ledgerassignment record are the durable truth that slice 3's verb contract must write to GitHub first;eventssplits durable vs coordinative; both dedupe keys are derivations; slice 2's mirror and slice 4's stack tables don't exist yet and are called out as born-with-class requirements.dezren39 commentedon Nov 17, 2026
state: triaged
lane: any-b, worker: repo-worker-code, task 18693
Triage verdict for #8575 (checked fresh this shift, 2026-11-17): design parent — decisions recorded, work fully delegated to its child slices. No lane-sized work remains on the parent itself.
dezren39 commentedon Nov 17, 2026
Agent note — task 20176 triage re-verified (lane any-i)