Documentation
¶
Overview ¶
Package controlplane is runeward's governed execution core. Every tool call runs through one path: policy, approval gate, guardrails, backend exec, audit ledger. The Manager owns sandbox sessions and the shared ledger; the REST and MCP servers are thin adapters over it.
Index ¶
- type Approval
- type ApprovalStore
- type ApprovalView
- type ClientError
- type CreateOptions
- type Fleet
- type FleetView
- type Manager
- func (m *Manager) AddTask(fleetID, payload string) (*fleet.Task, error)
- func (m *Manager) Approvals() *ApprovalStore
- func (m *Manager) AttachTerminal(ctx context.Context, id string, stream backend.PTYStream) error
- func (m *Manager) Browser(ctx context.Context, id, url, mode string) (*ToolResult, error)
- func (m *Manager) BrowserAct(ctx context.Context, id, sessionID string, cmd browser.Command) (*ToolResult, error)
- func (m *Manager) BrowserClose(ctx context.Context, id, sessionID string) error
- func (m *Manager) BrowserOpen(ctx context.Context, id string) (sessionID string, res *ToolResult, err error)
- func (m *Manager) ClaimTask(fleetID, owner string) (fleet.Task, bool, error)
- func (m *Manager) Close() error
- func (m *Manager) CompleteTask(fleetID, taskID, owner, result string) error
- func (m *Manager) CreateFleet(ctx context.Context, profileName string) (*FleetView, error)
- func (m *Manager) CreateFleetForOwner(ctx context.Context, profileName, owner string) (*FleetView, error)
- func (m *Manager) CreateSandbox(ctx context.Context, profileName string, opts CreateOptions) (*backend.Sandbox, error)
- func (m *Manager) ExportBundle(w io.Writer, sessionID string) error
- func (m *Manager) FailTask(fleetID, taskID, owner, errMsg string, requeue bool) error
- func (m *Manager) FileList(ctx context.Context, id, path string) (*ToolResult, error)
- func (m *Manager) FileRead(ctx context.Context, id, path string) (*ToolResult, error)
- func (m *Manager) FileSearch(ctx context.Context, id, query, path string) (*ToolResult, error)
- func (m *Manager) FileWrite(ctx context.Context, id, path, content string) (*ToolResult, error)
- func (m *Manager) FleetView(id string) (*FleetView, bool)
- func (m *Manager) HeartbeatTask(fleetID, taskID, owner string) (fleet.Task, error)
- func (m *Manager) KillFleet(ctx context.Context, id string) error
- func (m *Manager) KillSandbox(ctx context.Context, id string) error
- func (m *Manager) Ledger() *ledger.Ledger
- func (m *Manager) LedgerPublicKey() (pub string, keyID string)
- func (m *Manager) ListFleets() []FleetView
- func (m *Manager) ListProfiles() ([]ProfileInfo, error)
- func (m *Manager) ListSandboxInfos() []SandboxInfo
- func (m *Manager) ListSandboxes() []backend.Sandbox
- func (m *Manager) ListSnapshots() []backend.SnapshotRef
- func (m *Manager) ListTasks(fleetID string) ([]fleet.Task, error)
- func (m *Manager) Node(ctx context.Context, id, code string) (*ToolResult, error)
- func (m *Manager) Python(ctx context.Context, id, code string) (*ToolResult, error)
- func (m *Manager) RecordUsage(id string, tokens int64, costUSD float64) error
- func (m *Manager) ResolveApproval(id string, approve bool, actor string) bool
- func (m *Manager) RestoreSnapshot(ctx context.Context, snapshotID, owner string) (*backend.Sandbox, error)
- func (m *Manager) Sandbox(id string) (*backend.Sandbox, bool)
- func (m *Manager) SandboxOwner(id string) (owner string, ok bool)
- func (m *Manager) SandboxUsage(id string) accounting.Usage
- func (m *Manager) Shell(ctx context.Context, id string, command []string, workdir string) (*ToolResult, error)
- func (m *Manager) Signed() bool
- func (m *Manager) Snapshot(ctx context.Context, id, name string) (*backend.SnapshotRef, error)
- func (m *Manager) StateDir() string
- func (m *Manager) VerifyLedger() error
- type ProfileInfo
- type SandboxInfo
- type Session
- type ToolResult
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Approval ¶
type Approval struct {
ID string
Sandbox string
Tool string
Action string
Reason string
Created time.Time
// contains filtered or unexported fields
}
Approval is a pending human-in-the-loop authorization request. The blocked tool call waits on decided until an operator resolves it.
type ApprovalStore ¶
type ApprovalStore struct {
// contains filtered or unexported fields
}
ApprovalStore is a concurrency-safe registry of pending approvals.
func NewApprovalStore ¶
func NewApprovalStore() *ApprovalStore
NewApprovalStore returns an empty store.
func (*ApprovalStore) Create ¶
func (s *ApprovalStore) Create(sandbox, tool, action, reason string) *Approval
Create registers a new pending approval and returns it.
func (*ApprovalStore) List ¶
func (s *ApprovalStore) List() []ApprovalView
List returns a snapshot of pending approvals in map order; callers sort if they need to.
func (*ApprovalStore) Resolve ¶
func (s *ApprovalStore) Resolve(id string, approve bool) bool
Resolve delivers a decision to the waiting tool call and removes the approval. It reports whether that id was pending.
func (*ApprovalStore) ResolveView ¶
func (s *ApprovalStore) ResolveView(id string, approve bool) (ApprovalView, bool)
ResolveView is like Resolve but also returns a view of the approval that was resolved, so callers can record who decided it and what it authorized.
type ApprovalView ¶
type ApprovalView struct {
ID string `json:"id"`
Sandbox string `json:"sandbox"`
Tool string `json:"tool"`
Action string `json:"action"`
Reason string `json:"reason"`
Created time.Time `json:"created"`
}
ApprovalView is the JSON projection of an Approval.
type ClientError ¶
type ClientError struct {
// NotFound marks a missing resource (sandbox, fleet, snapshot, browser
// session) -> 404. When false the error is treated as bad input -> 400.
NotFound bool
Message string
}
ClientError is an error whose message is safe to return to an API caller and which maps to a client-facing HTTP status. It lets the server distinguish bad input and missing resources (which the caller can act on) from genuine internal failures, which must stay opaque so they cannot leak host paths, backend detail, or other server-side information.
func (*ClientError) Error ¶
func (e *ClientError) Error() string
type CreateOptions ¶
type CreateOptions struct {
// CopyFrom overrides host.copy_from for this create: a one-time copy into
// the fresh workspace, the host dir is never mounted. "~/" is expanded.
CopyFrom string
// Owner records the RBAC principal that created the sandbox, for
// per-principal visibility and access control. Empty means unowned
// (RBAC disabled), in which case every caller can see it.
Owner string
}
CreateOptions carries per-create overrides that are not part of the profile.
type Fleet ¶
type Fleet struct {
ID string
Profile string
Owner string
Board *fleet.Board
Sandboxes []string
Created time.Time
// contains filtered or unexported fields
}
Fleet is a set of sandboxes from one profile sharing an atomic task board.
type FleetView ¶
type FleetView struct {
ID string `json:"id"`
Profile string `json:"profile"`
Owner string `json:"owner,omitempty"`
Sandboxes []string `json:"sandboxes"`
Stats fleet.Stats `json:"stats"`
Created time.Time `json:"created"`
}
FleetView is the JSON projection of a fleet.
type Manager ¶
type Manager struct {
// contains filtered or unexported fields
}
Manager is the control-plane core. It is safe for concurrent use.
func (*Manager) Approvals ¶
func (m *Manager) Approvals() *ApprovalStore
Approvals returns the approval store.
func (*Manager) AttachTerminal ¶
AttachTerminal wires an interactive PTY to the sandbox. Terminals are not policy-gated per keystroke, but the attach itself is audited.
func (*Manager) Browser ¶
Browser renders a page with headless Chromium inside the sandbox. It is policy-gated as tool "browser" (arg = url), and the profile's egress proxy is passed via --proxy-server so egress rules cover browser traffic too. mode is "text" (rendered DOM HTML) or "screenshot" (base64 PNG in Stdout).
func (*Manager) BrowserAct ¶
func (m *Manager) BrowserAct(ctx context.Context, id, sessionID string, cmd browser.Command) (*ToolResult, error)
BrowserAct sends one action to a live browser session through the governed path. Stdout carries the value (or base64 screenshot); a driver-level failure surfaces in Reason.
func (*Manager) BrowserClose ¶
BrowserClose shuts down the driver (best-effort) and always removes local bookkeeping.
func (*Manager) BrowserOpen ¶
func (m *Manager) BrowserOpen(ctx context.Context, id string) (sessionID string, res *ToolResult, err error)
BrowserOpen starts a stateful CDP browser session in the sandbox and returns its id. The driver is launched detached; the egress proxy is threaded through via --proxy. Gated by policy as tool "browser" (action "open"), so a deny or pending verdict comes back in the ToolResult without starting a session.
func (*Manager) Close ¶
Close stops the sweeper, flushes audit sinks, and releases the ledger handle.
func (*Manager) CompleteTask ¶
CompleteTask marks a claimed task done. owner must match the claiming worker.
func (*Manager) CreateFleet ¶
CreateFleet provisions the profile's replicas with a shared task board seeded from its task_board list.
func (*Manager) CreateFleetForOwner ¶
func (m *Manager) CreateFleetForOwner(ctx context.Context, profileName, owner string) (*FleetView, error)
CreateFleetForOwner provisions the profile's replicas with a shared task board seeded from its task_board list and attributes member sandboxes to the owning principal when provided.
func (*Manager) CreateSandbox ¶
func (m *Manager) CreateSandbox(ctx context.Context, profileName string, opts CreateOptions) (*backend.Sandbox, error)
CreateSandbox loads the named profile, provisions a sandbox on its backend, and registers a governed session for it.
func (*Manager) ExportBundle ¶
ExportBundle writes a verifiable transcript of a session's audit events (all events when sessionID is "") to w. Fails when signing is disabled.
func (*Manager) FailTask ¶
FailTask marks a claimed task failed, optionally requeuing it. owner must match the claiming worker.
func (*Manager) FileSearch ¶
FileSearch runs a recursive grep rooted at path.
func (*Manager) FileWrite ¶
FileWrite writes a file in the sandbox, creating parent directories. Content travels base64-encoded to stay binary-safe over the shell.
func (*Manager) HeartbeatTask ¶
HeartbeatTask extends a worker's lease on a task so the sweeper won't requeue it.
func (*Manager) KillSandbox ¶
KillSandbox tears down a sandbox and removes its session.
func (*Manager) LedgerPublicKey ¶
LedgerPublicKey returns the base64 signing key and key id, or empty strings when signing is disabled.
func (*Manager) ListFleets ¶
ListFleets returns all fleets.
func (*Manager) ListProfiles ¶
func (m *Manager) ListProfiles() ([]ProfileInfo, error)
ListProfiles returns the resolvable profiles for the configured search path.
func (*Manager) ListSandboxInfos ¶
func (m *Manager) ListSandboxInfos() []SandboxInfo
ListSandboxInfos returns every governed sandbox together with its owner. The server uses this to filter the list per principal ("multi-user" views).
func (*Manager) ListSandboxes ¶
ListSandboxes returns handles for every governed sandbox.
func (*Manager) ListSnapshots ¶
func (m *Manager) ListSnapshots() []backend.SnapshotRef
ListSnapshots returns all captured snapshot references.
func (*Manager) RecordUsage ¶
RecordUsage attributes reported model usage (tokens and/or US-dollar spend) to a sandbox, updating the accounting totals and metrics and appending an audit event. Callers (agents, fleet workers) report usage they observe from the model provider; once the profile's budget is exceeded, govern denies further tool calls. It errors if the sandbox is unknown.
func (*Manager) ResolveApproval ¶
ResolveApproval resolves a pending approval and records who decided it in the tamper-evident ledger, so a human-in-the-loop decision is always attributed. It reports whether the id was pending.
func (*Manager) RestoreSnapshot ¶
func (m *Manager) RestoreSnapshot(ctx context.Context, snapshotID, owner string) (*backend.Sandbox, error)
RestoreSnapshot recreates a governed sandbox from a snapshot, re-deriving policy and guardrails from the snapshot's profile.
func (*Manager) SandboxOwner ¶
SandboxOwner returns the owning principal for a sandbox id. ok is false when the sandbox is unknown; a known-but-unowned sandbox returns ("", true).
func (*Manager) SandboxUsage ¶
func (m *Manager) SandboxUsage(id string) accounting.Usage
SandboxUsage returns the cumulative reported usage for a sandbox.
func (*Manager) Shell ¶
func (m *Manager) Shell(ctx context.Context, id string, command []string, workdir string) (*ToolResult, error)
Shell runs a command vector in the sandbox under policy control.
func (*Manager) StateDir ¶
StateDir returns the directory holding runeward state (ledger, keys, and terminal recordings).
func (*Manager) VerifyLedger ¶
VerifyLedger checks the hash chain and, when signing is enabled, signatures.
type ProfileInfo ¶
type ProfileInfo struct {
Name string `json:"name"`
Host string `json:"host"`
Egress string `json:"egress"`
}
ProfileInfo is a lightweight profile descriptor for listing.
type SandboxInfo ¶
SandboxInfo pairs a sandbox handle with its owning principal for listing.
type Session ¶
type Session struct {
Sandbox *backend.Sandbox
Backend backend.Backend
Profile *profile.Profile
Engine policy.Evaluator
Guard *policy.Guard
Env map[string]string
Workdir string
// Owner is the name of the RBAC principal that created the sandbox, used
// for per-principal ("multi-user") visibility and access control. Empty
// when RBAC is not configured.
Owner string
// contains filtered or unexported fields
}
Session is the per-sandbox governed state.
type ToolResult ¶
type ToolResult struct {
Verdict profile.Verdict `json:"verdict"`
Reason string `json:"reason,omitempty"`
ApprovalID string `json:"approval_id,omitempty"`
Pending bool `json:"pending,omitempty"`
ExitCode int `json:"exit_code"`
Stdout string `json:"stdout,omitempty"`
Stderr string `json:"stderr,omitempty"`
DurationMS int64 `json:"duration_ms"`
}
ToolResult is the governed outcome of a single tool invocation.