summaryeval

package
v2.1.1 Latest Latest
Warning

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

Go to latest
Published: Nov 24, 2026 License: MIT Imports: 41 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

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

Constants

This section is empty.

Variables

View Source
var ErrUsage = errors.New("compaction usage")

ErrUsage identifies invalid caller specifications, mapped to CLI exit 2.

Functions

func ListJSON

func ListJSON(headers []Header) ([]byte, error)

ListJSON returns the versioned compaction listing document.

func Read

func Read(dir string, s Selection) ([]Cut, Source, error)

Read selects T13 attempts or a raw self-contained export, never the original run store.

func Reconstruct

func Reconstruct(c Cut) (*agRuntime.SummarizeContextInput, error)

Reconstruct restores the production input solely from adopted run evidence.

func Resolve

func Resolve(root, ref string) (string, error)

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).

func Cuts

func Cuts(rec *runrecord.RunRecord) []Cut

Cuts returns threshold cuts in parent-first run order and canonical event order. Its input is a decoded RunRecord; it performs no I/O and does not mutate it.

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.

func Run

func Run(ctx context.Context, cfg Config, opts Options) (*Experiment, error)

Run verifies every baseline and plans every variant before making provider calls.

type Fact

type Fact struct {
	Claim    judge.Claim
	Category string
}

Fact adds an application-specific retention claim.

func Rubric

func Rubric() []Fact

Rubric returns the six built-in retention claims in stable order.

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.

func List

func List(root string) ([]Header, error)

List returns replay manifests newest first, ignoring the reserved cache directory.

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 Selection

type Selection struct {
	From, Export, Run string
	Attempts          []string
	All               bool
	Step, MaxCuts     int
}

Selection restricts immutable cuts without recomputing them.

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.

func Replay

func Replay(ctx context.Context, c Cut, in *agRuntime.SummarizeContextInput, client model.Client) (Side, error)

Replay invokes only the production summary activity in a fresh scratch store.

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.

func ParseVariant

func ParseVariant(cfg Config, spec string) (Variant, error)

ParseVariant validates the fixed-cut vocabulary and resolves named/file templates.

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.

type Verification

type Verification struct {
	Status    string `json:"status"`
	FirstCall int    `json:"first_call,omitzero"`
	Field     string `json:"field,omitzero"`
	Reason    string `json:"reason,omitzero"`
}

Verification distinguishes reproducible baselines from mismatches and missing evidence.

func Verify

func Verify(ctx context.Context, c Cut) (Verification, error)

Verify replays captured responses without consulting a registered model.

Jump to

Keyboard shortcuts

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