board

package
v0.93.0 Latest Latest
Warning

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

Go to latest
Published: Oct 8, 2026 License: Apache-2.0 Imports: 19 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 board is the Phase 2 task board: it bridges the hive's task files and mailboxes to the SQLite mirror and the API. It also answers the Stop hook to force a worker to keep going while its inbox is non-empty (the autonomy engine), with a hard per-(session,task) guard. See .ai/05-orchestration.md.

Index

Constants

View Source
const DefaultBudgetUSD = 5.0

DefaultBudgetUSD is applied when a task is created without a budget. It is a stop, not a forecast: unattended sessions run with --dangerously-skip-permissions, and the previous default (0 ⇒ unlimited) meant a runaway worker had no ceiling at all. The safe default must be a finite one; $5 is small enough that hitting it is a pause a human notices rather than a bill they discover, and a user who wants more states it explicitly. It is not a claim about what a task costs (rule 6) — it is the ceiling Caprock enforces when the user named none.

View Source
const MaxForcedContinues = 10

MaxForcedContinues is the Stop-loop guard: after this many forced continues for one (session, task), Caprock escalates to the human instead (default 10).

View Source
const MaxVerifyRounds = 3

MaxVerifyRounds is the verification-bounce guard (default 3): after this many failed rounds a task escalates to needs_you instead of bouncing again.

View Source
const VerifyCommandTimeout = 5 * time.Minute

VerifyCommandTimeout bounds a single done_criteria command.

Variables

View Source
var DestructivePatterns = []*regexp.Regexp{
	regexp.MustCompile(`\brm\s+(-[a-zA-Z]*\s+)*-[a-zA-Z]*[rf]`),
	regexp.MustCompile(`\brm\s+-[a-zA-Z]*f`),
	regexp.MustCompile(`\bgit\s+push\b`),
	regexp.MustCompile(`\bgit\s+.*\bpush\s+.*--force|\bgit\s+push\s+-f\b`),
	regexp.MustCompile(`\bgit\s+reset\s+--hard\b`),
	regexp.MustCompile(`\bgit\s+clean\s+-[a-zA-Z]*[dfx]`),
	regexp.MustCompile(`\bsudo\b`),
	regexp.MustCompile(`\b(shutdown|reboot|halt|poweroff)\b`),
	regexp.MustCompile(`\bmkfs\b|\bdd\s+if=`),
	regexp.MustCompile(`>\s*/dev/sd|\bfdisk\b`),
	regexp.MustCompile(`\bcurl\b.*\|\s*(sh|bash)\b|\bwget\b.*\|\s*(sh|bash)\b`),
	regexp.MustCompile(`\bkubectl\s+delete\b|\bterraform\s+(destroy|apply)\b`),
	regexp.MustCompile(`\bnpm\s+publish\b|\bcargo\s+publish\b|\btwine\s+upload\b|\bgoreleaser\s+release\b`),
	regexp.MustCompile(`:\(\)\s*\{.*\|.*&\s*\}`),
}

DestructivePatterns are commands a task must not run unattended — they land the task in needs_you for a human to approve instead. Conservative on purpose: these are irreversible or outside-the-repo actions. Users can extend the list via config later; this is the built-in floor. See .ai/05-orchestration.md § Approvals.

Functions

func IsDestructive

func IsDestructive(command string) (bool, string)

IsDestructive reports whether a command matches the destructive policy, and the first pattern it matched (for the escalation message).

func ScreenDoneCriteria

func ScreenDoneCriteria(criteria []string) []string

ScreenDoneCriteria returns the destructive commands among a task's done_criteria (empty when all are safe). The verification runner uses this to send a task to needs_you instead of running a dangerous command unattended.

func WorktreePath

func WorktreePath(repo, workerID string) string

WorktreePath returns the worktree dir for a worker under the repo, matching how the orchestrator's worker spawn creates it.

Types

type Board

type Board struct {
	Hive  *hive.Hive
	Store *store.Store
	Bus   *bus.Bus
	Log   *slog.Logger
	Now   func() time.Time
	// RepoCwd is the repo tasks operate on; verification commands run in the
	// assigned worker's worktree under it, or in RepoCwd when there is no worktree.
	RepoCwd string
	// contains filtered or unexported fields
}

