Merge branch 't3/mcp-refusals-write-nothing': a refused call writes nothing; four tools checked before writing

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
This commit is contained in:
swaitsandClaude Fable 5.2 committed 2026-11-21 12:30:50 -07:00
commit bf977b1bc7
16 files changed
+415 -23

No files matched your search

+8 -1
View File
@@ -996,8 +996,15 @@ impl BooksServer {
}
.to_tool_error());
}
for aid in &attachment_ids {
for (n, aid) in attachment_ids.iter().enumerate() {
store.check_linkable(*aid).map_err(|e| e.to_string())?;
// Linked once each: a second link of one file to the new entry
// would be refused after the disposal was written.
if attachment_ids[..n].contains(aid) {
return Err(format!(
"receipt_attachment_ids names attachment {aid} twice: name each file once"
));
}
}
if buyer.is_none()
&& !proceeds.amount.is_zero()
@@ -112,6 +112,11 @@ impl BooksServer {
let (file_name, mime_type) = named(p.file_name, p.mime_type, &file)?;
let (bytes, claim) = (file.bytes, file.claim);
self.refuse_tin_file(&store, &bytes, &mime_type, &file_name)?;
// Bytes already filed are one file: a link it has is refused now,
// before the filing writes anything.
store
.check_filing_links(&bytes, &link_to)
.map_err(|e| e.to_string())?;
let (attachment_id, sha256, deduplicated) = store
.attach_receipt(
p.entry_id,
@@ -170,6 +175,11 @@ impl BooksServer {
let (file_name, mime_type) = named(p.file_name, p.mime_type, &file)?;
let (bytes, claim) = (file.bytes, file.claim);
self.refuse_tin_file(&store, &bytes, &mime_type, &file_name)?;
// Bytes already filed are one file: a link it has is refused now,
// before the filing writes anything.
store
.check_filing_links(&bytes, &link_to)
.map_err(|e| e.to_string())?;
let (attachment_id, sha256, deduplicated) = store
.file_document(
&p.category,
+3
View File
@@ -207,6 +207,9 @@ impl BooksServer {
.as_deref()
.map(|ps| parse_shares(&store, ps))
.transpose()?;
if let Some(r) = no_party {
ledger_core::Ledger::check_no_party_reason(r).map_err(|e| e.to_string())?;
}
if no_party.is_some() && (party.is_some() || vendor.is_some() || shares.is_some()) {
return Err(
"no_party_reason is for an entry with no counterparty: pass it without party, parties, or vendor".into(),
+3
View File
@@ -1778,6 +1778,9 @@ impl BooksServer {
.map(|r| resolve_party(&store, r))
.transpose()?;
// Every check before anything is journaled.
if let Some(r) = no_party {
ledger_core::Ledger::check_no_party_reason(r).map_err(bad)?;
}
store
.ledger()
.template_lines(&p.template_id, amount, &p.accounts)