Why a retry can mislead a daily report
Retrying a delivery is sometimes the safest response to a timeout. If the previous attempt already wrote, the retry arrives with events that may look new but are actually the same business fact. Without replay safety, the same order would contribute twice to a daily total.
This companion story uses the same synthetic retail-orders project as the flagship. The amount is integer AUD cents, dates are UTC, and the orders are not recognised accounting revenue. The pipeline that decides whether a retry is harmless is the one explained here.
What makes two events the same
Two rows describe the same business event when their event identifier is identical and the full raw payload matches. The pipeline records the raw payload as a SHA-256 hash alongside the event identifier in the event ledger. An empty or missing event identifier is quarantined first; a usable identifier with a different hash is treated as a conflicting payload, not as a duplicate.
- The event identifier alone is not enough: the same identifier with a different payload must be rejected, not silently collapsed.
- The full raw payload is hashed so the comparison does not depend on column ordering, whitespace or JSON formatting.
- Quarantine reasons are mutually exclusive; each invalid row receives one primary reason and stays as its own quarantine record.
How exact duplicates are handled
The pipeline keeps every original event row long enough to assign one primary quarantine reason to every invalid row, and to compare usable event IDs against the committed event ledger. Only after that does it collapse raw-identical valid events into a single accepted event.
The accepted unique event count is one number; the duplicate count is a separate number; the quarantined count is a third. The summary distinguishes them so the reader can see what the pipeline actually did with the input.
How conflicting events are handled
If a batch reuses an event identifier with a different raw payload, either within the same batch or against the committed ledger, the pipeline stops before any mutation. Nothing is written to the event ledger, the order state, the fact table or the daily groups.
This strict rejection is deliberate. Once two competing payloads share an event identifier, the pipeline cannot tell which one was the intended business fact. Continuing would risk accepting the wrong one; rolling back leaves the previous committed state authoritative and gives the operator a clear signal to investigate.
What replay changes and what it leaves unchanged
Replaying the same accepted batch against the committed ledger demonstrates idempotent application for this small local example. The unique valid events that were already accepted are recognised; their contribution to the committed state is not added again. The accepted unique event count for the replay is the same as the original batch, and the ignored event count includes those same events.
The current order facts, the daily groups and the quality checks are identical to the values produced by the original batch. The commit point is what makes that possible: the pipeline does not mix partial work into the visible state.
Why replay safety matters operationally
Replay safety is what lets a delivery system retry without auditing the previous attempt. A daily report would otherwise risk double-counting a corrected order, and a dashboard would risk presenting the same order twice. By recognising repeats before mutation, the pipeline can be retried at any point without changing the committed state.
For this synthetic project, replay safety is demonstrated inside one browser session against a small sample dataset. It does not prove exactly-once delivery across a broker, a database, a network or any other production side effect.
One meaningful design trade-off
The pipeline rejects a conflicting payload for an already-accepted event identifier instead of trusting the most recent source update. The alternative would let the more recent write win, which would simplify the source-code path but would also make the order fact dependent on the order of retries.
Rejecting the conflict preserves an auditable answer: the previous committed state stays visible, the operator is told the event identifier cannot be reused with a different payload, and the rejection is reported in the run summary rather than absorbed into a silent overwrite.
Evidence and limits of this explanation
The saved result below is shown only when its build, sample data, schema, SQL and runtime identities match this application. It is a captured browser run from a real pipeline, not a fabricated outcome. Its sample is the follow-up batch, which contains one raw-identical valid repeat and several events that the previous initial batch already accepted.
Replay-safety numbers a reader can read directly off the saved summary: the duplicate count of one is the raw-identical repeat the pipeline collapsed; the three ignored events are the accepted events that were already in the ledger and therefore contributed zero new state. Together they show that the retried batch did not add a second contribution from the same business event.
The grain of the summary is per-batch: input event rows reconcile to invalid rows, identical valid duplicates removed and unique valid events accepted. Current order facts are one row per order; daily groups are aggregates by UTC date and channel. Event totals, fact rows and daily groups are separate grains and should not be added together. The example proves behaviour for these small synthetic inputs and this browser pipeline. It does not establish production scale, accounting treatment, durable recovery or exactly-once delivery. If the engine cannot start, this explanation and the bundled SQL remain available.
Evidence mode: saved browser run captured from build 821aed49a48d with sample file SHA-256 464d7430a9cf and SQL SHA-256 cd70dcad203d. New local runs from the flagship are labelled separately.
Saved browser run, follow-up batch
A captured result from the synthetic project
This is a saved result from a real browser run, captured . It is separate from any new local run below.
- Input event rows
- 7
- Quarantined rows
- 1
- Identical valid repeats
- 1
- Orders inserted
- 1
- Orders updated
- 1
- Stale/no-op events
- 3
- Current order facts
- 5
- Current order value
- A$245.00
3 quality checks passed for this saved run.
| Order date (UTC)VARCHAR | ChannelVARCHAR | OrdersBIGINT | Order valueHUGEINT |
|---|---|---|---|
| 2026-01-01 | store | 1 | A$25.00 (2,500 cents) |
| 2026-01-02 | store | 2 | A$30.00 (3,000 cents) |
| 2026-01-02 | web | 2 | A$190.00 (19,000 cents) |
- Passed: state fact reconciliation
- Passed: daily mart reconciliation
- Passed: nonnegative order amounts
Build identity, asset hashes and measured timings
- Captured at
- Identity schema version
- 2
- Build identity
821aed49a48d31e2 405d54a1 f79325ff 67873684 6762ad4e fc63acf7 ec878460 - Sample file SHA-256
464d7430a9cf05b7 1e02ed1a 83d17876 0ad05cb1 a97d5a5b 1e203f26 5562b7c7 - Schema SHA-256
29db3589925d4d92 65565c18 7378e8df fae68c8f 6fe1f81c d46ef8f0 63542f9c - SQL SHA-256
cd70dcad203d30ce a9c10e55 10eef328 2e247a20 b8007109 10163047 7badd991 - Execution source SHA-256
f878c8f580ca044d f92b6bf9 899e9a68 39d22920 e9fced37 33fb2fcd cd5a3ac7 - Evidence trust source SHA-256
43cc24c47850b136 bb5f029f 49d249c4 85b0606b 2a18d594 0ddccd64 dbb3876f - DuckDB-Wasm package
- 1.32.0
- DuckDB SQL engine
- v1.4.3
- Worker initialization
- 0 ms
- Sample file load
- 7 ms
- SQL pipeline
- 101 ms
- Total run
- 119 ms
Timings describe this captured browser run; they are not a benchmark promise.
Read the flagship end-to-end story
The pipeline steps that decide replay safety
The architecture fragment below is the part of the flagship pipeline that decides whether a retried batch is a harmless repeat. The event identity gate checks the ledger; validation assigns one reason per invalid row; dedupe collapses only raw-identical valid events; the ledger and current state stages record what the replay contributes.
Select a stage to see its details. The diagram explains the pipeline and does not run it; the full explanation follows below.
- 01
Replay event identity gate
For each usable event identifier in the batch, compare the SHA-256 of its raw payload against the committed event ledger. Reject the batch if any identifier carries a different payload, so retries cannot silently overwrite prior accepted state.
- Inputs
- Original event rows from the retried batch; Committed event ledger with stored payload hashes
- Outputs
- Either a fatal conflict result that prevents mutation, or rows eligible for validation
- SQL queries
get_event_ledger, insert_event_ledger- Quality checks
- No quality check at this stage
- 02
Replay validation of every row
Assign one primary quarantine reason to each invalid row, including invalid repeats of an already-known event identifier. Repeated invalid rows remain separate quarantine records so the audit trail stays visible.
- Inputs
- Rows that passed the event identity gate
- Outputs
- Valid candidates; Quarantined rows with primary reasons
- SQL queries
create_event_ledger- Quality checks
- No quality check at this stage
- 03
Replay dedupe of valid events
After every row has been validated, collapse raw-identical valid event identifiers into a single accepted event. Dedupe never collapses rows that differ in payload, channel, date, version, timestamp or amount.
- Inputs
- Valid candidate rows
- Outputs
- Unique accepted events for this batch; Duplicate disposition count
- SQL queries
insert_event_ledger- Quality checks
- No quality check at this stage
- 04
Replay ledger and current state
Remember each unique accepted event, including those that are stale or no-op against the existing order state. The winning complete order state is chosen by source version, source update timestamp, then lexicographically greater event identifier.
- Inputs
- Unique accepted events from this batch; Committed event ledger and order state
- Outputs
- Updated event ledger; Winning current state per order, with replay events appearing as no-op or stale where applicable
- SQL queries
begin_transaction, insert_event_ledger, upsert_order_state, commit_transaction, rollback_transaction- Quality checks
- No quality check at this stage
On a narrow screen, follow the complete ordered list above.