feat(act): idempotent actions via correlation-based deduplication#574
Closed
feat(act): idempotent actions via correlation-based deduplication#574
Conversation
Add optional correlation field to Target. When provided, action() checks for existing events with that correlation on the stream before executing — if found, returns original events without re-execution. Reuses the existing correlation field and index in event metadata. No new store methods, tables, TTL, or cleanup — the correlation lives in the immutable event log. - Target type: optional correlation?: string - event-sourcing.ts: dedup check before action execution - 7 unit tests: dedup, different streams, no-correlation, multi-event - README: design decision documenting approach vs other frameworks - CLAUDE.md: idempotent actions section Closes #567 Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Owner
Author
|
Reverting after deeper analysis. Correlation-based deduplication has critical holes:
Act relies on optimistic concurrency for conflict detection. Request-level idempotency belongs in the API middleware layer (tRPC, Express) with a dedicated dedup cache — the established pattern used by production systems. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
correlationfield toTargetfor safe client retriesaction()checks for existing events with that correlation on the stream before executing — if found, returns original events without re-executionOther frameworks (Axon, Eventuous, Marten) use dedicated deduplication stores with TTL and background cleanup. Act reuses what's already there — the correlation ID in the immutable event log.
Test plan
pnpm test— 754 tests pass (7 new idempotency tests)pnpm typecheck— cleanCloses #567
🤖 Generated with Claude Code