MessageDeduplicator with TTL-based dedup cache #630

Closed
opened 2026-10-27 13:37:06 +00:00 by sam · 0 comments
Owner

Prevent duplicate processing of the same platform message. At-least-once delivery (webhook retries, Telegram long-poll re-fetch after a slow ack, forge redelivery) can hand the gateway the same MessageEvent more than once; without a dedup layer it gets answered twice.

Context for implementers

internal/gateway/messageevent.go already carries a platform-assigned ID field (MessageEvent.ID, see line ~59) suitable as a dedup key alongside ChannelID/Platform. There is currently no dedup file in internal/gateway — this is new code, not a rename. Related but distinct: archie-core-ippu (gateway: replay and redelivery lose tool activity) covers a different symptom — a replayed turn losing its tool-call history in the transcript, not a duplicate inbound message being processed twice. Fix this one first; it may reduce (but won't eliminate) triggers for the other.

Acceptance Criteria

A MessageDeduplicator (or equivalent) keyed on platform + channel + message ID rejects a second delivery of the same message within a configurable TTL window. TTL expiry is covered by a test using an injected clock, not a real sleep. Memory use is bounded (LRU or TTL sweep), not an unbounded map.

Close reason

Closed


Imported from beads archie-core-1786637492498-104-1bde76ae · GitHub #125 · type task · priority P2 · created 2026-08-08 · closed 2026-10-01

Prevent duplicate processing of the same platform message. At-least-once delivery (webhook retries, Telegram long-poll re-fetch after a slow ack, forge redelivery) can hand the gateway the same `MessageEvent` more than once; without a dedup layer it gets answered twice. ### Context for implementers `internal/gateway/messageevent.go` already carries a platform-assigned `ID` field (`MessageEvent.ID`, see line ~59) suitable as a dedup key alongside `ChannelID`/`Platform`. There is currently no dedup file in `internal/gateway` — this is new code, not a rename. Related but distinct: `archie-core-ippu` (gateway: replay and redelivery lose tool activity) covers a different symptom — a replayed *turn* losing its tool-call history in the transcript, not a duplicate inbound message being processed twice. Fix this one first; it may reduce (but won't eliminate) triggers for the other. ### Acceptance Criteria A `MessageDeduplicator` (or equivalent) keyed on platform + channel + message ID rejects a second delivery of the same message within a configurable TTL window. TTL expiry is covered by a test using an injected clock, not a real sleep. Memory use is bounded (LRU or TTL sweep), not an unbounded map. ### Close reason Closed --- _Imported from beads `archie-core-1786637492498-104-1bde76ae` · GitHub #125 · type task · priority P2 · created 2026-08-08 · closed 2026-10-01_
sam added the mediumtask labels 2026-10-27 13:37:06 +00:00
sam self-assigned this 2026-10-27 13:37:06 +00:00
sam closed this issue 2026-10-27 13:37:06 +00:00
sam added a new dependency 2026-10-27 13:42:12 +00:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Reference: sam/archie#630