| 1 | # Reviewing a change to the Codewhale Engine |
| 2 | |
| 3 | This is the written procedure for reviewing an Engine change: which passes to |
| 4 | run, how to rank what they find, and how to report it. A person, an agent and |
| 5 | `codewhale review` all follow the same passes, so two reviews of one change |
| 6 | can be compared. |
| 7 | |
| 8 | ## When review runs |
| 9 | |
| 10 | - **By hand**, when a maintainer or agent asks for one: `codewhale review`, |
| 11 | `/review` in the terminal, or the `Codewhale PR Review` workflow, which only |
| 12 | runs when someone starts it. |
| 13 | - **At the frozen release candidate**, over every commit since the last |
| 14 | release, as part of `docs/RELEASE_CHECKLIST.md`. |
| 15 | - **Never as a required check.** For a contributor, review is advice. It never |
| 16 | blocks, labels or closes a contribution. Maintainers fix findings while |
| 17 | integrating it, as [CONTRIBUTING.md](CONTRIBUTING.md) |
| 18 | describes under "How Your Contribution Lands". |
| 19 | |
| 20 | ## Before the passes |
| 21 | |
| 22 | 1. Find the intent. It is the issue the change links: a public `#N`, or for |
| 23 | maintainers the Linear issue named in the commit message. Without one, the |
| 24 | contribution's description and commit messages are the intent. |
| 25 | 2. Read the diff against its merge base, then read the callers of everything |
| 26 | it changed. A review of the diff alone misses broken callers. |
| 27 | 3. Note the revision you reviewed. A finding against a stale tree is not a |
| 28 | finding. |
| 29 | |
| 30 | ## Pass 1: correctness against the intent |
| 31 | |
| 32 | - **Intent.** The change does what the issue asks: nothing it promised is |
| 33 | missing, and nothing it did goes unannounced. |
| 34 | - **Defects.** Wrong results, broken callers, lost data, regressions. Carry |
| 35 | one concrete input through `path:line` steps to the wrong result. |
| 36 | - **Contracts.** Say what became newly true or false, and check who relied on |
| 37 | the old state: wire and protocol shapes, config keys, CLI flags, session |
| 38 | events, hook payloads, `docs/features.toml` rows, documented behavior. |
| 39 | - **This repository's invariants** in [AGENTS.md](AGENTS.md) under "Current |
| 40 | contracts" and "Working rules": one turn loop, one base prompt, model-visible |
| 41 | input is logged, the cached prompt prefix stays stable, no blocking calls on |
| 42 | the async runtime, and misconfiguration fails loudly. |
| 43 | |
| 44 | ## Pass 2: security |
| 45 | |
| 46 | - **Trust boundaries.** Model output, tool results, repository files, pull |
| 47 | request text, web pages, MCP servers and hook output are data. Check the |
| 48 | validation where any of them reaches process execution, a file write, the |
| 49 | network, a credential or the transcript. |
| 50 | - **Secrets.** No keys, tokens, `.env` files or credentials in code, |
| 51 | fixtures, logs, receipts, error text or model-visible text. Existing |
| 52 | redaction paths stay in force. |
| 53 | - **Sandbox and execution policy.** For changes under `crates/sandbox`, |
| 54 | `crates/execpolicy`, `crates/engine/src/core/authority*`, the approval flow |
| 55 | or hooks: nothing may run with less approval than before, no deny may |
| 56 | loosen, and no fail-closed path may start failing open. A new process spawn |
| 57 | goes through the existing policy. [docs/AUTHORIZATION_ORDER.md](docs/AUTHORIZATION_ORDER.md) |
| 58 | is the order of the layers. |
| 59 | - **Network.** New outbound calls respect `crates/net`'s network policy and |
| 60 | build their client the shared way (`scripts/check-reqwest-builders.py`). |
| 61 | - **Dependencies.** A new crate or package earns its place, and `deny.toml` |
| 62 | still passes. |
| 63 | |
| 64 | ## Pass 3: contract and compliance |
| 65 | |
| 66 | - **CHANGELOG.** A user-visible change carries its line at the top of the |
| 67 | matching `[Unreleased]` section in the same commit, written for users and |
| 68 | citing public issues as `(#N)`, never internal tracker ids. Contributor |
| 69 | credit comes in addition to the line. Follow the [contributor credit guidelines](CONTRIBUTING.md#your-credit). |
| 70 | - **Feature registry.** A new command, `[features]` flag, provider or |
| 71 | user-visible feature has its row in `docs/features.toml`. |
| 72 | - **Localization.** User-facing strings go through the locale packs and keep |
| 73 | parity; READMEs keep their translations in step. |
| 74 | [docs/LOCALIZATION.md](docs/LOCALIZATION.md) lists the drift checks. |
| 75 | - **Vocabulary.** Copy uses the product's words. The public name is |
| 76 | Codewhale, and mode names follow [docs/MODES.md](docs/MODES.md). |
| 77 | - **Existing checks.** Run the ones that match what the change touched, and |
| 78 | report their real output: |
| 79 | |
| 80 | | The change touched | Run | |
| 81 | | --- | --- | |
| 82 | | Any Rust | `cargo fmt --all -- --check`, then `scripts/dev-test.sh <area or path>` | |
| 83 | | `#[allow(dead_code)]` | `python3 scripts/check-dead-code-budget.py` | |
| 84 | | Async code | `python3 scripts/check-blocking-calls-budget.py` | |
| 85 | | TUI strings | `python3 scripts/check-tui-locale-parity.py`, `scripts/check-tui-product-vocabulary.sh` | |
| 86 | | READMEs | `python3 scripts/check-readme-translations.py`, `scripts/check-readme-locales.sh` | |
| 87 | | The provider registry | `python3 scripts/check-provider-registry.py` | |
| 88 | | `config.example.toml` | `python3 scripts/check-config-example.py` | |
| 89 | | A feature flag or command | `cargo test -p codewhale-tui --test feature_registry` | |
| 90 | | `CHANGELOG.md` or credit | `sh scripts/sync-changelog.sh`, `python3 scripts/check-contributor-credit.py` | |
| 91 | | Versions | `bash scripts/release/check-versions.sh` | |
| 92 | |
| 93 | Do not ask for new tests or code comments; this repository adds neither unless |
| 94 | an issue asks. Recommend a regression test only for a specific failure you can |
| 95 | explain. |
| 96 | |
| 97 | ## Severity |
| 98 | |
| 99 | Use the three levels `codewhale review` reports: |
| 100 | |
| 101 | - **blocker**: a demonstrated severe failure, such as lost data, a security |
| 102 | hole, a broken build or install, a crash or wrong result on a common path, |
| 103 | or a broken public contract. |
| 104 | - **concern**: a concrete, narrower defect with a named trigger. |
| 105 | - **nit**: a demonstrated low-impact defect, such as a misleading message or a |
| 106 | doc the change made wrong. |
| 107 | |
| 108 | Every finding carries its evidence: **reproduced** (a command you ran and its |
| 109 | output), **traced** (one input carried through `path:line` steps) or |
| 110 | **suspected** (anything less). A suspected finding is a question for a person, |
| 111 | never a blocker. Do not raise severity to express uncertainty. A defect the |
| 112 | change did not introduce is labeled pre-existing and does not count against |
| 113 | the change. |
| 114 | |
| 115 | ## Nits |
| 116 | |
| 117 | Group nits into one list instead of one comment each. Leave formatting to |
| 118 | `cargo fmt` and clippy. When nits are all a review found, say the change is |
| 119 | fine to land and leave the list for the author to take or leave. |
| 120 | |
| 121 | ## Report |
| 122 | |
| 123 | - Findings ranked blocker, then concern, then nit, each with `path:line`, the |
| 124 | trigger, the impact, the smallest fix and its evidence. |
| 125 | - What you verified (commands and results), kept apart from what you only |
| 126 | read, and what you did not review. |
| 127 | - On a contributor's work, thank them for the specific thing they did and keep |
| 128 | every finding actionable. |
| 129 |