Trace_definitions.Replayable_traceSourceReplayable_trace, a trace of Tezos's interactions with Irmin.
All the recorded operations in Tezos operate on (and create new) immutable records of type context. Most of the time, everything is linear (i.e. the input context to an operation is the latest output context), but there sometimes are several parallel chains of contexts, where all but one will end up being discarded.
Similarly to contexts, commits are not always linear, i.e. a checkout may choose a parent that is not the latest commit.
To solve this conundrum when replaying the trace, we need to remember all the context_id -> tree and trace commit hash -> real commit hash pairs to make sure an operation is operating on the right parent.
In the trace, the context indices and the commit hashes are 'scoped', meaning that they are tagged with a boolean information indicating if this is the very last occurence of that value in the trace. This way we can discard a recorded pair as soon as possible.
In practice, there is only 1 context and 1 commit in history, and sometimes 0 or 2, but the code is ready for more.
include module type of struct include Latest endtype add = V0.add = {key : key;value : string;in_ctx_id : context_id scope;out_ctx_id : context_id scope;}type copy = V0.copy = {key_src : key;key_dst : key;in_ctx_id : context_id scope;out_ctx_id : context_id scope;}type row = V0.row = | Checkout of hash scope * context_id scope| Add of add| Remove of key * context_id scope * context_id scope| Copy of copy| Find of key * bool * context_id scope| Mem of key * bool * context_id scope| Mem_tree of key * bool * context_id scope| Commit of commitinclude sig ... endval decoded_seq_of_encoded_chan_with_prefixes :
'a Repr.ty ->
in_channel ->
unit ->
'a Seq.node