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:
1 parent
e542319e63
commit
d4c0036599
11 files changed
+950
-120
No files matched your search
@@ -43,6 +43,9 @@ pub struct Described {
|
||||
pub subjects: Vec<String>,
|
||||
/// The entry it belongs to, if it is about one.
|
||||
pub entry_id: Option<u64>,
|
||||
/// Whether the line counts (calls.rs): a line of a call that failed or
|
||||
/// never finished is listed, and its summary says it did not count.
|
||||
pub standing: crate::calls::Standing,
|
||||
}
|
||||
|
||||
/// Which lines to list (INVARIANT 3).
|
||||
@@ -245,12 +248,29 @@ pub fn describe_line(line: &JournalLine) -> Described {
|
||||
summary: describe(line),
|
||||
subjects,
|
||||
entry_id,
|
||||
standing: crate::calls::Standing::Counts,
|
||||
}
|
||||
}
|
||||
|
||||
/// The lines `filter` asks for, described, in journal order (INVARIANT 3),
|
||||
/// and whether more match after the last one returned.
|
||||
/// and whether more match after the last one returned. Every line counts
|
||||
/// (use [`history_standing`] where some may not).
|
||||
pub fn history(lines: &[JournalLine], filter: &HistoryFilter) -> (Vec<Described>, bool) {
|
||||
history_standing(
|
||||
lines,
|
||||
&vec![crate::calls::Standing::Counts; lines.len()],
|
||||
filter,
|
||||
)
|
||||
}
|
||||
|
||||
/// [`history`] with each line's standing (calls.rs INVARIANT 7): a line
|
||||
/// of a call that failed, never finished or is still running is listed,
|
||||
/// as history is, and its summary says in words that it does not count.
|
||||
pub fn history_standing(
|
||||
lines: &[JournalLine],
|
||||
standing: &[crate::calls::Standing],
|
||||
filter: &HistoryFilter,
|
||||
) -> (Vec<Described>, bool) {
|
||||
let wanted = |l: &JournalLine| {
|
||||
l.seq > filter.after_seq
|
||||
&& (filter.types.is_empty()
|
||||
@@ -268,12 +288,17 @@ pub fn history(lines: &[JournalLine], filter: &HistoryFilter) -> (Vec<Described>
|
||||
};
|
||||
let mut out = Vec::new();
|
||||
let mut more = false;
|
||||
for l in lines.iter().filter(|l| wanted(l)) {
|
||||
for (l, st) in lines.iter().zip(standing).filter(|(l, _)| wanted(l)) {
|
||||
if out.len() == filter.limit {
|
||||
more = true;
|
||||
break;
|
||||
}
|
||||
out.push(describe_line(l));
|
||||
let mut d = describe_line(l);
|
||||
d.standing = *st;
|
||||
if let Some(note) = st.note() {
|
||||
d.summary = format!("{} ({note})", d.summary);
|
||||
}
|
||||
out.push(d);
|
||||
}
|
||||
(out, more)
|
||||
}
|
||||
@@ -299,7 +324,8 @@ impl crate::Store {
|
||||
let (lines, _format) = crate::journal::read_journal_and_format(
|
||||
&self.data_dir().join(crate::store::JOURNAL_FILE),
|
||||
)?;
|
||||
let (described, more) = history(&lines, filter);
|
||||
let standing = crate::calls::standings(&lines)?;
|
||||
let (described, more) = history_standing(&lines, &standing, filter);
|
||||
let tail_repairs = self
|
||||
.tail_repairs()?
|
||||
.into_iter()
|
||||
|
||||
Reference in new issue
Block a user