feat(mcp): one check of every write tool's text for a tax id, from a table of its strings

Every string a write tool takes (423 across 78 tools) is classed in
text_fields::TABLE: 127 free text (refused when it looks like a tax id),
27 party fields (refused at any run of nine digits, as the engine does),
and 269 exempt for a named reason (vault input, lookup key, id, amount,
date, vocabulary, last four digits, bank pattern, link, a structured value
the engine reads). The check runs in call_tool before the tool or any
write, for previews too, and a refused call writes nothing (WB-format-10).
A test fails when a write tool has a string the table does not class, or
the table names one no tool takes. A string the table does not know is
free text. Annotations on a receipt (payee, source, note ...) meet the
engine's check as well.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
This commit is contained in:
swaitsandClaude Fable 5.2 committed 2026-11-21 14:57:58 -07:00
1 parent 548901ce7d
commit 7327d04897
6 files changed
+1379 -1

No files matched your search

+16
View File
@@ -74,6 +74,19 @@ impl AnnotationFields {
self.category = trim(self.category);
self.source = trim(self.source);
self.reimbursable_to = trim(self.reimbursable_to);
// Who, what and where in words: no tax id among them (BS-partner-2;
// not in a replay, which keeps the journal as written).
for (field, text) in [
("the payee", &self.payee),
("the payment method", &self.instrument),
("the category", &self.category),
("the source", &self.source),
("who is to be reimbursed", &self.reimbursable_to),
] {
if let Some(t) = text {
LedgerError::free_text(field, t)?;
}
}
if self.receipt_number == Some(0) {
return Err(LedgerError::InvalidEvidence(
"a receipt number is positive".into(),
@@ -111,6 +124,9 @@ impl Annotation {
.note
.map(|n| n.trim().to_string())
.filter(|n| !n.is_empty());
if let Some(n) = &self.note {
LedgerError::free_text("the note", n)?;
}
if self.fields.is_empty() && self.note.is_none() {
return Err(LedgerError::InvalidEvidence(
"an annotation records at least one field or a note".into(),
+1 -1
View File
@@ -8755,7 +8755,7 @@ impl Ledger {
&mut self,
annotation: crate::evidence::Annotation,
) -> Result<(), LedgerError> {
self.annotate_attachment(annotation)
crate::parties::replaying(|| self.annotate_attachment(annotation))
}
/// The entries `entry` records settling (`entry.settles`, plan P6).