Documentation
¶
Overview ¶
Package audit writes an append-only JSONL record of what tools did and what the user approved or denied. Secrets are masked before writing.
Index ¶
Constants ¶
const ( KindSession = "session_start" KindPrompt = "prompt" KindToolCall = "tool_call" KindToolResult = "tool_result" KindApproval = "approval" KindDenial = "denial" KindHook = "hook" KindRule = "rule" // a rule's verdict on a prompt or an answer (spec_041_gates) KindGuardrail = "guardrail" // a guardrail's decision on a prompt, a tool call, a result or an answer KindUndo = "undo" KindAttachment = "attachment" // an image sent to the model: path and hash only KindUserShell = "user_shell" // a command the user ran with "!" (not an agent action) KindUserSearch = "user_search" // a web search the user ran with /search web KindTurnEnd = "turn_end" // a turn that didn't finish: stopped, or at a limit (Decision) )
Kinds of audit entries.
const ( DecisionSteer = "steer" // a prompt sent while a turn ran (Workspace.Steer) DecisionStopped = "stopped" // the user stopped the turn DecisionLimit = "limit" // the turn reached a limit; Detail: steps, cost or time )
Decisions on a KindPrompt and a KindTurnEnd entry.
Variables ¶
This section is empty.
Functions ¶
func SessionFrom ¶ added in v0.8.3
SessionFrom is the session WithSession put in ctx ("" none).
Types ¶
type Entry ¶
type Entry struct {
Time time.Time `json:"time"`
Session string `json:"session,omitempty"`
Kind string `json:"kind"`
Tool string `json:"tool,omitempty"`
Args map[string]any `json:"args,omitempty"`
Detail string `json:"detail,omitempty"`
Decision string `json:"decision,omitempty"`
Error string `json:"error,omitempty"`
Workspace string `json:"workspace,omitempty"`
// Agent is the agent whose action it was: on denials and failed tool
// results only, which the harness's evidence blames agents with.
Agent string `json:"agent,omitempty"`
}
Entry is one audit record.
type Logger ¶
type Logger struct {
// contains filtered or unexported fields
}
Logger appends entries to <dir>/audit-YYYY-MM-DD.jsonl. A nil *Logger is a valid no-op, so callers never need to check whether auditing is enabled.
func (*Logger) Log ¶
Log appends an entry. Failures are reported once to stderr and otherwise ignored: auditing must never break the session.
func (*Logger) LogContext ¶ added in v0.8.3
LogContext is Log, with the session of ctx's turn when e names none, and the agent of ctx on a denial or a failed result.
func (*Logger) SetWorkspace ¶ added in v0.8.3
SetWorkspace sets the workspace later entries record when they name none. The session is each entry's own (LogContext): a workspace runs turns of several sessions at once, so the logger has none.