audit

package
v0.0.20 Latest Latest
Warning

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

Go to latest
Published: Nov 6, 2026 License: AGPL-3.0 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 is the local JSONL log of AI actions. Files live in <dataDir>/ai-audit/YYYY-MM.jsonl, one JSON object per line. A line never contains file contents, command output, or secrets. A month file is deleted only when that whole month is older than the retention window (default 90 days). On open, an existing month file is tightened to 0600 and the directory to 0700 (Windows has no mode bits).

Index

Constants

View Source
const DefaultRetentionDays = 90

DefaultRetentionDays is the retention window when the caller passes zero or a negative number.

Variables

This section is empty.

Functions

func NormalizeRetention

func NormalizeRetention(days int) int

NormalizeRetention returns days, or DefaultRetentionDays when days <= 0.

Types

type Filter

type Filter struct {
	Host string
	From time.Time
	To   time.Time
}

Filter selects records. A zero time is unbounded. Host is exact; empty matches every host. From and To are inclusive.

type Log

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

Log appends audit records. It is safe for concurrent Record calls.

func New

func New(dataDir string) *Log

New writes under dataDir/ai-audit.

func (*Log) Export

func (l *Log) Export(w io.Writer, f Filter) error

Export writes matching lines as JSONL. Malformed lines are skipped.

func (*Log) Prepare

func (l *Log) Prepare() error

Prepare creates the log directory. The gate calls it before a run.

func (*Log) Prune

func (l *Log) Prune(now time.Time, days int) error

Prune deletes month files whose next month starts at or before now-days. days <= 0 uses DefaultRetentionDays. Other files are left in place.

func (*Log) Read

func (l *Log) Read(f Filter) ([]policy.AuditRecord, error)

Read returns matching records. A malformed line is skipped.

func (*Log) Record

func (l *Log) Record(r policy.AuditRecord) error

Record appends one line to the month file of r.Time (in that time's zone).

Jump to

Keyboard shortcuts

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