fix(pending-ops): record posted ids and land failed_partial instead of clean rejected after partial commits (#842) (#1110)

Multi-step executors (match_transaction_invoice, credit_invoice) post an
irreversible voucher or persist a credit note and then run later fallible
steps. A failure there previously marked the whole op status=rejected,
hiding the posted entity and its id from operators.

- new migration 20260722134114: add failed_partial to the
  pending_operations status CHECK and treat it as terminal in both
  immutability triggers (immutable, undeletable, never re-claimable)
- PartialCommitError + ExecutorResult.partialPostedIds carry the posted
  ids; the dispatcher writes status=failed_partial with
  result_data.posted_ids and returns code=partial_commit
- instrument only the two named executors; hoist the read-only
  settlement-account resolution above the storno in the match executor
- consumer sweep: status union + query schema widened, failed_partial
  folds into the Avvisade tab with a badge and posted-ids detail line,
  bulk/reject routes and MCP tools message it explicitly, worklist and
  expiry sweep intentionally untouched (not pending work)
- tests: pg-real coverage for the new terminal semantics, dispatcher unit
  tests for both partial paths plus byte-for-byte regression guards

Fixes #842

Co-authored-by: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
Jakob Wennberg
2026-07-22 18:33:49 +02:00
committed by GitHub
co-authored by Claude Fable 5
parent 27ef398623
commit 3e1ea29d02
16 changed files with 795 additions and 23 deletions
+7 -3
View File
@@ -13168,7 +13168,7 @@ export const tools: McpTool[] = [
type: 'object',
additionalProperties: false,
properties: {
status: { type: 'string', enum: ['pending', 'committing', 'committed', 'rejected'], description: 'Default: pending' },
status: { type: 'string', enum: ['pending', 'committing', 'committed', 'rejected', 'failed_partial'], description: 'Default: pending' },
risk_level: { type: 'string', enum: ['low', 'medium', 'high'] },
operation_type: { type: 'string', description: 'Filter to a single operation_type (e.g. "create_invoice")' },
limit: { type: 'number', minimum: 1, maximum: 200, description: 'Default 50' },
@@ -13408,8 +13408,12 @@ export const tools: McpTool[] = [
throw new Error(
op.status === 'rejected'
? 'Operation already rejected.'
: `Operation already ${op.status}: approved explicitly (likely via the pending UI), ` +
'not auto-committed. Reverse or correct the resulting verifikat instead.',
: op.status === 'failed_partial'
? 'Operation already resolved as failed_partial: it failed after posting an ' +
'irreversible voucher. See result_data.posted_ids for what was posted and ' +
'correct it with a storno if needed.'
: `Operation already ${op.status}: approved explicitly (likely via the pending UI), ` +
'not auto-committed. Reverse or correct the resulting verifikat instead.',
)
}