Documentation
¶
Index ¶
- type ApprovalInfo
- type ApprovalMode
- type ChainState
- type CreateSessionRequest
- type Decision
- type EnvPolicyWire
- type Event
- type EventQuery
- type ExecError
- type ExecEvents
- type ExecGuidance
- type ExecRequest
- type ExecResources
- type ExecResponse
- type ExecResult
- type FileRedirectInfo
- type InspectInfo
- type MountInfo
- type Pagination
- type PolicyInfo
- type RedirectInfo
- type Session
- type SessionPatchRequest
- type SessionResult
- type SessionState
- type SessionStats
- type Suggestion
- type TaintEvent
- type TaintInfo
- type TaintMatchedRule
- type TaintTrace
- type WrapInitRequest
- type WrapInitResponse
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type ApprovalInfo ¶
type ApprovalInfo struct {
Required bool `json:"required"`
Mode ApprovalMode `json:"mode,omitempty"`
ID string `json:"id,omitempty"`
}
type ApprovalMode ¶
type ApprovalMode string
const ( ApprovalModeShadow ApprovalMode = "shadow" ApprovalModeEnforced ApprovalMode = "enforced" )
type ChainState ¶
ChainState is the shared (sequence, generation) tuple that the composite store will stamp on each event before fanout to chained sinks. See docs/superpowers/specs/2026-04-18-phase-0-shared-sequence-contract.md.
Contract for consumers: ChainState MUST be treated as read-only. Sinks must never mutate the fields of a *ChainState they receive on types.Event.Chain.
Lifecycle: this type and the Event.Chain field exist now so downstream tasks can build against a stable type, but no caller writes to Chain yet. Task 5 of the Phase 0 plan will land the composite-store wiring that allocates a (sequence, generation) tuple via audit.SequenceAllocator and stamps a separate *ChainState per fanned-out sink (so the pointer is never aliased across sinks).
type CreateSessionRequest ¶
type CreateSessionRequest struct {
ID string `json:"id,omitempty"`
Workspace string `json:"workspace,omitempty"`
Policy string `json:"policy,omitempty"`
Profile string `json:"profile,omitempty"`
Home string `json:"home,omitempty"` // User's home directory for ${HOME} policy expansion
DetectProjectRoot *bool `json:"detect_project_root,omitempty"` // Override server default
ProjectRoot string `json:"project_root,omitempty"` // Explicit override
RealPaths *bool `json:"real_paths,omitempty"` // Use actual host paths instead of /workspace
}
type Decision ¶
type Decision string
const ( DecisionAllow Decision = "allow" DecisionDeny Decision = "deny" DecisionApprove Decision = "approve" DecisionRedirect Decision = "redirect" DecisionAudit Decision = "audit" // Allow + enhanced logging DecisionSoftDelete Decision = "soft_delete" // Redirect destructive ops to trash // DecisionInspect defers the verdict to content inspection. It is not a // terminal state: a caller that holds the content runs the named // inspection profiles and resolves it to the rule's on_violation (on a // finding) or allow (on a clean result). A caller that does not // understand inspection sees EffectiveDecision deny, so an unwired code // path blocks rather than passes. DecisionInspect Decision = "inspect" )
type EnvPolicyWire ¶
type EnvPolicyWire struct {
Allow []string `json:"allow,omitempty"`
Deny []string `json:"deny,omitempty"`
}
EnvPolicyWire carries the resolved env allow/deny for the client (shell shim / CLI wrap) to filter the executed command's inherited environment. Nil/ omitted means "no filtering" — the field is only populated when sandbox.wrap_env_policy.enabled is true, which also makes mixed-version deployments degrade safely.
Only allow/deny are carried. block_iteration (replaces environ, incompatible with shells) and max_bytes/max_keys are intentionally NOT enforced on the wrap path: BuildEnv treats a max_* overflow as a hard error, which under the wrap path's fail-open contract would revert to the FULL unfiltered env — silently bypassing the very allow/deny stripping the operator wanted. So the wrap filter is allow/deny (+ the built-in default-secret-deny) only. Issue #379.
type Event ¶
type Event struct {
ID string `json:"id,omitempty"`
Timestamp time.Time `json:"timestamp"`
Type string `json:"type"`
SessionID string `json:"session_id"`
CommandID string `json:"command_id,omitempty"`
Source string `json:"source,omitempty"`
PID int `json:"pid,omitempty"`
Policy *PolicyInfo `json:"policy,omitempty"`
// Process context (for execve events)
ParentPID int `json:"parent_pid,omitempty"`
Depth int `json:"depth,omitempty"`
// Execve details
Filename string `json:"filename,omitempty"`
RawFilename string `json:"raw_filename,omitempty"`
Argv []string `json:"argv,omitempty"`
Truncated bool `json:"truncated,omitempty"`
// Transparent command unwrapping
UnwrappedFrom string `json:"unwrapped_from,omitempty"`
PayloadCommand string `json:"payload_command,omitempty"`
// Common convenience fields for indexing/search.
Path string `json:"path,omitempty"`
Abstract bool `json:"abstract,omitempty"`
Domain string `json:"domain,omitempty"`
Remote string `json:"remote,omitempty"`
Operation string `json:"operation,omitempty"`
// Policy result
EffectiveAction string `json:"effective_action,omitempty"`
Fields map[string]any `json:"fields,omitempty"`
// Chain is the shared (sequence, generation) allocated by the composite
// store before fanout. Used by chained sinks to produce sink-local
// integrity hashes. Nil until composite stamps it.
//
// json:"-" is load-bearing: this field must never appear in any
// user-visible serialization. Tested by TestEvent_ChainFieldNotMarshaled.
//
// Sinks MUST treat the pointed-to ChainState as read-only — see the
// ChainState type comment for the per-sink-copy contract.
Chain *ChainState `json:"-"`
}
type EventQuery ¶
type ExecEvents ¶
type ExecEvents struct {
FileOperations []Event `json:"file_operations"`
NetworkOperations []Event `json:"network_operations"`
BlockedOperations []Event `json:"blocked_operations"`
Other []Event `json:"other,omitempty"`
// Counts are reported even when events are omitted for response-size reasons.
FileOperationsCount int `json:"file_operations_count,omitempty"`
NetworkOperationsCount int `json:"network_operations_count,omitempty"`
BlockedOperationsCount int `json:"blocked_operations_count,omitempty"`
OtherCount int `json:"other_count,omitempty"`
// Truncated indicates the response omitted some events due to include_events settings or caps.
Truncated bool `json:"truncated,omitempty"`
}
type ExecGuidance ¶
type ExecGuidance struct {
// Status is an agent-friendly classification: "ok", "failed", or "blocked".
Status string `json:"status,omitempty"`
Blocked bool `json:"blocked,omitempty"`
Retryable bool `json:"retryable,omitempty"`
Reason string `json:"reason,omitempty"`
PolicyRule string `json:"policy_rule,omitempty"`
BlockedOperation string `json:"blocked_operation,omitempty"`
BlockedTarget string `json:"blocked_target,omitempty"`
// Substitutions are ordered "do this instead" options.
Substitutions []Suggestion `json:"substitutions,omitempty"`
// Suggestions are remediation steps when substitution isn't available.
Suggestions []Suggestion `json:"suggestions,omitempty"`
}
type ExecRequest ¶
type ExecRequest struct {
Command string `json:"command"`
Argv0 string `json:"argv0,omitempty"`
Args []string `json:"args,omitempty"`
Timeout string `json:"timeout,omitempty"`
WorkingDir string `json:"working_dir,omitempty"`
Env map[string]string `json:"env,omitempty"`
Stdin string `json:"stdin,omitempty"`
StreamOutput bool `json:"stream_output,omitempty"`
// IncludeEvents controls how much event detail is returned in the ExecResponse.
// Valid values: "all" (default), "summary", "blocked", "none".
IncludeEvents string `json:"include_events,omitempty"`
}
type ExecResources ¶
type ExecResponse ¶
type ExecResponse struct {
CommandID string `json:"command_id"`
SessionID string `json:"session_id"`
Timestamp time.Time `json:"timestamp"`
Request ExecRequest `json:"request"`
Result ExecResult `json:"result"`
Events ExecEvents `json:"events"`
Resources *ExecResources `json:"resources,omitempty"`
// Guidance provides small, actionable context for agents (blocked vs failed, retryability, substitutions).
Guidance *ExecGuidance `json:"guidance,omitempty"`
}
type ExecResult ¶
type ExecResult struct {
ExitCode int `json:"exit_code"`
Stdout string `json:"stdout,omitempty"`
Stderr string `json:"stderr,omitempty"`
StdoutTruncated bool `json:"stdout_truncated,omitempty"`
StderrTruncated bool `json:"stderr_truncated,omitempty"`
StdoutTotalBytes int64 `json:"stdout_total_bytes,omitempty"`
StderrTotalBytes int64 `json:"stderr_total_bytes,omitempty"`
DurationMs int64 `json:"duration_ms"`
Error *ExecError `json:"error,omitempty"`
Pagination *Pagination `json:"pagination,omitempty"`
}
type FileRedirectInfo ¶
type FileRedirectInfo struct {
OriginalPath string `json:"original_path"`
RedirectPath string `json:"redirect_path"`
Operation string `json:"operation"`
Reason string `json:"reason,omitempty"`
}
FileRedirectInfo describes a file path redirect.
type InspectInfo ¶
type InspectInfo struct {
// Profiles names entries in the policy's inspection.profiles block.
Profiles []string `json:"profiles"`
// OnViolation is the decision to apply when inspection reports a
// finding. One of allow, deny, approve, redact.
OnViolation string `json:"on_violation"`
// OnFailure is what to do when inspection cannot run or times out.
// One of fail_closed, fail_open, approve.
OnFailure string `json:"on_failure"`
// TimeoutMS bounds a single inspection. Zero means the inspector's own
// default applies.
TimeoutMS int `json:"timeout_ms,omitempty"`
// Require marks inspection as a precondition on a non-inspect decision
// rather than the decision itself.
Require bool `json:"require,omitempty"`
// CleanDecision is the effective decision to restore when inspection
// finds nothing, captured before the fail-closed deny was applied.
//
// It is carried rather than re-derived because deriving it needs engine
// state the resolver has no access to: an approve is effective-approve
// under enforceApprovals and effective-allow in shadow mode, and audit
// is effective-allow. A resolver guessing from PolicyDecision alone
// would turn a shadow-mode approve into a hard gate.
CleanDecision Decision `json:"clean_decision,omitempty"`
}
InspectInfo is the inspection contract attached to a policy Decision. It is present when the rule's decision is "inspect", and when any other decision carries an `inspect:` block with require: true.
There is no DecisionRedact: redaction is an allow whose content was rewritten, which the content-holding caller applies. Adding a terminal "redact" state would give every enforcement backend a decision it has no way to act on.
type MountInfo ¶
type MountInfo struct {
Path string `json:"path"`
Policy string `json:"policy"`
MountPoint string `json:"mount_point"`
}
MountInfo describes an active mount in a session.
type Pagination ¶
type PolicyInfo ¶
type PolicyInfo struct {
Decision Decision `json:"decision,omitempty"`
EffectiveDecision Decision `json:"effective_decision,omitempty"`
Rule string `json:"rule,omitempty"`
Message string `json:"message,omitempty"`
Approval *ApprovalInfo `json:"approval,omitempty"`
Redirect *RedirectInfo `json:"redirect,omitempty"`
ThreatFeed string `json:"threat_feed,omitempty"`
ThreatMatch string `json:"threat_match,omitempty"`
ThreatAction string `json:"threat_action,omitempty"`
}
type RedirectInfo ¶
type RedirectInfo struct {
Command string `json:"command"`
Args []string `json:"args,omitempty"` // Prepended args
ArgsAppend []string `json:"args_append,omitempty"` // Appended args
Environment map[string]string `json:"environment,omitempty"` // Environment overrides
Reason string `json:"reason,omitempty"`
}
type Session ¶
type Session struct {
ID string `json:"id"`
State SessionState `json:"state"`
CreatedAt time.Time `json:"created_at"`
Workspace string `json:"workspace"`
WorkspaceMount string `json:"workspace_mount,omitempty"` // FUSE mount point (if active)
Policy string `json:"policy"`
Profile string `json:"profile,omitempty"`
Mounts []MountInfo `json:"mounts,omitempty"`
Cwd string `json:"cwd"`
VirtualRoot string `json:"virtual_root,omitempty"`
ProxyURL string `json:"proxy_url,omitempty"`
LLMProxyURL string `json:"llm_proxy_url,omitempty"`
DBProxySocketDir string `json:"db_proxy_socket_dir,omitempty"`
TOTPSecret string `json:"-"` // Hidden from JSON/API, used for TOTP approval mode
ProjectRoot string `json:"project_root,omitempty"`
GitRoot string `json:"git_root,omitempty"`
}
type SessionPatchRequest ¶
type SessionResult ¶
type SessionResult struct {
ExitCode int `json:"exit_code"`
Duration time.Duration `json:"duration"`
Stats SessionStats `json:"stats"`
Error string `json:"error,omitempty"`
}
SessionResult contains the final result of a session.
type SessionState ¶
type SessionState string
const ( SessionStatePending SessionState = "pending" // Created, not started SessionStateCreating SessionState = "creating" // Legacy: alias for starting SessionStateStarting SessionState = "starting" // Initializing sandbox SessionStateReady SessionState = "ready" // Legacy: alias for running SessionStateRunning SessionState = "running" // Agent is executing SessionStateBusy SessionState = "busy" // Command in progress SessionStatePaused SessionState = "paused" // Awaiting approval SessionStateStopping SessionState = "stopping" // Legacy: alias for terminating SessionStateTerminating SessionState = "terminating" // Graceful shutdown SessionStateCompleted SessionState = "completed" // Normal exit SessionStateFailed SessionState = "failed" // Error/crash SessionStateTimedOut SessionState = "timed_out" // Exceeded timeout SessionStateKilled SessionState = "killed" // Force terminated )
func (SessionState) IsActive ¶
func (s SessionState) IsActive() bool
IsActive returns true if the session is currently active.
func (SessionState) IsTerminal ¶
func (s SessionState) IsTerminal() bool
IsTerminal returns true if the session state is final.
type SessionStats ¶
type SessionStats struct {
// File operations
FileReads int64 `json:"file_reads"`
FileWrites int64 `json:"file_writes"`
BytesRead int64 `json:"bytes_read"`
BytesWritten int64 `json:"bytes_written"`
// Network operations
NetworkConns int64 `json:"network_conns"`
NetworkBytesTx int64 `json:"network_bytes_tx"`
NetworkBytesRx int64 `json:"network_bytes_rx"`
DNSQueries int64 `json:"dns_queries"`
// Environment operations
EnvReads int64 `json:"env_reads"`
// Policy enforcement
BlockedOps int64 `json:"blocked_ops"`
ApprovalsPending int `json:"approvals_pending"`
ApprovalsGranted int `json:"approvals_granted"`
ApprovalsDenied int `json:"approvals_denied"`
// Resource usage
CPUTimeMs int64 `json:"cpu_time_ms"`
PeakMemoryMB int64 `json:"peak_memory_mb"`
// Commands
CommandsExecuted int64 `json:"commands_executed"`
CommandsFailed int64 `json:"commands_failed"`
}
SessionStats tracks metrics for a session.
type Suggestion ¶
type TaintEvent ¶
type TaintEvent struct {
Type string `json:"type"` // taint_created, taint_propagated, taint_removed, agent_detected
PID int `json:"pid"`
SourcePID int `json:"source_pid,omitempty"`
SourceName string `json:"source_name,omitempty"`
ContextName string `json:"context_name,omitempty"`
Depth int `json:"depth,omitempty"`
IsAgent bool `json:"is_agent,omitempty"`
Confidence float64 `json:"confidence,omitempty"` // For agent_detected events
Timestamp time.Time `json:"timestamp"`
}
TaintEvent represents a taint-related event for streaming.
type TaintInfo ¶
type TaintInfo struct {
PID int `json:"pid"`
SourcePID int `json:"source_pid"`
SourceName string `json:"source_name"`
ContextName string `json:"context_name"`
IsAgent bool `json:"is_agent"`
Via []string `json:"via"`
ViaClasses []string `json:"via_classes"`
Depth int `json:"depth"`
InheritedAt time.Time `json:"inherited_at"`
}
TaintInfo contains information about a tainted process.
type TaintMatchedRule ¶
type TaintMatchedRule struct {
Name string `json:"name"`
Action string `json:"action"`
Message string `json:"message,omitempty"`
}
TaintMatchedRule represents a chain rule that matched during evaluation.
type TaintTrace ¶
type TaintTrace struct {
Taint *TaintInfo `json:"taint"`
MatchedRules []TaintMatchedRule `json:"matched_rules,omitempty"`
}
TaintTrace contains a full ancestry trace for a process.
type WrapInitRequest ¶
type WrapInitRequest struct {
AgentCommand string `json:"agent_command"`
AgentArgs []string `json:"agent_args,omitempty"`
CallerUID int `json:"caller_uid,omitempty"`
// CallerPID is the PID of the process invoking wrap. On macOS it becomes
// the session root the system extension attributes processes to: the agent
// is launched as its child and NOTIFY_FORK carries session membership down
// the tree. Ignored on Linux, where interception is per-process.
CallerPID int `json:"caller_pid,omitempty"`
// Mode selects wrap lifecycle. Both "agent" (default, used by
// `agentmon wrap`) and "shim" (used by the shell shim) currently use
// the server's existing accept-once-then-handler control flow — the
// listener goroutine accepts a single connection from the wrapper,
// hands the notify fd to the persistent notify-handler, and exits.
// The Mode field is plumbed for future use (e.g., distinct cleanup
// strategies) and as an explicit signal of intent at the call site.
// An empty string (field absent on the wire) is treated the same as
// "agent".
Mode string `json:"mode,omitempty"`
}
WrapInitRequest is sent by the CLI or shim to initialize seccomp wrapping for a session.
type WrapInitResponse ¶
type WrapInitResponse struct {
PtraceMode bool `json:"ptrace_mode,omitempty"`
SafeToBypassShellShim bool `json:"safe_to_bypass_shell_shim"`
WrapperBinary string `json:"wrapper_binary"`
StubBinary string `json:"stub_binary,omitempty"`
SeccompConfig string `json:"seccomp_config"`
NotifySocket string `json:"notify_socket"`
SignalSocket string `json:"signal_socket,omitempty"`
WrapperEnv map[string]string `json:"wrapper_env"`
// EnvInject carries operator-configured sandbox.env_inject values for the
// client (shell shim / CLI wrap) to overlay onto the executed command's
// environment. On the client-spawned wrap path the server does not build
// the child env itself, so these must be plumbed through the response and
// applied client-side; on the server-spawned exec path env_inject is
// applied directly in internal/api/exec.go instead. Issue #374.
EnvInject map[string]string `json:"env_inject,omitempty"`
// EnvPolicy carries the resolved env allow/deny for the client to
// filter the executed command's inherited environment, when
// sandbox.wrap_env_policy.enabled is set. Nil ⇒ no filtering. Issue #379.
EnvPolicy *EnvPolicyWire `json:"env_policy,omitempty"`
}
WrapInitResponse returns the seccomp wrapper configuration to the caller.
To decide whether to install kernel filters, the caller MUST inspect the presence of WrapperBinary (and NotifySocket): both populated means install; either empty means skip. Do not infer install/skip from a single boolean field — it is impossible to distinguish a deliberate "skip" from an old server that omits the field, and treating an absent field as "skip" would silently bypass enforcement in mixed-version deployments. The presence-of-WrapperBinary check is fail-closed: an old server that knows nothing about Mode==shim still returns its standard populated response, which the caller installs from.