# cygnux-labs/tracekit architecture

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

- Interactive diagram: https://gitdiagram.com/cygnux-labs/tracekit
- Repository: https://github.com/cygnux-labs/tracekit

## Overview

Tracekit instruments AI-agent tool and model activity, evaluates calls before execution, and records decisions and results in a signed, append-only run log. Users export run evidence and verify it offline; optional witness, viewing, and causal-analysis capabilities support audit and investigation. The README documents the principal workflow and product capabilities; sampled source and the SOURCE INDEX support the signer, policy, storage, and verification layers, but do not expose every runtime connection.

Main entry points: [`tracekit/signer/service.py`](https://github.com/cygnux-labs/tracekit/blob/main/tracekit/signer/service.py) (Signer service), [`tracekit/signer/pipeline.py`](https://github.com/cygnux-labs/tracekit/blob/main/tracekit/signer/pipeline.py) (Record writer), [`tracekit/bundle.py`](https://github.com/cygnux-labs/tracekit/blob/main/tracekit/bundle.py) (Run bundles), [`tracekit/integrations/claude_code.py`](https://github.com/cygnux-labs/tracekit/blob/main/tracekit/integrations/claude_code.py) (Framework hooks)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_capture["Capture and control"]
  node_hooks["Framework hooks<br/>[claude_code.py]"]
  node_sdk["Python client<br/>[client.py]"]
  node_transport["Signer transport<br/>[http.py]"]
  node_policy["Policy engine<br/>[engine.py]"]
  node_approvals["Approval handling<br/>[reviewer.py]"]
end

subgraph group_record["Signing and storage"]
  node_signer["Signer service<br/>[service.py]"]
  node_pipeline["Record writer<br/>[pipeline.py]"]
  node_crypto["Canonical format and crypto<br/>[canon.py]"]
  node_storage[("Record storage<br/>[postgres.py]")]
  node_merkle["Merkle trees<br/>[__init__.py]"]
end

subgraph group_assurance["Evidence and assurance"]
  node_bundle["Run bundles<br/>[bundle.py]"]
  node_pyverify["Python verifier<br/>[v2.py]"]
  node_tsverify["TypeScript verifier<br/>[index.ts]"]
  node_witness["Witness service<br/>[tlog_witness.py]"]
  node_anchor["Transparency anchoring<br/>[rekor2.py]"]
end

subgraph group_operations["Operations and analysis"]
  node_cli["CLI and run viewer<br/>[cli.py]"]
  node_ingest["Telemetry ingestion<br/>[ingest.py]"]
  node_why["Run explanation and replay<br/>[replay.py]"]
end

node_agent(("Agent framework"))
node_operator(("Operator"))
node_external_witness(("External witness network"))

node_agent -->|"runs through"| node_hooks
node_hooks -->|"records calls"| node_sdk
node_sdk -->|"sends RPC"| node_transport
node_transport -->|"routes requests"| node_signer
node_signer -->|"checks policy"| node_policy
node_signer -->|"handles reviews"| node_approvals
node_signer -->|"submits records"| node_pipeline
node_pipeline -->|"signs records"| node_crypto
node_pipeline -->|"appends batches"| node_storage
node_storage -->|"maintains tree"| node_merkle
node_operator -->|"exports and views"| node_cli
node_cli -->|"exports run"| node_bundle
node_bundle -->|"verifies offline"| node_pyverify
node_bundle -->|"verifies offline"| node_tsverify
node_operator -->|"checks evidence"| node_pyverify
node_signer -->|"publishes checkpoints"| node_anchor
node_anchor -.->|"submits checkpoints"| node_external_witness
node_external_witness -->|"cosigns trees"| node_witness
node_operator -->|"investigates runs"| node_why
node_signer -.->|"accepts telemetry"| node_ingest

click node_hooks "https://github.com/cygnux-labs/tracekit/blob/main/tracekit/integrations/claude_code.py"
click node_sdk "https://github.com/cygnux-labs/tracekit/blob/main/tracekit/sdk/client.py"
click node_transport "https://github.com/cygnux-labs/tracekit/blob/main/tracekit/transport/http.py"
click node_policy "https://github.com/cygnux-labs/tracekit/blob/main/tracekit/policy2/engine.py"
click node_approvals "https://github.com/cygnux-labs/tracekit/blob/main/tracekit/reviewer.py"
click node_signer "https://github.com/cygnux-labs/tracekit/blob/main/tracekit/signer/service.py"
click node_pipeline "https://github.com/cygnux-labs/tracekit/blob/main/tracekit/signer/pipeline.py"
click node_crypto "https://github.com/cygnux-labs/tracekit/blob/main/tracekit/format/canon.py"
click node_storage "https://github.com/cygnux-labs/tracekit/blob/main/tracekit/storage/postgres.py"
click node_merkle "https://github.com/cygnux-labs/tracekit/blob/main/tracekit/merkle/__init__.py"
click node_bundle "https://github.com/cygnux-labs/tracekit/blob/main/tracekit/bundle.py"
click node_pyverify "https://github.com/cygnux-labs/tracekit/blob/main/tracekit/verify/v2.py"
click node_tsverify "https://github.com/cygnux-labs/tracekit/blob/main/sdk/typescript/src/verify/index.ts"
click node_witness "https://github.com/cygnux-labs/tracekit/blob/main/tracekit/tlog_witness.py"
click node_anchor "https://github.com/cygnux-labs/tracekit/blob/main/tracekit/anchor/rekor2.py"
click node_cli "https://github.com/cygnux-labs/tracekit/blob/main/tracekit/cli.py"
click node_ingest "https://github.com/cygnux-labs/tracekit/blob/main/tracekit/ingest.py"
click node_why "https://github.com/cygnux-labs/tracekit/blob/main/tracekit/why/replay.py"

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_hooks,node_sdk,node_transport,node_policy,node_approvals toneBlue
class node_signer,node_pipeline,node_crypto,node_storage,node_merkle toneAmber
class node_bundle,node_pyverify,node_tsverify,node_witness,node_anchor toneMint
class node_cli,node_ingest,node_why toneRose
class node_agent,node_operator,node_external_witness toneIndigo
```

## Components

### Capture and control

- [Framework hooks](https://github.com/cygnux-labs/tracekit/blob/main/tracekit/integrations/claude_code.py): `tracekit/integrations/claude_code.py`
- [Python client](https://github.com/cygnux-labs/tracekit/blob/main/tracekit/sdk/client.py): `tracekit/sdk/client.py`
- [Signer transport](https://github.com/cygnux-labs/tracekit/blob/main/tracekit/transport/http.py): `tracekit/transport/http.py`
- [Policy engine](https://github.com/cygnux-labs/tracekit/blob/main/tracekit/policy2/engine.py): `tracekit/policy2/engine.py`
- [Approval handling](https://github.com/cygnux-labs/tracekit/blob/main/tracekit/reviewer.py): `tracekit/reviewer.py`

### Signing and storage

- [Signer service](https://github.com/cygnux-labs/tracekit/blob/main/tracekit/signer/service.py): `tracekit/signer/service.py`
- [Record writer](https://github.com/cygnux-labs/tracekit/blob/main/tracekit/signer/pipeline.py): `tracekit/signer/pipeline.py`
- [Canonical format and crypto](https://github.com/cygnux-labs/tracekit/blob/main/tracekit/format/canon.py): `tracekit/format/canon.py`
- [Record storage](https://github.com/cygnux-labs/tracekit/blob/main/tracekit/storage/postgres.py): `tracekit/storage/postgres.py`
- [Merkle trees](https://github.com/cygnux-labs/tracekit/blob/main/tracekit/merkle/__init__.py): `tracekit/merkle/__init__.py`

### Evidence and assurance

- [Run bundles](https://github.com/cygnux-labs/tracekit/blob/main/tracekit/bundle.py): `tracekit/bundle.py`
- [Python verifier](https://github.com/cygnux-labs/tracekit/blob/main/tracekit/verify/v2.py): `tracekit/verify/v2.py`
- [TypeScript verifier](https://github.com/cygnux-labs/tracekit/blob/main/sdk/typescript/src/verify/index.ts): `sdk/typescript/src/verify/index.ts`
- [Witness service](https://github.com/cygnux-labs/tracekit/blob/main/tracekit/tlog_witness.py): `tracekit/tlog_witness.py`
- [Transparency anchoring](https://github.com/cygnux-labs/tracekit/blob/main/tracekit/anchor/rekor2.py): `tracekit/anchor/rekor2.py`

### Operations and analysis

- [CLI and run viewer](https://github.com/cygnux-labs/tracekit/blob/main/tracekit/cli.py): `tracekit/cli.py`
- [Telemetry ingestion](https://github.com/cygnux-labs/tracekit/blob/main/tracekit/ingest.py): `tracekit/ingest.py`
- [Run explanation and replay](https://github.com/cygnux-labs/tracekit/blob/main/tracekit/why/replay.py): `tracekit/why/replay.py`

### Other components

- **Agent framework**
- **Operator**
- **External witness network**

## Connections

- Agent framework → Framework hooks: runs through
- Framework hooks → Python client: records calls (evidence: `tracekit/integrations/claude_code.py`)
- Python client → Signer transport: sends RPC (evidence: `tracekit/sdk/client.py`)
- Signer transport → Signer service: routes requests (evidence: `tracekit/transport/http.py`)
- Signer service → Policy engine: checks policy (evidence: `tracekit/signer/service.py`)
- Signer service → Approval handling: handles reviews (evidence: `tracekit/reviewer.py`)
- Signer service → Record writer: submits records (evidence: `tracekit/signer/pipeline.py`)
- Record writer → Canonical format and crypto: signs records (evidence: `tracekit/signer/pipeline.py`)
- Record writer → Record storage: appends batches (evidence: `tracekit/signer/pipeline.py`)
- Record storage → Merkle trees: maintains tree (evidence: `tracekit/storage/postgres.py`)
- Operator → CLI and run viewer: exports and views
- CLI and run viewer → Run bundles: exports run
- Run bundles → Python verifier: verifies offline (evidence: `tracekit/verify/v2.py`)
- Run bundles → TypeScript verifier: verifies offline
- Operator → Python verifier: checks evidence
- Signer service → Transparency anchoring: publishes checkpoints (evidence: `tracekit/signer/service.py`)
- Transparency anchoring → External witness network: submits checkpoints
- External witness network → Witness service: cosigns trees (evidence: `tracekit/tlog_witness.py`)
- Operator → Run explanation and replay: investigates runs
- Signer service → Telemetry ingestion: accepts telemetry
