GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — impl(backups): mesh class D — fleet-queue-backup D1 export to Turso home (#13458) by dezren39 · Pull Request #13539 · developing-today/code

Conversation

@dezren39

@dezren39 dezren39 commented Nov 23, 2026 •
edited by blacksmith-sh Bot
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Member

Refs #13458 — backup-mesh class D leg (design: #9093, record PR #13467). This PR lands the code half of the leg; the issue stays open for the live leg and the step-2 inventory (named on the issue).

What lands

The reverse of the #8584 pipeline, reusing its machinery (fq_common clients, restore_drill's D1 schema/read path with keyset paging and CAST-AS-TEXT integer fidelity):

  • bin/export_to_turso.py — weekly D1 → Turso-home export for the fleet-queue-backup D1 database into the new home d1-backup-fleet-queue-backup. Staged wholesale import: load into _d1stage_ tables, verify emitted counts cross-checked against D1 count(*) (a disagreement means the source moved mid-run → fail, previous import intact — the Fleet unification slice 6: backups — Turso into D1, repos to Cloudflare plus mirror plus R2 #8584 smear lesson), then swap behind a commit marker in _d1_backup_home_meta (marker/record import_id equality is the witness), recreate indexes/views/triggers, verify live counts, write the import record with per-table counts, drop the retiring set. An interrupted swap is recovered at the next run's start: uncommitted → roll back to the recorded import; committed → clean the retiring leftovers.
  • bin/restore_drill_d1_home.py — the restore verification: rebuilds the D1 database from the home alone into a local SQLite file (the issue's local-SQLite scratch target) and verifies counts against the import record.
  • systemd/ — run-d1-home-export.sh wrapper (secrets by name from Bitwarden; fails with a clear message while the home token is unprovisioned), fleet-queue-backup-d1-home.service (TimeoutStartSec=2h) + .timer (Sun 03:40 + RandomizedDelaySec 30m, Persistent), install-units.sh extended, argument tests extended.
  • Tests: tests/test_export_to_turso.py (6) + tests/test_restore_drill_d1_home.py (3) — hermetic, sqlite-backed fakes in the established standalone pattern. They caught two real defects during development (the swap renaming its own staging tables aside; a fixture drop-order error), both fixed in-branch.
  • doc/fleet-schedule-registry.md — new Surface 2b row for the timer (declared in repo; laptop install is part of the issue's live leg).
  • README + RUNBOOK: class-D pieces, credentials, provisioning steps for the live leg, failure/recovery notes.

No new dependencies (Python standard library only). No changes to fq_common.py or restore_drill.py.

Evidence

Full infra/fleet-queue-backup suite run remotely against this branch (fleet queue dispatch): fleet-command run 45230221803 — conclusion success: all 9 test files pass (38 tests: pre-existing 29 incl. the #8584 suites, plus 7 export + 3 D1-home drill tests added here) and systemd/test-export-arguments.sh reports all checks passed. Two earlier runs against this branch (45221374628, 45228755235) caught real defects in the new code — the swap renaming its own staging tables aside, and the rollback dropping the retiring set it was about to restore — both fixed in-branch with regression tests before this green run.

What remains on #13458 after this PR

  • Live leg: provision the Turso home d1-backup-fleet-queue-backup, mint the vault token turso.d1-backup-fleet-queue-backup-rw-token, install the units on the laptop, first live import record posted on the issue, live restore verification.
  • Step 2 (follow-on): account-wide D1 inventory.

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

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
felix added 4 commits November 23, 2026 16:51
felix
impl(backups): mesh class D — D1 exports to a Turso backup home (#13458)
cc9ec41
The reverse direction of the #8584 leg: bin/export_to_turso.py exports
the fleet-queue-backup D1 database into its dedicated Turso home
(d1-backup-fleet-queue-backup) on a weekly schedule, reusing
restore_drill's proven D1 read path (keyset paging, CAST AS TEXT
integer fidelity, _cf_KV excluded) and fq_common's libsql client.

Wholesale replace, staged: the new copy is loaded into staging
tables and verified (emitted counts, cross-checked against the
source so a mid-run source move fails the run) before anything live
moves; a failed import leaves the previous import intact. The swap
writes the incoming record as a marker before its first rename and
as the import record after live counts verify -- marker/record
agreement by import_id is the commit point -- and a later run
reconciles retiring tables against it (roll back an uncommitted
swap, drop a committed swap's leftovers).

bin/restore_drill_d1_home.py is the acceptance drill: rebuild the
D1 database from the home into a local SQLite file and verify
counts against the import record. Weekly systemd units
(Sun 03:40) + wrapper fetching credentials by name, install-units
and argument-test coverage, schedule-registry row in the same pass,
README + runbook (incl. the provisioning steps for the live leg).

Hermetic tests: sqlite3 is the oracle -- row-for-row copy incl.
int64::MAX, wholesale replacement, failed-import and smear refusal
leaving the previous import intact, and both swap-crash readings.
felix
fix(backups): the swap's live set must exclude the staging tables (#1…
21b312f
…3458)

home_schema lists every table in the home, staging included, so
_swap renamed the staging tables aside as if they were the live
copy and then could not find them to rename in. Caught by the
hermetic suite on its first remote run (6 errors, no such table:
_d1stage_tasks).
felix
test(backups): drop the index before its table in the v2 fixture (#13458
5c52feb
)

DROP TABLE notes removes idx_notes_task with it, so the explicit
DROP INDEX afterwards failed with 'no such index'. The first
export tests passed in the same run; only the variant-2 fixtures
errored.
felix
fix(backups): swap rollback must not drop the retiring set it restores (
fc40874
#13458)

recover_interrupted_swap built its 'live' set from every table in
the home -- retiring tables included -- dropped them all, and then
failed renaming the retiring tables back ('no such table:
_d1retire_tasks'). The rollback now decides per live table from
the marker: the marker carries the pre-swap live set (replaces),
and a live table is dropped only when a retiring copy shadows it
or it is an incoming table that did not exist before the swap;
untouched old copies stay. New test covers the early-crash shape
(one table renamed aside, the rest live, one incoming-only table
already in). Caught by the hermetic suite on its second remote
run: 5 of 6 export tests passed, this one errored.
@coderabbitai

coderabbitai Bot commented Nov 23, 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 34 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: ee356eed-22f6-4c2f-a5a7-36d45aa4bde4
Commits

Reviewing files that changed from the base of the PR and between cb4f687 and fc40874.

Files selected for processing: 12

  • doc/fleet-schedule-registry.md
  • infra/fleet-queue-backup/README.md
  • infra/fleet-queue-backup/bin/export_to_turso.py
  • infra/fleet-queue-backup/bin/restore_drill_d1_home.py
  • infra/fleet-queue-backup/docs/RUNBOOK.md
  • infra/fleet-queue-backup/systemd/fleet-queue-backup-d1-home.service
  • infra/fleet-queue-backup/systemd/fleet-queue-backup-d1-home.timer
  • infra/fleet-queue-backup/systemd/install-units.sh
  • infra/fleet-queue-backup/systemd/run-d1-home-export.sh
  • infra/fleet-queue-backup/systemd/test-export-arguments.sh
  • infra/fleet-queue-backup/tests/test_export_to_turso.py
  • infra/fleet-queue-backup/tests/test_restore_drill_d1_home.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

  • X
  • Mastodon
  • Reddit
  • LinkedIn
All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@dezren39 dezren39 mentioned this pull request Nov 23, 2026
impl(backups): mesh leg — D1 exports → Turso backup home (fleet-queue-backup D1 first) #13458
Open
4 tasks
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 23, 2026 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

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-23T18:00:34.209705Z fc40874 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.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@dezren39
dezren39 merged commit 192fd04 into main Nov 23, 2026
2 checks passed

Uh oh!

There was an error while loading. Please reload this page.

@dezren39
dezren39 deleted the felix/13458-d1-turso-home branch November 23, 2026 18:00
chatgpt-codex-connector[bot]
chatgpt-codex-connector Bot reviewed Nov 23, 2026
View reviewed changes

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: fc40874e12

ℹ️ 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".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
Comment thread infra/fleet-queue-backup/bin/restore_drill_d1_home.py
Comment on lines +57 to +59
record = export_to_turso.read_import_record(home)
if record is None:
raise RuntimeError("Turso home has no import record; nothing to verify")

@chatgpt-codex-connector chatgpt-codex-connector Bot Nov 23, 2026

Copy link
Copy Markdown

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Verify the import generation stays stable throughout the restore

If the weekly export swaps the home while this drill is reading it, separate table/page requests can copy different import generations. The drill reads the import record only once and never checks the swap marker or rechecks import_id, so an export that changes values without changing per-table counts lets a mixed-generation database pass verification. An interrupted export after the incoming renames can likewise expose uncommitted data under the previous import record. Reject an uncommitted swap and verify that the committed generation remains unchanged through the final read before reporting success.

Useful? React with 👍 / 👎.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@dezren39 dezren39 added the audit:partial PR partially implemented; gap filed label Nov 24, 2026
This was referenced Nov 24, 2026
impl(atlas/fleet): backup mesh — all-Turso 14d restic-zstd to R2, R2/laptop/Drive mesh, D1+laptop DBs into Turso #9093
Open
Fleet unification slice 6: backups — Turso into D1, repos to Cloudflare plus mirror plus R2 #8584
Closed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@chatgpt-codex-connector chatgpt-codex-connector[bot] chatgpt-codex-connector[bot] left review comments

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

audit:partial PR partially implemented; gap filed

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

Uh oh!

There was an error while loading. Please reload this page.

1 participant

@dezren39
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
You are visitor 01402775 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.