Documentation
¶
Overview ¶
Package cardcontract is the frame around a card's task (docs/SPEC-CARD-CONTRACT.md): the frame the member hands native (Frame), the result shape a child ends with (Result), and the profiles, keyed by model family, that write JOB.md and the shims first on the child's PATH so the child meets the frame through the commands it already knows.
Index ¶
- Constants
- Variables
- func FamilyOf(model string) string
- func Install(p Profile, f Frame, s Staged, shimDir string) error
- func IsFinish(job string, raw []byte) bool
- func LastPushed(job string) (branch, head string)
- func ParseCarryLine(log []byte) string
- func Prompt(job, card string) string
- func ReadFinish(job string) (typedrec.CardResult, bool)
- func ShapeText(kind string) string
- func StageRecipes(f Frame, job string) error
- func WriteFrame(path string, f Frame) error
- type Carry
- type Frame
- type Gate
- type GateRun
- type Profile
- type Shim
- type Staged
Constants ¶
const ( CarryNone = "none" // no earlier attempt pushed: the checkout is the tip CarryOK = "carried" // the earlier work applied cleanly: the checkout is the tip and that work CarryHeld = "held" // the tip already holds the earlier work: the checkout is the tip CarryConflict = "conflict" // the earlier work did not apply cleanly: the checkout is the bare tip )
The states of a carry.
const BrokenFindingText = "" /* 343-byte string literal not displayed */
BrokenFindingText is what every profile's read JOB.md says of a broken verdict (docs/SPEC-CARD-CONTRACT.md section 3): it names the defect, or it is no verdict.
const CarryLinePrefix = "STAGE CARRY "
CarryLinePrefix begins native's one line about a rework's carry, which the member reads from native's log into the finish's report, so the card's timeline says where the attempt was staged and whether the work before it came with it.
const FinishName = ".sprint/finish.md"
FinishName is the file in the job directory the gh shim records the finish in (gh pr create, gh pr review), in the result shape: a file the child is never told to write, so a RESULT.md the child writes after it does not overwrite it.
const FrameName = ".frame.json"
FrameName is the file name the member writes a frame under, beside the card file.
const JobName = "JOB.md"
JobName is the frame's text in the job directory, the first thing the child reads.
const PushedName = ".sprint/pushed.tsv"
PushedName is the file in the job directory the git shim records each push in: branch, head and checkout top, tab separated, one line a push.
const ReadTitle = "# JOB: read"
ReadTitle begins the first line of a read's JOB.md in every profile, and of no work's: a brief that speaks to its readers names it, so a work card never takes itself for a read and stops with nothing to do.
const RecipesName = "recipes"
RecipesName is the directory recipes are kept in, in the member's root, and staged into, in the job directory.
const StagedName = "staged"
StagedName is the file in the slot directory (outside the job, which the wall lets the child write) where native records the commit it staged, the one the member counts the child's commits from.
Variables ¶
var Families = []string{"claude", "openai", "gemini", "grok", "deepseek", "plain"}
Families are the model families a profile is keyed by, plain last: the fallback.
Functions ¶
func IsFinish ¶
IsFinish is whether raw is the finish the gh shim recorded in the job, byte for byte: native publishes that record as the card's result when the child wrote no RESULT.md.
func LastPushed ¶
LastPushed is the last head the git shim recorded in the job directory, "" when none.
func ParseCarryLine ¶
ParseCarryLine is the words of the last carry line in native's log, "" when it has none.
func ReadFinish ¶
func ReadFinish(job string) (typedrec.CardResult, bool)
ReadFinish is the finish the gh shim recorded in the job directory, and whether there is one (an empty file is none).
func StageRecipes ¶
StageRecipes copies the recipe files a frame names from the member's recipes directory into <job>/recipes, each at its own relative path (docs/SPEC-CARD-CONTRACT.md, staged recipes): a brief holds 16 KiB, a recipe a card works from can be larger, and the wall gives the child no forge to fetch one from. A name that is not a local relative path, or is not a regular file in the recipes directory, refuses the whole staging; every source is opened through an os.Root of the recipes directory, so no path component, a symlinked directory included, leaves it, and a refusal names the Stage line and the reason.
func WriteFrame ¶
WriteFrame writes a frame as JSON at path.
Types ¶
type Carry ¶
type Carry struct {
Base string // the base branch
Tip string // its tip on origin when the checkout was staged, a full sha
Prev string // the head carried: the last pushed head of any earlier attempt; "" when none pushed
From int // the attempt Prev is the head of
Staged string // the commit the checkout is at, the one the finish counts from
State string // CarryNone, CarryOK, CarryHeld or CarryConflict
}
Carry is how a rework's checkout was staged (docs/SPEC-CARD-CONTRACT.md, where a rework starts): at the tip of its base branch as staging found it on origin, with the work of the attempt whose head it continues carried on top when that work applies cleanly there. A rework staged at an earlier attempt's head instead stayed on a base hours old, and a fix that said to start again from the tip could not be obeyed: the finish refuses a head that does not descend from the staged commit (nova-tools#5215).
type Frame ¶
type Frame struct {
Kind string `json:"kind"` // work or read
Card string `json:"card"`
Attempt int `json:"attempt"`
Tier string `json:"tier,omitempty"`
Model string `json:"model"`
Repo string `json:"repo"` // the clone URL or local path the card works in; "" when it names none
BaseRef string `json:"base_ref,omitempty"` // the ref the card's work is based on (a pull request's base)
StageSha string `json:"stage_sha,omitempty"` // the commit staged: a previous attempt's pushed head, a read's head under read, else the card's base sha
Branch string `json:"branch"` // the branch the checkout is on: the card's sprint branch, a read's work branch
PrevHead string `json:"prev_head,omitempty"` // the last pushed head of any earlier attempt (sprint.BaseOf)
PrevFrom int `json:"prev_attempt,omitempty"` // the attempt PrevHead is the head of
Why string `json:"why,omitempty"` // a rework: how the attempt before ended
Finding string `json:"finding,omitempty"` // a rework: what the readers of the attempt before found
Fix string `json:"fix,omitempty"` // a rework: what the coordinator asks of this attempt
ReviewBase string `json:"review_base,omitempty"` // a read: the ref the change is reviewed against
Stage []string `json:"stage,omitempty"` // the recipe files the brief's Stage: header lines name, relative to Recipes
Recipes string `json:"recipes,omitempty"` // the member's recipes directory, <root>/recipes
// A decide read's bars on p(defect) (docs/SPEC-SPRINT.md section 6): native asks the
// read decision over the card and the diff before any child and routes the read by
// them; both empty for a strings read.
DecideBounce string `json:"decide_bounce,omitempty"`
DecideReview string `json:"decide_review,omitempty"`
// A work card's gate decision bars (docs/SPEC-SPRINT.md section 5, the gate verdict):
// native classifies a red gate's failures by them after the child, before the member
// reports the take; both empty for none.
DecideGateFlaky string `json:"decide_gate_flaky,omitempty"`
DecideGatePreexisting string `json:"decide_gate_preexisting,omitempty"`
}
Frame is what the member knows of one launch and hands native as a file: the repository and the commit to stage, the branch the checkout is on (and the member pushes), the attempt, what the attempt before left, the tier and the model. It is the packet's, never the brief's prose.
type Gate ¶
Gate is a read's gate: the packages it vets and tests whole, the class-test packages it runs some tests of, and whether go.mod or go.sum changed (the whole module is built).
type GateRun ¶
GateRun is a package a read runs only some tests of: one CI runs whole on every change.
type Profile ¶
type Profile interface {
Family() string
JobText(f Frame, s Staged) string
Shims(f Frame, s Staged) []Shim
}
Profile is how one model family meets the frame (docs/SPEC-CARD-CONTRACT.md section 5).
type Shim ¶
type Shim struct {
Name string // the command it answers for: git, gh
Script string // a POSIX sh script
}
Shim is one script a profile writes first on the child's PATH.
type Staged ¶
type Staged struct {
Job string // <slot>/jobs/<label>
Repo string // <job>/repo
Head string // the full sha the checkout is at
Git string // the real git, absolute
// Start is a read's: the commit the work under review started from, a full sha (the
// merge base of Head and the review base, found when the checkout was staged), so the
// read sees exactly the work's change however far the base branch has moved since;
// "" for work, or when no merge base was found.
Start string
GoCache string // the machine's shared build cache the child's GOCACHE names; "" when it has none
Gate *Gate // a read's gate (ReadGate); nil: the card's
// Carry is a rework's staging at the tip of its base branch (Carry); nil for a first
// attempt, a read, and a rework whose base is a sha or a tag, which never moves.
Carry *Carry
}
Staged is what native knows once the checkout is staged: the job directory, the checkout, the commit it is at, and the real git the shims hand through to.