Skip to content

docs: migrate backup scripts & backup documentation from hatch (#5976) - #8544

Merged
dezren39 merged 2 commits into
mainfrom
queue/10506-5976-backup-docs-migration
Nov 11, 2026
Merged

dezren39 merged 2 commits into
mainfrom
queue/10506-5976-backup-docs-migration

Conversation

@dezren39

@dezren39 dezren39 commented Nov 11, 2026 •

Copy link
Copy Markdown
Member

Summary

Implements #5976: the backup batch of the hatch → code docs migration (plan §4.1, docs-migration-plan-2026-11-04). Copy, never delete — every hatch original stays in place.

Copied into pkgs/agent-backup/:

  • All tracked files of tools/runtime-db-export/ (24 files: README, schema.sql/schema2.sql, spec_m1–m5/m8/r1/r2/s5.json, loaders, prune SQL, turso_client, progress/load_and_log.py). The issue/plan counted 21; the tracked set is 24, and the complete set is migrated so no part of the pipeline is left behind.
  • tools/bws-backup-secrets.sh — copied as text only, never run during this migration (known delete-then-create hazard, noted in the issue).

Copied into doc/backups/ (new):

  • reports/README.md, reports/backup-process-2026-10-21.md
  • library/toolchains/binary-backup.md
  • library/skills/muse-backup.md
  • archive/small-files/workspace/custom-skills/muse-backup/SKILL.md → doc/backups/muse-backup-SKILL.md (renamed only to sit beside muse-backup.md; content verbatim)

Verification

  • sha256 of all 30 copied files match their hatch sources exactly (byte-identical copies; for that reason the .md copies keep their source formatting — prettier flags 3 of them for pre-existing source style, deliberately not reformatted here).
  • bash -n on the copied shell script: OK. Python AST parse of all copied .py files: OK. Nothing was executed.
  • Reference check before declaring the code copies canonical: no live cron/job references the old hatch paths (the one cron.d copy is archived and enabled: false); the TOOLS.d/secrets.md pointer to the hatch script stays valid because the original remains.
  • After this PR merges, one-line Canonical: headers go onto the hatch copies of the living docs, per the issue's done criteria (hatch-side commit, separate from this PR).

Queue: task 10506, lane code-a (taken direct per #8187 — fresh lane assignment returned direct).


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

@dezren39
dezren39 requested a review from a team as a code owner November 11, 2026 05:14
@coderabbitai

coderabbitai Bot commented Nov 11, 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 55 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: 2cb8002e-94c1-472e-b141-0e95c82db766
Commits

Reviewing files that changed from the base of the PR and between 44fd6a4 and bd7d93b.

Files selected for processing: 30

  • doc/backups/README.md
  • doc/backups/backup-process-2026-10-21.md
  • doc/backups/binary-backup.md
  • doc/backups/muse-backup-SKILL.md
  • doc/backups/muse-backup.md
  • pkgs/agent-backup/README.md
  • pkgs/agent-backup/bws-backup-secrets.sh
  • pkgs/agent-backup/load_from_output.py
  • pkgs/agent-backup/load_rows.py
  • pkgs/agent-backup/load_rows_pg.py
  • pkgs/agent-backup/merge_s5.py
  • pkgs/agent-backup/page_load.py
  • pkgs/agent-backup/progress/load_and_log.py
  • pkgs/agent-backup/prune_m1.sql
  • pkgs/agent-backup/prune_m4.sql
  • pkgs/agent-backup/run_sql.py
  • pkgs/agent-backup/run_sql_pg.py
  • pkgs/agent-backup/schema.sql
  • pkgs/agent-backup/schema2.sql
  • pkgs/agent-backup/set_state.py
  • pkgs/agent-backup/spec_m1.json
  • pkgs/agent-backup/spec_m2.json
  • pkgs/agent-backup/spec_m3.json
  • pkgs/agent-backup/spec_m4.json
  • pkgs/agent-backup/spec_m5.json
  • pkgs/agent-backup/spec_m8.json
  • pkgs/agent-backup/spec_r1.json
  • pkgs/agent-backup/spec_r2.json
  • pkgs/agent-backup/spec_s5.json
  • pkgs/agent-backup/turso_client.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

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 11, 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-11T05:21:46.970825Z bd7d93b New commits
ℹ️ 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.

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

Copy link
Copy Markdown

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: 8ca4cef441

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

Comment thread pkgs/agent-backup/load_from_output.py Outdated
import sys
import os

LOADER = os.path.expanduser("~/tools/runtime-db-export/load_rows.py")

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Resolve the loader relative to the migrated helper

When the saved-output flow is run from the new pkgs/agent-backup location, this hard-coded path still invokes the old ~/tools/runtime-db-export/load_rows.py rather than the loader copied alongside this helper. On a machine with only this checkout, both load_from_output.py and its caller page_load.py fail because that external script does not exist; where the old installation remains, they silently execute its version instead of the migrated one. Resolve the loader relative to __file__, and update the equivalent old-directory references in merge_s5.py and progress/load_and_log.py, so the migrated flow uses this package.

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Fixed in bd7d93b: load_from_output.py now resolves the loader as os.path.join(os.path.dirname(os.path.abspath(__file__)), "load_rows.py"), and the equivalent old-directory references in merge_s5.py and progress/load_and_log.py are resolved relative to the package the same way (progress/load_and_log.py's HERE is now the package root derived from __file__). The migrated flow no longer depends on the hatch ~/tools/runtime-db-export path. Other ~/tools/... references in the package (supabase-exec, bws-env) point at separate hatch tools that are outside this batch's scope (supabase-exec migrates in a later batch, plan §4.3) and were left as-is deliberately.

Comment thread pkgs/agent-backup/set_state.py Outdated
Comment on lines +20 to +21
with open(STATE) as f:
state = json.load(f)

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Bootstrap the state file in the migrated directory

When set_state.py is invoked from the migrated package, it unconditionally reads an adjacent state.json, but that file was not migrated and there is no initialization path. A repository-wide file search and inspection of the package's state references found neither the file nor a bootstrap step. Consequently, even on the original host with its old state file intact elsewhere, this copy raises FileNotFoundError before recording the outcome in agent_mirror_export_state. Provide an explicit state migration/bootstrap step or initialize the expected {"tables": {}} structure when the file is absent.

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Fixed in bd7d93b: set_state.py now bootstraps when the adjacent state file is absent — it starts from {"tables": {}} and writes state.json on the first run, instead of raising FileNotFoundError. (The live state.json is runtime state and intentionally not migrated; the bootstrap makes the migrated copy self-initializing.)

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

Copy link
Copy Markdown

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: bd7d93b170

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

Comment on lines +365 to +366
for i in range(0, len(statements), 100):
chunk = statements[i:i + 100]

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Preserve the session across history-loader pipeline chunks

When a history-enabled spec such as spec_m3.json loads a 100-row page, load_rows.py creates and populates the temporary rde_incoming table using more than 100 statements. This loop splits those statements into separate _pipeline calls, each of which appends close without preserving a session baton. Subsequent staging inserts and the history archive therefore access a connection where rde_incoming does not exist, causing normal paged exports to fail. Preserve the same session across chunks or keep the staging, archive, and merge operations together.

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Dispositioned, not fixed in this PR: this is a pre-existing defect in the hatch original (tools/runtime-db-export/turso_client.py) that this migration copies verbatim — it is not introduced by the move. Changing Turso pipeline/session semantics inside a copy-migration PR would silently diverge the migrated copy from the still-running original and cannot be verified without a live Turso target. Tracked properly as its own work item: issue #8545 (fix in the canonical copy + mirror to the hatch original, with a chunk-boundary test). The two findings from the previous round were migration-introduced and were fixed in bd7d93b; this one predates the migration and is filed, not buried.

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