# Three template rules

| Rule | Copy it when | Lane, watch, cooldown | Action |
| --- | --- | --- | --- |
| `DangerousCommandGuard` | Block before an action happens | gate, `tool.before`, 0 | `Gate.ask` |
| `TestGapWatcher` | Remind once conditions accumulate, wary of false positives | observer, `model.response_completed`, 30 min | `Notify`; design: `Prepare` first |
| `UnvalidatedCompletionNudge` | Correct the model without bothering the user | observer, `model.response_completed`, 15 min | `Inject` |

Three on purpose: proactive systems die of false positives, as Clippy and UAC prompts did. Rules are Python classes that pass code review, with no config file or DSL. Each is polished before a fourth is added.

## `DangerousCommandGuard`

| Stops | Lets through |
| --- | --- |
| `rm -rf` on root, home, `/*`, `..`, or system directories | `rm -rf /tmp/x`, `rm -rf node_modules` |
| `git push --force` naming `main`, `master`, `release`, `prod`, `production` | Force-push to your own branch |
| `kubectl delete namespace` or `ns` | `kubectl delete pod x` |
| `terraform destroy`, `DROP DATABASE` | Anything unsure: a miss beats a flood of prompts |

Keyword matching produces false positives until people confirm by reflex, so the rule parses targets and branches. It catches slips only: [Threat model](https://fzkuji.github.io/OpenProgram/docs/reference/design/proactive/_research_archive/threat-model.html).

Design: attach to the existing tool approval as a risk annotation, so one command gets one confirmation.

## `TestGapWatcher`

| Item | Detail |
| --- | --- |
| Fires when | The turn changed files, a core path changed and no test file did |
| Core paths | `/auth/`, `/billing`, `/payment`, `/security`; the agent, conversation, jobs, permissions, providers and proactive packages |
| Test files | `test_`, `_test`, `/tests/`, `spec.` |
| Checked | At wrap-up only, not per file change |
| Design: false alarms | Comment edits, renames, config changes and dependency bumps would trigger it, so a read-only `Prepare` task confirms the gap first; notifies only when confident |
| Design: cost | The UI shows today's count, spend and swallowed reminders, and can turn checks off |
| Design: reminder | A “write the tests for me” button |

## `UnvalidatedCompletionNudge`

| Item | Detail |
| --- | --- |
| Fires when | The turn changed files and ran no verification. Tests and browser checks both count, or frontend work would be misjudged: [what counts](https://fzkuji.github.io/OpenProgram/docs/reference/design/proactive/events-and-state.html) |
| Why `Inject` | This repository already requires self-verification, so nudging the model is cheaper than asking the user |
| Design | Notify the user only if the nudge did not work; require the model to actually claim completion |

## Implementation status

All three are in `openprogram/runtime/proactive/policies/` with tests. `install_mvp_policies()` is not called at worker start. The items marked Design are not built: [action state](https://fzkuji.github.io/OpenProgram/docs/reference/design/proactive/execution-model.html).

[Invariants](https://fzkuji.github.io/OpenProgram/docs/reference/design/proactive/invariants.html)
