feat(mcp): bulk-link documents to vouchers in one staged approval (#1411)

gnubok_link_documents_to_vouchers stages up to 300 document-to-verifikat
links as a single pending operation, addressed by voucher_series /
voucher_number / fiscal_year instead of journal_entry_id UUIDs, for bulk
receipt-migration jobs where N separate tools mean N separate approvals.

Staging resolves every row server-side and returns a per-row hit or miss,
so a systematic offset such as a wrong fiscal_year is visible before
anything is approved rather than after N approvals. Only resolved rows
enter the staged operation.

The WORM precondition and the document lookup are shared with the
single-document executor through precheckDocumentLink: a bulk call must
enforce exactly the invariants N single calls would, and a second copy of
a BFL 5 kap 6 § guard is a copy that keeps the old behaviour when the
first is hardened.

A batch that links nothing returns 409 instead of a committed no-op.
Partial skips stay committed, but an approval-gated operation on
räkenskapsinformation must not leave an audit record asserting a run that
changed nothing.

The tool is search-only: a one-off migration tool does not belong in the
default catalog every session pays for in context, and keeping it there
pushed the tools/list projection past the 58.5K token ceiling that
payload-size.bench.test.ts guards.

Co-authored-by: Jakob Wennberg <311770904+jakobwennberg-oss@users.noreply.github.com>
Co-authored-by: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
bjornbergenheim
2026-08-17 14:52:58 +02:00
committed by GitHub
co-authored by Jakob Wennberg Claude Fable 5
parent 4300cb711b
commit 3841ab9f54
12 changed files with 682 additions and 32 deletions
+1
View File
@@ -674,6 +674,7 @@
"type_convert_invoice": "Convert invoice",
"type_attach_document_to_transaction": "Attach document",
"type_link_document_to_voucher": "Link document",
"type_link_documents_to_vouchers": "Link documents (bulk)",
"type_link_invoice_voucher": "Link invoice",
"type_link_supplier_invoice_voucher": "Link supplier invoice",
"type_link_transaction_journal_entry": "Link transaction",
+1
View File
@@ -674,6 +674,7 @@
"type_convert_invoice": "Konvertera faktura",
"type_attach_document_to_transaction": "Bifoga underlag",
"type_link_document_to_voucher": "Länka underlag",
"type_link_documents_to_vouchers": "Länka underlag (bulk)",
"type_link_invoice_voucher": "Länka faktura",
"type_link_supplier_invoice_voucher": "Länka leverantörsfaktura",
"type_link_transaction_journal_entry": "Länka transaktion",