dispatch

package
v0.4.0 Latest Latest
Warning

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

Go to latest
Published: Apr 30, 2026 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var PollInterval = 250 * time.Millisecond

PollInterval is the WaitWorkerAbsent poll cadence. Exported so tests can shorten it; production callers leave it at the default.

Functions

func BuildWorkerCommand

func BuildWorkerCommand(bin string, spec Spec) (*exec.Cmd, error)

BuildWorkerCommand assembles the `bones tasks dispatch worker` invocation with the required flags wired from spec. The parent appends per-result flags (--result, --summary, --claim-from-agent-id) before Start.

Earlier iterations passed these as AGENT_INFRA_* env vars, but the worker's Kong struct never read them — the worker would fail Kong's required-flag validation immediately and the parent would hit its 5s subscribe timeout. Flags-only is the single source of truth.

func FormatResult

func FormatResult(msg ResultMessage) string

func WaitWorkerAbsent

func WaitWorkerAbsent(
	ctx context.Context,
	probe PresenceProbe,
	workerAgentID string,
	deadline time.Duration,
) error

WaitWorkerAbsent polls the substrate's presence view via probe and returns nil once workerAgentID is no longer present, or an error if the deadline elapses first. Used by the dispatch parent to detect worker dropout (heartbeat lapse) before reclaiming the claim.

The probe callback decouples dispatch from coord: tests can pass a closure backed by an in-memory list, and production wiring uses `coord.Coord.PresentAgentIDs`.

Types

type PresenceProbe added in v0.2.0

type PresenceProbe func(ctx context.Context) ([]string, error)

PresenceProbe returns the agent IDs currently present in the substrate. Used by WaitWorkerAbsent to poll for worker dropout without depending on a particular substrate's Presence type.

The standard binding is `coord.Coord.PresentAgentIDs`; tests can pass a closure backed by an in-memory slice.

type ResultKind

type ResultKind string
const (
	ResultSuccess ResultKind = "success"
	ResultFork    ResultKind = "fork"
	ResultFail    ResultKind = "fail"
)

type ResultMessage

type ResultMessage struct {
	Kind    ResultKind
	Summary string
	Branch  string
	Rev     string
}

func ParseResult

func ParseResult(body string) (ResultMessage, bool)

type Spec

type Spec struct {
	TaskID        string
	Title         string
	Files         []string
	Thread        string
	ParentAgentID string
	WorkerAgentID string
	WorkspaceDir  string
}

Spec is the parent-resolved description of a task ready to dispatch to a worker process. Pure data; no substrate references. The CLI adapter that produced the Task value is the only thing that knows about coord.

func BuildSpec

func BuildSpec(parentAgentID, workspaceDir string, task Task) (Spec, error)

BuildSpec materializes a Spec from a parent agent's view of a dispatchable task. The Task interface keeps dispatch coord-free; CLI callers pass a small adapter wrapping coord.Task.

type Task added in v0.2.0

type Task interface {
	// ID returns the task identifier as a plain string. Whatever
	// coord-side type wraps the ID is converted at the adapter
	// boundary; dispatch carries it as a string.
	ID() string

	// Title is the human-readable title.
	Title() string

	// Files lists the absolute workspace paths the task scopes its
	// work to. The returned slice may be the task's own copy;
	// BuildSpec takes a copy if it needs to mutate.
	Files() []string
}

Task is the dispatch-local view of a coord task record. Defined here (rather than imported from coord) so dispatch can be tested with minimal in-memory fakes and so a future migration to a different task source — a different substrate, a different storage shape — does not ripple through dispatch.

Coord's task type satisfies this structurally via a small adapter at the CLI layer; dispatch never imports coord.Task directly.

Jump to

Keyboard shortcuts

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