audit

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Nov 29, 2026 License: MIT Imports: 13 Imported by: 0 modules, 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 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

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

func ErrorText(res hub.Result, err error) string

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

func NewWriter(repo store.Activity, log *slog.Logger) *Writer

NewWriter starts the writer over repo; log receives store failures (nil discards them).

func (*Writer) Close

func (w *Writer) Close()

Close stores what is queued and stops the writer.

func (*Writer) Dropped

func (w *Writer) Dropped() uint64

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.

func (*Writer) Record

func (w *Writer) Record(_ context.Context, e hub.AuditEntry)

Record queues a tool call; it never blocks.

Jump to

Keyboard shortcuts

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