> Agent-ready spec from Diff of the Day (2026-12-01, idea 2). Give this file to your coding agent (Claude Code, Codex, Cursor) and ask it to build the P0 requirements first.

# Spec: Auto-approval dry run

## Problem Statement
AI tools raise the number of pull requests faster than people can review them, so pull requests wait. Some changes are low risk and do not need a person, but a team cannot know which ones without evidence from its own history.

## Goals
- Classify the last 100 merged pull requests as "would auto-approve" or "needs a person" with written rules.
- Report how many auto-approved pull requests were later reverted or hot-fixed; the target is zero.
- Report the review hours the rules would have saved, from the time each pull request waited.

## Non-Goals
- Approving or merging anything: this is a read-only dry run.
- An AI reviewer: the first version uses rules on paths, size and checks only, so the result is easy to explain.
- Organisation-wide rollout: one repository is enough to learn from.

## User Stories
- As a tech lead, I want to see which past pull requests a policy would have approved so that I can judge the policy before I trust it.
- As a reviewer, I want each decision to name the rule that made it so that I can argue with it.
- Edge case: as a tech lead, I want a pull request that touches both a safe path and an unsafe path to count as "needs a person", so that a mixed change never slips through.

## Requirements
### P0
- A fetch step that reads merged pull requests through the GitHub API with a read-only token from the environment.
  - [ ] It stores files changed, lines changed, check results, wait time and merge time.
- A rule file with allow rules (paths, maximum size, required checks).
  - [ ] Every changed file must match an allow rule, or the pull request needs a person.
- A report with the decision and the rule for each pull request.
  - [ ] It flags each auto-approved pull request that a later revert or fix commit touched.

### P1
- Hours saved per rule, from the recorded wait times.
  - [ ] The report ranks rules by hours saved.

### P2
- A second pass that proposes one new rule from the "needs a person" group.
  - [ ] The proposal shows which pull requests it would add.

## Success Metrics
- Share of pull requests the rules would approve.
- Number of those that were later reverted or fixed.
- Review hours saved.

## Open Questions
- How do you link a revert or a hotfix to the pull request it repairs?
- Which paths in your repository are truly additive?

## Timeline
One weekend: fetch and rules on day one, revert check and report on day two.

## Agent Instructions
- Suggested stack: a script in the language of the repository, the GitHub REST API, a YAML rule file, Markdown output.
- Build order: fetch and cache, rule engine, report, revert link, hours saved.
- Safety: read the token from an environment variable, use read-only scope, never write to the repository or to a pull request.
- Done when: the report covers 100 merged pull requests and lists every auto-approved one that was later reverted.

## Sources
- https://www.linkedin.com/feed/update/urn:li:activity:7533168022912536577/
- https://lnkd.in/p/dRx96Ddu
