Architecture & Metrics Baseline

Engineering metrics baseline and architecture observability.

Architecture & Metrics Baseline

Purpose: Architectural reference for follow-up metrics, onboarding, and product decisions.
Source of truth: This document is derived from the codebase only (agentrust-edge/, agentrust_sdk/, k8s/). External URLs and CLI stubs are called out where the code references them but does not implement them.

Last reviewed against: gateway, SDK, dashboard, docker-compose, and k8s manifests in this repository.


Table of contents

  1. What problem this code solves
  2. How users can use this platform
  3. Edge-only vs server deployment
  4. Server-side management requirements
  5. Agent development support
  6. Evolving into an agent certification harness
  7. Integrating new agent frameworks
  8. Metrics to track
  9. Repository layout
  10. Explicit gaps (not in repo)

1. What problem this code solves

This repository implements runtime governance for AI agent executions. Each agent run is validated, scored, risk-rated, and given a decision before its output is treated as trustworthy.

Core pipeline

The primary entry point is POST /v1/runtime/validate in agentrust-edge/gateway/routes/runtime.py. The documented pipeline:

  1. Fetch historical reliability (Redis cache → audit store)
  2. Run six-check ValidationEngine
  3. Run seven-signal ConfidenceEngine
  4. Run full RiskEngine (formula scoring)
  5. Run DecisionEngine
  6. Persist to append-only audit ledger
  7. Push escalate / request_evidence decisions to review queue (fire-and-forget)
  8. Enqueue LLM judge job for slow-path enrichment (fire-and-forget)

Validation (fast path)

ValidationEngine in agentrust-edge/gateway/engines/validation_engine.py is documented as target: <20ms, zero LLM calls. It runs:

CheckRole
SchemaOutput structure validation
Tool trustTool call / result verification
PolicyPolicy pack rules
ConsistencyOutput consistency (with optional contradiction detector)
Golden testsYAML-defined regression rules
GroundingEvidence / grounding checks
AdversarialHard gate; caps policy score on failure

Decisions and risk

Defined in agentrust-edge/gateway/models/envelope.py:

  • Decision outcomes: approve, retry, request_evidence, escalate, block, pending
  • Risk tiers: low, medium, high, critical
  • Frameworks: LangGraph, CrewAI, OpenAI Agents, Claude Agents, MCP, Custom, REST

Supporting capabilities (in code)

