# @nous/autoresearch-governance

Governance, safety & compute-budget controls for the Phase-178
autonomous-research stack (TODOS/phase-178 §178.11). All logic here is real,
self-contained rule/stat-based control — no external service required.

## Components

| Module         | Summary                                                                                                                                                                                                                                                                                                                                      |
| -------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `budget.py`    | **Compute-budget governor**: GPU-hours / dollars / wall-clock caps enforced simultaneously per **run, researcher and org**; a charge over _any_ enclosing cap is atomically rejected and hard-stops that scope; `approve_resume` clears the stop and optionally raises the cap. (§178.11.1.1)                                                |
| `guards.py`    | **Self-amplification guard** — flags edits to protected scaffold/budget/governance paths or text requesting self-modification / budget escalation, routing to human approval; **distribution-shift detector** — Mahalanobis distance + Population-Stability-Index alarms on rapid divergence from validated work. (§178.11.1.2, §178.11.1.3) |
| `review.py`    | **Adversarial self-review** — the CLAUDE.md stub bright-line as an executable gate: phrase patterns, silent-stub code-patterns (`Math.random`/`NotImplementedError`/fabricated-score), eval-contamination (n-gram overlap) and LLM-regurgitation; **only stub-free trials accumulate delta credit**. (§178.11.2.1)                           |
| `dualuse.py`   | **Dual-use risk classifier** (defensive) — bioweapon/CBRN, cyber-offense, child-safety, election-interference lexicons with benign-context discounting; explicit weapon markers force **HIGH → halt + escalate**. (§178.11.2.2)                                                                                                              |
| `telemetry.py` | **Kuan Yin integration** — normalises every safety event into one `ModerationEvent` schema so autoresearch and product safety share a pane of glass. (§178.11.2.3)                                                                                                                                                                           |
| `report.py`    | **Quarterly Accountability Report** — trials/accepted-deltas/novel-results/cost/safety-events/reviewer-outcomes as a dict + deterministic Markdown. (§178.11.2.4)                                                                                                                                                                            |

> Note: `review.py` and `dualuse.py` intentionally contain stub-scan phrases and
> risk lexicons as string literals — that is the detection vocabulary, not
> stubs.

## Testing

```bash
python3 -m pytest tests/ -q     # 21 tests
python3 -m ruff check .
```
