# Proactive layer

1. **Model** `rm -rf ~`
2. **Event** `tool.before`
3. **Rule** `DangerousCommandGuard` `evaluate(event, state)`
4. **Action** `Gate.ask`
   
   command stopped

Rules never watch Agent internals; they watch the event stream. Landing the action is the framework's job.

| Concept | Is | Detail |
| --- | --- | --- |
| Event | A record that something just happened; append-only | [Event layer](https://fzkuji.github.io/OpenProgram/docs/reference/design/proactive/event-layer.html) |
| Policy | A Python class: which events it watches, and how it decides. A new capability is a new class. | [Rules and how they run](https://fzkuji.github.io/OpenProgram/docs/reference/design/proactive/execution-model.html) |
| Lane | Gate blocks before and must be fast; observer watches after and may be slow. Opposite timing, so they stay apart. | [Rules and how they run](https://fzkuji.github.io/OpenProgram/docs/reference/design/proactive/execution-model.html) |
| Action | Fixed set: block, allow or ask; remind; inject a hint; prepare in the background | [Three template rules](https://fzkuji.github.io/OpenProgram/docs/reference/design/proactive/policies-mvp.html) |
| State | The current situation, folded from events | [Events and state](https://fzkuji.github.io/OpenProgram/docs/reference/design/proactive/events-and-state.html) |

State is why this is more than a hook. A rule that only looks at one moment needs nothing else. “Same tool failed three times in a row” needs memory, and with hooks every such rule hand-rolls a counter, its resets and session isolation.

**Left out on purpose**

Each can be added without rework; research notes are in `_research_archive/`.

- Crash recovery and tamper resistance for persisted events
- Offline replay to measure a new rule's false-positive rate
- Adversarial security and secret redaction
- Interruption budgets and automatic breakers; `cooldown_s` carries the load

## Implementation status

The code is in `openprogram/runtime/proactive/`, tested but not installed at worker start. Per-action state: [Rules and how they run](https://fzkuji.github.io/OpenProgram/docs/reference/design/proactive/execution-model.html).

[Events and state](https://fzkuji.github.io/OpenProgram/docs/reference/design/proactive/events-and-state.html)
