Skip to content

Commit d9fac34

Browse files
authored
Merge pull request #3 from SuPuHe/feature/unified-agent-workflow
chore: unify agent review workflow
2 parents 6ea00fd + d295f8d commit d9fac34

13 files changed

Lines changed: 223 additions & 62 deletions

File tree

‎.agent/AGENTS.md‎

Lines changed: 22 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,23 @@ infrastructure, data, and model agent working in this repository.
1313
If instructions conflict, stop and surface the conflict. Do not silently choose
1414
the most convenient interpretation.
1515

16+
## Tool neutrality
17+
18+
- Shared policy must remain independent of agent vendor, model, operating
19+
system, and editor.
20+
- Codex, Claude, Antigravity, Cursor, or another capable agent may implement or
21+
review a change.
22+
- Tool-specific repository files must be thin adapters pointing to the
23+
canonical `AGENTS.md` and `.agent/` documents. Do not copy policy into them.
24+
- Personal prompts, permissions, model choices, and machine-specific commands
25+
belong in ignored local files.
26+
- A gate reviewer must use a fresh read-only session, must not be the
27+
implementation agent, and must identify its tool and platform-reported model
28+
in the verdict. Record `not exposed by platform` when no model identifier is
29+
available.
30+
- Different tools may perform Gate A and Gate B. Both must use the canonical
31+
prompts and required verdict format.
32+
1633
## Before making changes
1734

1835
- Read the task, acceptance criteria, relevant code, and related documentation.
@@ -84,15 +101,17 @@ blocker for the user.
84101
Follow `.agent/MILESTONE_IMPLEMENTATION_LOOP.md` exactly.
85102

86103
- Review Gate A is a fresh, independent review of the complete workspace change
87-
before the draft pull request is created. It evaluates the diff against the target
88-
base branch (`develop`), covering acceptance criteria, correctness, edge cases,
89-
security, and test coverage.
104+
before the draft pull request is created. It evaluates the staged candidate
105+
tree against the exact target base SHA, covering acceptance criteria,
106+
correctness, edge cases, security, and test coverage.
90107
- Review Gate B is a second fresh, independent review after the draft PR exists
91108
and required CI is green. Gate B is bound to the exact PR head commit SHA and verifies
92109
PR readiness, diff integrity, and check results.
93110
- The implementation agent must not act as its own independent reviewer. Reviewers
94111
must be invoked in an independent session using `.agent/review-prompts/implementation-review.md`
95112
for Gate A and `.agent/review-prompts/draft-pr-review.md` for Gate B.
113+
- No specific review vendor or model is mandatory unless a milestone explicitly
114+
requires one. Missing reviewer tool or reviewed Git identity is a failure.
96115
- Do not reuse or resume the Gate A session for Gate B.
97116
- Any content change after Gate A invalidates Gate A.
98117
- Any commit after Gate B invalidates Gate B.

‎.agent/MILESTONE_IMPLEMENTATION_LOOP.md‎

Lines changed: 37 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -44,12 +44,15 @@ objective, testable acceptance criteria.
4444
```bash
4545
git checkout develop
4646
git pull origin develop
47-
git checkout -b milestone/<id>-<name>
47+
git checkout -b feature/<name>
4848
```
49+
Use `fix/<name>` or `milestone/<id>-<name>` when appropriate.
4950
2. Make the smallest coherent change satisfying the milestone.
5051
3. Add or update tests and documentation alongside code.
5152
4. Inspect the full workspace diff (`git status`, `git diff`, untracked files)
5253
for scope drift, generated files, secrets, and unrelated edits.
54+
5. Stage only the complete intended candidate. Leave no intended change
55+
unstaged or untracked before Gate A.
5356

5457
The implementation may remain uncommitted through Gate A. Do not push a branch
5558
or create a PR yet.
@@ -71,10 +74,26 @@ Exit gate: All applicable local checks pass for the current workspace content.
7174

7275
## Phase 4 - Review Gate A: workspace implementation review
7376

