Route#

class Route#

Which stages run for one request, decided once and then frozen.

Optional inputs and optional outputs are the same computation. Two passes, each exactly once – there is no fixed point to iterate towards:

forward available: topological order, prune a stage whose source is gone according to its OnMissing. Only propagates downstream. backward required: reverse order from the terminals the caller attached a sink to. Only propagates upstream. active = available AND required, then two checks.

The backward pass cannot undo the forward one: a stage the backward pass drops is by construction not upstream of any required stage. Iteration would only be needed if a stage’s survival depended on something downstream of it – a cycle, or a “required only when X is active” input. The topology has neither.

Public Functions

Route() = default#
inline std::vector<int32_t> const &order() const noexcept#

Topological order of the active stages.

inline std::vector<RouteEdge> const &edges() const noexcept#
bool isActive(int32_t stageIndex) const noexcept#
bool isActive(std::string const &stageId) const = delete#

A Route holds indices, not ids; resolve one with MultiStageConfig::stageIndex() first.

inline uint64_t fingerprint() const noexcept#

Two requests may share a batch only when these are equal.

inline std::vector<std::pair<int32_t, std::string>> const &skippedInputs(
) const noexcept#

Inputs of active stages whose source is absent from this route and whose OnMissing is kSkip.

Public Static Functions

static bool resolve(
MultiStageConfig const &config,
std::vector<std::string> const &wanted,
RequestCapabilities const &available,
Route &out,
std::string &error
)#

Resolve the active subgraph for one request.

Parameters:
  • config – Already validated (see multiStage::validate).

  • wanted – Terminal port ids the caller attached a sink to.

  • available – What the request supplies.

  • error – Filled with a human-readable reason when this returns false.

struct RequestCapabilities#

What this request actually supplies, built once in submit() from the payload’s bound names. No stage may re-derive the modality set, or two stages can disagree on it.

Public Functions

bool supplies(std::string const &requestKey) const#

Public Members

std::vector<std::string> suppliedRequestKeys#

Fully-qualified request keys, e.g. “request:messages”, “request:audio”.

struct RouteEdge#

One edge that survived resolution.

Public Members

int32_t producer = {-1}#

Stage index. -1 means the value comes from the request.

int32_t consumer = {-1}#
std::string port#

Producer’s port id, or the request field.

std::string inputName#

Consumer’s input name.

Transport transport = {Transport::kDeviceTensor}#
bool crossLane = {false}#