feat(audit): record LLM/HTTP exchanges, tool calls, approvals, capability changes and capsule loads
Author: MastaPCreated Sep 28, 2026Updated Sep 28, 2026
Summary
Write audit entries for the events that determine what an agent did. Today none of these are recorded:
- LLM and other HTTP exchanges;
- capsule tool calls;
- approval decisions;
- capability grants and revocations;
- capsule install and load.
Motivation
The signed audit log is the natural record of agent behaviour, but its production writers cover only admin requests, file, network and process host calls, and MCP server start/stop:
- LLM and HTTP.
AuditAction::LlmRequestexists but has no production writer. Kernel-mediated HTTP (every provider call) appears only intracing::debug!(crates/astrid-capsule/src/engine/wasm/host/http/backend.rs:637,646). An agent turn, including its outbound model request, adds no audit entry. - Approvals, capabilities, loads. Approval decisions, capability
mint/revoke, and capsule install/load outcomes (with the wasm and manifest
hashes that identify the code) are not audit entries. Install-hook file
writes pass no audit sink (
crates/astrid-capsule-install/src/lifecycle.rs:277). - Attribution. Host-call entries do not name the capsule that acted.
FileWritecarries a zero content hash (crates/astrid-kernel/src/audit_sink/mod.rs:611).
Anchoring the log externally (#1995/#1996) makes it fork-proof, but it can only certify what was written. #1367 describes receipts over admitted causal inputs, and #693 describes session receipts with coverage metadata. Both need these observations to exist first.
Proposed Implementation
- HTTP exchanges. Record kernel-mediated HTTP as a pre-commit entry before the request is sent: method, host, the hash of the request body with credentials redacted, a per-principal counter. A completion entry follows, with status, the hash of the raw response stream and provider request ids. The pre-commit makes silently re-asking a model visible. Content stays out of the log; only commitments are written.
- Tools and approvals. Emit
CapsuleToolCall(tool, arguments hash, result hash, outcome), and approval request/decision entries that link the request to the decision. - Capabilities and code. Emit capability grant/revoke entries, and capsule install/load entries that bind the wasm hash, manifest hash and engine profile.
- Attribution. Add capsule id and wasm hash to host-call entries, and store real content hashes for file writes.
- Credentials. Keep them out of committed data: inject provider
credentials on the host side, rather than having the guest read
api_keyfrom its environment and set the header itself (as aos-ce'scapsule-openai-compatdoes today), or redact them before hashing.
Alternatives Considered
- Capsule-side logging. A capsule could log its own LLM calls, but that is the capsule's word, and it is bypassable. The kernel's HTTP host is the single mediated point.
- Tracing/OTel. It is asynchronous, sampled, unsigned and not hash-chained, so it can't serve as the audit record.
Part of #1997.
Source: astrid-runtime/astrid