{"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.2.0","deps":[],"features":{},"cksum":"sha256:0c5cb70cfbe8855fef98b2b11edcf0db9dd6af0d8bc322216ecda6e9c8cb93af","sig":"ed25519:74c44ac0c5f5c0696c536f18760b38129d8bfaf74d9f42648d34f6b093b9c5d924336bdb6378f67ba4ca3cc7378b33b9d1c1bb425ff20ee080821d4b5a279900","key_fp":"SHA256:UspGxFtb7yFbHAcyG72z6OYMpTR5mLh+BO2Rht625yY","yanked":false,"edition":"2026","hew":">=0.6.0-rc1, <0.7.0","registry_sig":"ed25519:aa4710783252bb3cada6e9c2d9b3f684244641d1f282398c9d3b598a251f50846267b388a488a5aed7ad075638b0b3bef73bcf2fba368e3bbf76e466b6c7650f","registry_key_fp":"SHA256:NR2yrof9/ZWkCWyhDODRU8Yvm9Lob/0yYVTdCKzMHb8","published_at":"2026-08-15T20:03:51.121Z","dl":"https://cdn.hewpkg.com/tarballs/hew/dag/0.2.0.tar.zst"}}