checks

package
v2.7.0 Latest Latest
Warning

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

Go to latest
Published: Oct 2, 2026 License: MIT Imports: 15 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 checks runs a project's check command against a session's worktree when its agent stops, and stores the result for the card to show.

It is the session half of docs/agent-events.md section 4 ("Checks"). Tasks keep their existing one-shot auto-verify (internal/scheduler, unchanged attempts.verify_json shape); this package's Resolve/Execute are what that path now calls too, so "verify_cmd, or auto-detected .verify.yaml" is one rule instead of two. Sessions are different from a task attempt in one important way: they are ongoing, so running the same command again every time an agent goes idle — often with nothing new in the worktree — would be pure waste. RunForSession exists to make that cheap: a fingerprint over the worktree's diff decides whether there is anything worth checking.

Index

Constants

View Source
const (
	StatusRunning = "running"
	StatusPassed  = "passed"
	StatusFailed  = "failed"
	StatusError   = "error"
	StatusSkipped = "skipped"
)

Status values stored in session_checks.status (see store/schema.go).

View Source
const (
	ReasonStop   = "stop"   // an agent Stop (or codex AgentTurnComplete) hook
	ReasonScreen = "screen" // the screen-derived busy->idle fallback
	ReasonManual = "manual" // a human pressed "Run check"
)

Trigger reasons stored in session_checks.reason.

View Source
const AutoVerifyCommand = "verify run .verify.yaml"

AutoVerifyCommand is what a project with no verify_cmd but a checked-in .verify.yaml and `verify` on the target's PATH gets for free — see probeAutoCommand and docs/agent-events.md section 4.

View Source
const DefaultTimeout = 15 * time.Minute

DefaultTimeout is 15 minutes, matching the literal the task auto-verify path used before this package existed.

Variables

This section is empty.

Functions

This section is empty.

Types

type Runner

type Runner struct {
	DB       *store.DB
	Reg      *executor.Registry
	Bus      *bus.Bus
	Notifier *sinks.Notifier
	Log      *slog.Logger
	// Timeout bounds one check run; DefaultTimeout is used when unset.
	Timeout time.Duration
	// contains filtered or unexported fields
}

Runner owns check execution for both sessions (this file) and, via RunForTask, the task auto-verify path (internal/scheduler).

func New

func New(db *store.DB, reg *executor.Registry, b *bus.Bus, notifier *sinks.Notifier, timeout time.Duration, log *slog.Logger) *Runner

New builds a Runner.

func (*Runner) DetectCommand

func (r *Runner) DetectCommand(ctx context.Context, project *store.Project) (cmd, source string)

DetectCommand is resolve for a project with no live worktree yet — the project settings UI's "Check command: auto-detected: ..." preview. It probes the project's own repo checkout on its target, since .verify.yaml is checked into the repo and so is present in any worktree cut from it.

func (*Runner) OnAgentStop

func (r *Runner) OnAgentStop(sessionID int64)

OnAgentStop implements StopListener. The actual run happens on a fresh goroutine with its own background context: the caller (a hook's HTTP handler, or a poll tick) must get its own turn back immediately, and a check that legitimately takes minutes must not be cancelled just because the request that triggered it already answered.

func (*Runner) RunForSession

func (r *Runner) RunForSession(ctx context.Context, sessionID int64, reason string)

RunForSession resolves a session's check command and runs it if the worktree has changed since the last check (or reason is ReasonManual, which always runs). Only one check runs at a time per session; a request that arrives while one is already running is coalesced into a single extra run afterward, using whichever reason arrived last.

func (*Runner) RunForTask

func (r *Runner) RunForTask(ctx context.Context, ex executor.Executor, project *store.Project, worktreePath string) (map[string]any, bool)

RunForTask runs a project's check command against a finished task attempt's worktree, in the exact {"cmd","rc","output"} shape scheduler.go has always stored in attempts.verify_json — callers must not change that shape, since the timeline event and the board badge both parse it. Unlike a session, a task attempt is one-shot: there is nothing to fingerprint against and no coalescing concern, so this is just resolve-then-execute.

type StopListener

type StopListener interface {
	// OnAgentStop is fire-and-forget: it must not block its caller (a hook
	// handler that owes the agent a fast HTTP response, or a poll tick that
	// owes the rest of the fleet its turn). The runner performs the actual
	// check on its own goroutine, coalescing overlapping requests.
	OnAgentStop(sessionID int64)
}

StopListener is how something that observes an agent's lifecycle (a Stop hook, or the screen-derived status fallback) tells the checks runner a session may have new work to check. It is defined here, not imported by its callers as a concrete type, so internal/agentevents and internal/sessions never need to import internal/checks — *Runner satisfies this interface structurally, wired up in internal/app.

Jump to

Keyboard shortcuts

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