Removes operator-private material from the shipped tree, corrects documentation
that had drifted from the code, deletes dead code, and applies a consistent
prose style.
Private material moved out of the public tree (docs/private/, git-ignored):
- the wallet keyfile recovery runbook and its helper scripts, which together
published the mainnet wallet file path, the service account, backup snapshot
filenames, and the wallet RPC listener state. The helper duplicated the same
constants, so relocating the document alone would not have removed them.
- the stagenet parallel-candidate runbook and its fixtures.
- the dated production-state record, the internal remediation plan, and the
TODO list. None are reference documentation for an outside reader.
Redacted or genericised:
- operator home-directory paths in shipped scripts and units. The asset build
script now takes KENNEY_ASSETS_DIR instead of a hard-coded path.
- private LAN addresses in tests, env examples and deploy docs, replaced with
RFC 5737 documentation addresses.
- the default alert sender and the notification hub example.
- the Monero wallet unit now matches the Wownero one: a dedicated service
account and a config file, instead of the operator's login account with the
wallet password in argv where any local user can read it from /proc.
Ignore rules now cover every .env variant rather than the bare name, plus local
agent state. The deployment docs instruct operators to create .env.mainnet and
.env.stagenet, which the exact-name rule would have allowed to be committed.
Documentation corrected against the code: per-chain dungeon level counts, the
premium unlock rule, Tavern chat scope, backup retention, the chain-profile
fallback, the environment template location, and several sections describing
shipped work as pending.
Dead code removed: configPersistence, rpccalls, a duplicate vendored ROT.js
bundle, the unused tile-picker overlay, the unreachable legacy game-size path
and its vestigial parameter, spectator stubs that shadowed the real
SpectatorManager, and commented-out debugging. nip98 now imports the shared
nostr loader rather than duplicating it.
Prose style: em-dashes removed throughout in favour of colons, semicolons and
commas; comments restated as present-tense descriptions of the code rather than
narration of past changes.
127 suites / 1015 tests pass.
5.4 KiB
Disposable clone migration gate
npm run db:migrate:clone applies a release's ordered migrations to an existing, disposable
PostgreSQL clone. It is the migration step for a restored production dump, run before an immutable
release becomes eligible for activation. It never creates, restores, drops, audits, or activates a
database.
The runner is src/scripts/migrate-disposable-clone.js. Its only input is the inherited process
environment: it accepts no command-line options, so a target or credential cannot land in argv or
shell history.
Hard target contract
The runner refuses to open a connection unless all of these conditions hold:
DB_HOSTis explicit loopback (127.0.0.1,::1, orlocalhost) or one of the standard local Unix socket directories/run/postgresqland/var/run/postgresql;DB_NAMEmatches^[a-z][a-z0-9_]{2,62}$, its first underscore-delimited token ismonerogue,wownerogue, orwowngeon, and some later token is exactlyclone,restore, orcanary;- no token of
DB_NAMEbegins with a live marker:active,current,live,mainnet,master,primary,prd,prod, orproduction; CLONE_MIGRATION_EXPECT_DATABASEexactly equalsDB_NAME;CLONE_MIGRATION_CONFIRMexactly equalsMIGRATE_DISPOSABLE_CLONE:<DB_NAME>;DB_PORTis an explicit integer port from 1 through 65535 andDB_USERis an explicit simple role name matching^[a-z_][a-z0-9_]{0,62}$;DATABASE_URLis unset or empty, and the process receives no command-line arguments.
The migration manifest is then discovered from the running release's src/migrations directory.
Every .sql entry must be a regular file named NNN_name.sql, the ordinals must be contiguous
from 001, and the highest ordinal must be at least 043.
Only after those static gates pass does the runner connect. It opens a single-connection pool
(max: 1, five-second connection and idle timeouts, application_name
wowngeon-disposable-clone-migrations) and reads PostgreSQL's own current_database() before any
DDL, requiring an exact match with CLONE_MIGRATION_EXPECT_DATABASE.
Migrations then run through the same DatabaseManager.runMigrations() that application startup
uses: lexical filename order, a schema_migrations ledger, and one transaction per newly applied
file that both executes the SQL and records the ledger row. Afterwards the runner requires the
ledger to equal the repository manifest exactly: same count, same filenames, same order, ending at
the same latest migration.
A successful run reports:
clone_migration_status=ok
database=monerogue_restore_20260721t220048z_28d513b29b36
migration_count=43
latest_migration=043_durable_solo_restart_snapshots.sql
Any refusal or verification failure exits non-zero after printing a single line prefixed REFUSED:
(target or manifest contract violation) or FAILED: (any other error). The FAILED: path prints no
server diagnostics, connection object, or environment value.
Invocation
Create and restore the clone with the reviewed backup procedure first. Keep the target variables in
a protected operator-owned environment file and database credentials in a mode-0600 PGPASSFILE.
Do not pass a password, connection URL, or target as a command argument. A non-secret target
environment looks like this:
DB_HOST=127.0.0.1
DB_PORT=5432
DB_NAME=monerogue_restore_20260721t220048z_28d513b29b36
DB_USER=monerogue
PGPASSFILE=/run/wowngeon/clone-migration.pgpass
CLONE_MIGRATION_EXPECT_DATABASE=monerogue_restore_20260721t220048z_28d513b29b36
CLONE_MIGRATION_CONFIRM=MIGRATE_DISPOSABLE_CLONE:monerogue_restore_20260721t220048z_28d513b29b36
Database names use lowercase letters, digits, and underscores only. Normalize a release ID into a
separate safe tag rather than copying a hyphenated artifact ID into DB_NAME.
Load that protected environment through the reviewed service or wrapper, change into the extracted
candidate's src directory, and run only:
npm run db:migrate:clone
Do not append -- arguments. The runner logs no host, role, password, connection URL, or
PGPASSFILE contents. DB_PASSWORD is honoured when an already-protected service environment
supplies it and is held in memory only; PGPASSFILE or PGPASSWORD is preferred, and neither
requires the application-specific variable.
Required follow-on gates
Run these against the same clone after migration:
scripts/deploy/financial-audit.sql, compared against the pre-migration audit of the same data;scripts/deploy/financial-constraint-validate-restore.sql, the restored-data constraint validation gate described in FINANCIAL_CONSTRAINT_VALIDATION.md.
Then test both the candidate and its predecessor against the migrated clone, as described in RELEASE_ARTIFACT.md. The deploy SQL lives outside the runtime artifact and is run from the repository against the clone.
Limits
This runner does not prove that a database with a disposable-looking name is operationally disposable, does not prevent another process from connecting to it, and does not acquire an activation-wide drain lock. The operator must create the clone from the intended fresh dump, keep it outside public service configuration, and destroy it separately after the release decision.
A successful result authorizes only the next audit and test gate. It does not authorize a symlink switch, wallet action, payout, or traffic restoration.