Draft

class Draft<out T>(val nodes: List<DraftNode>)

An immutable, inspectable dataflow graph that captures a distributed computation without running it.

Think of a Draft as a recipe, not a meal. It records what should happen — a dependency graph of named operations — but touches no data and invokes no code. This lets a planner inspect, rewrite, and optimise the graph before committing to execution (E-2 rewrites, E-3 cost model, E-5 incremental execution, G2–G5 DAG consolidation).

Structure — dependency DAG

A Draft is a directed acyclic graph of DraftNodes. Each node wraps a DraftStage and carries the set of NodeIds it depends on (DraftNode.predecessors). A linear pipeline — built by chaining map/filter/embroider — is the degenerate path: each node has exactly one predecessor.

Building a Draft

Start with Warp.shuttle, then chain map, filter, and optionally embroider:

val draft: Draft<ByteArray> = Warp.shuttle(OpId("docs"))
.map(OpId("score"))
.filter(OpId("above-threshold"))
.embroider(OpId("rank"))

Inspecting a Draft

The no-execution guarantee

A Draft stores only symbolic OpIds — the names of registered operations. It has no access to an OpRegistry and no mechanism to invoke an Op. Nothing executes until E-5 provides a runtime.

Type Parameters

T

phantom type parameter representing the element type the pipeline would produce at execution time. Not instantiated in E-1; present for forward compatibility with E-5 typed wrappers.

See also

Samples

val draft: Draft<ByteArray> = Warp.shuttle(OpId("docs"))
    .map(OpId("score"))
    .filter(OpId("above-threshold"))
    .embroider(OpId("rank"))

check(draft.stages.size == 4)
check(draft.isMonotone.not())          // has an Embroider stage
check(draft.embroidery?.opId == OpId("rank"))

Constructors

Link copied to clipboard
constructor(nodes: List<DraftNode>)

Properties

Link copied to clipboard

All DraftStage.Embroider nodes in this Draft, in topological order.

Link copied to clipboard

The single DraftStage.Embroider stage in this pipeline, or null if none was added. Equivalent to embroideries.singleOrNull().

Link copied to clipboard

true when every stage in this Draft is CoordinationKind.Free — no consensus step is present. A monotone pipeline converges without any Raft round.

Link copied to clipboard

All nodes of this dependency DAG in topological order (dependencies precede dependents).

Link copied to clipboard

Topological-order view of the stage types recorded in this Draft.

Functions

Link copied to clipboard
fun combine(other: Draft<*>): Draft<Unit>

Merges this Draft and other into a single dependency DAG with two independent branches — no edges connect the two branches, so their DraftStage.Embroider nodes can be consolidated into a single Raft round by the G3 planner.

Link copied to clipboard
fun embroider(opId: OpId): Draft<T>

Appends a DraftStage.Embroider stage referencing opId and returns a new Draft.

Link copied to clipboard
fun filter(opId: OpId): Draft<T>

Appends a DraftStage.Filter stage referencing opId and returns a new Draft.

Link copied to clipboard
fun map(opId: OpId): Draft<ByteArray>

Appends a DraftStage.Map stage referencing opId and returns a new Draft.