Trace_definitions.Replayable_traceReplayable_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.
module V0 : sig ... endmodule Latest = V0include module type of struct include Latest endval scope_t : 'a Repr.t -> 'b scope Repr.ttype add = V0.add = {key : key;value : string;in_ctx_id : context_id scope;out_ctx_id : context_id scope;}val add_t : add Repr.ttype copy = V0.copy = {key_src : key;key_dst : key;in_ctx_id : context_id scope;out_ctx_id : context_id scope;}val copy_t : copy Repr.tval commit_t : commit Repr.ttype 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 commitval row_t : row Repr.t