feat(core): the engine refuses free text that looks like a tax id

Entry and reversal descriptions, write-off and void reasons, document
memos, references, duplicate reasons and line descriptions, asset
descriptions, serials and tags, period names, account codes, schedule and
recurring descriptions and payroll employee names now meet the one
free-text detector in the Ledger command itself (FreeTextHoldsTin), so a
caller other than the MCP layer cannot journal a tax id (BS-partner-2).
Replay never refuses (BS-entry-4). Draft notes, discard reasons, no-party
reasons and send references and notes move from the strict nine-digit
reading to the shapes (parties::check_note), as the owner chose on
2026-11-21; party fields, names and recipients keep the strict reading.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
This commit is contained in:
swaitsandClaude Fable 5.2 committed 2026-11-21 14:51:47 -07:00
1 parent ff58b055ce
commit 548901ce7d
9 files changed
+136 -18

No files matched your search

+17
View File
@@ -367,6 +367,13 @@ pub enum LedgerError {
)]
AccountNameHoldsTin,
/// Free text (a memo, a note, a reason, a description, a tag) that
/// looks like it holds a tax id: nine digits standing alone, or an
/// SSN's 3-2-4 or an EIN's 2-7 grouping (BS-partner-2). The words name
/// the field and where a tax id goes, never the number.
#[error("{0}")]
FreeTextHoldsTin(String),
/// A new account name (a new account's, or a rename's) that isn't one
/// line of text within the bound ([`crate::account::MAX_ACCOUNT_NAME`]
/// characters): every report, export and the IIF print it on one line.
@@ -993,6 +1000,16 @@ pub enum LedgerError {
ApprovalNeedsDraft(String),
}
impl LedgerError {
/// Free text a command may keep: it must not look like a tax id
/// ([`crate::settings::check_free_text`]; never refused in a replay).
/// `field` is how the refusal names it ("the memo", "the entry
/// description").
pub fn free_text(field: &str, text: &str) -> Result<(), LedgerError> {
crate::settings::check_free_text(field, text).map_err(LedgerError::FreeTextHoldsTin)
}
}
/// The refusal [`LedgerError::TaxCategoryRequired`] gives: what to pass,
/// and where the categories are listed.
fn tax_category_required_text(account: &str, clearing: bool) -> String {