interplane.Get Omega
Read in your language

aegis-runtime-mv

Native Rust agent runtime: Axum WebSocket/SSE/REST gateway, heartbeat scheduler, dependency-aware task workflow, SQLite storage. Attachment of AienOS. Pre-alpha.

Brought by drakestapleton

branch main Branches Tags History

aegis-runtime-mv / docs / WORKFLOW-DAG.md

67 lines · 8307 bytes Raw Blame History Source

Workflow DAG (issue #39)

A small dependency-aware task layer for multi-step agent work. It decides when a caller-supplied task may start. Nothing else.

Existing machinery

Inspected before writing any code.

AreaWhat exists
src/orchestration/run.rsOne Run with RunState {Running, WaitingForApproval, WaitingForTool, Completed, Failed, Cancelled}, step and action counters, a Trigger. A run is a single linear lifecycle.
src/orchestration/budget.rsRunBudget counters (steps, inference calls, actions, wall seconds) for one run.
src/orchestration/termination.rs, trigger.rsWhy a run ended; what started it.
src/agent.rsAgentEngine::execute_task: a sequential model/tool loop. Since #38 it classifies tool failures (FailureRecord), retries only idempotent no-effect cases, and stops on ApprovalPending.
src/failure.rs (#38)FailureClass, EffectCertainty, FailureRecord, CancelToken. Reused here.
src/events/{event,envelope,bus}.rsAegisEvent, EventEnvelope (has a sequence field), broadcast EventBus.
src/execution/{broker,action,receipt}.rsExecutionAuthority and action receipts: the only authority for effects.
src/sessions, tests/aegis_tests.rsIds (RunId, SessionId), stores, and the integration test conventions (tokio tests, scripted fakes).

Already present: the single-run lifecycle, approval-gate states, a per-run budget, cancellation tokens, failure vocabulary, events.

Absent before this change: prerequisite edges between tasks, readiness tracking, bounded concurrent execution of independent tasks, propagation of a prerequisite's failure to dependents, a workflow-level event order. No equivalent DAG exists, so src/orchestration/workflow.rs is new. It is not an inference scheduler: AIEN's aien-scheduler and the swarm manager are untouched and never called.

Model

Rules the executor enforces

Events and replay

Every transition takes a workflow sequence number under one lock, together with the state change, and is published in that same critical section. New AegisEvent variants: WorkflowTaskReady/Started/Completed/Waiting/Failed/Cancelled/Skipped, WorkflowFinished. They carry workflow_seq and go out with EventEnvelope.sequence set to it, so sorting by sequence replays the exact order. With max_parallel = 1 the whole order is fixed for a given spec; with more parallelism the order of simultaneous completions follows real completion order, but the sequence is still gapless and dependency-consistent. Existing variants are unchanged; the canonical mapping returns None for the new ones. The Uncertain task state (#55) has no bus variant yet (#55 item 4): its ledger event uncertain is written in sequence, and the bus stays silent rather than publish a false Failed or Cancelled. WorkflowStatus still reads Failed or Cancelled when a task is uncertain; the "needs reconciliation" status is #55 item 2, not in the first cut.

Results: WorkflowSnapshot.results maps task id to a sha256 digest of the result value. Failure records for Failed, Skipped and Cancelled tasks are in WorkflowReport.failures.

Agent adapter

AgentTaskRunner runs one AgentEngine::execute_task as a task; agent_outcome maps its result (failure class and certainty from the last tool failure, ApprovalPending stays pending, an incomplete run is Failed/Uncertain). It is a thin seam and is not exercised against a live model in tests.

Restart boundary

Workflow state is in memory only. After a process restart nothing is recovered and no task is resumed or re-run. WorkflowSnapshot is serializable (tested) so a later change can persist it, but no schema, table or recovery path exists. A resumed workflow must not re-run a task whose effect is Uncertain; that recovery policy is not designed here. Which record owns each fact of a delegated task, and the rebuild rule after a restart, are in DELEGATED-DAG.md. src/orchestration/recovery.rs (#56) implements that rebuild as a pure host function over an AuthorityLookup trait, tested against in-memory fakes; nothing stores the pointers yet and no real authority client exists.

Not claimed

AEGIS is outside release v1; nothing here is wired into a release path or the frozen E2E contract. Timings printed by the demo test compare max_parallel = 1 against 2 with sleep-based fake tasks on CPU. They are informational, and no GPU or throughput claim is made.

Progress messages for the Pi

src/orchestration/progress.rs (#58) maps recorded task state to the PST1 Draft v0 message types (aien-dev/aien-protocols-mv#28): Pending and Ready are queued; Skipped is failed with reason PREREQUISITE_FAILED; Uncertain, and Failed with Uncertain effect certainty, are uncertain_after_disconnect (not known), never failed. Ids come from the stored records, ordinals count each task's messages from 0, and a completed task carries its result digest, never raw output. A message that would need a guess (no cause id, no result digest, no action digest) is refused. The first cut has no encoding and no network; the resume summary and the bytes are later.

Grant gate for effectful tasks

src/orchestration/grant_gate.rs (#59) wraps an effectful task body. It starts only under a desk grant bound to the request's objective id and cause id, and checks the grant again after preparation, immediately before the effect. No grant leaves the task waiting for approval; an unbound binding, a forged id, a spent, expired or revoked grant, a foreign objective or cause, and an unreachable desk are refused with a named reason and no effect. The gate checks and never spends: the effect ledger spends the grant when it opens the effect intent. The desk is a trait tested with a fake; the real adapter waits on sovereign-core#379, and binding to the INTERPLANE canonical request digest waits on aien-protocols-mv#33.