audit

package
v0.6.7 Latest Latest
Warning

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

Go to latest
Published: Jul 1, 2026 License: AGPL-3.0 Imports: 7 Imported by: 0

Documentation

Overview

Package audit records an append-only, local-first history of every operation that changes a database — migrations, fleet convergence/recovery, SQL writes, and inline row edits. Each line is one JSON object in ~/.litescope/audit.log, giving an "ops layer" the provenance it needs: who changed what, when, and how it turned out. There is no server; the log lives on the operator's machine.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func LogPath

func LogPath() string

LogPath returns the audit log location. LITESCOPE_AUDIT_LOG overrides it (used by tests); otherwise it is ~/.litescope/audit.log.

func Operator

func Operator() string

Operator resolves who is performing operations: LITESCOPE_OPERATOR if set, otherwise the OS username, otherwise "unknown".

func Record

func Record(e Entry) error

Record appends an entry to the audit log. It fills in Time and Operator when unset and is best-effort: a logging failure never blocks the operation, it is returned so the caller may surface it if it cares.

Types

type Entry

type Entry struct {
	Time     time.Time `json:"time"`
	Operator string    `json:"operator"`
	Action   string    `json:"action"`  // e.g. "migrate.apply", "fleet.converge", "sql.write"
	Target   string    `json:"target"`  // database path or fleet name
	Summary  string    `json:"summary"` // human-readable what-happened
	Outcome  string    `json:"outcome"` // "ok" | "error"
	Detail   string    `json:"detail,omitempty"`
}

Entry is one recorded operation.

func Read

func Read(limit int, target, action string) ([]Entry, error)

Read returns up to limit recent entries (newest first), optionally filtered by target substring and exact action. A missing log is not an error: it returns an empty slice.

Jump to

Keyboard shortcuts

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