| <!-- Copyright 2026 The Fuchsia Authors | |
| Licensed under a BSD-style license <LICENSE-BSD>, Apache License, Version 2.0 | |
| <LICENSE-APACHE or https://www.apache.org/licenses/LICENSE-2.0>, or the MIT | |
| license <LICENSE-MIT or https://opensource.org/licenses/MIT>, at your option. | |
| This file may not be copied, modified, or distributed except according to | |
| those terms. --> | |
| # Gate 2 review policy and diagnostics | |
| Anneal pairs local `change-review`, `trust-review`, CI, and human review with | |
| an independent cross-family automated review (**Gate 2**). Gate 2 accepts | |
| either an independent cross-family `COMMENT` review carrying a structured | |
| `anneal-gate2-review:v1` footer or, for backwards compatibility when no | |
| authentic `anneal-gate2-review:v1` verdict covers the current identity, a | |
| healthy `chatgpt-codex-connector[bot]` review summary. Until | |
| [#28](https://github.com/google/anneal/issues/28) is resolved, Gate 2 is | |
| enforced by the manual merge gates below rather than by a GitHub ruleset. | |
| ## Merge gates | |
| Do not merge a pull request—and never use admin-bypass merges such as | |
| `gh pr merge --admin`—until all five gates below pass for the PR's current | |
| **identity** with full review history preserved (for stacked PRs, land | |
| bottom-up so each PR meets Gate 4 on `main` before merging). A PR's identity | |
| is the content it would land: | |
| - For a PR with one commit on top of its target base, the identity is the | |
| triple (tree of the commit's parent, tree of the commit, full commit | |
| message). | |
| - For a PR with several commits, the identity is the exact | |
| `(target_base, head)` SHA pair. | |
| The PR's `target_base` is `main` for a lone PR or the bottom PR of a stack, and | |
| the head of the PR directly below it while stacked (Gate 4 requires stacked PRs | |
| to rebase onto `main` before merging once lower PRs land). Normally | |
| `merge_base == target_base` so the PR's commits sit directly on `target_base`; | |
| conditional delta reviews may also span an advanced `target_base` before | |
| rebasing under rule **(a)** below, though a delta review covers only the | |
| identity it names and never carries forward across a subsequent rebase. | |
| Review evidence recorded on this PR for one identity (review receipts, Gate 2 | |
| reviews, and human approvals) remains valid for every later head of the same PR | |
| with that identity, however that head was produced, and for no other, subject to | |
| the Gate 5 rules for the Review Receipt comment's `Human review surface` block. | |
| The one exception is the evaluator-verified rebase-only carry-forward of a clean | |
| full Gate 2 review (and any Gate 1 closure check recorded on it) described under | |
| Gates 1 and 2. Evidence never transfers between pull requests. In particular, | |
| when a lower stack PR is squash-merged and the PR above it is rebased onto that | |
| squash commit (whose tree equals the lower PR's reviewed head tree), the upper | |
| PR's identity—and its review evidence—is unchanged. The | |
| identity omits author and committer metadata, and GitHub reports CI per commit | |
| SHA, so every new head still needs its own SHA-bound deterministic preflight | |
| (including the authorship and trailer checks in | |
| [`AGENTS.md`](../AGENTS.md#standing-rules)) and its own Gate 3 CI. Any change to | |
| either tree or to the commit message changes a one-commit PR's identity, and any | |
| change of SHA changes a multi-commit PR's identity; re-confirm every affected | |
| gate whenever the identity changes: | |
| 1. **Gate 1 — Local review and receipt:** Local | |
| [`change-review`](../skills/change-review/SKILL.md) and | |
| [`trust-review`](../skills/trust-review/SKILL.md) have converged on the | |
| current identity, every open trust question is resolved by evidence or | |
| explicit human maintainer disposition, no confirmed in-scope defect remains | |
| unresolved, and the PR author or acting agent has posted a Review Receipt | |
| comment naming a reviewed `head` SHA with the current identity that includes | |
| an accurate `Human review surface` block. | |
| **Fix-only re-push.** After a Gate 2 review reports findings, a new identity | |
| whose changes since the last identity on which local review converged are all | |
| *fix-only* needs no separate local review round. A change is fix-only when it | |
| - edits only files that the PR already changes at that converged identity, | |
| and changes no Human review surface item defined in | |
| [`AGENTS.md`](../AGENTS.md#code-review-rules) and no CI-executed surface | |
| defined in | |
| [`change-review`](../skills/change-review/SKILL.md#schedule-by-data-dependency), | |
| which keep their local review; | |
| - addresses one or more findings in `anneal-gate2-review:v1` reviews posted | |
| on this PR (a pure rebase that addresses no finding uses `change-review`'s | |
| clean-rebase row instead), with every changed hunk and any new or edited | |
| commit message since that converged identity mapping to one of them, and | |
| every finding that the identity addresses or reopens under **Fixed** | |
| (Gate 2) is an `anneal-gate2-review:v1` finding carrying an `id` used by no | |
| other finding on the PR (reopening a legacy Codex finding or a finding with | |
| a missing or duplicate `id` makes the change not fix-only, so it needs | |
| Gate 1 in full); and | |
| - is otherwise at most a clean rebase as defined by the reuse rules in | |
| [`change-review`](../skills/change-review/SKILL.md#key-every-result-to-its-inputs). | |
| The Review Receipt comment names the `(target_base, merge_base, head)` tuple | |
| of both the new identity and that converged identity, carries the | |
| `Human review surface` block, maps the `id` of every addressed or reopened | |
| finding to its fixing hunk or edit (in the changes since the converged | |
| identity when newly addressed, or in the current PR state when reopened), | |
| includes the new head's deterministic preflight receipt, names every model | |
| family (or `human`) that authored a change since the converged identity (the | |
| *fix families*), and says that it relies on this rule. The receipt never | |
| confirms a fix by itself: Gate 1 holds for a fix-only identity only when at | |
| least one *closure check* of that identity confirms every addressed or | |
| reopened finding and no closure check or Gate 2 item for that identity | |
| disqualifies it below. A closure check is an automated read-only pass, | |
| separate from the unprimed cold Gate 2 pass (it is the separate warm check | |
| that `change-review`'s fresh-context rule calls for), launched from a clean | |
| `<target_base>` checkout or neutral directory by a model family distinct from | |
| the PR's `author_family` and from every fix family. It receives the PR's | |
| Gate 2 reviews, PR description, and Review Receipt, together with the | |
| converged identity's `<base>..<head>` commit range and the new identity's | |
| `<base>..<head>` commit range and `head` tree (plus | |
| `<converged_base>..<new_base>` and `git range-diff` across a rebase); it | |
| checks that the change is fix-only as defined above and that each fix holds | |
| for every finding that the identity addresses or reopens under **Fixed** | |
| (Gate 2). A closure check is never posted as a standalone | |
| `anneal-gate2-review:v1` review; instead, it attaches an explicit verdict for | |
| every addressed or reopened finding to the `prior_findings_status` of a | |
| completed full (not delta) `anneal-gate2-review:v1` cold-pass review of that | |
| identity (`review_mode` absent or `"full"`) run on an unfiltered host (never | |
| a severity-filtered host or legacy Codex summary) with at least one completed | |
| cold pass from a family distinct from the `author_family` and every fix | |
| family, recording | |
| `{"id":"<id>","status":"closed","basis":"verified","fix_only":true,"family":"<family>"}` | |
| (with `<family>` distinct from the `author_family` and every fix family) when | |
| both the change is fix-only and the fix holds. When either fails, that review | |
| records `"fix_only":false` or a non-`closed` `status` (such as `"still_open"` | |
| or `"unclear"`) in `prior_findings_status` for each addressed or reopened | |
| finding with an `id` and reports `verdict: "findings"` with a `findings[]` | |
| entry for each unconfirmed fix or fix-only failure (never | |
| `verdict: "clean"`). A status inferred from a reviewer not raising a finding | |
| again is not a closure check. Any closure check or Gate 2 item for that | |
| identity (including | |
| on any commit with that identity, or from an incomplete, errored, malformed, | |
| parallel, or earlier run) that records `"fix_only":false`, records a | |
| non-`closed` `status` for a finding that the identity addresses or reopens | |
| under **Fixed**, or records a `"fix_only"` entry without `"status":"closed"`, | |
| `"basis":"verified"`, `"fix_only":true`, and such a distinct `"family"` | |
| permanently disqualifies that identity from this rule—no parallel or later | |
| closure check of that identity can override it. When the evaluator's | |
| rebase-only carry-forward applies to that cold-pass review and neither the | |
| reviewed nor the current identity is disqualified above, both its cold pass | |
| and its closure check cover the carried-forward identity too, except for any | |
| finding concerning a surface outside the identity (such as the PR description | |
| or Review Receipt comment) that changed after that review, which reopens | |
| under **Fixed**. Without a qualifying closure check covering every addressed | |
| or reopened finding, or when the identity is disqualified above, the identity | |
| needs Gate 1 in full. Gate 1 remains mandatory in full for the PR's first | |
| identity and for any identity that is not fix-only, over every change since | |
| the last identity on which local review converged. | |
| 2. **Gate 2 — Independent cross-family review and finding dispositions:** At | |
| least one complete automated Gate 2 review posted on this PR covers the | |
| current identity, and no Gate 2 review requested on this PR, for any | |
| identity, may still be running at merge time. A Gate 2 review is valid only | |
| when produced via one of two mechanisms: | |
| - **Structured cross-family `COMMENT` review (`anneal-gate2-review:v1`):** | |
| A PR review submitted with `event: "COMMENT"` (never `APPROVE`, keeping | |
| Gate 5 human approval strictly separate) by an authorized reviewer | |
| (repository owner, org member, or collaborator, or an explicitly | |
| configured review bot identity) using an automated model family strictly | |
| distinct from the PR's authoring model family | |
| (`reviewer_family != author_family`), executed from a clean `<target_base>` | |
| checkout or neutral directory without author or Gate 1 conversation | |
| history. When Gate 1 already used a distinct model family from the author, | |
| prefer a third distinct model family for Gate 2 when available; otherwise, | |
| pair Gate 2 with a distinct model family from the author in a fresh, | |
| unprimed harness. Its body must contain exactly one machine-readable | |
| footer: | |
| ```html | |
| <!-- anneal-gate2-review:v1 {"base_sha":"<40-hex>","head_sha":"<40-hex>","tree_sha":"<40-hex>","reviewer_family":"<family>","author_family":"<family|human>","verdict":"clean|findings|incomplete","findings":[{"severity":"P0|P1|P2|P3","path":"<path|null>","line":1,"summary":"<text>"}]} --> | |
| ``` | |
| Here `author_family` names the authoring model family (or `"human"` for a | |
| wholly human-authored PR), `reviewer_family` names an automated model | |
| family distinct from `author_family` (never `"human"` or a placeholder; or | |
| `"multi"` when `panel_seats[]` is present with at least one completed | |
| cross-family seat), `verdict` is `"clean"` (`findings: []`), `"findings"` | |
| (non-empty `findings`), or `"incomplete"`, and optional `parent_tree`, | |
| `commit_msg_sha256`, `reviewed_at`, `round`, `risk_tier`, `merge_base`, | |
| `identity_key`, `panel_seats[]`, `prior_findings_status[]`, and `coverage` | |
| (plus per-finding `id`, `fingerprint`, `surface`, `consensus_count`, | |
| `raised_by[]`, and `repro_status`) may carry one-commit identity or | |
| multi-seat diagnostic metadata. When `identity_key` uses a structured | |
| `one:` or `multi:` prefix (case-insensitive after trimming whitespace), it | |
| must match `one:<parent_tree>:<tree_sha>:<commit_msg_sha256>` (lowercase | |
| 40-hex SHAs and 64-hex SHA-256 over the UTF-8 `commit.message` returned by | |
| GitHub's commits API, which omits the raw commit object's trailing | |
| newlines) or `multi:<base_sha>:<head_sha>` and agree with `tree_sha`, | |
| `parent_tree`, `commit_msg_sha256`, `base_sha`, and `head_sha` fail-closed; | |
| non-structured legacy keys are accepted only on exact | |
| `(head_sha, base_sha, tree_sha)` and never transfer across heads. Gate 2 | |
| provides the cold cross-family review and falsification pass after Gate 1's | |
| pre-push convergence. | |
| Optional `advisories[]` entries are `P3` notes in the finding shape. They | |
| never block, and are not findings for the resolution rule below; a | |
| reviewer that would report only `P3` issues may report `verdict: "clean"` | |
| with those notes as advisories. A `P3` entry in `findings[]` keeps its | |
| blocking meaning, so a reviewer that follows only the Code Review Rules | |
| and reports `P3` issues as findings is still correct. | |
| **Conditional delta reviews.** A Gate 2 review normally reads the PR's | |
| whole change (`review_mode` absent or `"full"`). A later round may instead | |
| post a *delta review* (`"review_mode": "delta"`), which reads only the fix: | |
| every change to the PR's tree and commit messages since the head named by | |
| its `delta_from` SHA, together with each whole function, Lean declaration, | |
| or other definition that the fix touches, as of the new head. A delta | |
| review is a complete Gate 2 review of its identity only when all of the | |
| following hold; whenever one fails, or the reviewer cannot establish it, | |
| the round must be a full review instead. A delta review that fails any of | |
| them never passes the gate, but its findings still block like those of | |
| any other Gate 2 review: | |
| - **(a) Full-panel anchor and verified base advance:** no Gate 2 item or | |
| Codex summary on this PR has been deleted, the delta review is the | |
| latest Gate 2 item on the PR, and the Gate 2 item immediately before it | |
| is an `anneal-gate2-review:v1` PR review, not an issue comment and not | |
| itself a delta review, submitted on commit `delta_from` without any | |
| intervening base-branch retarget or force-push. That anchor has no | |
| `merge_base` other than its `base_sha`. Either both reviews share the | |
| same `base_sha` and `merge_base == base_sha`, or the target base moved | |
| strictly forward (`anchor.base_sha..base_sha`) without touching any | |
| review rule listed under **Rebase-only carry-forward** below (or | |
| `ci/checks.toml`, `.github/CODEOWNERS`, or any dot-prefixed file or | |
| directory) and stayed disjoint from every PR file, while the PR either | |
| kept `merge_base == anchor.base_sha` (unrebased) or rebased cleanly | |
| onto a newer ancestor of `base_sha`. | |
| That anchor is a `COMMENT` review whose `reviewer_family` differs from | |
| its `author_family`, has verdict `"clean"` or `"findings"`, has a | |
| non-empty `panel_seats[]` in which every seat completed with a `"clean"` | |
| or `"findings"` verdict (at least one of them cross-family), and reports | |
| no blocked `coverage`. Its `tree_sha` is the tree that GitHub reports | |
| for commit `delta_from`. Delta reviews therefore never chain, and the | |
| delta review's `round` is at least 2. | |
| - **(b) No high-severity findings:** no Gate 2 item recorded on the | |
| anchor's head or tree reports a P0 or P1 finding. | |
| - **(c) Small fix inside the PR:** the fix edits only files that the PR | |
| already changed at `delta_from`, adds no file to the PR, keeps every | |
| PR file a regular non-executable blob (`100644`), changes at most 400 | |
| symmetric lines (`max(removed, added)` per changed block) across at | |
| most 25 files, and edits no item on the Human review surface defined in | |
| [`AGENTS.md`](../AGENTS.md#code-review-rules) (such as a stated spec or | |
| a definition it depends on, a public API or theorem type, a waiver, a | |
| trust tier, a dependency, editor or agent config, or a policy | |
| relaxation). | |
| - **(d) Both families:** every seat of the delta review's `panel_seats[]` | |
| completed with a `"clean"` or `"findings"` verdict, including at least | |
| one Claude-family seat and one Gemini-family seat. | |
| - **(e) Strictly non-TCB, non-policy PRs (`tier0_docs` / `tier1_code`):** | |
| both reviews record a non-TCB `risk_tier` (`"tier0_docs"` or | |
| `"tier1_code"`), the delta review's tier never exceeds the anchor's | |
| (`tier0_docs < tier1_code`), and neither the anchor's identity nor the | |
| delta review's identity touches any Tier 2, TCB, CI, workflow, | |
| CODEOWNERS, review-policy, skill, vendor, proc-macro, githook, tooling, | |
| build/manifest/lock/pin, dot-prefixed, or script/config path. Delta | |
| reviews are disabled on all `"tier2b_cli_policy"`, `"tier2a_core_tcb"`, | |
| and CODEOWNERS-protected PRs. The evaluator derives protected CI build | |
| inputs and ownership rules directly from `ci/checks.toml` | |
| (`[tcb.caller].caller_workflows`, `[tcb].extra_executable_paths`, | |
| `[pins.*]`, `[images.*]`, `[caches.*]`) and `.github/CODEOWNERS`, fails | |
| closed (classifying every path as Tier 2 and rejecting delta reviews) | |
| if either file is missing, unreadable, or unparseable, and rejects | |
| delta reviews whenever either file appears in the PR's changed paths or | |
| differs from the evaluator's checkout in the anchor or delta Git tree. | |
| In addition, every path under `anneal/trusted/`, `anneal/ci/`, `ci/`, | |
| `zerocopy/ci/`, `anneal/.github/`, `.github/`, `anneal/skills/`, | |
| `skills/`, `anneal/vendor/`, `vendor/`, `zerocopy/vendor/`, | |
| `zerocopy/zerocopy-derive/`, `zerocopy-derive/`, `githooks/`, `tools/`, | |
| or `anneal/tools/`, any dot-prefixed file or directory (such as | |
| `.cargo/`, `.vscode/`, `.agents/`, `.dockerignore`, `.envrc`, or | |
| `.gitattributes`), any review rule listed under **Rebase-only | |
| carry-forward** below, any build/manifest/lock/pin/skill/config file | |
| (`Cargo.toml*`, `Cargo.lock*`, `flake.*`, `lakefile*`, | |
| `lean-toolchain*`, `rust-toolchain*`, `build.rs`, `Makefile`, | |
| `GNUmakefile`, `Justfile`, `Dockerfile`, `*.Dockerfile`, | |
| `root-manifest.sha256`, `foundation-lock.json`, `lake-manifest.json`, | |
| `library-lock.json`, `bundle-manifest.json`, `miri_oracle_pin.json`, | |
| `UPSTREAM_PIN.json`, `SKILL.md`, `rustfmt.toml`, `clippy.toml`, | |
| `cargo.sh`, `zerocopy/cargo.sh`, | |
| `anneal/tests/cargo-anneal/tests/fixtures/starnix/source.json`), | |
| and any `.sh`, `.py`, `.bat`, `.cmd`, `.ps1`, `.nix`, `.yml`, or | |
| `.yaml` file classifies as Tier 2 and requires a full Gate 2 panel; | |
| remaining code/proof/config paths (`anneal/theory/`, | |
| `anneal/correspondence/`, `anneal/tests/`, `exocrate/`, | |
| `verification/`, `zerocopy/`, `src/`, `tests/`, or `.rs`, `.lean`, | |
| `.toml` outside `.stderr`/`.expected`) classify as `tier1_code`, and | |
| other paths classify as `tier0_docs`. Any edited file whose base or | |
| head blob anywhere contains a trust-tier directive | |
| (`anneal-trust-tier:`), an `anneal::trusted` waiver token (`::` | |
| together with `(r#)?anneal` and `(r#)?trusted`), a Lean proof-escape or | |
| compiler-override token (`sorry`, `sorryAx`, `admit`, `axiom`, | |
| `native_decide`, `bv_decide`, `bv_check`, `implemented_by`, `csimp`, | |
| `ofReduceBool`, or `trustCompiler`), or `extern` in a `.lean` file also | |
| fails closed and requires a full Gate 2 panel. | |
| - **(f) Bounded share of the PR:** the fix's symmetric changed lines are | |
| at most 30% of the PR's `+/-` changed lines, excluding generated | |
| outputs (`*.stderr`, `*.expected`, and `bundled_theory.json`). | |
| - **(g) Whole definitions in context:** the reviewers receive every whole | |
| definition that the fix touches; if they do not fit the reviewer's | |
| context budget, the round is a full review. | |
| - **(h) Every earlier finding audited:** `prior_findings_status[]` holds | |
| exactly one `{"id": ..., "status": ...}` object per id, each with | |
| status `"closed"`, `"still_open"`, or `"unclear"`, and names every | |
| `findings[]` entry of every earlier Gate 2 item on this PR, whatever | |
| head it reviewed. A finding without an `id`, two earlier findings that | |
| share an `id`, or a malformed earlier Gate 2 item (including one with a | |
| malformed or contradictory `identity_key`) rules out a delta round. | |
| The evaluator checks (a), (b), (d), (e)'s tier rule, and (h) (and, when | |
| reconciling against GitHub, verifies (c)'s `100644` mode, file, and line | |
| caps, (e)'s path-tier, config-parity, and whole-blob token bounds, and | |
| (f) on every delta review via GitHub comparisons, recursive Git trees, | |
| and bounded `<= 4 MiB` blobs; direct callers without that verifier permit | |
| only same-base Tier 0/1 rounds); the reviewer must establish (c) through | |
| (g), including (c)'s Human review surface rule, from the PR's commits and | |
| Review Receipt before posting. Beyond the | |
| general payload schema, only a `review_mode` other than `"full"` or | |
| `"delta"`, or a `delta_from` that is not a lowercase 40-hex SHA or appears | |
| outside delta mode, makes a payload malformed; every other delta condition | |
| only keeps a delta review that would pass pending. A delta review covers | |
| only the identity it names: the rebase-only carry-forward below never | |
| applies to it. | |
| **Rebase-only carry-forward.** A clean full (not delta) | |
| `anneal-gate2-review:v1` review also covers a later identity of a | |
| one-commit PR when the evaluator itself confirms from GitHub data that the | |
| PR was only rebased onto a later base since that review: | |
| - the review is the latest Gate 2 item on the PR (deleted comments | |
| included, and never itself a deleted comment), names a different head | |
| and base than the current ones, and passes with the PR's whole review | |
| history judged as of the reviewed head's GitHub-verified tree and | |
| one-commit identity (clean, cross-family, `COMMENTED`, current | |
| `merge_base`, no active failure); | |
| - no Gate 2 item recorded on the reviewed head or tree has findings or, | |
| unless it is a deleted comment, fails on its own recorded identity, and | |
| every other head with Gate 2 findings or failures makes different | |
| changes than the reviewed head (legacy | |
| `codex-pull-request-review-summary` comments never block carry-forward | |
| of a clean cross-family `anneal-gate2-review:v1` review); | |
| - both heads are single commits on their bases with the same commit | |
| message; | |
| - every file's added and removed lines, status, rename source, resulting | |
| blob, and mode (from the raw diff) are identical between the two | |
| commits; only context lines and hunk positions may differ, and a file | |
| without a comparable patch or blob fails closed; and | |
| - the base moved strictly forward (`compare` status `ahead`) without | |
| touching the review rules (any `AGENTS.md`, `AGENTS.override.md`, | |
| `CLAUDE.md`, or `GEMINI.md`, `.gemini/styleguide.md` files, `skills/` | |
| and `.github/` trees, this document, `review-policy-design.md`, | |
| `rustc-workarounds.md`, `trust-model.md`, the principles and threat | |
| model docs, or `ci/codex_review.py`) or any file the PR touches, except | |
| `anneal/trusted/root-manifest.sha256`, whose lines each name their | |
| file and digest: if the base changed it, only its blob may differ. | |
| Anything else, including GitHub's 300-file truncation or an API error, | |
| needs a new review. No reviewer posts anything for a carry-forward; the | |
| evaluator's status names the reviewed commit it carried forward. This is | |
| an intentional relaxation of the one-identity rule: interactions between | |
| the PR and base changes to other files (outside the review rules above) | |
| are left to Gate 3 CI and the merge queue. | |
| - **Legacy Codex summary (`codex-review-state:v1`):** For backwards | |
| compatibility when no completed authentic cross-family | |
| `anneal-gate2-review:v1` verdict covers the current identity, a complete | |
| code review by an authentic `chatgpt-codex-connector[bot]` covering the | |
| current identity. Once a completed authentic cross-family | |
| `anneal-gate2-review:v1` verdict covers the current identity (directly or | |
| via rebase-only carry-forward), that Gate 2 verdict is authoritative in | |
| `ci/codex_review.py` over legacy Codex summary failures or connector | |
| errors (while a pending, incomplete, dismissed, or base-stale Gate 2 | |
| entry still lets a legacy Codex failure report `failure`); any legacy | |
| Codex finding posted on the PR still follows the manual resolution rule | |
| below (fixed or dispositioned at Gate 5), which static | |
| `codex-review-state:v1` comments cannot record. | |
| An aborted run, a request answered with an error, a `verdict: "incomplete"` | |
| run, or a run that has not completed is never a passing Gate 2 review. Every | |
| finding that a Gate 2 reviewer posts on this PR (a `findings[]` entry or a | |
| legacy Codex finding, never an advisory), for any identity and including | |
| findings from incomplete or errored runs, is resolved in exactly one of two | |
| ways: | |
| - **Fixed:** after the finding, the surface it concerns changes (the PR's | |
| tree; its commit message; or, for a finding about something outside the | |
| identity, such as the PR description or Review Receipt comment, that | |
| surface), and Gate 1 confirms | |
| on the PR's current state that the fix is still present and still | |
| addresses the finding, mapping it to the fixing hunk or edit in the | |
| Review Receipt. When the current identity satisfies Gate 1 via the | |
| fix-only re-push rule, that rule's closure-check confirmation of the | |
| finding takes the place of Gate 1's local confirmation; the Review Receipt | |
| alone never confirms a fix. Any later edit to that surface reopens the | |
| finding until Gate 1 confirms the fix again (by local review or under the | |
| fix-only re-push rule). A finding anchored to code or describing the | |
| tree's behavior concerns the tree, and an ambiguous finding counts as a | |
| tree finding. A finding about the tree or commit message that was raised | |
| on the current identity cannot be fixed without a new identity. | |
| - **Dispositioned:** the finding appears in a `Gate 2 finding dispositions` | |
| (or legacy `Codex finding dispositions`) list inside the Review Receipt | |
| comment's `Human review surface` block, with a proposed disposition and | |
| its evidence, and the maintainer's Gate 5 approval, newer than that | |
| comment's creation and last edit, accepts it. A disposition may | |
| refute a finding with falsifiable evidence or defer an out-of-scope | |
| finding (handling pre-existing hazards as | |
| [`trust-review`](../skills/trust-review/SKILL.md#report-findings-and-pre-existing-hazards) | |
| requires); a confirmed in-scope trust or soundness defect must be fixed, | |
| never deferred. | |
| Automated review is nondeterministic: repeated reviews of identical content | |
| regularly raise new findings, so a later review's silence about a finding | |
| never resolves it. Requesting several reviews of one identity, including in | |
| parallel, is permitted and only adds findings to resolve. Resolving a review | |
| thread never resolves a finding by itself, and a green `codex-review.yml` | |
| diagnostic workflow run is never a Gate 2 review. When a hosted provider | |
| filters output by severity (for example, GitHub Codex defaulting to P0 and | |
| P1 issues per the [Codex GitHub integration docs][codex-github]; re-verify | |
| periodically if provider behavior changes), Gate 1 owns open trust questions | |
| and lower-severity defects. If a PR added or modified an unauthorized nested | |
| `AGENTS.md` or any `AGENTS.override.md` that tainted an automated review, | |
| remove it and require a new complete Gate 2 review of the resulting | |
| identity; when a PR edits root policy files (prefer dedicated policy-only | |
| PRs so automated reviewers do not evaluate product code under modified | |
| rules), policy-stability verification against the base rules comes from | |
| Gate 1 (local review against `<target_base>`) and Gate 5, not Gate 2 alone. | |
| An acting agent may propose dispositions, but never waives Gate 2, declares | |
| it passed with an unresolved finding, or authors, edits, or simulates the | |
| maintainer's acceptance. | |
| 3. **Gate 3 — Green required CI:** All required GitHub Actions checks pass on | |
| GitHub's current pull-request test-merge commit for the exact final | |
| `(target_base, head)` (reported on `head` by `pull_request`-triggered | |
| workflows), or on the merge queue's `merge_group` commit when merging via | |
| GitHub's merge queue. The required checks are `ci-core / gate` and | |
| `PR hygiene`. Every `pull_request` run of `ci-core / gate`, draft or ready | |
| and with no opt-in label, evaluates the input-scoped PR checks in | |
| `ci/checks.toml`. `PR hygiene` passes with findings waived by a | |
| `Skip-pr-hygiene:` trailer on `head` (see | |
| [`docs/contributing/scaffolding.md`](contributing/scaffolding.md)); the Gate | |
| 5 approver must accept each waiver. GitHub reports checks per commit SHA, so | |
| a rewrite that preserves the identity still needs green checks on the new | |
| `head`. | |
| 4. **Gate 4 — Bottom-of-stack ordering:** For stacked PRs, every lower PR in | |
| the stack has merged and this PR is rebased onto `main` so | |
| `merge_base == target_base` before merging or entering GitHub's merge queue | |
| (`merge_group`). | |
| 5. **Gate 5 — Human approval:** An independent human maintainer account (never | |
| a bot or acting agent) has approved the pull request on GitHub, confirming | |
| every item listed in the Review Receipt comment's `Human review surface` | |
| block (defined in [`AGENTS.md`](../AGENTS.md#code-review-rules), including | |
| stated specs and every definition their meaning transitively depends on, | |
| plus any editor or agent config, intentional policy relaxation, or proposed | |
| Gate 2 finding disposition). An approval holds across a pure rebase only if | |
| no subsequent push changes this PR's own Human review surface, no | |
| rebased-over commit modifies a definition in a stated spec's transitive | |
| dependency closure (verified via `git range-diff` and inspecting touched | |
| dependencies), and no subsequent Review Receipt comment or edit modifies the | |
| `Human review surface` block or relevant commit bodies. An unchanged | |
| identity satisfies the first two conditions, and a push that leaves the | |
| identity unchanged affects none of those surfaces; the `Human review | |
| surface` condition still applies. Verify that the approval's timestamp is | |
| newer than both the last push affecting those surfaces and the latest Review | |
| Receipt comment's creation and last edit (via GitHub's comment timestamps | |
| and edit history); any later change requires fresh human maintainer | |
| approval. Because agents may act under credentials matching a human account, | |
| agents must never self-approve pull requests or author, edit, or simulate | |
| maintainer dispositions or acceptance. In particular, an acting agent never | |
| posts `/ci-core approve`, never dismisses a `CHANGES_REQUESTED` review | |
| (including through the administrator review-dismissal API), and never | |
| enqueues a PR that the account it acts as did not author (for example, any | |
| non-`joshlf` PR when acting as `joshlf`) unless a human maintainer has | |
| approved that PR's exact head SHA on GitHub. GitHub enforces none of these | |
| for an administrator's credentials; see | |
| [`docs/trust-model.md`](trust-model.md#merge-governance). | |
| ## Automated Gate 2 reviewers and skill boundaries | |
| Automated Gate 2 reviewers follow the | |
| [Code Review Rules](../AGENTS.md#code-review-rules) (mirrored verbatim in | |
| [`.gemini/styleguide.md`](../.gemini/styleguide.md)) and report within host | |
| output and severity limits per | |
| [`change-review`](../skills/change-review/SKILL.md#report-within-the-hosts-constraints); | |
| these instructions never create a setting for unlimited findings or override a | |
| service limit. See | |
| [`docs/review-policy-design.md`](review-policy-design.md#policy-ownership) for | |
| file ownership across skills and docs. | |
| On a pull request that edits a file in that ownership table, if any Gate 2 | |
| review after the second round raises a finding about policy wording rather | |
| than a trust, soundness, or correctness defect, stop requesting automated | |
| reviews. Send a human maintainer a short Gate 5 decision brief listing the | |
| open findings, a proposed disposition for each, and a recommendation, then | |
| follow the maintainer's decision. Gate 2 still requires a complete review of | |
| the identity that lands, with every finding resolved. | |
| ## Live GitHub ruleset state and diagnostic workflow | |
| The diagnostic [workflow](../.github/workflows/codex-review.yml) runs only on | |
| manual dispatch: it checks out the adapter from `main`, uses read-only | |
| permissions, runs default diagnostic mode, and neither publishes **Codex | |
| review** statuses nor records summary deletions. PRs, comments, merge groups, | |
| and pushes do not trigger it automatically. | |
| While [#28](https://github.com/google/anneal/issues/28) remains open: | |
| - Keep | |
| [`.github/codex-review-ruleset.json`](../.github/codex-review-ruleset.json) | |
| at `"enforcement": "disabled"` (retaining its original status context and | |
| GitHub Actions App binding for future work). | |
| - Keep GitHub ruleset **Main — Codex review** (ID `26810364`) set to | |
| `disabled`. | |
| - Leave the CI and human-review rulesets enabled: `26220845` (`main`), | |
| `26220870` (maintenance branches), and `26220859` (tags). Change them only | |
| as the `ci-core` cutover in [`ci/README.md`](https://github.com/google/zerocopy/blob/main/ci/README.md) describes, | |
| which replaces `26220845` with a required-checks ruleset and a | |
| human-review ruleset. | |
| Changing Git files does not change GitHub's live rulesets. Disabling ruleset | |
| `26810364` never waives the five merge gates above. | |
| ## Run read-only diagnostics | |
| When authorized, the workflow can be dispatched manually on `main`: | |
| ```sh | |
| gh workflow run codex-review.yml --repo google/zerocopy --ref main | |
| gh run list --repo google/zerocopy --workflow codex-review.yml | |
| ``` | |
| For local read-only diagnosis (without write-effect flags): | |
| ```sh | |
| GH_TOKEN="$(gh auth token)" python3 -I -B ci/codex_review.py \ | |
| --repository google/zerocopy | |
| ``` | |
| The evaluator reads live PRs, PR reviews, summaries, commit metadata (`tree`, | |
| `parents`, and `commit.message`), historical deletion records, and merge queue | |
| state, then prints proposed verdicts. For `anneal-gate2-review:v1` reviews, it | |
| derives `one:<parent_tree>:<tree_sha>:<commit_msg_sha256>` (single-commit PR on | |
| `base_sha`) or `multi:<base_sha>:<head_sha>` from GitHub's commits API and | |
| validates `tree_sha`, structured `identity_key`, `reviewer_family != | |
| author_family`, `COMMENTED` state, and `findings[]` fail-closed (`merge_base` | |
| when set must equal `base_sha` on full reviews, while delta reviews verify any | |
| `merge_base != base_sha` through the delta base-advance rules; `advisories[]` | |
| must be `P3`-only). Clean verdicts with a `one:` key transfer | |
| across `head_sha`/`base_sha` changes only when `merge_base` is absent or equals | |
| `payload.base_sha` and GitHub confirms that the historical | |
| `(payload.head_sha, payload.base_sha)` commit has the same `(tree_sha, | |
| identity_key)`, or when the rebase-only carry-forward above holds, which it | |
| checks with the `commits/{sha}` file patches and raw diff modes and | |
| `compare/{base}...{base}`; | |
| a clean review whose `base_sha` equals the current `base_sha` | |
| (exact head or not) must still postdate the last `base_changed_at` event, | |
| with or without a matching key, so only full-review transfers from a different, | |
| GitHub-verified `base_sha` skip that freshness comparison (malformed | |
| `base_changed_at` timestamps always fail closed, and delta reviews still fail | |
| closed on any `base_changed_at` event at or after their anchor even across | |
| one-commit identity transfers), and a base change never | |
| stops a failing review from blocking. Active prior findings on the exact | |
| `(head_sha, base_sha, tree_sha)` or any historical commit whose GitHub tree | |
| matches `tree_sha` (including message-only amends, identity-preserving | |
| rewrites, and still-present issue comments with `id <= deleted_through`) block | |
| later clean reviews regardless of `identity_key` presence or format (and | |
| despite `base_changed_at` events or `base_sha` retargets on the same commit), | |
| while `deleted_through` still prevents comments with `id <= deleted_through` | |
| from approving. Earlier non-finding failures (`CHANGES_REQUESTED`, `APPROVED`, | |
| same-family reviews, or a mismatched `commit_id`) on the exact `(head_sha, | |
| base_sha, tree_sha)`, or on any historical commit that GitHub confirms has the | |
| current `one:` identity (with or without a payload `identity_key`), also remain | |
| blocking across later clean retries and identity-preserving rewrites. Such a | |
| failure stops blocking only when it carries a mismatched structured | |
| `identity_key` or a stale `merge_base` on a non-delta review, or when it is an | |
| issue comment with `id <= deleted_through` (whose historical commit is then | |
| never looked up). If GitHub cannot resolve the historical commit of such a | |
| failure (HTTP 404 or 422), the evaluator fails closed instead of dropping it. | |
| Once a completed | |
| authentic cross-family `anneal-gate2-review:v1` verdict covers the current | |
| identity (directly or via rebase-only carry-forward), `ci/codex_review.py` | |
| treats that Gate 2 verdict as authoritative over legacy | |
| `codex-review-state:v1` summaries (including completed findings and connector | |
| errors, leaving manual resolution or Gate 5 disposition of any posted legacy | |
| Codex finding to the merge gates above) and never lets legacy summaries block | |
| rebase carry-forward (retaining the legacy summary check in | |
| `_carry_forward_blocked_by_history` only when no authentic cross-family Gate 2 | |
| entry exists). When no completed authentic Gate 2 verdict covers the current | |
| identity, legacy `codex-review-state:v1` failures still report `failure` (and | |
| legacy `success` applies when no pending Gate 2 entry matches the current | |
| identity): active completed findings on the current head or a historical | |
| commit whose GitHub tree matches `tree_sha` (including still-present comments | |
| with `id <= deleted_through`) continue blocking across rewrites; such a summary | |
| records no tree, so one on a historical commit GitHub cannot resolve (HTTP | |
| 404 or 422) is treated like a finding on a different tree and does not | |
| block. `review_snapshot` tracks those active summaries alongside the latest | |
| summary, and freshness rules still reject a completed review when Codex edits | |
| an older summary or supplies only a prose receipt; deletion records are no | |
| longer updated automatically. A delta review that would pass instead stays | |
| pending, asking for a full review, unless its own fields, the PR's Gate 2 | |
| history, the deletion journal, and its comparison and scope checks satisfy the | |
| delta review rules above and GitHub confirms the anchor's tree; like a full | |
| Gate 2 review and rebase-only carry-forward, a passing delta review is | |
| authoritative in `ci/codex_review.py` over legacy Codex summaries while manual | |
| finding resolution still applies. Treat diagnostic output as evidence and | |
| inspect actual Gate 2 reviews before making a manual merge decision. | |
| ## Preserve the evaluator and re-enablement criteria | |
| The [adapter](../ci/codex_review.py) and its tests remain available for | |
| [#28](https://github.com/google/anneal/issues/28) as **supporting | |
| infrastructure for automated Gate 2 verification**. Run the simulated tests | |
| locally with: | |
| ```sh | |
| python3 -B -m unittest discover -s ci -p 'test_codex_review.py' -v | |
| ``` | |
| These tests use fake API data, make no GitHub changes, and include a deployment | |
| assertion requiring `.github/codex-review-ruleset.json` to remain disabled. | |
| Passing these tests does **not** by itself validate live GitHub ruleset | |
| enforcement or a reviewer's model-family honesty without an authenticated bot | |
| identity. | |
| Before re-enabling ruleset `26810364` and automated status publication: | |
| 1. Address [#28](https://github.com/google/anneal/issues/28) (including | |
| authenticating a dedicated Gate 2 bot identity via `--reviewer-login` or | |
| bot-ID pinning if required) and exercise both **acceptance and refusal** | |
| against the live GitHub integration before enabling enforcement. | |
| 2. Deploy and validate the evaluator and provide a **recovery path that | |
| preserves review history** rather than deleting prior reviews. | |
| 3. Reconcile the live GitHub ruleset with the checked-in ruleset template (and | |
| update the disabled-template deployment test deliberately). | |
| Re-enabling enforcement without those checks would restore the unresolved | |
| failure modes. | |
| [codex-github]: https://developers.openai.com/codex/integrations/github/ |