From 4bed29e87c9a15c212f65509b1cd05c0a7eed048 Mon Sep 17 00:00:00 2001 From: davion-knight <298846663+davion-knight@users.noreply.github.com> Date: Wed, 15 Jul 2026 01:00:45 -0500 Subject: [PATCH] fix(selfhost): default miner DR scripts to the post-rename config dir backup-miner.sh and restore-miner.sh defaulted STATE_DIR to the pre-rename $HOME/.config/gittensory-miner, so an operator who never sets LOOPOVER_MINER_CONFIG_DIR would back up/restore a directory that no longer exists after the rebrand's hard cutover (the real default is ~/.config/loopover-miner, per local-store.js's resolveLocalStoreDbPath). Fix both defaults to loopover-miner, refresh the describing comments (keeping the #4872 references), and add a test/unit regression guard asserting the default fallback string. Closes #5933 --- scripts/backup-miner.sh | 4 +-- scripts/restore-miner.sh | 8 +++--- .../miner-dr-scripts-config-default.test.ts | 28 +++++++++++++++++++ 3 files changed, 34 insertions(+), 6 deletions(-) create mode 100644 test/unit/miner-dr-scripts-config-default.test.ts diff --git a/scripts/backup-miner.sh b/scripts/backup-miner.sh index 171573567d..7c8aeb96a6 100644 --- a/scripts/backup-miner.sh +++ b/scripts/backup-miner.sh @@ -1,5 +1,5 @@ #!/bin/sh -# gittensory-miner local-state backup (#4872): every store is an independent SQLite file directly under +# loopover-miner local-state backup (#4872): every store is an independent SQLite file directly under # LOOPOVER_MINER_CONFIG_DIR (packages/loopover-miner/docs/operations-runbook.md's "Local state at a # glance") -- there is no Postgres/Qdrant involved, so this is deliberately a simpler sibling to # scripts/backup.sh, not a reuse of it (that script's manifest/multi-target logic has nothing to compose with @@ -17,7 +17,7 @@ # LOOPOVER_MINER_CONFIG_DIR=/data/miner LOOPOVER_MINER_BACKUP_RETAIN=14 sh scripts/backup-miner.sh set -eu -STATE_DIR="${LOOPOVER_MINER_CONFIG_DIR:-$HOME/.config/gittensory-miner}" +STATE_DIR="${LOOPOVER_MINER_CONFIG_DIR:-$HOME/.config/loopover-miner}" OUT_DIR="${LOOPOVER_MINER_BACKUP_DIR:-$STATE_DIR/backups}" RETAIN="${LOOPOVER_MINER_BACKUP_RETAIN:-7}" diff --git a/scripts/restore-miner.sh b/scripts/restore-miner.sh index fcd3b0f637..915f7978b4 100644 --- a/scripts/restore-miner.sh +++ b/scripts/restore-miner.sh @@ -1,5 +1,5 @@ #!/bin/sh -# gittensory-miner local-state restore (#4872): the read side of scripts/backup-miner.sh. STOP the miner (and +# loopover-miner local-state restore (#4872): the read side of scripts/backup-miner.sh. STOP the miner (and # any loop/systemd/docker service) before running this -- it overwrites the live state directory and does not # detect a running process itself, the same "stop first" precondition operations-runbook.md's "ledger # corrupted" scenario already documents for manual recovery. @@ -15,14 +15,14 @@ # sh scripts/restore-miner.sh --yes /path/to/backups/ # restores a specific backup set -eu -STATE_DIR="${LOOPOVER_MINER_CONFIG_DIR:-$HOME/.config/gittensory-miner}" +STATE_DIR="${LOOPOVER_MINER_CONFIG_DIR:-$HOME/.config/loopover-miner}" BACKUP_DIR="${LOOPOVER_MINER_BACKUP_DIR:-$STATE_DIR/backups}" usage() { cat <&2 Usage: $0 --yes [BACKUP_DIR] -Restores gittensory-miner local state from a backup produced by backup-miner.sh. +Restores loopover-miner local state from a backup produced by backup-miner.sh. BACKUP_DIR A specific timestamped backup directory. Defaults to the newest one under \$LOOPOVER_MINER_BACKUP_DIR ($BACKUP_DIR). @@ -98,4 +98,4 @@ for db in "$SOURCE"/*.sqlite3; do echo "[restore-miner] restored $name" done -echo "[restore-miner] complete. Run 'gittensory-miner doctor --json' to verify." +echo "[restore-miner] complete. Run 'loopover-miner doctor --json' to verify." diff --git a/test/unit/miner-dr-scripts-config-default.test.ts b/test/unit/miner-dr-scripts-config-default.test.ts new file mode 100644 index 0000000000..9efd428809 --- /dev/null +++ b/test/unit/miner-dr-scripts-config-default.test.ts @@ -0,0 +1,28 @@ +import { readFileSync } from "node:fs"; +import { join } from "node:path"; +import { describe, expect, it } from "vitest"; + +// Regression guard for #5933: the AMS miner's DR script pair (backup-miner.sh / restore-miner.sh) must default +// their working directory to the miner's real, current config dir (`~/.config/loopover-miner`, per +// packages/loopover-miner/lib/local-store.js's resolveLocalStoreDbPath) and NOT the pre-rename +// `~/.config/gittensory-miner`, so an operator who never sets LOOPOVER_MINER_CONFIG_DIR backs up/restores real +// state instead of a directory that no longer exists after the rebrand's hard cutover. These are `scripts/**` +// shell files, outside Codecov's coverage.include, so this content check is their only automated guard for the +// default (the sibling miner-backup-restore-scripts.test.ts always sets LOOPOVER_MINER_CONFIG_DIR explicitly, so +// it never exercises the default). Pattern mirrors test/unit/miner-docker-compose.test.ts: readFileSync + assert. +const SCRIPTS_DIR = join(process.cwd(), "scripts"); +const CURRENT_DEFAULT = "$HOME/.config/loopover-miner"; + +describe("miner DR scripts default config dir (#5933)", () => { + for (const script of ["backup-miner.sh", "restore-miner.sh"]) { + const source = readFileSync(join(SCRIPTS_DIR, script), "utf8"); + + it(`${script} defaults STATE_DIR to the current ~/.config/loopover-miner`, () => { + expect(source).toContain(`STATE_DIR="\${LOOPOVER_MINER_CONFIG_DIR:-${CURRENT_DEFAULT}}"`); + }); + + it(`${script} carries no pre-rename gittensory-miner residue`, () => { + expect(source).not.toContain("gittensory-miner"); + }); + } +});