audit

package
v0.7.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 19, 2026 License: Apache-2.0 Imports: 7 Imported by: 1 module, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

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

View Source
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_gates_041)
	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
)

Kinds of audit entries.

Variables

This section is empty.

Functions

This section is empty.

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"`
}

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 Open

func Open(dir string, r *redact.Redactor) (*Logger, error)

Open creates the audit directory (owner-only) and returns a logger.

func (*Logger) Close

func (l *Logger) Close() error

Close closes the current file.

func (*Logger) Log

func (l *Logger) Log(e Entry)

Log appends an entry. Failures are reported once to stderr and otherwise ignored: auditing must never break the session.

func (*Logger) SetContext

func (l *Logger) SetContext(session, workspace string)

SetContext sets the session and workspace recorded on later entries.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL