Documentation
¶
Overview ¶
Package ledger implements the append-only evidence ledger that every run writes and every report is rendered from.
The ledger is a JSON Lines file. Each line is one Event. Events are only ever appended: nothing in Spackle rewrites or truncates a ledger.
Index ¶
Constants ¶
const ( TypeRunStart = "run.start" TypeMap = "map" TypeLead = "lead" TypeSeeder = "seeder" TypeModelCall = "model.call" TypeToolCall = "tool.call" TypeIntent = "intent" TypeSandboxRun = "sandbox.run" TypeHTTPExchange = "http.exchange" TypeFinding = "finding.upsert" TypeVerdict = "verdict" TypeReject = "draft.reject" TypeBudgetSkip = "budget.skip" TypeNote = "note" TypeRunEnd = "run.end" )
Event types. Data shapes are defined by the packages that emit them.
const FileName = "ledger.jsonl"
FileName is the ledger file inside a run directory.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type BudgetSkip ¶
type BudgetSkip struct {
Cap string `json:"cap"` // which cap was reached
Skipped []string `json:"skipped"` // what was not examined
}
BudgetSkip is the data of a budget.skip event.
type Event ¶
type Event struct {
Seq int64 `json:"seq"`
TS time.Time `json:"ts"`
Parent int64 `json:"parent,omitempty"`
Type string `json:"type"`
Data json.RawMessage `json:"data"`
}
Event is one ledger line.
type HTTPExchange ¶
type HTTPExchange struct {
ID string `json:"id"`
Method string `json:"method"`
URL string `json:"url"`
Status int `json:"status"`
Note string `json:"note,omitempty"`
Ref string `json:"ref"`
}
HTTPExchange is the data of an http.exchange event: a pointer to one recorded request and response. The full exchange, redacted, is in the referenced evidence file.
type Intent ¶
type Intent struct {
ID string `json:"id"`
Title string `json:"title"`
Class string `json:"class,omitempty"`
Hypothesis string `json:"hypothesis"`
Files []string `json:"files,omitempty"`
LeadIDs []string `json:"lead_ids,omitempty"`
Priority int `json:"priority"`
Source string `json:"source"` // planner|fallback
}
Intent is the data of an intent event: one planned investigation.
type MapSummary ¶
type MapSummary struct {
Files int `json:"files"`
Skipped int `json:"skipped"`
Languages []string `json:"languages,omitempty"`
Frameworks []string `json:"frameworks,omitempty"`
EntryPoints int `json:"entry_points"`
InfraFiles int `json:"infra_files"`
TestCommand string `json:"test_command,omitempty"`
Endpoints int `json:"endpoints,omitempty"` // for a live target
}
MapSummary is the data of a map event.
type ModelCall ¶
type ModelCall struct {
Stage string `json:"stage"`
Provider string `json:"provider"`
Model string `json:"model"`
InputTokens int `json:"input_tokens"`
OutputTokens int `json:"output_tokens"`
Estimated bool `json:"estimated,omitempty"`
CostUSD float64 `json:"cost_usd"`
CostKnown bool `json:"cost_known"`
Error string `json:"error,omitempty"`
}
ModelCall is the data of a model.call event. It records accounting, not content: prompts and completions are kept out of the ledger.
type Reject ¶
type Reject struct {
Stage string `json:"stage"`
Intent string `json:"intent,omitempty"`
Reason string `json:"reason"`
}
Reject is the data of a draft.reject event.
type RunEnd ¶
type RunEnd struct {
Outcome string `json:"outcome"` // completed|budget-exhausted|failed
Note string `json:"note,omitempty"`
}
RunEnd is the data of a run.end event.
type RunStart ¶
type RunStart struct {
RunID string `json:"run_id"`
Version string `json:"version"`
Command string `json:"command"` // scan|debug|verify
Target string `json:"target"` // as the operator gave it, with credentials removed
TargetKind string `json:"target_kind"` // path|git|url
Commit string `json:"commit,omitempty"`
Mode string `json:"mode"` // deterministic|agentic
Provider string `json:"provider,omitempty"`
Model string `json:"model,omitempty"`
Offline bool `json:"offline,omitempty"`
// Scope is the authorized scope for a live target, as confirmed.
Scope string `json:"scope,omitempty"`
// ScopeSource says how authorization was given: scope-file, config or interactive.
ScopeSource string `json:"scope_source,omitempty"`
Isolation string `json:"isolation,omitempty"` // sandbox profile summary, or "no container runtime"
}
RunStart is the data of a run.start event.
type SandboxRun ¶
type SandboxRun struct {
FindingID string `json:"finding_id,omitempty"`
Purpose string `json:"purpose"` // poc|tests|fix-verify|repro|bisect
Image string `json:"image"`
Command string `json:"command"`
ExitCode int `json:"exit_code"`
TimedOut bool `json:"timed_out,omitempty"`
Isolation string `json:"isolation"`
OutputRef string `json:"output_ref,omitempty"` // path relative to the run directory
}
SandboxRun is the data of a sandbox.run event.
type SeederStatus ¶
type SeederStatus struct {
Name string `json:"name"`
Available bool `json:"available"`
Note string `json:"note,omitempty"`
Leads int `json:"leads"`
Error string `json:"error,omitempty"`
}
SeederStatus is the data of a seeder event.
type ToolCall ¶
type ToolCall struct {
Stage string `json:"stage"`
Tool string `json:"tool"`
Args string `json:"args"`
IsError bool `json:"is_error,omitempty"`
Bytes int `json:"bytes"`
}
ToolCall is the data of a tool.call event. Arguments are redacted and clipped; results are not stored, only their size.
type Verdict ¶
type Verdict struct {
FindingID string `json:"finding_id"`
Stage string `json:"stage"` // reviewer|prover|fixer|verify
Outcome string `json:"outcome"` // confirmed|dismissed|demonstrated|not-reproduced|fixed|fix-rejected
Reason string `json:"reason,omitempty"`
}
Verdict is the data of a verdict event: a change to a finding's standing.
type Writer ¶
type Writer struct {
// contains filtered or unexported fields
}
Writer appends events to a ledger. It is safe for concurrent use.
func Create ¶
Create starts a new ledger in dir, which must not already contain one. clock supplies event timestamps; nil means time.Now.
func Open ¶
Open reopens an existing ledger for appending, continuing its sequence. It is used by commands that add to a finished run, such as verify.