Skip to content

docs: correct replayFromLedger idempotency claims in JSDoc and swagge…#969

Open
CHKM001 wants to merge 1 commit into
LabsCrypt:mainfrom
CHKM001:docs/replay-from-ledger-jsdoc-808
Open

docs: correct replayFromLedger idempotency claims in JSDoc and swagge…#969
CHKM001 wants to merge 1 commit into
LabsCrypt:mainfrom
CHKM001:docs/replay-from-ledger-jsdoc-808

Conversation

@CHKM001

@CHKM001 CHKM001 commented Jun 30, 2026

Copy link
Copy Markdown

PR #808 [Docs] Correct replayFromLedger idempotency claims in JSDoc & swagger summary

Closes #808

Summary

The replayFromLedger JSDoc falsely claimed that worker deduplication guarantees idempotent replay. This is only true for StreamEvent rows (via the @@unique([transactionHash, eventType]) constraint), but not for stream state mutations like Stream.withdrawnAmount in handleTokensWithdrawn.

Changes

backend/src/services/indexerService.ts

  • Updated the replayFromLedger JSDoc to:
    • Clearly state that the @@unique([transactionHash, eventType]) constraint guarantees no duplicate StreamEvent rows on replay
    • Add a CAVEAT noting that stream state mutations (e.g., Stream.withdrawnAmount in handleTokensWithdrawn at soroban-event-worker.ts:635) are not idempotent — they execute unconditionally on every replay
    • Cross-reference issue [Docs] replayFromLedger JSDoc falsely claims worker dedup guarantees idempotent replay #808 for the withdrawnAmount idempotency fix

backend/src/routes/v1/admin.routes.ts

  • Changed the /v1/admin/indexer/replay swagger summary from (idempotent) to (StreamEvent rows deduplicated; stream mutations not idempotent — see indexerService.ts JSDoc)

Non-idempotent mutations

Handler Mutation Idempotent?
handleTokensWithdrawn Stream.withdrawnAmount increment No — double-counts on replay
handleStreamToppedUp depositedAmount / endTime update No
handleStreamCancelled isActive / withdrawnAmount update No
handleStreamCompleted isActive update No
handleStreamPaused isPaused update No
handleStreamResumed totalPausedDuration update No
handleStreamCreated stream.upsert Yes
handleFeeCollected streamEvent.upsert only Yes
handleFeeConfigUpdated streamEvent.upsert only Yes
handleAdminTransferred streamEvent.upsert only Yes

Files touched

  • backend/src/services/indexerService.ts
  • backend/src/routes/v1/admin.routes.ts

Out of scope

Closes #808

…r summary

Updates the replayFromLedger JSDoc to clarify that the
@@unique([transactionHash, eventType]) constraint guarantees
StreamEvent row dedup, but Stream.withdrawnAmount increments in
handleTokensWithdrawn are NOT idempotent on replay.

Updates the /v1/admin/indexer/replay swagger summary to match.

Refs LabsCrypt#808
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Docs] replayFromLedger JSDoc falsely claims worker dedup guarantees idempotent replay

1 participant