lab

package
v0.16.1 Latest Latest
Warning

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

Go to latest
Published: Nov 4, 2026 License: MIT Imports: 28 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 lab mechanises the lab conventions three hand-run experiments proved (itd-2609212137128014): a lab is a throwaway world pinned at one commit of a repository, run to answer one question, whose evidence lives at the operator level and whose knowledge enters the record only through capture.

The store is machine-scoped and keyed on the repository's root commit, the way the transcript and worktree stores are:

~/.abcd.noindex/lab/<root-sha>/index.jsonl        one registry line per lab
~/.abcd.noindex/lab/<root-sha>/<lab-id>/          one lab home
    INTENTION.md                          the question, before any mutation
    snapshot/                             a standalone clone at the pin
    home/                                 the lab's own HOME
    bin/                                  the work binary (and a test binary)
    state/preflight.md                    the preflight artefact
    state/probes/<probe>/                 one probe record per probe
    state/sweep.md                        the retraction sweep's artefact
    findings.md, corrections.md           running logs the harvest mines
    amendments.md                         procedure deltas the lab contributed
    harvest/harvest.md                    the assembled harvest

Every verb writes only under one lab home (the registry line is the store's own), and nothing is ever written into the repository a lab studies. Hand-run labs that predate the keyed layout sit beside the root-commit directories and are neither read nor written.

The package never writes to stdout: it returns results, and the front doors under internal/surface render them.

Index

Constants

View Source
const (
	KindProduct   = "product"
	KindProcedure = "procedure"
	KindResult    = "result"
	KindGate      = "gate"
)

The finding kinds the harvest sorts on.

View Source
const (
	SkippedWindow = "window"
	SkippedFailed = "adapter-failed"
)

SkippedWindow marks a pair whose state exceeded the adapter's window, so only the host answered; SkippedFailed one whose adapter call failed.

View Source
const (
	GroupIsolation  = "harness-isolation"
	GroupDualBinary = "dual-binary"
)

The two check groups the preflight runs.

View Source
const MaxStateBytes = maxDocBytes

MaxStateBytes bounds one procedure record read back; a procedure never writes one larger.

Variables

View Source
var ErrHalted = errors.New("lab halted")

ErrHalted marks a gate that failed: the verb wrote its artefact and a finding, and the lab is halted until that gate passes again.

View Source
var ErrNoLab = errors.New("no lab minted for this repository")

ErrNoLab is RecordPair's answer when the repository has no lab to record in: the host has decided, and the pair is not kept.

View Source
var ErrRefused = errors.New("refused")

ErrRefused marks a refusal the caller can act on (a bad argument, an unknown lab, a store path occupied by the wrong kind of thing). A front door maps it to a usage exit.

View Source
var StoreDisplay = abcdhome.Display("lab")

StoreDisplay names the store in a message, in tilde form, so no output carries the account's home path.

Functions

func BinaryIdentity added in v0.16.0

func BinaryIdentity(f interface {
	io.Reader
	io.ReaderAt
}) (vintage.Current, string, error)

BinaryIdentity is a binary's build vintage and its sha256, read without running it. The preflight pins a lab's work binary through it, and a procedure pins the binary that drives it the same way.

func RecordPair added in v0.16.0

func RecordPair(repoRoot string, p Pair) (id, where string, err error)

RecordPair appends p to pairs.jsonl in the newest lab minted for the repository at repoRoot, stamping its time, and returns the lab's id and the file in tilde form. It refuses a pair without its type, kind, state hash or host answer, and returns ErrNoLab when the repository has no lab.

func SetAbcdRootCommitForTest added in v0.13.3

func SetAbcdRootCommitForTest(sha string) (restore func())

SetAbcdRootCommitForTest repoints the root commit the dual-binary gate applies to, so a test can treat a throwaway repository as abcd's own, and returns the restore.

func ValidID

func ValidID(s string) bool

ValidID reports whether s is a lab id as the store names one.

Types

type Agreement added in v0.16.0

type Agreement struct {
	LabHome    string          `json:"lab_home"`
	Pairs      int             `json:"pairs"`
	Unreadable int             `json:"unreadable"`
	Types      []TypeAgreement `json:"types"`
	Note       string          `json:"note"`
}

Agreement is the harvest's report over a lab's pairs: the lab home, the pairs counted, the lines that did not parse, each type's agreement, and the line a research note filed from it carries.

type Band added in v0.16.0

type Band struct {
	Band     string `json:"band"`
	Compared int    `json:"compared"`
	Agreed   int    `json:"agreed"`
}

Band is one probability band of a type's compared pairs.

type Candidate

type Candidate struct {
	Finding     string `json:"finding"`
	Title       string `json:"title"`
	FoundDuring string `json:"found_during"`
	Refutation  string `json:"refutation,omitempty"`
	Command     string `json:"command"`
}

Candidate is a product finding the harvest lists for filing through capture.

type Check

type Check struct {
	ID            string `json:"id"`
	Group         string `json:"group"`
	OK            bool   `json:"ok"`
	NotApplicable bool   `json:"not_applicable,omitempty"`
	Detail        string `json:"detail"`
}

Check is one preflight check's verdict. A check that does not apply to this lab passes (OK) and says so: NotApplicable is set, and Detail says why.

type Correction

type Correction struct {
	N         int        `json:"n"`
	Line      int        `json:"line"`
	Pattern   string     `json:"pattern"`
	Applied   bool       `json:"applied"`
	Invalid   string     `json:"invalid,omitempty"`
	Instances []Instance `json:"instances"`
}

Correction is one retracted claim: the literal text the lab's documents must no longer carry.

type Entry

type Entry struct {
	ID       string `json:"id"`
	RootSHA  string `json:"root_sha"`
	Pin      string `json:"pin"`
	Created  string `json:"created"`
	Question string `json:"question"`
}

Entry is one registry line: what a lab was minted for, and at which pin.

type Finding

type Finding struct {
	ID         string   `json:"id"`
	Title      string   `json:"title"`
	Kind       string   `json:"kind"`
	Status     string   `json:"status"`
	Probes     []string `json:"probes"`
	Evidence   []string `json:"evidence"`
	Refutation string   `json:"refutation,omitempty"`
	Gate       string   `json:"gate,omitempty"`
	Body       string   `json:"body,omitempty"`
}

Finding is one entry of a lab's findings log.

type Gap

type Gap struct {
	Finding string `json:"finding"`
	Reason  string `json:"reason"`
}

Gap is a finding the harvest cannot cite from the lab's own records.

type Harvested

type Harvested struct {
	ID         string            `json:"id"`
	Written    bool              `json:"written"`
	Artefact   string            `json:"artefact"`
	Sections   []string          `json:"sections"`
	Probes     []string          `json:"probes"`
	Candidates []Candidate       `json:"candidates"`
	Amendments []string          `json:"amendments"`
	Gaps       []Gap             `json:"gaps"`
	Coverage   []SectionCoverage `json:"coverage"`
	Halted     []string          `json:"halted"`
	// Agreement is the decision adapter's shadow agreement over the lab's
	// pairs.jsonl (pairs.go); absent when the lab recorded no pair.
	Agreement *Agreement `json:"agreement,omitempty"`
}

Harvested is the harvest's result.

func Harvest

func Harvest(repoRoot, id string) (Harvested, error)

Harvest assembles the lab's harvest in the lifeboat's section shape — intention, method, what worked, what is open, candidates, coverage — from the INTENTION, the findings log and the probe records, citing each finding's probe records by path. Its product findings are listed as capture candidates, each with the capture line that files it, found during this lab. A lab that recorded the decision adapter's shadow pairs (pairs.go) also gets the agreement per judgement type, with counts and probability bands, and the line a research note filed from it carries, naming the lab home and the count (itd-2609221009495079 criterion 2).

No claim outlives its input: a finding that cites no probe record or evidence file, or cites one that is missing or incomplete, is a gap, and a harvest with a gap is refused and writes nothing. A halted lab can still be harvested — halting is what ends a lab's mutation, and its gate findings lead the harvest.

type Instance

type Instance struct {
	File string `json:"file"`
	Line int    `json:"line"`
}

Instance is one place a retracted pattern still stands.

type Listing

type Listing struct {
	Store     string    `json:"store"`
	Labs      []Summary `json:"labs"`
	Unparsed  int       `json:"unparsed,omitempty"`
	RootSHA   string    `json:"root_sha"`
	StoreSeen bool      `json:"store_seen"`
}

Listing is the bare verb's read-only answer.

func List

func List(repoRoot string) (Listing, error)

List reads this repository's labs. It writes nothing and creates nothing.

type Minted

type Minted struct {
	Entry
	Home     string   `json:"home"`
	Snapshot string   `json:"snapshot"`
	Written  []string `json:"written"`
	Next     []string `json:"next"`
}

Minted is what mint laid down.

func Mint

func Mint(repoRoot, question, pin string) (Minted, error)

Mint lays down a new lab for question, pinned at pin (a revision of the repository at repoRoot; empty means HEAD): the lab home under this repository's lane of the store, a standalone clone of the repository detached at the pin, the lifecycle's documents, and one registry line. Nothing is written into the repository.

The clone runs under the isolated git environment, so no hook the operator's global configuration names fires while it is made, and its origin remote is removed, so nothing done in the lab world can be pushed back into the checkout it came from.

type Pair added in v0.16.0

type Pair struct {
	At          string   `json:"at"`
	Type        string   `json:"type"`
	Kind        string   `json:"kind"`
	StateSHA256 string   `json:"state_sha256"`
	StateTokens int      `json:"state_tokens"`
	Host        string   `json:"host"`
	Adapter     string   `json:"adapter,omitempty"`
	Probability *float64 `json:"probability,omitempty"`
	// Target is the adapter's <provider>/<model>; ModelReported the model
	// the provider said answered.
	Target        string `json:"target"`
	ModelReported string `json:"model_reported,omitempty"`
	// Skipped is SkippedWindow or SkippedFailed when the adapter gave no
	// answer, and Detail says why.
	Skipped string `json:"skipped,omitempty"`
	Detail  string `json:"detail,omitempty"`
}

Pair is one shadow judgement: the type and its question kind, the state's hash and size, the host's answer, and the adapter's answer with its probability, or why the adapter did not answer.

type Preflighted

type Preflighted struct {
	ID       string  `json:"id"`
	Passed   bool    `json:"passed"`
	Checks   []Check `json:"checks"`
	Artefact string  `json:"artefact"`
	Finding  string  `json:"finding,omitempty"`
	Lifted   string  `json:"lifted,omitempty"`
}

Preflighted is the preflight's result: every check, the artefact it wrote, and — when a check failed — the finding the halt recorded.

func Preflight

func Preflight(repoRoot, id string) (Preflighted, error)

Preflight runs the harness-isolation and dual-binary checks against the lab home and writes them as the lab's preflight artefact. A failed check halts the lab and records the refusal as a finding naming every failed check (ErrHalted); a passing preflight lifts a standing preflight halt. The finding stays in the log either way.

type Probe

type Probe struct {
	Lab      string   `json:"lab"`
	Name     string   `json:"name"`
	Dir      string   `json:"dir"`
	Files    []string `json:"files"`
	Artefact string   `json:"artefact"`
	Fill     string   `json:"fill"`
}

Probe is one probe record's scaffold.

func Record

func Record(repoRoot, id, name string) (Probe, error)

Record scaffolds one probe record under the lab's state/probes/: the five capture files, empty, and a record.md naming the artefact the probe observes (the work binary's vintage and sha256, when there is one). It refuses on a halted lab: a lab halted by a gate records nothing more until the gate passes, which is what keeps a refusal from being adapted around.

