Skip to content
LoFi edited this page Jan 27, 2026 · 2 revisions

The Ledger

Verification is Currency.

The Ledger (verification_history.md) is the central accounting system for LoFi Gate. It tracks two things:

  1. Truth: Did your tests pass or fail?
  2. Cost: How many tokens did you spend (or save) finding that out?

๐Ÿ“ Location

The Ledger is always located at the Project Root: ./verification_history.md

Note

For Humans & Agents This log is designed to be read by both. It uses Markdown formatting, emojis, and interactive HTML elements. It works best when viewed in a Markdown previewer or by an LLM Agent.

๐Ÿ“ The Format

Each entry is a transaction record:

- **[TIMESTAMP]** [COMMAND] โœ… **Label**: STATUS (Duration) (Metrics)
  • TIMESTAMP: When the check ran.
  • COMMAND: The exact command executed (e.g., [npm test], [cargo audit]).
  • Label: Functional name of the check (e.g., "Test Suite").
  • STATUS: PASS or FAIL.
  • Metrics: (total token size: 500) (tokens truncated: 0)

๐Ÿงฎ Zero-Dependency Calculation

To keep LoFi Gate fast and portable, we do not import heavy tokenizers (like tiktoken) into the runtime. Instead, we use the Standard Heuristic:

4 characters โ‰ˆ 1 token

This allows us to run on any system (Python standard lib only) without downloading massive vocab files, while remaining accurate enough for "Order of Magnitude" cost tracking.

๐Ÿ’ฐ Smart Truncation (The Savings)

When a test fails, modern tools spit out thousands of lines of noise. LoFi Gate captures this output but truncates the middle section if it's too long.

Why?

  • Context Window: Providing 10k lines of logs pushes useful code out of the model's memory.
  • Cost: You pay for every input token. Spam logs = burning money.

Interactive Debugging

To keep the log clean, these errors are wrapped in Interactive Dropdowns:

๐Ÿ” View Truncated Error
Error: Something exploded in the core reactor.
...
... [Truncated 12,000 chars] ...
...
Final memory dump: 0xDEADBEEF

Agents can request to "expand" this if they need the deep trace, but usually the Head + Tail is enough.

๐Ÿ“Š The "Sticky" Footer

At the bottom of the Ledger, you will always find the Running Balance:

๐Ÿ“Š Total Token Size: 3625 | ๐Ÿ’ฐ Total Token Savings: 2996

  • Total Token Size: The cumulative amount of text (tokens) generated by your tools.
  • Total Token Savings: The cumulative amount of text avoided (deleted) by the Smart Truncation engine.

This number represents raw profit in API costs and Context Window efficiency.

Clone this wiki locally