audit

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Mar 6, 2026 License: Apache-2.0 Imports: 3 Imported by: 0

Documentation

Overview

Package audit implements structured audit logging to PostgreSQL.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AuditLogger

type AuditLogger interface {
	Log(ctx context.Context, event Event) error
	Query(ctx context.Context, filter QueryFilter) ([]Event, error)
	Count(ctx context.Context, filter QueryFilter) (int, error)
}

AuditLogger provides audit logging operations.

type Event

type Event struct {
	ID        string
	TenantID  string
	UserID    string
	RequestID string
	Action    string // e.g., "skill.execute", "model.generate"
	Resource  string // e.g., "skill/search", "model/claude"
	Outcome   string // "success", "failure", "timeout"
	Duration  time.Duration
	Metadata  map[string]string
	Timestamp time.Time
}

Event represents an audit log entry.

type PGAuditLogger

type PGAuditLogger struct {
	// contains filtered or unexported fields
}

PGAuditLogger implements AuditLogger using PostgreSQL (in-memory stub).

func NewPGAuditLogger

func NewPGAuditLogger() *PGAuditLogger

NewPGAuditLogger creates a new audit logger.

func (*PGAuditLogger) Count

func (l *PGAuditLogger) Count(ctx context.Context, filter QueryFilter) (int, error)

Count returns the number of events matching the filter.

func (*PGAuditLogger) Log

func (l *PGAuditLogger) Log(ctx context.Context, event Event) error

Log records an audit event.

func (*PGAuditLogger) Query

func (l *PGAuditLogger) Query(ctx context.Context, filter QueryFilter) ([]Event, error)

Query retrieves audit events matching the filter.

type QueryFilter

type QueryFilter struct {
	TenantID  string
	UserID    string
	RequestID string
	Action    string
	From      time.Time
	To        time.Time
	Limit     int
}

QueryFilter defines filters for audit queries.

Jump to

Keyboard shortcuts

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