type Procedure added in v0.16.0

type Procedure struct {
	// contains filtered or unexported fields
}

Procedure is one lab opened by a procedure that drives it.

func OpenProcedure added in v0.16.0

func OpenProcedure(repoRoot, id string) (*Procedure, error)

OpenProcedure opens lab id of the repository at repoRoot for a procedure. It refuses a lab a gate holds halted (ErrHalted), the same refusal Record gives, and a lab whose preflight has not passed (ErrRefused): a procedure runs only in a lab whose isolation was proved.

func (*Procedure) Close added in v0.16.0

func (p *Procedure) Close()

Close releases the lab.

func (*Procedure) Entry added in v0.16.0

func (p *Procedure) Entry() Entry

Entry is the lab's registry line: its id, root commit and pin.

func (*Procedure) ReadState added in v0.16.0

func (p *Procedure) ReadState(rel string) ([]byte, error)

ReadState reads one procedure record back.

func (*Procedure) WorkBinary added in v0.16.0

func (p *Procedure) WorkBinary() (sha string, revision string, ok bool, err error)

WorkBinary is the work binary's identity as the lab's first passing preflight pinned it; ok is false where none was pinned (a lab of a repository that is not abcd's own has none). A pin that is there but cannot be read is an error, never no pin: the preflight's own check fails on it too, so a procedure cannot record a run against an unchecked binary.

func (*Procedure) WriteState added in v0.16.0

func (p *Procedure) WriteState(rel string, data []byte) error

WriteState writes one procedure record under the lab's state/matrix/, creating its directories, and never replaces one already written; it refuses a record larger than MaxStateBytes, which ReadState could not read back.

func (*Procedure) WriteStates added in v0.16.0

func (p *Procedure) WriteStates(files ...StateFile) error

WriteStates writes a set of procedure records that only make sense together, in order, each once, as WriteState does. Every path is checked before anything is written, and a write that fails part-way removes each record this call created (it created them exclusively, so they are its own), so a failed set leaves nothing and can be written again.

type SectionCoverage

type SectionCoverage struct {
	Section string `json:"section"`
	Status  string `json:"status"`
	Note    string `json:"note"`
}

SectionCoverage is one harvest section's grounding, in the lifeboat's grounded / partial / blank vocabulary.

type StateFile added in v0.16.0

type StateFile struct {
	Rel  string
	Data []byte
}

StateFile is one procedure record of a set WriteStates writes.

type Summary

type Summary struct {
	Entry
	Home    string   `json:"home"`
	Probes  int      `json:"probes"`
	Halted  []string `json:"halted"`
	Missing bool     `json:"missing,omitempty"`
}

Summary is one lab as the bare listing shows it.

type Swept

type Swept struct {
	ID          string       `json:"id"`
	Passed      bool         `json:"passed"`
	Corrections []Correction `json:"corrections"`
	Files       int          `json:"files"`
	NotSwept    []string     `json:"not_swept"`
	Artefact    string       `json:"artefact"`
	Finding     string       `json:"finding,omitempty"`
	Lifted      string       `json:"lifted,omitempty"`
}

Swept is the retraction sweep's result.

func Sweep

func Sweep(repoRoot, id string) (Swept, error)

Sweep verifies every correction the lab recorded is applied: each retracted literal is searched for across the lab's own documents — the pattern, not the instance — and every place it still stands is listed. An unapplied or unreadable correction fails the sweep, and so does any document the sweep could not read while a correction is recorded (fail-closed: it is listed by path, never passed over). A failed sweep halts the lab and records the refusal as a finding (ErrHalted); a passing sweep lifts a standing sweep halt. The artefact and the finding name a correction by its number, never by its text, so neither becomes a new instance.

type TypeAgreement added in v0.16.0

type TypeAgreement struct {
	Type     string  `json:"type"`
	Pairs    int     `json:"pairs"`
	Compared int     `json:"compared"`
	Agreed   int     `json:"agreed"`
	Skipped  int     `json:"skipped"`
	Rate     float64 `json:"rate"`
	Bands    []Band  `json:"bands"`
}

TypeAgreement is one judgement type's agreement: every pair recorded, the ones the adapter answered (compared), those whose answers matched, those it did not answer (skipped), the rate over the compared, and the bands.

Jump to

Keyboard shortcuts

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