54. The software factory

Chapter 53 ends at a verdict: a branch in a worktree, a reviewer that found nothing above minor, acceptance tests that passed under the daemon’s own sandbox. This chapter is where that branch meets the repository’s invariants, which are not the agent’s: the spec’s acceptance commands, run again over the commit, the evals the repository keeps for its agents, and a policy over what the agent wrote and ran. aec-work land runs the three as gates and moves the base branch by fast-forward only when all three pass.

An accepted attempt through the three gates A row from left to right. The attempt, a worktree with its ledger.jsonl and rounds directory, feeds three gates in a row: tests, policy and eval. Under tests: the acceptance commands, run with sh -c under the sandbox. Under policy: the diff against Allow and the protected paths, the policy and approval records, and the skill loader over a written skill. Under eval: the suite over the export of the commit, aec-eval run, and the trials.jsonl it leaves. Each gate passes along the row to the next; the last gate passes to a box, fast-forward main. Each gate also has an exit downward, for fail or skipped, to one box below the row, the report, which collects every verdict when a gate fails or is skipped, and nothing lands. A dashed boundary encloses the row and the report, and the label on its right edge reads: the factory stops here, no push. Outside the boundary, at the lower left, a grey box reads: what the agent read, seen by no gate. the factory stops here: no push attempt worktree ledger.jsonl rounds/ tests policy eval fast-forward main acceptance commands, sh -c under the sandbox diff vs Allow and protected paths; policy records and approvals; the loader over a written skill suite over the commit's export, aec-eval run, trials.jsonl report fail or skipped: every verdict, nothing lands what the agent read: seen by no gate

Why this layer exists

Chapter 52 made the statement of the work a document with graders; chapter 53 made a loop that produces a change and a verdict on it. The verdict is the daemon’s: the loop’s own acceptance run, its reviewer, its mutants. A repository has invariants the loop does not know. The tests gate re-runs the spec’s acceptance commands, and what differs from the loop’s own run is the tree graded (the commit’s export, with the base’s .spec/) and who runs it; the repository’s full suite is in the gate only if the spec’s acceptance names it, as the fixture’s vet-test names go vet ./... && go test ./.... The repository may keep evals for the agents that work on it, which test a different path through the same code. And it has a rule about what a change may touch and what the agent that wrote it did on the way, which no test of the code can state. The factory is where those are checked, by something that did not write the change, before the change is on the branch everything else builds from.

A gate here is a check whose evidence is an artefact, and which is credited only by that artefact: a trial record, a diff, an audit line. A gate that passes by absence (no record, no sandbox, no suite) is the failure mode the design refuses, so every gate fails closed and says why. The tests gate does not run without a sandbox that isolates the filesystem and the network. The policy gate fails a session that has no record in the audit log. The eval gate reads trials.jsonl, and a skipped cell is a refusal. Chapter 55 reads an incident in this book’s own production in which a check was credited that never ran; the gates are built so that a check which did not run cannot be credited.

The worktree is the rollback this book had not built. Chapter 42 left rollback out of the daemon because a tool’s side effect is not undone by the runtime, and pointed here as the place an agent’s change is kept from landing. The attempt’s branch is the unit that lands or is discarded: the worktree is what the daemon’s tools saw, and the base branch moves only by fast-forward, never by merge, so a refused attempt leaves the repository as it was. No gate edits the attempt, and nothing is undone, because nothing was done to the base.

The fixture of this chapter is chapter 52’s, with a median feature the loop has already built; the section “Your repository”, in the Walkthrough, says what changes for the reader’s own.

Mechanism

The attempt

The gates read an Attempt, assembled by FromRun from a chapter 53 run directory and the repository it was cut from.

// FromRun assembles the Attempt of a chapter 53 run directory: the Result
// from the round ledger (Status), the session ids from its step_begin
// events, the spec from specPath (the run directory's spec.md when empty),
// whose hash must be the ledger's, and the commit's diff against the base
// commit the ledger recorded. auditDir is the daemon's audit directory;
// FromRun does not require it, PolicyGate does.
//
// It refuses a run that is not accepted (ErrNotAccepted), a worktree that is
// not clean and equal to the recorded head (ErrNotClean), and a worktree
// repo found tampered with (repo.ErrTampered): only the finished, accepted
// commit is a candidate to land. g reads the worktree through the run's own
// ignore file (workflow.GitFor). repoDir must be given; the Attempt carries
// it absolute, with symlinks resolved.
func FromRun(ctx context.Context, g *repo.Git, runDir, repoDir, specPath, auditDir string) (Attempt, error) {
    if g == nil {
        return Attempt{}, errors.New("factory: no git")
    }
    // An empty directory would be git's working directory, whatever that
    // is when the reader runs land: the repository is named or nothing is.
    if repoDir == "" {
        return Attempt{}, errors.New("factory: no repository: name the main checkout to land in")
    }
    repoDir, err := filepath.Abs(repoDir)
    if err == nil {
        repoDir, err = filepath.EvalSymlinks(repoDir)
    }
    if err != nil {
        return Attempt{}, fmt.Errorf("factory: the repository: %w", err)
    }
    res, err := workflow.Status(runDir)
    if err != nil {
        return Attempt{}, fmt.Errorf("factory: %w", err)
    }
    if res.Verdict != "accepted" {
        return Attempt{}, &NotAcceptedError{Verdict: res.Verdict, Reason: res.Reason}
    }
    if res.Worktree == "" || res.Head == "" || res.Base == "" {
        return Attempt{}, errors.New("factory: the run has no worktree, base or commit to land")
    }
    if !commitHash.MatchString(res.Base) {
        // A ledger that predates the recorded base commit names the branch
        // (workflow.Result.Base); resolving that now would diff against
        // wherever it has moved to.
        return Attempt{}, fmt.Errorf("factory: the run records %q as its base, not a commit hash: a ledger older than the recorded base commit cannot be landed", res.Base)
    }
    if specPath == "" {
        specPath = filepath.Join(runDir, "spec.md")
    }
    f, err := os.Open(specPath)
    if err != nil {
        return Attempt{}, fmt.Errorf("factory: spec: %w", err)
    }
    doc, err := spec.Parse(f)
    f.Close()
    if err != nil {
        return Attempt{}, fmt.Errorf("factory: spec: %w", err)
    }
    if res.Spec != "" && doc.Hash != res.Spec {
        return Attempt{}, fmt.Errorf("factory: the spec at %s (sha256 %s) is not the run's (%s)", specPath, doc.Hash, res.Spec)
    }
    // Both commits must be in the repository given: a repoDir that is not the
    // run's cannot resolve them.
    head, err := g.Resolve(ctx, repoDir, res.Head)
    if err != nil {
        return Attempt{}, fmt.Errorf("factory: the run's head: %w", err)
    }
    baseCommit, err := g.Resolve(ctx, repoDir, res.Base)
    if err != nil {
        return Attempt{}, fmt.Errorf("factory: the run's base: %w", err)
    }
    gw := workflow.GitFor(g, res)
    // The worktree against its own head first: an uncommitted edit or an
    // untracked file shows as a file, a moved head as a different Head.
    now, err := gw.Changes(ctx, repoDir, res.Worktree, head)
    if err != nil {
        return Attempt{}, fmt.Errorf("factory: the worktree: %w", err)
    }
    if len(now.Files) > 0 || now.Head != head {
        return Attempt{}, fmt.Errorf("%w: %d file(s) differ from %s and its head is %s", ErrNotClean, len(now.Files), head, now.Head)
    }
    // Clean and at head: the worktree's diff against the base is the commit's.
    diff, err := gw.Changes(ctx, repoDir, res.Worktree, baseCommit)
    if err != nil {
        return Attempt{}, fmt.Errorf("factory: diff: %w", err)
    }
    base := doc.Base
    if base == "" {
        base = "main"
    }
    // The sessions are the loop's record, in the order the run opened them
    // (the work session first): "<spec id>-<run>-work", "<spec id>-<run>-review-<n>".
    sessions := append([]string(nil), res.Sessions...)
    return Attempt{Spec: doc, Repo: repoDir, Worktree: res.Worktree, Base: base, BaseCommit: baseCommit, Head: head,
        Diff: diff, Run: res, AuditDir: auditDir, Sessions: sessions}, nil
}

Each field has a source. The Result comes from the round ledger through workflow.Status, which needs no daemon: its verdict, worktree, head, base commit and sessions. The spec is parsed from RUNDIR/spec.md and must hash to the ledger’s spec, so a spec edited after the run is refused. Head and BaseCommit are resolved in the main repository the reader names with -repo, which must be given. Diff is the worktree’s diff against the base commit, taken through workflow.GitFor, the run’s own Git, because the toolchain’s files in the worktree are hidden only by the run’s ignore file, and a bare Git would find a clean worktree dirty. Sessions are the session ids the ledger’s step_begin events opened, the work session first; their names are run-unique (<spec id>-<run>-work, <spec id>-<run>-review-<n>), and the factory reads them from the ledger and never builds one from the spec id.

FromRun refuses what is not the finished, accepted commit. A verdict other than accepted is an ErrNotAccepted that names the verdict and its reason. A worktree that is not exactly its recorded head (an edit left uncommitted, a file left untracked, a moved head) is ErrNotClean. A worktree whose .git is not the gitfile git wrote is repo.ErrTampered. A run that records a branch name for its base instead of a commit hash predates the recorded base commit and is refused, because resolving a branch name now would diff against wherever it has moved to.

The tests gate

The tests gate runs the spec’s acceptance commands, the commands the spec names (chapter 52), which the loop ran at the end of its rounds (chapter 53), now as the factory’s: each one is chapter 43’s exec grader, sh -c over a tree under the sandbox, passing on ExpectStatus (0 unless the spec says otherwise). Chapter 52’s acceptance and the factory’s tests gate are one mechanism. land gives the gate no commands of its own, so it runs the acceptance of the spec of the run it is landing. The gate can also fail before any command runs, for a commit that cannot be exported or tracks .cache/ or .config/ (below), or a sandbox that cannot be configured.

