Expand description
EngineState — the single Mutex-guarded state object — plus the
supporting types.
EngineState holds every mutable piece of engine flow state (task
table, session table, prompts, token records, worker handles, resume
table, per-task notifiers, resources, per-attempt output events, and the
event log tail). It sits on the Domain side of the Data / Domain split
and is unchanged by the Data-plane (output_store module) refactor.
Structs§
- Agent
CtxEntry - One
(task_id, attempt)entry ofEngineState::agent_ctx— the materializedcrate::core::agent_context::AgentContextView(Contract C, GH #20) and the effectivemlua_swarm_schema::ContextPolicyAgentContextMiddlewarealready applied to it (projection-adapterST5), folded into one struct (GH #23) so the two values — written together at the same single insert site — can no longer drift apart. - CapToken
Record - Server-side counter/state holder paired 1:1 with a minted
CapToken(keyed by nonce inEngineState.tokens). Tracks remaining uses, revocation, and — for Worker tokens — the task the token is bound to. - Engine
State - The single
Mutex-guarded blob of engine flow state, accessed only throughEngine::with_state(see the R1-R4 discipline documented there). - Operator
Session - Persisted record of one attached Operator session: identity, role,
heartbeat bookkeeping, owned tasks, and the
OperatorKindcascade inputs plus registry IDs used to rebuildOperatorInfoon dispatch (seeEngine::resolve_operator_info). - Resume
Key - Opaque handle identifying one
query_seniorsuspend/resumecycle. Stored onTaskState.suspended_onand as the key ofEngineState.pending_resumes. - Resume
Pending - Entry for a task suspended via
query_senior, waiting to be resumed. - Task
Spec - Static task definition supplied to
start_task: which agent runs it and the initial prompt/directive value. - Task
State - The full mutable record of one task: its static
spec, currentstatus, attempt counter, and bookkeeping timestamps. Cloned out ofEngineStateon every read (e.g. byread_task_state/poll_task).
Enums§
- CapToken
Consume Error - Why
CapTokenRecord::consumerefused to spend a use. - Dispatch
Outcome - Result of a
dispatch_attempt_withcall (or the conceptual outcome of a task attempt more broadly). - Event
- Engine lifecycle event. Every event is both appended to
EngineState.event_log_tail(in-process ring buffer) and broadcast onEngine::event_txfor live subscribers. - Submit
Outcome - GH #76 Skip tier: the completion tier a caller of
crate::core::engine::Engine::submit_worker_result_trustedsignals alongside itsvalue. Sibling toDispatchOutcome(the engine-side outcome enum) — this one is the CALLER’s intent enum, whereasDispatchOutcomeis the reduced outcome the engine derives from the completed attempt. - Task
Status - Lifecycle state of a task.
Pendingis the only non-terminal, non-Suspendedstate before the firstdispatch_attempt_with;Pass/Blocked/Cancelledare terminal.
Constants§
- SKIP_
MARKER_ KEY - Reserved sentinel key used by
wrap_skip_marker/is_skip_markerto encode aDispatchOutcome::Skippayload as a plainserde_json::Value(GH #76 Skip tier: Skip tier). Documented as a reserved key on the wire: an ordinary worker payload MUST NOT contain a top-level object field named"__mse_skip".
Functions§
- is_
skip_ marker - Return
truewhenvis an object with{ "__mse_skip": true }set — the sentinel shapewrap_skip_markerproduces. Used by the dispatcher (and the flow-ir binding boundary in future subtasks) to route a Skip completion out of the ordinary Pass/Blocked value path. - unwrap_
skip_ marker - If
vis a skip-marker sentinel (seeis_skip_marker), return the carried inner value cloned out of the"value"field (orValue::Nullwhen the field is absent — a malformed sentinel is still a skip signal with no payload). ReturnsNoneotherwise, so the caller can fall back to the ordinary Pass/Blocked path. - wrap_
skip_ marker - Wrap
vin the reserved{ "__mse_skip": true, "value": v }sentinel shape produced by aSubmitOutcome::Skipsubmission and consumed byis_skip_marker/unwrap_skip_markeron the read side. SeeSKIP_MARKER_KEYfor the reserved-key contract.
Type Aliases§
- Event
Stream - Receiver half of the engine-wide
Eventbroadcast channel, obtained viaEngine::subscribe.