feat(mcp): books.journal_history, the journal in words (P5)

Agent reason: an agent traces a figure back to what produced it by reading
the journal, but it must never read the file. books.journal_history is the
one way: each line in order with its seq, time, type, a sentence saying what
it did to what, its subject and the entry it belongs to, filtered by
after_seq, type (exact, or a group like entry.) and subject (entry:12,
invoice:3, bill:3, account:10, party:5, asset:2), paged with more, with the
torn tails set aside on open listed beside them. It reads the verified
journal through read_journal_and_format, so a damaged chain is an error, not
a story.

The sentences come from ledger-store's describe.rs, which quotes only
identifiers, dates, amounts and the short names a person typed: never a
setting's value (settings.set names its keys) and never a full TIN (masked,
B-26). Every event type the store writes has a sentence (tested against
EVENT_TYPES). The tool is read-only (books:read); the books://journal/{seq}
and books://entries/{id} resources read through it.

Departure from the plan: the viewer's own sentences (its describe arms in
ledger-gui, which carry icons, routes and today's party and account names)
stay where they are; moving a thousand lines of egui text behind a
formatting trait was not worth the risk to the viewer's tests, so the server
has the shared describer and the viewer keeps its own.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01HS8WZziDnyxunC23MUxrLp
This commit is contained in:
swaitsandClaude Fable 5.1 committed 2026-10-29 15:48:27 -06:00
1 parent 4236f03744
commit 61da9e57cd
8 files changed
+594 -3

No files matched your search

+31
View File
@@ -584,6 +584,7 @@ impl BooksServer {
+ Self::tax_router()
+ Self::write_offs_router()
+ Self::drafts_router()
+ Self::journal_router()
}
/// The settings in force for this request: the books' own, taken from
@@ -1403,6 +1404,8 @@ mod backup_tools;
mod files;
#[path = "tools/instruments.rs"]
mod instruments;
#[path = "tools/journal.rs"]
mod journal_tools;
#[path = "tools/kept.rs"]
mod kept;
#[path = "tools/projects.rs"]
@@ -1539,6 +1542,34 @@ impl BooksServer {
.await?;
json(&out)
}
_ if path.starts_with("books://entries/") => {
let id: u64 = path["books://entries/".len()..]
.parse()
.map_err(|_| format!("bad entry resource URI: {uri}"))?;
let Json(out) = self
.get_entry(Parameters(GetEntryParams { entry_id: id }))
.await?;
json(&out)
}
_ if path.starts_with("books://journal/") => {
let seq: u64 = path["books://journal/".len()..]
.parse()
.map_err(|_| format!("bad journal resource URI: {uri}"))?;
if seq == 0 {
return Err("journal seqs start at 1".into());
}
let Json(out) = self
.journal_history(Parameters(journal_tools::JournalHistoryParams {
after_seq: Some(seq - 1),
limit: Some(1),
..Default::default()
}))
.await?;
if out.lines.first().is_none_or(|l| l.seq != seq) {
return Err(format!("the journal has no line {seq}"));
}
json(&out)
}
handbook::URI => {
let Json(out) = self.handbook(Parameters(HandbookParams::default())).await?;
json(&out)