Skip to main content

Module context

Module context 

Source
Expand description

L1 compute context — primitive-facing interface for Action compute().

ActionContext<'i> carries the per-tick state an Action needs to produce effects: derived entity id generator, EventRecord buffer, Op accumulator (bridges into the L0 dispatch path), principal / caps, idempotency-key lookup.

§L0 bridge model

Each compute() invocation accumulates L0 Ops (SpawnEntity / SetComponent / RemoveComponent / EmitEvent / …) into an internal Vec<Op>. The L2 service layer (RuntimeService in arkhe-forge-platform; reference by name only — forge-core does not import forge-platform, layer-independence directive) drives the Kernel::submit + Kernel::step loop; the kernel-side ActionCompute impl emitted by #[derive(ArkheAction)] invokes crate::bridge::kernel_compute, which reconstructs a fresh ActionContext from the kernel’s read-only context view, runs the forge compute() body, and returns the drained Vec<Op> to the kernel. The kernel performs authorize → dispatch → WAL append on its own internal Effect<'i, _> lifecycle (the Effect constructor and authorize function are kernel-private in v0.13, by design).

§'i brand

The 'i lifetime parameter is currently a phantom on the public API surface, reserved for a future L0 expansion that exposes the Effect<'i, _> brand to the L2 service layer. Kernel v0.13 keeps the Effect brand internal, so the forge-side 'i cannot be wired to a kernel-side Effect<'i, _> cross-call. The phantom position is preserved on the public API so a later release can switch from phantom to real-brand without breaking signatures.

Structs§

ActionContext
Per-Action compute context.
EventRecord
Deterministic event record — what emit_event accumulates per tick before the pipeline drains them into the WAL Op::EmitEvent stream.

Enums§

ActionError
Taxonomy of compute-time rejections. ActionCompute::compute returns Result<(), ActionError>; the pipeline converts these to rejection records while preserving deterministic bytes (no panicking paths).

Traits§

ActorHandleIndex
L2-provided (shell_id, handle) → ActorId index, backing E-actor-3 uniqueness enforcement.
IdempotencyIndex
L2-provided dedup backend — resolves idempotency keys to prior (EntityId, Tick) assignments.