Skip to content

Execution

Crypto workflow trigger deduplication

A trigger retry can multiply analysis and journal work before an order check runs. Define the admitted run, freeze its context and recover missing branches.

Four ivory square tokens approach a dark gate; one lime token sits beside three ivory paths ending in circular dishes.
Illustration for execution; examples in this article are educational.

A crypto workflow should deduplicate triggers by mapping each source occurrence to one durable run before any branch starts. Retries must resolve to that run, while distinct candles, intended destinations and authorized reruns remain distinguishable. Trigger deduplication limits duplicate evaluations; it does not authenticate a webhook or guarantee that exchange orders execute once.

Count runs before counting orders

One trigger may start an AI analysis branch, a deterministic signal branch and a journal branch. If the same occurrence starts four runs, each branch can evaluate four times before an execution control notices anything wrong. Extra model calls, competing decisions and repeated notifications remain problems even if a later order check blocks additional trades.

Repeated delivery is normal for some providers. TradingView's webhook resubmission policy specifies a resend after five seconds for HTTP 500–599 responses except 504, with up to three resends. That permits four sends for one trigger under that policy; it does not describe every failure or provider.

The admission question is therefore: “Has this occurrence already been assigned a run for this destination?” Ask it before fan-out, meaning the point where one run splits into several branches. A valid answer can be an existing run that completed without trading.

Define the identity boundary

Keep three identities separate: the occurrence, each delivery attempt and the run admitted for a particular workflow destination. An attempt's arrival time changes on retry. A run ID generated afresh for every arrival also changes. Neither alone identifies the repeated occurrence.

The CloudEvents 1.0.2 event specification provides a useful model: producers make the combination of source and event ID unique for distinct events, and consumers may regard identical source and ID values as duplicates. This is an event-format convention, not evidence that a particular chart alert implements it or always preserves an ID across retries.

For a sender with a reliable stable ID, bind that identity to a trusted workflow destination and environment. One event may legitimately feed two subscribed workflows, each receiving its own run. A retry addressed to the same subscription should retrieve the same run.

When no stable ID exists, define an occurrence key from documented source semantics. For a candle trigger, that could include venue, product, instrument, interval, interval anchor, candle opening timestamp and trigger rule identity. Use the candle-close trigger contract to establish those fields. “BTC buy” or a rounded arrival minute cannot distinguish separate legitimate signals.

A payload hash is useful conflict evidence but a poor universal identity. Whitespace can change without changing meaning, and identical payloads can represent separate scheduled occurrences. Define which fields are immutable and how their comparable representation is constructed.

Fill out a run-admission worksheet

This worksheet describes a design to evaluate, not a list of KLINEO configuration controls.

ItemIllustrative choiceRequired interpretation
Occurrence identitySource S, event AOne upstream occurrence, independent of delivery attempts
Destination scopeSubscription W, paper environmentOne admitted evaluation for this subscription; live is a separate authorized destination
Stable admission lookupDestination scope plus occurrence identityLocate the existing run before selecting new execution work
Frozen run contextWorkflow revision 7 and saved input referencesRedelivery preserves the context selected at first admission
Immutable-content digestDigest of specified occurrence fieldsSame identity with changed content is a conflict to investigate
Run outcomePending, running, completed, skipped or failedA failed or skipped run still belongs to its original occurrence
Branch launch identityRun ID plus branch slotRecovery finds missing branch work without starting a fresh run
Recovery and retentionRecorded policy and expiry boundariesLate deliveries have an explicit outcome after normal processing ends

Keep revision selection out of a lookup that would turn every deployment into a new occurrence. If event A was admitted under revision 7, redelivery after revision 8 is deployed should find A's original run. Store the chosen revision on that run. Applying revision 8 to historical data is a separately authorized research rerun, linked to the original occurrence.

Four deliveries, three branches

