Merge branch 't3/refuse-tax-ids-in-free-text': free text refuses a tax id's shapes; references take nine digits; bank files mask (WB-partner-15)

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
This commit is contained in:
swaitsandClaude Fable 5.2 committed 2026-11-21 16:56:02 -07:00
commit e7d5e4b8cd
36 files changed
+4353 -113

No files matched your search

+125
View File
@@ -116,6 +116,21 @@ is its TIN facts', else its W-9 facts'.
**Pick (BS-partner-8):** `outside-the-books`, the owner, 2026-10-15.
**CHOICE (the owner, 2026-11-21):** how text is read for a tax id depends
on what the text is: free text (a memo, a note, a reason, a description, a
reference, a class or project name) is refused only when it *looks like* a
tax id (nine digits standing alone, an SSN's 3-2-4 or an EIN's 2-7, with any
dash or space between, and a dot between all of an SSN's groups); a party's
own fields keep the strict reading (any run of nine digits); a bank file's
descriptions are kept with such a number masked to its last four digits.
Within that choice the lead decided on 2026-11-21 that a *reference field*,
an identifier by nature (an asset tag or serial, an invoice, bill, payment
or send reference, an account code, a file name, an instrument's label,
where a W-9 or W-4 is kept), refuses only the printed 3-2-4 and 2-7 shapes
and allows a bare nine digits, which is how a serial number or a check
number is written. WB-partner-15 states it, with the downsides the owner
accepted.
**Enforced:** `crate::parties` (has_full_tin, check_text, W9Facts::check,
W4Facts::check), `Ledger::add_party`, `update_party`, `set_party_role`,
@@ -303,6 +318,116 @@ directory read W-9 facts only, so a member's read as missing).
`books.export_cpa_package`, `books.party`. **Checked:** `ledger-core`
`tests/spec_parties.rs`; `ledger-cli` `tests/spec_vault.rs`.
**WB-partner-15** Free text meets a tax id's shapes, not every run of nine
digits (CHOICE, the owner, 2026-11-21). The refusal of BS-partner-2 reads
text two ways, on purpose:
- *Free text* (entry and reversal descriptions, memos, notes, reasons, a
discount's reason, line descriptions, class, project, period, asset and
schedule texts, a receipt's description and annotations, a decision's or
an item's words) is refused when it holds nine digits standing alone, or
an SSN's 3-2-4 or an EIN's 2-7 grouping joined by a hyphen or any other
dash or space (a line break is a space), in any Unicode form, with
zero-width and soft-hyphen characters not counted
(`settings::holds_printed_tin`). A dot joins an SSN's groups only when it
joins both (`000.00.0000`) and never an EIN's, so a coordinate
(`47.6062095`) passes; a group that starts or ends inside a longer run of
digits and dashes (a date's day then its reference, `2026-11-21 0001234`;
a part number) belongs to that run. An invoice number (`2026-11-0042`),
a phone number, an order number, a reference of ten digits or more, an
amount, a decimal and a date pass. Letters between digits, and a number
split across two fields, are left alone: an accident, not an evasion.
- *A reference field* (an asset's tag and serial number, a bill's and an
invoice's reference, a payment's and a send's reference, an account's
code, a file's name, an instrument's label, where a W-9 or W-4 is kept)
is an identifier by nature, and a bare run of nine digits is a legitimate
value there: only the printed SSN and EIN shapes are refused
(`settings::holds_printed_tin_in_reference`, the one detector without its
bare-nine group). The refusal's words are the same as for free text. An
entry's description, which is free text, shows a payment's reference with
such a run masked (`PaymentDetails::description`), and the audit reads
each journal field as its class.
- *A party's own fields* (a party's name and details, a customer's or
vendor's name, the customer's printed details on an invoice, a recipient,
an account name) keep the strict reading of WB-partner-4: any run of nine
digits (`has_full_tin`).
- *A bank file's description* is not typed by a person and often carries a
nine-digit reference, so a bank import is not refused for one: a number
that reads as a tax id is kept masked to its last four digits
(`•••-••-1234`, `settings::mask_printed_tins`), and the import's answer
says how many values were masked and on which lines (`masked_count`,
`masked`, `masked_note`). A rule that categorizes a transaction matches the
bank's own words, so one keyed on a nine-digit reference still matches;
what is kept is the masked text. A *chart* file is typed by a person: a
cell that looks like a tax id refuses the file, naming its row and column
(an account code is a reference: a bare nine digits is a code).
The downsides the owner accepted: a nine-digit bank reference or routing
number typed into a memo is refused (write its last four), and a tax id
typed with unusual spacing could slip into a memo, since the reading
catches an accident, not a deliberate evasion. The lead's, within them: a
bare nine digits in a reference field is kept, so a tax id written there
without its grouping is not caught.
Text the program composes from what the books already hold is never
refused: a depreciation or disposal entry's description names the asset as
the books hold it, and the asset's description may hold a shape from before
this reading, so such a composed line holds it masked to its last four
(`settings::mask_printed_tins`), as a reference in a payment's description
and an issued invoice's file name do. The vault, the party fields
and the file check of WB-partner-7 stand around it.
The reading is made in two places that agree. Every `Ledger` command that
takes free text refuses it (`LedgerError::FreeTextHoldsTin`), so a caller
other than the tools cannot journal one, and a journal line an earlier
version took still replays whatever it holds (BS-entry-4), so no books are
refused for opening. And the tools check every string of every write tool
once, before any call runs or writes anything (WB-format-10), from one
table that classes each string as free text, a reference, a party field, or
exempt for a named reason (the vault's input, a lookup key, an id, an amount, a date, a
fixed vocabulary, the last four digits, a bank pattern, a link, a value
the engine reads); a test fails when a write tool has a string the table
does not class. The refusal names the field, says it looks like a tax id and
that tax ids are stored with `books.set_tin` or a W-9 (`books.set_w9`), and
never repeats the number.
Books that already hold such a line are never rewritten and always open;
`books.audit` names the journal line and the field in a `tax_id_in_journal`
warning, and never the number.
**Enforced:** `settings::holds_printed_tin`, `settings::mask_printed_tins`,
`settings::holds_printed_tin_in_reference`,
`settings::mask_printed_tins_in_reference`, `settings::check_free_text`,
`settings::check_reference_text`, `parties::check_note`,
`parties::check_reference_note`, `PaymentDetails::check`,
`PaymentDetails::description`, `Ledger::try_create_entry`,
`Ledger::reverse_entry`, `Ledger::create_invoice_with`,
`Ledger::create_bill_with`, `Ledger::register_asset`,
`Ledger::create_period`, `Ledger::annotate_attachment`,
`Ledger::check_no_party_reason`, `Ledger::renumber_account`,
`Ledger::set_asset_tag`, `Ledger::set_asset_serial`; `ledger-mcp` `text_fields`,
`books.import_bank_csv`, `books.import_chart_csv`; `ledger-import`
`parse_bank_csv_masked`, `parse_chart_csv`; `ledger-store`
`integrity_findings`, `Store::attach_receipt`, `Store::file_document`,
`Store::unlink_receipt`, `Store::withdraw_attachment`, `Store::review_entry`.
**Checked:** `ledger-core` `tests/free_text_tin.rs`
(every grouping with every separator is found, a dot between all of an
SSN's groups only, a date and its reference or a decimal never, a line break
or a zero-width character does not hide one, nine digits alone, a reference
takes nine digits, the allow-list passes, each command refuses, the engine
refuses a project's field, a payment's reference and a discount's reason, a
replay never does);
`ledger-mcp` the unit tests in `text_fields.rs` (every string a write tool
takes is classed) and `a_call_with_a_tax_id_in_free_text_is_refused_unrun_and_writes_nothing`;
`ledger-import` the unit tests in `bank_csv.rs` and `chart_csv.rs`;
`ledger-store` `tests/audit.rs` (the store's own texts, and a journal line
an earlier version took opens and is named by the audit) and
`tests/free_text_old_books.rs` (an old asset still depreciates and is
disposed of, the lines hold the masked form, the audit reads a reference as
one); `ledger-cli`
`tests/tin_in_text.rs` (through the real server: a refusal writes nothing,
a reference is kept, a bank file is masked, a chart file is refused).
## B-35 A party's part of an entry, and a party's totals
**bookspec:** `BS-partner-3`