// Check runs the commands under the sandbox, each as chapter 43's exec
// grader runs an acceptance test (sh -c over a tree, the exec environment,
// ExecWall), so the gate and the spec's acceptance are one mechanism. The
// tree is a fresh export of the attempt's head commit (gradeTree), made for
// this Check and removed on every return, and HOME is that tree: an
// acceptance command writes (the spec's vet-test copies the test file into
// calc/, and the toolchain leaves its cache under HOME), and nothing it
// wrote is read by the grade of another attempt. A backend that does not
// isolate both filesystem and network skips the gate with the reason, and a
// skipped gate never passes.
func (g *TestsGate) Check(ctx context.Context, a Attempt) Verdict {
    start := time.Now()
    cmds := g.Commands
    if len(cmds) == 0 && a.Spec != nil {
        cmds = a.Spec.Acceptance
    }
    if len(cmds) == 0 {
        return timed(failv("tests", "no acceptance command: the spec names none and the gate was given none"), start)
    }
    b := g.backend
    if b == nil {
        if g.Sandbox == "" {
            return timed(skipv("tests", "no sandbox named: the repository's tests are model-written code and do not run on the host (ruling X9-10)"), start)
        }
        var err error
        // The Go toolchain does not fit under the sandbox's default 512 MiB
        // RLIMIT_AS (10a measured it on straylight, ruling P10-3): the
        // acceptance commands run under spec.SandboxLimits, the one owner of
        // the limit, as chapter 52's runner and chapter 53's passes do.
        if b, err = sandbox.Configure(g.Sandbox, spec.SandboxLimits()); err != nil {
            return timed(failv("tests", "sandbox %s: %v", g.Sandbox, err), start)
        }
    }
    if iso := b.Isolates(); !(iso.Filesystem && iso.Network) {
        return timed(skipv("tests", "sandbox %s does not isolate both filesystem and network; the tests are not run", b.Name()), start)
    }
    tree, err := os.MkdirTemp("", "aec-factory-tests-")
    if err != nil {
        return timed(failv("tests", "%v", err), start)
    }
    defer os.RemoveAll(tree)
    if err := gradeTree(ctx, g.Git, a, tree); err != nil {
        return timed(failv("tests", "%v", err), start)
    }
    ctx = eval.WithSandboxPath(eval.WithSandbox(ctx, b), sandbox.HostPath(b))
    var passed []string
    for _, c := range cmds {
        s, err := (&eval.Exec{Command: c.Command, ExpectStatus: c.ExpectStatus}).Grade(ctx, &eval.Trajectory{Workspace: tree})
        if err != nil {
            return timed(failv("tests", "%s: %v", c.Name, err), start)
        }
        if !s.Pass {
            return timed(failv("tests", "%s: %s", c.Name, s.Detail), start)
        }
        passed = append(passed, c.Name+" ("+s.Detail+")")
    }
    return timed(Verdict{Gate: "tests", Pass: true, Detail: fmt.Sprintf("%d command(s) passed under %s: %s", len(passed), b.Name(), strings.Join(passed, "; "))}, start)
}

The tree is not the worktree. gradeTree writes into a fresh directory the tracked files of the attempt’s head commit, read through the main repository, and nothing else. What the worktree holds untracked or git-ignored (a build cache, a scratch file, an env file the attempt wrote) is in no gate’s tree, so what is graded is what lands, and what the reviewer’s diff showed. The spec’s .spec/ is replaced by the base commit’s: the acceptance test is the spec’s, not the attempt’s. A commit that tracks a symlink or a gitlink, has a path with a .git element, or holds a tree over 256 MiB cannot be exported and is not graded. A commit that tracks .cache/ or .config/ is refused by name, because HOME is the graded tree and those are the directories the Go toolchain reads from HOME. The tree is made for this one check, is HOME, and is removed on every return, so nothing an acceptance command wrote is read by the grade of another attempt. The class of risk this closes is the threat model’s invariant for a factory that grades many attempts on one host: no state a sandboxed process can write is read by the grade of a different attempt.

A backend that does not isolate both the filesystem and the network skips the gate with the reason, and a skipped gate never passes. The commands run the attempt’s own code, and nothing model-written runs on the host (ruling X9-10): the rule that governed the loop governs the factory.

The eval gate

The eval gate takes chapter 37’s harness as the repository’s CI. The repository keeps a suite for its agents; the gate compiles that suite over the attempt, runs aec-eval run as a subprocess so the record is the record a CI would have, and reads the verdict from the record.

// Check compiles the suite over the attempt (every task's environment is
// the tracked files of the attempt's head commit, exported fresh for this
// Check), runs aec-eval run over it into a
// directory made for this Check and reads trials.jsonl: the verdict is the
// record's, not the command's exit code, which aec-eval run moves only for an
// errored trial (code 3) or a refused suite (code 2). The suite is a host file
// outside the repository (ruling P10-42), so no attempt reads or edits it,
// and nothing a Check wrote (the record, HOME, the temporary directory)
// is read by another Check.
func (g *EvalGate) Check(ctx context.Context, a Attempt) Verdict {
    start := time.Now()
    if g.Suite == "" {
        return timed(failv("eval", "no suite named"), start)
    }
    suiteName := g.Suite
    raw, err := readSuite(g.Suite, a)
    if err != nil {
        return timed(failv("eval", "suite: %v", err), start)
    }
    var s eval.Suite
    if err := json.Unmarshal(raw, &s); err != nil {
        return timed(failv("eval", "suite %s: %v", suiteName, err), start)
    }
    if len(s.Tasks) == 0 || len(s.Candidates) == 0 {
        return timed(failv("eval", "suite %s names %d task(s) and %d candidate(s)", suiteName, len(s.Tasks), len(s.Candidates)), start)
    }
    // The live rule: a provider off the loopback is a model request, which
    // the factory sends only when told so; the run's bound is the suite's
    // shape, printed before the first request.
    var hosts []string
    for name, pc := range s.Providers {
        u, err := url.Parse(pc.BaseURL)
        if err != nil {
            return timed(failv("eval", "provider %s: %v", name, err), start)
        }
        if !loopback(u.Hostname()) {
            hosts = append(hosts, name+" at "+u.Hostname())
        }
    }
    sort.Strings(hosts)
    if len(hosts) > 0 && !g.Live {
        return timed(skipv("eval", "the suite names a model provider off this host (%s): a live gate; run with -live", strings.Join(hosts, ", ")), start)
    }
    if g.Sandbox != "" {
        s.Sandbox = g.Sandbox
    }
    if s.SandboxLimits == nil {
        // Overriding the backend does not carry limits: a suite without its
        // own gets the default 512 MiB, which the Go toolchain does not fit
        // in (10a measured it). spec.SandboxLimits is the one owner.
        l := spec.SandboxLimits()
        s.SandboxLimits = &l
    }
    // This Check's own directory: the compiled suite, the run and a HOME and
    // TMPDIR for aec-eval itself. A directory given is the parent of these,
    // kept for the reader; none given is a temporary one removed on return.
    var dir string
    kept := g.dir != ""
    if kept {
        if err := os.MkdirAll(g.dir, 0o700); err != nil {
            return timed(failv("eval", "%v", err), start)
        }
        dir, err = os.MkdirTemp(g.dir, "eval-")
    } else {
        dir, err = os.MkdirTemp("", "aec-factory-eval-")
    }
    if err != nil {
        return timed(failv("eval", "%v", err), start)
    }
    if !kept {
        defer os.RemoveAll(dir)
    }
    envTree := filepath.Join(dir, "env")
    if err := os.Mkdir(envTree, 0o700); err != nil {
        return timed(failv("eval", "%v", err), start)
    }
    if err := gradeTree(ctx, g.Git, a, envTree); err != nil {
        return timed(failv("eval", "environment: %v", err), start)
    }
    env, err := environment(envTree)
    if err != nil {
        return timed(failv("eval", "environment: %v", err), start)
    }
    if err := os.RemoveAll(envTree); err != nil {
        return timed(failv("eval", "environment: %v", err), start)
    }
    for i := range s.Tasks {
        s.Tasks[i].Env = &eval.Files{Before: env}
    }
    home, tmp := filepath.Join(dir, "home"), filepath.Join(dir, "tmp")
    for _, d := range []string{home, tmp} {
        if err := os.Mkdir(d, 0o700); err != nil {
            return timed(failv("eval", "%v", err), start)
        }
    }
    compiled := filepath.Join(dir, "suite.json")
    out, err := json.MarshalIndent(&s, "", "  ")
    if err != nil {
        return timed(failv("eval", "%v", err), start)
    }
    if err := os.WriteFile(compiled, out, 0o600); err != nil {
        return timed(failv("eval", "%v", err), start)
    }
    bin, err := g.resolve()
    if err != nil {
        return timed(failv("eval", "%v", err), start)
    }
    n := g.n
    if n <= 0 {
        n = 3
    }
    runDir := filepath.Join(dir, "run")
    bound := len(s.Candidates) * len(s.Tasks) * n
    cmd := exec.CommandContext(ctx, bin, "run", "-suite", compiled, "-dir", runDir, "-n", strconv.Itoa(n))
    // What reaches aec-eval is the factory's own environment: PATH,
    // XDG_RUNTIME_DIR and the session bus (systemd-run needs them), any GO*
    // variable, any *_API_KEY or *_TOKEN, and AEC_LIVE, with HOME and TMPDIR
    // replaced by this Check's own. AEC_ZAI_URL is dropped unless the gate is
    // live: the router sends a provider named zai there whatever the suite's
    // base_url says, which would be an off-host request from a gate told it
    // may make none. This is not a clean environment. The attempt's code never
    // sees any of it: a trial and an exec grader run with PATH, HOME (the
    // trial's workspace), LANG, TMPDIR=/tmp and TERM only, and an attempt
    // reaches aec-eval as text in Files.Before.
    drop := []string{"HOME", "TMPDIR"}
    if !g.Live {
        drop = append(drop, "AEC_ZAI_URL")
    }
    cmd.Env = append(withoutKeys(os.Environ(), drop...), "HOME="+home, "TMPDIR="+tmp)
    var stderr strings.Builder
    cmd.Stdout, cmd.Stderr = &stderr, &stderr
    runErr := cmd.Run()
    code := 0
    var ee *exec.ExitError
    if errors.As(runErr, &ee) {
        code = ee.ExitCode()
    } else if runErr != nil {
        return timed(failv("eval", "aec-eval: %v", runErr), start)
    }
    if code == 2 || code == 1 {
        return timed(Verdict{Gate: "eval", Code: code, Detail: fmt.Sprintf("aec-eval run exited %d before the matrix ran: %s", code, firstLine(stderr.String()))}, start)
    }
    f, err := os.Open(filepath.Join(runDir, "trials.jsonl"))
    if err != nil {
        return timed(Verdict{Gate: "eval", Code: code, Detail: fmt.Sprintf("aec-eval run exited %d and left no record: %v", code, err)}, start)
    }
    defer f.Close()
    trials, err := eval.ReadTrials(f)
    if err != nil {
        return timed(Verdict{Gate: "eval", Code: 3, Detail: "trials.jsonl: " + err.Error()}, start)
    }
    record := runDir
    if !kept {
        record = ""
    }
    v := verdictOf(trials, bound, record)
    if code == 3 && v.Pass {
        // The record passed but the command said a trial errored or the run
        // ended early: the record is incomplete, and incomplete is not pass.
        v = Verdict{Gate: "eval", Code: 3, Detail: "aec-eval run exited 3 (" + firstLine(stderr.String()) + ") over " + v.Detail}
    }
    return timed(v, start)
}