Consider a hypothetical workflow with exactly three branch slots: analysis, signal and journal. Event A arrives four times because of redelivery. Event B is the next distinct candle. Both are addressed to the same paper subscription. The following outcomes are design expectations, not measured platform behavior.

Arrival or recovery caseRun-admission resultNew logical branch launches
First A deliveryCreate run R-A with its frozen contextThree
Concurrent second A deliveryRetrieve R-A after the atomic admission decisionZero
Third A delivery after completionReference R-A and its recorded outcomeZero
Fourth A delivery after restartRecover R-A from durable storageZero
First B deliveryCreate distinct run R-BThree
A identity with changed immutable signal fieldsFlag a conflict; preserve R-AZero
Worker resumes R-A after two branch slots were recordedSchedule the missing slot under R-AOne missing slot; no new run

Without admission deduplication, four A deliveries could create 4 × 3 = 12 logical branch launches. With the worksheet's rule, A creates three. Adding B brings the total to 3 + 3 = 6, rather than 12 + 3 = 15. The recovery row completes A's existing set of three; it does not add a fourth slot. Worker attempts may still exceed logical launches, so branch operations need their own retry rules.

This controls cardinality, not capital. If multiple accepted branches can change exposure, branch risk budgets determine how their permitted commitments interact. One admitted run can still contain several independent trading actions.

Make admission and launch recoverable

A separate “does this exist?” read followed by an insert allows two arrivals to both observe absence. Use a shared uniqueness boundary. For example, PostgreSQL's INSERT documentation explains how a unique constraint or index can arbitrate conflicting inserts, with ON CONFLICT DO NOTHING avoiding the duplicate insertion. Only a successful new admission should create a new run.

Persist the accepted identity, run and pending launch work together where the storage design permits. Otherwise, document how recovery detects the gap. Marking an occurrence accepted and then crashing before queuing its branches can silently lose the run. Queuing branches first and recording admission later can multiply them.

A durable pending-work record can let recovery schedule unfinished branch slots. Queue delivery may itself repeat; each branch must recognize its run and slot rather than assume one delivery. See safe branch merging for how downstream joins account for branch completion. A completion counter alone is unsafe if repeated messages increment it twice.

Cases that must stay separate

Two source IDs reporting the same market condition are not automatically duplicates. They may describe different markets, observation times or definitions. Only coalesce them when an explicit upstream mapping proves they represent the same occurrence under the workflow's policy. Otherwise evaluate their meanings using the contradictory-source worksheet; identity matching cannot settle factual disagreement.

Likewise, admission is separate from the security checks in webhook replay protection. A unique event can be unauthenticated or stale. A duplicate with a valid signature still belongs to its previous run. Do not erase accepted identities merely to make an old signal appear new.

Finally, a failed branch must not authorize a fresh whole-workflow run that repeats completed actions. An exchange submission with an unknown result needs the order idempotency and recovery rules attached to that action. Deduplicating triggers cannot resolve whether an order already traded.

Check the admission record under failure

Test two simultaneous copies, a restart after admission but before launch, repeated queue deliveries, a deployment between retries, changed content under the same ID and a legitimate new candle with identical values. Also test arrival after the retention boundary. A short-lived cache can admit an old occurrence as new after eviction; retain evidence for the supported redelivery horizon and define what happens outside it.

For each test, inspect the number of admitted runs, frozen revisions, logical branch slots and recorded duplicate reasons. Include skipped runs in the counts. Use an isolated harness or an available paper environment; paper validation explains why simulated execution evidence has limits. The acceptance target is an explainable run history, including deliberate reruns and unresolved failures.

This AI-assisted educational article follows the editorial policy. Primary sources were reviewed on October 23, 2026. The worksheet is a proposed architecture and does not establish that KLINEO exposes or implements its admission controls.

Keep the context with the example.

Each worked example is illustrative, with its sources and assumptions in the article. Read our editorial standards for authorship, verification and corrections.