{"metadata":{"name":"hew/dag","vers":"0.7.0","description":"Fail-closed runtime DAG parsing, topological sorting, and dependency-ordered value routing for Hew","license":"MIT OR Apache-2.0","authors":["Hew Contributors"],"deps":[],"features":{},"edition":"2026","hew":">=0.10.0, <0.12.0","keywords":["dag","workflow","graph","routing","topological-sort"],"repository":"https://github.com/hew-lang/ecosystem","readme":"# hew.dag\n\nRuntime-loaded, fail-closed directed acyclic graph parsing and value routing.\nMalformed specs, unknown operations, bad node references, and cycles are typed\n`DagError` values.\n\n```hew\nimport hew.dag;\n\nfn main() {\n    match dag.run_text(\"add:1 multiply:10 | 0->1\", 3) {\n        .Ok(report) => println(f\"sink = {dag.sink_output(report)}\"),\n        .Err(failure) => println(dag.describe(dag.error_of(failure))),\n    }\n}\n```\n\nRun `hew run dag/examples/linear_pipeline.hew` from the ecosystem repository\nroot for a complete example.\n\n## API surface\n\n**Types**\n\n- `NodeOp` — `Add | Multiply | Square | Identity`, the operation a node applies.\n- `NodeSpec { id, op_code, operand }` — one node's compiled operation.\n- `Edge { src, dst }` — a directed dependency (`dst` runs after `src`).\n- `DagSpec { num_nodes, nodes, edges }` — a compiled graph.\n- `RunReport { outputs, order, num_nodes }` — the outcome of a run.\n- `RunFailure { err, stopped_at }` — a run failure with the node it stopped at.\n- `DagError` — `Empty | Cyclic | UnknownNode(i64) | Malformed(i64) | UnknownOperation(i64) | Dispatch(i64)`.\n- `LifecycleState` — the spec's readiness (`lifecycle_for`/`state_name`).\n\n**Building and parsing specs**\n\n- `new_spec() -> DagSpec` / `add_node(spec, op, operand) -> DagSpec` /\n  `add_edge(spec, src, dst) -> Result<DagSpec, DagError>` — build a spec\n  programmatically.\n- `parse_spec(text: string) -> Result<DagSpec, DagError>` — parse the\n  `op:operand ... | src->dst ; ...` text grammar (see the module doc comment\n  in `dag.hew`).\n\n**Routing**\n\n- `run_text(text, initial) -> Result<RunReport, RunFailure>` — parse and\n  route in one call, using the library's own `apply_op` kernel.\n- `route_with(spec, initial, dispatch: fn[suspends](i64, i64) -> i64 fails DagError) -> Result<RunReport, RunFailure>` —\n  route through a caller-supplied per-node dispatch, called once per node in\n  topological order. The dispatch may suspend, so it can ask an actor, and it\n  fails with `DagError.Dispatch(node)` when a node cannot produce an output;\n  the run then stops with `stopped_at` set to that node. `route_with` always\n  suspends, so a caller that cannot suspend uses `run_text` instead.\n- `apply_op(op, x, operand) -> i64` — the per-node operation kernel\n  (`add`/`multiply`/`square`/`identity`).\n- `topo_order(spec) -> Result<Vec<i64>, DagError>` / `validate(spec) -> Result<i64, DagError>` /\n  `is_acyclic(spec) -> Result<bool, DagError>` — topological sort and\n  validation, refusing cyclic specs.\n\n**Inspecting results**\n\n- `node_count`, `edge_count`, `edge_src`, `edge_dst`, `node_at` — read a\n  `DagSpec`.\n- `output_at(report, id)`, `sink_output(report)` — read a `RunReport`.\n- `error_of(failure) -> DagError`, `describe(error) -> string`,\n  `is_cyclic(error) -> bool` — inspect and render a `DagError`.\n- `lifecycle_for(spec) -> LifecycleState`, `state_name(state) -> string` —\n  a spec's lifecycle state before routing.\n\n`dag/examples/actor_pipeline.hew` routes through one live actor per node: its\n`route_with` dispatch asks the node's actor and returns the reply, or fails\nwith `DagError.Dispatch(node)` when the actor does not answer.\n"},"version":{"name":"hew/dag","vers":"0.6.0","deps":[],"features":{},"cksum":"sha256:690c018ddc92dae8c8b27fd2549aeb01826f6b86284b7bf21a1a60a3dfceb5a4","sig":"ed25519:ddfb7b8e10ddf1f9c873d07cbee059462da574657cca83a5fda74cbda4c0c3da3d46e81df8c29a77f9cc67897d46ddafc57d7ff2b300dddf8c3c3ed0cdef7a0b","key_fp":"SHA256:CB3Ski8183EXzxoy+uSuMpWTxvd/4AlB8CThZu0ZG74","yanked":false,"edition":"2026","hew":">=0.9.0, <0.10.0","registry_sig":"ed25519:6f5c4445b84783a8161f6b0785ae6021e14c6a458159ab134a97b86e5577c1884303e4c60d29928e2291fa86fed73b66a3f12708681a2162dacd30cbb3967601","registry_key_fp":"SHA256:NR2yrof9/ZWkCWyhDODRU8Yvm9Lob/0yYVTdCKzMHb8","published_at":"2026-10-24T11:53:53.446Z","dl":"https://cdn.hewpkg.com/tarballs/hew/dag/0.6.0.tar.zst"}}