MACHINE Rechain keeps state and an ordered action log inside your canister. Follow top up eleven. A thunk reads selectors, makes a decision, and builds an action. After dispatch, it can return an application result. Here, Bob has six. The target is eleven, so we dispatch Transfer five. Each reducer checks the action against its own state. The balances reducer returns a function. That commit function subtracts five from Alice and adds five to Bob. It runs only if every reducer accepts. The prepared functions move into the queue. All accepted: run the commits. Each function updates only its owned state. The log makes room, and the action becomes block four. Its previous hash links it to the existing chain. We're slowing down one synchronous, atomic dispatch. The thunk can now return the result: id four. REJECTION An action can also go straight to dispatch, without a thunk. Try transferring ten. Alice only has nine. The balances reducer rejects it, so none of the prepared functions run. No state change, and no new block. ARCHIVES As the log grows, older blocks move to a separate archive canister. This is an awaited intercanister call. The source keeps its copy until the archive confirms the batch. Once confirmed, that space can be released. When an archive fills up, Rechain adds another as needed. The block numbers and hash links stay unchanged. Readers follow the archive locations to read the complete history. REPLAY Replay the recorded actions through the reducers to rebuild state. Your canister can do this, and so can a third party reading the log. Use the same starting state and reducer rules for the same result. Record decision inputs in actions; replay doesn't rerun thunks. A reader can analyse that state, make a decision, and call your public API. Normal authorisation and reducer checks still apply. CERTIFICATION How does a reader trust the log? Rechain commits the published tip's index and hash through a Merkle root in certified data. An IC certificate authenticates that root. The reader verifies the certificate and witness, then checks the blocks against that trusted tip. A modified block fails verification. Check certificate freshness too, to reject stale proofs. Rechain's polling reader checks block hashes; certificate verification is an additional client step. Together, these checks detect a man in the middle changing the log. INSPECT The same history is useful for debugging. Pick an action and compare state before and after. Here is Transfer five: Alice loses five, Bob gains five. You can see what happened, rebuild it, and understand why.