# `Cyclium.DynamicActor.Watcher`
[🔗](https://github.com/Cyclium/cyclium_ex/blob/main/lib/cyclium/dynamic_actor/watcher.ex#L1)

Optional GenServer that subscribes to Bus events and automatically
refreshes dynamic actors and dynamic workflows when their DB definitions change.

## Events handled

### Agent definitions
- `"agent_definition.created"` — loads and starts a new dynamic actor
- `"agent_definition.updated"` — drains, then reloads the actor from DB
- `"agent_definition.disabled"` — drains and stops the actor

### Workflow definitions
- `"workflow_definition.created"` — loads and registers a new dynamic workflow
- `"workflow_definition.updated"` — reloads the workflow from DB
- `"workflow_definition.disabled"` — unregisters the workflow

## Usage

Add to your supervision tree if you want automatic refresh:

    children = [
      # ... other children ...
      Cyclium.DynamicActor.Watcher
    ]

Then broadcast events from your application when definitions change:

    Cyclium.Bus.broadcast("agent_definition.created", %{actor_id: "my_monitor"})
    Cyclium.Bus.broadcast("workflow_definition.created", %{workflow_id: "onboarding"})

If you don't want automatic refresh, call lifecycle/loader functions directly.

# `child_spec`

Returns a specification to start this module under a supervisor.

See `Supervisor`.

# `start_link`

---

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