Documentation
¶
Overview ¶
Package executor runs prompt files inside Docker containers.
Index ¶
Constants ¶
This section is empty.
Variables ¶
ErrDockerDaemonUnavailable signals that the Docker daemon could not be reached (socket missing, daemon not running). Callers MUST NOT treat this as "container not running" — the container's actual state is unknown.
Functions ¶
func BuildDockerRunArgs ¶ added in v0.180.0
func BuildDockerRunArgs(opts ContainerLaunchOpts) []string
BuildDockerRunArgs returns the argv for `docker run --rm` from opts. First argv element is "run"; caller invokes via `exec.CommandContext(ctx, "docker", args...)` or `subproc.Runner.RunWithWarnAndTimeout(ctx, op, "docker", args...)`.
The returned argv shape matches what dark-factory's executor produces for prompt containers, minus the prompt-file mount and the YOLO_PROMPT_FILE/YOLO_OUTPUT env vars (those are prompt-specific and not part of the shared launch surface).
Stable argv shape: env keys are sorted, mount order is deterministic. Callers can grep the argv in tests without flakiness.
Types ¶
type ContainerCounter ¶ added in v0.82.0
ContainerCounter counts running dark-factory containers system-wide.
func NewDockerContainerCounter ¶ added in v0.82.0
func NewDockerContainerCounter(runner subproc.Runner) ContainerCounter
NewDockerContainerCounter creates a ContainerCounter that uses docker ps with label filtering.
type ContainerLaunchOpts ¶ added in v0.180.0
type ContainerLaunchOpts = launchpolicy.ContainerLaunchOpts
ContainerLaunchOpts is an alias for launchpolicy.ContainerLaunchOpts. The type definition lives in pkg/launchpolicy to avoid a circular import (executor imports launchpolicy; launchpolicy must not import executor). Callers continue using executor.ContainerLaunchOpts with no source change.
type ExecutionChecker ¶ added in v0.186.0
type ExecutionChecker interface {
IsRunning(ctx context.Context, executionID string) (bool, error)
// WaitUntilRunning blocks until the named execution is in the running state,
// the timeout elapses, or ctx is cancelled.
WaitUntilRunning(ctx context.Context, executionID string, timeout time.Duration) error
}
ExecutionChecker checks whether a unit of execution (identified by executionID) is currently running.
func NewDockerExecutionChecker ¶ added in v0.186.0
func NewDockerExecutionChecker( currentDateTimeGetter libtime.CurrentDateTimeGetter, ) ExecutionChecker
NewDockerExecutionChecker creates an ExecutionChecker backed by docker inspect.
type ExecutionStopper ¶ added in v0.186.0
ExecutionStopper stops a running unit of execution by its executionID.
func NewDockerExecutionStopper ¶ added in v0.186.0
func NewDockerExecutionStopper() ExecutionStopper
NewDockerExecutionStopper creates an ExecutionStopper backed by docker stop.
type Executor ¶ added in v0.2.0
type Executor interface {
Execute(ctx context.Context, promptContent string, logFile string, executionID string) error
// Reattach connects to a running execution's output stream and waits for it to exit.
// It does not create a new container. The log file is overwritten from the beginning
// of the container's output (docker logs replays all output from container start).
// maxPromptDuration is the remaining allowed run time; 0 disables the timeout.
// Returns nil when the execution exits successfully.
Reattach(
ctx context.Context,
logFile string,
executionID string,
maxPromptDuration time.Duration,
) error
// StopAndRemoveContainer stops and forcibly removes the named execution.
// Best-effort: any errors are logged but not returned.
StopAndRemoveContainer(ctx context.Context, executionID string)
}
Executor executes a prompt.
func NewDockerExecutor ¶ added in v0.2.0
func NewDockerExecutor( policy launchpolicy.Policy, model string, maxPromptDuration time.Duration, currentDateTimeGetter libtime.CurrentDateTimeGetter, fmtr formatter.Formatter, ) Executor
NewDockerExecutor creates a new Executor using Docker. The launch shape (image, project, mounts, base env, netrc/gitconfig, hide-git, capabilities) is sourced from the shared launchpolicy.Policy — see pkg/launchpolicy. Prompt-specific concerns (model, max duration, formatter) remain on the executor itself.