recipe

package
v0.207.0 Latest Latest
Warning

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

Go to latest
Published: Oct 30, 2026 License: Apache-2.0 Imports: 13 Imported by: 0 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 recipe is the recipe store of ADR 0036's 2026-10-15 amendment: a recipe is a typed record of closed-vocabulary agent_env_rules data, tagged with the seat capability it was distilled for, the acceptance-passing runs it came from and its status.

A recipe is DATA and nothing else. The record has six declared keys and refuses any other, the rule set is core.AgentEnvRules decoded the same strict way (so rules_code, the envharness key the ADR refuses by name, is an unknown key), and every string in it has a shape:

id, seat_tag     a slug; the id is also the file name in the store, so it cannot climb out of it
tool and argument names   a lower-case identifier
provenance entry a run id, no spaces
rewrite_error.text   one line of plain ASCII prose, at most 160 bytes, none of the characters
                     that carry code (backtick, $, braces, brackets, quotes, pipes, parentheses)
pattern          printable ASCII, at most 200 bytes, a Go (RE2) expression that does not match
                 the empty string (a pattern that fires on every result is a wipe, not a rule)

The shapes are not a safety argument by themselves. What keeps a recipe harmless is that an env rule never grants or denies an effect (ADR 0036, decision 3), that a recipe is only ever proposed or published by the audit, and that an operator applies it. The shapes keep the store from holding anything that is not rule data, so the next reader can review it as data.

Publishing is the audit's result and nothing else: a published record must carry the audit that earned it (verdict ADOPT, steps no worse than the incumbent's), so a record cannot be published by editing one word.

Index

Constants

View Source
const (
	StatusProposed  = "proposed"
	StatusPublished = "published"
	StatusDemoted   = "demoted"
)

Statuses.

View Source
const (
	MaxTextBytes    = 160 // rewrite_error.text: the bound the trace note uses for what the model was told
	MaxPatternBytes = 200
	MaxProvenance   = 64
)

Bounds on the free-form parts of a record.

Variables

This section is empty.

Functions

func CheckSeat

func CheckSeat(s string) error

CheckSeat reports whether s is shaped like a seat alias.

func Keys

func Keys() []string

Keys lists the rule keys of the vocabulary, in the order core.AgentEnvRules declares them.

func LiveABKeys

func LiveABKeys(r *core.AgentEnvRules) []string

LiveABKeys lists the keys a rule set uses that need a live A/B, in vocabulary order.

Types

type Audit

type Audit struct {
	Seat           string  `json:"seat"`
	BaselineHash   string  `json:"baseline_hash"`
	EraMarker      string  `json:"era_marker"`
	Verdict        string  `json:"verdict"`
	StepsIncumbent float64 `json:"steps_incumbent"`
	StepsCandidate float64 `json:"steps_candidate"`
}

Audit is the record of a recipe-audit run: which seat, which pre-registration, which era, the gate's verdict and the mean steps of the two arms over the tasks both finished.

func (Audit) StepsNoWorse

func (a Audit) StepsNoWorse() bool

StepsNoWorse reports whether the candidate used no more steps than the incumbent.

type Class

type Class string

Class says how a rule key may be scored (ADR 0036, the 2026-10-15 amendment).

const (
	// ClassReplay: the rule only removes or caps calls. A recorded trace holds the tool, the fate
	// and the stop class of every step, so it can be read against the rule without the seat
	// answering again: the branch (which tools may be called) and the parallelism (how many calls
	// of one tool a run makes), with the stop class of the run as what such a cut can move.
	ClassReplay Class = "replay"
	// ClassLiveAB: the rule changes an argument or what the seat reads. Every later step of the run
	// changes with it, and no recording says what the seat would have done next, so only a live
	// A/B on the seat can score it. recipe-audit is that A/B.
	ClassLiveAB Class = "live_ab"
)

func ClassOf

func ClassOf(key string) (Class, bool)

ClassOf returns the scoring class of a rule key, and false for a key outside the vocabulary.

type Recipe

type Recipe struct {
	// ID names the record and its file in the store.
	ID string `json:"id"`
	// SeatTag is the seat capability class the recipe was distilled for and audited on. A recipe
	// is evidence about one class of seat; it is never audited on another.
	SeatTag string `json:"seat_tag"`
	// Rules is the closed-vocabulary rule set: what would replace the seat's agent_env_rules.
	Rules core.AgentEnvRules `json:"rules"`
	// Provenance lists the acceptance-passing runs the rules were distilled from.
	Provenance []string `json:"provenance"`
	// Status is proposed, published or demoted.
	Status string `json:"status"`
	// Audit is what the last recipe-audit found. Nil on a proposed recipe.
	Audit *Audit `json:"audit,omitempty"`
}

Recipe is one record.

func Decode

func Decode(raw []byte) (Recipe, error)

Decode reads one recipe: exactly one JSON document, no unknown key anywhere in it (the rules and the audit included), no trailing data, and a record that validates.

func (Recipe) Encode

func (r Recipe) Encode() ([]byte, error)

Encode writes the canonical bytes of a record: two-space indent, LF, one trailing newline, no HTML escaping. It validates first, so a record that would not decode is never written.

func (Recipe) Validate

func (r Recipe) Validate() error

Validate refuses a record that is not closed-vocabulary rule data with its provenance and an audit consistent with its status. It reports every problem it finds, not the first.

type Store

type Store struct{ Dir string }

Store is a directory of recipe files, one per id, named <id>.json. Every file is read through Decode, so a store never hands back a record that would not decode, and a file whose record names another id than its file name does is refused.

func (Store) List

func (s Store) List() ([]Recipe, error)

List reads every <id>.json in the store, in id order. A file that does not decode fails the listing by name: a store with a bad record in it is not a store to read from. Other files (notes, temporary files of a save in flight) are not recipes and are passed over.

func (Store) Load

func (s Store) Load(id string) (Recipe, error)

Load reads one recipe by id.

func (Store) Path

func (s Store) Path(id string) (string, error)

Path is the file a recipe id lives in. An id that is not a slug is refused, which is what keeps an id from naming a path outside the store.

func (Store) Save

func (s Store) Save(r Recipe) error

Save writes a recipe to <id>.json, replacing what is there. The record is validated first and the file is written to a temporary name beside it and renamed over it, so a reader sees the old record or the new one, never half of either.

Jump to

Keyboard shortcuts

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