Goals and verification
zelk ends a run only when the model reports and the report holds up against what the run did. Runs and completion explains the rules; this page shows what a host controls.
The project’s checks
Section titled “The project’s checks”WithVerify names checks the model runs by name with the Verify tool. The
evidence records the command, its exit status and the workspace state it
ran against, and a run can’t end as a success while a check’s latest run
failed or went stale:
ctx := context.Background()root, err := os.Getwd()if err != nil { panic(err)}workspace, err := local.New(ctx, root)if err != nil { panic(err)}defer workspace.Close()p, err := replay.New(provider.Caps{})if err != nil { panic(err)}a, err := zelk.New(ctx, p, zelk.WithModel("m"), zelk.WithPermissionMode(permission.ModeAcceptEdits), zelk.WithEnvironment(workspace, filepath.ToSlash(root)), zelk.WithShell(zelk.Shell{Path: "/bin/bash", Env: []string{"PATH=/usr/local/go/bin:/usr/bin:/bin", "HOME=" + os.TempDir()}}), zelk.WithVerify(zelk.Check{Name: "test", Command: "go test ./..."}))if err != nil { panic(err)}defer a.Close(ctx)for _, d := range a.Tools() { if d.Name == "Bash" || d.Name == "Verify" { fmt.Println(d.Name) }}// Output:// Bash// VerifyWithRequiredVerification also requires fresh passing evidence for every
check before a run can succeed. Without host checks, sessions get no
Verify tool, and the model checks with Bash and says how in its report.
A run’s goal is the request that started it, unless the host sets one with
zelk.SetGoal(text), which then holds across later messages and
compaction until ClearGoal. The model can’t change it.
Reading the outcome
Section titled “Reading the outcome”Result carries the outcome, the report and
the usage. Result.Report says what the model claimed, what zelk verified,
which checks lacked fresh evidence and why, which files built-in tools
changed, and which claims in the final message no evidence supports.
WithCompletion(continuations, repeatLimit) sets how many times a run is
sent back before it ends incomplete (3) and when repeated identical
failures stop it. WithoutCompletion turns the check off.
Requirements per piece of work
Section titled “Requirements per piece of work”A host that tracks work items can scope verification to them: it declares each requirement with its own check, tied to the instruction it came from, and a run succeeds only when the requirements that apply pass:
p, err := replay.New(provider.Caps{})if err != nil { panic(err)}// The workspace ID is the host's stable mapping, never a display path.a, err := zelk.New(context.Background(), p, zelk.WithPermissionMode(permission.ModeBypass), zelk.WithModel("m"), zelk.WithScopedVerification("checkout-7f3a"))if err != nil { panic(err)}s, err := a.Session(context.Background(), "scoped-example")if err != nil { panic(err)}// Requirement commands are accepted only while the session is idle and// name an accepted originating instruction. None of them starts a run.origin := zelk.SetGoal("Add a changelog entry.")origin.ID = "changelog-request"acceptance := event.Requirement{ID: "changelog-entry", Revision: 1, Scope: event.RequirementWork, WorkID: "changelog", WorkRevision: 1, Name: "entry", Command: "grep -q 'v1.2' CHANGELOG.md"}x, err := s.Start(context.Background(), zelk.WithCommands(origin, zelk.SetVerificationWork("changelog", 1, origin.ID), zelk.DeclareRequirement(acceptance, 0, origin.ID)))if err != nil { panic(err)}if _, err := x.Wait(context.Background()); err != nil { panic(err)}st := loop.New(s.ID())for ev, err := range s.Events(context.Background(), 1) { if err != nil { panic(err) } if st, err = loop.Step(st, ev); err != nil { panic(err) }}for _, r := range st.ApplicableRequirements() { fmt.Println(r.ID, r.Revision, r.Command)}fmt.Println(len(p.Requests()))if err := a.Close(context.Background()); err != nil { panic(err)}// Output:// changelog-entry 1 grep -q 'v1.2' CHANGELOG.md// 0The completion contract specifies scoped verification in full.
Budgets and limits bound what a run may spend.