Documentation
¶
Overview ¶
Package observer turns a failed or blocked skill-workflow run into one concrete, reviewable artifact: a proposed project rule (see internal/ratchet) with a ready-to-run `tinyagent ratchet add` command. It also keeps a ledger of failure signatures so a failure that recurs after a proposal exists is flagged: the gate did not hold.
The observer is deterministic (no model call) and never applies a rule itself; a person runs the printed command.
Index ¶
Constants ¶
const MaxExcerpt = 2000
MaxExcerpt caps the stored check output excerpt, in bytes.
Variables ¶
This section is empty.
Functions ¶
func LedgerPath ¶
LedgerPath is the ledger file under the project root.
func LoadLedger ¶
LoadLedger reads the ledger: the latest entry per signature. A corrupt line is skipped and reported, never fatal.
func Normalize ¶
Normalize strips the parts of a line that change between runs of the same failure: paths, hashes, numbers and durations.
func ProposalsPath ¶
ProposalsPath is the proposals file under the project root.
Types ¶
type Entry ¶
type Entry struct {
Signature string `json:"signature"`
Stage string `json:"stage"`
FirstSeen string `json:"first_seen"`
LastSeen string `json:"last_seen"`
Count int `json:"count"`
ArtifactID string `json:"artifact_id"`
}
Entry is one ledger line. The latest line for a signature is its state.
type Observation ¶
type Observation struct {
// Observed is false for a passed or interrupted run: nothing written.
Observed bool
Proposal *Proposal // set on the first occurrence of a signature
Entry Entry
// Recurrence is set when the signature was already in the ledger.
Recurrence bool
// RuleID is the applied ratchet rule for this signature, if any.
RuleID string
// Warnings are non-fatal problems, such as a corrupt ledger.
Warnings []string
}
Observation is what Observe did for one run.
func Observe ¶
func Observe(res *harness.Result, root string, redact func(string) string, now time.Time) (Observation, error)
Observe records a failed or blocked run under root/.tinyagent/observer: a new signature gets one proposal and a ledger entry; a known signature bumps its count and is reported as a recurrence. Passed and interrupted runs are not observed. An error means a file couldn't be written; the caller should warn, not fail the run.
type Proposal ¶
type Proposal struct {
ID string `json:"id"`
Signature string `json:"signature"`
Created string `json:"created"`
Workflow string `json:"workflow"`
Status string `json:"status"`
Stage string `json:"stage"`
Reason string `json:"reason,omitempty"`
Method string `json:"check_method,omitempty"`
Argv []string `json:"check_argv,omitempty"`
Excerpt string `json:"check_output_excerpt,omitempty"`
Rule string `json:"rule"`
Incident string `json:"incident"`
Command string `json:"suggested_command"`
}
Proposal is one proposed project rule distilled from a failed run.