style: rustfmt and one clippy lint over the P5 files

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:42 -06:00
1 parent 7bac25496e
commit 632938fa97
11 files changed
+302 -108

No files matched your search

+23 -5
View File
@@ -99,7 +99,11 @@ pub(crate) fn mutating_tools() -> &'static HashSet<String> {
/// The steps a tool's own result implies (no books needed): the confirm
/// after a preview, and what follows a particular act.
pub(crate) fn tool_steps(tool: &str, args: Option<&Map<String, Value>>, result: &Value) -> Vec<Step> {
pub(crate) fn tool_steps(
tool: &str,
args: Option<&Map<String, Value>>,
result: &Value,
) -> Vec<Step> {
let mut steps = Vec::new();
let confirmed = args
.and_then(|a| a.get("confirmed"))
@@ -319,7 +323,11 @@ pub(crate) fn tool_steps(tool: &str, args: Option<&Map<String, Value>>, result:
}
/// The attention items about the subject of the call, as steps.
fn attention_steps(server: &BooksServer, subject: Subject, store: &ledger_store::Store) -> Vec<Step> {
fn attention_steps(
server: &BooksServer,
subject: Subject,
store: &ledger_store::Store,
) -> Vec<Step> {
let cfg = server.settings();
let settings = ledger_package::Settings {
company: &cfg.company,
@@ -342,7 +350,9 @@ fn attention_steps(server: &BooksServer, subject: Subject, store: &ledger_store:
match (a.target, tool.as_str()) {
(
Target::Entry(id),
"books.attach_receipt" | "books.set_entry_party" | "books.set_entry_settles",
"books.attach_receipt"
| "books.set_entry_party"
| "books.set_entry_settles",
) => Some(json!({ "entry_id": id })),
_ => None,
}
@@ -350,7 +360,12 @@ fn attention_steps(server: &BooksServer, subject: Subject, store: &ledger_store:
Some(args)
};
let title: String = a.title.chars().take(160).collect();
Some(Step::tool(&tool, args, &title, a.severity == Severity::Problem))
Some(Step::tool(
&tool,
args,
&title,
a.severity == Severity::Problem,
))
})
.take(4)
.collect()
@@ -493,7 +508,10 @@ mod tests {
.chain([digest_step()])
{
if let Some(t) = s.tool {
assert!(names.contains(&t), "{tool}: step names {t}, which is no tool");
assert!(
names.contains(&t),
"{tool}: step names {t}, which is no tool"
);
}
}
}
+13 -11
View File
@@ -1316,10 +1316,9 @@ fn prompt_reader(context: &RequestContext<RoleServer>) -> Result<(), rmcp::Error
crate::access::UNAUTHORIZED,
None,
)),
Some(c) if !c.may(ledger_store::auth::Scope::Read) => Err(rmcp::ErrorData::invalid_request(
crate::access::INSUFFICIENT_SCOPE,
None,
)),
Some(c) if !c.may(ledger_store::auth::Scope::Read) => Err(
rmcp::ErrorData::invalid_request(crate::access::INSUFFICIENT_SCOPE, None),
),
Some(_) => Ok(()),
}
}
@@ -1468,26 +1467,26 @@ enum ShownDates {
// Tools
// ---------------------------------------------------------------------------
#[path = "guards.rs"]
mod guards;
#[path = "next_steps.rs"]
mod next_steps;
#[path = "tools/access.rs"]
mod access_tools;
#[path = "tools/backup.rs"]
mod backup_tools;
#[path = "tools/files.rs"]
mod files;
#[path = "guards.rs"]
mod guards;
#[path = "tools/instruments.rs"]
mod instruments;
#[path = "tools/journal.rs"]
mod journal_tools;
#[path = "tools/prompts.rs"]
mod prompts;
#[path = "tools/kept.rs"]
mod kept;
#[path = "next_steps.rs"]
mod next_steps;
#[path = "tools/projects.rs"]
mod projects;
#[path = "tools/prompts.rs"]
mod prompts;
pub use kept::SettingKeyOut;
// The tool groups: one file each (plan/served.md 8.2 U0a). A unit adds a
@@ -1616,7 +1615,10 @@ impl BooksServer {
// `since_seq` (what was posted since a journal line) wins
// over `since`; with neither, this month so far.
let since_seq = query_param(query, "since_seq")
.map(|n| n.parse::<u64>().map_err(|_| format!("bad since_seq in {uri}")))
.map(|n| {
n.parse::<u64>()
.map_err(|_| format!("bad since_seq in {uri}"))
})
.transpose()?;
let since = if since_seq.is_some() {
None
+19 -6
View File
@@ -19,7 +19,12 @@ fn books_start_is_always_loaded() {
.as_ref()
.and_then(|m| m.0.get("anthropic/alwaysLoad"))
.and_then(serde_json::Value::as_bool);
assert_eq!(always == Some(true), tool.name == "books.start", "{}", tool.name);
assert_eq!(
always == Some(true),
tool.name == "books.start",
"{}",
tool.name
);
}
}
@@ -727,7 +732,10 @@ fn tool_descriptions_fit_700_characters() {
.map(|t| t.name.to_string())
.collect();
over.sort();
assert!(over.is_empty(), "tool descriptions over 700 characters: {over:?}");
assert!(
over.is_empty(),
"tool descriptions over 700 characters: {over:?}"
);
}
/// The tools docs/mcp-interface.md documents: a line (or a bullet)
@@ -1549,13 +1557,16 @@ fn every_mutating_result_has_head_and_next_steps() {
let answer = CallToolResponse::Complete(CallToolResult::structured(
serde_json::json!({"status": "ok"}),
));
let CallToolResponse::Complete(r) = next_steps::apply(&server, &name, None, Ok(answer))
.expect("an answer stays an answer")
let CallToolResponse::Complete(r) =
next_steps::apply(&server, &name, None, Ok(answer)).expect("an answer stays an answer")
else {
panic!("{name}: not a complete answer");
};
let body = r.structured_content.expect("structured");
assert!(body["guards"].is_array() && body["warnings"].is_array(), "{name}");
assert!(
body["guards"].is_array() && body["warnings"].is_array(),
"{name}"
);
let ContentBlock::Text(t) = &r.content[0] else {
panic!("{name}: no text block");
};
@@ -1597,7 +1608,9 @@ fn the_envelope_keeps_what_a_tool_said_and_carries_a_refusal_guard() {
&server,
"books.post_entry",
None,
Ok(CallToolResponse::Complete(CallToolResult::structured(own.clone()))),
Ok(CallToolResponse::Complete(CallToolResult::structured(
own.clone(),
))),
)
.unwrap() else {
panic!()
+3 -5
View File
@@ -1552,11 +1552,9 @@ impl BooksServer {
if let Some(id) = p.revises {
// A source correction: the decision's words stay (the ones
// given, if any, must be the ones it has).
let old = store
.ledger()
.conventions()
.decision(id)
.ok_or_else(|| format!("decision {id} doesn't exist: books.decisions lists them"))?;
let old = store.ledger().conventions().decision(id).ok_or_else(|| {
format!("decision {id} doesn't exist: books.decisions lists them")
})?;
if (!p.subject.is_empty() && p.subject != old.new.subject)
|| (!p.decision_md.is_empty() && p.decision_md != old.new.decision_md)
{
+19 -5
View File
@@ -149,8 +149,11 @@ impl BooksServer {
.with_required(true)
})
.collect::<Vec<_>>();
let mut prompt =
Prompt::new(p.name, Some(p.description), (!args.is_empty()).then_some(args));
let mut prompt = Prompt::new(
p.name,
Some(p.description),
(!args.is_empty()).then_some(args),
);
prompt.title = Some(p.title.to_string());
prompt
})
@@ -171,7 +174,11 @@ impl BooksServer {
format!(
"there is no prompt {:?}: {}",
request.name.chars().take(40).collect::<String>(),
PROMPTS.iter().map(|p| p.name).collect::<Vec<_>>().join(", ")
PROMPTS
.iter()
.map(|p| p.name)
.collect::<Vec<_>>()
.join(", ")
)
})?;
let mut text = def.text.trim_end().to_string();
@@ -214,7 +221,10 @@ mod tests {
.collect();
for p in &PROMPTS {
let mut seen = 0;
for word in p.text.split(|c: char| !(c.is_ascii_alphanumeric() || c == '_' || c == '.')) {
for word in p
.text
.split(|c: char| !(c.is_ascii_alphanumeric() || c == '_' || c == '.'))
{
if let Some(tool) = word.strip_prefix("books.") {
let tool = tool.trim_end_matches('.');
if !tool.is_empty() {
@@ -229,7 +239,11 @@ mod tests {
}
assert!(seen > 0, "{} names no tool", p.name);
for (name, _, _) in p.args {
assert!(p.text.contains(&format!("{{{{{name}}}}}")), "{}: {name}", p.name);
assert!(
p.text.contains(&format!("{{{{{name}}}}}")),
"{}: {name}",
p.name
);
}
}
}