Skip to main content

Module ledger

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 LRU 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 alter codelore 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§

GateRunRecord
One evaluated gate from one codelore check or codelore gate invocation.

Functions§

append_gate_runs
Append records to the gate-run ledger.
format_history
Print the last n gate-run records from all_records grouped by head_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.