feat(event-process): integrate IdempotencyService dedup into handle() (EVO-1211)#42
Open
nickoliveira23 wants to merge 1 commit into
Open
feat(event-process): integrate IdempotencyService dedup into handle() (EVO-1211)#42nickoliveira23 wants to merge 1 commit into
nickoliveira23 wants to merge 1 commit into
Conversation
… (EVO-1211) Implements story 3.5: after signature validation, the pipeline computes a sha256 of rawPayload and calls IdempotencyService.checkAndMark — a duplicate within the TTL is dropped (ack, no throw) and counted, while a first-seen event proceeds. Runs after signature validation so forged payloads never reach Redis; the hash covers only rawPayload so a different header can't mask a legitimate duplicate. - EventProcessService: inject IdempotencyService (@global), isDuplicate() gate, shared rawPayloadString() helper reused by the signature path - EventProcessMetrics: evo_webhook_event_duplicates_dropped_total{platform} - specs: AC1 (second identical dropped + metric), AC2 (bit-different payload is not a duplicate), and idempotency-runs-after-signature ordering The safety lock (acquireLock/releaseLock) is wired by 3.7 (EVO-1213) when persist exists; checkAndMark-only is the at-most-once gate for 3.5. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
There was a problem hiding this comment.
Sorry @nickoliveira23, you have reached your weekly rate limit of 500000 diff characters.
Please try again later or upgrade to continue using Sourcery
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
Implements story 3.5 (Webhook Event Pipeline): integrates the shared
IdempotencyService(2.4) intoEventProcessService.handle()to drop duplicate provider webhooks.sha256(rawPayload)viaIdempotencyService.computeHashand callscheckAndMark(hash):false(already seen within the 1h TTL) drops silently (ack, no throw) and increments the metric;true(first seen) proceeds.rawPayload(per the card) — folding in headers/metadata would mask legitimate duplicates that arrive with a different header.rawPayloadString()helper is reused by the signature path.Security
ack(never a throw), so a rejected payload is not redelivered forever.Notes
checkAndMark-only is at-most-once: it marks the hash before downstream processing exists. There is nothing to protect yet (enrichment 3.6 / persist 3.7 are not wired intohandle()). When story 3.7 adds the ClickHouse persist, the safety lock (acquireLock/releaseLock, already inIdempotencyService) should bridge the mark→persist window so a persist failure can retry instead of losing the event. Out of scope here per the 3.5 card.sha256(rawPayload)without platform (per the card's "no headers/metadata"); cross-platform byte-identical bodies are effectively impossible (each provider body carries unique ids).event-process.module.tschange:IdempotencyModuleis@Global, soIdempotencyServiceinjects directly.Test plan
evo-flow: npm run typecheck— cleanevo-flow: npx jest src/runners/event-process/services/event-process.service.spec.ts— 9 examples, 0 failuresevo-flow: npx eslint <changed .ts>— cleanCovers ACs: second identical message dropped +
event_duplicates_droppedincrements (AC1); a bit-different payload yields a different hash and is not deduped (AC2); plus idempotency-runs-only-after-signature ordering.Changed Files
src/runners/event-process/services/event-process.service.tssrc/runners/event-process/metrics/event-process-metrics.tssrc/runners/event-process/services/event-process.service.spec.tsLinked Issue