Expand description
§solti-model
Shared resource model for Solti agents and control planes.
This crate defines task resources, workloads, policies, selectors, queries, output events, capabilities, and bearer tokens. It does not execute tasks or own resource storage.
§Start Here
Use TaskManifest for caller-owned desired state.
Use Task for a stored resource with server metadata and status.
Use TaskSpec to describe execution.
Use TaskWorkload to select a built-in or extension workload.
§Resource Flow
caller
│ TaskManifest
▼
Task::from_manifest ── generates uid and creationTimestamp
│ └─ starts generation at 1
▼
Task
├── metadata: ObjectMeta
├── spec: TaskSpec
├── status: TaskStatus
│
└── state store assigns resourceVersionThe model validates values and applies state transitions. Storage, reconciliation, execution, and transport stay in higher layers.
§Features
The default schema feature implements schemars::JsonSchema for resource, workload, selector, capability, and output types.
Disable default features when schema generation is not needed.
Runtime validation remains authoritative for cross-field and byte-budget rules.
§Quick Start
Build a task spec:
use solti_model::{
Flag, SubprocessMode, SubprocessSpec, TaskEnv, TaskSpec, TaskWorkload,
};
let workload = TaskWorkload::Subprocess(SubprocessSpec::new(
SubprocessMode::Command {
command: "echo".into(),
args: vec!["hello".into()],
},
TaskEnv::default(),
None,
Flag::enabled(),
));
let spec = TaskSpec::builder("hello", workload, 5_000u64)
.build()
.expect("valid spec");
spec.validate().expect("valid spec");
assert_eq!(spec.slot().as_str(), "hello");Create a stored task resource:
use solti_model::{EmbeddedSpec, Task, TaskPhase, TaskSpec, TaskWorkload};
let workload = TaskWorkload::Embedded(EmbeddedSpec::new("v1").unwrap());
let spec = TaskSpec::builder("cleanup", workload, 1_000u64)
.build()
.unwrap();
let task = Task::new("embedded-cleanup-1", spec).unwrap();
assert_eq!(*task.phase(), TaskPhase::Pending);
assert_eq!(task.name().as_str(), "embedded-cleanup-1");TaskWorkload::Embedded is valid in the shared model.
API and runner layers apply their own admission rules.
§Resource Model
Task
apiVersion, kind
metadata: ObjectMeta
spec: TaskSpec
status: TaskStatus
TaskSpec
slot, workload, timeout, restart, backoff, admission
max_retries, runner_selector
TaskStatus
observed_generation, conditions, phase, attempt, exit_code, errorTaskSpec is desired state.
TaskStatus is observed state.
ObjectMeta carries identity, versions, labels, annotations, and timestamps.
§Lifecycle
Pending ──▶ Running ──▶ Succeeded
├────────▶ Failed
├────────▶ Timeout
└────────▶ Canceled
Failed | Timeout ── retry budget exhausted ──▶ ExhaustedTerminal phases are Succeeded, Failed, Timeout, Canceled, and Exhausted.
See TaskPhase::is_terminal.
§Task Workloads
TaskWorkload describes what a task runs:
| Kind | Meaning | Routed by runner |
|---|---|---|
Subprocess | Host command or script | yes |
Container | OCI image | yes |
Wasm | WASI module | yes |
Embedded | In-process task | no |
Extension | Application-defined | yes |
Routable variants are consumed by solti-runner.
Embedded workloads bypass runner routing.
§Selectors
LabelSelector matches runner labels. All requirements are ANDed:
use solti_model::{Labels, LabelSelector, SelectorRequirement};
let selector = LabelSelector {
match_labels: {
let mut labels = Labels::new();
labels.insert("zone", "eu");
labels
},
match_expressions: vec![SelectorRequirement::exists("gpu")],
};
let mut runner = Labels::new();
runner.insert("zone", "eu");
runner.insert("gpu", "h100");
assert!(selector.matches(&runner));§Auth
Token wraps a bearer secret.
Its Debug output is redacted.
Token::verify uses a constant-time comparison for equal-length values.
§Main Types
| Area | Types |
|---|---|
| Resource | Task, TaskManifest, TaskSpec, TaskStatus, ObjectMeta, TaskRun |
| Identity | Slot, TaskId, AgentId, Uid |
| Workload | TaskWorkload, ExtensionWorkload, SubprocessSpec, WasmSpec, ContainerSpec |
| Policies | RestartPolicy, BackoffPolicy, JitterPolicy, AdmissionPolicy, Timeout |
| Selection | Labels, LabelSelector, SelectorRequirement, SelectorOperator |
| Capabilities | AgentCapabilities, RunnerCapability, WorkloadTypeMeta |
| Query | TaskContinuation, TaskFilter, TaskQuery, TaskPage, TaskWatchEvent |
| Output | OutputEvent, OutputChunk, StreamKind |
| Auth | Token |
| Errors | ModelError, ModelResult |
§See Also
solti-runnerconsumesTaskSpecandTaskWorkloadto build executable tasks.solti-coremanagesTasklifecycle and state transitions.solti-apiserializes model types over gRPC and HTTP.
Structs§
- Agent
Capabilities - Immutable snapshot of agent execution capabilities.
- AgentId
- Caller-provided identifier for a Solti agent.
- Annotations
- Key-sorted, free-form resource metadata.
- Backoff
Policy - Exponential backoff configuration for task restart delays.
- Container
Spec - Specification for OCI-compatible container execution.
- Embedded
Spec - Desired state of an embedded task implementation.
- Extension
Workload - GVK envelope for an application-provided workload.
- Flag
- Boolean flag with explicit enable/disable constructors.
- KeyValue
- Key-value pair used for environment variables or generic metadata.
- Label
Selector - Label selector for matching any labeled object.
- Labels
- Structured key-value metadata based on
BTreeMap. - Labels
Iter - Iterator over
Labelsyielding(&str, &str)pairs. - Object
Meta - Identity, concurrency version, generation and user metadata for a task.
- Output
Chunk - Output bytes from one task run.
- Runner
Capability - One registered runner and the workload GVKs it can execute.
- Selector
Requirement - Single set-based requirement for label matching.
- Slot
- Logical identifier for a controller slot.
- Subprocess
Spec - Specification for subprocess execution on the host.
- Task
- Stored Task resource.
- Task
Condition - One observed condition for a Task resource.
- Task
Condition Type - Stable and extensible type of condition reported for a
Task. - Task
Continuation - Position of the next page in one Task collection snapshot.
- TaskEnv
- Environment variables passed to a task at submission time.
- Task
Filter - Filters shared by task list and watch operations.
- TaskId
- Stable name used to address a task resource.
- Task
Manifest - Caller-owned desired state for create and apply.
- Task
Manifest Meta - User-owned metadata accepted in a
TaskManifest. - Task
Page - One page from a Task collection snapshot.
- Task
Query - Query parameters for filtered, snapshot-consistent Task listing.
- TaskRun
- Record of one execution attempt.
- Task
Spec - Desired state for a task.
- Task
Spec Builder - Builder for
TaskSpec. - Task
Status - Observed runtime state of a task.
- Timeout
- Timeout value in milliseconds.
- Token
- Validated bearer token.
- Type
Meta - Group/version and kind of resource schema.
- Uid
- Opaque, server-assigned identity of one resource incarnation.
- Wasm
Spec - Specification for WebAssembly module execution via a WASI-compatible runtime.
- Workload
Type Meta - Group/version and kind of one workload schema.
- Write
Preconditions - Optional identity and version checks for a resource write.
Enums§
- Admission
Policy - Admission behavior for a busy slot.
- Condition
Status - Condition status.
- Desired
Change - Classification of an apply operation.
- Jitter
Policy - Jitter applied to a backoff delay.
- Model
Error - Error type for parsing and validating model values.
- Output
Event - Event in a task live-output stream.
- Restart
Policy - Policy for starting another attempt.
- Selector
Operator - Set-based operator for
super::SelectorRequirement. - Stream
Kind - Standard stream that produced a chunk.
- Subprocess
Mode - Execution strategy for a subprocess task.
- Task
Phase - Current execution phase of a task.
- Task
Watch Event - One change emitted by a task watch.
- Task
Workload - Executable desired state nested in a
TaskSpec.
Constants§
- AGENT_
ID_ MAX_ LEN - Maximum length of an
AgentId. - DEFAULT_
LIMIT - Default page size when the caller does not specify one.
- MAX_
LIMIT - Hard cap on page size.
- MAX_
SCRIPT_ BODY_ BYTES - Maximum decoded script body size.
- SLOT_
MAX_ LEN - Maximum length of a
Slotidentifier. - TASK_
API_ VERSION - API group and version of the built-in Task resource.
- TASK_
API_ VERSION_ MAJOR - Major version of the built-in Task resource API.
- TASK_
ID_ MAX_ LEN - Maximum length of a
TaskId. - TASK_
KIND - Kind of the built-in Task resource.
- WORKLOAD_
API_ VERSION - API group and version of built-in Solti workloads.
Type Aliases§
- Model
Result - Convenience alias for
Result<T, ModelError>.