fix(store,gui,package): every reader that derives facts reads the committed journal (P15 T1 review)

A failed call's ids are handed out again (nothing it wrote counted), so a
reader of the raw journal pins dead lines on whatever takes the id next: a
failed books.create_bill for entry 42 then a manual entry 42 showed as a
Bill. One accessor, calls::committed (lines outside a call and of calls
that closed ok, the frame left out), now feeds the viewer's books (entry
events and origin, asset trails, party events), the package feed attention
reads, and the adopt preview's settings check. The journal page and
journal_history keep every line and say in words of each line of a call
that failed, never finished or is still running that it did not count.

A call's closing line is now bounded (ANSWER_CAP 4 KiB: above it, the
answer's SHA-256 and length), a call that wrote no line leaves no line (its
key and answer live in a bounded in-memory table), and the journaled
argument digest is an HMAC under the books' own call key, so two requests
that differ only in a tax id are two requests and nothing journaled lets a
guess of one be tested.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
This commit is contained in:
swaitsandClaude Fable 5.2 committed 2026-11-21 10:09:17 -07:00
1 parent e542319e63
commit d4c0036599
11 files changed
+950 -120

No files matched your search

+21 -2
View File
@@ -987,7 +987,11 @@ impl Root {
head.0
)));
}
let keeps_settings = lines.iter().any(|l| l.line_type == "settings.set");
// Facts of the books only: a failed call's settings line never counted
// (calls.rs INVARIANT 7).
let keeps_settings = crate::calls::committed(&lines)?
.iter()
.any(|l| l.line_type == "settings.set");
if !keeps_settings && options.settings.is_none() {
return Err(RootError::Adopt(
"these books keep no settings of their own yet: give their settings file \
@@ -1497,7 +1501,9 @@ impl Root {
Ok(SourcePreview {
head: head_of(&lines),
currency: crate::store::journal_currency(&lines)?,
keeps_settings: lines.iter().any(|l| l.line_type == "settings.set"),
keeps_settings: crate::calls::committed(&lines)?
.iter()
.any(|l| l.line_type == "settings.set"),
})
})()
.map_err(|e| self.hide(e))
@@ -2290,6 +2296,19 @@ fn write_private_file(path: &Path, bytes: &[u8]) -> Result<(), RootError> {
Ok(())
}
/// Write a new file, mode 0600 set explicitly, synced, as `io::Result`
/// (the call key, calls.rs): an existing file is `AlreadyExists`.
pub(crate) fn write_new_private_file(path: &Path, bytes: &[u8]) -> std::io::Result<()> {
use std::io::Write;
let mut file = std::fs::OpenOptions::new()
.write(true)
.create_new(true)
.open(path)?;
set_mode(path, 0o600)?;
file.write_all(bytes)?;
file.sync_all()
}
/// Make a folder's entries durable (Unix; NTFS journals its own).
fn sync_dir(path: &Path) -> Result<(), RootError> {
#[cfg(unix)]