feat(package): one attention engine over PackageBooks (U0b)

Needs attention was computed by the viewer alone, while books.start
hand-picked a handful of next steps. The human's list and the agent's
could disagree, and a new item had to be written twice (or, as
books.start showed, not at all).

Move the engine to ledger-package over PackageBooks: one function,
find/find_with(books, today, settings, integrity), reads the ledger, the
journal's event types (an entry's origin), the attachments and their
links, the statements, the reconciliations, and the database check. The
viewer's attention module now only maps Target to Route; books.start
turns the same items into its next steps (why = the item's title, top 12),
so the list the human sees and the steps the agent gets cannot drift.

PackageBooks gains settings, journal, statements, reconciliations and
disk_check, implemented for Store and Snapshot, so both views answer
alike. The W-9, reconciliation and 1099 predicates move beside the items
to keep one copy. ledger-package gains ledger-config and serde_json (the
receipt policy and the tool arguments the items carry).

Tests: view_model.rs and spec_kept.rs pass unchanged; the new
attention_parity.rs compares the viewer and books.start item for item on
the demo books and on a book written entry by entry. just check green.
This commit is contained in:
swaits committed 2026-10-27 06:12:55 -06:00
1 parent eeee9658da
commit 0cf2f8f5c5
17 files changed
+2026 -895

No files matched your search

+37
View File
@@ -761,6 +761,18 @@ impl BooksServer {
args,
why: why.into(),
};
// An attention title can carry a free-text description; keep the
// step short so books.start stays within START_MAX (INVARIANT 4).
let step_title = |t: &str| -> String {
const MAX: usize = 160;
if t.chars().count() <= MAX {
t.to_string()
} else {
let mut s: String = t.chars().take(MAX - 1).collect();
s.push('…');
s
}
};
let mut next_steps = Vec::new();
// Books an older version wrote wait for the owner's go-ahead to
// upgrade their format: first, at every start until it is given
@@ -811,6 +823,31 @@ impl BooksServer {
));
}
}
// The attention items, as next steps: the same function the viewer
// draws (ledger_package::attention), so the agent and the human see
// one list. The most urgent first (the list is sorted by severity),
// at most 12: `books.start` stays small (INVARIANT 4).
{
let attention_settings = ledger_package::Settings {
company: &cfg.company,
cash_accounts: &cfg.roles.cash,
financing_accounts: &cfg.roles.financing,
investing_accounts: &cfg.roles.investing,
};
let attention = ledger_package::find_with(
store,
today,
&attention_settings,
&ledger_package::Integrity::default(),
);
for a in attention.iter().filter(|a| a.tool.is_some()).take(12) {
let Some((tool, args)) = &a.tool else {
continue;
};
let args = (!args.is_null()).then(|| args.clone());
next_steps.push(step(tool, args, &step_title(&a.title)));
}
}
match focus {
"close" => next_steps.push(step(
"books.conventions",