Documentation
¶
Overview ¶
Package store is PlugIt's call log (SPEC §3.6 data/plugit.db, §3.7 step 9): one row of redacted metadata per tool call, kept for the API's log.retention, read by `plugit logs` and `plugit stats`. It is SQLite (modernc.org/sqlite: pure Go, no CGO) in WAL mode, so several `plugit serve` processes (one per MCP client) can write while a viewer reads.
Callers redact before recording: nothing here knows about secrets.
Index ¶
- Constants
- Variables
- type Call
- type DB
- func (db *DB) Close() error
- func (db *DB) Insert(ctx context.Context, c Call) (int64, error)
- func (db *DB) List(ctx context.Context, f Filter) ([]Call, error)
- func (db *DB) Prune(ctx context.Context, api string, before time.Time) (int64, error)
- func (db *DB) Stats(ctx context.Context, f Filter) ([]ToolStats, error)
- type Filter
- type Outcome
- type Recorder
- type ToolStats
Constants ¶
const ( MaxArgsBytes = 16 << 10 MaxPreviewBytes = 2 << 10 MaxErrorBytes = 1 << 10 )
Caps on stored text, so one huge call can't bloat the log.
const SchemaVersion = 1
SchemaVersion is the call log's schema version (PRAGMA user_version).
Variables ¶
var ErrNoLog = errors.New("no calls recorded yet")
ErrNoLog means there is no call log yet (nothing has been served).
Functions ¶
This section is empty.
Types ¶
type Call ¶
type Call struct {
ID int64 `json:"id"`
Time time.Time `json:"time"`
API string `json:"api"`
Toolset string `json:"toolset"`
Tool string `json:"tool"`
Op string `json:"op"`
Outcome Outcome `json:"outcome"`
Status int `json:"status,omitempty"`
Duration time.Duration `json:"duration_ns"`
Bytes int `json:"bytes,omitempty"`
Args json.RawMessage `json:"args,omitempty"`
Preview string `json:"preview,omitempty"`
Error string `json:"error,omitempty"`
}
Call is one logged tool call. Every text field is already redacted.
type DB ¶
type DB struct {
// contains filtered or unexported fields
}
DB is an open call log.
func Open ¶
Open opens (creating if needed) the call log at path. The directory is owner-only and the file is created 0600 before SQLite touches it; SQLite gives its -wal and -shm files the same permissions.
func OpenExisting ¶
OpenExisting opens the log for reading, or returns ErrNoLog if it doesn't exist yet. It never creates the file.
type Recorder ¶
type Recorder struct {
// contains filtered or unexported fields
}
Recorder writes calls in the background so recording never blocks or fails a tool call (SPEC §3.7 step 9). When its buffer is full, calls are dropped and counted.
func NewRecorder ¶
NewRecorder starts a recorder with room for buffer pending calls. onErr (may be nil) hears about write failures.
func (*Recorder) Close ¶
func (r *Recorder) Close()
Close stops accepting calls and waits for queued ones to be written.
type ToolStats ¶
type ToolStats struct {
API string `json:"api"`
Tool string `json:"tool"`
Calls int `json:"calls"`
Errors int `json:"errors"`
P50 time.Duration `json:"p50_ns"`
P95 time.Duration `json:"p95_ns"`
Bytes int64 `json:"bytes"`
Last time.Time `json:"last"`
Outcomes map[Outcome]int
}
ToolStats summarizes one tool's calls.