drive

package
v0.59.0 Latest Latest
Warning

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

Go to latest
Published: Nov 11, 2026 License: MIT Imports: 53 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 (

	// 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
)
View Source
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
)
View Source
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.

View Source
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
)
View Source
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.

View Source
const FinishClause = "drive finishes it after ship and removes this worktree"

FinishClause tells a driven ship that drive finishes the task after it.

View Source
const WatchFile = "watch.yaml"

WatchFile records what each pass last reported, so a fact is told once.

View Source
const WatchHostKey = "host"

WatchHostKey is the store's entry for the host not answering, about the project, not one task.

View Source
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

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 DriveTitle

func DriveTitle(r daemon.Run) string

func DriveUsage

func DriveUsage() string

DriveUsage is drive's ArgsUsage, read off DriveFlags.

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 Halt

func Halt(id, skill, reason string) error

Halt ends the task halted at skill for reason.

func HaltPayload

func HaltPayload(res DriveResult) ledger.Payload

HaltPayload is a halt's ledger payload: the attempts it counted, if any.

func HeldStop

func HeldStop(run *state.Run) bool

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

func ListIndex(tasks []DriveTask) map[string]int

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 OnOff

func OnOff(on bool) string

func OriginWait

func OriginWait(run *state.Run) bool

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

func RecheckFinish(ctx context.Context, b agentctl.Backend, main string, task WatchedTask) error

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

func RecordArgs(argv []string) []string

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 RecordAt

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

func ResumeAt

func ResumeAt(skill string, run *state.Run) string

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 ResumeCommand(argv []string) string

func ResumeShown

func ResumeShown(run *state.Run, at string) string

ResumeShown is ResumeAt's steering as a person reads it: the resumed entry by its label, when the flow gives it one.

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 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 StartVerifyJob(ctx context.Context, run func(context.Context) (stack.VerifyRun, error)) *verifyJob

func Steered

func Steered(prompt, steering string) string

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

func Stopping(runs []*DriveRun) bool

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

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 TaskStanding

func TaskStanding(t drives.Task, running bool) string

func ThroughDaemon

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

func TopoOrder

func TopoOrder(tasks []DriveTask, index map[string]int) ([]int, error)

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

func WaitingOnAsk(run *state.Run) bool

WaitingOnAsk: the next prompt such an idle agent gets should be the answer, not a catchup.

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 WatcherFinishInput

func WatcherFinishInput(t *target.Target, main string, h hostops.Host, r ref.Ref, branch string) finish.FinishInput

WatcherFinishInput is the finish the watcher runs: merged requests only, and a bundle's riders closed as the PR body says, since no one is asked.

func WriteDaemonStatus

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

WriteDaemonStatus prints what the daemon runs and watches.

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

func (in *DriveInput) CatchupLeft(ctx context.Context, r *DriveRun) (stack.TreeState, error)

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

func (in *DriveInput) Graph(ctx context.Context, tasks []DriveTask) ([]int, []string, error)

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 (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

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) OnTask

func (in *DriveInput) OnTask(ctx context.Context, r *DriveRun, err error) error

OnTask applies an end r's path returned; any other error goes on up.

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

func (in *DriveInput) ResolveTasks(ctx context.Context) ([]DriveTask, []string, error)

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) Span

func (in *DriveInput) Span(ctx context.Context) (ref.Ref, ref.Ref, error)

func (*DriveInput) SpikeDone

func (in *DriveInput) SpikeDone(ctx context.Context, r *DriveRun) (bool, error)

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.

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 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 EndOf

func EndOf(err error) (DriveResult, bool)

EndOf is the end err carries, if it is one.

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.

func (*DriveRun) HoldsSlot

func (r *DriveRun) HoldsSlot() bool

HoldsSlot: a run on its way keeps its slot from one skill to the next; one parked, waiting or queued has given it up.

func (*DriveRun) Opened

func (r *DriveRun) Opened() bool

func (*DriveRun) Queued

func (r *DriveRun) Queued() bool

Queued: the cap holds the task, opened or not.

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 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.

func (*OpenGate) Order

func (g *OpenGate) Order(runs []*DriveRun) []*DriveRun

Order puts the tasks with an agent already open first, since they add no session and are the work a resume finds under way; the rest keep the drive's order.

func (*OpenGate) Workspace

func (g *OpenGate) Workspace(r *DriveRun) *agentctl.Workspace

Workspace is the one showing r's checkout, nil for none.

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

func (s TaskState) Fingerprint() string

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

func (s TaskState) Has(skill string) bool

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

func (s TaskState) Shipped() bool

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

func (v *TickView) JustOpened(r *DriveRun)

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)

Jump to

Keyboard shortcuts

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