check / check (push) Canceled after 0s
The owner (2026-10-23): "We should probably just delete the stdio path altogether. THere's no point in that. And it sitting there unused will just lead to bitrot. Nuke it?" Books are served only by the books server (`wanderbooks server`), reached by agents through the bridge (`wanderbooks mcp --book ID`), which stays. Removed: `wanderbooks dev-stdio`, the `ledger-mcp` binary, and `ledger_mcp::run` (stdio and `--http` over a bare data dir), with all that only that mode had: - files the books make coming back inline: `HandedFile.content_base64` is gone, and `download` and `expires_at` are always there; - books with no access log or backups: `books.access_log`, `books.backup` and `books.back_up_now` are always offered, by scope; - the settings file read and reloaded (`legacy_files`), the vault key named by a file or `--vault-key-file`, and the books dir's key-inside-the-books and git checks (with `paths.rs`); - `wire.rs` (the bridge frames an agent's lines itself); - `books.settings`' file fields and `books.start`'s `settings_source`. `BooksServer` is built one way, from `Served` (a book as the books server serves it), in production and in the unit tests. An unknown tool is now a protocol error (mcp-tools.md). Inline file input is unchanged. Then the owner's three decisions (2026-10-23, the question tool): (a) `books.import_settings` is removed entirely (118 tools): old books come in whole by `wanderbooks books adopt`, which reads their settings file once; ledger-config keeps its settings-file parsing only as far as adoption uses it (`load` and the path-reading `effective_receipt_policy` are gone), and `books.chart_template` gives its settings as `books.set_setting` changes. (b) The viewer's loose-books-folder mode is removed (`--data-dir`, `--books-toml`, `--vault-key-file`, the settings file and config.json followed): it opens only books of the data root, reading settings from the journal and the vault from the book's own `vault/` and `keys/`. (c) `wanderbooks dev-stdio` has no stub: it is an unknown command like any other word. Also: an upload's expiry past the calendar is an error, never an empty string. Tests: every suite that drove the stdio server moved to crates/ledger-cli/tests/ and drives a real `wanderbooks server` on a data root of its own (tests/common), handed files by their download; mcp_stdio.rs is mcp_journeys.rs. Tests of what is gone are deleted and listed in docs/testing.md. Docs: plan D-44 (D-18 superseded), STATUS, testing, rules, mcp-interface, the handbook, README; justfile recipes. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01T3gXMVt7XJPi6ens1or9Dj
122 lines
4.5 KiB
Rust
122 lines
4.5 KiB
Rust
//! `books.backup` and `books.back_up_now` (plan 3.7, D-30): the books'
|
|
//! backups as they stand, and one made now.
|
|
//!
|
|
//! ```text
|
|
//! GOAL: the agent can tell the human whether the books are backed up,
|
|
//! and back them up now when asked.
|
|
//! SOURCE: plan 3.7 ("books.backup {status|run} reports it": two tools,
|
|
//! one read-only), D-30.
|
|
//! INVARIANTS:
|
|
//! 1. A status reads the backup record only; a run makes and pushes a
|
|
//! backup (backup.rs) and answers the status after it.
|
|
//! ```
|
|
|
|
use super::*;
|
|
use schemars::JsonSchema;
|
|
use serde::{Deserialize, Serialize};
|
|
|
|
#[derive(Debug, Default, Deserialize, JsonSchema)]
|
|
pub struct BackupParams {}
|
|
|
|
#[derive(Debug, Default, Deserialize, JsonSchema)]
|
|
pub struct BackUpNowParams {
|
|
/// The backup folder's disk is new (or another): begin these books'
|
|
/// backup there again. Only when the human says so: a folder that
|
|
/// should hold one is otherwise a disk not connected.
|
|
#[serde(default)]
|
|
pub new_disk: bool,
|
|
}
|
|
|
|
#[derive(Debug, Serialize, JsonSchema)]
|
|
pub struct TargetOut {
|
|
/// "repository" (the private repository) or "folder".
|
|
pub target: String,
|
|
/// Where it is.
|
|
pub at: String,
|
|
/// When it last took a backup (UTC), if ever.
|
|
pub last_ok_at: Option<String>,
|
|
/// The journal seq it holds, if any.
|
|
pub through_seq: Option<u64>,
|
|
/// More than a day without the books' latest: tell the human.
|
|
pub stale: bool,
|
|
/// Why its last backup failed, if it did.
|
|
pub last_error: Option<String>,
|
|
/// When its backup was last proven restorable (UTC), if ever: each
|
|
/// is cloned and checked weekly.
|
|
pub last_drill_at: Option<String>,
|
|
/// Why that check failed, if it did: tell the human.
|
|
pub drill_error: Option<String>,
|
|
/// Not backed up there: these books were restored as a copy of others.
|
|
pub paused: bool,
|
|
}
|
|
|
|
#[derive(Debug, Serialize, JsonSchema)]
|
|
pub struct BackupOut {
|
|
/// The books' journal seq now.
|
|
pub head_seq: u64,
|
|
/// Each backup the settings name.
|
|
pub targets: Vec<TargetOut>,
|
|
/// What to do, when none is set up.
|
|
pub note: Option<String>,
|
|
}
|
|
|
|
impl From<crate::backup::Status> for BackupOut {
|
|
fn from(s: crate::backup::Status) -> Self {
|
|
BackupOut {
|
|
head_seq: s.head_seq,
|
|
note: s.note,
|
|
targets: s
|
|
.targets
|
|
.into_iter()
|
|
.map(|t| TargetOut {
|
|
target: t.target,
|
|
at: t.at,
|
|
last_ok_at: t.last_ok_at,
|
|
through_seq: t.through_seq,
|
|
stale: t.stale,
|
|
last_error: t.last_error,
|
|
last_drill_at: t.last_drill_at,
|
|
drill_error: t.drill_error,
|
|
paused: t.paused,
|
|
})
|
|
.collect(),
|
|
}
|
|
}
|
|
}
|
|
|
|
#[tool_router(router = backup_router, vis = "pub(super)")]
|
|
impl BooksServer {
|
|
#[tool(
|
|
name = "books.backup",
|
|
title = "Backups",
|
|
description = "Whether the books are backed up: each backup target the settings name (backup.git_remote, a private repository; backup.folder, a folder on another disk), when it last took the books, through which journal seq, and why it failed if it did. stale: it lacks the latest, and the first try to back that up was more than a day ago: tell the human. The books back themselves up a little after each change, when they open and before they close; books.back_up_now makes one now.",
|
|
annotations(read_only_hint = true, open_world_hint = false)
|
|
)]
|
|
async fn backup(&self, _params: Parameters<BackupParams>) -> Result<Json<BackupOut>, String> {
|
|
Ok(Json(self.backups.status().await.into()))
|
|
}
|
|
|
|
#[tool(
|
|
name = "books.back_up_now",
|
|
title = "Back up now",
|
|
description = "Back the books up now to every target the settings name, and answer how each went (as books.backup). new_disk: true only when the human says the backup folder's disk is new: the books' backup is then begun there again. Needs books:admin.",
|
|
annotations(
|
|
read_only_hint = false,
|
|
destructive_hint = false,
|
|
idempotent_hint = true,
|
|
open_world_hint = true
|
|
)
|
|
)]
|
|
async fn back_up_now(
|
|
&self,
|
|
params: Parameters<BackUpNowParams>,
|
|
) -> Result<Json<BackupOut>, String> {
|
|
Ok(Json(
|
|
self.backups
|
|
.run_with("asked", params.0.new_disk)
|
|
.await?
|
|
.into(),
|
|
))
|
|
}
|
|
}
|