Skip to content

Atomic Split Payment Rollback Coordinator #520

Description

@Kingsman-99

Description

Multi-recipient split payments consist of several payment operations grouped in one transaction, but when a partial failure occurs at the application layer (e.g. post-submission webhook failure, database write failure), the SDK provides no mechanism to track which portions of the split were acknowledged and coordinate a corrective resubmission or reversal. A rollback coordinator should record split state atomically and provide a reconciliation primitive.

Technical Context

Add src/splitRollbackCoordinator.ts. Integrates with src/snapshot.ts for state persistence. Reads SplitResult and SplitLeg from src/types.ts. Uses src/idempotency.ts to prevent double-reversal. Hooks into src/client.ts submitPayment() post-submission lifecycle. Emits splitRollbackInitiated and splitRollbackCompleted via src/events.ts.

Acceptance Criteria

  • RollbackCoordinator.begin(splitId) creates a persistent rollback checkpoint recording all intended split legs
  • RollbackCoordinator.markLegSuccess(splitId, legIndex) and markLegFailed(splitId, legIndex) update the checkpoint atomically
  • RollbackCoordinator.getIncomplete(splitId) returns the set of legs that neither succeeded nor are confirmed failed
  • RollbackCoordinator.initiateRollback(splitId) emits splitRollbackInitiated and stores a rollback record in src/snapshot.ts
  • Integration test simulates a post-submission failure, calls initiateRollback, and asserts the checkpoint reflects the correct incomplete legs
  • All CI checks (npm test, npm run build, ESLint/TypeScript) pass and the branch has no merge conflicts

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions