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
- Variables
- func BatchOf(ctx context.Context, t *target.Target, token string) (drivestore.Live, bool)
- func CloseDriveAsks(ctx context.Context, w io.Writer, dir, root string, n int, now time.Time)
- func CommandID(root string, rec *drivestore.Record) string
- 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 LogBatch(ctx context.Context, t *target.Target, token string) (int, 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 RecordOf(ctx context.Context, t *target.Target, token string) (*drivestore.Record, bool)
- func Resumable(ctx context.Context, t *target.Target, token string) (*drivestore.Record, error)
- func ResumeUsage() string
- func RowFinishedFor(ctx context.Context, t *target.Target) func(string) bool
- func StopBatch(ctx context.Context, t *target.Target, token string) (int, error)
- 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 TuneAttach(w io.Writer, root string, argv []string, a drivectl.DriveArgs) int
- 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 IDList
- type LineReporter
- type NoBatchError
- type NotResumableError
- type PlanInput
- type PlanResult
- type SeveralStoppedError
- 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 ¶
var ErrNoneStopped = errors.New("no stopped batch in this project: f10 status --batches lists every batch")
ErrNoneStopped is a bare resume in a project with no stopped batch.
Functions ¶
func CloseDriveAsks ¶
CloseDriveAsks closes drive n's open asks: a cancelled drive leaves nothing waiting in the inbox.
func CommandID ¶ added in v0.71.0
func CommandID(root string, rec *drivestore.Record) string
CommandID is the task id that names rec to stop, resume and daemon logs: its first task that resolves back to it, else its lead. Every hint prints it, so a hint never names a task a newer batch has taken. It reads every record, so it is called where a line is printed, never in the poll loop.
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 LogBatch ¶ added in v0.71.0
LogBatch is the number of the newest batch whose record holds the task, live or not. A finished batch still has a log, and an older live batch is not the one the task last ran in.
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 RecordOf ¶ added in v0.71.0
RecordOf is the newest record holding the task a token names, whatever its standing: a finished batch still has a log, and a stopped one a reason.
func Resumable ¶ added in v0.71.0
Resumable is the batch a resume names: the live one holding the task, or with no token the project's one stopped batch.
func ResumeUsage ¶ added in v0.64.0
func ResumeUsage() string
ResumeUsage is the flags a resume takes.
func RowFinishedFor ¶
RowFinishedFor checks a record's row, an id as typed, by FinishedTask. Drive, status and the board share that rule, so a stated open issue is never finished. A row that names no task, or a git error, reads as unfinished, because a wrong yes hides a halt.
func StopBatch ¶ added in v0.71.0
StopBatch is the number of the batch f10 stop ends for a task: the running one holding its lease, else the newest live one whose record holds it. The lease is asked first, because a batch the daemon has just taken runs before its record is readable.
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 TuneAttach ¶ added in v0.71.0
TuneAttach writes a given --parallel into the record, because a running batch the daemon attaches to never reads the line, only its record. It returns the record to attach by, none when answers need a process of their own.
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 a halt over an ask: a follower waits through an ask for the drive to resume, so only a halt tells it that someone must act.
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
// Join is a join's listed bases. A base outside the list is finished.
Join []*DriveRun
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 is the one base the drive waits for, "" for none or for a join.
Base string
// Join is a join's bases as ids, two or more. Each must merge before
// the join branches from the default branch, and Base is then empty.
Join []string
// contains filtered or unexported fields
}
A DriveTask is one task of the list, as the validation pass found it.
type IDList ¶ added in v0.71.0
type IDList []string
IDList is a list of task ids that also reads a single id, since a model writing the sheet gives "FT-44" as readily as ["FT-44"].
func (*IDList) UnmarshalJSON ¶ added in v0.71.0
type LineReporter ¶
func (LineReporter) Report ¶
func (l LineReporter) Report(r watchReport)
type NoBatchError ¶ added in v0.71.0
type NoBatchError struct{ Token string }
A NoBatchError is a task id no batch answers to, for the command asking.
func (NoBatchError) Error ¶ added in v0.71.0
func (e NoBatchError) Error() string
type NotResumableError ¶ added in v0.71.0
type NotResumableError struct {
Token string
Ended *drivestore.Record
}
A NotResumableError is a task no live batch holds. Ended is set when f10 stop ended the newest batch holding it, which no resume picks up.
func (NotResumableError) Error ¶ added in v0.71.0
func (e NotResumableError) Error() string
type PlanInput ¶ added in v0.61.0
type PlanInput struct {
Storage storage.Root
Tracker stack.Tracker
FlowByArea map[string]string
MaxLines int
DefaultParallel int
Joins bool // the run's flow finishes, so an entry may wait on several bases
Main string // the main checkout, where a task's branch is looked up
}
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
}
PlanResult is a proposal.
type SeveralStoppedError ¶ added in v0.71.0
type SeveralStoppedError struct{ Stopped []drivestore.Live }
A SeveralStoppedError is a bare resume that cannot pick: each batch is named by its lead, which resumes it.
func (SeveralStoppedError) Error ¶ added in v0.71.0
func (e SeveralStoppedError) Error() string
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 IDList `json:"buildsOn,omitempty"`
Risky string `json:"risky,omitempty"`
Alone bool `json:"alone,omitempty"`
With string `json:"with,omitempty"`
After IDList `json:"after,omitempty"`
}
A SheetTask is one task's row in the facts sheet the propose step writes. It holds 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
¶
- batch.go
- 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