Skip to main content

Module sop

Module sop 

Re-exports§

pub use approval::ApprovalDecision;
pub use audit::SopAuditLogger;
pub use binding::BindingContext;
pub use binding::BindingRef;
pub use binding::BindingScope;
pub use binding::ExtractedBinding;
pub use binding::extract_bindings;
pub use binding::remap_step_refs;
pub use binding::resolve_args;
pub use capability::CapabilityContext;
pub use capability::CapabilityInfo;
pub use capability::CapabilityResult;
pub use capability::SopCapability;
pub use capability::SopCapabilityRegistry;
pub use engine::MaintenanceSummary;
pub use engine::SopEngine;
pub use engine::err_is_resume_at_capacity;
pub use executor::drive_resumed_broker_action;
pub use executor::spawn_headless_run_driver;
pub use graph::NodeRunOverlay;
pub use graph::RunOverlay;
pub use graph::SopGraphExt;
pub use graph::TextGraphFormat;
pub use graph::ToolSpecs;
pub use graph::render_graph_text;
pub use metrics::SopMetricsCollector;
pub use scope::StepToolScope;
pub use step_contract::StepFailure;
pub use step_contract::StepRouting;
pub use step_contract::SwitchRule;
pub use store::ClaimToken;
pub use store::PersistedRun;
pub use store::ProposalKind;
pub use store::ProposalRecord;
pub use store::ProposalStatus;
pub use store::SopEventRecord;
pub use store::SopRunStore;
pub use store::SqliteRunStore;
pub use store::StoreError;
pub use store::build_run_store;
pub use trigger_registry::BoundTriggerSource;
pub use trigger_registry::ChannelAlias;
pub use trigger_registry::ChannelTriggerKind;
pub use trigger_registry::ConditionField;
pub use trigger_registry::ConditionValueType;
pub use trigger_registry::ConfiguredChannel;
pub use trigger_registry::PayloadContract;
pub use trigger_registry::TriggerField;
pub use trigger_registry::TriggerFieldKind;
pub use trigger_registry::TriggerSourceRegistry;
pub use trigger_registry::build_registry;
pub use trigger_registry::registry_from_config;
pub use types::DeterministicRunState;
pub use types::DeterministicSavings;
pub use types::FilesystemEventKind;
pub use types::PlannedToolCall;
pub use types::Sop;
pub use types::SopEvent;
pub use types::SopExecutionMode;
pub use types::SopPriority;
pub use types::SopRun;
pub use types::SopRunAction;
pub use types::SopRunStatus;
pub use types::SopRunSummary;
pub use types::SopStep;
pub use types::SopStepKind;
pub use types::SopStepResult;
pub use types::SopStepStatus;
pub use types::SopTrigger;
pub use types::SopTriggerSource;
pub use types::StepSchema;
pub use types::StepToolCall;
pub use wire::WireEdit;
pub use wire::WireError;
pub use wire::WireOp;
pub use wire::apply_wire;

Modules§

active_scope
approval
Out-of-band SOP approval plane (EPIC C; EPIC G broker).
audit
binding
Argument bindings for planned tool calls. A string value inside a planned call’s args may embed {{steps.N.path}} (data captured from a prior step) or {{calls.K.path}} (an earlier call in the same step, zero-based). Extraction feeds strict-save validation; resolution substitutes live or pinned run data at execution/preview time.
capability
condition
dispatch
Unified SOP event dispatch helpers.
engine
executor
Live SOP action executor.
graph
Blueprint graph projection of a Sop.
metrics
procedural_memory
Procedural-memory proposal lifecycle for SOP definitions.
route
rundata
schema
scope
step_contract
store
Durable SOP run-state store (EPIC B) — the keystone contract.
trigger_registry
Trigger-source registry projected for the SOP authoring surfaces.
trigger_source
One matcher per SOP trigger source. SopTrigger::behavior is the only place that names every variant for matching; field specs are generated separately by the TriggerFields derive, so neither matching nor the authoring registry hand-lists a source. Add a variant and the compiler forces its arm here (matching) and the derive supplies its fields.
types
wire
Wire-edit application: translates a visual editor’s connect/disconnect gesture into the corresponding StepRouting/StepFailure mutation on a draft Sop. The graph is a projection; these edits write back to the source of truth it was projected from.

Structs§

