# croviatrust/causari architecture

> Architecture diagram of the GitHub repository croviatrust/causari, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-10-03). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/croviatrust/causari
- Repository: https://github.com/croviatrust/causari

## Overview

Causari is a Rust CLI for measuring survival of AI-attributed code in Git history and recording agent activity in a local causal ledger. Users run `re audit` for a history-based report, or initialize the ledger and capture agent actions to trace their causes and effects. The README also documents proxy capture, skills, MCP, and PNX proof-of-non-exfiltration capabilities. Edges reflect README workflows and relationships listed in the source index; unsampled command implementations are represented by their exact paths, with uncertain links omitted.

Main entry points: [`src/cli.rs`](https://github.com/croviatrust/causari/blob/main/src/cli.rs) (CLI), [`src/commands/hook.rs`](https://github.com/croviatrust/causari/blob/main/src/commands/hook.rs) (Agent hooks), [`src/commands/pnx.rs`](https://github.com/croviatrust/causari/blob/main/src/commands/pnx.rs) (PNX command), [`src/pnx_run.rs`](https://github.com/croviatrust/causari/blob/main/src/pnx_run.rs) (PNX runtime)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_audit["History audit"]
  node_cli["CLI<br/>[cli.rs]"]
  node_audit_cmd["Audit command<br/>[audit.rs]"]
  node_audit_engine["Survival audit<br/>[audit.rs]"]
  node_git_repo[("Git repository")]
  node_audit_output["Audit report"]
end

subgraph group_capture["Agent capture"]
  node_hook_cmd["Agent hooks<br/>[hook.rs]"]
  node_cursor_hook["Cursor hook<br/>[cursor.rs]"]
  node_proxy_cmd["LLM proxy<br/>[proxy.rs]"]
  node_capture_parser["Exchange capture<br/>[capture.rs]"]
  node_redaction["Redaction<br/>[redact.rs]"]
end

subgraph group_ledger["Causal ledger"]
  node_snapshot["Tree snapshots<br/>[snapshot.rs]"]
  node_object_model["Event objects<br/>[object.rs]"]
  node_object_store[("Content store<br/>[store.rs]")]
  node_repo_state[("Ledger refs<br/>[repo.rs]")]
  node_commit_event["Event commit<br/>[commit.rs]"]
  node_index[("Event index<br/>[index.rs]")]
end

subgraph group_analysis["Ledger analysis"]
  node_ledger_queries["Causal queries<br/>[why.rs]"]
end

subgraph group_trust["Proof and trust"]
  node_pnx_command["PNX command<br/>[pnx.rs]"]
  node_pnx_proof["PNX proofs<br/>[pnx.rs]"]
  node_reach_record["Reach record<br/>[pnx_reach.rs]"]
  node_proof_runtime["PNX runtime<br/>[pnx_run.rs]"]
  node_seals["Signed seals<br/>[seal.rs]"]
  node_keys["Signing keys<br/>[keys.rs]"]
end

node_user(("Engineer"))

node_user -->|"runs commands"| node_cli
node_cli -->|"dispatches audit"| node_audit_cmd
node_audit_cmd -->|"runs audit"| node_audit_engine
node_audit_engine -->|"reads history"| node_git_repo
node_audit_engine -->|"reports survival"| node_audit_output
node_cli -->|"dispatches hooks"| node_hook_cmd
node_hook_cmd -->|"records exchanges"| node_capture_parser
node_hook_cmd -->|"uses Cursor hook"| node_cursor_hook
node_cli -->|"dispatches proxy"| node_proxy_cmd
node_proxy_cmd -->|"parses exchanges"| node_capture_parser
node_hook_cmd -->|"captures tree state"| node_snapshot
node_hook_cmd -->|"redacts captured data"| node_redaction
node_capture_parser -->|"redacts content"| node_redaction
node_snapshot -->|"writes blobs"| node_object_store
node_snapshot -->|"builds trees"| node_object_model
node_object_store -->|"stores objects"| node_object_model
node_commit_event -->|"persists events"| node_object_store
node_commit_event -->|"updates refs"| node_repo_state
node_commit_event -->|"indexes events"| node_index
node_cli -->|"dispatches queries"| node_ledger_queries
node_cli -->|"dispatches PNX"| node_pnx_command
node_pnx_command -->|"verifies proofs"| node_pnx_proof
node_pnx_command -->|"checks reach"| node_reach_record
node_pnx_command -->|"runs witness"| node_proof_runtime
node_proof_runtime -->|"builds run sheet"| node_pnx_proof
node_proof_runtime -->|"records destinations"| node_reach_record
node_proof_runtime -->|"signs proof"| node_seals
node_seals -->|"loads signing keys"| node_keys

click node_cli "https://github.com/croviatrust/causari/blob/main/src/cli.rs"
click node_audit_cmd "https://github.com/croviatrust/causari/blob/main/src/commands/audit.rs"
click node_audit_engine "https://github.com/croviatrust/causari/blob/main/src/audit.rs"
click node_hook_cmd "https://github.com/croviatrust/causari/blob/main/src/commands/hook.rs"
click node_cursor_hook "https://github.com/croviatrust/causari/blob/main/src/commands/hook/cursor.rs"
click node_proxy_cmd "https://github.com/croviatrust/causari/blob/main/src/commands/proxy.rs"
click node_capture_parser "https://github.com/croviatrust/causari/blob/main/src/capture.rs"
click node_redaction "https://github.com/croviatrust/causari/blob/main/src/redact.rs"
click node_snapshot "https://github.com/croviatrust/causari/blob/main/src/snapshot.rs"
click node_object_model "https://github.com/croviatrust/causari/blob/main/src/object.rs"
click node_object_store "https://github.com/croviatrust/causari/blob/main/src/store.rs"
click node_repo_state "https://github.com/croviatrust/causari/blob/main/src/repo.rs"
click node_commit_event "https://github.com/croviatrust/causari/blob/main/src/commit.rs"
click node_index "https://github.com/croviatrust/causari/blob/main/src/index.rs"
click node_ledger_queries "https://github.com/croviatrust/causari/blob/main/src/commands/why.rs"
click node_pnx_command "https://github.com/croviatrust/causari/blob/main/src/commands/pnx.rs"
click node_pnx_proof "https://github.com/croviatrust/causari/blob/main/src/pnx.rs"
click node_reach_record "https://github.com/croviatrust/causari/blob/main/src/pnx_reach.rs"
click node_proof_runtime "https://github.com/croviatrust/causari/blob/main/src/pnx_run.rs"
click node_seals "https://github.com/croviatrust/causari/blob/main/src/seal.rs"
click node_keys "https://github.com/croviatrust/causari/blob/main/src/keys.rs"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_cli,node_audit_cmd,node_audit_engine,node_git_repo,node_audit_output toneBlue
class node_hook_cmd,node_cursor_hook,node_proxy_cmd,node_capture_parser,node_redaction toneAmber
class node_snapshot,node_object_model,node_object_store,node_repo_state,node_commit_event,node_index toneMint
class node_ledger_queries toneRose
class node_pnx_command,node_pnx_proof,node_reach_record,node_proof_runtime,node_seals,node_keys,node_user toneIndigo
```

## Components

### History audit

- [CLI](https://github.com/croviatrust/causari/blob/main/src/cli.rs): `src/cli.rs`
- [Audit command](https://github.com/croviatrust/causari/blob/main/src/commands/audit.rs): `src/commands/audit.rs`
- [Survival audit](https://github.com/croviatrust/causari/blob/main/src/audit.rs): `src/audit.rs`
- **Git repository**
- **Audit report**

### Agent capture

- [Agent hooks](https://github.com/croviatrust/causari/blob/main/src/commands/hook.rs): `src/commands/hook.rs`
- [Cursor hook](https://github.com/croviatrust/causari/blob/main/src/commands/hook/cursor.rs): `src/commands/hook/cursor.rs`
- [LLM proxy](https://github.com/croviatrust/causari/blob/main/src/commands/proxy.rs): `src/commands/proxy.rs`
- [Exchange capture](https://github.com/croviatrust/causari/blob/main/src/capture.rs): `src/capture.rs`
- [Redaction](https://github.com/croviatrust/causari/blob/main/src/redact.rs): `src/redact.rs`

### Causal ledger

- [Tree snapshots](https://github.com/croviatrust/causari/blob/main/src/snapshot.rs): `src/snapshot.rs`
- [Event objects](https://github.com/croviatrust/causari/blob/main/src/object.rs): `src/object.rs`
- [Content store](https://github.com/croviatrust/causari/blob/main/src/store.rs): `src/store.rs`
- [Ledger refs](https://github.com/croviatrust/causari/blob/main/src/repo.rs): `src/repo.rs`
- [Event commit](https://github.com/croviatrust/causari/blob/main/src/commit.rs): `src/commit.rs`
- [Event index](https://github.com/croviatrust/causari/blob/main/src/index.rs): `src/index.rs`

### Ledger analysis

- [Causal queries](https://github.com/croviatrust/causari/blob/main/src/commands/why.rs): `src/commands/why.rs`

### Proof and trust

- [PNX command](https://github.com/croviatrust/causari/blob/main/src/commands/pnx.rs): `src/commands/pnx.rs`
- [PNX proofs](https://github.com/croviatrust/causari/blob/main/src/pnx.rs): `src/pnx.rs`
- [Reach record](https://github.com/croviatrust/causari/blob/main/src/pnx_reach.rs): `src/pnx_reach.rs`
- [PNX runtime](https://github.com/croviatrust/causari/blob/main/src/pnx_run.rs): `src/pnx_run.rs`
- [Signed seals](https://github.com/croviatrust/causari/blob/main/src/seal.rs): `src/seal.rs`
- [Signing keys](https://github.com/croviatrust/causari/blob/main/src/keys.rs): `src/keys.rs`

### Other components

- **Engineer**

## Connections

- Engineer → CLI: runs commands (evidence: `README.md`)
- CLI → Audit command: dispatches audit (evidence: `src/commands/audit.rs`)
- Audit command → Survival audit: runs audit (evidence: `src/commands/audit.rs`)
- Survival audit → Git repository: reads history (evidence: `README.md`)
- Survival audit → Audit report: reports survival (evidence: `README.md`)
- CLI → Agent hooks: dispatches hooks (evidence: `src/commands/hook.rs`)
- Agent hooks → Exchange capture: records exchanges (evidence: `src/commands/hook.rs`)
- Agent hooks → Cursor hook: uses Cursor hook (evidence: `src/commands/hook.rs`)
- CLI → LLM proxy: dispatches proxy (evidence: `src/commands/proxy.rs`)
- LLM proxy → Exchange capture: parses exchanges (evidence: `src/commands/proxy.rs`)
- Agent hooks → Tree snapshots: captures tree state (evidence: `src/commands/hook.rs`)
- Agent hooks → Redaction: redacts captured data (evidence: `src/commands/hook.rs`)
- Exchange capture → Redaction: redacts content (evidence: `src/capture.rs`)
- Tree snapshots → Content store: writes blobs (evidence: `src/snapshot.rs`)
- Tree snapshots → Event objects: builds trees (evidence: `src/snapshot.rs`)
- Content store → Event objects: stores objects (evidence: `src/store.rs`)
- Event commit → Content store: persists events (evidence: `src/commit.rs`)
- Event commit → Ledger refs: updates refs (evidence: `src/commit.rs`)
- Event commit → Event index: indexes events (evidence: `src/commit.rs`)
- CLI → Causal queries: dispatches queries (evidence: `README.md`)
- CLI → PNX command: dispatches PNX (evidence: `src/commands/pnx.rs`)
- PNX command → PNX proofs: verifies proofs (evidence: `src/commands/pnx.rs`)
- PNX command → Reach record: checks reach (evidence: `src/commands/pnx.rs`)
- PNX command → PNX runtime: runs witness (evidence: `src/commands/pnx.rs`)
- PNX runtime → PNX proofs: builds run sheet (evidence: `src/pnx_run.rs`)
- PNX runtime → Reach record: records destinations (evidence: `src/pnx_run.rs`)
- PNX runtime → Signed seals: signs proof (evidence: `src/pnx_run.rs`)
- Signed seals → Signing keys: loads signing keys (evidence: `src/seal.rs`)
