Skip to content

Fleet unification slice 5: local coordination replica for database-down resilience #8583

Open

Description

@dezren39

Parent design: #8575 (one door, one home per fact — fleet tool state unification). Slice 5 of 7. Approved by Drew 2026-11-11: implement in full.

Work

Database-down resilience for coordination:

  1. Run a Turso embedded replica of the coordination tables on the laptop, so claims, leases, and heartbeats continue against the local copy when the cloud database or the broker path is unreachable.
  2. The fleet tool detects database failure itself and switches to the replica without lane involvement (contract from slice 3), reporting db-degraded mode.
  3. On recovery, the replica syncs back up; any claims made locally are reconciled against the cloud store — a claim honored locally is honored globally, and double-claims across the partition are detected and reported, never silently merged.
  4. Behind the replica, the existing GitHub-marker fallback mode remains the last resort.

Acceptance

  • A drill: database made unreachable mid-shift; lanes keep claiming and working against the replica; on restoration, sync completes with zero lost claims and any partition double-claims surfaced in a report.
  • The replica's data passes the wipe test by construction: it holds coordination only (per slice 1's classification).

Activity

  1. developing-today commented on Nov 11, 2026

    @developing-today
    Contributor
  2. added
    task/small-fixQueue packet kind: bounded fix with reproduction and targeted tests
    priority/highImportant and time-sensitive
    effort/lLarge: multi-day or open-ended; expect staged check-ins
    kind/infrastructureInfrastructure / host-portability work
    and removed on Nov 11, 2026
  3. dezren39 commented on Nov 11, 2026

    @dezren39
    MemberAuthor

    🤖 Agent note · triaged

    • Agent: triage-step
    • State: triaged
    • Work kind: task/small-fix - a bounded implementation slice of the Drew-approved fleet unification program (parent Design: one door, one home per fact — the fleet tool owns every route and every fallback #8575); not a PR-shepherd or CI-investigation item.
    • Priority: priority/high - Priorities brief line 1 (keep the fleet itself able to work: a dead queue/broker path outranks feature work) and line 4 (Drew's named programs: the four repos healthy). This slice is part of Drew-approved (2026-11-11) fleet unification parent Design: one door, one home per fact — the fleet tool owns every route and every fallback #8575, the queue/broker resilience program.
    • Effort: effort/l - multi-day implementation slice.
    • Kind: kind/infrastructure (added this triage).
    • First concrete step: Stand up a Turso embedded replica of the coordination tables on the laptop so claims, leases, and heartbeats continue against the local copy when the cloud database is unreachable.
    • Acceptance check: A drill: database made unreachable mid-shift; lanes keep claiming and working against the replica; on restoration, sync completes with zero lost claims and any partition double-claims surfaced in a report.
    • Fix packet: - Fix packet: task 14911 in repo-health-code-pilot (dedupe repo-health:v1:fix:developing-today/code:issue:8583, priority 20, kind small_fix, queued; signal refreshed).
  4. dezren39 commented on Nov 11, 2026

    @dezren39
    MemberAuthor

    agent-note:v1
    state: blocked (dependency)
    lane: code-c (task 14911)
    issue: #8583

    Dependency gate declared on task 14911 (fleet queue dep-block, broker rechecks every 15 min, max TTL 3 days). Slice 5's own text names its two unlanded inputs: item 2 switches to the replica 'without lane involvement (contract from slice 3)' — slice 3 is #8581, itself dep-blocked today (task 14909) on slices 2 and 5 — and the acceptance holds the replica to 'coordination only (per slice 1's classification)' — slice 1 is #8579, the wipe-test schema audit, also OPEN and unlanded (verified fresh 2026-11-11: all seven #8575 slices open, no mirror/replica/contract code in the fleet tooling). The replica's table set is exactly what slice 1 classifies, and its failover surface is exactly what slice 3 declares; building either half against guesses would force rework across three slices. Note the interlock is circular by construction (#8581 lists this slice as an input too): the program order that unblocks everything is slice 1 first, then slices 2/3/5 against its classification. This task returns to the pool automatically when #8579 and #8581 close.

  5. added
    work/assignedQueue worker lifecycle state
    queue/claimedQueue worker lifecycle state
    queue/blockedQueue or user escalation state
    and removed
    queue/claimedQueue worker lifecycle state
    on Nov 11, 2026
  6. 150 remaining items

  7. added
    status/blockedQueue or user escalation state
    queue/blockedQueue or user escalation state
    and removed
    queue/claimedQueue worker lifecycle state
    on Nov 22, 2026
  8. dezren39 commented on Nov 22, 2026

    @dezren39
    MemberAuthor

    🤖 Agent note · picked up — queue task 21043 (packet #12538), lane lane-ap (archer)

    Slice picked: the durable local replica. The packet's dependency order is #8581 contract → #8583 replica → #8584 backups. The contract half is settled on main (PR #12601 mode contract, PR #12638 work::routing + CoordinationReplica, both verified — see #8581's slice record), and #8584's tooling landed today (PR #12685); its remainders are operator-session work. The next unfinished implementation slice is therefore this issue's replica, exactly the step every prior park on #8583/task 14911 named as the resume action ("after PR #12638 merges with compile/tests verified, implement the replica against the landed interface" — that condition is now met).

    Scope of this slice (bounded): a CoordinationReplica implementation backed by a durable local SQLite store (SqliteReplica, rusqlite bundled — the same stack atlas-core already pins), in fleet-queue next to the contract, with the caller's clock supplied exactly as MemoryReplica takes it. Claim/heartbeat/checkpoint semantics and sync_up reconciliation (a local claim is applied to the cloud store on sync; a divergent cloud holder surfaces as a double-claim, never silently merged; zero lost claims) are checked against an explicit model oracle over generated operation sequences — the same MBT shape as the MemoryReplica proptest in work/routing.rs — plus a reopen test: a claim recorded before the store is closed is still held after it is reopened (the durability MemoryReplica cannot offer).

    Not in this slice (named remainders, in order): (1) route the claim/lease/heartbeat verbs through route_for and emit mode_line on their outputs (#8581 remainder 1 — the adapter that would call this replica); (2) the live #8583 drill (cloud made unreachable mid-shift against the real Turso store, sync on restoration) — it needs the adapter in (1) and a live-store session; (3) Turso-native embedded-replica sync (libsql) if the SQLite store's reconciliation proves insufficient — the trait is the boundary either way.

  9. added 2 commits that reference this issue on Nov 22, 2026
  10. dezren39 commented on Nov 22, 2026

    @dezren39
    MemberAuthor

    🤖 Agent note · slice landed — queue task 21043 (packet #12538), lane lane-ap (archer)

    PR #12692 merged (fc72fada01c6f7cbbd41abce6791a3fd79ff7007) — the durable local replica this issue was parked waiting for now exists on main: work::sqlite_replica::SqliteReplica in fleet-queue implements the CoordinationReplica interface settled by #12638, backed by a local SQLite store (rusqlite bundled, gated on the queue-broker feature alongside turso_queue). Claims, leases, and checkpoints persist in the store across restarts; the store holds coordination only, so the wipe test passes by construction. sync_up reconciles against an attached cloud store: a claim honored locally is applied to the cloud store (honored globally), a task the cloud view holds for a different (worker, lane) surfaces in double_claims and is never silently merged or applied, and lost_claims stays empty by construction. Semantics match MemoryReplica exactly — caller-supplied clock, (worker, lane) identity, injected cloud view consumed by the sync.

    Verification (fleet-run, nix develop .#fleet, the AGENTS.md command cargo test --locked -p fleet-queue --lib --features client,queue-broker):

    • Failing-first: commit a463302 landed the oracle tests against a stub returning Unavailable — fleet-run 45077366316: 0 passed, 10 failed, every failure the stub error.
    • With the implementation (head d284da8): fleet-run 45077676146: 477 passed, 0 failed — all 10 new replica tests green, including the model-oracle proptest (sqlite_replica_matches_model_over_generated_sequences, the ModelReplica state machine from work/routing.rs as the named oracle, compared on every step of generated op sequences) and the reopen-durability test; the 139 turso_queue tests in the run confirm the feature-gated surface actually executed.

    What of #8583's acceptance remains (issue stays open), in order:

    1. Verb adapter — route the claim/lease/heartbeat verbs through route_for and emit mode_line on their outputs (Fleet unification slice 3: fleet verb contract v2 — routes and degraded modes in the tool #8581 remainder 1), so a verb actually lands on this replica when the database leg fails and the tool reports db-degraded itself, without lane involvement. Nothing calls SqliteReplica yet.
    2. The live drill — the acceptance drill (database made unreachable mid-shift; lanes keep claiming against the replica; on restoration sync completes with zero lost claims and partition double-claims in a report) needs (1) plus a live-store session against the real Turso database; the drill harness in this slice reconciles against a file-backed cloud stand-in.
    3. Turso-native embedded sync — if store-level reconciliation proves insufficient in the drill, implement sync via libsql's embedded replica behind the same trait; the trait is the boundary either way.

    Broker redeploy: not needed — a new library module behind the existing feature; no broker-served behavior changed and nothing calls it yet.

  11. dezren39 commented on Nov 22, 2026

    @dezren39
    MemberAuthor

    🤖 Agent note · remainder 1 (verb adapter) landed — lane lane-av2 (archer)

    PR #12706 merged (7817b4effccd584bd2c0aabbb101e5fbc2fe2af3). The adapter now routes the coordination verbs through route_for and emits mode_line on their outputs: claim (single/batch/guard outcomes), heartbeat, and checkpoint carry {verb, mode, route} on the cloud path, and the #6741 fallback switch envelope carries db-degraded / github-markers on the primary-store failure path — a verb now reports the route it actually used, itself, without lane involvement. Full record, verification (failing-first 3 passed / 2 failed against the stub; 480 passed / 0 failed on the laptop and independently in fleet-run 45081347079), and the client-side-only confirmation are on #8581: (see lane-av2's completion note there).

    One boundary of this slice, stated plainly: nothing calls SqliteReplica from the client yet, and this slice did not change that — the client holds no local replica, so on a dead store the selected route is honestly github-markers, the route the fallback switch hands the work to. Serving verbs from the replica is the remaining adapter work and is a precondition of the live drill below.

    What of this issue's acceptance remains (issue stays open), in order:

    1. Client/broker replica wiring — decide where SqliteReplica is served from (client-held store vs broker-side) and wire the coordination verbs to land on it when the database leg fails, so the reported route becomes local-replica in fact.
    2. The live drill — the acceptance drill (database made unreachable mid-shift; lanes keep claiming against the replica; on restoration sync completes with zero lost claims and partition double-claims in a report) needs (1) plus a live-store session against the real Turso database.
    3. Turso-native embedded sync — only if store-level reconciliation proves insufficient in the drill; the trait is the boundary either way.

    Broker redeploy: not needed for this slice — client-side only, confirmed on #8581's record.

  12. dezren39 commented on Nov 23, 2026

    @dezren39
    MemberAuthor

    Block lifted — stale-block sweep, 2026-11-23 (Survey B, archer).

    Named blocker of record: the slice-3 contract from #8581 (fleet verb contract v2 / coordination-replica interface), which this slice's implementation waited on.

    Evidence the gating contract landed, verified first-hand via gh GraphQL this sweep:

    Action: queue/blocked removed, queue/queued added. #8581 remains open for its own remaining scope, but the contract this slice was blocked on is on main and this slice's core deliverables have landed; any remainders are this issue's own work.

  13. added and removed
    queue/blockedQueue or user escalation state
    on Nov 23, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    effort/lLarge: multi-day or open-ended; expect staged check-insepic/fleet-orchestrationReprioritization program epic (2026-11-12)epic/fleet-toolEpic: fleet-tool - all issues of this effort carry itkind/infrastructureInfrastructure / host-portability workpriority/highImportant and time-sensitivequeue/queuedHas a queued queue taskstatus/blockedQueue or user escalation statestatus:in-reviewtask/small-fixQueue packet kind: bounded fix with reproduction and targeted testswork/assignedQueue worker lifecycle state

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions