1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
//! # 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
//!
//! ```text
//! caller
//! │ TaskManifest
//! ▼
//! Task::from_manifest ── generates uid and creationTimestamp
//! │ └─ starts generation at 1
//! ▼
//! Task
//! ├── metadata: ObjectMeta
//! ├── spec: TaskSpec
//! ├── status: TaskStatus
//! │
//! └── state store assigns resourceVersion
//! ```
//!
//! The 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:
//!
//! ```rust
//! 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:
//!
//! ```rust
//! 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
//!
//! ```text
//! 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, error
//! ```
//!
//! [`TaskSpec`] is desired state.
//! [`TaskStatus`] is observed state.
//! [`ObjectMeta`] carries identity, versions, labels, annotations, and timestamps.
//!
//! ## Lifecycle
//!
//! ```text
//! Pending ──▶ Running ──▶ Succeeded
//! ├────────▶ Failed
//! ├────────▶ Timeout
//! └────────▶ Canceled
//!
//! Failed | Timeout ── retry budget exhausted ──▶ Exhausted
//! ```
//!
//! Terminal 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:
//!
//! ```rust
//! 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-runner` consumes [`TaskSpec`] and [`TaskWorkload`] to build executable tasks.
//! - `solti-core` manages [`Task`] lifecycle and state transitions.
//! - `solti-api` serializes model types over gRPC and HTTP.
/// Compiles the runnable Rust code blocks in `README.md` as doctests.
;
pub use ;
pub use ;
pub use ;
pub use Token;