Documentation
¶
Overview ¶
Package summaryeval evaluates recorded compaction cuts independently of agent execution. Read loads a T13 experiment or raw runrecord export; Cuts extracts threshold summaries, rejected attempts and optional receipt-only evictions. Verify replays recorded responses in an isolated runtime and checks request digests, rejection kind and checkpoint identity before any variant runs.
Run uses the production SummarizeContextActivity for each cut, variant and repeat. It preserves the recorded previous summary, evidence and cut budget; planners, tools and recall never run. Prompt templates use Previous, Evicted, Instructions and Budget. Cut-moving and chained variants are outside this API.
Private versioned replays and summary caches live under _compaction in the eval store. Judgments use eval/judge, share the old side across variants, and are not cached. Aggregate excludes unverified baselines and incomplete comparisons. Callers supply gated models and optional application facts through Config.
Index ¶
- Variables
- func ListJSON(headers []Header) ([]byte, error)
- func Read(dir string, s Selection) ([]Cut, Source, error)
- func Reconstruct(c Cut) (*agRuntime.SummarizeContextInput, error)
- func Resolve(root, ref string) (string, error)
- func Show(w io.Writer, e *Experiment, full bool) error
- func ShowJSON(e *Experiment) ([]byte, error)
- type Call
- type Config
- type Cut
- type Experiment
- type Fact
- type Header
- type Judgment
- type Line
- type Model
- type Options
- type Preflight
- type Retention
- type Selection
- type Side
- type SideRetention
- type Source
- type Variant
- type VariantAggregate
- type VariantIdentity
- type Verification
Constants ¶
This section is empty.
Variables ¶
var ErrUsage = errors.New("compaction usage")
ErrUsage identifies invalid caller specifications, mapped to CLI exit 2.
Functions ¶
func Reconstruct ¶
func Reconstruct(c Cut) (*agRuntime.SummarizeContextInput, error)
Reconstruct restores the production input solely from adopted run evidence.
func Resolve ¶
Resolve selects an exact ID, unique prefix of eight or more bytes, or last terminal replay.
func Show ¶
func Show(w io.Writer, e *Experiment, full bool) error
Show writes cut evidence and summaries, abbreviated to twenty lines unless full.
func ShowJSON ¶
func ShowJSON(e *Experiment) ([]byte, error)
ShowJSON returns the versioned compaction show document.
Types ¶
type Call ¶
type Call struct {
Seq int `json:"seq"`
Digest runstore.Hash `json:"digest"`
Text string `json:"text"`
}
Call is the inspectable evidence of a scratch summarizer invocation.
type Config ¶
type Config struct {
Prompts map[string]string
Instructions map[string]string
NewModels func() (map[string]Model, error)
Facts func(context.Context, Cut) ([]Fact, error)
ReferenceBytes int
}
Config supplies named templates, instructions, gated models and application facts.
type Cut ¶
type Cut struct {
RunID string `json:"run_id"`
Step int `json:"step"`
From index.MessageID `json:"from"`
To index.MessageID `json:"to"`
Origin string `json:"origin"`
Record runstore.Hash `json:"record"`
Prev *runstore.Hash `json:"prev"`
ChainPos int `json:"chain_pos"`
EvictedBytes int `json:"evicted_bytes"`
Old Side `json:"-"`
// contains filtered or unexported fields
}
Cut identifies an immutable recorded eviction interval, [From, To).
type Experiment ¶
type Experiment struct {
Header Header `json:"header"`
Preflight Preflight `json:"preflight"`
Lines []Line `json:"lines"`
TruncatedTail bool `json:"truncated_tail"`
}
Experiment is a replay manifest and its append-only result lines.
func Load ¶
func Load(root, id string) (*Experiment, error)
Load strictly decodes complete lines; an unterminated final line is a torn tail.
type Header ¶
type Header struct {
Format string `json:"format"`
Version int `json:"version"`
ID string `json:"id"`
Label string `json:"label"`
Status string `json:"status"`
Started time.Time `json:"started"`
Finished time.Time `json:"finished"`
Source Source `json:"source"`
Identity eval.Identity `json:"identity"`
Variants []VariantIdentity `json:"variants"`
Judge *eval.JudgeInfo `json:"judge"`
Planned int `json:"planned"`
Tokens int `json:"tokens"`
Calls int `json:"calls"`
}
Header is the atomically replaced replay manifest.
type Judgment ¶
type Judgment struct {
eval.StoredJudgment
Side string `json:"side"`
Category string `json:"category"`
NoCall bool `json:"no_call"`
}
Judgment adds side and category to the standard eval judgment contract.
type Line ¶
type Line struct {
Key string `json:"key"`
Variant string `json:"variant"`
Repeat int `json:"repeat"`
Cut Cut `json:"cut"`
Verification Verification `json:"verification"`
Old Side `json:"old"`
New Side `json:"new"`
Judgments []Judgment `json:"judgments"`
JudgeUsage model.TokenUsage `json:"judge_usage"`
NotRun string `json:"not_run"`
Error string `json:"error"`
}
Line is one durable (cut, variant, repeat) result.
type Model ¶
type Model struct {
Client model.Client
Class model.ModelClass
AcceptsImages, AcceptsDocuments bool
Limits *model.ContextLimits
}
Model describes a summarizer. Limits supplies ContextInfo for clients lacking it.
type Options ¶
type Options struct {
// OnPreflight runs after all verification/planning and before any provider calls.
OnPreflight func(Preflight) error
Dir string
Source Source
Cuts []Cut
Variants []Variant
Repeat, Concurrency, MaxTokens int
Label string
DryRun, Fresh bool
Judge *judge.Judge
Notice io.Writer
Now func() time.Time
NewID func() (string, error)
}
Options configures one offline replay. Now and NewID support reproducible tests.
type Preflight ¶
type Preflight struct {
Cuts int `json:"cuts"`
CallUpperBound int `json:"call_upper_bound"`
InputTokens int `json:"input_tokens"`
}
Preflight records planned cut count, provider call upper bound and table-rate input estimate.
type Retention ¶
type Retention struct {
Entailed int `json:"entailed"`
Claims int `json:"claims"`
Retention float64 `json:"retention"`
}
Retention is an entailed fraction, without confidence intervals.
type Side ¶
type Side struct {
Kind string `json:"kind"`
Text string `json:"text"`
Bytes int `json:"bytes"`
RenderedBytes int `json:"rendered_bytes"`
Usage model.TokenUsage `json:"usage"`
Chunks int `json:"chunks"`
UnsummarisedBytes int `json:"unsummarised_bytes"`
LooseRefs int `json:"loose_refs"`
Latency time.Duration `json:"latency"`
Prompt *prompt.PromptRef `json:"prompt"`
Fingerprint string `json:"fingerprint"`
Checkpoint runstore.Hash `json:"checkpoint"`
Calls []Call `json:"calls"`
Cached bool `json:"cached"`
}
Side preserves a summary and its measured production output.
type SideRetention ¶
type SideRetention struct {
Entailed int `json:"entailed"`
Claims int `json:"claims"`
Retention float64 `json:"retention"`
Categories map[string]Retention `json:"categories"`
}
SideRetention includes totals and application/rubric categories.
type Source ¶
type Source struct {
Experiment string `json:"experiment,omitzero"`
Attempts []string `json:"attempts,omitzero"`
ExportSHA256 string `json:"export_sha256,omitzero"`
}
Source names the original experiment/attempts or the exported file's digest.
type Variant ¶
type Variant struct {
ID string `json:"id"`
Prompt string `json:"prompt"`
Template string `json:"template"`
Instructions *string `json:"instructions"`
Model string `json:"model"`
MaxSummaryChunks int `json:"max_summary_chunks"`
MaxSummarisedResultTokens int `json:"max_summarised_result_tokens"`
}
Variant is a validated fixed-cut change; ID is its sorted canonical specification.
type VariantAggregate ¶
type VariantAggregate struct {
OldBytes int `json:"old_bytes"`
NewBytes int `json:"new_bytes"`
Tokens int `json:"tokens"`
Chunks int `json:"chunks"`
Latency time.Duration `json:"latency"`
Variant string `json:"variant"`
Cuts int `json:"cuts"`
Old SideRetention `json:"old"`
New SideRetention `json:"new"`
Better int `json:"better"`
Worse int `json:"worse"`
Same int `json:"same"`
}
VariantAggregate includes only verified, completed paired comparisons.
func Aggregate ¶
func Aggregate(lines []Line) []VariantAggregate
Aggregate pools claim counts for verified cuts; unverified and incomplete lines are excluded.
type VariantIdentity ¶
type VariantIdentity struct {
ID string `json:"id"`
Fingerprint string `json:"fingerprint"`
Prompt prompt.PromptRef `json:"prompt"`
Template runstore.Hash `json:"template"`
ModelID string `json:"model_id"`
}
VariantIdentity identifies effective settings for a variant on one cut.