mirror of
https://github.com/hanzoai/flow.git
synced 2026-10-17 01:29:18 +00:00
The seam the whole platform composes on. A stdlib-only Go module (core/) that
holds zero domain knowledge and is what every node-pack and execution backend
plugs into. flow is curried over two parameters:
Value type — what travels on an edge (Message / Tensor / connector I/O). The
engine never inspects it; a Step interprets it per its domain.
Mode — execution locality/durability (InProcess | GPUResident | Durable),
a PARAMETER not baked in: media flows keep latents pinned in VRAM
and serialize nothing; automations checkpoint every step on the
durable backend. Same scheduler, different Backend.
So every product is flow applied:
studio = Run(GPUResident, graph-of-Tensor-steps) // comfy nodes
automations = Run(Durable, graph-of-ConnectorIO) // triggers -> actions
llmFlow = Run(InProcess, graph-of-Message-steps) // langflow (lfx) nodes
Contract: Value (opaque, typed by PortType), Port/Step (typed in/out ports + Run),
Graph (Add/Wire/Validate — port typecheck + acyclicity), Mode + Backend (the
locality/durability seam), and Scheduler (the ONE topology walk, curried over
value-domain and Mode). Ships with the reference InProcess backend; GPUResident
(studio VRAM) and Durable (auto/tasks activities) register the same way.
Tests prove it: a domain-agnostic 2-step pipeline runs in order, port type
mismatch is rejected at wire time, AnyType bypasses, cycles are caught by
Validate, and Mode selects the backend over an identical scheduler walk.
Next: studio and langflow delete their private executors and become node-packs
on this scheduler; auto's tasks engine registers as the Durable backend.
17 lines
615 B
Go
17 lines
615 B
Go
package flow
|
|
|
|
import "context"
|
|
|
|
// inProcess is the reference Backend: it runs a step by calling Step.Run directly,
|
|
// values passed by reference in shared memory. No serialization, no checkpointing.
|
|
// It is always registered (New seeds it) so the engine works out of the box; the
|
|
// GPUResident and Durable backends live in their own packages (studio's VRAM
|
|
// executor, auto/tasks' activity dispatcher) and register the same way.
|
|
type inProcess struct{}
|
|
|
|
func (inProcess) Mode() Mode { return InProcess }
|
|
|
|
func (inProcess) Exec(ctx context.Context, s Step, in Inputs) (Outputs, error) {
|
|
return s.Run(ctx, in)
|
|
}
|