Documentation
¶
Index ¶
- type AuditRow
- type Logger
- func (l *Logger) Close() error
- func (l *Logger) CountCalls(agentID, toolName string, since time.Time) (int, error)
- func (l *Logger) CountCallsGlobal(toolName string, since time.Time) (int, error)
- func (l *Logger) Log(e *model.AuditEntry)
- func (l *Logger) Purge(days int) (int64, error)
- func (l *Logger) Query(limit, offset int) ([]AuditRow, error)
- func (l *Logger) RecordCall(agentID, toolName string)
- func (l *Logger) StartPurgeLoop(retentionDays int)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type AuditRow ¶
type AuditRow struct {
RequestID string `json:"request_id"`
AgentID string `json:"agent_id"`
BackendID string `json:"backend_id"`
ToolName string `json:"tool_name"`
Arguments string `json:"arguments"`
ACLResult string `json:"acl_result"`
RateLimitResult string `json:"rate_limit_result"`
ApprovalResult string `json:"approval_result"`
QueuePosition int `json:"queue_position"`
QueueWaitMs int64 `json:"queue_wait_ms"`
ExecStatus string `json:"exec_status"`
ExecDurationMs int64 `json:"exec_duration_ms"`
ErrorMessage string `json:"error_message"`
CreatedAt string `json:"created_at"`
}
AuditRow represents a row from the audit log for API queries.
type Logger ¶
type Logger struct {
// contains filtered or unexported fields
}
Logger writes audit entries and rate limit records to SQLite.
func (*Logger) Close ¶
Close stops the purge loop and closes the database. Safe to call multiple times.
func (*Logger) CountCalls ¶
CountCalls returns the number of calls by an agent for a tool since the given time. Returns an error if the DB query fails (callers should fail-closed).
func (*Logger) CountCallsGlobal ¶
CountCallsGlobal returns the number of calls for a tool across all agents since the given time. Returns an error if the DB query fails (callers should fail-closed).
func (*Logger) RecordCall ¶
RecordCall records a tool call for rate limiting.
func (*Logger) StartPurgeLoop ¶
StartPurgeLoop starts a background goroutine that purges old entries daily.