Board wires the hive, store mirror and bus.

func New

func New(h *hive.Hive, st *store.Store, b *bus.Bus, log *slog.Logger) *Board

func (*Board) Approvals

func (b *Board) Approvals(ctx context.Context) (any, error)

Approvals lists tasks in the needs-you column.

func (*Board) Approve

func (b *Board) Approve(ctx context.Context, id string, approve bool) error

Approve/reject a task in the needs-you column, feeding the decision back to the orchestrator via a mailbox message.

func (*Board) Create

func (b *Board) Create(ctx context.Context, req any) (any, error)

Create writes a task to the hive and mirrors it.

func (*Board) Get

func (b *Board) Get(ctx context.Context, id string) (any, error)

Get returns one mirrored task plus its hive body.

func (*Board) List

func (b *Board) List(ctx context.Context) (any, error)

List returns the mirrored task rows.

func (*Board) OverBudget added in v0.12.0

func (b *Board) OverBudget(ctx context.Context, taskID, reason string) error

OverBudget parks a task that outspent its budget in needs_you and records why, so the approvals column shows a reason rather than an unexplained pause. The reason is appended to the task body (which the UI already renders) rather than added as a column — no DDL, and it survives in the hive file, which is the source of truth. Re-parking an already-parked task is a no-op.

func (*Board) Rescan

func (b *Board) Rescan(ctx context.Context) error

Rescan rebuilds the SQLite task mirror from the hive files (source of truth).

func (*Board) StopDecision

func (b *Board) StopDecision(ctx context.Context, sessionID, agentID, taskID string) []byte

StopDecision answers a worker's Stop hook: block (force continue) while the worker's inbox is non-empty and the guard is not exhausted; else allow the stop. Returns the JSON body to relay to Claude Code, or nil to allow.

func (*Board) VerificationOutputDir added in v0.15.0

func (b *Board) VerificationOutputDir(taskID string) string

VerificationOutputDir is where captured done_criteria output is persisted, under the hive so it lives with the task files it explains.

func (*Board) Verify

func (b *Board) Verify(ctx context.Context, taskID, cwd string) (VerifyResult, error)

Verify runs a task's done_criteria in the worker's worktree. All green ⇒ the task moves to done. Any red ⇒ it bounces back to the worker with the failing output (up to MaxVerifyRounds, then it escalates to needs_you). Cwd is the directory the commands run in (the worker's worktree, or the repo).

func (*Board) VerifyTask

func (b *Board) VerifyTask(ctx context.Context, id string) (VerifyResult, error)

VerifyTask (controller entry) resolves the worktree for the assigned worker and runs verification.

type CommandRun

type CommandRun struct {
	Command  string `json:"command"`
	ExitCode int    `json:"exit_code"`
	Output   string `json:"output"`
	Passed   bool   `json:"passed"`
	// OutputPath is the file the full captured output was written to, so a green
	// result can be audited after the fact (`Output` is tail-capped for the UI).
	OutputPath string `json:"output_path,omitempty"`
}

CommandRun is one done_criteria command's result.

type CreateRequest

type CreateRequest struct {
	ID           string   `json:"id"`
	Title        string   `json:"title"`
	BudgetUSD    float64  `json:"budget_usd"`
	DoneCriteria []string `json:"done_criteria"`
	Body         string   `json:"body"`
}

CreateRequest is the POST /v1/tasks body.

type VerifyResult

type VerifyResult struct {
	TaskID    string       `json:"task_id"`
	Round     int          `json:"round"`
	Passed    bool         `json:"passed"`
	Commands  []CommandRun `json:"commands"`
	Status    string       `json:"status"` // the task's new status
	Escalated bool         `json:"escalated"`
	// Unverifiable is true when the task could not be checked at all (no
	// done_criteria, or no worktree to run them in). It never means "passed":
	// the task is parked in needs_you for the human.
	Unverifiable bool `json:"unverifiable,omitempty"`
}

VerifyResult reports the outcome of running a task's done_criteria.

Jump to

Keyboard shortcuts

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