Merge branch 't3/plain-folder-backups': a backup is a plain folder; git leaves the program (D-91, D-92)
Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
This commit is contained in:
commit
e6d722372e
84 files changed
+14087
-7326
No files matched your search
@@ -487,9 +487,8 @@ already running with other flags keeps them; on a self-host machine
|
||||
`serve` is the unit's only holder.
|
||||
|
||||
The unit sets `IPAddressDeny=any` and `IPAddressAllow=localhost`: the
|
||||
server reaches nothing out. A book whose backup target is a remote git
|
||||
repository therefore needs that host allowed in a drop-in (D-31 backups
|
||||
still run on the server). The recipe, the head check for the move and the
|
||||
server reaches nothing out. Backups go to a folder on the machine's own
|
||||
disks and need no network (D-91). The recipe, the head check for the move and the
|
||||
two-account CI job are in `deploy/README.md`, `deploy/wanderbooks-server.service`
|
||||
and `.github/workflows/two-user.yml`; the checks are
|
||||
`crates/ledger-cli/tests/two_user.rs`.
|
||||
|
||||
+164
@@ -0,0 +1,164 @@
|
||||
# Backups
|
||||
|
||||
A backup of your books is an ordinary folder of ordinary files. Nothing needs
|
||||
to be installed to make one or to read one back, and you never need to know how
|
||||
it works. This page says where it is, what is in it, and how to get your books
|
||||
back, on this computer, on a new one, or from a backup an older version made.
|
||||
|
||||
## Where it is
|
||||
|
||||
You choose the folder once (in the window: **Back up to...**): another disk, a
|
||||
USB drive, a folder on your network, or a folder your cloud drive keeps in sync
|
||||
(Dropbox, iCloud Drive, OneDrive, Google Drive). Your books then back
|
||||
themselves up a little after each change, when they open and before they
|
||||
close; **Back up now** does it at once. Every backup is read back and checked
|
||||
before it is counted as good. A backup that is more than a day behind is
|
||||
flagged, and once a week your books prove they can be restored from it: the
|
||||
newest backup, in full. If the newest backup is damaged, that check fails and
|
||||
says so, even when an older backup is still whole.
|
||||
|
||||
**If the folder is kept in sync by Dropbox, iCloud Drive, OneDrive, Google
|
||||
Drive or the like:** use that folder from one computer only (two computers
|
||||
backing up into one synced folder can overwrite each other's work; a second
|
||||
computer needs a folder of its own), and keep it available offline, not online
|
||||
only. A file that is online only and not yet on this computer reads as "not
|
||||
downloaded yet", never as damage: the backup waits, and nothing is written
|
||||
over it. The set-up and the Backups window say this too.
|
||||
|
||||
## What is in it
|
||||
|
||||
One folder for your books, inside the folder you chose:
|
||||
|
||||
```text
|
||||
Backups/ the folder you chose
|
||||
wanderbooks-acme/ your books (wanderbooks- and the name you gave them)
|
||||
READ-ME.txt a few words about the folder
|
||||
manifests/
|
||||
000001.json one per backup that changed something
|
||||
000002.json
|
||||
proofs/000001 a mark that a backup was read back and proven
|
||||
journal/000001-..., 000002-... the journal, in pieces
|
||||
access/000001-... who reached the books, in pieces
|
||||
files-index/000001-... which receipts and files there are
|
||||
files/ab/abcdef... each receipt or file, once
|
||||
vault/... keys/... your tax-ID vault and its key
|
||||
```
|
||||
|
||||
Files are only ever **added**. Nothing in the folder is changed or deleted by
|
||||
Wanderbooks, so a sync service never sees a file change under it, and an earlier
|
||||
state of your books is always still there. A backup counts as complete only
|
||||
when its small manifest file is in place, written last; an interrupted backup
|
||||
leaves a few unused files and the last complete backup is still whole. A
|
||||
manifest lists the one before it and what is new, and one in sixty-four lists
|
||||
everything again, so a folder of thousands of backups stays small (3,000 backups
|
||||
took 12 MB of manifests, the newest 0.8 KB). Two computers backing up to one
|
||||
folder cannot damage it either: whichever writes the next manifest first wins,
|
||||
and the other goes on from there (but see above: one computer per synced
|
||||
folder).
|
||||
|
||||
**What "backed up" means.** After each backup Wanderbooks reads the new manifest
|
||||
back from the folder and checks it: every piece of the journal and the access
|
||||
log is read again and its checksum checked, the journal's chain is replayed to
|
||||
its end, your books are opened from it, the vault and its key are there, and the
|
||||
receipts and files that backup added are read again together with a sixteenth
|
||||
of the others, so **every receipt and file is read again within sixteen
|
||||
backups** (the weekly check reads all of them). Only then is the backup counted
|
||||
as good. If a file in the folder turns out to be damaged (a bad sector, a bad
|
||||
sync), the next backup writes that file again beside it under a new name ending
|
||||
`.g1`, uses the good one from then on, and the Backups window lists the damaged
|
||||
file as found and written again. The damaged file stays where it is, because
|
||||
Wanderbooks never deletes anything in the folder: you may delete it yourself.
|
||||
|
||||
**If your books are behind the folder.** If you restored your books from an
|
||||
older backup (or a backup file) and then point them at the folder that holds a
|
||||
longer history of them, Wanderbooks says so and writes nothing: *the backup
|
||||
folder holds a longer history of these books than this computer has*. To carry
|
||||
on with the books you have, choose **Start a new backup set here** in the
|
||||
Backups window (or `wanderbooks books back-up ID --new-set`): a new set
|
||||
(`wanderbooks-acme.2`) begins beside the old one, which stays in the folder,
|
||||
untouched, and later backups go to the new one. If instead the folder holds
|
||||
other books, or a history that has diverged from yours, Wanderbooks says so and
|
||||
writes nothing.
|
||||
|
||||
**If the passphrase key is lost.** Your computer keeps the passphrase's key
|
||||
privately. If that file is lost while the folder's backups are sealed,
|
||||
Wanderbooks stops, writes nothing, and asks for the passphrase again in the
|
||||
backup settings: it never quietly writes an unprotected copy of your books into
|
||||
a folder you protected. Backups are written without protection only after you
|
||||
choose **Take the passphrase off**.
|
||||
|
||||
If your disk is short of room, you may delete the whole folder of your books
|
||||
(never parts of it) once you have another backup.
|
||||
|
||||
## A passphrase (optional)
|
||||
|
||||
When you set up backups you may protect them with a passphrase. It is off unless
|
||||
you turn it on. With one, every file in the folder is sealed (XChaCha20-Poly1305;
|
||||
the key comes from your passphrase through Argon2id) and the file names say
|
||||
nothing about your books, only how many files there are and how big. Your
|
||||
computer keeps the key privately, so backups stay automatic. **A forgotten
|
||||
passphrase cannot be recovered**, by anyone: write it down somewhere safe.
|
||||
On another computer, restoring asks for the passphrase.
|
||||
|
||||
Changing the passphrase starts a new set of sealed backups beside the old
|
||||
ones, which stay as they are and stay sealed with the passphrase they were made
|
||||
with. Turning it off makes later backups plain. If you want old backups gone
|
||||
after a change, delete their folder yourself.
|
||||
|
||||
## One file instead of a folder
|
||||
|
||||
**Save a backup...** writes the same backup as a single file ending in
|
||||
.wbbackup (a zip). Keep it, email it to yourself, or carry it on a USB stick. It
|
||||
is sealed if your backups are. A file by the same name is never overwritten.
|
||||
|
||||
## Getting your books back
|
||||
|
||||
**Restore...** takes the backup folder you chose (or the folder of one set of
|
||||
books inside it), or a .wbbackup file. It checks everything first and shows you
|
||||
what it found: how far the books go, how many files. If the newest backup in the
|
||||
folder is damaged and this restore would use an older one, the first thing it
|
||||
says, in bold, is **NOT THE NEWEST BACKUP**, with how many newer backups it passes
|
||||
over, when this backup was made, when the newest was, and that anything written
|
||||
after this backup is not in it. Only then does it put your books back, as new
|
||||
books, or in place of books with the same name (those are kept whole in a
|
||||
`legacy` folder, never deleted).
|
||||
|
||||
On a **new computer**: install Wanderbooks, open it, choose **Restore...**, point it
|
||||
at the backup folder (connect the disk or let your cloud drive finish syncing
|
||||
first) or at the .wbbackup file, and give the passphrase if it asks. Then choose
|
||||
a backup folder again to keep backing up.
|
||||
|
||||
If the disk your backups were on is not connected, Wanderbooks says so and does
|
||||
not start over on another disk by itself: connect the disk, or, if it is a new
|
||||
disk, say so when you back up and it begins there again.
|
||||
|
||||
## A backup made with an older version
|
||||
|
||||
Older versions kept backups differently, in a way that needed another program
|
||||
called git. Wanderbooks no longer writes those or reads them, and does not touch
|
||||
them: they stay exactly where they are. If you still have one and want your books
|
||||
from it, you can get them back with git yourself:
|
||||
|
||||
1. In a terminal, make a plain folder from the old backup (it is the folder named
|
||||
after your books, ending in .git, inside the folder you backed up to):
|
||||
|
||||
```text
|
||||
git clone /path/to/backups/acme.git acme-old
|
||||
```
|
||||
|
||||
2. Adopt that folder as books (with your vault and its key, which the backup
|
||||
also kept), and check what it says:
|
||||
|
||||
```text
|
||||
wanderbooks books adopt acme-old --id acme --vault acme-old/vault --vault-key acme-old/keys/legacy.key
|
||||
```
|
||||
|
||||
It copies the books in, proves them whole, and leaves the original as it was.
|
||||
(If your books had a tax-ID vault you did not use, leave out the two vault
|
||||
options and add `--no-vault`.)
|
||||
|
||||
3. Choose a backup folder for the books you got back, so new backups are made in
|
||||
the new form beside the old one.
|
||||
|
||||
Your books still list the private repository they used to back up to; it is no
|
||||
longer used, and you may clear that setting.
|
||||
+7
-6
@@ -23,8 +23,8 @@ close the window: that quits Wanderbooks fully and closes your books.
|
||||
|
||||
Where things are: the program is in `%LOCALAPPDATA%\Programs\Wanderbooks`; your
|
||||
books, keys and backups are in `%LOCALAPPDATA%\wanderbooks`.
|
||||
Backups need Git for Windows (https://git-scm.com/download/win, or `winget
|
||||
install --id Git.Git -e`); without it Wanderbooks works and says so.
|
||||
Backups need nothing installed: choose a backup folder in Wanderbooks
|
||||
(another disk, or a folder your cloud drive keeps in sync).
|
||||
|
||||
## macOS
|
||||
|
||||
@@ -38,8 +38,9 @@ install --id Git.Git -e`); without it Wanderbooks works and says so.
|
||||
remove it, drag it to the Trash. Neither touches your books.
|
||||
|
||||
Your books, keys and backups are in `~/Library/Application Support/wanderbooks`.
|
||||
Backups need git: run `xcode-select --install` in Terminal (or `brew install
|
||||
git`).
|
||||
Backups need nothing installed: choose a backup folder in Wanderbooks
|
||||
(another disk, or a folder iCloud, Dropbox, OneDrive or Google Drive keeps in
|
||||
sync).
|
||||
|
||||
## Linux
|
||||
|
||||
@@ -48,8 +49,8 @@ Ubuntu), the `.rpm` (Fedora), the Arch package, or the AppImage (one file: mark
|
||||
it executable, keep it where you put it, and run it). Open **Wanderbooks** from
|
||||
the menu. To update, install the newer package, or replace the AppImage. Your
|
||||
books are in `~/.local/share/wanderbooks` and are never touched by a package.
|
||||
Backups need git (`sudo apt install git`, `sudo dnf install git`,
|
||||
`sudo pacman -S git`).
|
||||
Backups need nothing installed: choose a backup folder in Wanderbooks
|
||||
(another disk, or a folder your sync program keeps).
|
||||
|
||||
## After it is installed
|
||||
|
||||
|
||||
+71
-78
@@ -378,27 +378,21 @@ didn't open, with why). Protocol version 1: the requests are new, the
|
||||
(a drill, or a format upgrade not yet journaled, is stopped when the
|
||||
close begins, at its next look, so it never takes the last backup's
|
||||
turn; its scratch clone is removed and the books are unchanged):
|
||||
a backup still running after that is stopped (git is sent SIGTERM, which
|
||||
makes it remove its own lock files, and killed with all it started only
|
||||
if it hasn't ended after 5 seconds) and waited for to end. The program
|
||||
never writes to or deletes from a backup folder (it is the owner's, and
|
||||
may be shared with other computers or a sync program): a lock git left
|
||||
there when it had to be killed is left in place, recorded in
|
||||
`ops/backup.jsonl` as `lock_left` with its whole path, and the target's
|
||||
backup is marked failed with words naming the file and saying to remove
|
||||
it only when nothing else is using the backup folder (`books.backup`
|
||||
and the close's answer say the same; the next backup that finds the
|
||||
lock gone goes on). In the book's own archive (`archive.git`, private to
|
||||
the program; running git by hand inside it is unsupported) it removes
|
||||
only the locks its own stopped git made, and, at open and when a backup
|
||||
begins, locks older than ten minutes, each recorded `lock_removed`;
|
||||
a backup still running after that is stopped (its copy of files
|
||||
stops at the next piece, or the next 64 KiB of one) and waited for to
|
||||
end. The program never rewrites or deletes anything in a backup folder
|
||||
(it is the owner's, and may be shared with other computers or a sync
|
||||
program): a backup stopped part way leaves pieces no manifest names and
|
||||
the folder proves whole at its previous manifest, so there is nothing to
|
||||
clean up and nothing to remove by hand.
|
||||
**What a close stops, and what it waits for.** At its start a close
|
||||
stops the calls and jobs that can do long I/O or loop over a book's
|
||||
whole journal or files, each at its next look: `books.back_up_now` and
|
||||
a backup a timer asked for (git is stopped; the call answers that it was
|
||||
stopped because the books are closing, its access record says
|
||||
a backup a timer asked for (its copy is stopped; the call answers that it
|
||||
was stopped because the books are closing, its access record says
|
||||
`refused: stopped_by_close`, and nothing it was doing is recorded as done;
|
||||
a commit it had made stands), `books.verify` (once per journal line and
|
||||
what it had written stands, and the folder still proves whole at its
|
||||
previous manifest), `books.verify` (once per journal line and
|
||||
per stored file; a heal of a drifted database is begun only if no stop
|
||||
was asked before it, then finishes), `books.export_cpa_package` (once per
|
||||
stored file, unless it has journaled a decision, below), a drill, and a
|
||||
@@ -1365,75 +1359,74 @@ through the policy.
|
||||
|
||||
## Tools — backups
|
||||
|
||||
Books back themselves up (plan 3.7, D-30,
|
||||
D-31): each keeps `archive.git`, a bare repository whose commits are its
|
||||
journal, stored files, vault, keys and access log as they were (one
|
||||
commit per backup, made under the store's lock, its message
|
||||
`seq N head H` and, below, `book <id>`), pushed fast-forward only to the targets the settings
|
||||
name: `backup.git_remote` (the owner's private repository) and
|
||||
`backup.folder` (a repository `<book>.git` in a folder on another disk).
|
||||
Not encrypted: the destinations keep it private. Backups run a little
|
||||
after the books are last written (`--backup-quiet`, 30 s), when they
|
||||
open, before they close, and on request; a failed one is retried after
|
||||
15 minutes. Each target is drilled weekly: cloned, its chain replayed,
|
||||
every stored file re-hashed, every TIN record the books name there with
|
||||
its key, its head the one its commit records, its journal a byte prefix
|
||||
of the live one (a failed drill is tried again at the server's next
|
||||
hourly look, once 15 minutes have passed). A backup's tree is checked
|
||||
before any of it is written out: plain files under the backed-up paths
|
||||
only, never a link or a submodule. git runs with no hooks (in a
|
||||
repository on this computer it pushes to as well), no ignore or
|
||||
attributes rules of anyone's (a `.gitattributes` in a book's folder
|
||||
refuses the backup) and no command-running transports; a repository on
|
||||
this computer is used only if plain (a bare repository at that very
|
||||
path, no settings of its own but where a copy came from, nothing sending
|
||||
git elsewhere, no link where it or its parts are), and a backup folder that took backups and is gone is
|
||||
reported as a disk not connected, never made again (restored books count
|
||||
the backups of the books they were). Books restored beside the books they
|
||||
were (under another id) don't push to those books' repository, which
|
||||
would stop theirs: `books.backup` says it is paused for them until
|
||||
another is named. A damaged backup record is set aside and begun again;
|
||||
it never keeps the books shut. One book's drill holds the others'
|
||||
backups until it ends (a backup at close waits at most a minute for
|
||||
it). A target
|
||||
whose push failed is left out of the backups after writes for 15
|
||||
minutes, then tried again, written to or not; the other targets don't
|
||||
wait for it. Every
|
||||
commit, push and drill is a record in the book's `ops/backup.jsonl` (a
|
||||
chain log; a backup never moves the books' head), each target's records
|
||||
keyed by the target itself. Setting `backup.*` (books.set_setting) needs
|
||||
books:admin, as
|
||||
backing up does: a backup is the whole book, its vault and key included.
|
||||
Books back themselves up (plan 3.7, D-91, D-92): to the folder the settings
|
||||
name, `backup.folder` (a folder on another disk, or one a sync service
|
||||
keeps), as plain files written once (docs/backups.md): a folder for the
|
||||
books holding a read-me, a `manifests/` folder, and the pieces the manifests
|
||||
name, the journal and the access log as numbered segments, an index of the
|
||||
stored files and the files themselves under their hash, the vault and keys
|
||||
by content hash. The manifest is written last and makes a backup complete;
|
||||
nothing in the folder is ever rewritten or deleted. Taking a backup holds
|
||||
the store's lock only to cut the books (the journal's length and head, the
|
||||
vault, the keys); the files are written after it. With a passphrase (D-92,
|
||||
set up in the window; off by default) every file is sealed with
|
||||
XChaCha20-Poly1305, the key derived with Argon2id (64 MiB, 3 passes, 1
|
||||
lane), names say no more than counts and sizes, and the key is kept on this
|
||||
computer only. Backups run a little after the books are last written
|
||||
(`--backup-quiet`, 30 s), when they open, before they close, and on request;
|
||||
a failed one is retried after 15 minutes. The folder's backup is drilled
|
||||
weekly: its books built and proven whole, every stored file re-hashed, every
|
||||
TIN record the books name there with its key, its head the one its manifest
|
||||
records, its journal a byte prefix of the live one (a failed drill is tried
|
||||
again at the server's next hourly look, once 15 minutes have passed). A
|
||||
backup is written only onto a folder whose newest whole manifest is a point
|
||||
on the live journal; one holding other books, another history, or more than
|
||||
these books have is said, and nothing is written. A backup folder that took
|
||||
backups and is gone is reported as a disk not connected, never made again
|
||||
(restored books count the backups of the books they were). Books restored
|
||||
under another id back up to a folder of their own in the same place. A
|
||||
damaged backup record is set aside and begun again; it never keeps the books
|
||||
shut. A folder whose write failed is left out of the backups after writes
|
||||
for 15 minutes, then tried again. Every cut, write and drill is a record in
|
||||
the book's `ops/backup.jsonl` (a chain log; a backup never moves the books'
|
||||
head), the folder's records keyed by the folder and the passphrase. Setting
|
||||
`backup.*` (books.set_setting) needs books:admin, as backing up does: a
|
||||
backup is the whole book, its vault and key included. Books that still name
|
||||
a private repository (`backup.git_remote`, an older kind of backup) work as
|
||||
ever; `books.backup`'s `note` says it is no longer used, and an older backup
|
||||
history in the book's folder is left alone and said once.
|
||||
|
||||
- `books.backup {}` (books:read) → `{ head_seq, targets: [{ target:
|
||||
"repository" | "folder", at, last_ok_at, through_seq, stale,
|
||||
last_error, last_drill_at, drill_error, paused }], note }`. `paused`:
|
||||
not backed up there, these books being restored as a copy of others
|
||||
(its `last_error` says so). `stale`: the target
|
||||
"folder", at, last_ok_at, through_seq, stale, last_error,
|
||||
last_drill_at, drill_error, sealed, disconnected }], note }`.
|
||||
`sealed`: protected by a passphrase. `disconnected`: its disk isn't
|
||||
there. `stale`: the target
|
||||
lacks the head, and the first try to back up what it lacks (since its
|
||||
last good backup, or ever) is more than a day old. `last_error`: its
|
||||
last push's, or a later failed commit's. `note`
|
||||
says what to set when no target is. `books.start` adds a next step when
|
||||
none is set up, or one is stale, failing, paused or failed its drill.
|
||||
last write's, or a later failed cut's. `note`
|
||||
says what to set when no folder is, and what older settings or history are
|
||||
no longer used. `books.start` adds a next step when none is set up, or the
|
||||
folder is stale, failing or failed its drill.
|
||||
- `books.back_up_now { new_disk? }` (books:admin) → the same, after
|
||||
backing up to every target now. `new_disk`: the backup folder's disk is
|
||||
backing up to the folder now. `new_disk`: the backup folder's disk is
|
||||
new, so a folder that took these books' backups and holds none now is
|
||||
begun again (otherwise it is a disk not connected). The one tool whose
|
||||
`openWorldHint` is true. A target paused for books restored as a copy
|
||||
of others shows `paused` (and is no failure to retry).
|
||||
`openWorldHint` is true.
|
||||
|
||||
Restoring is the owner's, from a terminal: `wanderbooks books restore
|
||||
BACKUP [--id ID] [--replace] [--yes]` (the admin socket's `restore`,
|
||||
previewed then confirmed against the previewed head; without `--id`, the
|
||||
books keep the id of the books the backup holds, which the preview names,
|
||||
else the repository's name; under another id they are a copy, and don't
|
||||
push to those books' repository). The backup is
|
||||
cloned into the root, proven whole as a drill proves it (but for the
|
||||
live-journal check: there may be no live books), and built as an
|
||||
adoption builds; it arrives as new books, or replaces books (`--replace`,
|
||||
which are let go and moved whole into `legacy/<id>-<time>/`). The
|
||||
restored books keep the backup's history, so their next backups carry
|
||||
on from it.
|
||||
Restoring is the owner's, in the window (Restore...) or from a terminal:
|
||||
`wanderbooks books restore BACKUP [--id ID] [--replace] [--yes]` (the admin
|
||||
socket's `restore`, previewed then confirmed against the previewed head;
|
||||
without `--id`, the books keep the id of the books the backup holds, which the
|
||||
preview names). BACKUP is the backup folder, the folder of one set of books in
|
||||
it, or a backup file (`.wbbackup`); a sealed one asks for its passphrase
|
||||
(unechoed at a terminal, never on the command line). The backup is built in
|
||||
the root, proven whole as a drill proves it (but for the live-journal check:
|
||||
there may be no live books), and built as an adoption builds; it arrives as
|
||||
new books, or replaces books (`--replace`, which are let go and moved whole
|
||||
into `legacy/<id>-<time>/`). If the newest backup in the folder is damaged,
|
||||
the newest whole one is the one previewed, and the preview says so. A sealed
|
||||
backup's restored books keep backing up sealed, to the same folder, from this
|
||||
computer.
|
||||
|
||||
## Tools — payouts
|
||||
|
||||
|
||||
+2
-26
@@ -280,7 +280,7 @@ entry, icon, licences).
|
||||
| Books | `%LOCALAPPDATA%\wanderbooks` | `~/Library/Application Support/wanderbooks` | `~/.local/share/wanderbooks` (unchanged) |
|
||||
| Removal leaves the books | the uninstaller names no data folder | dragging to Trash runs nothing | no package script runs |
|
||||
| No console window | built for the GUI subsystem; attaches to a terminal for commands | n/a | n/a |
|
||||
| Without git | says how to get Git for Windows | says `xcode-select --install`; the system's stub is not taken for git | says the package manager's command |
|
||||
| Backups | plain files; nothing to install | plain files; nothing to install | plain files; nothing to install |
|
||||
|
||||
**Why NSIS written by hand, not cargo-packager's.** The installer's rules
|
||||
(per user, one program, an uninstaller that can never reach the books) are
|
||||
@@ -320,30 +320,6 @@ icon);
|
||||
`wanderbooks.cmd`/PATH setup so a terminal waits for a command on Windows (a
|
||||
GUI-subsystem program returns the prompt at once); a macOS refusal for a program
|
||||
run from a mounted disk image (a path under `/Volumes` may be a real install on
|
||||
another disk); bundling git on Windows and macOS (the owner's decision, below); the signed `manifest.json` of the earlier self-update
|
||||
another disk); the signed `manifest.json` of the earlier self-update
|
||||
(needs the release key, Q-4).
|
||||
|
||||
### Bundling git (an owner decision, not made here)
|
||||
|
||||
Backups run the system's git. **Linux:** the packages now depend on git, so the
|
||||
package manager fetches it (nothing is bundled). **Windows and macOS:** the app
|
||||
detects a missing git and says how to get it (WB-pkg-4); nothing is bundled.
|
||||
|
||||
What bundling would mean. Git is GPL-2.0-only free software. Shipping an
|
||||
unmodified git as a separate file that our program starts as its own process
|
||||
(never linked) is what the GPL calls aggregation: our MIT OR Apache-2.0 code is
|
||||
unaffected, and AGENTS.md's clean-room rule (never copy GnuCash's code) is not
|
||||
touched, since nothing of git is copied into ours; `deny.toml` governs Rust
|
||||
crates only and does not see it. It still requires, for each release that
|
||||
carries git: git's GPL text and copyright notices beside it (Git for Windows'
|
||||
MinGit adds the notices of the components it carries: OpenSSL/curl, the MSYS2
|
||||
runtime); the corresponding source of exactly that git, or a written offer for it
|
||||
valid three years (GPLv2 section 3), most simply the git version's source
|
||||
archive attached to the same release; no term of ours that forbids the
|
||||
recipient what the GPL permits; and a note of any change if git were modified.
|
||||
`THIRD-PARTY-NOTICES.txt` (cargo-about) covers Rust crates only, so it would
|
||||
need an addition. On Windows the candidate is MinGit from Git for Windows
|
||||
(about 40 MB, unpacked beside the program; `Git::find` would look there first);
|
||||
on macOS Apple's command line tools' git is Apple's and cannot be bundled, so
|
||||
it would be a build of our own (Homebrew's, or from source), universal, signed
|
||||
inside the app, with the same obligations.
|
||||
@@ -280,3 +280,16 @@ product's own sign-in has been tried against it yet.
|
||||
| A tool call's lines commit together with a closing line or not at all; a call that never closed, or failed, builds nothing in any replay; a failed call is on the record | A database transaction; QBO and Xero make a write all or nothing and say so on failure | partial | WB-format-8, WB-format-10; `ledger-store` `tests/calls.rs` (`a_crash_at_each_point_of_a_call_leaves_the_whole_call_or_none_of_it`, `a_replay_of_any_prefix_inside_a_call_is_the_replay_of_the_prefix_before_it`, `a_failed_call_is_on_the_record_and_builds_nothing`); partial until the Lean law is in bookspec and a `done` needs a golden |
|
||||
| Every write carries a request key; a repeat returns the first answer and writes nothing, across a restart; the same key for another request is refused | An idempotency key (a payments API's `Idempotency-Key`); QBO's `requestid` | partial | WB-format-9; `ledger-cli` `tests/call_transactions.rs` (`a_repeat_of_a_key_returns_the_first_answer_and_writes_nothing`, `the_same_key_for_another_request_is_refused_in_words`, `every_tool_that_can_write_asks_for_a_key_and_no_other_does`); `books.import_bank_csv` is one transaction (`the_import_is_one_transaction`) |
|
||||
| Books that haven't declared the feature take no write and still read; every set of books has a unique id | No counterpart; the owner's rule (D-89) | partial | WB-format-11, WB-format-12; `ledger-store` `tests/calls.rs` (`books_that_have_not_declared_the_feature_take_no_call_and_still_read`, `new_books_are_born_with_an_id_and_no_two_share_one`); `ledger-cli` `tests/format_upgrade.rs` (`books_p2_served_cut_over_whole`) |
|
||||
|
||||
## P15 section 9: backups without git (2026-11-21, D-91, D-92)
|
||||
|
||||
Two new rows below; none above changed status, so the floor stands. A backup is a
|
||||
folder of plain files written once, optionally sealed with a passphrase
|
||||
(WB-backup-1 to WB-backup-11, `docs/backups.md`); the old backup made with git
|
||||
is gone. Both rows are `partial`: nothing of the window's folder chooser and
|
||||
passphrase set-up has run on Windows or macOS, and the window part has no golden.
|
||||
|
||||
| Area | Counterpart (a cross-check, not the spec) | Status | Notes |
|
||||
|---|---|---|---|
|
||||
| A backup is a folder the person picks, made of files written once, complete when its manifest is in place; a restore previews first and restores only the head it previewed; a restore of any whole manifest is a prefix of the books; a destination only grows | QBO's "back up company" is one file on the vendor's servers; Xero's export is a copy; GnuCash keeps one file and a dated backup beside it | partial | WB-backup-1 to WB-backup-6, WB-backup-9, WB-backup-10; `ledger-store` `tests/backup.rs` (`a_backup_is_the_book_and_proves_whole`, `a_program_that_dies_at_any_write_leaves_what_proved_whole_before`, `two_programs_writing_one_destination_do_not_corrupt_it`), `tests/backup_props.rs` (`any_whole_manifest_restores_a_prefix_of_the_books`, `a_destination_only_grows`); `ledger-cli` `tests/backups.rs` |
|
||||
| The backups can be protected with a passphrase, off by default, and a backup can be saved as one file | GnuCash and QBO export files are not sealed; a sealed archive with a passphrase is the usual cross-check | partial | WB-backup-7, WB-backup-8; `ledger-store` `tests/backup.rs` (`a_wrong_passphrase_never_yields_books_and_is_told_from_damage`, `a_single_file_holds_the_same_backup_plain_or_sealed`), `tests/backup_props.rs` (`a_wrong_passphrase_never_yields_books`) |
|
||||
+14
-13
@@ -28,19 +28,20 @@ easily backupable, journable":
|
||||
journals a `journal.tail_repaired` line; `books.digest` reports it.
|
||||
Damage before the last newline is corruption and refuses to open: that
|
||||
is for a human, never repaired automatically. The server does better
|
||||
(plan 3.7): it commits the journal, the blobs, the vault, its key and
|
||||
the access log to each book's own git repository (the blobs staged
|
||||
ahead, the commit under the store's lock) and pushes it to the
|
||||
owner's private repository and backup folder, versioned and
|
||||
deduplicated, with full history (docs/mcp-interface.md, "Tools —
|
||||
backups"). The program stops its git gently (SIGTERM first, so git
|
||||
removes its own lock files, and a kill only after 5 seconds), and never
|
||||
writes to or deletes from a backup folder, which is the owner's (shared,
|
||||
perhaps, with another computer or a sync program): a lock git left
|
||||
there after a kill is reported with its path, never removed. The book's
|
||||
own archive (`archive.git`) is private to the program; there it removes
|
||||
only the locks its own stopped git made, and locks older than ten
|
||||
minutes found when the books open or a backup begins.
|
||||
(plan 3.7, D-91): it backs the journal, the stored files, the vault, its
|
||||
key and the access log up to a folder the owner chooses, as plain files
|
||||
that are written once and never changed or deleted (docs/backups.md, and
|
||||
docs/mcp-interface.md, "Tools — backups"): the journal and the access log
|
||||
as numbered segments, each stored file once under its hash, and a
|
||||
manifest, written last, that says which pieces make a backup whole. The
|
||||
books' lock is held only to take a cut of the journal's length and the
|
||||
vault; the files are written after it. With a passphrase (D-92) every file
|
||||
is sealed. Nothing is installed for it, and nothing in the backup folder
|
||||
is ever deleted or rewritten by the program, which is the owner's (shared,
|
||||
perhaps, with another computer or a sync program). The book's own
|
||||
folder keeps a local backup of the same form (`local-backup/`) made
|
||||
before a format upgrade. The old history older versions kept in the book's
|
||||
folder is left where it is, unread and unwritten.
|
||||
- **Journable.** It literally is a journal: `{seq, ts, type, payload, prev}`.
|
||||
Greppable, diffable, replayable. The audit trail isn't a feature bolted
|
||||
on — it's the storage format.
|
||||
|
||||
@@ -0,0 +1,401 @@
|
||||
# Claims: backups
|
||||
|
||||
Wanderbooks' own product rules for backups: plain folders, written once,
|
||||
optionally sealed with a passphrase (plan P15 section 9, D-91 and D-92,
|
||||
`plan/p15-app-and-relay.md`). No authority outside this product states them.
|
||||
They are `WB-backup-<n>`. They replace the rules for backups made with git
|
||||
(D-30, D-31), which are gone.
|
||||
|
||||
Rules: none from bookspec's list; these are product rules only. What a backup
|
||||
holds (the journal, the stored files, the vault, the keys, the access log;
|
||||
never the database, which a restore rebuilds) and when it runs are unchanged
|
||||
(plan 3.7).
|
||||
|
||||
---
|
||||
|
||||
### Product rules
|
||||
|
||||
**WB-backup-1 A backup is plain files, each written once, so a destination
|
||||
only grows.** A destination is a folder the person picks. It holds one folder
|
||||
per set of books, named with a fixed prefix and the books' id so that it is a
|
||||
legal folder name on every system whatever the id is, with a read-me in plain
|
||||
words, a folder of manifests, and the pieces the manifests name: the journal
|
||||
and the access log as numbered segments, an index of the stored files, the
|
||||
stored files themselves under their hash, and the vault and the keys under
|
||||
their content hash. Every file is put once: written under a scratch name in
|
||||
its own folder, synced, and given its name by a hard link, which is made
|
||||
exactly once or refused (WB-backup-18 says what is done on a disk that makes
|
||||
none). Nothing in a destination is
|
||||
ever deleted or rewritten by the program: the only file it removes there is the
|
||||
scratch file it made a moment before. So a service that syncs the folder never
|
||||
sees a file change under it, and an earlier state of the books is always still
|
||||
there (the journal is the history: an earlier state is a shorter prefix, and
|
||||
each manifest marks one).
|
||||
*Enforced:* `ledger_store::backup::write::write_destination`,
|
||||
`ledger_store::backup::write::Destination`, `crates/ledger-store/src/backup/io.rs`.
|
||||
*Checked:* `ledger-store` `tests/backup.rs`
|
||||
(`a_backup_is_the_book_and_proves_whole`,
|
||||
`a_program_that_dies_at_any_write_leaves_what_proved_whole_before`),
|
||||
`tests/backup_props.rs` (`a_destination_only_grows`).
|
||||
|
||||
**WB-backup-2 A backup is whole when its manifest is in place, and a manifest
|
||||
names only pieces that exist and hash right.** The manifest is written last
|
||||
and atomically. It names the books' id, the head and sequence number it
|
||||
reaches, every segment, and the vault and key files, each by where it is, how
|
||||
long it is and what is in it (SHA-256). A manifest names the manifest before
|
||||
it and only the segments added since, until a chain of 64 is made, when one
|
||||
names everything again (WB-backup-17); read, every manifest names everything,
|
||||
and one that is lost, or replaced by a sync service's conflict copy, makes
|
||||
unreadable only those chained on it, never an earlier one. A reader looks at
|
||||
the manifests newest first and takes the first whose pieces are all there at the
|
||||
length it names and that proves whole (it reads no more than that), and the
|
||||
proof re-hashes every piece: the journal's chain replays to the head the manifest
|
||||
records before the books are opened, the books open, every stored file re-hashes,
|
||||
every TIN record the books name and the key that opens them are there. A
|
||||
manifest that is cut short or changed is no manifest. A run that dies leaves
|
||||
pieces no manifest names, which are harmless.
|
||||
*Enforced:* `ledger_store::backup::read::find`, `ledger_store::backup::read::verify_found`,
|
||||
`ledger_store::backup::read::Set`, `ledger_store::backup::read::prove_books`.
|
||||
*Checked:* `ledger-store` `tests/backup.rs`
|
||||
(`a_flipped_or_cut_piece_is_found_and_never_restored`,
|
||||
`the_text_read_from_a_stored_file_is_a_stored_file_too`), `tests/backup_repair.rs`
|
||||
(`only_the_newest_backup_is_tried_in_the_good_case`).
|
||||
|
||||
**WB-backup-3 A restore of any whole manifest yields books whose journal is
|
||||
byte-identical to a prefix of the source's.** A restore previews first and
|
||||
restores only the head it previewed, as new books or replacing books (which are
|
||||
moved whole into the legacy folder, never deleted). When the newest manifest is
|
||||
damaged the newest whole one is used, and the preview says so before anything
|
||||
else (WB-backup-15). The backup's journal is a byte prefix of the live one (a
|
||||
drill checks it).
|
||||
*Enforced:* `ledger_store::backup::read::verify_found`, `ledger_store::root::Root::restore`,
|
||||
`ledger_store::root::Root::restore_preview`.
|
||||
*Checked:* `ledger-store` `tests/backup_props.rs`
|
||||
(`any_whole_manifest_restores_a_prefix_of_the_books`),
|
||||
`tests/backup.rs` (`a_damaged_newest_backup_falls_back_to_the_one_before_and_says_so`);
|
||||
`ledger-cli` `tests/backups_restore.rs` (`a_restore_is_of_the_backup_previewed_only`,
|
||||
`restore_never_overwrites_and_replacing_keeps_the_old_books`).
|
||||
|
||||
**WB-backup-4 A destination of other books, another history of these, or more
|
||||
than these books have is never written, and the two are told apart.** Before
|
||||
writing, the destination's newest whole manifest must be a point on the live
|
||||
journal: the bytes of the journal it names are the first bytes of the live one.
|
||||
When the destination's journal is the longer, the live journal is checked to be
|
||||
the beginning of it: if it is, the books are behind the folder (as after a
|
||||
restore from an older backup or a backup file) and that is said, in words that
|
||||
say what to do; if it is not, the books are other books or have diverged, and
|
||||
that is said. Either way nothing is written. A person who wants to carry on
|
||||
with the books they have can start a new set of backups beside the old one, in
|
||||
the same folder, at their explicit request; the old set is never touched, and
|
||||
later backups go to the new one. A folder that took these books' backups and
|
||||
holds none now is a disk not connected, never made again where the disk should
|
||||
be unless the person says it is a new disk.
|
||||
*Enforced:* `ledger_store::backup::write::write_destination_with`,
|
||||
`ledger_store::backup::write::Options`, `ledger_store::backup::BackupError`,
|
||||
`ledger_mcp::backup::Backups`.
|
||||
*Checked:* `ledger-store` `tests/backup.rs`
|
||||
(`a_destination_of_other_books_or_another_history_is_never_written`,
|
||||
`a_disk_that_is_gone_is_never_made_again_where_it_should_be`),
|
||||
`tests/backup_repair.rs` (`books_behind_the_destination_are_ahead_and_other_books_are_diverged`,
|
||||
`a_new_set_begins_beside_the_old_at_the_persons_request_and_the_old_is_never_touched`);
|
||||
`ledger-cli` `tests/backups.rs` (`a_backup_of_another_history_is_never_written_over`),
|
||||
`tests/backups_restore.rs` (`restored_books_never_make_their_backup_folder_again`),
|
||||
`tests/backups_trouble.rs`
|
||||
(`books_restored_from_an_older_backup_are_ahead_and_a_new_set_begins_at_their_request`).
|
||||
|
||||
**WB-backup-5 Two programs, or two computers, writing one destination cannot
|
||||
corrupt it, and a program that dies at any write leaves what proved whole
|
||||
before.** Pieces are named by what is in them, so two writers of one piece write
|
||||
the same bytes; the only decision is which writer takes the next manifest
|
||||
number, and the disk decides it (exclusive create). The loser looks again and
|
||||
goes on from what the winner wrote, or finds nothing left to write. A program
|
||||
that dies at any write point (a scratch file, a piece, the manifest) leaves a
|
||||
destination whose newest whole manifest is the one before, or the new one, and
|
||||
a restore from it is a prefix of the books. No lock a sync service ignores is
|
||||
relied on.
|
||||
*Enforced:* `ledger_store::backup::write::write_destination`,
|
||||
`crates/ledger-store/src/backup/write.rs`.
|
||||
*Checked:* `ledger-store` `tests/backup.rs`
|
||||
(`two_programs_writing_one_destination_do_not_corrupt_it`,
|
||||
`a_loser_of_a_manifest_number_goes_on_from_the_winner`,
|
||||
`a_program_that_dies_at_any_write_leaves_what_proved_whole_before`),
|
||||
`tests/backup_props.rs` (`random_interleavings_of_two_writers_leave_a_whole_backup`).
|
||||
|
||||
**WB-backup-6 A flipped or cut piece is found and never restored.** Every piece
|
||||
is checked against what its manifest says, in length and in hash, and a sealed
|
||||
piece against its seal; a piece that fails ends the proof of that manifest, and
|
||||
nothing is put in the books' place from it. A piece is accepted under any
|
||||
generation of it (WB-backup-13) if its contents hash right.
|
||||
*Enforced:* `ledger_store::backup::read::verify_found`.
|
||||
*Checked:* `ledger-store` `tests/backup_props.rs`
|
||||
(`any_flipped_or_cut_piece_is_found_never_restored`), `tests/backup.rs`
|
||||
(`a_flipped_or_cut_piece_is_found_and_never_restored`); `ledger-cli`
|
||||
`tests/backups_restore.rs` (`restore_refuses_a_damaged_backup_and_writes_nothing`),
|
||||
`tests/backups.rs` (`restore_drill_failure_is_flagged`).
|
||||
|
||||
**WB-backup-7 A passphrase seals every piece, and a wrong passphrase never
|
||||
yields books.** The passphrase is offered at set-up and is off by default
|
||||
(D-92). With one, every piece and every manifest is sealed with
|
||||
XChaCha20-Poly1305 in chunks of 1 MiB, each bound to what is in it and to
|
||||
whether it is the last. The key is derived from the passphrase with Argon2id at
|
||||
the owner passphrase's own cost (64 MiB, 3 passes, 1 lane) and a salt of its
|
||||
own, which the set's header records, so another computer derives the same key.
|
||||
File names are made from the key and say no more than counts and sizes. The
|
||||
header carries a sealed check bound to the key settings, so a wrong passphrase
|
||||
is told from a damaged header; a setting the header asks for beyond four times
|
||||
this program's own (memory, passes, lanes) is refused as damage before any key is
|
||||
derived, a header that was changed by accident breaks its own check line and
|
||||
reads as damage, and one changed on purpose can only make the key come out
|
||||
different, which opens nothing. A folder of sealed sets costs one key derivation
|
||||
for each distinct setting, not one for each set. Pieces are kept in folders of
|
||||
the first two digits of their names, so no folder outgrows a small disk's file
|
||||
system. The derived key is kept on this computer only, in the book's own
|
||||
folder, readable by the person's account alone; never in a backup, never in the
|
||||
journal, never in a record or an error. Changing the passphrase starts a new set
|
||||
beside the old one and removing it makes the next backup plain: pieces already
|
||||
written are never rewritten, so the old ones stay as they were, sealed with the
|
||||
passphrase they were made with. A forgotten passphrase cannot be recovered, and
|
||||
the set-up says so.
|
||||
*Enforced:* `ledger_store::backup::seal::BackupKey`,
|
||||
`crates/ledger-store/src/backup/seal.rs`.
|
||||
*Checked:* `ledger-store` `tests/backup.rs`
|
||||
(`a_sealed_backup_gives_away_counts_and_sizes_only`,
|
||||
`a_wrong_passphrase_never_yields_books_and_is_told_from_damage`,
|
||||
`a_changed_passphrase_is_a_new_set_beside_the_old_which_is_untouched`,
|
||||
`the_key_is_kept_privately_and_only_there`), `tests/backup_props.rs`
|
||||
(`a_wrong_passphrase_never_yields_books`), `tests/backup_disk.rs`
|
||||
(`a_header_cannot_ask_for_more_than_a_few_times_what_this_program_spends`,
|
||||
`a_header_that_was_changed_reads_as_damage_and_not_as_a_wrong_passphrase`,
|
||||
`a_folder_of_sealed_sets_costs_one_key_derivation_per_setting_not_one_per_set`,
|
||||
`sealed_pieces_are_spread_over_folders_as_the_plain_form_does`).
|
||||
|
||||
**WB-backup-8 "Save a backup..." is the same backup as one file.** The file is a
|
||||
zip of the set's folder form holding one manifest and only the pieces it names,
|
||||
sealed when the backups are, with the extension .wbbackup. A file by the name
|
||||
asked for is never written over, and is moved into place only when it has been
|
||||
read back as a restore reads it and proven whole. Restore reads a destination
|
||||
folder, a set's own folder, or this file.
|
||||
*Enforced:* `ledger_store::backup::single::save_file`, `ledger_store::backup::single::FILE_EXTENSION`.
|
||||
*Checked:* `ledger-store` `tests/backup.rs`
|
||||
(`a_single_file_holds_the_same_backup_plain_or_sealed`).
|
||||
|
||||
**WB-backup-9 A stopped backup leaves a destination that proves whole at its
|
||||
previous manifest, and a close is bounded.** A backup a close stops (the
|
||||
books' close, or a call or timer's backup when a close begins) looks for the
|
||||
stop between pieces and once per chunk of a file read, including in the proof
|
||||
after the backup, so it ends promptly; the server records `stopped` and no
|
||||
result of the run's own, and the close's own last backup is stopped only at its
|
||||
bound. A manifest written before the stop is not marked proven: the next
|
||||
backup proves it, even one with nothing new to write (WB-backup-12). The proof's
|
||||
scratch books are removed whatever ends it.
|
||||
*Enforced:* `ledger_store::backup::Ctx`, `ledger_mcp::backup::Backups`.
|
||||
*Checked:* `ledger-store` `tests/backup.rs`
|
||||
(`a_stopped_backup_leaves_what_proved_whole_before`), `tests/backup_repair.rs`
|
||||
(`a_proof_cut_short_by_a_close_ends_cleanly_and_is_made_again_by_the_next_backup`);
|
||||
`ledger-cli` `tests/book_open_close.rs`
|
||||
(`a_close_is_not_answered_while_its_backup_still_runs`,
|
||||
`a_close_stops_a_running_backup_call_and_says_so`).
|
||||
|
||||
**WB-backup-10 Older forms are left alone and said.** Books that still carry
|
||||
the old setting naming a private repository open and work; the backup status
|
||||
says in plain words that it is no longer used and to choose a folder. An older
|
||||
backup history in a book's own folder, and an older backup folder made with git
|
||||
beside a destination, are neither read, written, moved nor deleted; the new form
|
||||
goes beside them, and the status says once, until a backup has been made in the
|
||||
new form, that the older one is no longer written. A person who has an older
|
||||
backup clones it themselves and adopts the plain folder (docs/backups.md).
|
||||
*Enforced:* `ledger_mcp::backup::Backups`.
|
||||
*Checked:* `ledger-cli` `tests/backups.rs`
|
||||
(`old_settings_and_an_old_backup_history_are_left_alone_and_said`,
|
||||
`a_clone_of_an_old_git_backup_is_adopted_as_a_plain_folder`: it builds a clone's
|
||||
working tree itself, so it runs, and says nothing is skipped, with no git on the
|
||||
machine).
|
||||
|
||||
**WB-backup-11 A format upgrade needs a proven local backup, made under the
|
||||
store's lock.** The local backup is the same form in the book's own folder
|
||||
(`local-backup`), written and proven to hold the books exactly as they are
|
||||
(journal, vault and keys byte for byte, every stored file re-hashed) before
|
||||
the journal's format moves, all under the store's lock.
|
||||
*Enforced:* `ledger_store::backup::write::write_local`, `ledger_store::backup::read::prove_local`,
|
||||
`ledger_mcp::backup::Backups`.
|
||||
*Checked:* `ledger-mcp` `local.rs` (`format_upgrade_waits_for_consent`,
|
||||
`no_upgrade_unless_the_backup_is_proven`, `no_upgrade_without_a_backup`).
|
||||
|
||||
**WB-backup-12 "Recorded good" means the backup was read back and proven, and
|
||||
this is exactly what that proves.** After a manifest is put and before the
|
||||
backup is recorded good, the manifest is read back from the destination as a
|
||||
restore would read it, and proven: every journal and access segment it names is
|
||||
re-hashed and the hash chain replays to the head it records, the books built
|
||||
from them open, the vault and the keys and their presence are checked (every TIN
|
||||
record the books name, and the key that opens them), the index of stored files
|
||||
is read, every stored file the books name is in it, and of the stored files
|
||||
itself those this backup added and one sixteenth of the others are re-hashed.
|
||||
The sixteenth is the files whose hash begins with a digit group equal to the
|
||||
manifest number modulo 16, so any 16 manifest numbers in a row between them re-read
|
||||
every stored file once: **every stored file is re-read within 16 backups** (the
|
||||
weekly drill re-reads all of them), and the cost of a backup's proof is the
|
||||
journal and access log, which the books need anyway, plus a sixteenth of the
|
||||
stored files. A backup that is not proven is not recorded good. The proof is
|
||||
marked, per manifest, by a tiny file written once, so a manifest whose proof
|
||||
was cut short is proven by the next backup. What "recorded good" does not prove:
|
||||
that a stored file that is not in the share of the 16 is still whole today (the
|
||||
rotation and the drill will say, and a damaged one is written again, WB-backup-13);
|
||||
that the destination is still whole after the backup (the next backup and the
|
||||
weekly drill say). A backup file saved on request is proven whole in full before
|
||||
it is named.
|
||||
*Enforced:* `ledger_store::backup::read::prove_written`,
|
||||
`ledger_store::backup::read::in_rotation`, `ledger_store::backup::read::ROTATION`,
|
||||
`ledger_store::backup::write::prove_and_repair`, `ledger_store::backup::form::proof_path`,
|
||||
`ledger_store::backup::single::save_file`, `ledger_mcp::backup::Backups`.
|
||||
*Checked:* `ledger-store` `src/backup/tests.rs`
|
||||
(`a_piece_belongs_to_one_share_and_every_share_is_read_within_sixteen_backups`),
|
||||
`tests/backup_repair.rs`
|
||||
(`one_damaged_segment_is_found_by_the_next_backup_and_the_drill_does_not_hide_it`,
|
||||
`a_damaged_stored_file_is_found_by_the_rotation_and_the_next_backup_repairs_it`,
|
||||
`a_proof_cut_short_by_a_close_ends_cleanly_and_is_made_again_by_the_next_backup`).
|
||||
|
||||
**WB-backup-13 A damaged piece is written again beside the damaged file, and a
|
||||
damaged destination can be repaired.** A piece already in the destination under
|
||||
its name is taken as the piece when it is put (its name is its hash), so a
|
||||
damaged one would be taken again by every later backup; the proof after a
|
||||
backup finds it, and the backup writes the piece again from the books under the
|
||||
next generation of its name (a name ending .g1, then .g2), a new manifest names
|
||||
the good one, and the proof is made again. Nothing is rewritten or deleted: the
|
||||
damaged file is left where it is, and is listed in the status and in the window
|
||||
as written again, for the person to delete if they wish. A stored file is found
|
||||
by its hash and generation, a segment, vault record or key by the manifest that
|
||||
names it, and an index segment that cannot be read is begun again from the
|
||||
stored files the books have. A damaged piece that can't be written again from the
|
||||
books (the books' own file is the damaged one) is an error said in words, and
|
||||
the backup is not recorded good.
|
||||
*Enforced:* `ledger_store::backup::write::fresh_path`,
|
||||
`ledger_store::backup::write::prove_and_repair`, `ledger_store::backup::form::generation_path`,
|
||||
`ledger_store::backup::read::Set`, `ledger_mcp::backup::TargetStatus`.
|
||||
*Checked:* `ledger-store` `tests/backup_repair.rs`
|
||||
(`one_damaged_segment_is_found_by_the_next_backup_and_the_drill_does_not_hide_it`,
|
||||
`a_damaged_stored_file_is_found_by_the_rotation_and_the_next_backup_repairs_it`,
|
||||
`a_piece_damaged_as_it_is_written_is_repaired_in_the_same_backup`,
|
||||
`a_damaged_vault_record_and_an_index_segment_are_written_again_too`), `src/backup/tests.rs`
|
||||
(`generations_and_set_names_round_trip`).
|
||||
|
||||
**WB-backup-14 A drill passes only on the newest manifest.** The weekly drill
|
||||
builds the newest backup's books and proves them whole, re-hashing every stored
|
||||
file, and passes only if that manifest proves whole and reaches the head of the
|
||||
last backup recorded good, and its journal is the beginning of the live one.
|
||||
An older manifest that proves whole while the newest does not is a failure,
|
||||
never ok: the status and the window say "the newest backup (number N, from
|
||||
DATE) is damaged; an older one from DATE is whole", and a restore from the
|
||||
folder would give that older one. A newest manifest that stops short of the last
|
||||
backup recorded good is a failure too: a backup that was made is not there.
|
||||
*Enforced:* `ledger_store::backup::read::drill`, `ledger_store::backup::BackupError`,
|
||||
`ledger_mcp::backup::Backups`.
|
||||
*Checked:* `ledger-store` `tests/backup_repair.rs`
|
||||
(`a_drill_never_passes_on_an_older_backup`,
|
||||
`a_drill_needs_the_newest_backup_to_reach_the_last_one_recorded_good`);
|
||||
`ledger-cli` `tests/backups_trouble.rs`
|
||||
(`a_drill_that_finds_only_an_older_backup_is_a_failure_in_words_and_never_ok`).
|
||||
|
||||
**WB-backup-15 A restore that is not of the newest backup says so before the
|
||||
person confirms.** When the newest backup in the folder does not prove whole and
|
||||
a restore would use an older one, the preview says so first, before anything
|
||||
else, in the warning colour in the window: this is not the newest backup, how
|
||||
many newer backups it passes over, when this one was made and when the newest
|
||||
was, and that anything written after is not in it.
|
||||
*Enforced:* `ledger_host::commands::older_backup_words`,
|
||||
`ledger_store::root::RestorePreview`, `ledger_store::backup::read::Verified`.
|
||||
*Checked:* `ledger-store` `tests/backup_repair.rs` (`a_drill_never_passes_on_an_older_backup`);
|
||||
`ledger-cli` `tests/backups_trouble.rs`
|
||||
(`a_drill_that_finds_only_an_older_backup_is_a_failure_in_words_and_never_ok`).
|
||||
|
||||
**WB-backup-16 A key lost from a sealed destination never makes backups
|
||||
plain.** That a destination is sealed is kept where it survives losing the key
|
||||
file: in the backup record (what was last chosen about the passphrase, and the
|
||||
key's fingerprint, which opens nothing) and, where the record has nothing, in
|
||||
the folder itself (it holds sealed sets and none that is plain). A sealed
|
||||
destination with no key available stops backing up, writes nothing, and says in
|
||||
words to enter the passphrase or remove it; plain backups are written only after
|
||||
the person removes the passphrase, which the record keeps.
|
||||
*Enforced:* `ledger_mcp::backup::Backups`, `ledger_store::backup::write::holds_only_sealed`,
|
||||
`ledger_store::backup::BackupError`.
|
||||
*Checked:* `ledger-cli` `tests/backups_trouble.rs`
|
||||
(`a_lost_key_file_never_makes_backups_plain`).
|
||||
|
||||
**WB-backup-17 A manifest names the one before it, and its growth is bounded
|
||||
without trusting an unproven chain.** No series is ever written again as one
|
||||
(a series of many small segments is acceptable). A manifest names its base by
|
||||
number and by what its body hashes to, and the segments added since; a chain is
|
||||
at most 64 long, then one names everything. A reader proves a chain link by link:
|
||||
each base must hash to what its successor names and be one link shorter, so a
|
||||
changed, swapped, missing or looping base makes the manifest unreadable and the
|
||||
reader takes the newest that reads; no manifest is believed on a chain it has not
|
||||
read. For a destination of 3000 backups the manifests were 12.1 MB in all
|
||||
(naming everything each time would be about 765 MB), the largest 413 KB (one in
|
||||
64 names everything) and the newest 0.8 KB, and the newest was found and read
|
||||
whole in 32 ms (an unoptimised build; the proof's own time is the journal's).
|
||||
*Enforced:* `ledger_store::backup::write::kept_form`, `ledger_store::backup::form::DELTA_CHAIN`,
|
||||
`ledger_store::backup::form::BaseRef`, `ledger_store::backup::read::Set`.
|
||||
*Checked:* `ledger-store` `src/backup/tests.rs`
|
||||
(`the_writers_manifests_chain_to_a_bounded_depth_and_are_proven_link_by_link`,
|
||||
`a_destination_of_thousands_of_backups_stays_small_and_quick_to_read`).
|
||||
|
||||
**WB-backup-18 A disk that makes no hard links takes backups too, and a failed
|
||||
link is never a reason to replace.** Only an error that means the disk makes no
|
||||
links (on Unix EPERM, ENOSYS, EOPNOTSUPP, ENOTSUP; on Windows
|
||||
ERROR_INVALID_FUNCTION, ERROR_NOT_SUPPORTED, ERROR_INVALID_PARAMETER,
|
||||
ERROR_CALL_NOT_IMPLEMENTED) sends a put down the path for such a disk; any other
|
||||
error is an error. There the finished scratch file is moved into place by a move
|
||||
that refuses to replace (renameat2 with RENAME_NOREPLACE on Linux, renamex_np
|
||||
with RENAME_EXCL on macOS, MoveFileExW without the replace flag on Windows); on a
|
||||
file system that cannot say no, the last resort is exclusive create under the
|
||||
real name and a copy, which leaves a short file under the name if the program
|
||||
dies in the middle: the next proof finds it and the piece is written again
|
||||
(WB-backup-13); a short manifest is accepted by no reader.
|
||||
*Enforced:* `crates/ledger-store/src/backup/io.rs`,
|
||||
`ledger_store::backup::Ctx`.
|
||||
*Checked:* `ledger-store` `tests/backup_disk.rs`
|
||||
(`a_disk_that_makes_no_links_takes_whole_backups_and_only_grows`,
|
||||
`two_writers_racing_on_a_disk_that_makes_no_links_do_not_corrupt_it`,
|
||||
`a_taken_number_or_name_is_never_replaced_on_a_disk_that_makes_no_links`),
|
||||
`src/backup/tests.rs` (`only_an_error_that_means_no_links_is_taken_to_mean_it`).
|
||||
|
||||
**WB-backup-19 A folder a sync service keeps is said in plain words, and a file
|
||||
it has not downloaded is never read as damage or absence.** When the backup
|
||||
folder is inside a known sync service's folder (told by the names in its path:
|
||||
Dropbox, OneDrive, iCloud Drive, Google Drive, Nextcloud, pCloud, Box), and
|
||||
otherwise in general words, the set-up and the window say: use this folder from
|
||||
one computer only, keep it available offline, a second computer needs a folder
|
||||
of its own. A file that is not on this computer yet reads as "not downloaded
|
||||
yet", the backup waits, and nothing is written over it: on macOS before 14 by
|
||||
the stand-in name (.name.icloud), on macOS by the dataless file flag, on Windows
|
||||
by the offline and recall file attributes (read there it would make Windows fetch
|
||||
it, which may take long or fail, so it is not read). Where nothing can tell
|
||||
(Linux, whatever client), a file reads as the file it is, and a missing or short
|
||||
one is found by the proof.
|
||||
*Enforced:* `ledger_mcp::backup::sync_service`, `ledger_mcp::backup::sync_words`,
|
||||
`ledger_store::backup::BackupError`, `crates/ledger-store/src/backup/io.rs`.
|
||||
*Checked:* `ledger-store` `tests/backup_disk.rs`
|
||||
(`a_file_that_is_not_downloaded_yet_reads_as_such_and_never_as_damage_or_absence`),
|
||||
`src/backup/tests.rs`
|
||||
(`what_a_sync_service_leaves_for_a_file_it_has_not_downloaded_is_known`);
|
||||
`ledger-cli` `tests/backups_trouble.rs`
|
||||
(`a_folder_a_sync_service_keeps_is_said_in_plain_words_at_set_up`).
|
||||
|
||||
**WB-backup-20 The vault's scratch files are never backed up as records.** A
|
||||
vault write that is between its steps leaves a record staged under a name ending
|
||||
.staged- and a tag, or an old one set aside under .purging- and a tag. A backup
|
||||
cut then holds the vault as the journal says it is: a staged record is not the
|
||||
books' yet and is left out; a record set aside for a purge that has not
|
||||
committed is still the books' and is backed up under the name it has when it is
|
||||
not set aside.
|
||||
*Enforced:* `crates/ledger-store/src/backup/cut.rs`.
|
||||
*Checked:* `ledger-store` `tests/backup_repair.rs`
|
||||
(`a_backup_cut_while_the_vault_is_being_written_restores_a_vault_that_matches_the_journal`).
|
||||
|
||||
**WB-backup-21 A set's folder is a legal name on every system.** The folder is
|
||||
named with a fixed prefix and the books' id (con, nul, aux, prn, com1 to com9 and
|
||||
lpt1 to lpt9 are not names on Windows, but the prefixed names are), and a later
|
||||
set of the same books ends in a dot and a number, which no id holds.
|
||||
*Enforced:* `ledger_store::backup::form::plain_set_name`,
|
||||
`ledger_store::backup::write::set_name_for`.
|
||||
*Checked:* `ledger-store` `tests/backup_repair.rs`
|
||||
(`a_set_folder_is_a_legal_name_whatever_the_books_are_called`).
|
||||
@@ -185,8 +185,8 @@ consent; `tests/p2_compat.rs`). Only the owner's go-ahead moves them, with the
|
||||
owner passphrase (the server checks it, Argon2id): in the app, which asks at
|
||||
every open until it is given, or with `wanderbooks books upgrade ID` at a
|
||||
terminal, whose commands that open the books also ask; never an agent, and no
|
||||
tool. Before the upgrade the server commits the books to their own backup
|
||||
repository and proves the copy holds them exactly as they are (journal, stored
|
||||
tool. Before the upgrade the server writes the books to a local backup in their own
|
||||
folder (WB-backup-11) and proves it holds them exactly as they are (journal, stored
|
||||
files, vault and keys, byte for byte), all under the books' lock; a backup
|
||||
that can't be made or proven upgrades nothing. The upgrade is then one
|
||||
`journal.format_set` declaring the whole format, so a book's format moves
|
||||
@@ -195,8 +195,8 @@ copy is new books of this version and moves to its format as it is made (the
|
||||
original keeps its own). The upgrade never weakens the gate: books declaring a
|
||||
feature this version doesn't know are newer, as above.
|
||||
|
||||
*Enforced:* `ledger_store::format` (`current`, `JournalFormat::upgrade`), `Store::create`, `Store::upgrade_format`, `Root::adopt`, `ledger_store::backup::prove_archive`, ledger-mcp `Backups::upgrade_format` and `local.rs` (the passphrase), ledger-host `host.rs` (the lease intent, handed to the server) and `commands.rs` (`books upgrade`, asking at open), ledger-gui `owner.rs` (the notice and the dialog).
|
||||
*Checked:* `ledger-store` `tests/format_upgrade.rs` (new books in this version's format, a change waiting for the upgrade, every old-books fixture upgrading to its figures, a newer feature still refused), the unit tests in `format.rs` and `backup.rs` (`the_archive_proves_to_hold_the_book_as_it_is_keys_and_all`), `tests/root.rs` (adoption); `ledger-mcp` `local.rs` (`format_upgrade_waits_for_consent`, `no_upgrade_without_a_backup`, `no_upgrade_unless_the_backup_just_made_is_proven`); `ledger-host` `lease.rs` (`a_consent_never_shows_its_passphrase`); `ledger-cli` `tests/format_upgrade.rs` (from end to end); `ledger-gui` `tests/format_upgrade.rs`.
|
||||
*Enforced:* `ledger_store::format` (`current`, `JournalFormat::upgrade`), `Store::create`, `Store::upgrade_format`, `Root::adopt`, `ledger_store::backup::read::prove_local`, ledger-mcp `Backups::upgrade_format` and `local.rs` (the passphrase), ledger-host `host.rs` (the lease intent, handed to the server) and `commands.rs` (`books upgrade`, asking at open), ledger-gui `owner.rs` (the notice and the dialog).
|
||||
*Checked:* `ledger-store` `tests/format_upgrade.rs` (new books in this version's format, a change waiting for the upgrade, every old-books fixture upgrading to its figures, a newer feature still refused), the unit tests in `format.rs`, `tests/root.rs` (adoption); `ledger-mcp` `local.rs` (`format_upgrade_waits_for_consent`, `no_upgrade_without_a_backup`, `no_upgrade_unless_the_backup_is_proven`); `ledger-host` `lease.rs` (`a_consent_never_shows_its_passphrase`); `ledger-cli` `tests/format_upgrade.rs` (from end to end); `ledger-gui` `tests/format_upgrade.rs`.
|
||||
|
||||
**WB-format-4 Each projection schema in a file of its own.** (The lead's
|
||||
decision, 2026-10-21, for 3.9's "before consent, the way back is always
|
||||
|
||||
@@ -88,21 +88,14 @@ earlier staged update still works; no release key exists yet, so today none does
|
||||
`update.rs` (`a_macos_app_is_never_updated_in_place`); `ledger-gui`
|
||||
`tests/update_notice.rs` (`a_newer_version_is_told_with_where_to_get_it`).
|
||||
|
||||
**WB-pkg-4 Without git, backups are off and the person is told how to get
|
||||
it.** Backups run the system's git; the program carries none. With no git found, a
|
||||
backup says so in plain words for the system it runs on (Git for Windows or winget; Apple's
|
||||
command line tools or Homebrew; the package manager) and the books work as
|
||||
ever; the next backup looks again, so installing git needs no restart. On a Mac
|
||||
without the developer tools, the stub at the system's git path is not taken for a
|
||||
git. Whether to ship a git with the app is the owner's decision, since git is
|
||||
GPL-2.0-only free software and shipping it carries a source offer and notices.
|
||||
*Enforced:* `ledger_store::backup::how_to_get_git`,
|
||||
`ledger_store::backup::Git::find`.
|
||||
*Checked:* `ledger-store` unit tests in `backup.rs`
|
||||
(`a_missing_git_says_how_to_get_it`,
|
||||
`the_mac_stub_is_not_a_git_until_the_developer_tools_are_there`);
|
||||
`ledger-cli` `tests/packaging.rs`
|
||||
(`the_linux_packages_depend_on_git_and_none_carries_one`).
|
||||
**WB-pkg-4 Backups need nothing installed.** A backup is a folder of plain files
|
||||
the program writes itself (WB-backup-1), so no package depends on another program
|
||||
for it, none carries one, and no backup asks the person to install anything. This
|
||||
replaces the rule that backups ran the system's git and said how to get it (D-91).
|
||||
*Enforced:* `deploy/packaging/packager.toml`, `deploy/packaging/aur/PKGBUILD` and
|
||||
`crates/ledger-cli/Cargo.toml` name no such dependency.
|
||||
*Checked:* `ledger-cli` `tests/packaging.rs`
|
||||
(`no_package_depends_on_another_program_for_backups`).
|
||||
|
||||
**WB-pkg-5 The Connect page can write a one-click Claude desktop extension
|
||||
for a company.** The "Claude desktop app" row has one button. It makes the
|
||||
|
||||
+82
-42
@@ -561,25 +561,19 @@ suites (`exports.rs`, `read_only.rs`, `show.rs`, `kept.rs`, `live.rs` and
|
||||
the rest), `ledger-package/tests/package.rs`, `ledger-store` `saving.rs`
|
||||
and `ops.rs`.
|
||||
|
||||
**Slice 7, backups and restore.** `ledger_store::backup`, `Root::restore`,
|
||||
`ledger-mcp` `backup.rs` and `tools/backup.rs`, the loop in `local.rs`:
|
||||
`ledger-cli/tests/backups.rs` (17: both targets after a write, the quiet
|
||||
before a backup, close and catching up at the next open, admin only and
|
||||
the head unmoved, a target that moved on, a failing target waiting while
|
||||
the others carry on, a damaged record, restore beside and on a clean
|
||||
install, of the previewed backup only, with its vault and key, refusing
|
||||
damage, never overwriting, a failed replace, a restored copy leaving its
|
||||
original's repository alone, a backup folder never made again, drills on
|
||||
open and a failed drill flagged), `open_while_held.rs` (`books restore`
|
||||
and its default id), `backup.rs`'s unit tests (20, among them links and
|
||||
strangers refused before checkout, target and archive hooks never run, the
|
||||
owner's hostile git configuration never spoiling a backup, repositories
|
||||
with settings of their own or something beside them refused, fake gits
|
||||
for the time limit and the process group), `tests/root.rs` (never moving
|
||||
books something holds). Five review rounds (about 25, 15, 10, 7 and 3
|
||||
findings, all fixed) and a sixth that only attacked the repository guard
|
||||
(one low finding, fixed). The backup suite passed every run three at a
|
||||
time.
|
||||
**Slice 7, backups and restore.** (Rewritten for the plain-folder form,
|
||||
D-91: see "Backups in plain folders" below; the git form's tests are gone and
|
||||
the table there says what holds each promise now.) `ledger_store::backup`,
|
||||
`Root::restore`, `ledger-mcp` `backup.rs` and `tools/backup.rs`, the loop in
|
||||
`local.rs`: `ledger-cli/tests/backups.rs` (18: the folder after a write, the
|
||||
quiet before a backup, close and catching up at the next open, admin only and
|
||||
the head unmoved, another history never written over, restore beside and on a
|
||||
clean install, of the previewed backup only, with its vault and key, refusing
|
||||
damage, never overwriting, a failed replace, a backup folder never made again,
|
||||
drills on open and a failed drill flagged, old settings and an old history left
|
||||
alone and said, a clone of an old backup adopted), `open_while_held.rs`
|
||||
(`books restore` and its default id), `tests/root.rs` (never moving books
|
||||
something holds).
|
||||
|
||||
**Slice 8, the viewer's menu, setup, no confinement (D-32).**
|
||||
`ledger-gui/tests/owner_menu.rs` (each item through a fake owner, the
|
||||
@@ -1557,23 +1551,20 @@ version's journal format (BS-format-1). Mutation testing waits for P12
|
||||
books' file named for its schema. Checked by breaking it (the legacy
|
||||
file always taken, the schema check dropped): three tests fail. The
|
||||
store's other tests use `db_file()`, this version's file.
|
||||
- `ledger-store` `backup.rs`: `the_archive_proves_to_hold_the_book_as_it_is_keys_and_all`
|
||||
(a changed or extra key, a changed vault record, books that moved on, a
|
||||
journal changed under the recorded head: each refused; the scratch
|
||||
folder always removed).
|
||||
- `ledger-store` `tests/backup.rs`: `the_local_backup_proves_to_hold_the_book_as_it_is_keys_and_all`
|
||||
(a changed or extra key, a changed vault record, books that moved on:
|
||||
each refused; the scratch folder always removed).
|
||||
- `ledger-mcp` `local.rs`: `format_upgrade_waits_for_consent` (listed as
|
||||
waiting; no passphrase set, a wrong one or none refused before anything
|
||||
is done, no backup, no line, still served; with it, the backup is the
|
||||
archive's latest commit, holding the journal as it was and the key; one
|
||||
local backup's latest, holding the journal as it was and the key; one
|
||||
line, the whole format; on the backup record; again, nothing; new books
|
||||
wait for nothing, and asking for their upgrade makes not even a backup
|
||||
repository), `no_upgrade_without_a_backup` (a backup refused: nothing
|
||||
wait for nothing, and asking for their upgrade makes not even a local
|
||||
backup), `no_upgrade_without_a_backup` (a backup refused: nothing
|
||||
upgraded, still waiting, recorded) and
|
||||
`no_upgrade_unless_the_backup_just_made_is_proven` (an archive whose
|
||||
head names another branch takes the commit where no clone finds it:
|
||||
what is proven isn't what was made, nothing upgraded, both recorded;
|
||||
put right, the latest commit, which already holds the books, is proven
|
||||
and the upgrade made). Each checked by breaking the code it guards (the
|
||||
`no_upgrade_unless_the_backup_is_proven` (a local backup with a piece
|
||||
damaged proves nothing whole: nothing upgraded, recorded; put right, the
|
||||
backup, which already holds the books, is proven and the upgrade made). Each checked by breaking the code it guards (the
|
||||
proof skipped, the made-is-proven check dropped, the early return for
|
||||
books that wait for nothing removed): the test fails, then passes once
|
||||
restored.
|
||||
@@ -1610,8 +1601,7 @@ version's journal format (BS-format-1). Mutation testing waits for P12
|
||||
**For P12:** `ledger-store` `format.rs` (`current`, `upgrade_to`, `adds`,
|
||||
`require_format`, `require_feature`), `store.rs` (`create_in_format`,
|
||||
`ensure_format`, `ensure_feature`, `upgrade_format`), `root.rs`
|
||||
(adoption's upgrade and its verify), `backup.rs` (`prove_archive`,
|
||||
`held_files`); `ledger-mcp` `backup.rs` (`upgrade_format`,
|
||||
(adoption's upgrade and its verify), `backup/read.rs` (`prove_local`); `ledger-mcp` `backup.rs` (`upgrade_format`,
|
||||
`UpgradeFailed::parts`), `local.rs` (`upgrade_format`, the List's
|
||||
`format_upgrade`, `waiting`), `server.rs` (`with_store_mut`),
|
||||
`tools/kept.rs` (the first next step, `format_upgrade`), `admin.rs`;
|
||||
@@ -2321,7 +2311,7 @@ data root of its own, reached as an agent reaches it.
|
||||
each start, as a new server process read the same books, and lets a
|
||||
test write books into the root before the first), the async rmcp
|
||||
`connect` and `call`, and `book_files` (the books' files but what every
|
||||
call writes by design: the access log, `ops/`, `archive.git/`,
|
||||
call writes by design: the access log, `ops/`, `local-backup/`,
|
||||
`exports/`, `uploads/`, SQLite's -wal and -shm). Settings a test gives
|
||||
as a settings file's text are set as an agent sets them: the changes
|
||||
`ledger_config::codec::import` reads from it, by `books.set_setting`.
|
||||
@@ -4328,13 +4318,13 @@ one book never refuses or holds up a call on another.
|
||||
| `book_open_close::the_servers_own_close_cuts_stalled_requests_and_exits_zero_in_time` | one upload stalled on one book and one MCP body stalled on another, the server's stdin closed: exit code 0 within the bound, both cut after the grace, no part file, nothing journaled, two `cut_by_close` records, every log whole |
|
||||
| `book_open_close::a_backup_and_a_sweep_that_took_their_handles_before_a_close_do_nothing_after_it`, `…a_drill_and_a_sweep…` | `--timer-hold` holds a timer between taking a book's handles and acting; the book is closed meanwhile, stray files planted, the timers go on: the closed book's tree doesn't move; opened again the sweep works (fail with the handles' closed state, the gate's check and the backups' shut flag removed) |
|
||||
| `book_open_close::a_close_stops_a_slow_drill_instead_of_waiting_for_it` | `--slow-steps` makes each phase of a drill wait a minute: the close answers plain `closed` (the last backup was made), within the stated sum, with the drill's scratch clone removed (fails without `hurry`: `closed_backup_incomplete`) |
|
||||
| `book_open_close::a_close_that_stops_git_in_a_commit_or_a_push_leaves_no_lock_and_the_next_backup_succeeds` | REAL git (a wrapper that points git's hooks at a `reference-transaction` hook that waits) stopped inside `init`, a commit and a push to a folder by a close: git is sent SIGTERM and removes its own locks, so none is left in the archive or the folder and the backup's record holds no `lock_removed` or `lock_left` (nothing for the server to clean up), the reopened book backs up with no step by hand, `git fsck --strict` passes on both |
|
||||
| `book_open_close::a_close_is_not_answered_while_its_backup_still_runs` | a backup held at each phase (`--slow-steps` and the book's `ops/slow-backup` file) when a close begins: the close is answered at its bound, saying the backup wasn't whole; the destination still proves whole at its previous manifest and nothing in it or in the book moves after the answer, with the stall lifted |
|
||||
| `local::tests::a_close_stops_a_format_upgrade_before_it_is_journaled` | an upgrade held in its backup's proof: the close stops it, it says nothing was upgraded, the journal is byte for byte as before |
|
||||
| `local::tests::a_body_read_to_its_end_is_never_cut_and_one_not_yet_is` | the line of the cut: a body read to its end is never cut (the cut firing, the body asked again), one not read to its end is cut even with bytes on the way |
|
||||
| `ledger-store` `backup::tests::a_git_stopped_by_sigterm_mid_commit_…`, `…_stopped_mid_add_…`, `a_push_stopped_by_sigterm_…`, `a_git_that_ignores_sigterm_…`, `a_git_that_cannot_end_on_sigterm_…`, `a_lock_left_in_a_folder_target_…`, `a_push_stopped_during_the_pack_transfer_…`, `the_archives_age_rule_at_open`, `removal_after_a_stop_goes_through_the_handle_…`, `git_locks::tests` (3) | REAL git stopped inside a commit (HEAD and ref locks), an add (the index lock) and a push to a folder (the target's ref lock): on SIGTERM it removes its own locks and nothing is noted (the grace is long, so a git that needed the kill would show); a git whose group is frozen (SIGSTOP, so SIGTERM stays pending) is killed only after the grace, and the archive's locks it left (not there when the command began) are removed, noted; the folder target's lock is NEVER removed, reported with its whole path (`LockLeft`, `lock_left` with `path`), a lock that was there before the push is untouched and not named, a later push fails by git's words and removes nothing, the next one passes once the test removes the file; a fake git that traps SIGTERM is sent it first (marker) and killed after the grace with all it started; a 48 MiB pack held in the receiving end's `pre-receive` hook (the target's `incoming-` quarantine present) stopped by SIGTERM and by the kill, `git fsck --strict` on both repositories at once; the archive's locks at open: older than ten minutes removed and noted, younger left and said, non-lock names, folders and links untouched; a swapped `refs` folder or archive path after the handle was opened touches nothing outside; the handle module: exact lock names only, regular files only, no link followed |
|
||||
| `ledger-store` `backup::tests::a_drill_stops_inside_the_phase_it_is_told_to_stop_in` | for each phase (clone, replay, verify, blobs, prefix) a stop set as the phase begins ends the drill inside it (the observer sees no later phase), scratch removed; each case fails when the loop's looks inside that phase are removed |
|
||||
| `ledger-store` `tests/backup.rs` `a_program_that_dies_at_any_write_leaves_what_proved_whole_before`, `a_stopped_backup_leaves_what_proved_whole_before` | a death at each of a backup's write points, and a stop asked before it: what is left proves whole at the previous manifest or the new one, and the next run goes on (replaces the tests of a git stopped by SIGTERM or killed, and of the locks it left) |
|
||||
| `ledger-store` `tests/backup.rs` `a_drill_stops_inside_the_phase_it_is_told_to_stop_in` | for each phase (fetch, replay, verify, blobs, vault, prefix) a stop set as the phase begins ends the drill inside it (the observer sees no later phase), scratch removed |
|
||||
| `book_open_close::a_running_call_is_never_cut_when_the_grace_runs_out` | an ordinary call (`books.attach_receipt`, held inside its read of its file, a named pipe) past the grace (body whole) is not cut: it finishes when fed, is answered and recorded `ok`, and then the close is answered (a backup asked for is no longer this call: it is stoppable) |
|
||||
| `book_open_close::a_close_stops_a_running_backup_call_and_says_so` | `books.back_up_now` held in a stalled `git` (never lifted until the call answers): the close stops it, the call is answered that it was stopped because the books are closing, its access record is `refused: stopped_by_close` with no head, the backup record holds `stopped` and no result of its own for the run, git and all it started are gone, the close's last backup is made and the close answers `closed` |
|
||||
| `book_open_close::a_close_stops_a_running_backup_call_and_says_so` | `books.back_up_now` held at a phase of its copy (never lifted until the call answers): the close stops it, the call is answered that it was stopped because the books are closing, its access record is `refused: stopped_by_close` with no head, the backup record says `stopped` and no result of the run's own; the close's own last backup is made as always |
|
||||
| `book_open_close::a_close_stops_a_running_verification_and_a_running_package_and_says_so` | `books.verify` and `books.export_cpa_package` held as they begin by `--timer-hold` (`call:...`), which the close releases: each is stopped at its first look, answers it was stopped, is recorded `refused: stopped_by_close`, the journal is unchanged |
|
||||
| `book_open_close::a_close_stops_the_restore_and_the_open_of_its_own_book_leaving_the_root_as_it_was` | a restore over a book and the open of a book, each held inside a phase (`restore:copy`, `open:start`): its scratch or staging folder is there while held; a close of THAT book stops it, it answers it was stopped, the root's `books/` and `legacy/` are byte for byte as before; asked again it goes through |
|
||||
| `book_open_close::the_servers_close_stops_every_running_admin_job_leaving_the_root_as_it_was` | restore (a new book, and over `acme`), adopt, create and open, each held inside a phase, the server closed with nothing lifting the hold: each answers it was stopped, the root as it was, exit 0; asked again on a new server the first goes through |
|
||||
@@ -4343,10 +4333,9 @@ one book never refuses or holds up a call on another.
|
||||
| `ledger-store` `tests/root.rs::a_job_stopped_at_any_phase_before_its_point_of_no_return_leaves_the_root_as_it_was` | create, adopt, restore (over existing books) and the restore preview stopped at each phase they ask: `Stopped`, the root (`books/`, `legacy/`) byte for byte as before; never stopped, `place` is the last phase asked (nothing after the point of no return) |
|
||||
| `ledger-store` `tests/root.rs::an_adoption_that_does_not_finish_leaves_no_lock_file_in_the_source` | a source with no lock file: the adoption stopped at each of its seven phases, refused after taking the lock (a stale preview head), and panicking in the middle leaves the source folder name for name, byte for byte and mode for mode as it was; a lock file swapped in by someone else during the adoption is not removed; a source that had its lock keeps it (stopped or adopted, `source_lock_created` false); a success of a source with none leaves the one it made and says so. Mutation: no removal fails it |
|
||||
| `ledger-store` `tests/root.rs::a_job_waiting_for_its_turn_stops_when_asked_and_otherwise_waits_for_it` | the turn at making books held (as another process would): a create that isn't asked to stop waits, and stops within seconds once asked (`Stopped`, nothing made); not asked, it goes through when the turn is let go. Mutation: a blocking wait for the turn fails it |
|
||||
| `book_open_close::a_lock_a_kill_leaves_in_the_backup_folder_is_reported_and_never_removed_by_the_server` | REAL git in a push to a folder with its group frozen, so only the kill after the grace ends it: the lock it leaves is still there after the close, recorded `lock_left` with its whole path, no `lock_removed` for the folder, the close's answer and `books.backup` name the file and say when it may be removed, a lock that was there before is neither touched nor named, a later backup fails by git's words and removes nothing, and once the file is removed the backup goes on, `git fsck --strict` on both |
|
||||
| `book_open_close::a_call_whose_answer_was_never_read_is_on_record_as_having_run` | a journaled draft whose client goes without reading: after the close the access log has its record, outcome `ok`, with the head it wrote (INVARIANT 14: a retry isn't made safe by anything; the record says it ran) |
|
||||
| `book_open_close::a_close_is_not_answered_while_its_backup_still_runs` | a book with a folder target and a stand-in `git` on the server's PATH that waits: the close isn't answered before its backup bound (1.2 s), then answers `closed_backup_incomplete`, git and all it started are gone, and lifting the stall makes nothing resume; the reopened book's backup record is a whole chain and it backs up (fails when `shut` is removed: git still runs after the answer) |
|
||||
| `book_open_close::a_close_whose_backup_fails_says_so_and_leaves_nothing_running` | a target whose disk isn't there: `closed_backup_incomplete` naming the failure, quickly, no git run afterwards; the same book with its disk back is answered plainly `closed` |
|
||||
| `book_open_close::a_close_is_not_answered_while_its_backup_still_runs` | a book with a backup folder whose backup waits at each phase: the close isn't answered before its backup bound (1.2 s), then answers `closed_backup_incomplete`; the folder still proves whole at the backup before, and lifting the stall makes nothing resume; the reopened book's backup record is a whole chain and it backs up (fails when `shut` is removed: the copy still runs after the answer) |
|
||||
| `book_open_close::a_close_whose_backup_fails_says_so_and_leaves_nothing_running` | a target whose disk isn't there: `closed_backup_incomplete` naming the failure, quickly, nothing run afterwards; the same book with its disk back is answered plainly `closed` |
|
||||
| `book_open_close::an_upload_in_flight_finishes_before_the_close_is_answered` | an upload half received when the close begins: the close isn't answered until it is complete (200), its bytes are kept, its record is written, no `.part` is left, nothing moves afterwards |
|
||||
| `book_open_close::a_restore_over_an_open_book_waits_for_what_is_inside_it` | a replacing restore over a book with an upload half received isn't answered for five seconds (a restore that doesn't wait takes about one); the upload then completes, the replaced book's log in `legacy/` holds it, is whole, no `.part` is left in `legacy/`, and it stands still (fails when the restore lets the store go without the drain) |
|
||||
| `book_open_close::downloads_during_a_close_complete_or_are_refused` | four clients download a 300 KB file in a loop while the book closes: each answer is a whole 200 or a refusal, the number of 200s is the number of download records, and nothing moves after the answer |
|
||||
@@ -4901,7 +4890,7 @@ count.
|
||||
- [P3 format upgrade] `format.rs` (`current`, `upgrade_to`, `adds`,
|
||||
`require_format`, `require_feature`), `store.rs` (`create_in_format`,
|
||||
`ensure_format`, `ensure_feature`, `upgrade_format`), `root.rs` (adoption's
|
||||
upgrade and its verify), `backup.rs` (`prove_archive`, `held_files`).
|
||||
upgrade and its verify), `backup/read.rs` (`prove_local`).
|
||||
- [P3 asset basis] `asset_basis_from_journal` (newer vs corrupt); the
|
||||
projection loader's two key sets.
|
||||
- [P3 projects] `project_set_of` (newer vs corrupt); `Store::add_project`'s
|
||||
@@ -5213,3 +5202,54 @@ count.
|
||||
`rule_for_refusal`'s new arms; `check_amount`'s `positive` flag; `derive`'s
|
||||
`refusal_justified` arms, `Model::post`'s close, `signed`'s date window and
|
||||
`closings` flag, the accounting-equation check; the spec test's pin search.
|
||||
|
||||
|
||||
## Backups in plain folders (P15 section 9, D-91, D-92)
|
||||
|
||||
The form is files written once (docs/backups.md), so what is tested is what
|
||||
the files promise, in four layers.
|
||||
|
||||
- `ledger-store` `tests/backup.rs` (22 tests, about 35 s): the form on disk
|
||||
and that a second backup only adds files; other or newer history never
|
||||
written; a disk that is gone never made again; two writers; a loser of a
|
||||
manifest number; a death at every write point of a second backup (the
|
||||
program is made to die at each write point in turn: what is left restores,
|
||||
and the next run goes on); a stop; a flipped, cut or emptied piece, sealed or
|
||||
not; a damaged newest backup falling back to the one before and saying so; the
|
||||
passphrase (counts and sizes only, a wrong one never yields books and is
|
||||
told from damage, a changed one a new set beside the old, the key private);
|
||||
the single file; the removed tests' promises (a purged vault, a scratch file
|
||||
left behind, a stored file that doesn't match its name, a drill of this book's
|
||||
history only, the local backup proof, a link never followed, a drill stopping
|
||||
inside its phase).
|
||||
- `ledger-store` `tests/backup_props.rs` (5 properties, 5 cases each, about
|
||||
30 s): a destination only grows; the destination as of any manifest restores
|
||||
to a prefix of the books; random interleavings of two writers; any flipped or
|
||||
cut piece is found; no wrong passphrase yields books.
|
||||
- `ledger-cli` `tests/backups.rs` and `tests/book_open_close.rs`: the server and
|
||||
the admin socket on a real root of its own.
|
||||
- `ledger-mcp` `backup.rs`, `local.rs` (the format upgrade's proven local
|
||||
backup), `ledger-store` `tests/root.rs` (restore's phases).
|
||||
|
||||
What each removed test of the git form is now (git, its locks and its output
|
||||
are gone; a promise is either held by a new test or named as gone):
|
||||
|
||||
| Removed | Now |
|
||||
|---|---|
|
||||
| `a_missing_git_says_how_to_get_it`, `the_mac_stub_is_not_a_git_until_the_developer_tools_are_there` | gone: nothing is installed for backups; `no_package_depends_on_another_program_for_backups` |
|
||||
| `a_backup_is_the_book_and_proves_whole` | `a_backup_is_the_book_and_proves_whole` |
|
||||
| `a_folder_targets_hooks_never_run`, `the_archives_own_hooks_never_run`, `the_owners_git_configuration_never_spoils_a_backup`, `no_attributes_rule_changes_a_byte`, `no_ignore_rule_leaves_a_file_out`, `a_file_git_wont_take_fails_the_backup`, `what_git_said_keeps_whole_lines_and_drops_its_progress`, `what_git_said_cut_short_ends_at_its_last_whole_line`, `local_addresses_are_told_from_networked_ones`, `a_repository_with_settings_of_its_own_is_never_pushed_to_or_read` | gone: no program runs, no rule or setting of anyone's can change a file, and there are no addresses; bytes are held by `any_whole_manifest_restores_a_prefix_of_the_books` |
|
||||
| `a_target_that_moved_on_is_never_overwritten` | `a_destination_of_other_books_or_another_history_is_never_written` |
|
||||
| `a_missing_folder_or_a_strange_address_is_said_plainly`, `a_backup_folder_gone_from_a_connected_disk_is_never_made_again` | `a_disk_that_is_gone_is_never_made_again_where_it_should_be` |
|
||||
| `a_purged_vault_leaves_the_next_backup` | `a_purged_vault_leaves_the_next_backup_and_not_the_earlier_ones` |
|
||||
| `a_lock_left_behind_never_stops_the_next_backup`, `the_archives_age_rule_at_open`, `removal_after_a_stop_goes_through_the_handle_opened_before_the_command`, `a_lock_left_in_a_folder_target_by_a_kill_is_never_removed_but_reported`, the `git_locks.rs` tests | gone: the form has no lock to leave; `a_scratch_file_left_by_a_dead_program_never_stops_the_next_backup` |
|
||||
| `a_backup_with_a_changed_stored_file_or_a_busy_scratch_is_refused` | `a_stored_file_that_does_not_match_its_name_is_refused_and_nothing_is_written` |
|
||||
| `a_drill_proves_this_books_history_only` | `a_drill_proves_this_books_history_only` |
|
||||
| `the_archive_proves_to_hold_the_book_as_it_is_keys_and_all` | `the_local_backup_proves_to_hold_the_book_as_it_is_keys_and_all` |
|
||||
| `a_backup_holding_a_link_or_a_stranger_is_refused_before_checkout` | `a_link_in_a_backup_is_never_followed`; the names in a manifest are checked on read |
|
||||
| the five tests of a git stopped by SIGTERM, killed after the grace, left quiet or cancelled, and `a_push_stopped_during_the_pack_transfer_leaves_both_repositories_whole` | gone: no process is stopped; `a_program_that_dies_at_any_write_leaves_what_proved_whole_before`, `a_stopped_backup_leaves_what_proved_whole_before` |
|
||||
| `a_drill_stops_inside_the_phase_it_is_told_to_stop_in` | `a_drill_stops_inside_the_phase_it_is_told_to_stop_in` |
|
||||
| the `drain.rs` tests (a pipe another process holds) | gone: nothing is piped |
|
||||
| `book_open_close` `a_close_that_stops_git_in_a_commit_or_a_push_...`, `a_lock_a_kill_leaves_in_the_backup_folder_is_reported_and_never_removed_by_the_server` | `a_close_is_not_answered_while_its_backup_still_runs`; the lock one is gone with locks |
|
||||
| `ledger-cli` `backups.rs` `books_restored_beside_their_original_leave_its_repository_alone` | `restore_beside_existing_books_and_on_a_clean_install` (a copy backs up to a folder of its own) |
|
||||
| `a_failing_target_waits_while_the_others_carry_on` | `a_failing_destination_is_not_tried_again_after_each_write` (one destination) |
|
||||
Reference in new issue
Block a user