# uw-syfi/tracelab architecture

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

- Interactive diagram: https://gitdiagram.com/uw-syfi/tracelab
- Repository: https://github.com/uw-syfi/tracelab

## Overview

TraceLab collects and sanitizes Claude/Codex session traces, materializes them for reproducible workload analysis, and offers browser-based exploration and trace contribution. A separate Rust replay tool turns session traces into synthetic inference workloads. The graph follows documented pipeline stages and sampled call/reference evidence; unsampled experiment internals and some web wiring are represented only at the documented subsystem level.

Main entry points: [`artifacts/utils/trace_db.py`](https://github.com/uw-syfi/tracelab/blob/main/artifacts/utils/trace_db.py) (Trace database), [`replay/src/session.rs`](https://github.com/uw-syfi/tracelab/blob/main/replay/src/session.rs) (Session replay), [`replay/src/cli.rs`](https://github.com/uw-syfi/tracelab/blob/main/replay/src/cli.rs) (Replay CLI), [`scripts/collect_llm_traces.py`](https://github.com/uw-syfi/tracelab/blob/main/scripts/collect_llm_traces.py) (Trace collection)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_prep["Trace preparation"]
  node_collection["Trace collection"]
  node_claude_extract["Claude extraction"]
  node_codex_extract["Codex extraction"]
  node_sanitize["Trace sanitization"]
  node_privacy["Privacy safeguards<br/>[trace_privacy.py]"]
end

subgraph group_analysis["Trace analysis"]
  node_duckdb[("Trace database<br/>[trace_db.py]")]
  node_experiments["Workload experiments"]
  node_cache_analysis["Prefix-cache analysis"]
  node_tool_analysis["Tool-call analysis"]
  node_human_analysis["Human-loop analysis"]
  node_session_analysis["Session analysis"]
  node_trace_facts["Trace facts"]
  node_web_analytics["Web analytics data<br/>[rounds.py]"]
  node_validators["Trace validators"]
end

subgraph group_web["Browser explorer"]
  node_web_ingest["Trace ingest<br/>[ingest.py]"]
  node_ingest_ui["Ingest interface<br/>[ingestUi.ts]"]
  node_worker_protocol["Worker protocol<br/>[protocol.ts]"]
  node_analysis_worker["Browser analysis worker<br/>[analyze.worker.ts]"]
  node_ask_client["Ask-the-trace client<br/>[askClient.ts]"]
end

subgraph group_services["Web services"]
  node_ai_service["Ask-the-trace service<br/>[app.py]"]
  node_llm_runtime["LLM runtime"]
  node_contribute_service["Contribution API<br/>[app.py]"]
  node_contribution_store[("Contribution storage<br/>[store.py]")]
end

subgraph group_replay["Workload replay"]
  node_replay_cli["Replay CLI<br/>[cli.rs]"]
  node_replay_trace["Replay trace loader<br/>[trace.rs]"]
  node_replay_tokens["Synthetic tokens<br/>[tokens.rs]"]
  node_replay_sessions["Session replay<br/>[session.rs]"]
  node_replay_backend["Generation backend<br/>[backend.rs]"]
  node_replay_log["Step logging<br/>[record.rs]"]
end

node_trace_owner(("Trace owner"))
node_browser_user(("Browser user"))

node_trace_owner -->|"collects traces"| node_collection
node_collection -->|"extracts rounds"| node_claude_extract
node_collection -->|"extracts rounds"| node_codex_extract
node_trace_owner -->|"sanitizes trace"| node_sanitize
node_sanitize -->|"applies safeguards"| node_privacy
node_sanitize -->|"materializes trace"| node_duckdb
node_duckdb -->|"feeds analysis"| node_experiments
node_duckdb -->|"feeds analysis"| node_cache_analysis
node_duckdb -->|"feeds analysis"| node_tool_analysis
node_duckdb -->|"feeds analysis"| node_human_analysis
node_duckdb -->|"feeds analysis"| node_session_analysis
node_duckdb -->|"feeds analysis"| node_trace_facts
node_duckdb -->|"queries database"| node_web_analytics
node_web_analytics -.->|"supports audits"| node_validators
node_trace_owner -.->|"explores traces"| node_browser_user
node_browser_user -->|"drops trace"| node_web_ingest
node_web_ingest -->|"returns ingest results"| node_ingest_ui
node_ingest_ui -.->|"starts analysis"| node_analysis_worker
node_analysis_worker -->|"exchanges messages"| node_worker_protocol
node_browser_user -->|"asks trace questions"| node_ask_client
node_ask_client -->|"uses protocol"| node_worker_protocol
node_ask_client -->|"sends chat requests"| node_ai_service
node_ai_service -->|"runs chat turns"| node_llm_runtime
node_browser_user -->|"contributes trace"| node_contribute_service
node_contribute_service -->|"stores contributions"| node_contribution_store
node_replay_cli -->|"loads session trace"| node_replay_trace
node_replay_cli -->|"builds token pool"| node_replay_tokens
node_replay_cli -->|"runs sessions"| node_replay_sessions
node_replay_sessions -->|"builds prompts"| node_replay_tokens
node_replay_sessions -->|"sends inference"| node_replay_backend
node_replay_sessions -->|"emits step logs"| node_replay_log

click node_collection "https://github.com/uw-syfi/tracelab/blob/main/scripts/collect_llm_traces.py"
click node_claude_extract "https://github.com/uw-syfi/tracelab/blob/main/scripts/extract_claude_rounds.py"
click node_codex_extract "https://github.com/uw-syfi/tracelab/blob/main/scripts/extract_codex_rounds.py"
click node_sanitize "https://github.com/uw-syfi/tracelab/blob/main/scripts/sanitize_round_trace.py"
click node_privacy "https://github.com/uw-syfi/tracelab/blob/main/scripts/trace_privacy.py"
click node_duckdb "https://github.com/uw-syfi/tracelab/blob/main/artifacts/utils/trace_db.py"
click node_experiments "https://github.com/uw-syfi/tracelab/tree/main/artifacts/llm_generation"
click node_cache_analysis "https://github.com/uw-syfi/tracelab/tree/main/artifacts/prefix_cache"
click node_tool_analysis "https://github.com/uw-syfi/tracelab/tree/main/artifacts/tool_calls"
click node_human_analysis "https://github.com/uw-syfi/tracelab/tree/main/artifacts/human_in_the_loop"
click node_session_analysis "https://github.com/uw-syfi/tracelab/tree/main/artifacts/session"
click node_trace_facts "https://github.com/uw-syfi/tracelab/tree/main/artifacts/trace_facts"
click node_web_analytics "https://github.com/uw-syfi/tracelab/blob/main/artifacts/web_analytics/rounds.py"
click node_validators "https://github.com/uw-syfi/tracelab/tree/main/validators"
click node_web_ingest "https://github.com/uw-syfi/tracelab/blob/main/web/payload/ingest.py"
click node_ingest_ui "https://github.com/uw-syfi/tracelab/blob/main/web/app/src/lib/ingestUi.ts"
click node_worker_protocol "https://github.com/uw-syfi/tracelab/blob/main/web/app/src/lib/worker/protocol.ts"
click node_analysis_worker "https://github.com/uw-syfi/tracelab/blob/main/web/app/src/lib/worker/analyze.worker.ts"
click node_ask_client "https://github.com/uw-syfi/tracelab/blob/main/web/app/src/lib/ai/askClient.ts"
click node_ai_service "https://github.com/uw-syfi/tracelab/blob/main/web/ai_infra/app.py"
click node_llm_runtime "https://github.com/uw-syfi/tracelab/blob/main/web/ai_infra/syfi_llm_runtime.py"
click node_contribute_service "https://github.com/uw-syfi/tracelab/blob/main/web/server/app.py"
click node_contribution_store "https://github.com/uw-syfi/tracelab/blob/main/web/server/store.py"
click node_replay_cli "https://github.com/uw-syfi/tracelab/blob/main/replay/src/cli.rs"
click node_replay_trace "https://github.com/uw-syfi/tracelab/blob/main/replay/src/trace.rs"
click node_replay_tokens "https://github.com/uw-syfi/tracelab/blob/main/replay/src/tokens.rs"
click node_replay_sessions "https://github.com/uw-syfi/tracelab/blob/main/replay/src/session.rs"
click node_replay_backend "https://github.com/uw-syfi/tracelab/blob/main/replay/src/backend.rs"
click node_replay_log "https://github.com/uw-syfi/tracelab/blob/main/replay/src/record.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_collection,node_claude_extract,node_codex_extract,node_sanitize,node_privacy,node_browser_user toneBlue
class node_duckdb,node_experiments,node_cache_analysis,node_tool_analysis,node_human_analysis,node_session_analysis,node_trace_facts,node_web_analytics,node_validators toneAmber
class node_web_ingest,node_ingest_ui,node_worker_protocol,node_analysis_worker,node_ask_client toneMint
class node_ai_service,node_llm_runtime,node_contribute_service,node_contribution_store toneRose
class node_replay_cli,node_replay_trace,node_replay_tokens,node_replay_sessions,node_replay_backend,node_replay_log,node_trace_owner toneIndigo
```

## Components

### Trace preparation

- [Trace collection](https://github.com/uw-syfi/tracelab/blob/main/scripts/collect_llm_traces.py): `scripts/collect_llm_traces.py`
- [Claude extraction](https://github.com/uw-syfi/tracelab/blob/main/scripts/extract_claude_rounds.py): `scripts/extract_claude_rounds.py`
- [Codex extraction](https://github.com/uw-syfi/tracelab/blob/main/scripts/extract_codex_rounds.py): `scripts/extract_codex_rounds.py`
- [Trace sanitization](https://github.com/uw-syfi/tracelab/blob/main/scripts/sanitize_round_trace.py): `scripts/sanitize_round_trace.py`
- [Privacy safeguards](https://github.com/uw-syfi/tracelab/blob/main/scripts/trace_privacy.py): `scripts/trace_privacy.py`

### Trace analysis

- [Trace database](https://github.com/uw-syfi/tracelab/blob/main/artifacts/utils/trace_db.py): `artifacts/utils/trace_db.py`
- [Workload experiments](https://github.com/uw-syfi/tracelab/tree/main/artifacts/llm_generation): `artifacts/llm_generation`
- [Prefix-cache analysis](https://github.com/uw-syfi/tracelab/tree/main/artifacts/prefix_cache): `artifacts/prefix_cache`
- [Tool-call analysis](https://github.com/uw-syfi/tracelab/tree/main/artifacts/tool_calls): `artifacts/tool_calls`
- [Human-loop analysis](https://github.com/uw-syfi/tracelab/tree/main/artifacts/human_in_the_loop): `artifacts/human_in_the_loop`
- [Session analysis](https://github.com/uw-syfi/tracelab/tree/main/artifacts/session): `artifacts/session`
- [Trace facts](https://github.com/uw-syfi/tracelab/tree/main/artifacts/trace_facts): `artifacts/trace_facts`
- [Web analytics data](https://github.com/uw-syfi/tracelab/blob/main/artifacts/web_analytics/rounds.py): `artifacts/web_analytics/rounds.py`
- [Trace validators](https://github.com/uw-syfi/tracelab/tree/main/validators): `validators`

### Browser explorer

- [Trace ingest](https://github.com/uw-syfi/tracelab/blob/main/web/payload/ingest.py): `web/payload/ingest.py`
- [Ingest interface](https://github.com/uw-syfi/tracelab/blob/main/web/app/src/lib/ingestUi.ts): `web/app/src/lib/ingestUi.ts`
- [Worker protocol](https://github.com/uw-syfi/tracelab/blob/main/web/app/src/lib/worker/protocol.ts): `web/app/src/lib/worker/protocol.ts`
- [Browser analysis worker](https://github.com/uw-syfi/tracelab/blob/main/web/app/src/lib/worker/analyze.worker.ts): `web/app/src/lib/worker/analyze.worker.ts`
- [Ask-the-trace client](https://github.com/uw-syfi/tracelab/blob/main/web/app/src/lib/ai/askClient.ts): `web/app/src/lib/ai/askClient.ts`

### Web services

- [Ask-the-trace service](https://github.com/uw-syfi/tracelab/blob/main/web/ai_infra/app.py): `web/ai_infra/app.py`
- [LLM runtime](https://github.com/uw-syfi/tracelab/blob/main/web/ai_infra/syfi_llm_runtime.py): `web/ai_infra/syfi_llm_runtime.py`
- [Contribution API](https://github.com/uw-syfi/tracelab/blob/main/web/server/app.py): `web/server/app.py`
- [Contribution storage](https://github.com/uw-syfi/tracelab/blob/main/web/server/store.py): `web/server/store.py`

### Workload replay

- [Replay CLI](https://github.com/uw-syfi/tracelab/blob/main/replay/src/cli.rs): `replay/src/cli.rs`
- [Replay trace loader](https://github.com/uw-syfi/tracelab/blob/main/replay/src/trace.rs): `replay/src/trace.rs`
- [Synthetic tokens](https://github.com/uw-syfi/tracelab/blob/main/replay/src/tokens.rs): `replay/src/tokens.rs`
- [Session replay](https://github.com/uw-syfi/tracelab/blob/main/replay/src/session.rs): `replay/src/session.rs`
- [Generation backend](https://github.com/uw-syfi/tracelab/blob/main/replay/src/backend.rs): `replay/src/backend.rs`
- [Step logging](https://github.com/uw-syfi/tracelab/blob/main/replay/src/record.rs): `replay/src/record.rs`

### Other components

- **Trace owner**
- **Browser user**

## Connections

- Trace owner → Trace collection: collects traces (evidence: `README.md`)
- Trace collection → Claude extraction: extracts rounds (evidence: `README.md`)
- Trace collection → Codex extraction: extracts rounds (evidence: `README.md`)
- Trace owner → Trace sanitization: sanitizes trace (evidence: `README.md`)
- Trace sanitization → Privacy safeguards: applies safeguards (evidence: `README.md`)
- Trace sanitization → Trace database: materializes trace (evidence: `README.md`)
- Trace database → Workload experiments: feeds analysis (evidence: `README.md`)
- Trace database → Prefix-cache analysis: feeds analysis (evidence: `README.md`)
- Trace database → Tool-call analysis: feeds analysis (evidence: `README.md`)
- Trace database → Human-loop analysis: feeds analysis (evidence: `README.md`)
- Trace database → Session analysis: feeds analysis (evidence: `README.md`)
- Trace database → Trace facts: feeds analysis (evidence: `README.md`)
- Trace database → Web analytics data: queries database (evidence: `artifacts/web_analytics/analyze.py`)
- Web analytics data → Trace validators: supports audits
- Trace owner → Browser user: explores traces
- Browser user → Trace ingest: drops trace (evidence: `README.md`)
- Trace ingest → Ingest interface: returns ingest results (evidence: `web/app/src/lib/ingestUi.ts`)
- Ingest interface → Browser analysis worker: starts analysis
- Browser analysis worker → Worker protocol: exchanges messages (evidence: `web/app/src/lib/worker/analyze.worker.ts`)
- Browser user → Ask-the-trace client: asks trace questions (evidence: `README.md`)
- Ask-the-trace client → Worker protocol: uses protocol (evidence: `web/app/src/lib/ai/askClient.ts`)
- Ask-the-trace client → Ask-the-trace service: sends chat requests (evidence: `README.md`)
- Ask-the-trace service → LLM runtime: runs chat turns (evidence: `web/ai_infra/app.py`)
- Browser user → Contribution API: contributes trace (evidence: `README.md`)
- Contribution API → Contribution storage: stores contributions (evidence: `web/server/app.py`)
- Replay CLI → Replay trace loader: loads session trace (evidence: `replay/src/main.rs`)
- Replay CLI → Synthetic tokens: builds token pool (evidence: `replay/src/main.rs`)
- Replay CLI → Session replay: runs sessions (evidence: `replay/src/main.rs`)
- Session replay → Synthetic tokens: builds prompts (evidence: `replay/src/session.rs`)
- Session replay → Generation backend: sends inference (evidence: `replay/src/session.rs`)
- Session replay → Step logging: emits step logs (evidence: `replay/src/session.rs`)
