Review the prerequisites
Suitable for: Engineers deciding state ownership, recovery and external execution contracts.
- Algebra and business semantics of parallel state merging
- The reducer defines how deltas become shared facts. Replay requires that repeated input does not change the result, and parallelism requires that it does not rely on accidental arrival order; but deduplication, sorting, and conflict handling must obey business semantics, and all lists cannot be mechanically turned into sets.
How does the mechanism work?
Step-by-step explanation
- Why is list append not necessarily idempotent?
Recovery can reapply updates, so reason about idempotency using record identity.
- What should I do if two nodes return the same ID but different bodies?
Merging both deduplicates records and determines which content becomes trusted state.
- If the input version changes after restoration, can the old results still be used?
Idempotent updates do not establish that output remains applicable; also check input consistency.
Design · Explain the trade-offs
Design · Multi-source ordering, retention and the remote-effect boundary
Objectives of this level: Extend one tested local protocol without quietly claiming guarantees it does not provide.
Visual guide · Replay an event without rollback
This single-source protocol retains durable event identities. Replaying e1 returns its old receipt while the current state stays running at cursor 2. Select the figure to open it at full size.
Change three constraints: retriever and executor now produce independent events; a task can run for months; one transition sends an HTTP merchant action. The preceding experiment proves only a retained single-source local ledger. Use its invariants to decide which facts move to which authority.
Independent producers do not share a trustworthy seq by default
The local protocol has a trusted executor stream with contiguous seq. If retriever and executor both emit seq1, sorting by wall clock does not create business causality. One option keeps a single transition owner: branches submit immutable evidence proposals, an integrator chooses the next state event and allocates its sequence in the authority transaction. This simplifies ordered transitions but creates an integration bottleneck. Another keeps a cursor per (task,source), immutable event identities and a defined merge/causality rule. That improves independent progress but does not resolve conflicting status ownership automatically. Source authentication and assignment must be checked by the trusted adapter, not accepted from model output.
Suppose e3 arrives before e2. This experiment rejects sequence_gap without changing cursor. A future buffering protocol may persist e3 as pending while waiting for e2; it must not mark e3's effect committed. Define a gap deadline, who can repair the missing source event, and how cancellation interacts with the pending event. Never advance cursor solely because a later message arrived.
Retention changes what replay can prove
A cursor alone says how far a stream advanced; it cannot prove which old content occupied seq1. Retaining event digest and receipt detects changed identity and returns the original acknowledgment, at a storage cost. If events are compacted after 30 days but clients may retry after 90, this exercise's replay guarantee has expired. Choose a longer dedup/receipt retention, a verifiable snapshot with retained identity summaries, or an explicit expired_replay/manual-reconciliation outcome. Do not silently re-execute an old identity because its row was deleted. Restore snapshots in isolation and verify current authority; the supplied tests only reopen the current database, not an old backup.
A local commit does not stop an already sent remote action
An HTTP merchant write cannot join this SQLite transaction. Persist a versioned business intent and transactional outbox alongside the local state, dispatch under a stable business operation key, and reconcile the merchant's authoritative receipt. Local event_id and remote operation_id have different meanings. A sender can crash after remote commit and before recording acknowledgment; no local lock removes that window. A merchant that honors a retained idempotency key can reconcile the intent. With query-only or unavailable evidence, keep unknown and constrain retries; a new event ID is not permission to repeat a business effect.
SQLite serializes all writers in this database. This makes the experiment's competing-connection result possible and introduces writer contention. A five-second connection wait is a bounded lock wait, not a task deadline, fair scheduler or provider budget. Moving to another store requires revalidating conditional updates, unique constraints, transaction isolation and failure handling; a pure reducer is still not the commit authority.
A decision record with falsifiable evidence
Choose single integrator or per-source cursors; name the status owner, ordering rule, transaction and retention policy. Give an e3-before-e2 timeline, a same-sequence conflict, a replay beyond retention and a dispatch-after-remote-commit crash. For each, separate actual local evidence from a proposed integration test. Keep tenant authorization, immutable identity and unknown external effects as independent gates. The required artifact is a reasoned ADR with tests that could reject it, not a claim that the extension is already implemented.
code example
A discarded receipt cannot support an old replay guarantee
A 90-day-old event arrives after a 30-day dedup purge. Cursor120 alone cannot prove the original event payload. Stop with the declared expired-replay or reconciliation protocol; inventing a new ID or treating seq1 as new would weaken the business guarantee.
Acceptance task for this level
Write a concrete ADR comparing one transition owner and per-source cursors. Specify gap handling, identity/receipt retention, lock contention and a remote outbox/reconciliation boundary. Add one locally executable changed-condition test and mark all unimplemented integration claims pending.
Reading this browser’s record…
Hide the answer and check your understanding
Does a unique local event row plus BEGIN IMMEDIATE prove one remote merchant write?
Expand reference derivation
No. It proves a local serialized commit for the retained identity. The remote authority must deduplicate or provide adequate reconciliation evidence for the stable business intent. Local rollback cannot undo an already sent remote write.
Further explanations and practice
When encountering unfamiliar principles, first read the implementation, continuous questioning and migration cases, and then independently explain the premise and boundaries. Answers and notes are saved to the original account record.
All linked explanations and exercises (1 )
Sources and verification scope
The principles are based on public information; the numbers, cases and tasks are the teaching design of this website. Offline experiments verify the range noted on this page, and the learning effect still needs to be judged through independent tasks and feedback.
- LangGraph:Thinking in LangGraph
- LangGraph: Checkpointing and cross-thread storage
- LangGraph: state and reducer
- Public fixed function contract
- Shared function runner
- Source-only practice package
- Harness Journey: one connected practical project
- Bilingual project guide and fault exercises
- Harness Journey source ZIP