Documentation Index
Fetch the complete documentation index at: https://docs.tracectrl.ai/llms.txt
Use this file to discover all available pages before exploring further.
Overview
The TraceCtrl Engine is a FastAPI application that:- Runs a background pipeline every
PIPELINE_INTERVAL_SECONDSto process spans. - Serves a REST API under
/api/v1for the dashboard and external integrations. - Maintains cumulative state in ClickHouse using
ReplacingMergeTreetables.
Pipeline
Scheduled via APScheduler at the interval set byPIPELINE_INTERVAL_SECONDS (default: 60). Each tick re-reads all spans — there is no watermark on the main path; ReplacingMergeTree handles deduplication via background merges.
Update agent inventory
Group spans by
tracectrl.agent.id and upsert agent records. Tracks cumulative observation_count, run_count, tools_observed, and computes maturity (LEARNING → MATURE after 10 observations).Build topology
Create agent-to-agent edges (via
tracectrl.caller.agent_id or parent span resolution) and agent-to-tool edges. Edges carry cumulative counts and confidence levels (LOW → MEDIUM → HIGH).Ingest guardrail violations
Scan
otel_traces for tracectrl.guardrail.evaluation spans with decision in ('fail', 'error') and insert into guardrail_violations. A 5-minute lookback off the latest observed_at keeps it from rescanning the whole table every tick. Ingest guardrail registry
Scan
otel_traces for tracectrl.guardrail.registered spans and upsert into guardrail_registry. A health-override pass flips health='error' for any guardrail with a decision=error violation in the last hour. TAGAAI Rules
The engine ships four detection rules. Rule names and base CVSS come fromengine/rules/.
Rule (rule_name) | OWASP | Base CVSS | Trigger |
|---|---|---|---|
vulnerableToPromptInjection | ASI01 | 7.2 | Agent has a tool edge with external call-context > 0 AND no human_interaction tool. |
vulnerableToExcessiveAgency | ASI02 | 8.1 | Agent has access to code_execution or email tools without a human_interaction guardrail. |
vulnerableToDataLeakage | ASI01 + ASI02 | 6.8 | Agent chain where one reads from memory_read and another writes to external_api or email. |
ingressToEndpointAttackPath | ASI01/ASI02 (impact-dependent) | varies (5.0–9.0) | Multi-hop ingress → high-impact endpoint chain. Base CVSS varies by impact category. |
Guardrails Pipeline
The engine has two ingestion paths feeding the Alerts and Guardrails UI pages, both driven from spans the SDK already emits.Registration ingestion
update_guardrail_registry() reads tracectrl.guardrail.registered spans and writes one row per (agent_id, guardrail_name) to guardrail_registry. The ReplacingMergeTree version column is last_seen_at, so re-emitting the same registration just refreshes the row. Spans carry: severity, mode (monitoring/blocking), timing (pre_input/post_output), judge_model, description, judge_prompt, health (active/error/disabled), and provider (judge_llm or protector_plus).
Violation ingestion
update_violations() reads tracectrl.guardrail.evaluation spans with decision in ('fail', 'error') and writes them to guardrail_violations. The violation_id is the eval span id, so the ReplacingMergeTree dedupes re-inserts. Each row carries reason, evidence, severity, judge_model, and provider.
ClickHouse tables (guardrails)
| Table | Engine | Purpose |
|---|---|---|
guardrail_registry | ReplacingMergeTree(last_seen_at) ORDER BY (agent_id, guardrail_name) | One row per registered guardrail |
guardrail_violations | ReplacingMergeTree() ORDER BY (observed_at, violation_id) | One row per failing/erroring evaluation |
protector_plus_config | ReplacingMergeTree(updated_at) ORDER BY (id) | Single global row: endpoint, API key, enabled guardrails |
Configuration
| Variable | Default | Description |
|---|---|---|
CLICKHOUSE_HOST | localhost (clickhouse in compose) | ClickHouse host |
CLICKHOUSE_PORT | 9000 | ClickHouse native port |
CLICKHOUSE_DB | tracectrl | Database name |
PIPELINE_INTERVAL_SECONDS | 60 | Pipeline cycle interval |
Running Locally
When running locally, ensure ClickHouse is accessible at the configured host/port. The engine’s
ensure_schema() will create the tracectrl database and all tables on startup.