// verdictOf reads the harness's record the way chapter 54's gate does: a
// skipped cell is a refused verdict (code 4) and names the cell, an error
// is code 3, a failed trial code 1, and fewer trials than the matrix's
// shape is an incomplete record, never a pass. runDir names the record in
// the detail; "" when the record was not kept.
func verdictOf(trials []eval.Trial, bound int, runDir string) Verdict {
    var skipped, errored, failed []string
    for _, t := range trials {
        cell := fmt.Sprintf("%s/%s/%d", t.Task, t.Candidate, t.Rep)
        // The runner writes a skip's or an error's reason in Error and a
        // grader's verdict in Detail (eval.Trial).
        why := firstLine(t.Detail)
        if why == "" {
            why = firstLine(t.Error)
        }
        switch t.Status {
        case eval.Skipped:
            skipped = append(skipped, cell+": "+why)
        case eval.Error:
            errored = append(errored, cell+": "+why)
        case eval.Fail:
            failed = append(failed, cell+": "+why)
        }
    }
    rec := ""
    if runDir != "" {
        rec = " (record " + runDir + ")"
    }
    switch {
    case len(skipped) > 0:
        return Verdict{Gate: "eval", Code: 4, Detail: fmt.Sprintf("%d of %d trials skipped, a cell the harness could not run: %s%s", len(skipped), len(trials), strings.Join(skipped, "; "), rec)}
    case len(errored) > 0:
        return Verdict{Gate: "eval", Code: 3, Detail: fmt.Sprintf("%d of %d trials errored: %s%s", len(errored), len(trials), strings.Join(errored, "; "), rec)}
    case len(failed) > 0:
        return Verdict{Gate: "eval", Code: 1, Detail: fmt.Sprintf("%d of %d trials failed: %s%s", len(failed), len(trials), strings.Join(failed, "; "), rec)}
    case len(trials) < bound:
        return Verdict{Gate: "eval", Code: 3, Detail: fmt.Sprintf("%d trials recorded of the %d the matrix names%s", len(trials), bound, rec)}
    }
    return Verdict{Gate: "eval", Pass: true, Detail: fmt.Sprintf("%d of %d trials pass%s", len(trials), len(trials), rec)}
}

The suite is a host file outside the repository, named by an absolute path. A relative path is refused, and so is an absolute one that, with symlinks resolved, lies inside the attempt’s repository or worktree, because a suite an attempt can read is a suite whose expected answers an attempt can read, and one it can edit is one it can pass. The fixture’s suite has two tasks that ask an agent to build the attempt’s command with go build -o "$TMPDIR/calc" ./cmd/calc and run it: mean 1 2 3 must answer 2 and median 9 1 4 7 must answer 5.5. They test the attempt’s code through an agent, which is a different path from the acceptance tests: a Median that averages in integer arithmetic answers 5. Each task’s environment is the export of the attempt’s commit, carried in as the files Files.Before writes, bounded at 8 MiB, and the exported tree is removed before the run.

The verdict is the record’s, not the exit code’s. aec-eval run’s doc comment, at the head of chapter 37’s ch37-cmd listing, gives its codes: 0 when no trial is error, 1 on an I/O failure, 2 on usage, 3 when some trials are error or the run was cancelled.

A trial that fails its grader is not an error, and a cell the runner skipped is not an error: both leave the exit code at 0. A CI step that gated on the command’s status would land a failed matrix. verdictOf reads trials.jsonl with a precedence: any skipped trial is code 4, any errored trial code 3, any failed trial code 1, a record shorter than the matrix’s shape (candidates times tasks times n) code 3, and otherwise a pass. The code 4 is the refusal chapter 51’s aecd eval returns for a skipped registered cell (ruling 9c-5) and aec-stats decide returns for a verdict it cannot give (chapter 38): a skipped cell is a reported gap, never a pass. The refusal is carried here by the gate, because the matrix runner does not carry it. The command’s own code still counts in two places: a 1 or a 2 means the matrix never ran, and a 3 over a record that reads as a pass makes the record incomplete, which is not a pass.

A suite that names a model provider off the loopback is a live gate, and runs only when land is told -live. Without it the gate is skipped, naming the provider (straylight-35b at straylight). With it, the bound is the suite’s shape, printed before the first request: candidates times tasks times n trials, each at most the task’s max_turns completions. For the fixture’s suite that is 1×2×3=61 \times 2 \times 3 = 6 trials of at most 8 completions each, 48 in all. The environment aec-eval receives is the factory’s own, with HOME and TMPDIR replaced by directories made for this check, and AEC_ZAI_URL dropped unless the gate is live: the router sends a provider named zai to that URL whatever the suite says, which would make an off-host request from a gate told it may make none. The attempt’s code never sees any of this; a trial runs with PATH, a HOME that is the trial’s workspace, LANG, TMPDIR=/tmp and TERM.

The policy gate

The policy gate runs nothing. Its evidence is the diff, the spec, the protected paths and what the audit log recorded of the attempt’s sessions.

// Check reads the diff and the records. Nothing here runs: the gate's
// evidence is the diff against the spec, the protected paths, the audit
// log's records for the attempt's sessions, and a loader's reading of any
// skill the attempt wrote (read from the commit, not the worktree). Every
// absence is a failure named as such: a missing audit directory, a session
// with no record, a diff row whose source path the gate cannot see.
func (g *PolicyGate) Check(ctx context.Context, a Attempt) Verdict {
    start := time.Now()
    if a.Spec == nil {
        return timed(failv("policy", "no spec"), start)
    }
    protected := g.Protected
    if protected == nil {
        protected = DefaultProtected
    }
    roots := g.skillRoots()
    if !g.VetSkills {
        // Nothing vets a skill here, so no skill lands under a broad Allow:
        // a skill root is protected, and a spec lifts that only by naming a
        // path literally.
        protected = append([]string(nil), protected...)
        for _, r := range roots {
            protected = append(protected, path.Clean(r)+"/**")
        }
    }
    var problems, notes []string
    listed := map[string]string{} // outsideSkill's answers by revision and directory
    // The diff against the spec's Allow globs and the protected paths.
    for _, fc := range a.Diff.Files {
        p := path.Clean(filepath.ToSlash(fc.Path))
        if strings.HasPrefix(fc.Status, "R") || strings.HasPrefix(fc.Status, "C") {
            problems = append(problems, fmt.Sprintf("%s: a rename or copy (%s); the gate cannot see its source path", p, fc.Status))
            continue
        }
        if b := path.Base(p); b != "SKILL.md" && strings.EqualFold(b, "SKILL.md") {
            // Never legitimate content, and a loader that looks the name up
            // on a case-insensitive filesystem would take it for SKILL.md.
            problems = append(problems, fmt.Sprintf("%s: a SKILL.md in another case; a loader that looks the name up on a case-insensitive filesystem would take it for one", p))
            continue
        }
        if strings.EqualFold(path.Base(p), "SKILL.md") && underRoot(roots, p) == "" {
            // The daemon could load a skill from here; the gate vets only the
            // named roots, so it refuses what it cannot vet.
            problems = append(problems, fmt.Sprintf("%s: a SKILL.md outside the skill roots %v; the gate cannot vet it", p, roots))
            continue
        }
        if underRoot(roots, p) == "" {
            why, err := g.outsideSkill(ctx, a, p, listed)
            if err != nil {
                problems = append(problems, p+": skills outside the roots: "+err.Error())
                continue
            }
            if why != "" {
                problems = append(problems, fmt.Sprintf("%s: %s, outside the skill roots %v; the gate cannot vet it", p, why, roots))
                continue
            }
        }
        if !matchAny(a.Spec.Allow, p) {
            problems = append(problems, p+": outside the spec's allow globs")
            continue
        }
        if matchAny(protected, p) && !namedLiterally(a.Spec.Allow, p) {
            problems = append(problems, p+": a protected path (the spec would have to name it literally)")
        }
    }
    if len(a.Diff.Files) == 0 {
        problems = append(problems, "the diff is empty: nothing to land")
    }
    // The audit log's records for the attempt's sessions.
    switch {
    case a.AuditDir == "":
        problems = append(problems, "no audit directory: the attempt's sessions have no record")
    case len(a.Sessions) == 0:
        problems = append(problems, "no session named: the attempt's sessions are unknown")
    default:
        if _, _, err := audit.Verify(a.AuditDir, "", nil); err != nil {
            problems = append(problems, "the audit log does not verify: "+err.Error())
        }
        lines, err := readAuditDir(a.AuditDir)
        if err != nil {
            problems = append(problems, "audit log: "+err.Error())
        }
        want := map[string]bool{}
        for _, s := range a.Sessions {
            want[s] = true
        }
        seen := map[string]bool{}
        denied, asked, notGranted := 0, 0, 0
        for _, ln := range lines {
            r := ln.Record
            if !want[r.Session] {
                continue
            }
            seen[r.Session] = true
            switch r.Kind {
            case "policy":
                if r.Attrs["tier"] == "strict" {
                    problems = append(problems, fmt.Sprintf("session %s turn %d: %s decided at the strict tier (the model tier was down while the agent wrote this)", r.Session, r.Turn, r.Subject))
                }
                if r.Decision == "deny" {
                    denied++
                }
            case "approval":
                asked++
                if r.Decision != "allow" {
                    notGranted++
                }
            }
        }
        for _, s := range a.Sessions {
            if !seen[s] {
                problems = append(problems, "session "+s+" has no record in the audit log")
            }
        }
        notes = append(notes, fmt.Sprintf("%d call(s) denied, %d approval(s) asked, %d not granted", denied, asked, notGranted))
    }
    // Skills the attempt wrote, read as the daemon would load them, from the
    // commit's tracked files.
    if g.VetSkills {
        p, n := g.vetSkills(ctx, a)
        problems, notes = append(problems, p...), append(notes, n...)
    }
    if len(problems) > 0 {
        return timed(failv("policy", "%s", strings.Join(problems, "; ")), start)
    }
    return timed(Verdict{Gate: "policy", Pass: true, Detail: fmt.Sprintf("%d file(s) inside %v; %s", len(a.Diff.Files), a.Spec.Allow, strings.Join(notes, "; "))}, start)
}