74-
Run an independent review session using `.agent/review-prompts/implementation-review.md`.
77+
Refresh the base, then copy the two printed SHAs into the review evidence:
78+
79+
```bash
80+
git fetch origin develop
81+
git rev-parse origin/develop
82+
git write-tree
83+
git diff --cached <recorded-base-sha>
84+
```
85+
86+
`<recorded-base-sha>` is the immutable output from `git rev-parse
87+
origin/develop`, not the mutable remote-tracking ref itself.
88+
89+
Run a fresh, read-only independent review session using
90+
`.agent/review-prompts/implementation-review.md`. Any capable review tool may be
91+
used. Record its tool and platform-reported model name.
92+
If the platform does not expose a model identifier, record
93+
`not exposed by platform`.
7594

7695
The reviewer evaluates:
77-
- Complete workspace diff against `develop`;
96+
- Complete staged candidate tree against the recorded `develop` SHA;
7897
- Acceptance criteria coverage;
7998
- Edge cases, error handling, regressions;
8099
- Security, secrets, and licensing;
@@ -89,26 +108,28 @@ Gate decision:
89108
On `FAIL`, resolve every blocking finding, rerun local validation, and repeat Gate A
90109
in a fresh session.
91110

92-
Exit gate: Gate A returns an explicit `VERDICT: PASS`.
111+
Exit gate: Gate A returns an explicit `VERDICT: PASS` containing reviewer tool,
112+
model, base SHA, and candidate tree SHA.
93113

94114
## Phase 5 - Commit and create draft pull request
95115

96116
Only after Gate A passes:
97117

98-
1. Stage only the reviewed milestone files and inspect the staged diff.
99-
2. Commit the reviewed change.
100-
3. Push the branch to origin:
118+
1. Confirm `git write-tree` still equals the reviewed candidate tree SHA.
119+
2. Commit the reviewed staged change without modifying its content.
120+
3. Confirm `git rev-parse "HEAD^{tree}"` equals the reviewed candidate tree SHA.
121+
4. Push the branch to origin:
101122
```bash
102-
git push -u origin milestone/<id>-<name>
123+
git push -u origin HEAD
103124
```
104-
4. Create a **draft** pull request against `develop`.
105-
5. Fill out `.github/PULL_REQUEST_TEMPLATE.md` with:
125+
5. Create a **draft** pull request against `develop`.
126+
6. Fill out `.github/PULL_REQUEST_TEMPLATE.md` with:
106127
- Milestone outcome & scope;
107128
- Acceptance criteria checklist;
108129
- Risk assessment;
109130
- Validation evidence;
110131
- Review Gate A verdict and reviewer evidence.
111-
6. Keep the pull request in draft state.
132+
7. Keep the pull request in draft state.
112133

113134
Exit gate: The draft PR is created against `develop` with complete Gate A evidence.
114135

@@ -129,11 +150,16 @@ Exit gate: All required status checks are green for the exact PR head commit.
129150
Gate B runs in an independent reviewer session after CI passes, evaluating the draft PR
130151
using `.agent/review-prompts/draft-pr-review.md`.
131152

153+
Gate B may use any capable review tool, including a different tool from Gate A.
154+
It must run in a fresh read-only session and record its tool and
155+
platform-reported model, or `not exposed by platform`.
156+
132157
The reviewer independently inspects:
133158
- PR title, description, and diff against `develop`;
134159
- Commits and file changes;
135160
- Required CI status and check logs;
136161
- Gate A evidence and resolution of earlier findings;
162+
- Equality of the PR head tree and Gate A candidate tree;
137163
- Merge readiness and residual risks.
138164

139165
On `FAIL`, return to Phase 2. Any content change requires rerunning Phases 3 through 7.
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
# M0: Unified agent workflow
2+
3+
## Outcome
4+
5+
Every contributor follows one repository workflow while remaining free to use
6+
Codex, Claude, Antigravity, Cursor, or another capable agent.
7+
8+
## Acceptance criteria
9+
10+
- `AGENTS.md` and `.agent/` remain the only canonical shared policy.
11+
- Tool-specific files point to canonical policy instead of copying it.
12+
- Personal agent configuration is ignored.
13+
- Gate A records reviewer, available model identity, exact base SHA, and
14+
candidate tree SHA.
15+
- Gate B records reviewer, available model identity, exact PR head SHA, and
16+
equality with the Gate A candidate tree after required CI.
17+
- Pull requests run a minimal `Agent policy` status check.
18+
- Feature work targets `develop`; humans retain merge authority.
19+
20+
## Scope
21+
22+
In scope: shared policy, portable Git evidence, review prompts, PR evidence
23+
fields, Antigravity adapter, ignore rules, and minimal policy CI.
24+
25+
Out of scope: product implementation, selecting a mandatory review provider,
26+
Windows-only automation, branch-protection mutation, and merging existing
27+
`agents-setup` or Claude adapter branches.
28+
29+
## Validation
30+
31+
- Inspect complete diff against the recorded immutable `develop` base SHA.
32+
- Confirm Markdown links and referenced paths exist.
33+
- Confirm only intended files are staged.
34+
- Run the policy workflow checks locally where practical.
35+
- Run independent Gate A before commit and Gate B after draft PR checks.
36+
37+
## Risks and rollback
38+
39+
Risk: a tool may not auto-load `AGENTS.md`. Thin adapters handle known tools;
40+
the PR template and human review expose missing gate evidence.
41+
42+
Rollback: revert this documentation-only commit. No runtime or data migration
43+
exists.

‎.agent/review-prompts/draft-pr-review.md‎

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,9 @@ This must be a fresh review. Do not rely on memory or a resumed Gate A session.
1313
- Verify draft pull request number, base branch (`develop`), head branch, and head SHA.
1414
- Read the PR description, full GitHub PR diff, commits, required status checks,
1515
and Review Gate A evidence.
16-
- Confirm all evidence refers to the exact current PR head SHA.
16+
- Confirm CI and Gate B evidence refer to the exact current PR head SHA.
17+
- Gate A evidence is bound to its base SHA and candidate tree SHA. Verify the
18+
current PR head tree equals the Gate A candidate tree before accepting it.
1719

1820
## Required analysis
1921

@@ -24,7 +26,7 @@ Independently evaluate:
2426
- Whether CI covers changed behavior and all required checks are green;
2527
- Whether documentation, config, and migration paths are complete;
2628
- Whether the PR description provides sufficient detail for human review;
27-
- Whether any commit made after Gate A invalidates its conclusions;
29+
- Whether the current PR head tree and base still match Gate A evidence;
2830
- Whether the PR is safe to mark ready for human review (not whether it should be merged).
2931

3032
## Verdict standard
@@ -36,9 +38,13 @@ Use this exact structure:
3638

3739
```text
3840
VERDICT: PASS | FAIL
41+
REVIEWER_TOOL: <tool or agent system>
42+
REVIEWER_MODEL: <exact model name, or not exposed by platform>
3943
PR: <number and URL>
4044
REVIEWED_HEAD: <full SHA>
41-
REVIEWED_BASE: develop
45+
REVIEWED_HEAD_TREE: <full `HEAD^{tree}` SHA>
46+
REVIEWED_BASE: develop (<exact base SHA>)
47+
GATE_A_TREE: <candidate tree SHA; must equal REVIEWED_HEAD_TREE>
4248
4349
BLOCKING_FINDINGS:
4450
- <severity> <file:line or subsystem> - <problem, impact, and required fix>

‎.agent/review-prompts/implementation-review.md‎

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,9 @@ Do not attempt to fix a finding yourself. Report findings and return the require
88

99
- Read the repository `AGENTS.md` and `.agent/AGENTS.md`.
1010
- Target base branch: `develop` (or designated milestone base).
11-
- Review the complete workspace diff against the base, including committed,
12-
staged, unstaged, and untracked files.
11+
- Review the complete staged candidate tree against the recorded base SHA.
12+
- Verify `git status` contains no intended unstaged or untracked change omitted
13+
from the candidate.
1314
- Read the milestone acceptance criteria, requirements, and relevant docs.
1415

1516
## Required analysis
@@ -33,8 +34,11 @@ Use this exact structure:
3334

3435
```text
3536
VERDICT: PASS | FAIL
36-
REVIEWED_TARGET: <branch or commit SHA>
37-
REVIEWED_BASE: develop (<base SHA>)
37+
REVIEWER_TOOL: <tool or agent system>
38+
REVIEWER_MODEL: <exact model name, or not exposed by platform>
39+
REVIEWED_TARGET: <branch>
40+
REVIEWED_BASE: develop (<exact base SHA>)
41+
REVIEWED_TREE: <exact candidate tree SHA>
3842
3943
BLOCKING_FINDINGS:
4044
- <severity> <file:line or subsystem> - <problem, impact, and required fix>

‎.agents/rules/repository-policy.md‎

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
# OneShot repository policy
2+
3+
Load and follow these canonical repository policies before planning, editing,
4+
reviewing, committing, pushing, or opening a pull request:
5+
6+
@../../AGENTS.md
7+
@../../.agent/AGENTS.md
8+
@../../.agent/MILESTONE_IMPLEMENTATION_LOOP.md
9+
10+
This file is an Antigravity adapter only. Personal rules belong in local
11+
ignored files and must not override repository policy.

‎.antigravity/README.md‎

Lines changed: 6 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,9 @@
1-
# Antigravity CLI Review Configuration
1+
# Antigravity adapter
22

3-
This directory contains configuration, prompts, and documentation for personal code review workflows using Antigravity CLI (gy).
3+
Antigravity loads `.agents/rules/repository-policy.md`, which points to the
4+
canonical repository policy and implementation loop.
45

5-
## Purpose
6+
Use the shared prompts in `.agent/review-prompts/` for Gate A and Gate B.
7+
Personal Antigravity configuration and review logs stay local.
68

7-
- Allows developers to run independent Review Gate A and Review Gate B evaluations using Antigravity CLI without conflicting with other team members' local review tooling.
8-
- Keeps personal Antigravity review logs and configurations decoupled from core repository policies.
9-
10-
## Review Gates
11-
12-
- **Gate A (Pre-PR Workspace Review)**:
13-
Run in Antigravity CLI using .agent/review-prompts/implementation-review.md.
14-
Evaluates workspace diff against develop before draft PR creation.
15-
- **Gate B (Post-PR Draft Review)**:
16-
Run in Antigravity CLI using .agent/review-prompts/draft-pr-review.md.
17-
Evaluates draft PR head commit, status checks, and diff against develop.
9+
Reference: https://www.antigravity.google/docs/rules-workflows/

‎.antigravity/review.md‎

Lines changed: 0 additions & 14 deletions
This file was deleted.

‎.github/BRANCH_POLICY.md‎

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,12 +18,22 @@
1818
- Human review and approval.
1919
4. Agents must never merge pull requests. Final approval and merging is performed exclusively by the user.
2020

21+
## Agent review evidence
22+
23+
Canonical agent and review rules live in `AGENTS.md`, `.agent/AGENTS.md`, and
24+
`.agent/MILESTONE_IMPLEMENTATION_LOOP.md`. Pull requests record their required
25+
evidence through `.github/PULL_REQUEST_TEMPLATE.md`.
26+
27+
GitHub status checks and branch protection enforce merge readiness. Local agent
28+
instructions alone are not enforcement.
29+
2130
## Required status checks
2231

23-
As CI workflows are established in `.github/workflows/`, branch protection rules for `develop` and `main` must enforce:
24-
- Linting and static analysis;
25-
- Automated test suites;
26-
- Build / compilation checks.
32+
The initial required check for `develop` and `main` is:
33+
34+
- `Agent policy`.
35+
36+
Add lint, test, and build checks as executable project components appear.
2737

2838
## Protection rules
2939

‎.github/PULL_REQUEST_TEMPLATE.md‎

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -33,22 +33,27 @@
3333

3434
## Review Gate A - implementation
3535

36-
- Reviewed head / commit:
37-
- Reviewer / model:
36+
- Reviewed base SHA:
37+
- Reviewed candidate tree SHA:
38+
- Reviewer tool:
39+
- Reviewer model:
3840
- Verdict:
3941
- Blocking findings resolved:
4042
- Evidence / review summary:
4143

4244
## Required CI
4345

44-
- [ ] Lint and static analysis
45-
- [ ] Automated tests
46-
- [ ] Build validation
46+
- [ ] `Agent policy`
47+
- [ ] All project checks applicable to this change
48+
- [ ] No required check is missing, pending, skipped, or failing
4749

4850
## Review Gate B - draft PR
4951

5052
- Reviewed PR head SHA:
51-
- Reviewer / model:
53+
- Reviewed PR head tree SHA:
54+
- Matching Gate A candidate tree SHA:
55+
- Reviewer tool:
56+
- Reviewer model:
5257
- Verdict:
5358
- Blocking findings resolved:
5459
- Evidence / review summary:

0 commit comments

Comments
 (0)