Governance
Audit log
Antraft records every decision. The tamper-evident logger hash-chains each record so any edit, reorder, or deletion is cryptographically detectable — a requirement for regulated and compliance use.
Tamper-evident logging
audit.py
from antraft.audit.tamper_evident import TamperEvidentAuditLogger log = TamperEvidentAuditLogger("audit.log", secret="signing-key")# attach to a runtime:runtime.auditor = log await runtime.run()print(log.verify()) # VerifyResult(ok=True, count=N, ...)Note
Each record stores the SHA-256 of
(previous_hash + record). With an optional HMACsecret, an attacker who rewrites the whole file still can't forge a valid chain.Verifying integrity
verify.py
from antraft.audit.tamper_evident import verify_chain res = verify_chain("audit.log", secret="signing-key")# res.ok -> bool# res.count -> records verified# res.broken_index-> first bad record (if any)# res.detail -> human-readable reasonWhat gets recorded
| Event | Contains |
|---|---|
action | The action, the decision (allow/deny/pause), and the reason. |
cognitive | Agent thoughts / reasoning steps. |
drift_warning | Anomalous behavior (e.g. tight loops). |
tool_error | A tool/validation/RBAC failure (non-fatal). |
run_complete | Terminal summary: actions, spend, status, final answer. |
Session recording & PII redaction
Capture full input/thought/action/output traces for replay, with PII scrubbed:
record.py
Antraft.agent(model, tools, task="...") .record_session("session.jsonl", redact_pii=True) .build()