Review the prerequisites
Suitable for: Readers who can follow a dictionary update and a state transition.
- 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.
Foundation · Understand the concepts
Understand · A batch reducer cannot recognize an old business event
Objectives of this level: Separate deterministic in-batch merging from durable event reconciliation.
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.
A retrieval branch writes notes while an executor owns task status. Overwriting the whole notes list loses another branch's evidence; concatenation preserves duplicates after recovery. A pure reducer therefore needs record identity, a conflict rule and field ownership. For an unordered evidence set, identity-based union can be associative, commutative and idempotent. Those properties do not authorize a writer or make an old result current.
Now change the problem. Task ticket-1 belongs to tenant A and begins waiting. One trusted executor emits e1/seq1 → ready, then e2/seq2 → running. Close the database, reopen it and deliver the original e1 again. A batch containing only e1 cannot tell whether it is a new instruction or a delivery of an old event. Rejecting every ready proposal from running also loses the ability to acknowledge a previously committed event. Preserve a durable identity and return its old receipt without changing the current state.
Distinguish three cases before implementing anything:
| Delivery after running | Meaning | Required behavior |
|---|---|---|
| Original e1/seq1/ready | Identical old event | Replay original ready receipt; current task stays running/cursor2 |
| e1/seq1 with changed content | Identity reused for another intent | event_conflict; no new local effect |
| New e3/seq3/ready | New backward instruction | status_transition; no cursor advance |
The receipt's status describes the effect of that event, not the latest task status. A saved ready receipt and a current running task are consistent. A model saying “completed” is neither a committed transition nor an authorization decision.
The following layers use actual local SQLite rows as effects. They do not send a merchant action. Source and tenant are authored stand-ins for server-bound inputs; their strings are not credentials. The function-only reducer remains a useful supplement, but it cannot prove durable recovery, concurrent commits or remote effect uniqueness.
code example
Record identity is different from equal content
Two different evidence events can contain the same text and still be distinct observations. Conversely, one event delivered twice remains one event. Define what the ID represents before choosing union, addition or ordered replay.
Acceptance task for this level
Predict the receipt, current state, cursor and local effect count for the three deliveries in the table. Explain why a pure reducer receiving only the current batch lacks enough history.
Reading this browser’s record…
Hide the answer and check your understanding
The replay returns a receipt with status ready while snapshot says running. Is the ledger inconsistent?
Expand reference derivation
No. The receipt records e1 at its original commit. Snapshot records the current task after e2. Replaying e1 must neither rewrite the receipt nor move the task backward.
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