lacing.oplog#
Operation log for time-travel debug + audit.
The op-log is an append-only sequence of mutations applied to a store.
Each entry carries a monotonically increasing Lamport clock, the
operation name (add_annotation, remove_annotation, add_tier,
…), the target id, a JSON payload sufficient to replay the
operation against a fresh store, plus actor / timestamp metadata.
Together with a fresh empty store, the op-log is enough to reconstruct the state of the system at any past clock value — the “killer debug feature” called out in BACK-DOC §4.7.
Two implementations ship with Phase 2:
InMemoryOpLog— for tests, dev, ephemeral runs.SqliteOpLog— persistent table on top of any SQLite database (intended to live in the same.annotfile as the store).
Use replay() to rebuild a store at a given clock.
Functions
|
|
|
Rebuild a store by replaying |
Classes
Simple list-backed op-log. |
|
|
Append-only log of mutations. |
|
One row of the op-log. |
|
Op-log backed by a SQLite table. |
- class lacing.oplog.InMemoryOpLog[source]#
Bases:
objectSimple list-backed op-log. Thread-safe via an RLock.
- class lacing.oplog.OpLog(*args, **kwargs)[source]#
Bases:
ProtocolAppend-only log of mutations.
Implementations must guarantee that the clock returned by
append()is strictly greater than every previously-returned clock value across the lifetime of the log.- append(operation, *, target_id=None, payload=None, actor='anonymous')[source]#
Append an entry; return its assigned clock.
- Return type:
- class lacing.oplog.OpLogEntry(clock, operation, target_id, payload, actor='anonymous', received_at=<factory>)[source]#
Bases:
objectOne row of the op-log.
- class lacing.oplog.SqliteOpLog(path, *, check_same_thread=True)[source]#
Bases:
objectOp-log backed by a SQLite table.
Designed to share a database file with
SqliteStoreso the store snapshot + the op-log live together and survive a singlecp project.annot project.backupstep.
- lacing.oplog.replay(log, *, until_clock=None, target_factory=None)[source]#
Rebuild a store by replaying
logup to (and including)until_clock.- Parameters:
- Return type:
- Returns:
The rebuilt store. Operations whose payload references unknown body schemas or tier parents are still applied; the caller is responsible for any post-replay validation.