Documentation
¶
Overview ¶
Package gen generates candidate scenarios for one table via a single structured-output call, then validates, dedupes, and appends them. It accepts an inference.Client and never constructs one (dependency confinement, matching pkg/run's own BuildTarget).
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Append ¶
func Append(path string, tableFile []byte, specs []packfile.ScenarioSpec, generatedBy string) ([]byte, error)
Append inserts specs into tableFile's scenarios sequence via yaml.Node surgery: it parses tableFile into a yaml.Node tree, appends one new sequence item per spec to the existing "scenarios" node (creating an empty one if the table has none yet), and re-encodes the whole tree. Every other node in the tree -- including comments -- is left untouched, so this is NOT a strict-decode-then-re-encode round trip (which would lose them).
Each appended scenario gains a {generated-by: generatedBy} label, merged into any labels already present on the spec (overriding a prior "generated-by" value rather than duplicating the key). generatedBy is a caller-supplied "<model>/<date>" string; Append never reads the clock or a model catalogue itself. path is used only for diagnostics.
Types ¶
type Rejection ¶
Rejection names one candidate that did not make it into Result.Accepted and why, so a caller (and a human reviewing --no-write output) can see exactly what was dropped and reason about it -- never a silent drop.
type Request ¶
type Request struct {
Doc *packfile.Document
Table string // table name within Doc
N int // 1..50
Focus string // optional steer for seeded generation
Intent string // bootstrap mode: required when the table has no scenarios
Model model.Model
}
Request selects the table and steers generation.
type Result ¶
type Result struct {
Accepted []packfile.ScenarioSpec
Rejected []Rejection // failed Validate/lint or duplicate ID
InputText string // the prompt, for --no-write inspection
}
Result reports exactly what happened; nothing is dropped silently.
func Generate ¶
Generate builds one generation prompt for req.Table, sends it to client as a single structured-output call, and converts the model's batch response into validated packfile.ScenarioSpecs. Every candidate is accounted for: a candidate whose ID duplicates an existing scenario or another candidate in the same batch, or that fails packfile.ScenarioSpec.Scenario validation, lands in Result.Rejected with a Reason rather than being dropped, while every other candidate still lands in Result.Accepted (partial success, not all-or-nothing).
Generate validates req.N and locates req.Table before doing anything else, so a caller mistake is rejected before any paid call.