---
id: WF-ACC-TRX-007
title: Resolve lost processor answers and clear bank debits
trigger: >-
  The minute recovery schedule scans active workspaces and staff resolve
  escalated uncertain operations.
product_area: accounting
module: transactions
revision: 1
status: draft
design_intent: proposed
implementation_evidence: observed
inference: []
source_sha:
  services-accounting: f47cb263875bbc0c5640fba7dae6785ec32695f8
  react-console: baf6dae382d6f41dce976c7f848667ccc37e076f
implements:
  - CAP-ACC-TRX-007
  - CAP-ACC-TRX-009
  - CAP-ACC-TRX-012
  - CAP-ACC-TRX-013
moves:
  - STATE-ACC-TRX-005
  - STATE-ACC-TRX-006
  - STATE-ACC-TRX-008
  - STATE-ACC-TRX-010
  - STATE-ACC-TRX-007
crosses:
  - SVC-ACC-TRX-transactions
hops:
  - 'n': 1
    actor_or_service: Payment intent sweeper
    action: >-
      Find unresolved financial operations by workspace and retrieve provider
      outcomes using a reference or due scheduled key lookup.
    anchor: >-
      services-accounting:modules/transactions/services/payments/intent-sweeper.ts:sweepIntentsOfEveryTenant
    seam: schedule
    on_failure: Record and count a workspace failure while continuing other workspaces.
    left_inconsistent: The affected workspace waits for a subsequent recovery pass.
    observer: Recovery metrics and logs identify the failed pass.
    provenance: observed
    source: >-
      services-accounting:modules/transactions/services/payments/intent-sweeper.ts:sweepIntentsOfEveryTenant;
      services-accounting:modules/transactions/tests/integration/services/payments/tender.integration.spec.js#it
      answers the payment to a replay of the same key, from what the processor
      holds, with no second charge
  - 'n': 2
    actor_or_service: Payment intent sweeper
    action: >-
      Apply retrieved outcomes, allowing definite charge failure after
      provider-reference absence exceeds its grace period while preserving
      refund and void uncertainty.
    anchor: >-
      services-accounting:modules/transactions/services/payments/payment-receive.ts:resolveIntentWithProcessor
    seam: schedule
    on_failure: Advance recovery when the next lookup becomes due after timeout.
    left_inconsistent: The operation remains unresolved.
    observer: The operation's recovery counters show lookup progress.
    provenance: observed
    source: >-
      services-accounting:modules/transactions/services/payments/payment-receive.ts:resolveIntentWithProcessor
  - 'n': 3
    actor_or_service: Lost answers
    action: >-
      Escalate exhausted scheduled lookups by committing a review marker with an
      attention item.
    anchor: >-
      services-accounting:modules/transactions/services/persistence/lost-answers.ts:publishLostAnswerAttention
    seam: event
    on_failure: Undo attention handover and retry it on a later pass.
    left_inconsistent: The charge request key remains held during human review.
    observer: >-
      The attention item routes unresolved collection to payment-exception
      staff.
    provenance: observed
    source: >-
      services-accounting:modules/transactions/services/persistence/lost-answers.ts:publishLostAnswerAttention;
      services-accounting:modules/transactions/tests/integration/services/payments/lost-answers.integration.spec.js#it
      hands the intent to a person at the last lookup: needs_review, the item
      published with its facts
  - 'n': 4
    actor_or_service: Accounting staff
    action: >-
      Record the staff-verified failure or capture outcome and resolve its
      attention item in the same transaction.
    anchor: >-
      services-accounting:modules/transactions/services/payments/lost-answer-commands.ts:settleLostAnswer
    seam: sync
    on_failure: Reject human resolution before review eligibility.
    left_inconsistent: Human resolution has closed the uncertain operation.
    observer: The operation and attention item show the human decision.
    provenance: observed
    source: >-
      services-accounting:modules/transactions/services/payments/lost-answer-commands.ts:settleLostAnswer;
      services-accounting:modules/transactions/tests/integration/services/payments/lost-answers.integration.spec.js#it
      refuses both decisions before the last lookup (lost_answer_not_in_review)
  - 'n': 5
    actor_or_service: Payment intent sweeper
    action: >-
      Resolve bank clearing, fail day-old settlements without an intent and
      abandon day-old processing intents outside review.
    anchor: >-
      services-accounting:modules/transactions/services/payments/intent-sweeper.ts:sweepProcessingIntents
    seam: schedule
    on_failure: Record the failure in logs and try again on another pass.
    left_inconsistent: Bank receipts remain awaiting clearing.
    observer: Abandonment appears in error logs.
    provenance: observed
    source: >-
      services-accounting:modules/transactions/services/payments/intent-sweeper.ts:sweepProcessingIntents
idempotency: >-
  Each resolver updates only eligible unresolved state and returns previously
  recorded outcomes after a race.
concurrency: >-
  Scheduled recovery shares record locks with other resolvers; competing
  resolution reads the winning result.
branches: []
waits:
  - >-
    Production key lookups use thirty-second, two-minute, ten-minute, one-hour
    and six-hour delays, with shorter development timing.
evidence:
  - >-
    services-accounting at f47cb263: services/payments/intent-sweeper.ts,
    intent-sweeper-cadence.ts, lost-answer-rules.ts, lost-answer-commands.ts;
    services/persistence/lost-answers.ts;
    attention/processor-answer-lost.attention.ts;
    aws/logic/payment-intent-sweeper.lambda.ts.
controls: [TC-IAM-001, TC-IAM-002, TC-IAM-004, TC-IAM-005, TC-IAM-006, TC-AZ-001, TC-AZ-002, TC-AZ-003, TC-AZ-004, TC-AZ-005, TC-AZ-006, TC-TEN-001, TC-TEN-002, TC-TEN-003, TC-CRY-001, TC-DAT-001, TC-DAT-002, TC-DAT-003, TC-LOG-001, TC-LOG-002, TC-LOG-003, TC-LOG-004, TC-LOG-005, TC-AVL-001, TC-AVL-004, TC-MON-001, TC-MON-002, TC-MON-004, TC-PI-001, TC-PI-002, TC-PI-003, TC-PI-004, TC-PI-005, TC-VEN-001, TC-VEN-002, TC-VEN-003, TC-PRV-001, TC-PRV-002]
---
# Resolve lost processor answers and clear bank debits

## What It Does

Recovery distinguishes provider-reference lookup from scheduled request-key lookup and from bank clearing. These paths have different definitive-failure and abandonment rules.

## The Flow

```mermaid
flowchart TD
  h0["Payment intent sweeper"]
  h1["Payment intent sweeper"]
  h0 --> h1
  h2["Lost answers"]
  h1 --> h2
  h3["Accounting staff"]
  h2 --> h3
  h4["Payment intent sweeper"]
  h3 --> h4
```

The numbered hops identify the participating services, synchronization boundary and evidence. Branch conditions in the frontmatter explain where preparation, completion and recovery diverge.

## When Something Fails

Each hop records its rollback, retry or compensation boundary and the result visible to callers or operators. External outcomes can remain unresolved after local preparation commits; the listed recovery behavior defines what remains pending.

## Open Design Questions

The abandoned-intent reconciliation exception remains unspecified; planning must also reconcile its broad empty-lookup guarantee with reference-based failure.
