# `AshUi.Patch.Dispatch`
[🔗](https://github.com/hyperbob-labs/ash_ui/blob/main/lib/ash_ui/patch/dispatch.ex#L1)

ONE dispatch semantics, backing-blind (DESIGN.md §5): run the target
instance's OWN action — arguments, validations, changes, never bypassed
— and persist through the instance's data layer. The storage seam is the
only place backing appears:

- store-backed: `update/4` — an ordinary update on the instance's row.
- embedded: `embedded_update/5` — the instance's data layer IS the
  parent attribute (Ash's own semantics). The embedded action runs
  against the instance located by primary key inside the parent
  attribute (scalar, or `{:array, Embedded}`; an absent key inserts a
  defaults instance with the action applied), and the result persists as
  exactly ONE parent update — one parent notification.

Errors surface: an embedded action's validation error returns the same
`{:error, _}` shape a store-backed action's would.

# `path_segment`

```elixir
@type path_segment() :: atom() | {:item, term()}
```

# `run`

```elixir
@spec run(struct(), tuple(), atom(), map(), keyword()) ::
  {:ok, struct()} | {:error, term()}
```

THE dispatch entry point — backing-blind. `target` is what
`AshUi.Patch.Bindings.resolve/3` returns; callers never branch on
backing:

    run(record, {:root}, action, params, opts)
    run(record, {:row, child_row}, action, params, opts)
    run(record, {:embedded, parent, path}, action, params, opts)

Returns `{:ok, updated_instance_owner}` — the root record, the child
row, or the parent — or `{:error, reason}` in one shape for all three.

---

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