Skip to content

Auditing & Provenance ​

In a long coding session, context compaction trims early turns, parallel subagents modify files concurrently, and dozens of builds and tool calls run in the background. Kompile's auditing layer makes sure neither compaction nor background execution erases what happened, why it happened, or whether it followed your rules.


1. Periodic Transcript Auditing (/policy-enforce) ​

Inline judges watch one turn at a time; they cannot easily notice when a 60-turn session has gradually drifted away from an architectural requirement you stated three compactions ago.

/policy-enforce (session) and /policy-enforce-global (project) solve this with a dedicated periodic read-only auditor:

  1. Checklist storage — policy items live in two scopes (project items numbered first, then session items):
    • Project: <project>/.kompile/chat-policies.json
    • Session: ~/.kompile/conversations/<session>.policies.json
  2. Configurable trigger — fire automatically every N completed turns (/policy-enforce every 10), on a duration interval (/policy-enforce every 30m), or on demand (/policy-enforce run). When no policy items exist, the trigger stays completely inert (zero subagents launched).
  3. Compaction-proof input — Kompile launches a read-only task subagent (code-reviewer by default, or any configured agent/role/model/thinking level) and gives it:
    • the numbered policy checklist,
    • the path to the append-only session transcript on disk (which still contains everything compaction dropped from live context), and
    • the newest ~60 KB of that transcript inline.
  4. Evidence-backed intervention — the auditor must cite concrete evidence for any violation:
    • Pass: prints a single summary line (✓ [policy] audit #3 · 7/7 items OK).
    • Violation: displays the structured report and interrupts the active chat turn (or starts a turn if idle) with a <kompile_policy_enforcement> block listing each violation, its evidence, and the required fixes.
    • Inconclusive / Failed: reported cleanly without interrupting or pretending the audit passed.

Because the auditor runs via the task tool, it respects your /subagent-config model bans, budgets, and failover rules. See the full command guide in /policy-enforce.


2. Kompile's Six Durable Audit Ledgers ​

Beyond periodic policy audits, Kompile continuously records structured operational evidence across six focused stores:

LedgerStorage LocationWhat It RecordsHow to Inspect
Judgement Log (JudgementLog)~/.kompile/sessions/<sessionId>/judgements.jsonlAppend-only JSONL of every compliance, direction, and deflection verdict (decision, severity, quoted violations, reasoning, excerpts)/judge judgements, /dashboard-judge, insights
Tool-Call Audit Catalog (McpToolAuditLogger)Shared tool-call catalog + .kompile/logs/mcp-activity.logEvery MCP tool invocation: tool name, latency, token footprint, outcome, and session/subagent attributiontool_call_catalog, /stats tools, /dashboard-tools, insights
Turn Diff Archive (EnforcerDiffArchive).kompile/enforcer-archive/<sessionId>/snapshots/turn-NNN/Pre-turn original file copies, unified diff.patch, and violation metadata for safe rollback/archive, /diff, /rollback
Edit History Index (diff_index)Project diff indexSearchable, filterable, sortable historical coding-agent edits (old/new text + unified diffs)diff_index MCP tool, /diffs
Build Provenance (BuildProvenanceTool)<project>/.kompile/build-provenance/Automatic record for every build tool run (and manual record entries): command, commit SHA, session ID, outputs, descriptionbuild_provenance (list/get/latest/record)
Test Milestones & IncidentsProject milestone store & incident ledgerAuto-captured + agent-recorded test milestones and structured incident records (invariant, verification status, evidence refs)/test-milestones, test_milestone, incident, /dashboard-tests, insights

Why Append-Only JSONL & Separate Stores? ​

  • Best-effort durability: JudgementLog writes single-line JSONL frames and swallows I/O failures so a full disk or transient lock can never break enforcement or crash a chat.
  • Compaction-safe: Transcripts, progress reports, judgements, build provenance, and diff indexes live outside the LLM context window — agents and humans can always verify claims against ground-truth artifacts instead of trusting summaries.
  • Clean lifecycle via /gc: Reversible stores (old transcripts, logs, journals, temp files) are managed explicitly through /gc (dry-run by default; pin protects critical sessions; models, code indexes, and provenance stay safe).

3. Unified Observability Surfaces ​

Query all audit ledgers without digging through raw files:

text
/dashboard                    # session summary + available topic reports
/dashboard-judge              # recent judge verdicts, flags, and overrides
/dashboard-tools              # tool-call counts, latency, and token overhead
/dashboard-tests              # test milestone pass/fail trends
/dashboard-timeline           # chronological session event stream (/timeline follow)
/stats tools                  # per-tool token drill-down by session and call ID
/process-logs grep <id> ERR   # search managed process, runtime, subprocess, and LSP logs

Agents can query the same operational data read-only using the insights and tool_call_catalog MCP tools.

Released under the Apache-2.0 License.