drive

package
v0.62.0 Latest Latest
Warning

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

Go to latest
Published: Nov 16, 2026 License: MIT Imports: 57 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 drive runs a list of tasks through their flow from one process: each in its own worktree and agent, dependents once their base has code, halting when an agent asks and nothing else can move; and the watcher's passes over tasks no drive owns.

Index

Constants

View Source
const (
	AtHeld runPhase // not opened: the cap holds it

)

Variables

This section is empty.

Functions

func CloseDriveAsks

func CloseDriveAsks(dir, root string, n int, now time.Time)

CloseDriveAsks closes drive n's open asks: a cancelled drive leaves nothing waiting in the inbox.

func DefaultParallel

func DefaultParallel() int

DefaultParallel is a drive's cap with no --parallel: half the cores, since each agent's verify uses several, held between 2 and 8.

func Drive

func Drive(ctx context.Context, w io.Writer, in *DriveInput) (err error)

Drive runs the flow; nothing is created or prompted before the graph passed validation.

func DriveCancel

func DriveCancel(w io.Writer, root string, n int, now time.Time) error

DriveCancel marks drive n cancelled: a live drive stops prompting at its next poll; worktrees, branches and agents stay as they are.

func DriveFinishInput

func DriveFinishInput(t *target.Target, main string, h hostops.Host, req DriveFinish) (finish.FinishInput, error)

func DriveList

func DriveList(
	ctx context.Context,
	w io.Writer,
	links *render.TaskLinks,
	project, root string,
	all bool,
	finished func(row string) bool,
) error

DriveList prints the records, newest first. finished reports a row's task finished outside its drive; nil checks nothing.

func DriveSkills

func DriveSkills(fl runplan.ShipFlow) []string

DriveSkills reads the skills off the flow: plan when the flow leads with it, ship, then finish when the pace finishes.

func DriveUsage

func DriveUsage() string

DriveUsage is drive's ArgsUsage, read off DriveFlags.

func LedgerReports added in v0.62.0

func LedgerReports(ctx context.Context, main string) func(watchReport)

LedgerReports records each report a pass tells as a watch_reported row, so API clients see what the watch log shows. The project is read once, on the first report; the pull and host reports are the project's own, so their rows name no task.

func LoadWatchStore

func LoadWatchStore(root string) (map[string]watchReport, error)

func NewAnswerBook

func NewAnswerBook() answerBook

func OnOff

func OnOff(on bool) string

func RecordAt

func RecordAt(ctx context.Context, dir string, e ledger.Event)

func RecordKey added in v0.62.0

func RecordKey(argv []string) string

RecordKey is the key the daemon attaches a drive's arguments by: its record's command line, "" for a drive given answers or a resume, which starts or names its own.

func RowFinishedFor

func RowFinishedFor(ctx context.Context, t *target.Target) func(string) bool

RowFinishedFor checks a record's row, an id as typed, by FinishedTask, as drive and status do; a row that names no task, or a git error, reads as unfinished, since a wrong yes hides a halt.

func TailLog

func TailLog(ctx context.Context, w io.Writer, path string) (daemon.Exit, error)

TailLog copies a drive's log to w as it grows, until its exit file appears, and returns the exit; ctx ending stops only the copy.

func ThroughDaemon

func ThroughDaemon(ctx context.Context, w io.Writer, t *target.Target, argv []string, a drivectl.DriveArgs) error

func VerifySpecOf

func VerifySpecOf(eff *facts.Effective) (stack.VerifySpec, string)

VerifySpecOf reads the project's verify as commands. A Verify heading counts only in the form f10 init writes (backticked commands joined by " / "); any other prose is rules only a model can follow, and why says so.

func WatchDrain

func WatchDrain(fore bool) (<-chan os.Signal, func())

WatchDrain catches SIGUSR1, the daemon's request that a foreground drive stop at its next tick; nil, and nothing caught, outside the foreground.

func WatchPass

func WatchPass(ctx context.Context, in WatchInput) (bool, error)

WatchPass reports false once the project has no task worktree and no local task branch, so the daemon drops it.

func WatcherFinish

func WatcherFinish(ctx context.Context, w io.Writer, t *target.Target, main, root string, task WatchedTask) error

WatcherFinish holds the lease as the watcher and refuses anything but a merged request. It writes no drive finish record: the board would read the watcher as a drive.

func WriteDaemonStatus

func WriteDaemonStatus(ctx context.Context, w io.Writer, links *render.TaskLinks, rep daemon.Status)

WriteDaemonStatus prints what the daemon runs and watches.

Types

type DriveFinish

type DriveFinish struct {
	Task     ref.Ref
	Suffix   string
	Branch   string // the run's branch, "" to look it up by task and suffix
	Pr       string // the answer to a foreign PR: FinishMerge, FinishLeaveOpen or ""
	Progress func(string)
	Handoff  func([]string)
	Deferred func(string)
}

DriveFinish is what a drive's finish needs from its run; the rest comes from the project's settings.

type DriveInput

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

DriveInput is one drive: what its command line and project settled, what it calls out to, and what the run changes as it goes.

func (*DriveInput) KeepFlow

func (in *DriveInput) KeepFlow(ctx context.Context, branch string) (runplan.ShipFlow, string, error)

KeepFlow prefers the flow a branch already records over the run's, since switching mid-run would rerun or skip entries ship already declared; one project.md no longer declares gives way to the run's, with a note.

func (in *DriveInput) LoadLinks(ctx context.Context, tasks []DriveTask)

LoadLinks reads the urls of the drive's tasks and their bases; a drive the daemon runs writes to a log, so it links nothing.

func (*DriveInput) Queue

func (in *DriveInput) Queue(r *DriveRun)

