# Framework signal routing

| Subsystem | Without a bus | On the bus |
| --- | --- | --- |
| EventBus | Unused | The sole hub: process singleton, one Event format, subscription by type |
| WebUI server | Every signal wired to `_broadcast` with its own JSON, making a UI component the routing point | Ordinary subscriber, forwards to the frontend WebSocket |
| Agent loop | Internal AgentEvent stream; hook returns discarded | Keeps that stream and emits at key points; `tool.before` can veto |
| Dispatcher | `on_event` chain to the WebUI | Keeps the chain and emits `user.prompt_submitted` and related events |
| Task runner | Direct `job_status` broadcast | Emits `subagent.*`; the broadcast comes through `ws.frame` |
| Auth | Correct events, almost no subscribers | Unchanged; a bridge translates AuthEvent |
| Context | `on_event` callback | Emits `context.*` from that callback |
| Channels | Direct `channel_turn` broadcast | Emits `channel.*`; the direct frontend connection stays |
| Memory | Polled, no signal | Emits at processing start and end |
| File changes | No signal | File tools emit `file.changed` |
| Plugin hooks | Observe only | Remain a plugin API on bus subscriptions |

A new consumer plugs in with one `subscribe(types=…)` instead of integrating five or six mechanisms, some moments of which had no signal at all.

- `tool.before` is the tool interception point. It sits outside the approval wrapper and applies to subagents. `turn.stop` is the other gate.
- A bridge is the pattern for a subsystem that already models its events well: nothing inside auth knows the bus exists.
- Connecting a source is additive: the bus gets a copy and the old path keeps running, so each source is verifiable and reversible alone.
- Switching the WebUI uses a pass-through envelope: broadcast frames are byte-for-byte the same, so no shadow comparison is needed and the frontend does not notice.

## Left untouched

| Component | What stays |
| --- | --- |
| Dispatcher | Seven-stage turn orchestration; the signature of `process_user_turn` |
| Session storage | Git DAG and contextgit |
| JobRunner | Thread-pool model |
| `ApprovalRegistry` | Unchanged |
| AuthStore | Bridged, not modified |
| Frontend | WebSocket protocol |

## Implementation status

The bus, class-A and class-B sources, `file.changed`, the `tool.before` gate and the WebUI subscription are in place; producers across runtime, tools and channels send `ws.frame` instead of importing the WebUI. The proactive rule layer consumes the bus and adds no sources; its engine is not yet installed.

[Event layer](https://fzkuji.github.io/OpenProgram/docs/reference/design/proactive/event-layer.html)
