GeezerVison is showing github.com — Turso-to-D1 migration audit + programme · Issue #13844 · developing-today/code
Turso-to-D1 migration audit + programme #13844DescriptionProgramme 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)"
}
}
Activitydeveloping-today commented on Nov 23, 2026 dezren39 commented on Nov 23, 2026 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.
dezren39 commented on Nov 24, 2026 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.
dezren39 commented on Nov 24, 2026 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. developing-today-fleet commented on Nov 24, 2026 Housekeeping executed — 8 frozen staging/recovery copies exported + deleted
Drew approved export + delete on 2026-11-23. Executed the same day from the laptop (turso CLI v1.0.33, org dezren39). All 8 databases named in the audit record (§"Not a D1 question") are done. Estate count: 50 → 42 databases (verified by turso db list after deletion; none of the 8 names remain).
Export location. The audit named no bucket, so this location was chosen and is stated here: R2 bucket supabase-backups (the estate's backup bucket, Developing.today account), prefix turso-exports/2026-11-23/ — one turso db export snapshot per database (.db, plus the .db-log sidecar for the four Turso-format databases; the recovery and runtime-tx logs are empty files). The export run log is in the same prefix as export.log. Local copies also remain on the laptop at ~/turso-exports/2026-11-23/.
Premise check (per database, before touching anything). Rows-written counters read via turso db inspect immediately before and after the export window were identical for all 8 — zero write activity. The non-zero counters are the one-time 2026-11-17/18 staging loads, which fall inside the current billing period; nothing showed signs of live use, so no database was held back.
Verification (every database, before its deletion).
- Export table count == live table count (via
tursodb/sqlite3 on the export vs turso db shell on the live database).
PRAGMA integrity_check = ok on the four SQLite-format exports; the four Turso-format exports open and query under tursodb.
- Every R2 object was re-downloaded and its SHA-256 compared against the local export — all byte-identical; head-object sizes also matched at upload.
| Database |
Turso size |
Rows written (pre = post) |
Tables |
Export .db bytes |
SHA-256 of export .db |
Deleted |
fleet-supabase-recovery-20261117 |
422 MB |
0 |
131 |
422,313,984 |
665fe5a4b793e3f59ca7bf9cc49b34768c21b5677ef999135a87990d10f93616 |
✅ |
fleet-supabase-runtime-stage-20261118 |
16 MB |
106,581 |
34 |
16,515,072 |
cc8f2e46853463a97838ffb78b7c334bdb00af7cb7a20416606ab69915a705f2 |
✅ |
fleet-supabase-runtime-legacy-stage-20261118 |
15 MB |
96,860 |
32 |
15,335,424 |
38b8cd566506a3ef8511e956122463ece5ddcf5f37d0a798e9628f65804b22f4 |
✅ |
fleet-supabase-runtime-tx-stage-20261118 |
8.2 kB |
96,652 |
28 |
15,335,424 |
04c9d4d2723020cdc81072e9a21997728a8b8f9e498a6e2616523b35ccf07ce0 |
✅ |
fleet-platform-reconcile-stage-20261118 |
6.0 MB |
13,879 |
22 |
5,951,488 |
793899f860d01609126cdc887c85058eb8e695022b35647166fb27e4850ccc57 |
✅ |
fleet-platform-batched-stage-20261118 |
5.9 MB |
13,852 |
16 |
6,029,312 |
d0a4b64eb10d2fe85f624cd723a0e27c1c63f5da9b4bc0ceeb9a2fb6193504ed |
✅ |
fleet-platform-short-tx-stage-20261118 |
5.3 MB |
13,852 |
16 |
6,029,312 |
d0a4b64eb10d2fe85f624cd723a0e27c1c63f5da9b4bc0ceeb9a2fb6193504ed |
✅ |
fleet-mirror-recovery-stage-20261118 |
4.8 MB |
3,603 |
4 |
4,849,664 |
fd333f0364327ad84c803585b50936598d6f20f85a5da180d2d3b200302d7b12 |
✅ |
Notes:
fleet-platform-batched-stage-20261118 and fleet-platform-short-tx-stage-20261118 have identical hashes — they were twin copies of the same staged dataset (their usage counters were also identical), not an export error.
- Sidecar
.db-log hashes, also verified byte-identical in R2: runtime-stage (994,146 B) 12a6e867e0ab1e74b1631b6000b9b94c3966dd7df13985c7f5e8c855c722efcf; runtime-legacy (133,660 B) 321e399abc373e9b483a73c930b3ef671cfb2f922448d83eb731216ddf0af65a; recovery and runtime-tx logs are empty.
- The org's
payment_failing_since: 2026-11-04 state did not block exports or deletions.
- ~475 MB of Turso storage and 8 database slots freed.
dezren39 commented on Nov 24, 2026
Triage verdict (lane any-o, queue task 22438, 2026-11-24): programme verified, first slice routed.
Fresh verification: audit record on main, DESIGN-REVIEW sound, Drew's fit-based direction + approved housekeeping both recorded and housekeeping executed (50→42 DBs). G1 tables confirmed referenced under pm-stack/aggregator. No existing queue item for G1. Follow-on feature_slice packet for slice 1 (G1 MOVE-CLEAN → one D1 database, dual-write cutover, parity check) enqueued; fleet-mirror retirement explicitly left as follow-up. Later slices (G2/G3, G4 read-shape scaling fix) stay untriaged until G1 proves the dual-write/parity pattern. dezren39 commented on Nov 24, 2026 Triage (oc-code-01, 2026-11-24): slice G1 (telemetry mirror and aggregates to D1) is the first build step of the Turso-to-D1 programme. The audit is measured and no migration has run. Slice 1 touches live telemetry data, so it needs a worktree, a fleet build and a verified mirror against the oracle before any cutover. This lane cannot run that. Left open for an implementation session. dezren39 commented on Nov 24, 2026 G1 sizing (oc-code-03, queue task 23241, 2026-11-24 14:40Z): parked, nothing landed.
- G1 creates one D1 database and switches agent_mirror_, agent_quota_records and agg_ to dual-write behind the pm-stack workers. That is a live write-path cutover, with a parity check that must pass before the old path is retired.
- Estimated 180 minutes of focused work, plus credentials and a production cutover window. Too big and too risky for an unattended scheduled lane.
- Resume in a focused build pass: start from pm-stack/aggregator/src/, parity check first, then the cutover. Fleet-mirror retirement stays a follow-up, as the packet says.
dezren39 commented on Nov 24, 2026 🤖 G1 sizing update · lane oc-code-03, queue task 23241 (recheck 2026-11-24 ~18:05Z). Concur with the 14:40Z sizing: still too big/risky for an unattended scheduled lane — parking. Three new findings for the focused build pass:
- D1 credential: the ambient
CLOUDFLARE_API_TOKEN is stale (API returns Invalid access token), but cloudflare.api-token-account-wide via fleet secrets get works — verified read-only with wrangler d1 list (7 databases, no G1 DB yet). Use that token for D1 creation, not the env one.
- Writer topology vs audit premise: G1 writers are NOT Worker-only.
agent_quota_records is written from the laptop (pm-stack/aggregator/scripts/gather-quota.ts:850,905, pkgs/deploy/quota-recorder.py:62,151 via libsql HTTP); agg tables go through the laptop aggregator (remote-stores.ts, turso-stores.ts); agent_mirror_* in fleet-platform has no in-repo writer identified yet (fleet-mirror writers in pkgs/fleet/runtime-db-export target fleet-mirror only). Dual-write must cover laptop writers via the D1 REST API, not just Worker bindings — the slice design should be updated before cutover.
- Live state verified: fleet-platform holds 28 G1 tables (21
agent_mirror_* + export_state, quota_records, token_expirations, external_comms, 5 agg_*); counts match the audit and are growing (quota_records 75,024 → 83,196). No PR, no branch, nothing landed.
No worktree changes; empty lane branch removed. dezren39 commented on Nov 25, 2026
Decided: Treat G1 as a mixed Worker and laptop writer migration; first land and verify a Cloudflare D1 HTTP SqlClient for laptop processes, and defer any production data copy or writer cutover until the agent_mirror_* writer is identified and every writer path has a parity check.
Why: pm-stack/aggregator/src/remote-stores.ts writes agg_* through the laptop aggregator, pm-stack/aggregator/scripts/gather-quota.ts and pkgs/deploy/quota-recorder.py write agent_quota_records from the laptop, and the current source review did not identify the agent_mirror_* writer. D1 has no direct laptop connection string; the Cloudflare API is the available laptop path. The audit correction and mocked transport contract are in lane/agent-next-22-local-23241-g1-d1.
Undo: Revert the audit correction and D1 transport, then restore the Worker-only migration sequence if a complete source inventory proves that all G1 writes and reads are Worker-bound.
By: agent-next-22-local dezren39 commented on Nov 25, 2026 G1 progress: PR #14680 adds a mocked, tested Cloudflare D1 HTTP SqlClient for laptop writers and corrects the audit's writer-path inventory. This is a transport slice only; no live data or cutover was touched. The targeted Fleet Bun test is running: https://github.com/dezren39/fleet/actions/runs/45515851780
Next slice: identify the agent_mirror_* writer and wire each confirmed writer to the D1 transport with a source-to-D1 parity/backfill check before any production cutover. dezren39 commented on Nov 25, 2026 PR #14680: Fleet run 45515851780 reports the targeted bun test src/d1-stores.test.ts execute step succeeded; the overall run is still in post-command cleanup. No D1 data was touched. The PR remains a transport slice; G1 parity and full writer coverage are not complete. dezren39 commented on Nov 26, 2026 G1 gate recheck (oc-code-06, 2026-11-26): PR #14680 merged at 3e01dca; its D1 HTTP SqlClient is on main. Re-inventory confirms pkgs/fleet/runtime-db-export/turso_client.py and pkgs/agent-backup/turso_client.py define and write agent_mirror_* tables to the dedicated fleet-mirror database; this source search does not identify a writer for the separate agent_mirror_* tables in fleet-platform. Laptop G1 writers for agent_quota_records (gather-quota.ts, quota-recorder.py) and agg_* (remote-stores.ts) remain confirmed. No code or live data changed. This lane is parking rather than attempting the 180-minute live dual-write/parity/cutover: the remaining work needs a complete inventory of the fleet-platform mirror writer and per-writer parity/backfill coverage before any cutover, as the existing decision comment requires. Resume condition: focused G1 implementation pass after those writer paths and parity oracles are scoped; do not enable a cutover based only on the fleet-mirror exporter. developing-today-fleet commented on Nov 27, 2026 🤖 Agent note · escalated
- Agent: fleet monitor
- Session / ID: repo-fleet-monitor cron run 2026-11-27 16:14 CST
- Found via: monitor reconciliation (Duty 4 protocol check)
- Task: Protocol gap: this item carries work/queue claim labels but NO comment contains the required agent-note:v1 footer (protocol §2/§6). The holding agent did not leave the required agent note. This gap needs a human/Muse review of why the protocol was not followed; the holder should post a proper agent note (pickup/checkpoint) or hand the item off.
- Expectation: holder posts an agent-note:v1 note or releases the item.
- Links: protocol ~/workspace/goals/keep-the-four-repos-healthy/files/agent-lifecycle-protocol-2026-10-25.md
MetadataMetadataDevelopmentNo branches or pull requestsIssue actions
|