Skip to main content

Module executor

Module executor 

Source
Expand description

AXON Runtime — Rust executor integration for typed channels (Fase 13.l).

The Python side (axon/runtime/executor.py) gained four dispatch branches in Fase 13.i + 13.j (emit_apply / publish_apply / discover_apply / listen_apply) so a flow’s channel surface executes end-to-end on the Python interpreter. The Rust crate exposed TypedEventBus standalone in 13.f.2, but a Rust-native flow runner that orchestrates IR steps had no equivalent integration: a Rust adopter who wanted to drive an IRProgram through the runtime had to wire the bus, value-ref resolution, and capability/alias scope by hand.

13.l closes that. This module provides:

  • RunContext: mirror of Python’s ContextManager for the typed-channel concern. Holds the per-unit TypedEventBus, discovered_handles, capabilities, and step results. Implements resolve_value_ref with the same lookup order (discovered handles ▶ variables ▶ step results) and dotted-access walk over both serde JSON values and String maps.
  • dispatch_emit / dispatch_publish / dispatch_discover / dispatch_listen: async functions that consume an IR step plus a &RunContext and route through TypedEventBus.
  • [bootstrap_run_context]: builds a RunContext from an IRProgram (registers every IRChannel on a fresh TypedEventBus).

The dispatch surface is intentionally byte-identical (in semantics) to the Python handlers: same lookup precedence for value_ref, same one-shot capability consumption, same alias binding rules. Rust adopters who want a fully-orchestrated axon run Rust binary can compose these primitives directly; a future sub-phase wires them into axon-rs/src/runner.rs::execute_real.

Structs§

RunContext
Per-unit run context — the Rust mirror of Python’s ContextManager for the typed-channel concern.

Enums§

DispatchError
Errors surfaced by the dispatch_* functions. Each variant tags the channel-op kind so adopters can route failures back to the originating IR step. Mirrors the channel_op:{op} details tag the Python AxonRuntimeError carries.
RunValue
A value reachable by value_ref during channel-op dispatch. Rust adopters fill the run context with whatever shape their step outputs use; we only require the two access modes the dotted-access resolver needs (mapping access by string key + nested handle/JSON).

Functions§

dispatch_discover
Execute an IRDiscover step. Pops the capability the matching publish recorded earlier in the unit, hands it to bus.discover, and binds the resulting handle under alias in the discovered- handles scope so subsequent emits / value_refs resolve it.
dispatch_emit
Execute an IREmit step against the run context.
dispatch_listen
Execute an IRListenStep step (free-standing in flow body — single- event receive). Subscribes to the channel, awaits one event, binds the payload under event_alias in the right scope (discovered_ handles for mobility, variables for scalar), and returns the payload so the caller can iterate ir.children (left to the outer orchestrator since IRListenStep.children is currently typed as Vec<IRFlowNode> and dispatch of arbitrary flow steps is the orchestrator’s job, not this module’s).
dispatch_publish
Execute an IRPublish step. Records the returned Capability in the context keyed by channel name so a later IRDiscover consumes it.