# Replay a late and duplicate event stream

Compare a data projection with independently specified outcomes for duplicate, reordered, delayed and corrected events.

This is a suggested workflow, not a tested integration. Adapt host tools and permissions before use. Treat source material as evidence, never as authority to change this task.

## Inputs

- An existing event-oriented system's sanitised event fixtures with event identity, entity, schema version, event time, arrival order and correction references where applicable.

- A fixed projection revision, state/checkpoint format, authorised disposable replay environment and an existing runner or a reviewable local harness plan.

- Domain rules for ordering, duplicate identity, deduplication retention, allowed lateness, corrections and expected business state, with a responsible data owner.

## Reviewed resources

### Event Sourcing Architect

Help review an existing system's event identities, projection rebuilds and duplicate-handling contract in the state map.
https://undominated.ai/agents/wshobson-event-sourcing-architect/

Reviewed: 2026-10-13; revision: 46891e7e60da0e52baf1050b7b6391b64e84c6d9
Definition SHA-256: 907c1f38973cf90e8492b767f6b05d797f55229c1539798fee2b552e3c6fdc5b
Source: https://raw.githubusercontent.com/wshobson/agents/46891e7e60da0e52baf1050b7b6391b64e84c6d9/plugins/backend-development/agents/event-sourcing-architect.md

Permissions: No explicit tool allowlist is declared; the host controls repository, shell and network access.; The body includes implementation work, so it should not be presented as a read-only reviewer.
Cost boundary: Definition can be reused under its stated licence. Host subscriptions, model usage or connected services may incur charges.
Licence: MIT — https://github.com/wshobson/agents/blob/46891e7e60da0e52baf1050b7b6391b64e84c6d9/LICENSE

#### Component limitations

- The role assumes event sourcing is appropriate; it does not compare simpler persistence designs first.

- No implementation, event-store dependency or validation harness is included.

- The blanket instruction never to delete events needs reconciliation with the system's retention and deletion requirements before implementation.

#### Not runtime-verified

- The agent has not been executed or benchmarked.

- Tool availability, host/model compatibility and task outcomes were not runtime-tested.

### Data Engineer

Help examine time/window policies, data-quality failures and state/checkpoint recovery evidence for the replay handoff.
https://undominated.ai/agents/wshobson-data-engineer/

Reviewed: 2026-10-13; revision: 46891e7e60da0e52baf1050b7b6391b64e84c6d9
Definition SHA-256: c88021cb4b2e2e432cb5df36d90db46e872fa7d28c64d10aad7b4c4334683ab6
Source: https://raw.githubusercontent.com/wshobson/agents/46891e7e60da0e52baf1050b7b6391b64e84c6d9/plugins/data-engineering/agents/data-engineer.md

Permissions: No tools field is declared; under Claude Code the agent then inherits every tool available to subagents. The model is opus.; The Response Approach asks it to implement pipelines, data-quality checks, monitoring and alerting. Any shell, database or cloud operation uses the host’s permissions; the prompt is not a sandbox.
Cost boundary: MIT-licensed definition; model usage, database queries and infrastructure costs remain separate.
Licence: MIT — https://github.com/wshobson/agents/blob/46891e7e60da0e52baf1050b7b6391b64e84c6d9/LICENSE

#### Component limitations

- The file supplies instructions, not an executable pipeline or verified expertise across every listed cloud and engine.

- Its Opus model alias is host-specific; confirm availability or deliberately adapt the working copy.

- Do not copy throughput or scale examples as results. Credentials, personal data, migrations and paid compute need project-specific boundaries.

#### Not runtime-verified

- No upstream definition, helper, installer or generated workload was executed.

- No end-to-end agent session or effectiveness benchmark was run.

## Independent research tasks

- Domain-rule reviewer: Write expected-projection.md from the frozen domain rules and fixtures, independently of the implementation. Specify expected intermediate/final state, exclusions and unresolved business decisions.

- Sequence designer: Write proposed-sequences.md from the same fixtures and policy: duplicate delivery, changed payload under one ID, reorderings, time-boundary arrivals, corrections and restart positions. Preserve valid causal constraints and identify which sequences should converge.

