How anirudh-kavle/coding-agent-audit-trails works
Purpose and entry points
Flight Recorder is a local audit trail for coding-agent tool sessions. It records consequential actions, their visible preceding rationale, and outcomes without storing model API keys. Primary entry points are the fr CLI in flight_recorder/cli.py, Claude hook adapter bin/fr_hook_entry.py, and provider-neutral API wrapper flight_recorder/recorder.py.
Hook ingestion and action pairing
Claude-style hook payloads enter through bin/fr_hook_entry.py and flight_recorder/hook.py. Pre-action arguments and post-action results are paired into one action record, preferring provider tool-call IDs and falling back to the newest unmatched same-session/tool action. Raw incoming payloads are independently retained for parser/debug validation.
Reasoning capture boundary
flight_recorder/reasoning.py extracts only visible assistant text or thinking from a live agent JSONL transcript. It tails a bounded transcript region, finds content preceding the current tool call, and stops at the prior tool result. Missing or unreadable transcripts do not block event capture: the stored action is marked with a capture gap rather than inventing rationale.
Provider-neutral instrumentation
API-backed agents instrument local tool execution through FlightRecorder in flight_recorder/recorder.py. start_action() captures tool name, arguments, and supplied visible rationale; the returned action is explicitly finished with either a successful result or error. This separates agent/provider orchestration from durable audit storage and supports future OpenAI or other provider loops without coupling to their credentials.
Durable local event store
flight_recorder/store.py owns persistence into the user-local ~/.flight-recorder/ directory. SQLite is the queryable source of record, configured for WAL behavior, while date-partitioned JSONL is an append-only mirror for evidence portability. The schema and full-text search support are defined in flight_recorder/schema.sql; result truncation and reasoning-size bounds constrain local storage volume.
CLI and project integration
flight_recorder/cli.py exposes fr init, status, ui, and grep. Initialization modifies a target project’s .claude/settings.json by merging recorder hooks rather than replacing existing settings. CLI commands form the operational boundary between installed recorder infrastructure and an instrumented coding project.
Viewing and search
The local timeline viewer is a FastAPI application rooted at flight_recorder/viewer/app.py, with its browser asset at flight_recorder/viewer/static/index.html. It reads the same local store used by capture, while fr grep relies on the SQLite/FTS query path. No remote backend or hosted service is required.
Runtime and trust model
The system is Python-packaged via pyproject.toml, uses SQLite and local filesystem storage, and can launch a FastAPI UI. External agent systems provide hook payloads or invoke the recorder API, but audit content remains local; raw payload logging under the recorder directory is intentionally available for compatibility diagnostics.
Main entry points: store.py Durable event store · recorder.py FlightRecorder · cli.py fr CLI · fr_hook_entry.py Hook entry adapter
Components 15
Capture
- Claude hooks · Supplies pre- and post-tool payloads.
- Hook entry adapter
bin/fr_hook_entry.py - Hook action pairing · Pairs calls by tool ID or unmatched session/tool action.
flight_recorder/hook.py - Visible reasoning capture · Captures preceding visible text without blocking events on gaps.
flight_recorder/reasoning.py - API-backed agents · Invoke provider-neutral local instrumentation.
Recorder Core
- FlightRecorder · Starts and explicitly finishes tool actions.
flight_recorder/recorder.py
Local Audit Store
- Durable event store · Applies size bounds and writes local audit records.
flight_recorder/store.py - SQLite schema & FTS
flight_recorder/schema.sql - SQLite query store · WAL-backed source of record in the user-local recorder directory.
- Date-partitioned JSONL · Append-only portable audit mirror in the user-local recorder directory.
- Raw payload log · Retains incoming payloads independently for compatibility debugging.
Operations & Viewing
- fr CLI · Provides init, status, ui, and grep.
flight_recorder/cli.py - Project Claude settings · Hook settings are merged rather than replaced.
- Timeline viewer API
flight_recorder/viewer/app.py - Timeline browser UI
flight_recorder/viewer/static/index.html
Connections 17
- Claude hooks → Hook entry adapter: hook payloads
- Hook entry adapter → Hook action pairing: normalizes events
- Hook entry adapter → Raw payload log: retains raw payloads
- Hook action pairing → Visible reasoning capture: finds preceding rationale
- Visible reasoning capture → FlightRecorder: rationale or capture gap
- Hook action pairing → FlightRecorder: paired action
- API-backed agents → FlightRecorder: start / finish action
- FlightRecorder → Durable event store: durable action record
- Durable event store → SQLite schema & FTS: uses
- Durable event store → SQLite query store: queryable records
- Durable event store → Date-partitioned JSONL: append-only mirror
- fr CLI → Project Claude settings: init merges hooks
- Project Claude settings → Claude hooks: configures hook execution
- fr CLI → SQLite query store: grep via FTS
- fr CLI → Timeline viewer API: launches UI
- Timeline viewer API → SQLite query store: reads timeline
- Timeline viewer API → Timeline browser UI: serves