Documentation
¶
Overview ¶
Package audit keeps the hub's activity log: every tool call, from the assistants (the MCP endpoint), the admin and the CLI, with redacted arguments, in the activity table of homie.db (store.Activity). Admin actions (a plugin installed, the settings changed) go to MCP Gatekeeper's audit instead (core.AuditEntry).
Writer is the hub.Auditor every surface records into. Record never blocks the call path: records go through a buffered channel to one goroutine that batches them into store.Activity.Append; when the buffer is full a record is dropped and counted. Arguments are redacted again on the way in, whatever the caller did (Redact).
Index ¶
Constants ¶
const DefaultBuffer = 1024
DefaultBuffer is the number of records Record can queue before it starts dropping them.
Variables ¶
This section is empty.
Functions ¶
func ErrorText ¶
ErrorText is the error text of an activity record: "" when the call worked. Schema-validation failures quote the rejected argument values, and those may be secrets (a PIN, a pairing code) that Redact hid in the arguments, so they become a fixed message. Both go-sdk shapes are caught: the isError result of a typed handler (`validating "arguments": …`) and a JSON-RPC invalid-params error.
func Redact ¶
func Redact(args json.RawMessage) json.RawMessage
Redact returns args with the value of every object key matching sensitiveKey replaced by "[redacted]", at any depth. Empty input returns nil; input that is not JSON is replaced as a whole, since it cannot be inspected.
Types ¶
type Writer ¶
type Writer struct {
// contains filtered or unexported fields
}
Writer is the activity log's hub.Auditor. NewWriter starts it; Close stores what is queued and stops it.
func NewWriter ¶
NewWriter starts the writer over repo; log receives store failures (nil discards them).
func (*Writer) Dropped ¶
Dropped returns how many records were lost (a full queue, a closed writer or a store failure).
func (*Writer) OnStored ¶
func (w *Writer) OnStored(fn func([]store.ActivityRecord))
OnStored sets fn to receive every batch once it is stored, with the ids the store gave it (the admin publishes them as events). It runs on the writer's goroutine.