The diff. Every file the diff names must match one of the spec’s Allow globs. The dialect is chapter 52’s spec.MatchGlob, applied to the cleaned path (ruling 10c-5), so calc/../flake.nix is the path flake.nix, not something under calc/. A rename or a copy is a path the gate cannot see the source of, and is refused. A SKILL.md in any case other than the exact one is refused, and so is any SKILL.md outside the skill roots, because nothing there can be vetted.

The protected paths. The factory’s defaults are AGENTS.md, CLAUDE.md, .github/**, flake.nix, .spec/** and skills.lock. A protected path lands only when the spec’s Allow names it literally, with no *, ? or [ in the entry (ruling 10c-6). A broad Allow such as ** is the author’s convenience and does not cover a path that is the agent’s instruction channel or the grader’s input. The reason for the first is a finding about rule files. Zhang et al. (arXiv 2604.11088) report that “Random rules improve a coding agent’s task performance as much as expert-curated ones (both +13.8pp on a discriminative subset of SWE-bench Verified)”: a rule file moves the agent whatever it says. A change an agent makes to the file that instructs the next agent is therefore not a documentation change, and it is the one path an agent’s change must not touch unasked. The reason for .spec/** is the pinned acceptance test: the tests gate grades the base commit’s copy, but a rewritten one that landed would be the next spec’s pinned hash.

The record. The audit log is chapter 48’s, read through audit.Verify and Read. A missing audit directory, a log whose chain does not verify, an attempt with no sessions named and a session with no record in the log are each a failure named as such. A policy record at tier: strict for an attempt’s session fails the gate, naming the session and the turn: the model tier was down while the agent wrote this, the strict tier decided in its place, and, as chapter 47 has it (allow_unattended is suspended while strict), nothing allow_unattended could lift. A denied call is counted and reported; an approval is counted as asked and, if it was not an allow, as not granted. The detail of a passing gate says so: 0 call(s) denied, 0 approval(s) asked, 0 not granted. The records exist where the daemon’s policy decided a tool call: the work session’s. The scripted reviewers of the rig’s loop make no tool calls, so they leave turn records and no policy records, and the gate asks each session for a record, not each for a policy record.

Skills. A skill can reach the repository as a file of the attempt, and the gate reads it as the daemon would load it. The skill loader runs over the whole exported tree at head and at base, with chapter 36’s rule that a directory is a skill when its listing holds an entry named exactly SKILL.md, and the outermost such directory is the skill. Any changed path inside a loaded skill’s directory is a change to that skill. Each touched skill’s files are compared with its entry in the skills.lock of the base commit, never the attempt’s: a lock the attempt wrote is the attempt vouching for itself. A new skill, a changed file and a removed skill are therefore all failures naming the file, and a skill whose loader problems exist at base fails at head. That is by design: any change to a locked skill fails until a human vets it and updates the lock. A skill the daemon learned is the other route: chapter 53’s learn step promotes it into the host’s live directory after a clean vet, not through the repository, and the host’s daemon lists it from its next start (skills load once, at Open), and aec-work land prints, when the diff holds no skill, the command the host runs for it (aecd vet skills -config <aecd.json> -write).

The loader reads the name from the directory listing and does not look it up. On a case-insensitive directory (APFS by default, a casefolded ext4 or tmpfs directory on Linux) a lookup of SKILL.md opens skill.md, which git treats as another file. The differential is reachable on Linux: straylight’s ext4 has the casefold feature, and an unprivileged mount namespace gives a casefolded tmpfs (TestExactNameOnACasefoldedTmpfs, in chapter 36’s package, mounts one and runs the loader on it). The gate refuses a changed skill.md outright, and the loader will not load one.

The pipeline

Pipeline.Run runs every gate, so the report is whole, and lands only if none failed.

// Gate is one check over an attempt. Check never runs the attempt's code on
// the host: TestsGate and EvalGate run under the sandbox, PolicyGate reads
// files and records.
type Gate interface {
    Name() string
    Check(ctx context.Context, a Attempt) Verdict
}

// Attempt is what the gates see. Repo, BaseCommit and Head are what they
// grade: the gates read commits through Repo, not the Worktree, which only
// the landing's Remove and the report use.
type Attempt struct {
    Spec       *spec.Document
    Repo       string
    Worktree   string
    Base       string // the base branch Land moves
    BaseCommit string // the commit the worktree was cut from (the run line's)
    Head       string
    Diff       repo.Diff       // BaseCommit..Head
    Run        workflow.Result // the loop's record
    AuditDir   string          // the daemon's audit log, for PolicyGate
    Sessions   []string        // the attempt's session ids
}

// Verdict is a gate's answer: pass, fail or skipped with the reason, and
// the harness's code when the gate wraps aec-eval run (0 every trial
// passed, 1 a failed trial, 3 an errored trial or a run that ended early,
// 4 a skipped cell, 2 a suite the runner refused).
type Verdict struct {
    Gate    string  `json:"gate"`
    Pass    bool    `json:"pass"`
    Skipped bool    `json:"skipped,omitempty"`
    Code    int     `json:"code,omitempty"`
    Detail  string  `json:"detail,omitempty"`
    Seconds float64 `json:"seconds"`
}

// TestsGate runs the repository's own test command (the spec's acceptance
// tests and the repository's full suite, as the spec names them) under the
// sandbox over a fresh export of the attempt's commit; pass is status 0.
type TestsGate struct {
    Git      *repo.Git
    Sandbox  string
    Commands []spec.Acceptance

    backend sandbox.Backend // set by NewTestsGate; nil builds Sandbox by name with Configure
}

// EvalGate runs aec-eval run over a suite file with the attempt's build as
// the environment and reads the record it leaves (trials.jsonl): every
// trial must pass; a failed trial fails the gate, and a skipped cell fails
// it naming the cell, as chapter 38's decide refuses a verdict it cannot
// give, because aec-eval run's own exit code moves only for an errored
// trial. A suite that names a model provider off the loopback is a live
// gate and runs only when the factory is told so. Suite is an absolute host
// path outside the repository (ruling P10-42): the grader is not readable by
// the graded.
type EvalGate struct {
    Git     *repo.Git
    Suite   string
    Live    bool
    Sandbox string

    binary string // the aec-eval binary; "" resolves it beside this program, then on PATH's absolute elements
    dir    string // where each Check's own directory goes; "" is a fresh temporary directory removed after the Check
    n      int    // repetitions per cell; 0 is 3
}

// PolicyGate reads the diff against the spec's Allow globs (a file outside
// them fails, named), refuses a diff that touches the repository's agent
// instructions, CI configuration, acceptance tests (.spec/) or skills lock
// unless the spec names the path literally, counts the attempt's policy and approval records from the audit
// log (a denied call is reported, a Strict-tier decision fails the gate: the
// model tier was down while the agent wrote this), and, with VetSkills, runs
// the skill loader over any skill the attempt wrote, read from the commit.
type PolicyGate struct {
    Git        *repo.Git // VetSkills only: the skills are read from the commits
    Protected  []string  // globs always refused; nil is DefaultProtected
    VetSkills  bool
    SkillRoots []string // where the daemon's skills live in the repository; nil is "skills"
}

// Pipeline is the gates in order and the landing rule.
type Pipeline struct {
    Gates []Gate
    Git   *repo.Git
    // Client is the daemon connection the pipeline asks whether the attempt's
    // work session is closed before it removes the worktree, which is that
    // session's workspace (ruling P10-43). daemon.Client satisfies it.
    Client Caller
    Push   bool // false: Land fast-forwards and stops; the factory never pushes by default
    Log    func(format string, args ...any)
    Clock  func() time.Time
}

// Report is the pipeline's record: every verdict, whether the change
// landed, and the hash it landed at.
type Report struct {
    Attempt  string    `json:"attempt"`
    Verdicts []Verdict `json:"verdicts"`
    Landed   bool      `json:"landed"`
    Head     string    `json:"head,omitempty"`
    Reason   string    `json:"reason,omitempty"`
    At       time.Time `json:"at"`
}

// Run checks every gate (all of them, so the report is complete, not the
// first failure) and, when all pass, fast-forwards the base branch to the
// attempt's head and removes the worktree; a failed gate leaves the
// worktree for the reader and lands nothing. An attempt whose run is not
// finished is refused: the worktree is the work session's workspace, and
// Remove deletes it.
func (p *Pipeline) Run(ctx context.Context, a Attempt) (Report, error) {
    now := p.Clock
    if now == nil {
        now = time.Now
    }
    logf := p.Log
    if logf == nil {
        logf = func(string, ...any) {}
    }
    rep := Report{Attempt: attemptID(a), At: now()}
    if p.Push {
        // There is no push in repo, so there is none here: the reader pushes
        // what landed. Refusing the flag is how "never pushes by default"
        // stays true of a configuration too.
        return rep, errors.New("factory: Push is not implemented: the factory never pushes; push what landed yourself")
    }
    if len(p.Gates) == 0 {
        return rep, errors.New("factory: no gates")
    }
    // Nothing lands without a repository, and a gate that reads one must not
    // be handed an attempt that names none.
    if a.Repo == "" {
        return rep, errors.New("factory: the attempt names no repository; nothing can land")
    }
    // A worktree is removed on landing, and only a finished run's is free to
    // remove: a hand-built Attempt with a worktree and no verdict is refused.
    if v := a.Run.Verdict; (v != "" || a.Worktree != "") && v != "accepted" {
        return rep, &NotAcceptedError{Verdict: v, Reason: a.Run.Reason}
    }
    if p.Git != nil && a.Repo != "" && a.Head != "" {
        // One resolved hash for the gates, the fast-forward and the report.
        h, err := p.Git.Resolve(ctx, a.Repo, a.Head)
        if err != nil {
            return rep, fmt.Errorf("factory: head: %w", err)
        }
        a.Head = h
    }
    var failed []string
    for _, g := range p.Gates {
        v := g.Check(ctx, a)
        v.Gate = g.Name()
        rep.Verdicts = append(rep.Verdicts, v)
        switch {
        case v.Pass:
            logf("gate %s: pass (%.1f s)", v.Gate, v.Seconds)
        case v.Skipped:
            logf("gate %s: skipped: %s", v.Gate, v.Detail)
            failed = append(failed, v.Gate+" (skipped)")
        default:
            logf("gate %s: fail: %s", v.Gate, v.Detail)
            failed = append(failed, v.Gate)
        }
    }
    if len(failed) > 0 {
        rep.Reason = "not landed: " + strings.Join(failed, ", ")
        return rep, nil
    }
    if p.Git == nil {
        return rep, errors.New("factory: no git")
    }
    base := baseOf(a)
    if a.BaseCommit != "" {
        // The policy diff is BaseCommit..Head. A branch anywhere else (ahead
        // after another landing, or behind the cut) would land history the
        // gates never saw.
        now, err := p.Git.Resolve(ctx, a.Repo, base)
        if err != nil {
            return rep, fmt.Errorf("factory: base: %w", err)
        }
        if now != a.BaseCommit {
            rep.Reason = fmt.Sprintf("not landed: %s is at %s, not the %s the attempt was cut from", base, now, a.BaseCommit)
            return rep, nil
        }
    }
    if a.Worktree != "" {
        if err := ensureClosed(ctx, p.Client, firstSession(a), a.Worktree); err != nil {
            return rep, err
        }
    }
    if err := p.Git.FastForward(ctx, a.Repo, base, a.Head); err != nil {
        if errors.Is(err, repo.ErrNotFastForward) {
            // The base moved under the attempt: a report, not an error. The
            // worktree stays for the reader to rebase.
            rep.Reason = fmt.Sprintf("not landed: %s is not a fast-forward of %s", a.Head, base)
            return rep, nil
        }
        return rep, fmt.Errorf("factory: fast-forward: %w", err)
    }
    rep.Landed, rep.Head = true, a.Head
    logf("landed %s on %s", a.Head, base)
    if a.Worktree != "" {
        // The run's own Git: the toolchain's files in the worktree are
        // hidden only by the run's ignore file, and a bare Git would find
        // a clean, accepted worktree dirty.
        if err := workflow.GitFor(p.Git, a.Run).Remove(ctx, a.Repo, a.Worktree, a.Run.Branch, false, false); err != nil {
            rep.Reason = "landed; the worktree was not removed: " + err.Error()
        }
    }
    return rep, nil
}

The order is tests, policy, eval. The live gate is last because it is the only one that spends anything, and a refusal from the free two should arrive first (all three run regardless). Before landing the pipeline checks that the base branch is still at the commit the attempt was cut from: the policy diff is BaseCommit..Head, and a branch anywhere else would land history the gates never saw, and the report says “not landed: main is at X, not the Y the attempt was cut from”. It closes the work session through the daemon if it is open, because the worktree is that session’s workspace and Remove deletes it. Then FastForward (git merge --ff-only); a base that moves between the check and the fast-forward is repo.ErrNotFastForward, also reported as “not landed”. In both the worktree is kept for the reader to rebase. On landing, the worktree is removed with the run’s own Git. A refusal keeps the worktree and lands nothing.

There is no push: repo has no push, and Push: true on the pipeline is an error before any gate runs. The reader pushes what landed.

aec-work land is the pipeline’s command.

// cmdLand is chapter 54's land: it runs an accepted chapter 53 attempt
// through the gates (tests, policy, eval, in that order, so the one gate that
// can cost a completion runs last) and fast-forwards the base branch only
// when every gate passed. It pushes nothing. The eval gate is not optional:
// without -suite nothing lands (exit 4), because "all gates passed" would
// otherwise name two of the three.
func cmdLand(args []string, stdout, stderr io.Writer) int {
    fs := flag.NewFlagSet("aec-work land", flag.ContinueOnError)
    fs.SetOutput(stderr)
    dir := fs.String("dir", "", "the run directory (chapter 53's)")
    repoDir := fs.String("repo", "", "the repository whose base branch lands (its base branch checked out)")
    auditDir := fs.String("audit", "", "the daemon's audit directory")
    socket := fs.String("socket", "", "the daemon's control socket: the work session is closed before its workspace is removed")
    specPath := fs.String("spec", "", "the spec file (default RUNDIR/spec.md)")
    suite := fs.String("suite", "", "the eval suite, a host file outside the repository (required)")
    live := fs.Bool("live", false, "the eval gate may name a model provider off this host")
    sb := fs.String("sandbox", "local", "the backend for the tests gate and the suite")
    protect := fs.String("protect", "", "comma-separated globs refused in addition to the defaults (the defaults cannot be removed by a flag)")
    vet := fs.Bool("vet-skills", true, "load and compare any skill the attempt wrote")
    n := fs.Int("n", 3, "repetitions per eval cell")
    evalBin := fs.String("eval-bin", "", "the aec-eval binary (default: beside this program, then on PATH)")
    out := fs.String("out", "", "the report (default RUNDIR/land.json; an existing file is not overwritten)")
    if err := fs.Parse(args); err != nil {
        return landExitUsage
    }
    if *dir == "" || *repoDir == "" || *auditDir == "" || *socket == "" || fs.NArg() != 0 || *n < 1 {
        fmt.Fprintln(stderr, usage)
        return landExitUsage
    }
    // The protected list only grows: a flag that replaced it could drop
    // .spec/** with a typo, and a rewritten acceptance test would land.
    protected := append([]string(nil), factory.DefaultProtected...)
    fs.Visit(func(f *flag.Flag) {
        if f.Name != "protect" {
            return
        }
        for _, g := range strings.Split(*protect, ",") {
            if g = strings.TrimSpace(g); g == "" {
                protected = nil
                return
            }
            if !slices.Contains(protected, g) {
                protected = append(protected, g)
            }
        }
    })
    if protected == nil {
        fmt.Fprintln(stderr, "aec-work land: -protect has an empty entry")
        fmt.Fprintln(stderr, usage)
        return landExitUsage
    }
    if *suite == "" {
        fmt.Fprintln(stderr, "aec-work land: no -suite: the eval gate is not optional, and nothing lands without all three gates")
        return landExitRefused
    }
    suiteFile, err := filepath.Abs(*suite)
    if err == nil {
        *socket, err = filepath.Abs(*socket)
    }
    if err != nil {
        fmt.Fprintln(stderr, "aec-work:", err)
        return landExitFailed
    }
    if *out == "" {
        *out = filepath.Join(*dir, "land.json")
    }
    ctx, stop := signal.NotifyContext(context.Background(), os.Interrupt, syscall.SIGTERM)
    defer stop()
    git, err := repo.Find(os.Getenv("PATH"))
    if err != nil {
        fmt.Fprintln(stderr, "aec-work:", err)
        return landExitFailed
    }
    a, err := factory.FromRun(ctx, git, *dir, *repoDir, *specPath, *auditDir)
    if err != nil {
        fmt.Fprintln(stderr, "aec-work:", err)
        return landExitFailed
    }
    head := a.Head
    if len(head) > 12 {
        head = head[:12]
    }
    fmt.Fprintf(stdout, "attempt %s@%s on %s, base %s, %d sessions, %d files changed\n", a.Spec.ID, head, a.Worktree, a.Base, len(a.Sessions), len(a.Diff.Files))

    // The daemon must be the one that holds the work session, and must
    // answer, before any gate spends anything: the session is closed through
    // it before its workspace is removed (ruling P10-43).
    state := filepath.Dir(filepath.Dir(filepath.Dir(a.Worktree)))
    if !sameDir(filepath.Dir(*socket), state) {
        fmt.Fprintf(stderr, "aec-work: the socket %s is not in the state directory %s that holds the worktree: it is not this run's daemon\n", *socket, state)
        return landExitFailed
    }
    dctx, cancel := context.WithTimeout(ctx, 10*time.Second)
    client, err := daemon.Dial(dctx, *socket)
    cancel()
    if err != nil {
        fmt.Fprintln(stderr, "aec-work:", err)
        return landExitFailed
    }
    defer client.Close()

    // The bound, before anything runs.
    line, err := evalBound(suiteFile, *n)
    if err != nil {
        fmt.Fprintln(stderr, "aec-work:", err)
        return landExitFailed
    }
    fmt.Fprintln(stdout, line)
    fmt.Fprintf(stdout, "protected: %s\n", strings.Join(protected, ", "))

    // The report file is claimed now, before a gate runs and before a
    // landing: a second land on the same run does not overwrite the first's
    // report (name another -out), and a report that cannot be written stops
    // the run while nothing has landed.
    rf, err := claimReport(*out)
    if err != nil {
        fmt.Fprintln(stderr, "aec-work:", err)
        return landExitFailed
    }
    defer rf.Close()
    evalDir, err := freshEvalDir(*dir)
    if err != nil {
        os.Remove(*out)
        fmt.Fprintln(stderr, "aec-work:", err)
        return landExitFailed
    }
    gates := []factory.Gate{
        factory.NewTestsGate(git, *sb, nil, nil),
        &factory.PolicyGate{Git: git, Protected: protected, VetSkills: *vet},
        factory.NewEvalGate(git, suiteFile, *live, *sb, factory.EvalOptions{Binary: *evalBin, Dir: evalDir, N: *n}),
    }

    p := &factory.Pipeline{Gates: gates, Git: git, Client: client,
        Log: func(f string, args ...any) { fmt.Fprintf(stderr, f+"\n", args...) }}
    rep, runErr := p.Run(ctx, a)
    var werr error
    if len(rep.Verdicts) > 0 {
        werr = writeLandReport(rf, rep)
    } else {
        os.Remove(*out)
    }
    refused := false
    for _, v := range rep.Verdicts {
        fmt.Fprintln(stdout, verdictLine(v))
        if v.Skipped || v.Code == 4 {
            refused = true
        }
    }
    if *vet && !skillInDiff(a) {
        fmt.Fprintln(stdout, "skills: none in the diff; a skill the daemon learned is vetted with: aecd vet skills -config <aecd.json> -write")
    }
    if rep.Landed {
        // The landing is the fact: it is printed, and the exit says landed,
        // even when the report could not be written (said on stderr).
        fmt.Fprintf(stdout, "landed %s on %s; pushed nothing (push what landed yourself)\n", rep.Head, a.Base)
        if rep.Reason != "" {
            fmt.Fprintln(stdout, rep.Reason)
        }
        if werr != nil {
            fmt.Fprintf(stderr, "aec-work: landed, but the report %s was not written: %v\n", *out, werr)
        }
        return landExitLanded
    }
    if werr != nil {
        fmt.Fprintf(stderr, "aec-work: the report %s was not written: %v\n", *out, werr)
    }
    if runErr != nil {
        fmt.Fprintln(stderr, "aec-work:", runErr)
        return landExitFailed
    }
    fmt.Fprintln(stdout, rep.Reason)
    if refused {
        return landExitRefused
    }
    return landExitFailed
}

Its refusals are before any gate spends anything. -dir, -repo, -audit and -socket are required. -suite has no default and is required: without it nothing lands (exit 4), because “all gates passed” would otherwise name two of the three. The socket must live in the state directory that holds the worktree, which is how land knows the daemon it dials is the run’s own; the pipeline asks that daemon whether the work session is open and closes it if it is, a busy session refuses to close, and a session still listed afterwards, a client that is not the run’s daemon or an error from it is a refusal, not a guess. -protect only adds globs to the defaults (ruling P10-49), entries trimmed and listed once, an empty entry a usage error: a flag that replaced the list could drop .spec/** with a typo, and a rewritten acceptance test would land, so removing a default protection takes code, not a flag. The report file is claimed with O_EXCL before the first gate, so a second land on the same run does not overwrite the first’s report. A land killed between that claim and the write leaves an empty file, or a truncated one if it died mid-write; the next land names which it found and what to do (remove the file if no land is running, or give another -out), and does not reclaim it, because an empty file is also what a land that is running right now looks like. A landing whose report could not be written still exits 0 with the failure on stderr: the landing is the fact. The exit codes are 0 landed, 1 not landed or an error, 2 usage, and 4 when a gate was skipped or the eval gate refused a verdict. A policy failure alone is exit 1; a policy failure beside an eval gate skipped for want of -live is exit 4, and the output shows both reasons.

A repository with submodules is refused: .gitmodules, a nested .git and any gitlink the staging would create are repo.ErrTampered, and an export refuses a gitlink. A repository that uses Git LFS lands pointer files: filter drivers are switched off on every call, so the commit holds the pointer files git stores and the gates grade those, never the objects they point to.

What the gates see, and what they cannot

The tests gate sees the commit’s tracked files, exported fresh, as the sandbox sees them, with the base’s .spec/; a TestMain the attempt committed runs under bwrap, not on the host. The eval gate sees the suite through the runner, and a skipped cell is a refusal. The policy gate sees the diff, the spec, the protected paths and what the audit log recorded of the sessions.

No gate sees what the agent read. The tool results it was shown, the pages it fetched, the memory lines it recalled: reading is where injection enters the agent, and writing and running are where it acts. Chapter 46’s channels are why that is the right boundary: the gates stand at the two places an effect becomes visible to a repository, the diff and the run. Where a read value flows is chapter 47’s taint labels (text from tool observations, memory, peers and workers); what the model was shown is the session’s transcript (chapter 40); chapter 48’s tool records cover only the outward calls among the reads, never a read_file. A gate that tried to judge what the agent read would have to model the injection, and would be an agent.

The grades have a limit that chapter 53 states and this chapter inherits. A gate computed by running the attempt’s code is evidence against honest mistakes, and only that: the sandbox stops an attempt from escaping, not from lying about its own tests. The defences against a dishonest attempt are not in the gates. They are the acceptance test pinned by hash, the reviewer reading a diff that shows everything that shaped the grade (which is why both running gates grade the tracked-only export of the commit), mutation testing, and the person who reads the result. The factory adds a layer to the first of these (the policy gate refuses an .spec/** change; the tests gate grades the base’s .spec/) and none to the last.

The host

On the always-on host the daemon is chapter 51’s module, and land is a command run against it. services.aecd.sandbox = "local" puts bubblewrap and util-linux on the unit’s path, which the tests gate and the suite need; metricsAddr is the loopback address the dashboard scrapes (chapter 49); router.enable = false where the host already runs a router the routes file names; extraPath carries the toolchain the sandbox needs; vetAtStart runs aecd vet skills and aecd vet mcp before every start; verifyTimer runs the audit chain’s verification on a timer. The escape suite on that host is the reader’s step. A factory daemon also sets max_tokens, which caps every model request of a turn.

The ssh backend is the factory’s remote runner in the sense chapter 43 gave it: a command the daemon runs on another host. It claims no isolation of that host’s files or network, so the tests gate, which requires both, skips on it, and what the backend owes the factory is an honest wall. Chapter 51’s first run of its escape table against orion, in Part IX, left two rows unmeasured, because the remote command’s wall kill came back as exit 255 with empty stderr, which the backend could not tell from a failed connection. The reason was the line, not the host. The remote timeout -s KILL signals its own process group, and the line had exec’d into env, so the session shell was a member of that group and died with the command. OpenSSH reports a remote command killed by a signal as exit 255 with nothing on stderr. The line no longer execs; it ends with ; exit $?. The shell is now the parent of timeout, outside its group, sees the child’s 137 and exits with it, and the backend reads 137 as SIGKILL. The Walkthrough shows the fake’s session mode reproducing both readings. The fix assumes a POSIX login shell on the remote; orion’s is zsh 5.9.1, which handles ; exit $? as a POSIX shell does.

aecd mcp is how a hosted pipeline would reach the daemon’s tools: it serves the daemon’s MCP server over stdio, or over a loopback address with a bearer token, to a host that launches servers as subprocesses. It is named, not run: the factory drives the daemon over its control socket. What a hosted CI would run in the gates’ place is one step, aec-work land, whose exit code (0 landed, 1 not landed, 2 usage, 4 refused) a CI step can read. That code is the pipeline’s verdict over the three gates, not a gate’s: the tests gate is sh -c over the acceptance commands, the eval gate is aec-eval run plus a reading of trials.jsonl, and the policy gate is a diff and an audit log. A CI that ran aec-eval run and trusted its status would land a failed matrix.

What PrivateSkip is

Chapter 47’s Decision gains a field, PrivateSkip, set when the model tier was skipped because the turn was private and no private model was configured, as distinct from the tier being down. Overridable already answered correctly for a privacy skip, because a privacy skip always sets ModelErr, and the clause that checked ModelErr answered for both. The answer rested on a coupling the code did not state. The field makes the skip explicit and gives Overridable a clause of its own, after the ModelErr check: a call the model tier did not look at is lifted for nothing above an outright Allow rule, whatever ModelErr says. No decision changed. The clause’s table test includes the rows the clause alone decides, which Decide as built cannot produce, and an invariant test pins where Decide sets the field.

One line of maths

A cell whose per-trial pass probability is pp clears all nn repetitions with probability pnp^n, since the repetitions are independent trials with the same pp and the gate requires each. At n=3n = 3 the values are 0.93=0.7290.9^3 = 0.729, 0.953=0.8573750.95^3 = 0.857375 and 0.993=0.9702990.99^3 = 0.970299. The gate’s “every trial passes” refuses about 27 per cent of attempts that are good over a cell passing nine times in ten, and 14 per cent at nineteen in twenty. That is the gate working as a threshold, not failing: a flaky suite is the repository’s defect, and the gate reports it as one. For the fixture’s suite, two cells of three, every trial at 0.9 clears all six with probability 0.96=0.5314410.9^6 = 0.531441. Chapter 38’s intervals are what a reader consults before raising nn; this chapter cites them and does not re-derive them.

Walkthrough

The landed path below is a scripted attempt: none of chapter 53’s six live runs reached accepted, so there is no live attempt to land. The rig is chapter 53’s, whose model is a script (a first Median that averages in int, a finding, a fix). Everything below ran on straylight on 2026-11-09 (UTC) from the flake’s dev shell, go 1.27.0. The refusal of a live run is shown first, because that is what the live runs got.

A live run that was not accepted

Chapter 53’s third capture ended its second run at stopped:no_progress. land over that run directory, with the other required flags present (command and output as run, paths shortened, <aec> the repository’s root):

$ aec-work land -dir <capture3>/run2 -repo <capture3>/fixture -audit <capture3>/state/audit -socket <capture3>/state/aecd.sock -suite <aec>/go/labs/ch54/testdata/evals/suite.json -live -sandbox local
aec-work: factory: the run is stopped:no_progress, not accepted; only an accepted run is landed

Exit 1. No gate ran, no model was named, and the run writes no report. This is FromRun’s refusal, before the socket is dialled.

The landed attempt

The run directory is <run>, in a directory outside the repository. A real aecd, whose model is chapter 53’s script, ran the loop over the fixture to accepted; the daemon’s state holds the audit directory the policy gate reads. Before the live gate, the router was read raw (GET /v1/models, saved), at 2026-11-09T23:36:37Z:

   gemma4-26b-a4b-abliterated sleeping
   ornith-1.5-35b-a3b loaded

(the other eleven models read unloaded). The 35b was loaded, so nothing was woken. The capture’s script printed the bound before the first request (land printed its own shorter line, below):

eval gate: 1 candidate x 2 tasks x n=3 = 6 trials, each at most 8 completions: at most 48 completions on straylight's 35b, plus one GET /v1/models per trial

The command, and its output with the worktree’s path (under the daemon’s temporary state directory) replaced by <worktree>:

$ aec-work land -dir <run> -repo <repo> -audit <state>/audit -socket <state>/aecd.sock \
    -suite <aec>/go/labs/ch54/testdata/evals/suite.json -live -sandbox local -out <run>/../land-landed.json
attempt median@cfa13c40e428 on <worktree>, base main, 3 sessions, 2 files changed
eval gate: 1 x 2 x n=3 trials, each at most 8 completions
protected: AGENTS.md, CLAUDE.md, .github/**, flake.nix, .spec/**, skills.lock
gate tests: pass (22.5 s)
gate policy: pass (0.0 s)
gate eval: pass (142.2 s)
landed cfa13c40e42832dc6c7569fd843be2b737eb1133 on main
gate tests: pass 22.5 s
gate policy: pass 0.0 s
gate eval: pass 142.2 s
skills: none in the diff; a skill the daemon learned is vetted with: aecd vet skills -config <aecd.json> -write
landed cfa13c40e42832dc6c7569fd843be2b737eb1133 on main; pushed nothing (push what landed yourself)

Exit 0. The progress lines come from the pipeline on stderr and the verdict lines from the command on stdout; the capture interleaved them. The report, land-landed.json, is committed in the lab’s testdata with the run directory’s path and the time rewritten; its three details read:

2 command(s) passed under local+bwrap+systemd-run: vet-test (exec pass: status 0); cli (exec pass: status 0)
2 file(s) inside [calc/** cmd/calc/**]; 0 call(s) denied, 0 approval(s) asked, 0 not granted
6 of 6 trials pass (record <run>/eval/1/eval-2951682679/run)

The audit log has 37 records, counted on the copy taken after land returned (the policy gate read the daemon’s log before the landing; the copy holds no record kind a landing adds, but the count is of the copy): 14 for the work session median-ca92fc58-work (3 of them policy, all allow), 4 for each of the two review sessions, and 15 not attributed to a session. The scripted reviewers made no tool calls, so they have turn records and no policy records. aec-eval report over the record the eval gate kept:

straylight-35b@default       *                  6/6
straylight-35b@default       mean               3/3
straylight-35b@default       median             3/3

The model in the six trials made 6, 7 and 5 turns on mean and 2, 5 and 4 on median (the record’s turns), 29 completions in all of the 48 the bound allowed, 39,187 prompt tokens and 2,577 completion tokens, each answering exactly 2 or 5.5. The gate runs without -traces, so no trial’s spans were kept, and it reads and discards the stderr of aec-eval run, so the aec-eval: requests: line was not kept either; the 29 are the sum of the record’s turns, which counts completions once each and not a client’s retries. The six trials took 142.0 s; the gate 142.2 s. After the run /v1/models was read again, at 2026-11-09T23:40:40Z: the same states, and the two reads differ in the created field of every model entry and nowhere else.

The repository after:

$ git log --oneline -2 main
cfa13c4 fix round 1: median
f69d6bc implement round 0: median
$ git worktree list
<repo>  cfa13c4 [main]
$ git branch
* main

The attempt’s two commits are on main and the branch and the worktree are gone: the fast-forward kept the attempt’s own history. The base of the fixture, 5b29b6cbcf6e656e7f239d0c33536b74f3ccca4f, is what two separate repo.Init calls over it both produced; the attempt’s commits carry the time of the run, so the head is a record of this run and not a value another run reproduces.

Two refusals by policy

Both attempts are authored (no model, no daemon wrote them), built by the lab’s own helpers, so the -socket each was given is a bare listener that nothing is ever asked of: a refused attempt is not landed. Neither run used -live.

The first adds one line to AGENTS.md beside a correct Median. An excerpt of the output, with the worktree’s path replaced by <worktree> and the cut lines marked:

attempt median@568976cd3b54 on <worktree>, base main, 2 sessions, 3 files changed
eval gate: 1 x 2 x n=3 trials, each at most 8 completions
protected: AGENTS.md, CLAUDE.md, .github/**, flake.nix, .spec/**, skills.lock
gate tests: pass (22.4 s)
gate policy: fail: AGENTS.md: outside the spec's allow globs
gate eval: skipped: the suite names a model provider off this host (straylight-35b at straylight): a live gate; run with -live
[the same three gate lines again, from the pipeline's progress output, and the skills line]
not landed: policy, eval (skipped)

Exit 4. The tests passed: the code was right, and the repository’s invariant is about what a change may touch. main was the base commit afterwards. The eval gate was skipped for want of -live, and that is why the exit is 4 and not 1: the policy failure alone would have been exit 1, and the skipped gate adds the refusal. Had -live been given, the eval gate would have cost up to the 48 completions of the bound for an attempt the policy gate had already refused; the order is the free gates first, but all three run so the report is whole. This report is the committed land-refused.json.

The second case is the broad Allow: the spec’s Allow is ** and the commit rewrites .spec/median_test.go. An excerpt, the lines the case differs in:

[attempt, bound and protected lines as above]
gate tests: pass (23.3 s)
gate policy: fail: .spec/median_test.go: a protected path (the spec would have to name it literally)
gate eval: skipped: the suite names a model provider off this host (straylight-35b at straylight): a live gate; run with -live
[...]
not landed: policy, eval (skipped)

Exit 4. The tests gate passed because it graded the base commit’s .spec/, not the rewritten file: the rewrite did not change the grade. What the policy gate refuses is what the rewrite would do if it landed.

The ssh wall

TestSSHWallKillIsSignal builds the Part IX remote line and the current one and runs each through the fake ssh’s session mode, a small Go waiter that runs the remote line as its child and exits 255 with nothing on stderr when that child was killed by a signal, which is what ssh does. A shell fake cannot show the difference: a shell waiting on a signalled child reads $? as 137, the same as a child that exited 137 itself, so the waiter reads WaitStatus.Signaled(). Run alone (straylight, go 1.27.0, 2026-11-09):

=== RUN   TestSSHWallKillIsSignal
    ssh_wall_test.go:103: old line: status 255, signal "", stderr ""
    ssh_wall_test.go:113: new line: status -1, signal "KILL"
--- PASS: TestSSHWallKillIsSignal (2.04s)

The same line against orion, driven from straylight on 2026-11-09, with the five rows driven from wntrmute on 2026-10-27 byte-identical to their committed copies:

<!-- escape table, host orion (the env, memory and pids rows driven from wntrmute, 2026-10-27; the wall rows driven from straylight, 2026-11-09) -->
| wall: a sleep past the limit | ssh | contained | SIGKILL |
| wall: a spin past the limit | ssh | contained | SIGKILL |

Chapter 51 prints the whole table and counts the ssh sessions of the step (13 against a bound of 12).

Your repository

What changes for a reader’s own repository, in the order the command takes it. The spec’s Allow and Base are the reader’s, and so is its acceptance: the tests gate runs only the spec’s acceptance commands, so a reader who wants the repository’s whole suite gated names its full test command there, as the fixture’s vet-test names go vet ./... && go test ./.... The reader runs aec-work spec check SPEC -repo DIR before aec-work run, because it is the one command that reports an allow glob matching no file of the repository (path_outside_allow) before the policy gate refuses the change for it. The base branch must be checked out in the repository named by -repo, because land fast-forwards a checked-out branch. The protected globs the reader adds with -protect join the defaults and cannot remove them: the CI configuration, the build files, the rule files for other agents, and the spec files themselves, wherever the repository keeps them. The suite is the evals the repository keeps for its agents, a host file outside the repository, with -live if it names a provider off the host and a bound the reader reads before the first request. The audit directory is the daemon’s own, <state>/audit of the daemon that ran the work; a hand-written audit log fails for what it lacks. The socket is the run’s daemon’s. The reader pushes what landed.

The provenance of every number above: the gate seconds, the trial table and the token counts are the capture on straylight on 2026-11-09 (the attempt’s gates and the 35b); the maths is a script; the ssh lines are the test on straylight, and the orion rows are the run chapter 51 describes.

Exercises

(a) aec-eval run exits 0 on a failed trial. Read cmdRun’s exit codes (the doc in chapter 37’s listing, and the loop that sets code) and say what a CI step that gates on the code lands. Name the codes the command can return, and what aecd eval does differently.

Answer

The doc names four codes: 0 when no trial is an error, 1 on an I/O failure, 2 on usage and 3 when some trials are errors or the run was cancelled. The loop sets code = 3 only for a trial whose status is error and for a run that ended early. A trial that fails its grader has status fail and a skipped cell has status skipped; neither moves the code, so both exit 0. A CI step that trusted the status would land a matrix whose every trial failed, or whose every cell was skipped. aecd eval returns 4 when a registered cell was skipped (ruling 9c-5; chapter 38’s refused verdict), because a skipped cell is a reported gap and not a pass. The factory carries that refusal itself, reading trials.jsonl: the status of a command is not the gate.

(b) A spec whose Allow is ** tries to land an AGENTS.md edit. What does the gate say, and why is the rule “named literally”? What one-line Allow entry lands it on purpose?

Answer

The gate says AGENTS.md: a protected path (the spec would have to name it literally). The broad glob is the spec author’s convenience for the files the work touches, and it is not an instruction to change the file that instructs the next agent: by arXiv 2604.11088’s finding a rule file moves an agent whatever it says, so an edit to it is a change in behaviour the repository should see on purpose. An entry AGENTS.md in allow (no *, ? or [) is the one line that lands it; it is visible in the spec, which is hashed into the run.

(c) The audit log holds a policy record at tier: strict for the attempt’s session. What happened in the daemon at that moment, why does the gate fail rather than warn, and what could allow_unattended not have lifted?

Answer

The model tier of chapter 47’s gate did not answer in time (or was down), so the strict tier decided in its place: the tool call was judged by rules alone, with the model’s reading absent. Overridable is false while ModelErr is set, except for a call a rule allowed outright (chapter 47: allow_unattended is suspended while strict), so allow_unattended lifted nothing the model tier could have escalated. The attempt’s code was written while a tier was down and the record says so. A warning would be a pass by another name: the gate cannot tell which of the attempt’s calls the model would have stopped, and a gate that passes by absence is the failure mode this chapter refuses.

(d) Compute the probability that a cell with p=0.9p = 0.9 clears n=3n = 3 and n=5n = 5, and the nn at which a cell with p=0.99p = 0.99 falls below a 95% chance of clearing. What does that say about raising nn to “be sure”?

Answer

0.93=0.7290.9^3 = 0.729 and 0.95=0.590490.9^5 = 0.59049. For p=0.99p = 0.99: 0.99n<0.95⇔n>ln0.95/ln0.99=5.100.99^n < 0.95 \Leftrightarrow n > \ln 0.95 / \ln 0.99 = 5.10, so n=6n = 6: 0.995=0.950990.99^5 = 0.95099 and 0.996=0.941480.99^6 = 0.94148. Raising nn does not make the gate surer that a good attempt passes; it makes it refuse more of them, because the gate demands every repetition. A larger nn is a stricter threshold, not a better estimate of pp, and the way to know pp is chapter 38’s interval over the trials, not a longer run of the gate.

(e) Derive why the old remote line reported 255, from timeout -s KILL, its process group, the exec’d session shell and what ssh reports for a signalled command. Then say what ; exit $? changes and why a shell fake cannot show the difference.

Answer

GNU timeout makes itself the leader of a new process group and, when the limit passes, sends the signal to its child and then to its own group (kill(0, SIGKILL)). The old line was cd DIR && exec env -i ... timeout -s KILL N ...: the session shell exec’d into env, which exec’d timeout, so the session’s process was the process that became the group’s leader, and the group signal killed the session itself. The remote command died by a signal, and OpenSSH reports that as exit 255 with nothing on stderr, which looks exactly like a failed connection. With no exec the shell is the parent of timeout, in its own group, outside timeout’s; it survives the kill, reads the child’s status (137 for SIGKILL) and, with ; exit $?, exits with it, so ssh reports 137 and the backend reads it as SIGKILL. A shell fake waiting on a signalled child gets $? = 137 for it and for a child that exited 137 on its own, so it cannot show the old line’s 255; a Go waiter reads WaitStatus.Signaled() and can.

(f) Name one thing none of the three gates can see about the attempt, and the mechanism of an earlier chapter that does.

Answer

What the agent read: the tool results it was shown, the pages it fetched, the memory lines it recalled. The gates stand at writing and running on purpose. Chapter 47’s taint labels account for where a read value flows, and the session’s transcript (chapter 40) holds what the model was shown; chapter 48’s tool records cover only outward calls (a fetched page by name and hash), never a read_file or a memory recall. A reviewer who wanted to know what shaped a change reads those, not the gates.

Lab

make lab CH=54 IMPL=ref runs go/labs/ch54 against the reference; IMPL=mine runs it against your mine/policy.go, which holds Policy: the policy gate’s Check, over the diff against the spec’s Allow and the protected paths, the audit records of the attempt’s sessions and the loader over any skill the attempt wrote. The tests that land or refuse a whole attempt run on the reference whichever IMPL is set, because they are the pipeline’s properties, which the chapter measures. The four that run your piece are TestDiffOutsideAllowRefuses, TestStrictDecisionRefuses, TestLearnedSkillVetted and TestProtectedPathsRefuse.

  • TestPipelineLands lands the median attempt through the three gates (the eval gate against a loopback fake) and checks that main is the attempt’s head and the worktree is gone. A second subtest stops after the gates and shows the tests gate graded an export of the commit: the worktree holds no calc/median_test.go and no .cache, and git sees it clean.
  • TestFailingTestRefuses: a Median that returns the lower middle value fails the pinned acceptance test at vet-test; the other gates still ran; nothing lands.
  • TestSkippedEvalCellRefuses: with the suite’s sandbox field removed the runner skips both execute_code tasks, and a skipped cell is a refused verdict (code 4) naming the cells, not a pass. The same suite unchanged, without Live, is a skipped gate naming the provider off this host.
  • TestDiffOutsideAllowRefuses: the median attempt plus an edit to AGENTS.md. TestStrictDecisionRefuses: an audit record at the strict tier fails the gate, naming the session and the turn.
  • TestLearnedSkillVetted: a learned skill arrives as a file of the attempt; a skill whose bytes differ from the base lock fails, naming the file, and one that matches passes.
  • TestProtectedPathsRefuse: a rewritten acceptance test under Allow: **; an edit beside a SKILL.md outside the skill roots; a skills.lock the attempt wrote. A Policy that ignores g.Protected passes the other policy tests and fails this one.
  • TestNoPush: a landing moves the local branch and nothing else, against a bare origin read from the bare repository. TestMainMovedRefuses: another commit lands on main first; the attempt is not landed, the report says why, and the fast-forward asked directly is repo.ErrNotFastForward.
  • TestFixtureSuiteLimits pins the host-owned suite: its sandbox limits are the one owner’s, both tasks run code only through execute_code, the median task expects 5.5, and the fixture repository holds no evals/. TestLandReportFixtures reads the two committed reports as factory.Report: the three gates in order, the landed one all passing, the refused one with a failing policy gate. TestNoSecretsInTestdata reads the lab’s testdata for secrets and for anything of a run.
  • TestLandsLoopAttempt is the one rig test: a real aecd answers chapter 53’s scripted implementer and reviewer; the loop runs over the fixture to accepted; FromRun reads the run; the gates run over its commit; the work session is closed through the daemon; the attempt lands. Its policy gate reads the daemon’s own audit log, and the test asserts that every session has records and that the work session has policy records, not that every session does.

AEC_IMPL=ref go test -count=1 -v ./labs/ch54 passed in 43.1 s on straylight (2026-11-09, in the dev shell at nice 19; the longest test, TestLandsLoopAttempt, took 41.7 s, of which the test’s own warm-up of the Go build cache under bwrap was 17.8 s). With AEC_IMPL=mine and the stub unwritten, TestDiffOutsideAllowRefuses, TestStrictDecisionRefuses, TestLearnedSkillVetted and TestProtectedPathsRefuse fail with the stub’s message in the verdict’s detail (panic: labs/ch54: write Policy in go/labs/ch54/mine/policy.go), and every other test passes.

On a host without bwrap the lab’s tests gate falls back to running the spec’s committed acceptance text on the host with sh -c (logged): that text is authored by the book, not chosen by a model, which is inside ruling X9-10’s test clause, and a host without bwrap is not a place the factory itself would run. land on such a host exits 4 with the tests gate skipped. What the lab cannot see: the model. The eval gate’s provider in the lab is a loopback fake, and TestLandsLoopAttempt’s implementer and reviewer are scripts. The capture above, one live run of the eval gate on one host, is the only place a model enters, and it is not re-run by anything.

Further reading

results matching ""

    No results matching ""