{"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.4.0","deps":[],"features":{},"cksum":"sha256:4fcc2aa20e9410b841e24de13c0a10d61560a3216292240e6a1f882d14eab0f0","sig":"ed25519:d457a4161e252e0429e734fbbfa91d3d6b0c752615f6b764157c0e86cb628916c86cff21a04196c9771362d0f4de4e393697d9d0382dd3802630fbc7ecd5d205","key_fp":"SHA256:bkFv7568keKWVEybPdkv3PglP/WcccdGO8I/l+R9crc","yanked":false,"edition":"2026","hew":">=0.6.1, <0.7.0","registry_sig":"ed25519:10b9025a535ef11e678aa2c904ef48cedd96244b52a211cfc514b7eae2e4a90e6726a205384dd8dc10853d6a5b204b880b88ea9c7f190b0088a3dd81066b2d0f","registry_key_fp":"SHA256:NR2yrof9/ZWkCWyhDODRU8Yvm9Lob/0yYVTdCKzMHb8","published_at":"2026-10-21T01:45:39.305Z","dl":"https://cdn.hewpkg.com/tarballs/hew/dag/0.4.0.tar.zst"}}