| File | Role |
|---|---|
teaagent/audit.py |
AuditLogger, redaction helpers, AuditEvent dataclass |
teaagent/audit_chain.py |
Hash-chain verification, ChainVerificationResult, last_chain_hash |
teaagent/audit_export.py |
Export helpers (JSON, CSV formats) |
teaagent/audit_viewer.py |
CLI-facing viewer, filtering, display |
teaagent/governance/audit_completeness.py |
Checks that required event types are present |
teaagent/telemetry/_audit.py |
OpenTelemetry sink adapter |
AuditEvent— frozen dataclass:event_type,run_id,payload,event_id,created_atAuditLogger— primary class:record(),add_sink(),enable_opentelemetry(),verify_chain_integrity()redact_audit_payload()— recursively redacts sensitive fieldsredact_sensitive_string()— applies regex patternsis_sensitive_key()— key-name sensitivity checksecure_audit_dir(),secure_audit_file()— chmod helpers- Constants:
AuditLevel,MAX_AUDIT_STRING_LENGTH=20_000,AUDIT_REDACTED,AUDIT_TRUNCATED
ChainVerificationResult— frozen dataclass:valid,event_count,errorverify_audit_chain(log_path, secret_key?)— reads JSONL, verifies SHA-256 chain + optional HMACcompute_event_hash(obj)— canonical SHA-256 over 6 chain fieldscompute_chain_hmac(event_hash, secret_key)— HMAC-SHA256 bindinglast_chain_hash(log_path)— tails the file to findprev_hashfor next append
audit.py
├── teaagent.storage.file_lock
├── teaagent.telemetry (optional, ImportError-guarded)
└── teaagent.audit_chain (lazy import inside record())
audit_chain.py
└── stdlib only (hashlib, hmac, json, pathlib)
runner/_core.py— createsAuditLogger(path=run_dir/"audit.jsonl"), passes to agent loopcli/_handlers/_audit.py—audit_verify_command,audit_list_command,audit_show_commandchat_session_controller.py— creates audit logger for chat sessions
runner._core.AgentRunner.run()
└── AuditLogger.record("run_started", ...)
└── AuditLogger.record("tool_call_started", ...)
└── [tool execution]
└── AuditLogger.record("tool_call_completed" | "tool_call_failed", ...)
└── AuditLogger.record("run_completed" | "run_failed", ...)
cli._handlers._audit.audit_verify_command()
└── verify_audit_chain(path)
└── compute_event_hash(obj) × N