ConcernImplementation
Confidence scoringConfidenceEngine — weighted signals: schema, tool trust, policy, consistency, evidence, judge, historical reliability
Audit & complianceAuditStore, /v1/audit/*, 90-day payload retention loop in main.py
Human reviewreview_queue for escalate / request_evidence
Async LLM judgeRedis worker started in gateway lifespan (main.py)
Multi-agent trustparent_envelope_id + trust_chain_service (can block on violation)
Golden / regression testsgateway/config/golden_tests/*.yaml (e.g. payment_agent.yaml)
Reliability over timereliability_service, /v1/agents/{agent_id}/reliability

Product naming (from code)

  • Gateway: AgentTrust Edge Gateway (agentrust-edge/gateway/main.py)
  • SDK: AgentTrust Edge — the AI Agent Harness (agentrust_sdk/pyproject.toml)

Problem statement (from behavior): Agents from many frameworks produce structured outputs and tool calls. This stack measures trustworthiness per execution, enforces policy, records an auditable envelope, and routes risky runs to human review—with deterministic checks on the fast path and optional async LLM judging on the slow path.


2. How users can use this platform

2.1 Local / self-hosted stack

agentrust-edge/docker-compose.yml runs:

ServicePortRole
Postgres5432Audit and execution storage
Redis6379Job queue, rate limiting, cache
Gateway8000Validate + management APIs
Dashboard3000React UI (VITE_API_URL → gateway)

Required env (from compose): POSTGRES_PASSWORD, REDIS_PASSWORD, AGENTRUST_JWT_SECRET; optional AGENTRUST_API_KEYS.

2.2 HTTP API — validate

Endpoint: POST /v1/runtime/validate
Router prefix: /v1/runtime (routes/runtime.py)

Clients send agent id, framework, request (user, input), execution metadata (model, tools, latency, tokens), and output. Response includes envelope_id, validation scores, risk, decision, latency, and governance disclosure text.

2.3 Other gateway APIs

Routers registered in agentrust-edge/gateway/main.py:

PrefixPurpose
/v1/runtimeValidate executions
/v1/auditList/get executions, verify audit chain
/v1/reviewHuman review queue
/v1/policyPolicy evaluation
/v1/agentsAgent reliability metrics
/v1/analyticsAnalytics
/v1/alertsAlerts
/v1/feedbackFeedback
/v1/healthHealth checks

2.4 Python SDK (agentrust-sdk v2.0.0)

MechanismLocationBehavior
@harness decoratoragentrust_sdk/decorator.pyWraps agent functions; validates after execution
validateSame moduleAlias for @harness
AgentTrustClient / AsyncAgentTrustClientagentrust_sdk/client.pyHTTP client; tier-gated response fields
OSS tier (no API key)client.pyLocal schema-only via _oss_schema_only; no HTTP
LangGraph adapteradapters/langgraph.pyAgentTrustNode (Team tier)
CrewAI adapteradapters/crewai.pyAgentTrustCallback (Team tier)
CLIcli.pyinit, whoami, status, policy, audit tail, etc.

Default gateway URL: http://localhost:8000 (client.py, decorator._resolve_base_url reads config control_plane_url with same default).

Blocking behavior: @harness can raise BlockedError on block or review outcomes when configured (decorator.py).

2.5 Dashboard

React app (agentrust-edge/dashboard/src/App.tsx):

RoutePage
/Dashboard home
/executionsExecutions list
/executions/:idExecution detail
/reviewReview queue
/reliabilityAgent reliability
/policiesPolicy packs
/healthSystem health

Roles stored in browser localStorage: admin, auditor, developer (client-side only; not enforced by gateway auth by default).

2.6 Tier and auth model

  • API key / JWT via header X-AgentTrust-Token (middleware/auth.py, auth.py)
  • Capabilities gated by tier in agentrust_sdk/tiers.py: OSS → Team → Enterprise
  • Without a key, SDK uses OSS tier (local schema validation only)

3. Edge-only vs server deployment

What the code ships

DeploymentEvidence
Docker ComposeFull stack in agentrust-edge/docker-compose.yml
Kubernetesk8s/agentrust-edge/ (also agentrust-edge/k8s/) — postgres, redis, gateway (multi-replica in 03-gateway.yaml), dashboard, ingress
NamingProduct is Edge Gateway; SDK defaults to local gateway URL
Enterprise flagCapability.SELF_HOSTED in tiers.py — message references Enterprise tier; no separate control-plane binary in repo
SDK URLcontrol_plane_url optional on client; resolves to same HTTP validate surface as base_url

Conclusion

ShapeSupported in repo?
Single machine / “edge-like” (compose)Yes
K8s / datacenter serverYes — same gateway + Postgres + Redis + dashboard
Separate SaaS control plane serviceNot implemented — CLI and tier flags reference it only

Edge here means tenant-owned governance runtime (self-hosted gateway + data plane), not a requirement for physical edge hardware. The same codebase deploys via compose or k8s.


4. Server-side management requirements

Required for full operation (in-repo)

ComponentRole
GatewayValidate pipeline + management APIs
PostgresAudit ledger, executions (DATABASE_URL)
RedisJudge queue, rate limit, cache (REDIS_URL)
DashboardOptional UI; API-only integration is valid
ConfigPolicy and golden-test YAML under gateway/config/; settings via env (config/settings.py)

Gateway lifespan (main.py): DB migrations on startup, judge worker, retention maintenance every 6 hours.

Not required in-repo (referenced but stubbed / external)

FeatureCode evidence
Remote control planeCLI policy sync / policy push print *Connect to control plane — agentrust init first* without HTTP implementation (cli.py`)
Central auditCapability.CENTRAL_AUDIT in tiers.py — no separate central audit service
Policy sync from cloudCapability.POLICY_SYNC — CLI stub only
Commercial URLsagentrust.io, docs.agentrust.io in pyproject.toml / CLI — not implemented in this repo

Conclusion: You do not need an external AgentRust server to run and manage what exists today. Operational management is gateway API + dashboard + Postgres/Redis. External “control plane” is a tier/commercial concept, not a second application in this repository.


5. Agent development support

Yes. The SDK is intended for integration during agent development and at runtime.

Integration patterns

  1. @harness — Wrap any Python callable; auto-detects framework from installed packages (_detect_framework in decorator.py: langgraph, crewai, langchain, autogen, llama_index → label, else REST).
  2. Explicit validateAgentTrustClient.validate(...) with agent_id, framework, I/O, tools_called, latency_ms, tokens, optional parent_envelope_id (Enterprise trust chain).
  3. Framework adapters — LangGraph node, CrewAI callback (Team tier, tier check at construction).
  4. Gateway Framework enum — Accepts known framework strings on validate requests.
  5. OSS path — Development without API keys: local schema validation only.
  6. Golden tests — YAML suites under gateway/config/golden_tests/ for regression-style checks (e.g. payment agent status/transaction_id rules).

Model of integration

This is post-execution governance: the agent runs first; output (and tool metadata) is sent to the gateway for scoring and decision. It does not replace LangGraph, CrewAI, or other orchestration frameworks.


6. Evolving into an agent certification harness

There is no route, model, or service named “certification” in the gateway today. Certification would compose existing primitives plus new workflow APIs.

6.1 Building blocks already in code

Building blockLocationCertification-like behavior
Golden test engineengines/golden_test_engine.py + config/golden_tests/Pass/fail rules on output fields
Validation engineengines/validation_engine.pyMulti-check scorecard
Decision engineengines/decision_engine.pyApprove / block / escalate / etc.
Reliability APIroutes/agents.py, reliability_service.pyHistorical pass rates per agent
Audit trailAuditStore, /v1/audit/*Evidence for audits
Review queueservices/review_queue.pyHuman attestation
LLM judge (async)Judge worker; judge_backend in settingsSlow-path qualitative score
Trust chaintrust_chain_serviceMulti-agent linkage
Gateway teststests/test_phase2.py, test_phase4.py, test_phase5.pyPipeline regression
  1. Certification run API — e.g. POST /v1/certify/run accepting agent_id, framework, golden suite id, batch inputs; return aggregate pass rate and envelope IDs by reusing validate pipeline in a loop.
  2. Certification record — Postgres entity: certification_id, agent_id, framework, policy_version, golden version, aggregate confidence, outcome, expires_at; link to audit envelope_id list.
  3. Agent certification status — Extend /v1/agents/{agent_id}/reliability or add /v1/agents/{agent_id}/certification.
  4. CI harness mode — CLI or @harness(certify=True) running golden YAML from repo; fail CI on block or below confidence threshold.
  5. Framework profiles — Map Framework enum → required checks / policy weights in policy YAML.
  6. Human-in-the-loop certification — Review queue resolution flips certification from pending to approved.
  7. Certification KPIs — Aggregate pass rate, mean confidence, block rate by framework via analytics queries on audit store.

7. Integrating new agent frameworks

7.1 Minimal integration (works today)

  1. Pass framework on POST /v1/runtime/validate (string aligned with Framework enum or use Custom / REST).
  2. Use @harness(framework="MyFramework") or client.validate(..., framework="...").
  3. Add golden tests: gateway/config/golden_tests/my_agent.yaml with agent_id_pattern and matchers (see payment_agent.yaml).
  4. No adapter required if the agent sends structured output dict and optional tools_called.

7.2 SDK auto-detection

Extend _detect_framework() in agentrust_sdk/decorator.py:

for name, label in [
    ("langgraph", "LangGraph"),
    ("crewai", "CrewAI"),
    ("langchain", "LangChain"),
    ("autogen", "AutoGen"),
    ("llama_index", "LlamaIndex"),
    # ("new_pkg", "NewFramework"),
]:

7.3 First-class framework support

StepFile(s)Action
1gateway/models/envelope.pyAdd member to Framework enum
2agentrust_sdk/adapters/New adapter module (mirror crewai.py / langgraph.py)
3agentrust_sdk/tiers.pyOptional Capability.*_ADAPTER + min tier
4agentrust_sdk/pyproject.tomlOptional [project.optional-dependencies]
5gateway/config/golden_tests/Framework- or agent-specific suites
6TestsAdapter + validate integration tests

7.4 Policy and risk by framework

Policy routes accept a framework string; extend policy YAML under gateway/config/ for framework-specific tool allowlists or risk weights without changing core engines.

7.5 Tier gating

Follow AgentTrustCallback / LangGraph adapter pattern: _check_adapter_tier() before exposing adapter classes (adapters/crewai.py).


8. Metrics to track

Derived from the validate pipeline and stored fields. Use these for dashboards, SLOs, and certification KPIs.

MetricSource
Validate latency (ms)ValidateResponse.latency_ms (runtime.py)
Per-check scoresValidationScores on envelope
Final confidenceValidationEngine / ConfidenceEnginefinal_confidence
Risk tierRiskTier on envelope
Decision outcomeDecisionOutcome
Historical reliabilityreliability_service (Redis + audit)
Judge score (async)validation.judge_score when worker completes
Review queue depth/v1/review
Audit chain integrityGET /v1/audit/chain/verify
Golden test contributionGolden engine weights in validation scores
Block / escalate rateAggregate from audit store by agent_id, framework
Retention archived countRetention loop logs in main.py

Suggested operational SLOs (to define against your deployment)

SLOBaseline from code
Fast-path validate p99Engine target <20ms (ValidationEngine docstring); measure latency_ms in production
Audit write successStep 6 in validate pipeline must succeed for envelope persistence
Judge queue lagRedis worker; monitor time from enqueue to judge_score populated
Gateway availability/v1/health

9. Repository layout

agentrust/
├── agentrust-edge/
│   ├── gateway/           # FastAPI governance runtime
│   │   ├── routes/        # runtime, audit, review, policy, agents, …
│   │   ├── engines/       # validation, confidence, decision, risk, golden, …
│   │   ├── services/      # audit_store, job_queue, review_queue, …
│   │   └── config/        # golden_tests, policy packs, weights
│   ├── dashboard/         # React UI (Vite)
│   └── docker-compose.yml
├── agentrust_sdk/         # Python harness, client, adapters, CLI
└── k8s/agentrust-edge/    # Kubernetes manifests

10. Explicit gaps (not in repo)

The following are not implemented as runnable code in this repository:

  • Separate multi-tenant SaaS control plane service
  • Working policy sync / policy push to remote server (CLI stubs only)
  • Dedicated certification API or certification badge storage
  • Non-Python SDKs (only Python client in tree)
  • Server-side enforcement of dashboard roles (localStorage only in UI)

When planning metrics or compliance narratives, distinguish implemented behavior (gateway + SDK + compose/k8s) from tier/marketing capabilities declared in tiers.py and CLI help text.


Appendix — Key file index

TopicPath
Validate pipelineagentrust-edge/gateway/routes/runtime.py
Validation engineagentrust-edge/gateway/engines/validation_engine.py
Confidence engineagentrust-edge/gateway/engines/confidence_engine.py
Envelope modelsagentrust-edge/gateway/models/envelope.py
Gateway appagentrust-edge/gateway/main.py
Audit APIagentrust-edge/gateway/routes/audit.py
Docker stackagentrust-edge/docker-compose.yml
SDK clientagentrust_sdk/agentrust_sdk/client.py
Harness decoratoragentrust_sdk/agentrust_sdk/decorator.py
Tiers / capabilitiesagentrust_sdk/agentrust_sdk/tiers.py
CLIagentrust_sdk/agentrust_sdk/cli.py
Golden test exampleagentrust-edge/gateway/config/golden_tests/payment_agent.yaml
Dashboard routesagentrust-edge/dashboard/src/App.tsx