mlua_swarm/store/run/mod.rs
1//! `RunStore` — persistence for `Run` records (one kick of a `Task`).
2//!
3//! Part of the issue #13 ID-hierarchy reconciliation: Blueprint -> Task ->
4//! Run -> Step -> Attempt. A [`RunId`](crate::types::RunId) is minted
5//! server-side each time a [`crate::store::task::TaskRecord`] is kicked; it
6//! carries a lightweight trace of the steps dispatched during that kick
7//! ([`StepEntry`]) for observability, plus its own outcome status
8//! independent of the owning Task's coarser status. A single Task can have
9//! N `Run`s over its lifetime (`list_by_task`).
10//!
11//! Current scope:
12//!
13//! - [`InMemoryRunStore`] — process-volatile default.
14//! - [`SqliteRunStore`] — file-backed persistence via `rusqlite-isle`.
15//! `step_entries` is a JSON column, not normalized into its own table —
16//! this is a trace/observability artifact, not something queried
17//! relationally.
18//! - Other persistent backends (Git / mini-app / …) are future carries.
19
20use crate::blueprint::BindingDigest;
21use crate::store::replay::{ReplayCursor, ReplayStore};
22use crate::types::{RunId, StepId, TaskId};
23use async_trait::async_trait;
24use serde::{Deserialize, Serialize};
25use std::collections::HashMap;
26use std::sync::{Arc, Mutex};
27use thiserror::Error;
28
29pub mod inmemory;
30pub mod sqlite;
31pub use inmemory::InMemoryRunStore;
32pub use sqlite::SqliteRunStore;
33
34// ──────────────────────────────────────────────────────────────────────────
35// RunStatus / StepEntry / RunRecord
36// ──────────────────────────────────────────────────────────────────────────
37
38/// Lifecycle status of a [`RunRecord`] — the outcome of one specific kick
39/// of a Task.
40#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize, schemars::JsonSchema)]
41#[serde(rename_all = "snake_case")]
42pub enum RunStatus {
43 /// Minted, not yet dispatched.
44 Pending,
45 /// Steps are currently being dispatched for this Run.
46 Running,
47 /// The Run completed successfully.
48 Done,
49 /// The Run failed.
50 Failed,
51 /// The Run was still `Running` when the server process restarted
52 /// (issue #35 ST2 boot-time recovery sweep). Terminal — in-flight
53 /// `EngineState` is process-local and unrecoverable; this variant
54 /// records the fact without attempting to reconstruct or resume it.
55 Interrupted,
56}
57
58/// One worker-reported degradation entry — a worker fell back to a
59/// substitute behavior instead of failing outright (e.g. a tool call errored
60/// and the worker used a cached/default value). Independent channel from
61/// [`StepEntry`]/`result_ref`: degradations never flow through step OUTPUT
62/// or the fold path (GH #32; sibling of the GH #34 audit sidecar — both
63/// keep observational signal off the BP-chain value). Reported via `POST
64/// /v1/worker/degradation`; the server injects `step_ref`/`attempt`/`at`
65/// before persisting.
66#[derive(Debug, Clone, Serialize, Deserialize, schemars::JsonSchema)]
67pub struct DegradationEntry {
68 /// The tool (or capability) the worker attempted to use.
69 pub tool: String,
70 /// The error that triggered the fallback, in the worker's own words.
71 pub error: String,
72 /// What the worker substituted instead of failing.
73 pub fallback: String,
74 /// Optional free-form context from the worker.
75 #[serde(default, skip_serializing_if = "Option::is_none")]
76 pub note: Option<String>,
77 /// The Blueprint step ref (`Step.ref`) this degradation was reported
78 /// under, if known. Server-injected metadata, not worker-supplied.
79 #[serde(default, skip_serializing_if = "Option::is_none")]
80 pub step_ref: Option<String>,
81 /// The attempt number this degradation was reported under, if known.
82 /// Server-injected metadata, not worker-supplied.
83 #[serde(default, skip_serializing_if = "Option::is_none")]
84 pub attempt: Option<u32>,
85 /// Unix epoch seconds — when this entry was recorded. Server-injected.
86 pub at: u64,
87}
88
89/// One entry in a Run's step trace — appended as the engine dispatches
90/// (and finishes) each step. Purely observational: no field here is
91/// consulted for flow control.
92#[derive(Debug, Clone, Serialize, Deserialize, schemars::JsonSchema)]
93pub struct StepEntry {
94 /// The step this entry traces.
95 #[schemars(with = "String")]
96 pub step_id: StepId,
97 /// The Blueprint step ref (`Step.ref`) that was dispatched, if known.
98 pub step_ref: Option<String>,
99 /// Free-form status label for this step at the time the entry was
100 /// recorded (e.g. `"dispatched"`, `"passed"`, `"blocked"`).
101 pub status: Option<String>,
102 /// Immutable Runner/Agent/Context snapshot digest used for this step.
103 /// `None` for rows created before BoundAgent launch wiring.
104 #[serde(default, skip_serializing_if = "Option::is_none")]
105 pub binding_digest: Option<BindingDigest>,
106 /// Unix epoch seconds — when this entry was recorded.
107 pub at: u64,
108}
109
110/// One persisted `Run` row — one kick of a [`crate::store::task::TaskRecord`].
111#[derive(Debug, Clone, Serialize, Deserialize, schemars::JsonSchema)]
112pub struct RunRecord {
113 /// Run identifier.
114 #[schemars(with = "String")]
115 pub id: RunId,
116 /// The Task this Run was kicked from.
117 #[schemars(with = "String")]
118 pub task_id: TaskId,
119 /// Current lifecycle status.
120 pub status: RunStatus,
121 /// Trace of dispatched steps, in append order.
122 pub step_entries: Vec<StepEntry>,
123 /// Worker-reported degradations, in append order (GH #32). Independent
124 /// channel from [`Self::step_entries`]/[`Self::result_ref`] — see
125 /// [`DegradationEntry`]'s doc for the invariant. `[]` (the default) =
126 /// no degradations reported — every pre-#32 Run is unaffected.
127 #[serde(default, skip_serializing_if = "Vec::is_empty")]
128 pub degradations: Vec<DegradationEntry>,
129 /// Operator session id bound to this Run, if any (WS operator
130 /// correlation).
131 pub operator_sid: Option<String>,
132 /// The Run's terminal result payload, set once by
133 /// [`RunStore::set_result`]. `None` while the Run is in flight.
134 #[schemars(with = "Option<serde_json::Value>")]
135 pub result_ref: Option<serde_json::Value>,
136 /// Opaque JSON snapshot of the launch input this Run was kicked with
137 /// (blueprint / init_ctx / operator injection / ttl / …). The server
138 /// serializes its own launch-input struct into this string at Run
139 /// creation time so an `Interrupted` Run can be resumed under the SAME
140 /// `run_id` without re-deriving the input from a since-stale request
141 /// body. The store treats it as an opaque blob — the schema is owned by
142 /// the caller (the server crate). `None` = no snapshot recorded (older
143 /// rows predating resume support, or a caller that never opts in); such
144 /// a Run cannot be resumed. Additive with `#[serde(default)]` so
145 /// pre-existing serialized rows deserialize unchanged.
146 #[serde(default, skip_serializing_if = "Option::is_none")]
147 pub input_json: Option<String>,
148 /// Unix epoch seconds — creation time.
149 pub created_at: u64,
150 /// Unix epoch seconds — last update time.
151 pub updated_at: u64,
152}
153
154/// Errors surfaced by a [`RunStore`] implementation.
155#[derive(Debug, Error)]
156pub enum RunStoreError {
157 /// No Run exists for the given id.
158 #[error("run not found: {0}")]
159 NotFound(RunId),
160
161 /// `create` was called with an id that is already stored.
162 #[error("run already exists: {0}")]
163 Duplicate(RunId),
164
165 /// Backend-specific failure not covered by the other variants.
166 #[error("other: {0}")]
167 Other(String),
168}
169
170/// The provenance of a Run snapshot's `bound_agents` array.
171///
172/// Persisted as the [`BOUND_AGENTS_ORIGIN_KEY`] sibling of `bound_agents`
173/// inside the opaque [`RunRecord::input_json`] blob. This is Run-store
174/// metadata, **not** a schema-crate Blueprint wire type: it never enters
175/// [`crate::blueprint::BoundAgent`], `BoundAgentDigestInput`, or any digest
176/// computation. It lives here beside [`RunContext`] — rather than in
177/// `crate::service::task_launch` — because both the domain launch service
178/// (which writes it) and the server crate's bindings-explain handler (which
179/// reads it) consume it, and both already depend on this module; parking it
180/// in the service module would force the server crate to reach into a
181/// service-private type.
182#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize, schemars::JsonSchema)]
183#[serde(rename_all = "snake_case")]
184pub enum SnapshotOrigin {
185 /// `bound_agents` were resolved and pinned at the Run's initial launch —
186 /// the binding identity is the launch-time pin.
187 Launch,
188 /// `bound_agents` were backfilled from the current Blueprint when a
189 /// pre-binding-snapshot Run was resumed or reran. The binding identity
190 /// carries no launch-time pin guarantee.
191 ResumeBackfill,
192}
193
194/// JSON key the [`SnapshotOrigin`] is persisted under, beside `bound_agents`,
195/// in [`RunRecord::input_json`].
196pub const BOUND_AGENTS_ORIGIN_KEY: &str = "bound_agents_origin";
197
198impl SnapshotOrigin {
199 /// Read the origin marker from a decoded launch snapshot. An absent (or
200 /// unparseable) [`BOUND_AGENTS_ORIGIN_KEY`] maps to
201 /// [`SnapshotOrigin::ResumeBackfill`] — the safe side: a snapshot whose
202 /// `bound_agents` were persisted before this marker existed cannot prove
203 /// they were pinned at launch, so it must not be reported as a launch pin
204 /// and (on the replay axis) must not have binding digests mixed into its
205 /// replay keys. Only test artifacts hit this case in practice — the
206 /// strict-binding series is unreleased, so no real snapshot predates the
207 /// marker.
208 pub fn from_snapshot(snapshot: &serde_json::Value) -> Self {
209 snapshot
210 .get(BOUND_AGENTS_ORIGIN_KEY)
211 .and_then(|v| serde_json::from_value::<SnapshotOrigin>(v.clone()).ok())
212 .unwrap_or(SnapshotOrigin::ResumeBackfill)
213 }
214}
215
216/// GH #76 error surface: single-slot breadcrumb the dispatcher writes when a step
217/// aborts the flow (currently: [`crate::core::state::DispatchOutcome::Blocked`]),
218/// so the surrounding [`crate::service::task_launch::TaskLaunchService::launch`]
219/// `map_err` closure can lift `failed_step` + `verdict_value` off the eval
220/// boundary into the structured [`crate::service::task_launch::TaskLaunchError::FlowEval`]
221/// variant. Sibling to `step_entries` (append-only per-step trace) — this
222/// slot is last-write-wins because only ONE aborting step matters for the
223/// eval's terminal error envelope, and flow-ir stops dispatching further
224/// steps after `EvalError::DispatcherError`.
225#[derive(Debug, Clone)]
226pub struct LastFailure {
227 /// The `StepId` (dispatch-time tid) the dispatcher assigned to the
228 /// aborting step.
229 pub step_id: StepId,
230 /// The Blueprint `Step.ref` that dispatched the aborting step, if
231 /// known (dispatcher fills this from its own `ref_` param — never `None`
232 /// on the current write path, but modeled `Option` because the
233 /// `LastFailure` shape is a public read surface and future breadcrumb
234 /// writers may not have a ref in hand).
235 pub step_ref: Option<String>,
236 /// The verdict value the aborting step carried
237 /// (e.g. `DispatchOutcome::Blocked(v)`'s `v`, cloned by the dispatcher
238 /// before mapping the outcome to `EvalError::DispatcherError`).
239 pub verdict_value: serde_json::Value,
240}
241
242/// Pairs a [`RunId`] with the [`RunStore`] used to persist its trace.
243///
244/// Threaded from the server entry points (`POST /v1/tasks`, `POST
245/// /v1/tasks/:id/runs`) down through `TaskApplication::handle_with_run` /
246/// `TaskLaunchService::launch` / `EngineDispatcher` (issue #13 run_id
247/// propagation) so every step the dispatcher runs can be appended to
248/// `RunRecord.step_entries` and the run's id exposed to workers via
249/// `Ctx.meta.runtime["run_id"]`. Kept as a distinct type — rather than a
250/// new field on `TaskApplicationInput` — so the pre-existing exhaustive
251/// struct literal in `mlua-swarm-cli`'s MCP adapter (`TaskApplicationInput
252/// { .. }`, no `run_ctx`) keeps compiling unchanged: callers that don't
253/// care about run tracing keep calling `TaskApplication::handle` /
254/// `TaskLaunchService::launch`, which pass `None` through internally.
255#[derive(Clone)]
256pub struct RunContext {
257 /// The Run this dispatch's steps should be traced into.
258 pub run_id: RunId,
259 /// Where to append [`StepEntry`] rows as steps are dispatched.
260 pub run_store: Arc<dyn RunStore>,
261 /// Optional [`ReplayStore`] the engine will append a Ctx-snapshot +
262 /// step-output row to after every completed step (see
263 /// [`crate::store::replay`] for the primitive). `None` (the default)
264 /// disables logging entirely — pre-replay callers keep their behavior
265 /// byte-for-byte.
266 pub replay_store: Option<Arc<dyn ReplayStore>>,
267 /// Optional [`ReplayCursor`] the engine consults BEFORE dispatching
268 /// each step. When present and the cursor has a matching row for
269 /// `(step_ref, input_hash, occurrence)`, the engine returns the
270 /// stored `DispatchOutcome::Pass(value)` verbatim and skips the
271 /// Adapter spawn — this is the replay-hit path. `None` (the default)
272 /// disables replay entirely.
273 pub replay_cursor: Option<Arc<Mutex<ReplayCursor>>>,
274 /// Run-pinned replay identity component, keyed by logical agent name.
275 pub binding_digests: Arc<HashMap<String, BindingDigest>>,
276 /// Whether this dispatch is a resume / rerun-from of an existing Run
277 /// rather than an initial launch. `false` (the default) marks an initial
278 /// launch. Set to `true` ONLY by the server's resume and rerun-from
279 /// handlers — it is the sole, explicit signal that decides a backfilled
280 /// snapshot's [`SnapshotOrigin`] (never inferred from replay-cursor or
281 /// step-entry state, whose wiring is free to change).
282 pub resume: bool,
283 /// GH #76 error surface: shared single-slot breadcrumb the dispatcher writes when
284 /// a step aborts the flow (`DispatchOutcome::Blocked` → `EvalError`).
285 /// Read by the enclosing [`crate::service::task_launch::TaskLaunchService::launch`]
286 /// `map_err` closure to populate the structured
287 /// [`crate::service::task_launch::TaskLaunchError::FlowEval`] variant's
288 /// `failed_step` / `verdict_value` fields. `None` (the default) means
289 /// no aborting step was recorded — either the run succeeded, or an
290 /// error path fired that does not go through the dispatcher's Blocked
291 /// arm (e.g. `EvalError` raised by flow-ir itself before dispatch).
292 /// Behind `std::sync::Mutex` to match the `replay_cursor` sibling
293 /// (same crate-level convention — dispatcher writes are short critical
294 /// sections, no `.await` held across).
295 pub last_failure: Arc<Mutex<Option<LastFailure>>>,
296}
297
298impl RunContext {
299 /// Construct a `RunContext` with just the RunStore wired — the same
300 /// shape all pre-replay callers use (`replay_store` / `replay_cursor`
301 /// both `None`). Preserved as a convenience so a caller that never
302 /// opts into replay can keep constructing `RunContext` positionally.
303 pub fn new(run_id: RunId, run_store: Arc<dyn RunStore>) -> Self {
304 Self {
305 run_id,
306 run_store,
307 replay_store: None,
308 replay_cursor: None,
309 binding_digests: Arc::new(HashMap::new()),
310 resume: false,
311 last_failure: Arc::new(Mutex::new(None)),
312 }
313 }
314
315 /// GH #76 error surface: write the aborting-step breadcrumb (last-write-wins).
316 /// Called by [`crate::blueprint::EngineDispatcher::dispatch`]'s Blocked
317 /// arm BEFORE it maps the outcome to `EvalError::DispatcherError`.
318 /// Silently succeeds if the mutex is poisoned — this is an
319 /// observability breadcrumb, not a load-bearing invariant, and a
320 /// poisoned mutex here must never prevent the primary abort error
321 /// from propagating (same fail-open convention as the sibling
322 /// `append_step_entry` warn-and-swallow at
323 /// `EngineDispatcher::dispatch`).
324 pub fn set_last_failure(&self, failure: LastFailure) {
325 if let Ok(mut slot) = self.last_failure.lock() {
326 *slot = Some(failure);
327 }
328 }
329
330 /// GH #76 error surface: reconstruct a partial-ctx snapshot from the step-entry
331 /// trace persisted so far — the in-tree substitute for a full
332 /// `storage.snapshot()` from flow-ir (upstream carry).
333 ///
334 /// Shape: `{ "steps": { "<step_id>": { "step_ref": ..., "status": ...,
335 /// "binding_digest": ..., "at": ... } } }` — a JSON object keyed by
336 /// each dispatched `StepId` with its recorded [`StepEntry`] metadata.
337 /// This is metadata-level, NOT value-level (no `StepEntry` carries the
338 /// step's actual OUTPUT value; that requires upstream mlua-flow-ir
339 /// support to expose `storage.snapshot()` on error). Consumers who
340 /// need value-level partial ctx must wait for the upstream carry —
341 /// see the FlowEval `partial_ctx` field rustdoc.
342 ///
343 /// Returns `Value::Null` if the store lookup fails (e.g. the row was
344 /// deleted between dispatch and error surfacing) — the caller's
345 /// `partial_ctx: Option<Value>` field wraps this so `Null` is
346 /// distinguishable from "no snapshot attempt at all".
347 pub async fn snapshot_partial_ctx(&self) -> serde_json::Value {
348 let record = match self.run_store.get(&self.run_id).await {
349 Ok(r) => r,
350 Err(_) => return serde_json::Value::Null,
351 };
352 let mut steps = serde_json::Map::new();
353 for entry in &record.step_entries {
354 let mut fields = serde_json::Map::new();
355 if let Some(ref_) = &entry.step_ref {
356 fields.insert(
357 "step_ref".to_string(),
358 serde_json::Value::String(ref_.clone()),
359 );
360 }
361 if let Some(status) = &entry.status {
362 fields.insert(
363 "status".to_string(),
364 serde_json::Value::String(status.clone()),
365 );
366 }
367 if let Some(digest) = &entry.binding_digest {
368 fields.insert(
369 "binding_digest".to_string(),
370 serde_json::Value::String(digest.to_string()),
371 );
372 }
373 fields.insert("at".to_string(), serde_json::Value::Number(entry.at.into()));
374 steps.insert(entry.step_id.to_string(), serde_json::Value::Object(fields));
375 }
376 let mut out = serde_json::Map::new();
377 out.insert("steps".to_string(), serde_json::Value::Object(steps));
378 serde_json::Value::Object(out)
379 }
380
381 /// Builder-style setter: attach a [`ReplayStore`] to log every
382 /// completed step's Ctx snapshot + output into.
383 pub fn with_replay_store(mut self, store: Arc<dyn ReplayStore>) -> Self {
384 self.replay_store = Some(store);
385 self
386 }
387
388 /// Builder-style setter: attach a [`ReplayCursor`] the dispatcher
389 /// consults for a hit before dispatching each step.
390 pub fn with_replay_cursor(mut self, cursor: Arc<Mutex<ReplayCursor>>) -> Self {
391 self.replay_cursor = Some(cursor);
392 self
393 }
394
395 /// Attach immutable binding digests so replay keys distinguish the same
396 /// step/input executed under different Runner/Agent/Context snapshots.
397 pub fn with_binding_digests(mut self, digests: HashMap<String, BindingDigest>) -> Self {
398 self.binding_digests = Arc::new(digests);
399 self
400 }
401
402 /// Builder-style setter: mark this dispatch as a resume / rerun-from of
403 /// an existing Run (see [`Self::resume`]). Called only by the server's
404 /// resume and rerun-from handlers; every other construction site leaves
405 /// the default `false` (initial launch).
406 pub fn with_resume(mut self) -> Self {
407 self.resume = true;
408 self
409 }
410}
411
412impl std::fmt::Debug for RunContext {
413 // `dyn RunStore` carries no `Debug` bound (backend implementations
414 // shouldn't be forced to derive it just to satisfy this struct's
415 // `Debug`); render `run_store` as its `name()` instead, same idiom as
416 // `WorkerInvocation`'s manual `Debug` for its `Arc<dyn OutputSink>`
417 // field.
418 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
419 f.debug_struct("RunContext")
420 .field("run_id", &self.run_id)
421 .field("run_store", &self.run_store.name())
422 .field(
423 "replay_store",
424 &self.replay_store.as_ref().map(|s| s.name()),
425 )
426 .field("replay_cursor", &self.replay_cursor.is_some())
427 .field("binding_digests", &self.binding_digests.len())
428 .field("resume", &self.resume)
429 .field(
430 "last_failure",
431 &self.last_failure.lock().ok().and_then(|slot| slot.clone()),
432 )
433 .finish()
434 }
435}
436
437// ──────────────────────────────────────────────────────────────────────────
438// RunStore trait
439// ──────────────────────────────────────────────────────────────────────────
440
441/// Persistence interface for `Run` records — one kick of a Task, in the
442/// issue #13 ID hierarchy.
443#[async_trait]
444pub trait RunStore: Send + Sync {
445 /// Backend name — for diagnostics/logging.
446 fn name(&self) -> &str;
447
448 /// Create a new Run row. Returns `Duplicate` if `record.id` is already
449 /// stored.
450 async fn create(&self, record: RunRecord) -> Result<(), RunStoreError>;
451
452 /// Fetch a Run by id.
453 async fn get(&self, id: &RunId) -> Result<RunRecord, RunStoreError>;
454
455 /// List every Run kicked from `task_id`, ascending by `created_at`
456 /// (oldest kick first).
457 async fn list_by_task(&self, task_id: &TaskId) -> Result<Vec<RunRecord>, RunStoreError>;
458
459 /// Append one step-trace entry to a Run's `step_entries`, bumping
460 /// `updated_at` to now.
461 async fn append_step_entry(&self, id: &RunId, entry: StepEntry) -> Result<(), RunStoreError>;
462
463 /// Append one worker-reported degradation to a Run's `degradations`
464 /// (GH #32), bumping `updated_at` to now. Independent of
465 /// [`Self::append_step_entry`] — degradations never flow through step
466 /// OUTPUT/fold.
467 async fn append_degradation(
468 &self,
469 id: &RunId,
470 entry: DegradationEntry,
471 ) -> Result<(), RunStoreError>;
472
473 /// Update a Run's status, bumping `updated_at` to now.
474 async fn update_status(&self, id: &RunId, status: RunStatus) -> Result<(), RunStoreError>;
475
476 /// Atomically transition a Run's status from `from` to `to`, bumping
477 /// `updated_at` to now — the compare-and-set primitive the resume path
478 /// (`POST /v1/runs/:id/resume`) uses to guard against a double resume
479 /// racing the same `Interrupted` Run into `Running` twice.
480 ///
481 /// Returns `Ok(true)` when a row with this `id` AND current status
482 /// `from` was found and flipped to `to`; `Ok(false)` when the row's
483 /// current status was not `from` (a concurrent transition already won,
484 /// or the Run is absent). Never a hard error for the status-mismatch /
485 /// absent case — the boolean is the caller's race signal.
486 async fn try_transition(
487 &self,
488 id: &RunId,
489 from: RunStatus,
490 to: RunStatus,
491 ) -> Result<bool, RunStoreError>;
492
493 /// Set a Run's terminal `result_ref`, bumping `updated_at` to now.
494 async fn set_result(
495 &self,
496 id: &RunId,
497 result_ref: serde_json::Value,
498 ) -> Result<(), RunStoreError>;
499
500 /// Replace the opaque launch snapshot after pre-dispatch binding has
501 /// enriched it (for example with immutable `bound_agents`).
502 async fn set_input_json(&self, id: &RunId, input_json: String) -> Result<(), RunStoreError>;
503
504 /// List every Run currently `Running` (issue #35 ST2 boot sweep +
505 /// ST4 occupancy check reuse this). No ordering guarantee.
506 async fn list_running(&self) -> Result<Vec<RunRecord>, RunStoreError>;
507}
508
509// ──────────────────────────────────────────────────────────────────────────
510// Shared inner state used by the InMemory backend.
511// ──────────────────────────────────────────────────────────────────────────
512
513#[derive(Default)]
514pub(crate) struct Inner {
515 /// Insertion order — used as a stable tie-break under `list_by_task()`.
516 pub(crate) order: Vec<RunId>,
517 pub(crate) records: HashMap<RunId, RunRecord>,
518}
519
520pub(crate) type SharedInner = Mutex<Inner>;