Module ledger
Expand description
Gate-run ledger: append-only JSONL record of every evaluated gate.
Each codelore check or codelore gate run appends one
GateRunRecord per evaluated gate to a per-repo JSONL file at
<cache_root>/codelore/<repo_hash_8>/gate_runs.jsonl.
The path reuses the same <repo_hash_8> component that cache.rs
derives for .duckdb files, placing history and cache entries under
the same per-repo directory. .jsonl files are NOT touched by the
cache pruner (which matches .duckdb only).
§Write contract
- File is created on first write (
O_CREAT | O_APPEND). - Every line is a valid JSON object followed by
\n. - IO errors on write are logged via
tracing::warn!and silently dropped — a ledger write failure must never altercodelore check’s exit code.
§Read contract
Lines that fail to parse as GateRunRecord are skipped and warned;
partial writes (e.g. from a crash mid-line) are tolerated.
Structs§
- Gate
RunRecord - One evaluated gate from one
codelore checkorcodelore gateinvocation.
Functions§
- append_
gate_ runs - Append
recordsto the gate-run ledger. - format_
history - Print the last
ngate-run records fromall_recordsgrouped byhead_sha, newest group last. Returns the formatted string. - ledger_
dir - Compute the per-repo ledger directory:
<cache_root>/codelore/<repo_hash_8>/ - ledger_
path - Path to the gate-runs JSONL file for
repo_path. - now_
utc_ ts - Return a UTC timestamp string in ISO-8601 format:
"YYYY-MM-DDTHH:MM:SSZ". - read_
gate_ runs - Read all gate-run records from the ledger, newest-last.