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
- func CloseDriveAsks(dir, root string, n int, now time.Time)
- func DefaultParallel() int
- func Drive(ctx context.Context, w io.Writer, in *DriveInput) (err error)
- func DriveCancel(w io.Writer, root string, n int, now time.Time) error
- func DriveFinishInput(t *target.Target, main string, h hostops.Host, req DriveFinish) (finish.FinishInput, error)
- func DriveList(ctx context.Context, w io.Writer, links *render.TaskLinks, ...) error
- func DriveSkills(fl runplan.ShipFlow) []string
- func DriveUsage() string
- func LedgerReports(ctx context.Context, main string) func(watchReport)
- func LoadWatchStore(root string) (map[string]watchReport, error)
- func NewAnswerBook() answerBook
- func OnOff(on bool) string
- func RecordAt(ctx context.Context, dir string, e ledger.Event)
- func RecordKey(argv []string) string
- func ResumeUsage() string
- func RowFinishedFor(ctx context.Context, t *target.Target) func(string) bool
- func TailLog(ctx context.Context, w io.Writer, path string) (daemon.Exit, error)
- func ThroughDaemon(ctx context.Context, w io.Writer, t *target.Target, argv []string, ...) error
- func VerifySpecOf(eff *facts.Effective) (stack.VerifySpec, string)
- func WatchDrain(fore bool) (<-chan os.Signal, func())
- func WatchPass(ctx context.Context, in WatchInput) (bool, error)
- func WatcherFinish(ctx context.Context, w io.Writer, t *target.Target, main, root string, ...) error
- func WriteDaemonStatus(ctx context.Context, w io.Writer, links *render.TaskLinks, rep daemon.Status)
- type DriveFinish
- type DriveInput
- func (in *DriveInput) KeepFlow(ctx context.Context, branch string) (runplan.ShipFlow, string, error)
- func (in *DriveInput) LoadLinks(ctx context.Context, tasks []DriveTask)
- func (in *DriveInput) Queue(r *DriveRun)
- func (in *DriveInput) Report(runs []*DriveRun, notes []string) error
- func (in *DriveInput) Skills(r *DriveRun) []string
- func (in *DriveInput) Wake(ctx context.Context, d time.Duration) error
- type DriveRun
- type DriveTask
- type LineReporter
- type PlanInput
- type PlanResult
- type SheetTask
- type WatchInput
- type WatchedTask
Constants ¶
const (
AtHeld runPhase // not opened: the cap holds it
)
const DrivesShown = 20
DrivesShown is how many records status --drives lists without --all, newest first.
Variables ¶
This section is empty.
Functions ¶
func CloseDriveAsks ¶
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 ¶
Drive runs the flow; nothing is created or prompted before the graph passed validation.
func DriveCancel ¶
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 ¶
DriveSkills reads the skills off the flow: plan when the flow leads with it, ship, then finish when the flow ends in it and the pace runs it.
func DriveUsage ¶
func DriveUsage() string
DriveUsage is start's flags for a flow start, read off DriveFlags.
func LedgerReports ¶ added in v0.62.0
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 NewAnswerBook ¶
func NewAnswerBook() answerBook
func RecordKey ¶ added in v0.62.0
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 ResumeUsage ¶ added in v0.64.0
func ResumeUsage() string
ResumeUsage is the flags --resume N takes.
func RowFinishedFor ¶
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 ¶
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, follow bool, ) error
ThroughDaemon runs the drive in the daemon. With follow it prints the drive's progress until the drive ends, and Ctrl+C stops only the following. Without follow it returns once the daemon has the drive. A start inside a discussion's worktree needs that, because the drive prompts that same agent, which must end this turn first.
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 ¶
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.
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 (*DriveInput) LoadLinks ¶
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 whose flow does not finish gets finish once it closes.
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 flow's finish entry, 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 ¶
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
}
PlanResult is a proposal.
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.
Source Files
¶
- daemon.go
- drain_unix.go
- drive.go
- driveanswers.go
- driveasks.go
- drivecap.go
- drivecatchup.go
- drivefinish.go
- driveflags.go
- drivegraph.go
- drivehalts.go
- driveopen.go
- driveplan.go
- drivepoll.go
- driverecord.go
- drivereport.go
- driveresolve.go
- driverun.go
- drivesend.go
- drivestanding.go
- drivestate.go
- drivetick.go
- drivetriage.go
- driveverify.go
- drivewait.go
- driveworkspace.go
- watch.go
- watchci.go
- watchledger.go