* feat(mcp): structured supplier-resolution failure with candidates in create_supplier_invoice_from_inbox
When supplier resolution failed (no match on id, org_number, or exact
name), the tool threw an opaque error — a dead end for the inbox
pipeline on small ad hoc vendors, which are most of the backlog
(agent.feedback). The error prose did mention supplier_id_override, but
gave the agent no candidate ids and no machine-readable next step.
Resolution failure now returns the staged-operation envelope with
staged:false: preview carries the extracted supplier identity and
near-miss candidates (normalized-name + org-digit matching — catches
punctuation/legal-suffix OCR variants like "Polarn o Pyret" vs
"Polarn O. Pyret AB", and formatted org numbers '556677-8899' vs
'5566778899'); next hints either retry-with-override on the best
candidate or a prefilled gnubok_create_supplier. Fuzzy scores never
auto-resolve — the agent confirms against the underlag.
Part of dev_docs/mcp_optimization_plan.md (P1-4).
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
* fix(mcp): review fixes — EF org-number forms, candidate-pool truncation flag, override tenancy validation
Addresses the three substantive review-bot findings on #873:
- orgNumberKey(): canonical 10-digit key. Swedish orgnr is exactly 10
digits; enskild firma org numbers are personnummer that appear in both
10- and 12-digit forms — exact digit-equality missed that legitimate
match, and >= 10 accepted non-orgnr garbage lengths.
- No silent caps: preview.candidate_pool_truncated + message note when
the 500-supplier candidate pool is hit.
- The defaults fetch now validates supplier existence in THIS company on
every resolution path and rejects a bad supplier_id_override with a
clear error — the unresolved next-hint actively promotes overrides, so
a bogus id must fail at staging, not opaquely at commit.
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
---------
Co-authored-by: Claude Fable 5 <noreply@anthropic.com>