audit

package
v0.5.1 Latest Latest
Warning

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

Go to latest
Published: Nov 22, 2026 License: MIT Imports: 13 Imported by: 0

Documentation

Overview

Package audit records structured execution and error telemetry for PTC runs.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ClassifyError

func ClassifyError(phase, msg string, traces []sandbox.OpTrace) string

ClassifyError assigns an actionable optimization category to compile, runtime, or capability errors.

func DiscoverLogDirs

func DiscoverLogDirs(explicitDataDir string) []string

DiscoverLogDirs returns candidate AgyPTC / MCPlex log directories ordered by priority. When explicitDataDir is non-empty, only that directory is inspected so tests and isolated runs never mix with global logs.

func FormatFullStreamCard

func FormatFullStreamCard(e Entry) string

FormatFullStreamCard renders a compact live monitor card showing input code, host ops, and return result for `agy-ptc logs -f`.

func FormatLogs

func FormatLogs(entries []Entry, usedFiles []string, tail int, runID string) string

FormatLogs renders recent entries or a full single-run diagnostic view (`runID != ""`).

func FormatStats

func FormatStats(entries []Entry) string

FormatStats aggregates execution logs into an actionable optimization report (error categories & failing capabilities).

func PayloadKeyLengths

func PayloadKeyLengths(payloads map[string]string) map[string]int

PayloadKeyLengths extracts only key names and byte sizes so sensitive file contents aren't duplicated in telemetry.

Types

type Entry

type Entry struct {
	ID            string            `json:"id"`
	Timestamp     string            `json:"timestamp"`
	Cwd           string            `json:"cwd"`
	Title         string            `json:"title"`
	Status        string            `json:"status"` // "ok" | "partial_op_error" | "compile_error" | "runtime_error" | "timeout"
	ErrorCategory string            `json:"errorCategory,omitempty"`
	ErrorMessage  string            `json:"errorMessage,omitempty"`
	DurationMs    int64             `json:"durationMs"`
	HostOps       int               `json:"hostOps"`
	FailedOps     int               `json:"failedOps"`
	ResponseBytes int               `json:"responseBytes"`
	AutoSpilled   bool              `json:"autoSpilled,omitempty"`
	PayloadKeys   map[string]int    `json:"payloadKeys,omitempty"` // key -> byte length (values omitted for secret safety)
	Traces        []sandbox.OpTrace `json:"traces,omitempty"`
	Logs          []string          `json:"logs,omitempty"`
	Warnings      []string          `json:"warnings,omitempty"`
	Code          string            `json:"code,omitempty"`
	ResultPreview string            `json:"resultPreview,omitempty"`
}

Entry represents a single recorded `mcp_agy-ptc_vm_exec` run in `executions.jsonl` / `errors.jsonl`.

func LoadEntries

func LoadEntries(explicitDataDir string, errorsOnly bool) ([]Entry, []string, error)

LoadEntries loads entries across discovered log directories, sorted oldest-to-newest.

type Logger

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

Logger writes structured JSONL execution and error logs under `<dataDir>/logs/`.

func NewLogger

func NewLogger(dataDir string) *Logger

NewLogger initializes an audit logger inside `<dataDir>/logs`.

func (*Logger) Record

func (l *Logger) Record(e Entry)

Record persists an execution entry to `executions.jsonl`, and also to `errors.jsonl` whenever any error occurred.

Jump to

Keyboard shortcuts

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