# `Hephaestus.Core.Workflow`
[🔗](https://github.com/hephaestus-org/hephaestus_core/blob/v0.3.1/lib/hephaestus/core/workflow.ex#L1)

Behaviour and compile-time validation helpers for workflow modules.

Workflows are declared with `use Hephaestus.Workflow` and must expose:

  * `start/0`
  * `transit/3` — static clauses ignore context with `_ctx`, dynamic clauses use `@targets`

The `Hephaestus.Workflow` macro extracts the workflow DAG at compile time,
validates it, and generates helper functions for runtime coordination.

# `edge`

```elixir
@type edge() :: %{
  from: module(),
  event: atom(),
  targets: [module()],
  dynamic?: boolean()
}
```

# `target`

```elixir
@type target() :: module() | {module(), map() | struct()}
```

Static or configured step target.

# `start`

```elixir
@callback start() :: target()
```

# `transit`

```elixir
@callback transit(
  from :: module(),
  event :: atom(),
  context :: Hephaestus.Core.Context.t()
) ::
  target() | [target()] | nil
```

# `validate!`

```elixir
@spec validate!(
  module(),
  module() | {module(), map() | struct()},
  [edge()],
  Macro.Env.t()
) :: %{
  graph: Graph.t(),
  predecessors: %{optional(module()) =&gt; MapSet.t(module())}
}
```

Validates the workflow DAG built from the given start target and edges.

Checks that the graph is acyclic, all steps are reachable from start,
leaf nodes terminate at `Hephaestus.Steps.Done`, fan-out branches converge,
context keys don't collide, and step events match transit clauses.

Returns the validated graph and a predecessors map. Raises `CompileError` on any violation.

---

*Consult [api-reference.md](api-reference.md) for complete listing*
