Skip to content

feat(queue-backup): Turso-to-D1 export and restore drill for the queue store (#8584) - #12685

Merged
dezren39 merged 1 commit into
mainfrom
archer-lane-an/8584-turso-d1
Nov 22, 2026
Merged

dezren39 merged 1 commit into
mainfrom
archer-lane-an/8584-turso-d1

Conversation

@dezren39

@dezren39 dezren39 commented Nov 22, 2026 •

Copy link
Copy Markdown
Member

Leg 3 (Turso -> D1) of #8584, the tooling half. Refs #8584 — the issue stays open on the remaining legs.

What lands

infra/queue-backup/, sibling to infra/github-backup:

  • bin/export_d1.py — a queue-store SQLite file (local replica / scratch copy of the Turso store, opened read-only) -> a D1-loadable SQL dump + manifest (per-table counts, schema fingerprint, dump SHA-256). Nothing is written until the dump loads into a fresh vanilla SQLite database with identical counts and schema; that load is the D1-fidelity check.
  • bin/restore_drill.py — the restore drill: dump/manifest integrity, D1-copy load, restore into a scratch store, count + schema re-checks, then a claim check running the queue's claim shape (the conditional UPDATE of turso_queue/claim.rs, queued branch, plus its leases row): exactly the first claimable task, exactly once.
  • bin/queue_backup_common.py — shared counts / schema-fingerprint / dump helpers.
  • docs/RUNBOOK.md — the operating path and the production wiring that remains.

Verification

  • Failing-first: both suites failed on the missing modules before the implementation existed.
  • python3 -I infra/queue-backup/tests/test_export_d1.py — 4/4 OK. Fixture is built from the queue DDL of record (turso_queue/core.rs SCHEMA + merge_intent.rs DDL); oracles: identical counts + schema fingerprint after a vanilla-SQLite load, manifest hashes match the written bytes, no-clobber without --force, non-database source rejected.
  • python3 -I infra/queue-backup/tests/test_restore_drill.py — 4/4 OK. Oracles: the priority-90 queued task is the one claimed (attempts 0 -> 1, worker + lease stamped, other tasks untouched); tampered manifest and tampered dump are both rejected; a store with no claimable task fails unless --allow-empty.
  • End-to-end CLI drill on the laptop: export reported 10 tables / 12 rows; the drill restored and claimed task 1 ("ok": true).
  • py_compile clean on all six Python files.

Deliberately not in this PR (named remainders on #8584)


Show it working
Open in [code]smith · Need help on this PR? Tag @codesmith-bot with what you need.

…e store (#8584)

Leg 3 of the fleet unification backups slice: the tooling half.

- bin/export_d1.py: queue-store SQLite file -> D1-loadable SQL dump +
  manifest (per-table counts, schema fingerprint, dump SHA-256). The
  export is written only after the dump loads into a fresh vanilla
  SQLite database with identical counts and schema.
- bin/restore_drill.py: verifies dump/manifest integrity, loads the D1
  copy, restores into a scratch store, re-checks counts and schema,
  then claims exactly the first claimable task using the claim shape
  of turso_queue/claim.rs (queued branch) plus its leases row.
- tests: fixture built from the queue DDL of record (turso_queue
  core.rs SCHEMA + merge_intent DDL); export 4/4, drill 4/4, plus an
  end-to-end CLI drill (10 tables, 12 rows, task 1 claimed).
- docs/RUNBOOK.md: the operating path and the production wiring that
  remains (D1 creation in the existing Cloudflare account, scheduled
  export + registry entry, broker-mediated claim against a scratch
  Turso database) as an operator session. No live infrastructure is
  changed by this PR.

Refs #8584.
@dezren39
dezren39 requested a review from a team as a code owner November 22, 2026 21:16
@coderabbitai

coderabbitai Bot commented Nov 22, 2026

Copy link
Copy Markdown

Warning

Review limit reached

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

Next included review available in 48 minutes.

Check out review usage here.

View limit details

Limit details: You’ve used the included review currently available.

Learn how review limits work.

Review configuration:

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: defaults
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: b173f86a-1967-4caa-90b4-d6c9d0afbac7
Commits

Reviewing files that changed from the base of the PR and between 82adcbc and 5fb9923.

Files selected for processing: 7

  • infra/queue-backup/README.md
  • infra/queue-backup/bin/export_d1.py
  • infra/queue-backup/bin/queue_backup_common.py
  • infra/queue-backup/bin/restore_drill.py
  • infra/queue-backup/docs/RUNBOOK.md
  • infra/queue-backup/tests/test_export_d1.py
  • infra/queue-backup/tests/test_restore_drill.py
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

@dezren39
dezren39 merged commit 50fba55 into main Nov 22, 2026
2 checks passed
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 22, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-22T21:17:59.443798Z 5fb9923 PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant