Skip to main content

traceguard

Point-in-time correct LLM instrumentation — the time-integrity layer for LLM pipelines.

When you run LLMs over historical data — backtesting a signal, replaying a pipeline, re-scoring an archive — TraceGuard makes it structurally hard to accidentally use a model or prompt that did not yet exist at the point in time you are simulating.

It is not a dashboard or a gateway; it is the lower layer that guarantees the timeline underneath one. It interoperates with observability stacks (Langfuse / Phoenix via the optional traceguard[otel] exporter) rather than competing with them. See docs/POSITIONING.md.

  • traceguard.registry.models — model registry with released_at / available_to_us_at; select_model(..., strict=...) with mandatory explicit mode (no default), so anachronistic choices fail loudly.
  • traceguard.registry.prompts — git-tracked YAML prompt templates; load_prompt pins the content hash into every trace.
  • traceguard.sdk.tracer@tracer.trace decorator and tracer.span() context manager recording input hash, model/prompt versions, output, and perf into SQLAlchemy (SQLite by default).
  • traceguard.sdk.normalizer — the single canonical normalize_input / input_hash (sorted keys, fixed float precision, normalized whitespace).
  • traceguard.sdk.wrappers.anthropicwrap_anthropic auto-instruments an Anthropic SDK client (extra: traceguard[anthropic]).
  • traceguard.validators.lookahead — pure-function invariant validators (validate_feature_as_of, validate_model_timing, validate_reference_timing) that raise InvariantViolation; call them in pytest/CI.

Install

pip install traceguard

Requires Python 3.11+. Optional extras: pip install "traceguard[anthropic]" (Anthropic client wrapper) and pip install "traceguard[otel]" (OpenTelemetry / OpenInference export to Langfuse, Phoenix, or any OTLP backend).

Example

from datetime import datetime, timezone
from traceguard.registry.models import register_model, select_model
from traceguard.store.models import make_engine

engine = make_engine("sqlite:///traceguard.db")

register_model("demo-llm-2024", model_family="internal-ml",
               capability_class="general-llm",
               released_at=datetime(2024, 1, 10, tzinfo=timezone.utc),
               available_to_us_at=datetime(2024, 2, 1, tzinfo=timezone.utc),
               engine=engine)

# Backtesting as of mid-2025: models that arrived later are invisible.
model_id = select_model("general-llm",
                        available_at=datetime(2025, 6, 30, tzinfo=timezone.utc),
                        strict=True, engine=engine)

A complete runnable tour (synthetic data, no API keys) lives in examples/quickstart.

Contract

The binding interface contract — table schemas, SDK signatures, the four look-ahead invariants, SemVer rules — is in docs/SPEC.md.

Phase 0 scope: tracer, model/prompt registries, normalizer, invariants 1–3, Anthropic wrapper. Not yet: drift checks, replay sets (invariant 4), CLI, Postgres/TimescaleDB, OpenAI/Voyage wrappers — see TRACEGUARD_ROADMAP.md.

Development

cd packages/traceguard
uv sync
uv run pytest        # 70 tests

License

Apache-2.0.

Download files

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

Source Distribution

traceguard-0.3.0.tar.gz (73.0 kB view details)

Uploaded Source

Built Distribution

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

traceguard-0.3.0-py3-none-any.whl (32.5 kB view details)

Uploaded Python 3

File details

Details for the file traceguard-0.3.0.tar.gz.

File metadata

  • Download URL: traceguard-0.3.0.tar.gz
  • Upload date:
  • Size: 73.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.12

File hashes

Hashes for traceguard-0.3.0.tar.gz
Algorithm Hash digest
SHA256 e588830633654092731134a0286cf8343151d386f0ed6ee32112495562f4589d
MD5 911d98a5f5779f28eaa7be8659ce7ebb
BLAKE2b-256 5f3f26e170c4ccb36a987fb5ec0ba2213732c81edd0ed3d90f4135b16652f561

See more details on using hashes here.

File details

Details for the file traceguard-0.3.0-py3-none-any.whl.

File metadata

  • Download URL: traceguard-0.3.0-py3-none-any.whl
  • Upload date:
  • Size: 32.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.12

File hashes

Hashes for traceguard-0.3.0-py3-none-any.whl
Algorithm Hash digest
SHA256 94576aa68b93a025c254d33f2e90dafabf404fecb5c165a8c8750ff26fdd0eb3
MD5 0be5657d4090ad5ea229afe8cb42b0e7
BLAKE2b-256 8d56c9e15f3018ef06a5890a90898bffbeaa2bfd9c83ad80b7e56cfbd68362f8

See more details on using hashes here.

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