Documentation
¶
Overview ¶
Package executor defines the worker abstraction (§48–§50). The deterministic `internal` executor is the first implementation; OMP is validated behind this same interface as `local_external`.
Package executor defines the worker abstraction (§48–§50). The deterministic `internal` executor is the first implementation; OMP is validated behind this same interface as `local_external`.
Package executor defines the worker abstraction (§48–§50). The deterministic `internal` executor is the first implementation; OMP is validated behind this same interface as `local_external`.
Index ¶
- func DefaultAgentImage(kind string) string
- func KeyEnvForModel(model string) string
- func PullImage(ctx context.Context, image string) (string, error)
- func SmokeAgent(ctx context.Context, kind, image, model string) error
- func TrustAllows(trust domain.ExecutorTrust, action string) bool
- func TrustTierFor(name string) domain.ExecutorTrust
- func VerifyAgentCLI(ctx context.Context, image, cli string) error
- type Attempt
- type Capabilities
- type CapabilityBroker
- type ContainerExecutor
- func (e *ContainerExecutor) Cancel(ctx context.Context, id string) error
- func (e *ContainerExecutor) Capabilities(ctx context.Context) Capabilities
- func (e *ContainerExecutor) Collect(ctx context.Context, id string) (Result, error)
- func (e *ContainerExecutor) Name() string
- func (e *ContainerExecutor) Start(ctx context.Context, req Request) (Attempt, error)
- func (e *ContainerExecutor) Status(ctx context.Context, id string) (Status, error)
- type ContainerSandbox
- type Executor
- type InternalExecutor
- func (e *InternalExecutor) Cancel(ctx context.Context, id string) error
- func (e *InternalExecutor) Capabilities(ctx context.Context) Capabilities
- func (e *InternalExecutor) Collect(ctx context.Context, id string) (Result, error)
- func (e *InternalExecutor) Name() string
- func (e *InternalExecutor) Start(ctx context.Context, req Request) (Attempt, error)
- func (e *InternalExecutor) Status(ctx context.Context, id string) (Status, error)
- type Request
- type Result
- type RunOptions
- type SandboxedAgentExecutor
- func (e *SandboxedAgentExecutor) Cancel(ctx context.Context, id string) error
- func (e *SandboxedAgentExecutor) Capabilities(ctx context.Context) Capabilities
- func (e *SandboxedAgentExecutor) Collect(ctx context.Context, id string) (Result, error)
- func (e *SandboxedAgentExecutor) Name() string
- func (e *SandboxedAgentExecutor) Start(ctx context.Context, req Request) (Attempt, error)
- func (e *SandboxedAgentExecutor) Status(ctx context.Context, id string) (Status, error)
- type Status
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func DefaultAgentImage ¶
DefaultAgentImage returns the pinned default container image for a coding agent, or "" when no canonical image exists (the caller should then require an explicit --image). Hermes has an official image; OMP does not.
func KeyEnvForModel ¶
KeyEnvForModel maps a "provider/model" spec to its provider API-key env var name (built-in presets only; custom providers are resolved by the engine at runtime). Used by the smoke check to confirm the required key is present.
func PullImage ¶
PullImage ensures image is present locally (docker pull only if absent) and returns its image ID so the caller can surface exactly what was downloaded.
func SmokeAgent ¶
SmokeAgent runs a trivial coding task through the agent in an isolated container and asserts it produced at least one file in the work root. It verifies the full CLI contract end-to-end (the exact agent invocation), not just that the binary exists. It requires the provider API key for model to be present in the environment (the agent needs it to call its model).
func TrustAllows ¶
func TrustAllows(trust domain.ExecutorTrust, action string) bool
TrustAllows reports whether an action is permitted for an executor's engine-assigned trust tier. It is the policy gate used before any execution, independent of the executor's self-declared capability list.
func TrustTierFor ¶
func TrustTierFor(name string) domain.ExecutorTrust
TrustTierFor maps an executor's Name() (== the selected executor kind) to its engine-assigned trust tier. It is the single source of truth, never the executor's self-declared Capabilities().Trust, and it fails closed for any unknown kind (review: system-deny / engine-assigned trust).
func VerifyAgentCLI ¶
VerifyAgentCLI checks that an agent CLI is present in a container image, WITHOUT pulling and with the same hardened flags the sandbox uses at runtime (no network, read-only root, dropped capabilities, non-root, bounded memory/ pids). It is a UX presence check only — trust must come from the image source, not this probe (review: v1 agent setup). The image must already be present locally; a missing image is a distinct error, not a CLI-missing result.
Types ¶
type Attempt ¶
type Attempt struct {
ID string `json:"id"`
Executor string `json:"executor"`
Status string `json:"status"` // running|succeeded|failed|cancelled
Phase string `json:"phase"` // Planning|Editing|Testing|Waiting|Reviewing|Finished
}
Attempt is the durable handle returned by Start.
type Capabilities ¶
type Capabilities struct {
Trust domain.ExecutorTrust `json:"trust"`
SandboxMode domain.SandboxMode `json:"sandbox_mode"`
Network bool `json:"network"`
Capabilities []string `json:"capabilities"`
}
Capabilities declares the executor's trust, sandbox mode, and (deterministic, not model-granted) capabilities.
type CapabilityBroker ¶
type CapabilityBroker struct{}
CapabilityBroker authorizes tool actions against an executor's declared capability set. It is a pure gate: it can only deny, never grant.
func (CapabilityBroker) Authorize ¶
func (CapabilityBroker) Authorize(caps []string, action string) error
Authorize returns nil if every declared capability required by action is present in caps, and an error otherwise. An unknown action is always denied.
func (CapabilityBroker) GrantSuggested ¶
func (CapabilityBroker) GrantSuggested(suggested []string) []string
GrantSuggested returns an empty set: models cannot grant capabilities. The suggested list is deliberately ignored so a model can never widen its own executor's declared capability set (§50).
type ContainerExecutor ¶
type ContainerExecutor struct {
// contains filtered or unexported fields
}
ContainerExecutor runs a task inside a Docker container with no network and a read-only-by-convention workspace mount, collecting the produced patch from a mounted hand-off file (§52 SandboxContainer).
func NewContainerExecutor ¶
func NewContainerExecutor(store *blob.Store, image string) *ContainerExecutor
NewContainerExecutor returns a ContainerExecutor that persists produced patch content to the given blob store. image defaults to a minimal Alpine image when empty; dockerPath is the Docker CLI (override for tests).
func (*ContainerExecutor) Cancel ¶
func (e *ContainerExecutor) Cancel(ctx context.Context, id string) error
Cancel removes the container, terminating the attempt.
func (*ContainerExecutor) Capabilities ¶
func (e *ContainerExecutor) Capabilities(ctx context.Context) Capabilities
Capabilities declares the container executor's deterministic capabilities.
func (*ContainerExecutor) Collect ¶
Collect reads the produced patch from the mounted hand-off file, cleans up the container, and persists the content to the blob store.
func (*ContainerExecutor) Name ¶
func (e *ContainerExecutor) Name() string
Name reports the executor's registered name.
type ContainerSandbox ¶
type ContainerSandbox struct {
// contains filtered or unexported fields
}
ContainerSandbox runs a command inside an isolated Docker container: no network, read-only root filesystem, dropped capabilities, bounded memory/pids, and the daemon's own UID/GID -- which is not the same as non-root. If the daemon runs as root the container does too, and nothing refuses to start or warns (docs/security-model.md records this under what the gateway does not protect against). Only the work root (mounted at /work) and a /tmp tmpfs are writable; an optional project root is mounted read-only at /repo. This is the OS-isolation boundary for external coding agents and deterministic checks (§52, review B2/H3).
func NewContainerSandbox ¶
func NewContainerSandbox(image string) *ContainerSandbox
NewContainerSandbox returns a sandbox using image (defaulting to a minimal Alpine image). dockerPath is the Docker CLI (override for tests).
func (*ContainerSandbox) Run ¶
func (s *ContainerSandbox) Run(ctx context.Context, opts RunOptions) (stdout, stderr string, exitCode int, err error)
Run executes cmd in the sandbox and returns stdout, stderr, and the exit code. The container is started detached so a context timeout/cancellation can be enforced by `docker rm -f` (a hung build/test is genuinely killed, not left orphaned). A non-zero exit code is not a Go error; only a failure to launch Docker is.
type Executor ¶
type Executor interface {
Name() string
Capabilities(ctx context.Context) Capabilities
Start(ctx context.Context, req Request) (Attempt, error)
Status(ctx context.Context, id string) (Status, error)
Cancel(ctx context.Context, id string) error
Collect(ctx context.Context, id string) (Result, error)
}
Executor runs a Task in an isolated worker and returns a patch.
type InternalExecutor ¶
type InternalExecutor struct {
// contains filtered or unexported fields
}
InternalExecutor runs tasks deterministically in-process. It is hermetic: it performs no network I/O and depends on no external services.
func NewInternalExecutor ¶
func NewInternalExecutor(store *blob.Store) *InternalExecutor
NewInternalExecutor returns a ready-to-use InternalExecutor that persists produced patch content to the given content-addressed blob store.
func (*InternalExecutor) Cancel ¶
func (e *InternalExecutor) Cancel(ctx context.Context, id string) error
Cancel marks an attempt cancelled. It is a no-op after the attempt has already succeeded or been cancelled.
func (*InternalExecutor) Capabilities ¶
func (e *InternalExecutor) Capabilities(ctx context.Context) Capabilities
Capabilities declares the executor's deterministic capabilities. Trust and sandbox mode are fixed by construction; the capability set is never model-granted (§49, §50).
func (*InternalExecutor) Collect ¶
Collect writes the deterministic implementation file into the isolated work root and returns an empty Result. The engine (orchestrator) snapshots the work root before/after and computes the real diff (§36); the executor's job is only to produce file changes, never to self-declare the diff.
func (*InternalExecutor) Name ¶
func (e *InternalExecutor) Name() string
Name reports the executor's registered name.
type Request ¶
type Request struct {
InitiativeID string `json:"initiative_id"`
TaskID string `json:"task_id"`
TaskTitle string `json:"task_title"`
TaskStatement string `json:"task_statement"`
Brief string `json:"brief,omitempty"`
WorkRoot string `json:"work_root"`
}
Request is one execution request. The canonical workspace is never passed as a writable root — the executor receives an isolated WorkRoot (§37). Brief is the planner-produced implementation brief (rendered text) the implementer should follow; when empty the executor falls back to TaskStatement.
type Result ¶
type Result struct {
PatchDigest string `json:"patch_digest"`
LogDigest string `json:"log_digest,omitempty"`
Usage domain.RunUsage `json:"usage,omitempty"`
}
Result is the collected execution output (content-addressed digests + usage).
type RunOptions ¶
type RunOptions struct {
WorkRoot string // writable, mounted at /work
RepoRoot string // optional, mounted read-only at /repo (the canonical workspace)
Cmd []string // command + args (run with work dir /work)
}
RunOptions configures a sandbox execution.
type SandboxedAgentExecutor ¶
type SandboxedAgentExecutor struct {
// contains filtered or unexported fields
}
SandboxedAgentExecutor runs a coding-agent CLI inside an isolated container (review B2, amended). The container gives FILESYSTEM/PROCESS isolation — read-only root, only the mounted /work and a /tmp tmpfs are writable — but NOT network isolation: the agent needs egress to reach its model API, so the provider keys are forwarded in and `--network none` is deliberately omitted. OMP and Hermes are the two agents; neither runs as a host subprocess. The agent writes files under /work (== req.WorkRoot); the engine snapshots that directory before/after and computes the diff (B3).
func NewHermesExecutor ¶
func NewHermesExecutor(store *blob.Store, model, image, keyEnv string) *SandboxedAgentExecutor
NewHermesExecutor returns a sandboxed Hermes (Nous Research) executor.
func NewOMPExecutor ¶
func NewOMPExecutor(store *blob.Store, model, image, keyEnv string) *SandboxedAgentExecutor
NewOMPExecutor returns a sandboxed OMP executor. keyEnv is the provider API-key env var name resolved by the engine (empty for keyless providers).
func (*SandboxedAgentExecutor) Cancel ¶
func (e *SandboxedAgentExecutor) Cancel(ctx context.Context, id string) error
Cancel removes the container, terminating the agent.
func (*SandboxedAgentExecutor) Capabilities ¶
func (e *SandboxedAgentExecutor) Capabilities(ctx context.Context) Capabilities
Capabilities declares the agent's capabilities. The sandbox mode is REAL filesystem/process isolation (container, read-only root); Network is true because the agent needs egress to reach its model API.
func (*SandboxedAgentExecutor) Collect ¶
Collect cleans up the container and returns an empty Result. The engine computes the diff from the work root (B3); the executor's job is only to run the agent in isolation.
func (*SandboxedAgentExecutor) Name ¶
func (e *SandboxedAgentExecutor) Name() string
Name reports the executor's registered name.
func (*SandboxedAgentExecutor) Start ¶
Start launches the agent inside the isolated container (detached) and records the container id. The provider keys are forwarded so the agent can reach its model; `--network none` is intentionally omitted (the agent must egress to the model API — this is a filesystem/process sandbox, not a network sandbox).