0017. History import: a local one-time tool, replaced by archiving
- Status: Accepted
- Date: 2026-12-01
Context
The old spreadsheet's history has to come into the app once, and be provably the same. The download is a file with real money in it; the app's database refuses deletes (ADR 0014); the repository is public.
Decision
- Where it lives: the pure part (turning a read workbook into a plan, the one-time check, the review list, the reconcile compare) is
packages/core/src/importand uses only the rules core already has. The part that touches files and the database isscripts/import. A fictional download is built by a script inpackages/mocks, so CI runs both a PASS and a FAIL (a deliberately wrong balance) on a file nobody typed. - Which download: File > Download > Microsoft Excel (.xlsx), the only one that keeps all tabs in one file and each cell's fill, underline, notes and formulas. The reader is hand-written on Node's built-ins (zip with size limits, a small XML reader that refuses DOCTYPE), so there is no spreadsheet library to audit or to ship with a real file.
- Local only, and out of git: the script opens a SQLite file under the Worker's local state and nothing else, refuses
--remotestyle flags and any Cloudflare credentials in the shell, and refuses an input or report path inside a git repository. Reports go to~/.config/budget-bob/reports(mode 0700, files 0600). - Re-runs replace, never double: every row an import writes has an id
imp-<run>-<kind>-<n>; a re-run archives all activeimp-rows and writes the new ones in one transaction. Settings and weekly amounts have no id, so a setting carries[import imp-N]in its notes and a weekly amount an import wrote has an audit line; only those are updated, anything else is kept and listed. Stale ones can't be deleted and are listed. - Bank lines come from a second file: the spreadsheet stores no bank transactions (its accounts tab holds balances only), so the compare reads a CSV of the bank's own download. Without it the compare is not run.
- Never run on a real download yet: said at the top of the docs page and in the pull request, so the first real run is read with care.
Consequences
- A run can be repeated on an edited file; the old rows stay, archived, in the database.
- Things the spreadsheet keeps in its script (the bank's words, money movement words, the checking account's last 4) come from a household file kept outside the repo; what is missing is reported.
- The check proves the loaded entries reproduce the file's own balances; it can't prove the file's balances were right.