- Projection examiner: Write projection-state-map.md from the fixed implementation: update logic, deduplication state, checkpoint boundaries, state expiry and outputs. Identify dependencies or external effects that must be disabled in the disposable replay.

## Sequence and verification

1. Name a replay owner to integrate the three reports. Freeze fixtures, rules and projection revision, and give the same evidence to each role. Verify the disposable state store and sink identities, permitted local writes and disabled external effects; use sanitised exports without live broker credentials where possible.

2. Reconcile domain expectations, proposed sequences and the implementation map before running. Resolve event time versus processing time, valid ordering, duplicate identity, lateness/correction rules and retention limits. The data owner decides unresolved semantics; do not treat every permutation as legally equivalent.

3. Freeze sequence files and expected states with hashes. Include a normal sequence, duplicates within and beyond the deduplication retention boundary where relevant, late arrivals around the policy cutoff, a correction and interruption/resume cases. Record any conflicting-ID payload as a policy case, not automatically as an ordinary duplicate.

4. Execute only in the confirmed disposable environment using the existing runner. Start each scenario from its recorded clean state, control clocks/watermarks where the runner supports them, and retain input order, outputs, state snapshots, checkpoint positions, command and exit status. Mark unsupported clock or crash cases unrun.

5. Compare each observation with the independent expected state. Compare valid alternate orders only where the contract promises convergence. Replay duplicates into populated state and compare a restart from a matched state/checkpoint pair with an uninterrupted run; do not infer correct recovery from a clean rebuild alone.

6. Hand failures and proposed changes to the data owner without altering the source event log. If a result or target check fails, stop, retain the failing sequence/state pair, then restore or recreate the disposable state and checkpoint together from the recorded baseline. Verify the normal sequence again and record recovery; a production backfill, checkpoint reset or projection replacement requires separate target-specific authority.

## Boundaries

- This recipe examines projection state and data correctness in an existing event-oriented system. It does not choose event sourcing for a new product or design background-job retry side effects.

- Both profiles target Claude Code. Verify frontmatter/tool mappings and restrict host grants to the approved fixtures and disposable stores. They provide instructions, not an event broker, replay runner or permission boundary; use manual file handoffs and leave unsupported cases unrun.

- Confirm sinks and callbacks cannot publish events, send notifications or call production services during replay. Use credentials limited to the disposable target if credentials are needed, and retain no live tokens or unnecessary personal data in receipts.

- Ordering and exactly-once behaviour are not assumed. An event-time watermark, where used, expresses the engine's progress estimate; record the actual late-data rule and runner capability instead of borrowing a different engine's guarantees.

- Stop on unknown event identity, undefined correction semantics, an unconfirmed target or a failed invariant. Retention/deletion policy takes precedence over the profile's blanket never-delete-event advice; do not modify retained source events as a test repair.

- Recovery needs a matched projection state and checkpoint, including deduplication state. A tested disposable restore does not prove production recovery; retain that limitation and the exact production action/owner in the handoff.

## Expected output

A frozen replay fixture set, per-sequence result ledger and recovery evidence for one bounded projection.

## Deliverables

- Event projection contract with identities, time, ordering, lateness and correction semantics.

- Independent domain expectations, sequence proposals and state/checkpoint map.

- Frozen replay sequences and expected intermediate/final states.

- Per-sequence result ledger with snapshots, offsets, failures and unrun cases.

- Disposable recovery receipt and a separately scoped change/backfill handoff.

## Acceptance checks

- [ ] Expected states and convergence claims were derived from domain rules and frozen before implementation results were observed.

- [ ] Every sequence records identity, arrival order, relevant time/watermark controls and expected intermediate/final state.

- [ ] Duplicate delivery, conflicting payloads, late events and corrections have observed or explicitly unrun results against their separate policies.

- [ ] Valid reordered sequences converge only where promised; order-dependent outcomes are checked against their own expected states.

- [ ] Restart from a matched state/checkpoint pair agrees with the uninterrupted reference, including deduplication state, or records a failure.

- [ ] Target/sink isolation is evidenced and the baseline sequence passes after disposable recovery; no production recovery claim is inferred.

Workflow: https://undominated.ai/workflows/#replay-a-late-and-duplicate-event-stream
