Documentation
¶
Index ¶
Constants ¶
const DirectionClientToServer = "client→server"
DirectionClientToServer names client-to-server audit direction.
const DirectionServerToClient = "server→client"
DirectionServerToClient names server-to-client audit direction.
Variables ¶
This section is empty.
Functions ¶
func MatchFilter ¶
func MatchFilter(entry Entry, filter QueryFilter) bool
MatchFilter reports whether entry satisfies filter.
Types ¶
type Entry ¶
type Entry struct {
ID string `json:"id"`
Timestamp time.Time `json:"timestamp"`
Direction string `json:"direction"`
Transport string `json:"transport"`
Method string `json:"method"`
RequestID string `json:"request_id,omitempty"`
ToolName string `json:"tool_name,omitempty"`
Params json.RawMessage `json:"params,omitempty"`
Result json.RawMessage `json:"result,omitempty"`
Error *RPCError `json:"error,omitempty"`
DurationMs int64 `json:"duration_ms"`
ClientID string `json:"client_id"`
ServerID string `json:"server_id"`
Signature string `json:"signature"`
}
Entry is a single audited JSON-RPC exchange or message.
func LimitNewest ¶
LimitNewest sorts entries newest first and applies limit.
type Logger ¶
type Logger struct {
// contains filtered or unexported fields
}
Logger records signed audit entries.
type LoggerConfig ¶
type LoggerConfig struct {
Store Store
Signer *Signer
Redactor Redactor
Log *slog.Logger
Transport string
ClientID string
ServerID string
Metrics MetricsRecorder
Trace TraceExporter
}
LoggerConfig configures a Logger.
type MetricsRecorder ¶ added in v0.4.0
type MetricsRecorder interface {
RecordAuditEntry(entry Entry)
}
MetricsRecorder records audit metrics.
type QueryFilter ¶
type QueryFilter struct {
Method string
ToolName string
ClientID string
From time.Time
To time.Time
Limit int
}
QueryFilter filters dashboard and API audit queries.
type RPCError ¶
type RPCError struct {
Code int `json:"code"`
Message string `json:"message"`
Data json.RawMessage `json:"data,omitempty"`
}
RPCError represents a JSON-RPC error object.
type Redactor ¶
type Redactor interface {
Redact(raw json.RawMessage) json.RawMessage
}
Redactor redacts sensitive values before entries are stored.
type Signer ¶
type Signer struct {
// contains filtered or unexported fields
}
Signer signs audit entries using HMAC-SHA256.
type Stats ¶
type Stats struct {
TotalToday int `json:"total_today"`
ErrorRate float64 `json:"error_rate"`
TopTools []ToolStat `json:"top_tools"`
}
Stats contains dashboard aggregate data.
func BuildStats ¶
BuildStats builds dashboard statistics from entries.
type Store ¶
type Store interface {
Append(entry Entry) error
Query(filter QueryFilter) ([]Entry, error)
Stats() (Stats, error)
Close() error
}
Store persists and queries audit entries.
type TraceExporter ¶ added in v0.6.0
TraceExporter exports audit entries to an operational tracing backend.