Skip to content

Turso-to-D1 migration audit + programme #13844

Backlog

Description

@dezren39

Programme tracking for the Turso-to-D1 migration audit (2026-11-23). Full audit + design record lands as a dated doc record (linked from this issue once merged). Research/design only so far — no migrations have been made.

What the audit found (measured, Turso API, current billing period)

  • 50 Turso databases. Estate totals: ~65.8M rows written, ~7.47B rows read, ~10.0 GB storage this period.
  • fleet-platform is 87% of all writes (57.4M rows written, 465 MB) — PM-stack/dashboard state owned end-to-end by Cloudflare Workers in pm-stack/.
  • fleet-queue is 81% of all reads (6.08B) — broker/poller scanning; a query-shape problem, not a store-location problem.
  • atlas is 73% of storage (7.28 GB) and is a native libSQL vector store (107,639 chunks + vec tables) across 33 sharded databases.
  • The compile coordinator's tables (fleet placement: central coordinator for compile dispatch — atomic slots, true load view, global budgets, cross-seat queueing #13765: placement_owner_state / placement_claims / placement_budgets) live in the same single fleet-queue database as the rest of the broker store (not yet landed; build is queue task 21517).

Groups

  • G1 MOVE-CLEAN — fleet-platform telemetry mirror & aggregates (agent_mirror_, agent_quota_records, agg_). Derived/rebuildable data, Worker-only access. Recommended first slice.
  • G2 MOVE-CLEAN — fleet-platform ingest families (ainventory/automation/research/engineering/finance/home *_sheet_rows + *_events + *_sources).
  • G3 MOVE-CLEAN — fleet-platform operational ledgers (alerts_, decision_set_events, ci_events, ideas_, orch_*). Completes the fleet-platform evacuation: all 57.4M writes/month off Turso.
  • G4 STAY-TURSO — fleet-queue broker core (tasks, events, leases, placement_, coordinator tables, actions_exec_). Rust broker on the laptop; transactional claim path; D1 has no local/embedded access path. Separate fix filed by the audit: index/cursor the pollers (the real read win).
  • G5 MOVE-WITH-BRIDGE — fleet-queue read-side mirrors (github_mirror_*, agent_events_pg_history). D1-first reads, Turso fallback, watermark sync (pattern per design(atlas): D1 tenant hot cache — admission, invalidation, Turso-hop skip #9134's D1 hot cache).
  • G6 MOVE-WITH-BRIDGE (low priority) — muse-meta coord_events + small tables; coord_tasks/leases stay.
  • G7 STAY-TURSO — Atlas (atlas + 32 shards). Vector search is libSQL-native; D1 has no vector index. Drew's sketch holds here: Turso remains the sharded embedding store.
  • G8 MOVE-CLEAN (opportunistic) — small stores (notes-submissions, bedside-and-away, voice-line-ledger, fleet-dispatch-jobs). Exception: great-star-lord stays (standing keep + third-party app DB).

Honest constraints

  • Moving G1–G3 alone does NOT permit a Turso plan downgrade: remaining reads (~6.9B, queue-dominated) exceed Developer-plan inclusion, and remaining storage (~9.5 GB) sits at its line. Downgrade needs the G4 read-shape fix too.
  • D1 walls respected in the design: 10 GB per database (one D1 DB per family), single-writer sequential processing (sync writers must batch), Workers/HTTP-API access only.
  • Housekeeping decision needed: 8 frozen staging/recovery copies from the 2026-11-17/18 Supabase recovery (~480 MB) should be exported to object storage and deleted — never migrated.

First slice (recommended)

G1: agent_mirror_* + agent_quota_records + agg_* from fleet-platform into one D1 database, dual-write cutover behind the pm-stack workers. Biggest write win (presumed majority of fleet-platform's 57.4M writes/month; per-table attribution is inference — the Turso API reports per-database only) at the lowest risk (derived data, rebuildable, Worker-only consumers). Side effect: fleet-mirror's duplicate copy of the same dataset can be retired after a parity check.

{
  "direct_parent": null,
  "links": [],
  "lineage": {
    "design": null,
    "roadmap_item": null,
    "priority": null
  },
  "pm_meta": 1,
  "provenance": {
    "queue_id": null,
    "scheduled_start": null,
    "picked_up_at": null,
    "work_started_at": null,
    "created_at": "2026-11-23T23:16:16Z",
    "session_id": null,
    "lane": null,
    "host": "htch-runtime",
    "worktree": null,
    "model": null,
    "lane_start_issues": [],
    "workspace_ref": null,
    "auth_subject": "archer",
    "stamped_by": "fleet 0.1.0 (native)"
  }
}

Activity

  1. developing-today commented on Nov 23, 2026

    @developing-today
    Contributor
  2. added a commit that references this issue on Nov 23, 2026
  3. dezren39 commented on Nov 23, 2026

    @dezren39
    MemberAuthor

    Audit record landed: PR #13845 merged — doc/2026-11-23T23-15-07Z_design_turso-d1-migration-audit/ (plus the doc/README.md index line).

    Headline results:

    • fleet-platform = 87% of estate writes (57.4M/mo) and is Worker-owned end to end → G1–G3 MOVE-CLEAN; first slice = G1 (agent_mirror_* + agent_quota_records + agg_* → one D1 database, dual-write cutover).
    • fleet-queue broker core STAYS (transactional claim path, laptop-side Rust consumer, no D1 local access path); its 6.08B reads/mo are a scanning problem — the read-shape fix is slice 3 and the real downgrade enabler.
    • Atlas STAYS as the sharded embedding store (33 DBs, native libSQL vectors); Drew's end-state sketch holds for writes/databases, refuted for reads.
    • Coordinator tables (fleet placement: central coordinator for compile dispatch — atomic slots, true load view, global budgets, cross-seat queueing #13765) confirmed by design + live enumeration: they belong to the single fleet-queue database; not yet landed (build = queue task 21517).
    • Decision needed (housekeeping): export + delete the 8 frozen 2026-11-17/18 staging/recovery copies (~480 MB) — recommended in the record, not actioned.
  4. dezren39 commented on Nov 24, 2026

    @dezren39
    MemberAuthor

    AUDIT-7 Lane 5 (DESIGN-REVIEW, #13876) — verdict on doc/2026-11-23T23-15-07Z_design_turso-d1-migration-audit: sound.

    • Programme order is explicit (Slices 1–5 + housekeeping) and the head is right: G1 first because it is the biggest write win AND derived/rebuildable data with Worker-only access — highest value at lowest risk. Slice 3 (G4 read-shape fix) is correctly identified as the downgrade enabler despite not being a migration.
    • Honest walls: per-family D1 databases, single-writer serialization, and the G4/G6 "consumer is not a Worker" constraint are stated in the design, not discovered later.
    • Minor: Slice 2's "retire fleet-platform after parity" depends on Slice 1's dual-write/parity pattern proving out, but that dependency is implicit — one line naming it would make the order executable by a fresh session. The housekeeping item (8 frozen staging/recovery copies) needs a named decision owner.
  5. dezren39 commented on Nov 24, 2026

    @dezren39
    MemberAuthor

    Direction correction (Drew, 2026-11-23)

    Recording Drew's ruling: the aim for Turso is to scale it, not to downgrade it. The audit's Scaler→Developer downgrade framing — including the "downgrade enabler" language for the slice-3 read-shape fix — is superseded.

    • Turso stays the home for the workloads that belong on it — the fleet-queue broker core (G4) and Atlas (G7) — and is expected to grow with them.
    • D1 moves in this programme are fit-based: a workload moves when D1 is the right store for its shape (Worker-owned, derived/rebuildable, single-writer-friendly), not as a step toward a cheaper Turso plan.
    • The G4 read-shape fix (slice 3) still matters — as a scaling fix for the broker's poller load, not as a downgrade enabler.

    Housekeeping decision also recorded here: export + delete of the 8 frozen 2026-11-17/18 staging/recovery copies is approved (Drew, 2026-11-23). Execution evidence will be posted on this issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions