Agent Change Gate
Treat an agent-generated change as a candidate patch, not as proof of completion. Decide whether the exact revision satisfies its intent without creating hidden regressions, unsafe expansion, or unverifiable claims.
Review is read-only by default. Do not edit the patch, post comments, approve, merge, push, rerun external jobs, or trigger deployment unless the user explicitly authorizes that action.
Freeze the review object
Resolve before analysis:
- exact repository, base revision, head revision, and diff range
- dirty or untracked work that is outside the candidate change
- originating issue, task, specification, and acceptance criteria
- author-reported commands, tests, scans, limitations, and environment
- generated files, vendored code, lockfiles, migrations, and deployment artifacts in scope
Do not review the working tree as though every visible change belongs to the agent. If the base, head, or ownership of changes is ambiguous, return a hold instead of guessing or cleaning user work.
Author logs and self-review are useful provenance, but they are claims until reproduced or supported by independent artifacts.
Build the intent-to-diff ledger
Trace both directions:
- For each acceptance criterion, identify the implementing code path and the evidence that would prove it.
- For each changed hunk, identify the criterion, invariant, or necessary support work that justifies it.
Flag:
- Uncovered intent: a requirement has no implementation or proof.
- Orphan change: a hunk has no task-relevant justification.
- Hidden contract change: behavior, API, schema, permission, default, or operational semantics changed without being declared.
- Evidence gap: implementation exists but the selected check cannot discriminate correct from plausible behavior.
Do not infer that a passing test covers a criterion merely because both mention the same function or feature.
Map risk before reading line by line
Use the diff to identify surfaces where a small change can have a large consequence:
- authentication, authorization, tenancy, secrets, privacy, and auditability
- persistence, migrations, serialization, caches, queues, retries, and concurrency
- public APIs, schemas, protocols, compatibility, and versioning
- dependency manifests, lockfiles, build scripts, CI, packaging, and generated outputs
- external calls, filesystem effects, infrastructure, feature flags, and deployment paths
- error handling, fallback behavior, resource limits, observability, and rollback
Expand context around high-risk hunks: inspect callers, callees, data producers and consumers, boundary validation, related tests, configuration, and deleted code. A diff can look locally correct while breaking an upstream or downstream contract.
Keep review depth proportional to risk and change size. Do not spend the evidence budget on formatting while a migration, permission check, or dependency boundary remains unexamined.
Look for agent-specific failure patterns
Check whether the patch makes validation easier to pass rather than making behavior correct:
- weakened or deleted assertions, fixtures, types, lints, scanners, or approval gates
- tests rewritten to mirror the implementation instead of the requirement
- broad exception handling, silent fallbacks, hardcoded success, or mocked-away boundaries
- hand-edited generated files without changing their source
- unrelated lockfile churn, new dependencies, copied code, or expanded permissions
- ignored failures, skipped checks, reduced coverage, or configuration that disables enforcement
- user-visible claims not supported by the actual code path
These are investigation triggers, not automatic guilt. Confirm the behavioral consequence before reporting a blocker.
Select independent verification
Independence means the gate obtains evidence separately from the author narrative; it does not require a different model.
- Re-run the smallest authoritative checks from the declared working directory when the environment permits.
- Add or select a negative, boundary, or counterexample case that would fail under the likely wrong implementation.
- For a regression test, establish that it detects the prior failure using an isolated checkout, reversible comparison, or existing failing evidence; do not alter the reviewed worktree merely to prove this.
- Verify generated artifacts through their generator and source-of-truth check.
- Treat existing green CI as revision-specific evidence only after confirming it ran on the reviewed head with relevant jobs enabled.
- Distinguish not-run, passed, failed, flaky, blocked-by-environment, and inherited-from-author results.
Do not silently install dependencies, access secrets, start paid services, change external state, or broaden network access to complete verification. Mark the resulting limitation and decide whether it is material to the gate.
Check security and dependency impact
Use available project scanners when relevant, but do not treat scanner silence as a security review.
Inspect changed trust boundaries for:
- missing authorization or object ownership checks
- unsafe parsing, injection, path traversal, deserialization, or command construction
- sensitive data in code, fixtures, logs, URLs, telemetry, or error messages
- new packages, versions, registries, install scripts, licenses, and transitive reach
- insecure defaults, widened network or production access, and weakened sandboxing
- dependency behavior that differs between manifest, lockfile, and runtime
Report only claims supported by the repository, reproducible behavior, authoritative advisories, or scanner output tied to the reviewed revision.
Produce high-signal findings
Each finding must include:
- severity based on reachable consequence, not stylistic preference
- file and location or a precise behavior path
- violated requirement or invariant
- concrete failure scenario
- evidence already observed and the smallest verification that would settle uncertainty
- whether it blocks the gate
Cluster duplicates and omit speculative comments that cannot change the decision. If no actionable defect is found, say so and list material areas that remain unverified.
Return the gate
Use one verdict:
- PASS: every acceptance criterion is mapped, required checks pass on the reviewed revision, high-risk surfaces were examined, and no material evidence gap remains.
- HOLD: the change may be correct, but revision identity, requirements, environment, ownership, or decision-critical evidence is missing.
- BLOCK: an observed defect, regression, security issue, unjustified scope expansion, or failed required check makes merge or release unsafe.
Include the reviewed base/head, intent-to-diff coverage, commands and results, findings in severity order, unverified risks, and the minimum next action needed to change the verdict.
A PASS verdict is analysis, not authorization to approve, merge, publish, or deploy. If the user separately requests remediation, fix only confirmed findings, rerun the affected gate, and preserve the original review evidence.
Completion criteria
The gate is complete only when:
- the exact candidate revision and user-owned changes are distinguished
- every requirement and changed hunk has a traceable disposition
- verification includes at least one decision-relevant case independent of author claims
- security, dependency, generated-file, and enforcement changes were checked when present
- findings are reproducible and prioritized, or the absence of findings is stated without overstating coverage
- the verdict follows the evidence and does not perform the merge or release action
1---2name: agent-change-gate3description: Review and gate AI-generated code changes by reconstructing intent, mapping diff risk, selecting independent verification, checking security and dependency impact, and requiring evidence before merge or release. Use for coding-agent pull requests, autonomous patches, or large AI-generated diffs; do not use for ordinary implementation requests or style-only review.4license: MIT5---67# Agent Change Gate89Treat an agent-generated change as a candidate patch, not as proof of completion. Decide whether the exact revision satisfies its intent without creating hidden regressions, unsafe expansion, or unverifiable claims.1011Review is read-only by default. Do not edit the patch, post comments, approve, merge, push, rerun external jobs, or trigger deployment unless the user explicitly authorizes that action.1213## Freeze the review object1415Resolve before analysis:1617- exact repository, base revision, head revision, and diff range18- dirty or untracked work that is outside the candidate change19- originating issue, task, specification, and acceptance criteria20- author-reported commands, tests, scans, limitations, and environment21- generated files, vendored code, lockfiles, migrations, and deployment artifacts in scope2223Do not review the working tree as though every visible change belongs to the agent. If the base, head, or ownership of changes is ambiguous, return a hold instead of guessing or cleaning user work.2425Author logs and self-review are useful provenance, but they are claims until reproduced or supported by independent artifacts.2627## Build the intent-to-diff ledger2829Trace both directions:30311. For each acceptance criterion, identify the implementing code path and the evidence that would prove it.322. For each changed hunk, identify the criterion, invariant, or necessary support work that justifies it.3334Flag:3536- **Uncovered intent:** a requirement has no implementation or proof.37- **Orphan change:** a hunk has no task-relevant justification.38- **Hidden contract change:** behavior, API, schema, permission, default, or operational semantics changed without being declared.39- **Evidence gap:** implementation exists but the selected check cannot discriminate correct from plausible behavior.4041Do not infer that a passing test covers a criterion merely because both mention the same function or feature.4243## Map risk before reading line by line4445Use the diff to identify surfaces where a small change can have a large consequence:4647- authentication, authorization, tenancy, secrets, privacy, and auditability48- persistence, migrations, serialization, caches, queues, retries, and concurrency49- public APIs, schemas, protocols, compatibility, and versioning50- dependency manifests, lockfiles, build scripts, CI, packaging, and generated outputs51- external calls, filesystem effects, infrastructure, feature flags, and deployment paths52- error handling, fallback behavior, resource limits, observability, and rollback5354Expand context around high-risk hunks: inspect callers, callees, data producers and consumers, boundary validation, related tests, configuration, and deleted code. A diff can look locally correct while breaking an upstream or downstream contract.5556Keep review depth proportional to risk and change size. Do not spend the evidence budget on formatting while a migration, permission check, or dependency boundary remains unexamined.5758## Look for agent-specific failure patterns5960Check whether the patch makes validation easier to pass rather than making behavior correct:6162- weakened or deleted assertions, fixtures, types, lints, scanners, or approval gates63- tests rewritten to mirror the implementation instead of the requirement64- broad exception handling, silent fallbacks, hardcoded success, or mocked-away boundaries65- hand-edited generated files without changing their source66- unrelated lockfile churn, new dependencies, copied code, or expanded permissions67- ignored failures, skipped checks, reduced coverage, or configuration that disables enforcement68- user-visible claims not supported by the actual code path6970These are investigation triggers, not automatic guilt. Confirm the behavioral consequence before reporting a blocker.7172## Select independent verification7374Independence means the gate obtains evidence separately from the author narrative; it does not require a different model.7576- Re-run the smallest authoritative checks from the declared working directory when the environment permits.77- Add or select a negative, boundary, or counterexample case that would fail under the likely wrong implementation.78- For a regression test, establish that it detects the prior failure using an isolated checkout, reversible comparison, or existing failing evidence; do not alter the reviewed worktree merely to prove this.79- Verify generated artifacts through their generator and source-of-truth check.80- Treat existing green CI as revision-specific evidence only after confirming it ran on the reviewed head with relevant jobs enabled.81- Distinguish not-run, passed, failed, flaky, blocked-by-environment, and inherited-from-author results.8283Do not silently install dependencies, access secrets, start paid services, change external state, or broaden network access to complete verification. Mark the resulting limitation and decide whether it is material to the gate.8485## Check security and dependency impact8687Use available project scanners when relevant, but do not treat scanner silence as a security review.8889Inspect changed trust boundaries for:9091- missing authorization or object ownership checks92- unsafe parsing, injection, path traversal, deserialization, or command construction93- sensitive data in code, fixtures, logs, URLs, telemetry, or error messages94- new packages, versions, registries, install scripts, licenses, and transitive reach95- insecure defaults, widened network or production access, and weakened sandboxing96- dependency behavior that differs between manifest, lockfile, and runtime9798Report only claims supported by the repository, reproducible behavior, authoritative advisories, or scanner output tied to the reviewed revision.99100## Produce high-signal findings101102Each finding must include:103104- severity based on reachable consequence, not stylistic preference105- file and location or a precise behavior path106- violated requirement or invariant107- concrete failure scenario108- evidence already observed and the smallest verification that would settle uncertainty109- whether it blocks the gate110111Cluster duplicates and omit speculative comments that cannot change the decision. If no actionable defect is found, say so and list material areas that remain unverified.112113## Return the gate114115Use one verdict:116117- **PASS:** every acceptance criterion is mapped, required checks pass on the reviewed revision, high-risk surfaces were examined, and no material evidence gap remains.118- **HOLD:** the change may be correct, but revision identity, requirements, environment, ownership, or decision-critical evidence is missing.119- **BLOCK:** an observed defect, regression, security issue, unjustified scope expansion, or failed required check makes merge or release unsafe.120121Include the reviewed base/head, intent-to-diff coverage, commands and results, findings in severity order, unverified risks, and the minimum next action needed to change the verdict.122123A PASS verdict is analysis, not authorization to approve, merge, publish, or deploy. If the user separately requests remediation, fix only confirmed findings, rerun the affected gate, and preserve the original review evidence.124125## Completion criteria126127The gate is complete only when:128129- the exact candidate revision and user-owned changes are distinguished130- every requirement and changed hunk has a traceable disposition131- verification includes at least one decision-relevant case independent of author claims132- security, dependency, generated-file, and enforcement changes were checked when present133- findings are reproducible and prioritized, or the absence of findings is stated without overstating coverage134- the verdict follows the evidence and does not perform the merge or release action