# Cursor rules for Cognithor · Agent OS

See `CLAUDE.md` for full context. Quick rules:

## Style

- Python: ruff-formatted, ruff-checked. Run `ruff format` before commit.
- Dart: `dart format` before commit. `flutter analyze` clean.
- No emojis in code, comments, or commit messages unless explicitly requested.
- No comments restating what code does. Only WHY when non-obvious.

## Tests

- Every backend feature gets a test in `tests/test_<package>/`.
- Every Flutter provider/service/model gets a test in `flutter_app/test/{providers,services,models}/`.
- Use `pytest -x -q` to fail fast.
- Mock at the boundary (HTTP/DB), not internal logic.

## Git

- Never `git add -A` or `git add .`. Always exact paths.
- Pre-existing dirty files in `skills/` and `docs/integrations/catalog.json` are auto-regen artefacts — don't stage them.
- Never amend a commit after a hook failure — make a new commit.
- Never chain `git push` + `gh pr merge` + cleanup. One per turn.

## Architecture

- PGE-Trinity is the canonical orchestration: `Planner` → `Gatekeeper` → `Executor`.
- Gatekeeper risk lists (`_classify_risk()` in `src/cognithor/core/gatekeeper.py`) — unknown tools default to ORANGE.
- Owner-gating uses `cognithor.security.owner.require_owner()`.
- TraceBus (`src/cognithor/crew/trace_bus.py`) is in-process pub/sub; subscribe via `subscribe_lifecycle()` or `subscribe(trace_id)`.

## What NOT to touch

- `flutter_app/lib/l10n/generated/` — regenerated by `flutter gen-l10n`.
- `cognithor_bench/results/`, `examples/insurance-agent-pack/results/`, `/results/` — gitignored runtime artefacts.
- `flutter_app/{linux,windows,macos}/flutter/generated_*` — regenerated by `flutter pub get`.

## Frequent mistakes to avoid

- Mixing `asyncio` and `_asyncio` aliasing in the same file (`webui.py` uses unaliased after Task 21 of v0.95.0).
- Removing `# noqa: SLF001` from `bus._subscribers` accesses — keep them, the suppress is intentional for internal-state checks.
- Calling `context.read<>()` inside `dispose()` — Flutter forbids deactivated-widget-ancestor lookup. Cache the provider in `didChangeDependencies()` instead.
- Hardcoding `Color(0x...)` hex in widgets — use `CognithorTheme.*` tokens (theme adoption is currently inconsistent and we're trying to fix that).
