Skip to main content

Crate borg_trace

Crate borg_trace 

Source
Expand description

Canonical touch streams from agent transcripts.

Every harness (Claude Code, omp, later opencode) is reduced to the same sequence of Events. Phase 0 mines these for headroom; later the same parser drives offline counterfactual replay of borg’s recall policy.

Modules§

claude
Claude Code transcripts: ~/.claude/projects/<slug>/<session>.jsonl (sub-agents under <session>/subagents/).
dialogue
The conversation between engineer and drone, as the live hooks see it: the engineer’s prompts, the drone’s visible text, what its tool calls touched, and tool calls the engineer refused with words. The touch streams (claude::parse, omp::parse) drop all of this; replay evals of hook logic (the queen) need it.
fingerprint
Deterministic fingerprints: the same error seen by two drones (or two sessions weeks apart) must hash the same, regardless of line numbers, temp paths, ids or durations.
omp
omp (oh-my-pi) sessions: ~/.omp/agent/sessions/<slug>/<ts>_<id>.jsonl.
scars
Execution memory (layer 1): scars and protocols, learned deterministically from what a session did, at zero tokens.

Structs§

Event
Reasoning
Session

Enums§

Harness
Kind

Constants§

CHARS_PER_TOKEN
Characters per token wherever borg estimates a token count: a transcript’s tool results here, a lesson line’s cost (borg whole.rs), the cost lines of borg status. Method: the usual rule of thumb for English text and code under today’s BPE tokenizers; an estimate, never a bound.

Functions§

approx_tokens
Approximate token count of a JSON tool result (CHARS_PER_TOKEN, counted in bytes).
civil_from_days
The civil date (year, month, day) of a day number since 1970-01-01, Howard Hinnant’s civil_from_days: the inverse of days_from_civil, with the same calendar numbers.
days_from_civil
Days since 1970-01-01 of the civil (proleptic Gregorian) date y-m-d, Howard Hinnant’s days_from_civil. The one calendar routine of borg’s crates, with civil_from_days (borg’s clock.rs re-exports both). Its numbers are the calendar’s (method): 146 097 days in a 400-year era, 719 468 days from 0000-03-01 to 1970-01-01, the year counted from March.
jsonl_files
All *.jsonl files below root.
parse_ts
Parse an RFC 3339 UTC timestamp (2026-09-15T22:18:11.638Z) to epoch ms.
repo_key
Resolve the repository a session worked in: nearest ancestor with .git, with borg/claude worktree suffixes folded back onto their parent repo. Only a worktree itself folds: a repo of its own nested deeper inside a worktree (a test fixture, a sandbox HOME’s repos) keeps its own name.
result_text
Flatten a tool result into text (for error fingerprinting).