GraphDiagnostic
A validation finding anchored to a step. Errors block saving (validate_sop_strict); warnings render but do not block.
GraphLayout
Deterministic auto-layout so every surface renders the same picture without a client-side layout engine.
GraphLegend
The canonical legend for the SOP canvas: flow-wire roles, pin classes, and run states. The single authority a surface reads to render a legend and per-handle/per-wire hover context, so no surface hardcodes these lists.
GraphNode
A node in the projected graph: one SOP step, or one synthetic trigger entry (step >= TRIGGER_NODE_BASE, trigger_index set).
GraphPin
One connection point on a node. Flow pins order execution; data pins carry the step’s declared input/output schema type.
GraphWire
A directed edge between two nodes. flow_role is set for flow wires; data wires carry the producer/consumer pin names instead.
LayoutGeometry
Canvas geometry carried on every serialized graph so the web canvas reads placement pitch from the wire instead of a local literal. The values are fixed by LayoutGeometry::CANONICAL; the struct rides on GraphLayout only to expose them to non-Rust surfaces.
LegendEntry
One legend row: a graph concept plus its human description. The stable key is the snake_case wire value the canvas maps tones/handles against.
NodePosition
Grid placement for one node: column = longest flow path from an entry, row = order of insertion within that column. x/y carry a persisted canvas coordinate when the node has been dragged; absent otherwise.
SopEngineAdapters
Injected side-effect adapters for build_sop_engine. Each is optional and fail-closed when absent: the route falls back to the log-only no-op adapter, and the forge.comment / llm.generate capabilities report a clear failure instead of acting. The daemon injects real implementations; CLI / standalone callers pass SopEngineAdapters::default().
SopGraph
The full projected graph: nodes, wires, validation diagnostics, and a precomputed layout. Serialized as-is over RPC (sops/graph) and HTTP.
SopValidation
Result of validate_sop_strict: blocking problems reject a save, warnings surface in editors but do not block.

Enums§

FlowRole
Why a flow wire exists. Mirrors the StepRouting/StepFailure field it was derived from, so an editor can write edits back to the right place.
GraphSeverity
NodeKind
NodeRunState
Per-node execution state projected from a run’s step results.
PinClass
SopAuthorError
Typed classification of an authoring failure so transports map it to the right status/RPC code without matching on stringified message substrings.

Constants§

TRIGGER_NODE_BASE
Node-id offset for synthetic trigger nodes, keeping them disjoint from real step numbers. Trigger i gets node id TRIGGER_NODE_BASE + i.

Functions§

build_sop_engine
Build a single shared SopEngine + SopAuditLogger pair. This is the sole construction site for SOP state within a daemon. Callers receive Arc<Mutex<SopEngine>> and Arc<SopAuditLogger> handles — never call SopEngine::new or SopAuditLogger::new directly outside this module.
create_sop
Create a new SOP on disk, refusing to overwrite an existing one. Same normalization and validation as save_sop.
create_sop_typed
delete_sop
Delete an SOP’s directory (manifest, steps, everything). Errors if no SOP with that name exists.
delete_sop_typed
extract_bold_title
Extract **title** from the beginning of text, returning (title, rest).
load_sop_by_name
Load a single SOP by directory name from the SOPs root. Errors if the directory or its SOP.toml is missing or malformed.
load_sops
Load all SOPs from the configured directory.
load_sops_from_directory
Load SOPs from a specific directory. Each subdirectory may contain SOP.toml (metadata + triggers) and SOP.md (procedure steps).
normalize_step_numbers
Renumber steps to a contiguous 1..=N sequence (positional order wins) and remap every internal reference: routing.next, depends_on, switch goto targets, and on_failure: goto. References to steps that no longer exist are dropped (goto falls back to Fail). No-op when step numbers are ambiguous (duplicates), since a remap would guess. Runs automatically inside save_sop.
parse_execution_mode
Parse an execution mode string into SopExecutionMode, falling back to Supervised for unknown values.
parse_steps
Parse procedure steps from SOP.md content. Expects a ## Steps heading followed by numbered items (1., 2., …). Each item’s first bold text (**...**) is the step title; the rest is body. Sub-bullets parse execution hints and dark per-step contract metadata.
render_steps
Render steps back to SOP.md markdown, the inverse of parse_steps. Every contract field (tools, scope, schema, routing, failure policy, mode) becomes a sub-bullet, so render -> parse is lossless.
resolve_sops_dir
Resolve the SOPs directory from config, falling back to workspace default.
run_overlay_for
Project the live run state for run_id onto sop’s graph. Errors if the run is unknown or the engine lock is poisoned.
run_summaries_for
Enumerate every run the engine holds (active + retained terminal), newest first, optionally scoped to one SOP. Errors only if the engine lock is poisoned. This is the Runs surface’s data source.
save_sop
Persist an SOP to <sops_dir>/<name>/ as SOP.toml + SOP.md. Normalizes step numbers first, then rejects the write entirely if strict validation finds blocking problems; nothing touches disk on failure.
tool_specs_from_config
Build the tool-spec map an SOP graph projection uses to type step pins. Keys are tool names; values are the tool’s declared parameters (input pins) and output (output pin) schema. Derived once from the agent’s resolved security policy so the pins mirror the exact tools the step can call, not a hand-authored list.
validate_sop
Validate a loaded SOP and return a list of warnings.
validate_sop_strict
Authoring-gate validation: empty name, empty step titles, and duplicate step numbers block, as do graph projection errors (dangling next / depends_on / switch / goto targets, unsatisfiable required inputs). Graph warnings and the legacy validate_sop findings are advisory.