PTWM
chain

ptwm_core::chain::runtime

PPG DAG runtime — forward executor, inverse executor, fusion picker.

ptwm_core::chain::runtime

PPG DAG runtime — forward executor, inverse executor, fusion picker.

rsmod

ptwm_core::chain::runtime

crates/ptwm-core/src/chain/runtime.rs:1
mod runtime

PPG DAG runtime — forward executor, inverse executor, fusion picker.

rsfn

ptwm_core::chain::runtime::chain_terminal_descriptors

crates/ptwm-core/src/chain/runtime.rs:290
pub fn chain_terminal_descriptors(chain: &Chain) -> Result<Vec<PlaneDescriptor>, PtwmCoreError>

Recover the [`PlaneDescriptor`] of every chain terminal in `chain.terminals` order, without the original tensor bytes.

The reconstruction runs [`forward_chain`] over a **placeholder source buffer** of zero bytes (length matching the `Source` op's declared shape × dtype). Forward execution honours fusion, role overrides, and every op's actual descriptor flow, so the descriptors returned here match exactly what an end-to-end forward pass on the real tensor would produce. The decoder calls this to feed faithful `Plane` values into [`inverse_chain`]. Cross-tensor delta ops are out of scope here: the placeholder forward would need real dep planes. Chains containing `XorDelta` / `FloatDelta` cannot reconstruct terminal descriptors via this helper alone — the compressor driver owns that orchestration.
rsfn

ptwm_core::chain::runtime::forward_chain

crates/ptwm-core/src/chain/runtime.rs:106
pub fn forward_chain(chain: &Chain, ctx: &ForwardContext<'_>) -> Result<ForwardResult, PtwmCoreError>

Execute the chain in forward (encode) order.

Node 0 must be `Source`; its output wraps `ctx.source_bytes` in a `Plane`. Each subsequent node comes from `op_from_id`, and the runtime calls `forward` with the gathered input planes. Terminal refs collect at the end in `chain.terminals` order.
rstype

ptwm_core::chain::runtime::ForwardContext

crates/ptwm-core/src/chain/runtime.rs:85
pub struct ForwardContext

Context supplied by the caller for a forward (encode) pass.

`source_bytes` is borrowed: the runtime owns the single allocation that seeds node 0's `Plane`, sparing callers (e.g. multi-chain trial-encode) from cloning the raw tensor for every candidate.
rstype

ptwm_core::chain::runtime::ForwardResult

crates/ptwm-core/src/chain/runtime.rs:95
pub struct ForwardResult

Output of a forward pass.

rstype

ptwm_core::chain::runtime::FusedExecution

crates/ptwm-core/src/chain/runtime.rs:538
pub struct FusedExecution

A fused execution pair: producer node merged with consumer node.

rsfn

ptwm_core::chain::runtime::inverse_chain

crates/ptwm-core/src/chain/runtime.rs:354
pub fn inverse_chain(chain: &Chain, ctx: &InverseContext<'_>) -> Result<Plane, PtwmCoreError>

Execute the chain in inverse (decode) order, reconstructing the source plane.

The traversal walks nodes in reverse topological order. For each node, `op.inverse` runs on the node's output planes (from the working state) to reconstruct the input planes, then stores them under the corresponding source edges. After the traversal, the plane at `(0, 0)` is the reconstructed source.
rstype

ptwm_core::chain::runtime::InverseContext

crates/ptwm-core/src/chain/runtime.rs:339
pub struct InverseContext

Context supplied by the caller for an inverse (decode) pass.

rsfn

ptwm_core::chain::runtime::try_fuse_at

crates/ptwm-core/src/chain/runtime.rs:558
pub fn try_fuse_at(chain: &Chain, node_idx: u8) -> Option<FusedExecution>

Check whether `node_idx` is the CONSUMER in a fusable pair. If so, return a `FusedExecution` with `producer_node` set to the upstream node.

Conditions for fusion: 1. The connecting edge has no `role_override` and empty `vendor_bytes`. 2. No other edge or terminal consumes the producer's output. 3. The (producer.op, consumer.op) pair is in the fusion table.