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 DriveTitle(r daemon.Run) string
- func DriveUsage() string
- func FinishedLazily(root storage.Root, id string, branched func() (bool, error), ...) bool
- func FollowDrive(ctx context.Context, w io.Writer, dir, ver string, req daemon.Request, ...) error
- func Halt(id, skill, reason string) error
- func HaltPayload(res DriveResult) ledger.Payload
- func HeldStop(run *state.Run) bool
- func ListIndex(tasks []DriveTask) map[string]int
- func LoadWatchStore(root string) (map[string]WatchReport, error)
- func NewAnswerBook() answerBook
- func OnOff(on bool) string
- func OriginWait(run *state.Run) bool
- func RecheckFinish(ctx context.Context, b agentctl.Backend, main string, task WatchedTask) error
- func RecordArgs(argv []string) []string
- func RecordAt(ctx context.Context, dir string, e ledger.Event)
- func ResumeAt(skill string, run *state.Run) string
- func ResumeCommand(argv []string) string
- func ResumeShown(run *state.Run, at string) string
- func RowFinishedFor(ctx context.Context, t *target.Target) func(string) bool
- func SaveWatchStore(root string, store map[string]WatchReport) error
- func SkillPrompt(skill, id string, dep *launch.Dependency, fl runplan.ShipFlow, finishing bool) string
- func Stalled(status agentctl.Status, run *state.Run, skill string, since time.Time, ...) bool
- func StartVerifyJob(ctx context.Context, run func(context.Context) (stack.VerifyRun, error)) *verifyJob
- func Steered(prompt, steering string) string
- func Stopping(runs []*DriveRun) bool
- func TailLog(ctx context.Context, w io.Writer, path string) (daemon.Exit, error)
- func TaskStanding(t drives.Task, running bool) string
- func ThroughDaemon(ctx context.Context, w io.Writer, t *target.Target, argv []string, ...) error
- func TopoOrder(tasks []DriveTask, index map[string]int) ([]int, error)
- func VerifySpecOf(eff *facts.Effective) (stack.VerifySpec, string)
- func WaitingOnAsk(run *state.Run) bool
- func WatchDrain(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 WatcherFinishInput(t *target.Target, main string, h hostops.Host, r ref.Ref, branch string) finish.FinishInput
- func WriteDaemonStatus(ctx context.Context, w io.Writer, links *render.TaskLinks, rep daemon.Reply)
- type Answer
- type DriveFinish
- type DriveInput
- func (in *DriveInput) AttemptAt(r *DriveRun, action, fp string, halt DriveResult) error
- func (in *DriveInput) BaseReady(ctx context.Context, r *DriveRun) bool
- func (in *DriveInput) Busy(except *DriveRun) int
- func (in *DriveInput) CatchupBase(ctx context.Context, r *DriveRun) (stack.CatchupPlan, error)
- func (in *DriveInput) CatchupLeft(ctx context.Context, r *DriveRun) (stack.TreeState, error)
- func (in *DriveInput) End(ctx context.Context, r *DriveRun, res DriveResult)
- func (in *DriveInput) Enter(r *DriveRun, p runPhase)
- func (in *DriveInput) Graph(ctx context.Context, tasks []DriveTask) ([]int, []string, error)
- func (in *DriveInput) KeepCatchup(r *DriveRun)
- func (in *DriveInput) KeepFlow(ctx context.Context, branch string) (runplan.ShipFlow, string, error)
- func (in *DriveInput) KeepPace(ctx context.Context, branch string, fl runplan.ShipFlow) (runplan.ShipFlow, string, error)
- func (in *DriveInput) LeaveRuns(ctx context.Context, runs []*DriveRun)
- func (in *DriveInput) LoadLinks(ctx context.Context, tasks []DriveTask)
- func (in *DriveInput) Look(ctx context.Context, r *DriveRun) (*agentctl.Workspace, *state.Run, error)
- func (in *DriveInput) MarkBehind(ctx context.Context, r *DriveRun) error
- func (in *DriveInput) MarkMoved(ctx context.Context, runs []*DriveRun, wss []agentctl.Workspace) error
- func (in *DriveInput) Next(ctx context.Context, r *DriveRun) error
- func (in *DriveInput) OnTask(ctx context.Context, r *DriveRun, err error) error
- func (in *DriveInput) OpenRecord(tasks []DriveTask) error
- func (in *DriveInput) ParkForOrigin(ctx context.Context, r *DriveRun) error
- func (in *DriveInput) Position(ctx context.Context, o start.OpenedTask, skills []string) (int, error)
- func (in *DriveInput) Queue(r *DriveRun)
- func (in *DriveInput) RecordLaunch() error
- func (in *DriveInput) ReleaseAll()
- func (in *DriveInput) Released(ctx context.Context, b *DriveRun) bool
- func (in *DriveInput) Report(runs []*DriveRun, notes []string) error
- func (in *DriveInput) ResolveTasks(ctx context.Context) ([]DriveTask, []string, error)
- func (in *DriveInput) RetryEnter(ctx context.Context, r *DriveRun)
- func (in *DriveInput) RetryPull(ctx context.Context)
- func (in *DriveInput) RunFinish(ctx context.Context, r *DriveRun) DriveResult
- func (in *DriveInput) SavedCatchup(t DriveTask) *drives.Catchup
- func (in *DriveInput) SequenceOf(fl runplan.ShipFlow) []string
- func (in *DriveInput) Skills(r *DriveRun) []string
- func (in *DriveInput) SlotFree(r *DriveRun) bool
- func (in *DriveInput) Span(ctx context.Context) (ref.Ref, ref.Ref, error)
- func (in *DriveInput) SpikeDone(ctx context.Context, r *DriveRun) (bool, error)
- func (in *DriveInput) TakeAnswers(tasks []DriveTask) error
- func (in *DriveInput) Unqueue(r *DriveRun)
- func (in *DriveInput) View() *TickView
- func (in *DriveInput) Wake(ctx context.Context, d time.Duration) error
- type DriveResult
- type DriveRun
- type DriveTask
- type LineReporter
- type OpenGate
- type Reporter
- type TaskState
- type TickView
- type WatchInput
- func (in WatchInput) HostTrouble(tasks []WatchedTask, store map[string]WatchReport)
- func (in WatchInput) ReadTargets(ctx context.Context, tasks []WatchedTask, store map[string]WatchReport)
- func (in WatchInput) Reconcile(ctx context.Context, tasks []WatchedTask, store map[string]WatchReport)
- func (in WatchInput) RetryPull(ctx context.Context, store map[string]WatchReport) bool
- func (in WatchInput) Tell(store map[string]WatchReport, id string, now time.Time, rep *WatchReport)
- type WatchReport
- type WatchedTask
Constants ¶
const ( // StartWindow is how long a prompted agent has to show it took the // prompt: Herdr reporting it working, or its run reporting. StartWindow = 2 * time.Minute // StallGrace absorbs the Stop hook, which promotes a finished phase // asynchronously after the agent already reads idle. A long verify left // in the background does not count against it (backgroundPending). StallGrace = time.Minute )
const ( // FromInbox is an inbox answer the agent never heard: the drive sends it FromInbox answerSource // HeardInbox is an inbox answer given where the agent heard it: the // drive follows that turn instead of sending anything HeardInbox )
const ( FinishMerge = "merge" FinishLeaveOpen = "local" )
The answers drive's own finish question takes, for a PR someone else opened: merge it, or clean up locally and leave it open.
const ( AtHeld runPhase // not opened: the cap holds it AtRunning // a skill in flight, or about to be sent AtParked // a skill waits for its base's code, or its branch on origin AtWaiting // finish waits for its base to be through )
const ( WatchMerged = "merged" // its request merged on the host WatchClosed = "closed" // its request closed without a merge WatchStalled = "stalled" // its agent idle while its run says running WatchStopped = "stopped" // its run stopped: done, blocked, failed or partial WatchFinished = "finished" // the watcher finished it WatchRefused = "refused" // the watcher's finish was refused // WatchUnpulled is a pull of the default branch a finish deferred, which the watcher retries WatchUnpulled = "unpulled" // WatchCatchup is a catchup the watcher sent, pushed, or did not end clean WatchCatchup = "catchup" // WatchBehind is a branch behind its target, and the watcher cannot catch it up WatchBehind = "behind" )
What a pass reports about a task.
const FinishClause = "drive finishes it after ship and removes this worktree"
FinishClause tells a driven ship that drive finishes the task after it.
const WatchFile = "watch.yaml"
WatchFile records what each pass last reported, so a fact is told once.
const WatchHostKey = "host"
WatchHostKey is the store's entry for the host not answering, about the project, not one task.
const WatchPullKey = "pull"
WatchPullKey is the store's entry for a deferred pull, about the project, not one task.
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 pace finishes.
func DriveTitle ¶
func FinishedLazily ¶
func FinishedLazily(root storage.Root, id string, branched func() (bool, error), info func() hostops.TaskInfo) bool
FinishedLazily is FinishedTask with its reads made lazily: the tracker is asked only when no branch, live plan or archived plan already decides.
func FollowDrive ¶
func FollowDrive( ctx context.Context, w io.Writer, dir, ver string, req daemon.Request, spawn func(context.Context) error, ) error
FollowDrive follows the drive until it exits, into the next daemon when an upgrade drained it. spawn starts a daemon; nil is this binary's.
func HaltPayload ¶
func HaltPayload(res DriveResult) ledger.Payload
HaltPayload is a halt's ledger payload: the attempts it counted, if any.
func HeldStop ¶
HeldStop is a ship stop a catchup leaves in place: the guard's, or a ship parked on its base, which resumes once the catchup ends clean.
func ListIndex ¶
ListIndex maps each listed id to its first position; every member of a bundle maps to the bundle's, so a base that rides in it waits for it.
func LoadWatchStore ¶
func LoadWatchStore(root string) (map[string]WatchReport, error)
func NewAnswerBook ¶
func NewAnswerBook() answerBook
func OriginWait ¶
OriginWait is a ship stopped before pr on a base origin lacks: a wait whose leaf is a pr entry, where the implement guard's wait is on the base's code.
func RecheckFinish ¶
RecheckFinish reads again, under the lease, what the pass read before it: an agent that started working, or a commit the PR lacks, keeps the task.
func RecordArgs ¶
RecordArgs is the command line a record is matched on: the flags that only tune a drive dropped, since none of them names another drive.
func ResumeAt ¶
ResumeAt is the steering that resumes a ship the catchup guard stopped, or one parked on its base, naming its place when the flow names the entry twice; a failed catchup keeps the place of the entry it guarded, which is where ship resumes.
func ResumeCommand ¶
func ResumeShown ¶
ResumeShown is ResumeAt's steering as a person reads it: the resumed entry by its label, when the flow gives it one.
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 SaveWatchStore ¶
func SaveWatchStore(root string, store map[string]WatchReport) error
func SkillPrompt ¶
func SkillPrompt(skill, id string, dep *launch.Dependency, fl runplan.ShipFlow, finishing bool) string
SkillPrompt: plan is bare and ship names only a non-default flow, since driven mode takes every gap on its default and reuses a saved plan; every skill but plan and ship takes a bundle's lead, which finds the branch.
func Stalled ¶
func Stalled( status agentctl.Status, run *state.Run, skill string, since time.Time, idle, grace time.Duration, bg, now time.Time, ) bool
Stalled is an agent idle for grace with its turn's end unreported, once the Stop hook had time; drive and the watcher read a stall the same way. Background work launched at bg keeps it working: Herdr shows an agent idle while it waits on one.
func StartVerifyJob ¶
func Steered ¶
Steered puts steering after the skill's subject, before any chained clause and the driven marker, so the skill reads it as its own.
func Stopping ¶
Stopping reports whether the drive ends: no task is active, or one asks and every active task is held on a base. An ask does not stop the rest, so a guard stop elsewhere still gets its catchup while the ask waits.
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 TopoOrder ¶
TopoOrder puts bases before dependents; among the ready, the one listed first goes first, so a list already in order runs in that order.
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 WaitingOnAsk ¶
WaitingOnAsk: the next prompt such an idle agent gets should be the answer, not a catchup.
func WatchDrain ¶
WatchDrain catches nothing here: there is no daemon to drain a drive.
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 Answer ¶
type Answer struct {
Task string // "" for bare
Text string
From answerSource
At time.Time // when an inbox answer was given
}
An Answer is one the drive holds until a task stopped on a question takes it: keyed to a task, or bare for the first such task.
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) AttemptAt ¶
func (in *DriveInput) AttemptAt(r *DriveRun, action, fp string, halt DriveResult) error
AttemptAt is attempt with the state to compare given: a catchup's is the conflict it left, since a catchup that merges moves the head without progress, and the reason it gives changes wording between catchups.
func (*DriveInput) BaseReady ¶
func (in *DriveInput) BaseReady(ctx context.Context, r *DriveRun) bool
BaseReady reports the base's code there for a skill: released, and for a ship that parked itself, moved past the head it found empty. A ship parked before pr needs the base's branch on origin instead, or the base done.
func (*DriveInput) Busy ¶
func (in *DriveInput) Busy(except *DriveRun) int
Busy counts the runs holding a slot, except.
func (*DriveInput) CatchupBase ¶
func (in *DriveInput) CatchupBase(ctx context.Context, r *DriveRun) (stack.CatchupPlan, error)
CatchupBase is the base the catchup brought in: the one this drive integrated, else, for a drive that did not (resumed), the one the marks name, read as f10 pr catchup reads it without a fetch. Re-reading after a turn would move it to the base branch's newer tip once a mark is cleared.
func (*DriveInput) CatchupLeft ¶
CatchupLeft is the engine's read of what keeps the branch from being caught up with the base this catchup brought in.
func (*DriveInput) End ¶
func (in *DriveInput) End(ctx context.Context, r *DriveRun, res DriveResult)
End prints the result now, so a halt or an ask is on screen when it happens, and puts a halt in the ledger for status to read after the exit.
func (*DriveInput) Enter ¶
func (in *DriveInput) Enter(r *DriveRun, p runPhase)
Enter moves r to phase p and writes its standing to the record.
func (*DriveInput) Graph ¶
Graph refuses a base outside the list that is not finished, and a cycle, before anything is created.
func (*DriveInput) KeepCatchup ¶
func (in *DriveInput) KeepCatchup(r *DriveRun)
KeepCatchup writes the task's catchup record to the drive record.
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) KeepPace ¶
func (in *DriveInput) KeepPace( ctx context.Context, branch string, fl runplan.ShipFlow, ) (runplan.ShipFlow, string, error)
KeepPace: a run's --pace wins and is recorded on the branch, since a rerun that slows down must be able to take finish off; with none typed, the branch's record wins over the project's default.
func (*DriveInput) LeaveRuns ¶
func (in *DriveInput) LeaveRuns(ctx context.Context, runs []*DriveRun)
LeaveRuns runs on every way out of the loop, drained and failed included: an interrupted drive leaves no finish record claiming it still runs, and no catchup verify running in its own process group.
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) Look ¶
func (in *DriveInput) Look(ctx context.Context, r *DriveRun) (*agentctl.Workspace, *state.Run, error)
Look reads the workspace by the id open settled on, since a checkout can show in more than one; one gone mid-run took the agent with it.
func (*DriveInput) MarkBehind ¶
func (in *DriveInput) MarkBehind(ctx context.Context, r *DriveRun) error
MarkBehind marks a pushed branch whose pull request's target moved past it, at the boundary before its next skill, so the open PR never sits behind; a listed base still in flight is MarkMoved's, and finish has readyToMerge.
func (*DriveInput) MarkMoved ¶
func (in *DriveInput) MarkMoved(ctx context.Context, runs []*DriveRun, wss []agentctl.Workspace) error
MarkMoved marks a running dependent whose base branch moved past it, read while the base agent is not mid-turn, so its next boundary catches up; a catchup in flight clears the mark itself, and a finished base is landed's.
func (*DriveInput) Next ¶
func (in *DriveInput) Next(ctx context.Context, r *DriveRun) error
Next sends the task its next element. A branch marked landed or moved is caught up before any skill, finish included; finish waits for the base, and a branch that conflicts is marked landed and caught up first.
func (*DriveInput) OpenRecord ¶
func (in *DriveInput) OpenRecord(tasks []DriveTask) error
OpenRecord folds the record's kept answers under the ones given now; a root of "" keeps no record.
func (*DriveInput) ParkForOrigin ¶
func (in *DriveInput) ParkForOrigin(ctx context.Context, r *DriveRun) error
ParkForOrigin holds a ship that stopped before pr on a base origin lacks until the base is pushed or done. A base already there gets ship sent at once; the same origin sha stopping it twice ends it, so the two never loop.
func (*DriveInput) Position ¶
func (in *DriveInput) Position(ctx context.Context, o start.OpenedTask, skills []string) (int, error)
Position: a skill drive recorded on the branch wins; else a plan the worktree reads counts as plan done, so driven ship takes it rather than planning again.
func (*DriveInput) Queue ¶
func (in *DriveInput) Queue(r *DriveRun)
func (*DriveInput) RecordLaunch ¶
func (in *DriveInput) RecordLaunch() error
RecordLaunch: a --resume (a drained drive, a drive resuming itself) and an --answer relayed from another session are nobody's launch.
func (*DriveInput) ReleaseAll ¶
func (in *DriveInput) ReleaseAll()
ReleaseAll drops every lease the drive still holds, its own last.
func (*DriveInput) Released ¶
func (in *DriveInput) Released(ctx context.Context, b *DriveRun) bool
Released: a base lets its dependents start once through, or once it has code of its own, which only a commit or pr step makes with verify green.
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) ResolveTasks ¶
ResolveTasks skips a range member the tracker does not know as a task, with a note; a listed one is an error.
func (*DriveInput) RetryEnter ¶
func (in *DriveInput) RetryEnter(ctx context.Context, r *DriveRun)
RetryEnter checks, once and EnterRetry after a typed send, that the text left the agent's input box, pressing Enter again if it did not. A failed check is printed, and the start window still decides.
func (*DriveInput) RetryPull ¶
func (in *DriveInput) RetryPull(ctx context.Context)
RetryPull retries a pull a finish deferred, once a tick, in a drive that ran a finish, since pulling is an act; a line already printed is not printed again, so a diverged main is said once.
func (*DriveInput) RunFinish ¶
func (in *DriveInput) RunFinish(ctx context.Context, r *DriveRun) DriveResult
RunFinish runs finish in process; its refusals halt the task, except a PR someone else opened, which asks.
func (*DriveInput) SavedCatchup ¶
func (in *DriveInput) SavedCatchup(t DriveTask) *drives.Catchup
SavedCatchup is the catchup record an earlier run of this drive kept for t, so a resumed drive leases its push as the first one would have.
func (*DriveInput) SequenceOf ¶
func (in *DriveInput) SequenceOf(fl runplan.ShipFlow) []string
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) SlotFree ¶
func (in *DriveInput) SlotFree(r *DriveRun) bool
SlotFree reports whether r may send a skill under the cap. A turn already running in its workspace takes a slot past the cap: the drive cannot stop it.
func (*DriveInput) SpikeDone ¶
SpikeDone: a spike report on a branch never pushed closes without a merge; a pushed one finishes through its PR.
func (*DriveInput) TakeAnswers ¶
func (in *DriveInput) TakeAnswers(tasks []DriveTask) error
func (*DriveInput) Unqueue ¶
func (in *DriveInput) Unqueue(r *DriveRun)
Unqueue releases r from the cap: an opened task runs its next skill, one not opened yet is pending until open.
func (*DriveInput) View ¶
func (in *DriveInput) View() *TickView
View is this tick's look, or before the first tick an empty one that still keeps the fetch.
type DriveResult ¶
type DriveResult struct {
Row string
Code int
Lines []string
// Skill and reason name a halt, for the ledger
Skill string
Reason string
// Drives is an end this drive gave the task, owned elsewhere or
// cancelled, which says nothing about the task itself
Drives bool
// Attempts are the failures a halt on the attempt rule counted
Attempts []attempt
// contains filtered or unexported fields
}
A DriveResult is how one task ended: its row in the report, and when it stopped, the exit code and the lines beneath the report.
func Halted ¶
func Halted(id, skill, reason string) DriveResult
func PushHalted ¶
func PushHalted(id, skill string, err error) DriveResult
PushHalted halts on a failed push, saying how to bring in what origin gained when that is the cause.
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 ¶
func (LineReporter) Report ¶
func (l LineReporter) Report(r WatchReport)
type OpenGate ¶
type OpenGate struct {
On bool
Limit int
Wss []agentctl.Workspace
Trees map[string]string // a task's branch to its checkout, for a task not opened yet
Open int // active and asking tasks with a workspace, this pass's opens included
// contains filtered or unexported fields
}
An OpenGate decides, for one startRunnable pass, which released tasks open under the cap. The zero gate admits every task.
func (*OpenGate) Admit ¶
func (g *OpenGate) Admit(in *DriveInput, r *DriveRun) bool
Admit reports whether r opens now, counting it if so. A task whose agent is mid-turn always opens, since the drive cannot stop that turn.
type Reporter ¶
type Reporter interface {
Report(WatchReport)
}
A Reporter is where a pass tells what it found; the daemon keeps the pass's output as the project's watch log.
type TaskState ¶
type TaskState struct {
Head, Origin string
Code bool // the branch has commits of its own past the default branch
Pr string // the open PR's number, "" for none or no host to ask
Reviews int // review rounds written for the change
ChangeJudged bool
Run *state.Run
// contains filtered or unexported fields
}
A TaskState is where a task stands by git, its PR and its files, read only where the drive reconciles a turn, never on every poll, since the PR read is a host call.
func (TaskState) Fingerprint ¶
Fingerprint is the state an attempt compares: the agent's status and every timestamp stay out, since they change on each turn that makes no progress.
func (TaskState) Has ¶
Has reports the evidence that a skill is done. finish is the drive's own step, never read from the branch, and any other skill only from its run's phase.
func (TaskState) Shipped ¶
Shipped reads the shipment ship leaves from the branch: its last delivering entry's output, and an artifact from every review and change judge on the way, so a ship stopped between its first pr and its last is not shipped. With no pipeline recorded, an open PR carrying the branch stands for it.
type TickView ¶
type TickView struct {
Wss []agentctl.Workspace // nil before the first tick's look
// contains filtered or unexported fields
}
A TickView is what one tick reads once for every task in flight: the workspaces, the live runs, and one fetch of origin.
func (*TickView) JustOpened ¶
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
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
}
WatchInput is everything a pass needs, so it runs in a test without a daemon, Herdr or a host.
func (WatchInput) HostTrouble ¶
func (in WatchInput) HostTrouble(tasks []WatchedTask, store map[string]WatchReport)
HostTrouble is told every pass, naming the tasks left out, since those tasks go silent; f10 watch shows it until the host answers again.
func (WatchInput) ReadTargets ¶
func (in WatchInput) ReadTargets(ctx context.Context, tasks []WatchedTask, store map[string]WatchReport)
ReadTargets fetches origin once, for every task that could be caught up or has a catchup to settle. A failed fetch reads nothing: a stale origin could hide a move, and a push lease needs the current sha.
func (WatchInput) Reconcile ¶
func (in WatchInput) Reconcile(ctx context.Context, tasks []WatchedTask, store map[string]WatchReport)
Reconcile forgets tasks gone from the project, except a finish, kept a day for f10 watch.
func (WatchInput) RetryPull ¶
func (in WatchInput) RetryPull(ctx context.Context, store map[string]WatchReport) bool
RetryPull retries a pull a finish deferred, under watch: finish alone, since pulling is an act. A cause already told is not told again.
func (WatchInput) Tell ¶
func (in WatchInput) Tell(store map[string]WatchReport, id string, now time.Time, rep *WatchReport)
Tell carries the stored report's told keys and catchup record over.
type WatchReport ¶
type WatchReport struct {
Task string `yaml:"-"`
Kind string `yaml:"kind"`
Text string `yaml:"text"`
Next string `yaml:"next,omitempty"`
Ask string `yaml:"ask,omitempty"` // a stopped run's question, options included
// Key is the fact the report was made on; Told, kept on the stored
// report, every key told for the task, so an old fact coming back after
// another (a host that did not answer for a pass) is not told again
Key string `yaml:"key"`
Told []string `yaml:"told,omitempty"`
At time.Time `yaml:"at"`
// Catchup is the catchup the watcher sent and has not settled, kept on
// the stored report like Told
Catchup *drives.Catchup `yaml:"catchup,omitempty"`
}
func DecideWatch ¶
func DecideWatch(t WatchedTask, mode string, now time.Time) (*WatchReport, bool)
DecideWatch answers the request first, then a stalled agent, then a stopped run.
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.
func CollectWatched ¶
func CollectWatched(ctx context.Context, in WatchInput) ([]WatchedTask, int, error)
Source Files
¶
- daemon.go
- drain_other.go
- drive.go
- driveanswers.go
- driveasks.go
- drivecap.go
- drivecatchup.go
- drivefinish.go
- driveflags.go
- drivegraph.go
- drivehalts.go
- driveopen.go
- drivepoll.go
- driverecord.go
- drivereport.go
- driveresolve.go
- driverun.go
- drivesend.go
- drivestanding.go
- drivestate.go
- drivetick.go
- driveverify.go
- drivewait.go
- driveworkspace.go
- watch.go