Treasury & Bank Transfer Management System — سامانه مدیریت خزانهداری و حوالههای بانکی
dev/v7-production-failclosed-20261021
TreasuryFlow — Local SQLite backup and safe recovery (nonfinal)
This is an offline, operator-controlled procedure for the local SQLite store. It does not certify V7 upgrade/rollback, production database disaster recovery, bank reconciliation or RPO/RTO. Keep all bank adapters disabled during recovery.
Preconditions
- Node.js 22 and the checked-out matching TreasuryFlow source are required.
- Stop the desktop application before restoring and keep a separately protected backup outside the active database directory.
- Treat every SQLite backup as sensitive financial data, not an export for public GitHub/CI.
- Perform this only on an authorized device with encrypted/private storage. The utility does not encrypt its output.
Offline commands
node --experimental-strip-types scripts/treasury-sqlite-recovery.mjs backup /path/to/current.sqlite /secure/new-backup.sqlite
node --experimental-strip-types scripts/treasury-sqlite-recovery.mjs verify /secure/new-backup.sqlite
node --experimental-strip-types scripts/treasury-sqlite-recovery.mjs restore-new /secure/new-backup.sqlite /path/to/new-recovery.sqlite
The backup uses SQLite VACUUM INTO for a consistent committed snapshot, even when the source has WAL activity. It validates PRAGMA integrity_check, required schema tables, exact schema version and financial amounts within JavaScript's precisely representable integer range. A legacy 64-bit SQLite amount that exceeds this limit is rejected, not silently rounded. The destination is created exclusively: an existing file, including a zero-byte file, is never overwritten. Restore works only to a new filename and does not modify the active database.
Operational handover / rollback
- Capture and verify a protected backup; record its SHA-256 in private release records.
- Run recovery into a new path and compare account, beneficiary, payment and audit counts.
- Have a finance checker independently reconcile balances, payment identifiers and critical audit sequences against authorized records. Counts alone are not reconciliation.
- Transactions in
UNKNOWNandDISPATCHINGmust remain blocked from automatic bank resubmission after restore. Confirm their status externally with the bank through approved channels and maker/checker review. - Point a separate test deployment at the recovered database for smoke verification. Production path switching is a separately authorized deployment action; this utility never performs it.
Security boundaries
- Never upload a real customer SQLite file, backup or restored copy to public CI artifacts, public repositories or support logs.
- This is not an automatic scheduled backup service and does not guarantee any production RPO/RTO.
- A valid file alone does not prove finance correctness or permission to replay bank transactions.
- Corrupt, unsupported-schema and existing-target cases fail closed, with no operational file replacement.
Test acceptance
See src/platform/local/verified-sqlite-backup.test.ts and scripts/treasury-sqlite-recovery.test.ts for normal, WAL, corruption, version, no-overwrite and operator command regressions. Verified in real three-job independent hosted CI run 39945850403, all PASS: full finance suite, strict typecheck, lint, Next build, smoke, production-only dependency audit 0, local WAL backup/restore and CLI normal/edge/failure tests. The preceding run 39945245100 uncovered a TypeScript error in the fs exclusive-copy constant; it was repaired and all three jobs were rerun. These are three separate CI processes, not three autonomous AI review agents.
This proves the local test contract only. It does not prove a Windows V7 installer, real Mayan database integration, authorized bank UAT or production recovery RPO/RTO.
Cross-platform rerun after financial-state recovery checks
Run 39946900552: all four independently hosted jobs PASS, including a real Windows Server 2022 job. The regression additionally recovers payments in UNKNOWN and in-flight DISPATCHING states from a verified backup and confirms the recovered instance cannot re-submit them automatically. Full financial suite, backup operator CLI, TypeScript, ESLint, build, smoke, production audit, corruption and no-overwrite assertions are included.
This remains a synthetic local rehearsal, not an actual production recovery, a V7 upgrade/rollback, or proof of a production RPO/RTO.