docs: packages need nothing for backups; handbook, tools and install words without git
The Linux packages, the AUR recipe and the rpm metadata no longer depend on another program for backups (WB-pkg-4 is replaced); the Windows host's PATH no longer carries Git for Windows; the handbook an assistant reads, the tool descriptions, the install notes and the site say plain folders. A test adopts a clone of an old backup as the docs describe. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
This commit is contained in:
1 parent
4313464bd7
commit
91d88dcee7
21 files changed
+277
-208
No files matched your search
@@ -75,8 +75,6 @@ workspace = true
|
||||
# program: `just package-linux`. Paths are relative to the workspace root.
|
||||
[package.metadata.generate-rpm]
|
||||
name = "wanderbooks"
|
||||
# Backups run the system's git (WB-pkg-4): dnf fetches it.
|
||||
requires = { git = "*" }
|
||||
summary = "Double-entry bookkeeping your agent keeps and you can read"
|
||||
license = "MIT OR Apache-2.0"
|
||||
url = "https://wanderbooks.ai"
|
||||
|
||||
@@ -1236,3 +1236,118 @@ async fn old_settings_and_an_old_backup_history_are_left_alone_and_said() {
|
||||
drop(c);
|
||||
assert!(server.close().success());
|
||||
}
|
||||
|
||||
/// docs/backups.md, "A backup made with an older version": a person who
|
||||
/// still has a backup made with git clones it themselves (git is their own
|
||||
/// tool now) and adopts the plain folder. This makes such a backup the way
|
||||
/// an older version did (a repository whose one commit is the books'
|
||||
/// files), clones it as the docs say, and adopts the clone with its vault
|
||||
/// and key as the docs say.
|
||||
#[tokio::test(flavor = "multi_thread", worker_threads = 4)]
|
||||
async fn a_clone_of_an_old_git_backup_is_adopted_as_a_plain_folder() {
|
||||
let git = |dir: &Path, args: &[&str]| {
|
||||
let out = Command::new("git")
|
||||
.arg("-C")
|
||||
.arg(dir)
|
||||
.args(["-c", "user.name=t", "-c", "user.email=t@t.invalid"])
|
||||
.args(args)
|
||||
.output();
|
||||
match out {
|
||||
Ok(o) => {
|
||||
assert!(o.status.success(), "{args:?}: {o:?}");
|
||||
true
|
||||
}
|
||||
// No git on this machine: the path is the person's own tool's.
|
||||
Err(_) => false,
|
||||
}
|
||||
};
|
||||
let home = Home::new("old-backup");
|
||||
let server = Server::start(&home, Duration::from_secs(3600));
|
||||
home.create("acme");
|
||||
let c = connect(&home, "acme", home.token("acme", &ALL)).await;
|
||||
call(
|
||||
&c,
|
||||
"books.add_party",
|
||||
json!({"name": "Mo", "roles": ["member"]}),
|
||||
)
|
||||
.await
|
||||
.unwrap();
|
||||
call(
|
||||
&c,
|
||||
"books.set_tin",
|
||||
json!({"party": "Mo", "tin": "12-3456789", "tin_type": "ein"}),
|
||||
)
|
||||
.await
|
||||
.unwrap();
|
||||
let (folder, want) = backed_up_acme(&home).await;
|
||||
drop(c);
|
||||
assert!(server.close().success());
|
||||
// The old backup: the books' files, committed, in a bare repository.
|
||||
let book = home.book_dir("acme");
|
||||
let work = home.outside("old-work");
|
||||
std::fs::create_dir_all(&work).unwrap();
|
||||
for part in ["journal.jsonl", "blobs", "vault", "keys", "access.jsonl"] {
|
||||
let from = book.join(part);
|
||||
if from.is_dir() {
|
||||
copy_dir(&from, &work.join(part));
|
||||
} else if from.is_file() {
|
||||
std::fs::copy(&from, work.join(part)).unwrap();
|
||||
}
|
||||
}
|
||||
if !git(&work, &["init", "-q", "-b", "main"]) {
|
||||
return;
|
||||
}
|
||||
git(&work, &["add", "-A", "-f"]);
|
||||
git(&work, &["commit", "-q", "-m", "seq 1 head x\n\nbook acme"]);
|
||||
let bare = home.outside("acme.git");
|
||||
let out = Command::new("git")
|
||||
.args(["clone", "-q", "--bare"])
|
||||
.arg(&work)
|
||||
.arg(&bare)
|
||||
.output()
|
||||
.unwrap();
|
||||
assert!(out.status.success(), "{out:?}");
|
||||
// The person's steps: clone it, then adopt the folder with its vault
|
||||
// and key.
|
||||
let clone = home.outside("acme-old");
|
||||
let out = Command::new("git")
|
||||
.args(["clone", "-q"])
|
||||
.arg(&bare)
|
||||
.arg(&clone)
|
||||
.output()
|
||||
.unwrap();
|
||||
assert!(out.status.success(), "{out:?}");
|
||||
let other = Home::new("old-backup-new");
|
||||
let server = Server::start(&other, Duration::from_secs(3600));
|
||||
let request = |confirmed: bool, expect_head: Option<(u64, String)>| Request::Adopt {
|
||||
id: "acme".into(),
|
||||
source: clone.clone(),
|
||||
settings_toml: None,
|
||||
config_json: None,
|
||||
vault_dir: Some(clone.join("vault")),
|
||||
vault_key: Some(clone.join("keys").join("legacy.key")),
|
||||
confirmed,
|
||||
expect_head,
|
||||
skip_unknown: false,
|
||||
};
|
||||
let preview = match other.admin(request(false, None)) {
|
||||
Response::Preview(p) => p,
|
||||
r => panic!("{r:?}"),
|
||||
};
|
||||
match other.admin(request(true, Some(preview.source_head))) {
|
||||
Response::Adopted(a) => {
|
||||
assert!(a.problem.is_none(), "{a:?}");
|
||||
assert_eq!(a.head, live_head(&home, "acme"));
|
||||
}
|
||||
r => panic!("{r:?}"),
|
||||
}
|
||||
let c = connect(&other, "acme", other.token("acme", &["read"])).await;
|
||||
assert_eq!(figures(&c).await, want);
|
||||
let party = call(&c, "books.party", json!({"party": "Mo"}))
|
||||
.await
|
||||
.unwrap();
|
||||
assert_eq!(party["party"]["tin"]["in_vault"], true, "{party}");
|
||||
drop(c);
|
||||
assert!(server.close().success());
|
||||
let _ = folder;
|
||||
}
|
||||
@@ -684,26 +684,30 @@ fn only_a_person_runs_the_workflow_that_publishes_the_repositories() {
|
||||
);
|
||||
}
|
||||
|
||||
/// WB-pkg-4: on Linux git is a dependency of every package, so the package
|
||||
/// manager fetches it; nothing carries a git of its own.
|
||||
/// WB-pkg-4: a backup is plain files the program writes itself, so no
|
||||
/// package depends on another program for it and none carries one.
|
||||
#[test]
|
||||
fn the_linux_packages_depend_on_git_and_none_carries_one() {
|
||||
let packager = read("deploy/packaging/packager.toml");
|
||||
assert_eq!(
|
||||
packager.matches("\"git\"").count(),
|
||||
2,
|
||||
"the deb and the pacman package depend on git"
|
||||
);
|
||||
assert!(read("crates/ledger-cli/Cargo.toml").contains("requires = { git = \"*\" }"));
|
||||
assert!(read("deploy/packaging/aur/PKGBUILD").contains("'git'"));
|
||||
fn no_package_depends_on_another_program_for_backups() {
|
||||
let word = |text: &str| {
|
||||
text.to_lowercase()
|
||||
.split(|c: char| !c.is_ascii_alphanumeric())
|
||||
.any(|w| w == "git")
|
||||
};
|
||||
for file in [
|
||||
"deploy/packaging/packager.toml",
|
||||
"deploy/packaging/aur/PKGBUILD",
|
||||
"crates/ledger-cli/Cargo.toml",
|
||||
"deploy/packaging/windows/wanderbooks.nsi",
|
||||
"deploy/packaging/macos/build-macos.sh",
|
||||
] {
|
||||
let text = read(file).to_lowercase();
|
||||
assert!(
|
||||
!text.contains("mingit") && !text.contains("git.exe"),
|
||||
"{file} bundles a git"
|
||||
);
|
||||
let text = read(file);
|
||||
// (Cargo.toml may name a git *dependency* of the build, never a
|
||||
// package requirement.)
|
||||
let checked: String = text
|
||||
.lines()
|
||||
.filter(|l| !l.contains("git ="))
|
||||
.collect::<Vec<_>>()
|
||||
.join("\n");
|
||||
assert!(!word(&checked), "{file} depends on, or bundles, a git");
|
||||
}
|
||||
}
|
||||
@@ -770,7 +770,7 @@ fn books_usage(prog: &str) {
|
||||
" back-up back the books up now to every backup their settings name (--new-disk: the backup folder's disk is new)"
|
||||
);
|
||||
eprintln!(
|
||||
" restore bring back a backup (a git repository's address, or BOOK.git in the backup folder), proven whole first: as new books, or replacing books (kept in legacy/)"
|
||||
" restore bring back a backup (your backup folder, the folder of one set of books in it, or a backup file), proven whole first: as new books, or replacing books (kept in legacy/)"
|
||||
);
|
||||
eprintln!(
|
||||
" upgrade give the go-ahead, with the owner passphrase, for books an older wanderbooks wrote to move to this version's journal format (a verified backup with the vault and keys first)"
|
||||
@@ -779,7 +779,7 @@ fn books_usage(prog: &str) {
|
||||
" extract read one attachment's text (a PDF, XLSX or text file) and journal it, one at a time; books an older version filed are read this way after an upgrade"
|
||||
);
|
||||
eprintln!(
|
||||
" put-aside move the old copies of adopted books (their data folder, their vault and its key, and other paths given: settings file, git history) whole into the legacy folder, once the books hold everything they do, byte for byte; nothing is deleted"
|
||||
" put-aside move the old copies of adopted books (their data folder, their vault and its key, and other paths given: settings file, old history) whole into the legacy folder, once the books hold everything they do, byte for byte; nothing is deleted"
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@@ -12,7 +12,7 @@
|
||||
//! and DBUS_SESSION_BUS_ADDRESS only when they point at this
|
||||
//! account's own private runtime folder, and SSH_AUTH_SOCK only when
|
||||
//! it names a socket this account owns (the owner's ssh agent, so the
|
||||
//! server's backups reach a private git repository, D-30). Nothing
|
||||
//! server's backups reach a folder on the network, D-91). Nothing
|
||||
//! else passes (a scope's own identifiers, such as INVOCATION_ID, are
|
||||
//! systemd's). Two more: APPIMAGE and APPDIR, only when they are
|
||||
//! this program's own (INVARIANT 6), so the host knows its own
|
||||
@@ -441,9 +441,9 @@ fn scope_made(child: &mut std::process::Child, log: &std::fs::File, from: u64) -
|
||||
|
||||
/// The host's environment on Windows (INVARIANT 1's counterpart): the
|
||||
/// system's own variables, the account's profile, and a PATH fixed to the
|
||||
/// system folders and Git for Windows (the backups run `git`). Nothing
|
||||
/// else of the opener's passes. (CHOICE, P11c: no authority states a
|
||||
/// Windows list; this is the least a Windows program and `git` need.)
|
||||
/// system folders. Nothing else of the opener's passes. (CHOICE, P11c: no
|
||||
/// authority states a Windows list; this is the least a Windows program
|
||||
/// needs.)
|
||||
#[cfg(windows)]
|
||||
fn host_env(home: &Path) -> Vec<(String, std::ffi::OsString)> {
|
||||
let var = |name: &str| std::env::var_os(name);
|
||||
@@ -452,12 +452,8 @@ fn host_env(home: &Path) -> Vec<(String, std::ffi::OsString)> {
|
||||
.map_or_else(|| PathBuf::from(r"C:\Windows"), PathBuf::from);
|
||||
let program_files: PathBuf =
|
||||
var("ProgramFiles").map_or_else(|| PathBuf::from(r"C:\Program Files"), PathBuf::from);
|
||||
let path = std::env::join_paths([
|
||||
system_root.join("System32"),
|
||||
system_root.clone(),
|
||||
program_files.join("Git").join("cmd"),
|
||||
])
|
||||
.unwrap_or_default();
|
||||
let path = std::env::join_paths([system_root.join("System32"), system_root.clone()])
|
||||
.unwrap_or_default();
|
||||
let mut env: Vec<(String, std::ffi::OsString)> = vec![
|
||||
("PATH".into(), path),
|
||||
("SystemRoot".into(), system_root.clone().into_os_string()),
|
||||
|
||||
@@ -1,9 +1,10 @@
|
||||
# Backups
|
||||
|
||||
- The books back themselves up: a little after each change, when they open, before they close. Each backup goes to the targets the settings name: backup.git_remote, a private repository the human owns, and backup.folder, a folder on another disk. Both is best. The backups aren't encrypted: the human's repository host and disk keep them private.
|
||||
- No targets set: books.start says so. Ask the human for the repository's address and the folder, then set them with books.set_setting (who decided, and when); choosing where backups go needs books:admin, as backing up does.
|
||||
- books.backup says how each target stands: when it last took the books, through which journal seq, why the last try failed, and whether its weekly restore check passed. A target that is stale, failing, or failed its check: tell the human what it says, in plain words (a disk not connected, a repository that refused).
|
||||
- books.back_up_now backs up at once, for instance before the human changes computers. A backup never changes the books.
|
||||
- A backup folder that took these books' backups but holds none now is a disk not connected: ask the human to connect it. Only if they say the disk is new, back up now with new_disk: true to begin the books' backup there again.
|
||||
- Books restored as a copy of other books (under another name) don't back up to those books' repository (that would stop theirs): books.backup says so; ask the human for one of their own.
|
||||
- Restoring is the human's to do, outside these tools: a backup comes back as new books, or replacing these (the old books are kept, never deleted), and each is proven whole before it is restored.
|
||||
- The books back themselves up: a little after each change, when they open, before they close. The backup goes to the backup folder the settings name (backup.folder): a folder on another disk, or one that Dropbox, iCloud, OneDrive or Google Drive keeps in sync. It holds one folder for these books, made only of files that are added and never changed or deleted, so a sync service never sees one change under it.
|
||||
- No backup folder set: books.start says so. Ask the human which folder, then set it with books.set_setting (who decided, and when); choosing where backups go needs books:admin, as backing up does. The window has a folder chooser for the same.
|
||||
- The human may protect the backups with a passphrase, set up in the window and off by default. Then every file in the folder is sealed and says no more than how many there are and how big. The passphrase is never in the books or in these tools, and a forgotten one can't be recovered: say so plainly if the human asks. books.backup says whether the backups are sealed.
|
||||
- books.backup says how the folder stands: when it last took the books, through which journal seq, why the last try failed, and whether its weekly restore check passed. A folder that is stale, failing, or failed its check: tell the human what it says, in plain words (a disk not connected, another set of books in the folder).
|
||||
- books.back_up_now backs up at once, for instance before the human changes computers. A backup never changes the books. The window's Save a backup... makes the same backup as one file to keep or carry.
|
||||
- A backup folder that took these books' backups but holds none now is a disk not connected (disconnected: true): ask the human to connect it. Only if they say the disk is new, back up now with new_disk: true to begin the books' backup there again.
|
||||
- Books that still name a private repository in their settings (an older kind of backup) are told it is no longer used: ask the human for a backup folder instead. Nothing older is deleted.
|
||||
- Restoring is the human's to do, outside these tools: a backup comes back as new books, or replacing these (the old books are kept, never deleted), from the backup folder or a backup file, and each is proven whole before it is restored.
|
||||
@@ -1038,11 +1038,11 @@ impl BooksServer {
|
||||
// failing.
|
||||
{
|
||||
let st = self.backups.standing(store);
|
||||
if st.note.is_some() {
|
||||
if st.targets.is_empty() {
|
||||
next_steps.push(step(
|
||||
"books.backup",
|
||||
None,
|
||||
"No backups are set up: ask the human for a private repository and a folder on another disk, then set backup.git_remote and backup.folder (books.set_setting).",
|
||||
"No backups are set up: ask the human which folder to back up to (a folder on another disk, or one a sync service keeps), then set backup.folder (books.set_setting).",
|
||||
));
|
||||
} else if st.needs_attention() {
|
||||
next_steps.push(step(
|
||||
|
||||
@@ -1124,7 +1124,7 @@ impl BooksServer {
|
||||
/// ```text
|
||||
/// GOAL: everything the CPA needs for the return in one zip, the K-1s'
|
||||
/// and 1099s' TINs included, without a full TIN ever landing in
|
||||
/// the books (a git repository) or the conversation.
|
||||
/// the books or the conversation.
|
||||
/// SOURCE: docs/mcp-interface.md; BS-partner-2; DECISION (owner,
|
||||
/// 2026-10-15): "it needs to be in the damn CPA package."
|
||||
/// INVARIANTS:
|
||||
|
||||
@@ -1294,7 +1294,7 @@ pub fn find_with(
|
||||
count(ids.len(), "stored file is", "stored files are")
|
||||
),
|
||||
detail: format!(
|
||||
"Attachment {}: the bytes on disk don't match their recorded hash. Restore them from a backup (the books dir's git history).",
|
||||
"Attachment {}: the bytes on disk don't match their recorded hash. Restore them from a backup.",
|
||||
ids.join(", ")
|
||||
),
|
||||
target: Target::Documents,
|
||||
|
||||
Reference in new issue
Block a user