func (*DriveInput) Report

func (in *DriveInput) Report(runs []*DriveRun, notes []string) error

Report exits with an ask over a halt, since answering the ask is what resumes the drive.

func (*DriveInput) Skills

func (in *DriveInput) Skills(r *DriveRun) []string

Skills is what drive prompts r through, in order; a spike its pace does not finish gets finish once it closes.

func (*DriveInput) Wake

func (in *DriveInput) Wake(ctx context.Context, d time.Duration) error

Wake returns before d once the drive's record or a per-session file about one of its worktrees is written. A stat a second of a few dozen small files costs nothing, and sees in-place writes a directory watch misses.

type DriveRun

type DriveRun struct {
	Task     DriveTask
	Base     *DriveRun // the listed base, or nil for none or one outside the list
	O        start.OpenedTask
	Phase    runPhase
	Flow     runplan.ShipFlow // the flow this task ships through: its branch's record, else the run's
	Finishes bool             // drive ends the task with finish: the pace says so, or a spike closes
	Pos      int              // the index in its skills of the skill in flight, or the next one
	End      *driveResult

	// parkedHead is the base's head when a ship parked itself, so only a
	// commit after it sends ship again, never the same empty base; waitHead
	// is the base head the last park read, so a base that committed before
	// the drive saw the stop is sent once, never looped
	WaitHead string
	// ParkedOrigin is set while a ship that stopped before pr waits for its
	// base's branch on origin, which the PR targets, not for its code
	ParkedOrigin bool

	// Job is the verify the drive runs after its own catchup, polled in
	// place of the agent while the phase is verifying
	Job *verifyJob
	// contains filtered or unexported fields
}

A DriveRun is one task on its way through the drive: pending until its base has a commit, then active with one skill in flight or waiting at finish for its base, then ended with its row.

type DriveTask

type DriveTask struct {
	Ref    ref.Ref
	Suffix string

	Branch string // the task's local branch, or "" before it started

	Base string // the base the drive waits for: the branch's record, else after
	// contains filtered or unexported fields
}

A DriveTask is one task of the list, as the validation pass found it.

type LineReporter

type LineReporter struct{ Out io.Writer }

func (LineReporter) Report

func (l LineReporter) Report(r watchReport)

type PlanInput added in v0.61.0

type PlanInput struct {
	Storage         storage.Root
	Tracker         stack.Tracker
	FlowByArea      map[string]string
	MaxLines        int
	DefaultParallel int
}

PlanInput is what drive plan reads beside its arguments. It writes nothing: no record, no lease, no tracker change.

type PlanResult added in v0.61.0

type PlanResult struct {
	Plan   driveplan.Plan
	Tasks  []driveplan.Task
	Notes  []string // tasks left out, and why
	Extra  []string // the drive flags carried onto the command
	Agreed *drivestore.Record
}

PlanResult is a proposal, or the drive already agreed from the same planning arguments.

func Plan added in v0.61.0

Plan proposes how to drive the arguments' tasks, or names the drive already agreed from them.

type SheetTask added in v0.61.0

type SheetTask struct {
	Kind     string   `json:"kind,omitempty"`
	Areas    []string `json:"areas,omitempty"`
	Files    []string `json:"files,omitempty"`
	Lines    int      `json:"lines,omitempty"`
	BuildsOn string   `json:"buildsOn,omitempty"`
	Risky    string   `json:"risky,omitempty"`
	Alone    bool     `json:"alone,omitempty"`
	With     string   `json:"with,omitempty"`
	After    string   `json:"after,omitempty"`
}

A SheetTask is one task's row in the facts sheet the drive skill writes: what only a read of the task against the code can tell, and the user's edits to the proposal.

type WatchInput

type WatchInput struct {
	Main, Root string
	Mode       string // watch: report or finish
	Jan        finish.JanitorInput
	Agents     agentctl.Backend // nil when this process cannot reach one
	StateDir   string
	TTL        time.Duration
	Now        func() time.Time
	// Finish finishes a merged task under its lease; nil in report mode
	Finish func(context.Context, WatchedTask) error
	Out    reporter
	// Record puts a report in the ledger once it is told; nil records none
	Record func(watchReport)
	Warn   func(string) // a line for the pass's output that is no report; nil drops it
	// Catchup is watch_catchup: on; prompt is nil with no backend to reach
	// an agent
	Catchup bool
	Prompt  func(ctx context.Context, task WatchedTask, text string) error
	// Engine integrates a catchup; storage names the task's review series
	// for a catchup merge's trailers
	Engine  *stack.CatchupEngine
	Storage storage.Root
	// CI is watch_ci: on, which sends a red head to its agent; Checks reads
	// a request's head checks, nil with no host to ask
	CI     bool
	Checks func(context.Context, forge.PR) (forge.HeadChecks, error)
}

WatchInput is everything a pass needs, so it runs in a test without a daemon, Herdr or a host.

type WatchedTask

type WatchedTask struct {
	ID       string // the lead
	Branch   string
	Path     string
	Owner    string     // who holds its lease; "" for nobody
	Off      bool       // f10 watch off
	Pr       *forge.PR  // nil with no request, or no host
	HostErr  error      // the host did not answer for its request this pass
	LocalSHA string     // the branch's tip
	Run      *state.Run // the newest run reported from its worktree
	// Background is when run's session launched background work still
	// pending, the zero time for none
	Background time.Time
	Agent      agentctl.Status // "" with no workspace, or no listing
	Listed     bool            // the workspaces were listed, so "" is no workspace
	Ws         string          // its workspace, for a message
	// contains filtered or unexported fields
}

A WatchedTask is what one pass knows about a task with a worktree.

Jump to

Keyboard shortcuts

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