Skip to content

Commit e333875

Browse files
committed
Fix inconsistencies between agent and copilot-review instructions
- Fix #1: Label management conditional on blocking findings (agent Step 9) - Fix #2: Add CI cross-reference step (agent Step 6a) - Fix #3: Add comment volume control caps (agent Step 8) - Fix #4: Add severity calibration section (agent) - Fix #6: Add design-decisions.md reference in severity calibration - Fix #7: Renumber steps (4a->5, 5->6, 6->7, 7->8, 8->9) - Fix #8: Expand Scenario E with agent-vs-human distinction (copilot-review) - Fix #10: Add source field to telemetry marker (agent/code-review)
1 parent 9e66a6a commit e333875

2 files changed

Lines changed: 95 additions & 19 deletions

File tree

.github/agents/arm-api-reviewer.agent.md

Lines changed: 82 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,7 @@ For each file type, read the corresponding instruction file(s) listed in "Author
159159
- For TypeSpec: Check the `Versions` enum for prior versions and review uses of `@added`, `@removed`, `@typeChangedFrom`.
160160
- Flag: removed properties, removed operations, type changes, narrowed enums, optional-to-required transitions, renamed paths.
161161
- If no previous version exists (new service), note this and skip the comparison.
162-
- **Record the previous version path** - it will be needed in Step 4a to classify issues as new vs. existing.
162+
- **Record the previous version path** - it will be needed in Step 5 to classify issues as new vs. existing.
163163

164164
**How to fetch previous versions:** Use GitHub MCP `get_file_contents` with `ref: "main"` (or the PR's base branch) to fetch files from the previous API version folder. To discover which prior version folders exist, use `get_file_contents` to list the directory (e.g., `specification/<service>/resource-manager/<ResourceProviderNamespace>/stable/`) on the base branch.
165165

@@ -198,7 +198,7 @@ When a PR adds or modifies a `readme.md` file that contains `directive` / `suppr
198198

199199
Apply the full "TypeSpec Review Checklist Summary" from `typespec-review.instructions.md`. Key areas include project structure, decorators, versioning, ARM resource patterns, secret detection, suppressions, and anti-patterns.
200200

201-
### Step 4a: New vs. Existing Issue Classification
201+
### Step 5: New vs. Existing Issue Classification
202202

203203
After completing the systematic review of the new version, classify every identified issue as **New** or **Existing** by checking whether the same violation is present in the previous API version:
204204

@@ -217,7 +217,7 @@ After completing the systematic review of the new version, classify every identi
217217

218218
4. **Verification:** Do not guess - always load and read the previous version's spec file to confirm whether an issue is pre-existing. A wrong classification wastes reviewer time.
219219

220-
### Step 5: Cross-File Consistency
220+
### Step 6: Cross-File Consistency
221221

222222
When a PR modifies multiple files or versions:
223223

@@ -228,11 +228,29 @@ When a PR modifies multiple files or versions:
228228
- Verify `readme.md` suppressions are consistent across versions - run the suppression continuity analysis described in Step 4 ("For `readme.md` suppression files").
229229
- For TypeSpec projects: verify generated OpenAPI under `stable/` or `preview/` is consistent with the `.tsp` source. If both are modified, confirm the JSON was regenerated (not hand-edited).
230230

231-
### Step 6: Report Findings
231+
### Step 6a: Check CI Results Before Posting
232+
233+
Before reporting a finding, check whether the same violation is already flagged by a CI check. If a CI check already reports it, **do not post a duplicate comment**. Instead, add depth that the CI check cannot: explain _why_ it matters and _how_ to fix it.
234+
235+
Key CI checks to cross-reference:
236+
237+
| CI Check Name | What It Catches | How to Avoid Duplicates |
238+
| ------------------------------- | --------------------------------------------------------- | --------------------------------------------------------------- |
239+
| `Swagger LintDiff` | Linter rule violations (130+ rules) | Rules annotated `(Also enforced by: <ID>)` in instruction files |
240+
| `Swagger BreakingChange` | Breaking changes vs. previous stable version | Skip if the agent's Step 3 finds the same break |
241+
| `BreakingChange(Cross-Version)` | Breaking changes across all versions | Same as above |
242+
| `Swagger ModelValidation` | Example files don't match operation schemas | Skip if agent flags the same example mismatch |
243+
| `Swagger SemanticValidation` | Structural OpenAPI errors (missing refs, invalid schemas) | Skip structural errors already reported |
244+
| `TypeSpec Validation` | TypeSpec compilation errors | Skip if already failing in CI |
245+
| `Swagger Avocado` | readme.md input-file references don't match actual files | Flag if agent finds missing files in tag configs |
246+
247+
When the agent finds an issue also caught by CI, the comment should reference the CI check: "_This is also flagged by the `Swagger LintDiff` CI check. See [aka.ms/ci-fix](https://aka.ms/ci-fix) for guidance on resolving CI failures._"
248+
249+
### Step 7: Report Findings
232250

233251
**Line number requirement:** Before writing any finding, you MUST resolve the exact line number of the violation. Read the file content, count or search for the specific line, and cite it as `line <N>` (e.g., `line 42`). For multi-line issues, cite the range `line <start>-<end>` (e.g., `line 10-15`). Vague references like "near end of file", "around line N", or "in the middle of the file" are **forbidden** - every finding must have a verifiable line number. For OpenAPI JSON, also include the JSON path (e.g., `$.paths['/foo'].put.responses.200`).
234252

235-
Organize your report as follows. Every issue **MUST** be tagged as `[NEW]` or `[EXISTING]` based on the classification from Step 4a:
253+
Organize your report as follows. Every issue **MUST** be tagged as `[NEW]` or `[EXISTING]` based on the classification from Step 5:
236254

237255
```markdown
238256
## API Review: `<service-name>/<api-version>`
@@ -294,7 +312,45 @@ These issues also exist in the previous version (`<previous-version>`) and were
294312

295313
Use the rule IDs from the instruction files (e.g., `RPC-Put-V1-01`, `RPC-Patch-V1-10`, `ARG001`, `TSP-2.1`). For generic rules without an explicit ID, cite the section name (e.g., "Section 6.1 - Naming", "Section 9 - Collections & Pagination").
296314

297-
### Step 7: Post Review Comments on PR
315+
### Severity Calibration
316+
317+
#### 🔴 Blocking (must fix before merge)
318+
319+
Use only when the rule says **MUST** and the violation is unambiguous:
320+
321+
- Security: secrets in GET/PUT/PATCH responses, missing `x-ms-secret`
322+
- Breaking changes: removed properties, changed types, new required fields
323+
- Missing CRUD operations on tracked resources
324+
- Incorrect response codes (PUT returning 202, DELETE returning 404)
325+
- Missing `provisioningState` on async resources
326+
- Missing security definitions
327+
328+
#### 🟡 Warning (should fix)
329+
330+
Use when the rule says **SHOULD** or the violation has clear impact:
331+
332+
- Missing descriptions on models/properties
333+
- `additionalProperties` on service-owned models
334+
- Boolean properties that should be enums
335+
- Suppressions without strong justification
336+
- Missing `x-ms-pageable` on collection operations
337+
338+
#### 💡 Suggestion (optional improvement)
339+
340+
Use for design trade-offs and best-practice recommendations:
341+
342+
- Grey-area decisions (see `.github/skills/azure-api-review/references/design-decisions.md` DD-001 through DD-010)
343+
- Property naming improvements
344+
- Enum value ordering
345+
- Documentation quality improvements
346+
347+
#### Skip (do not post)
348+
349+
- Violations already flagged by CI linter checks (see Step 6a)
350+
- Style nits that don't affect SDK generation or customer experience
351+
- Issues in unchanged files not modified by the PR
352+
353+
### Step 8: Post Review Comments on PR
298354

299355
After presenting the review findings to the human reviewer for approval:
300356

@@ -328,14 +384,15 @@ After presenting the review findings to the human reviewer for approval:
328384
8. Every posted comment **MUST** end with a hidden HTML telemetry marker as the very last line of the comment body. The marker format is:
329385

330386
```html
331-
<!-- posted-by: arm-api-reviewer-agent | rule: <RULE-ID> | severity: blocking|warning|suggestion | classification: new|existing -->
387+
<!-- posted-by: arm-api-reviewer-agent | source: agent | rule: <RULE-ID> | severity: blocking|warning|suggestion | classification: new|existing -->
332388
```
333389

390+
- **`source`**: Always `agent` for comments posted via this interactive agent. Automated Copilot Code Review uses `code-review` instead, enabling telemetry to distinguish the two posting mechanisms.
334391
- **`rule`**: The rule ID of the finding (e.g., `RPC-Put-V1-01`, `OAPI027`, `SEC-SECRET-DETECT`). Use `summary` for summary comments that don't flag a single rule.
335392
- **`severity`**: One of `blocking`, `warning`, or `suggestion`.
336393
- **`classification`**: One of `new` (introduced in this PR) or `existing` (pre-existing technical debt).
337394

338-
Example: `<!-- posted-by: arm-api-reviewer-agent | rule: RPC-Put-V1-11 | severity: blocking | classification: new -->`
395+
Example: `<!-- posted-by: arm-api-reviewer-agent | source: agent | rule: RPC-Put-V1-11 | severity: blocking | classification: new -->`
339396

340397
This marker is invisible in rendered markdown but enables querying agent-posted comments via the GitHub API, computing telemetry (comments per day, top rule violations, new-vs-existing ratio), and distinguishing agent comments from human comments during reconciliation. Do not omit this marker. All fields after `posted-by` are required.
341398

@@ -351,17 +408,28 @@ After presenting the review findings to the human reviewer for approval:
351408
- Wait for the reviewer to approve the plan before executing.
352409
11. Do NOT post comments without the human reviewer's approval.
353410

354-
### Step 8: Update PR Labels
411+
#### Comment Volume Control
412+
413+
Do not flood a PR with comments. Prioritize and cap:
414+
415+
1. **Security issues** -- always post (no cap)
416+
2. **Breaking changes** -- always post (no cap)
417+
3. **ARM contract violations** -- post up to 15
418+
4. **Property design / naming** -- post up to 5
419+
5. **Documentation gaps** -- post up to 3
420+
421+
If more findings exist beyond the cap, summarize them in a single comment: "_N additional warnings/suggestions were identified but not posted individually. Key themes: [list]. The author should review the full checklist in `armapi-review.instructions.md`._"
422+
423+
### Step 9: Update PR Labels
355424

356425
After successfully posting review comments to the PR:
357426

358-
1. **Propose label changes** to the human reviewer:
359-
- **Add** the `ARMChangesRequested` label to signal that the PR author needs to address review feedback.
360-
- **Remove** the `WaitForARMFeedback` label (if present) since ARM feedback has now been provided.
427+
1. **Propose label changes** to the human reviewer based on findings:
428+
- **If any `🔴 Blocking` findings were posted:** **Add** `ARMChangesRequested` and **remove** `WaitForARMFeedback` (if present).
429+
- **If no blocking findings were posted:** **Remove** `WaitForARMFeedback` (if present) to indicate ARM feedback has been provided. Do **not** add `ARMChangesRequested` -- there are no blocking changes to request.
361430
2. **Wait for explicit confirmation** from the human reviewer before adding or removing any labels. Do NOT modify labels without approval.
362431
3. Once approved, apply the label changes using the GitHub tools.
363-
4. If the PR does not have the `WaitForARMFeedback` label, skip the removal step and only propose adding `ARMChangesRequested`.
364-
5. Report to the human reviewer which labels were added and removed.
432+
4. Report to the human reviewer which labels were added and removed.
365433

366434
## Constraints
367435

.github/copilot-review-instructions.md

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -176,14 +176,15 @@ PUT operation is missing `201` response for resource creation. ARM PUT must retu
176176
Every comment **MUST** end with a hidden HTML telemetry marker as the very last line. The format is:
177177

178178
```html
179-
<!-- posted-by: arm-api-reviewer-agent | rule: <RULE-ID> | severity: blocking|warning|suggestion | classification: new|existing -->
179+
<!-- posted-by: arm-api-reviewer-agent | source: code-review | rule: <RULE-ID> | severity: blocking|warning|suggestion | classification: new|existing -->
180180
```
181181

182+
- **`source`**: Always `code-review` for automated Copilot Code Review comments. The interactive agent uses `agent` instead.
182183
- **`rule`**: The rule ID of the finding (e.g., `RPC-Put-V1-11`, `OAPI027`). Use `summary` for summary comments.
183184
- **`severity`**: One of `blocking`, `warning`, or `suggestion`.
184185
- **`classification`**: One of `new` or `existing`.
185186

186-
Example: `<!-- posted-by: arm-api-reviewer-agent | rule: RPC-Put-V1-11 | severity: blocking | classification: new -->`
187+
Example: `<!-- posted-by: arm-api-reviewer-agent | source: code-review | rule: RPC-Put-V1-11 | severity: blocking | classification: new -->`
187188

188189
To detect agent-posted comments during reconciliation, check for the substring `posted-by: arm-api-reviewer-agent` (matches both old and new marker formats).
189190

@@ -265,9 +266,16 @@ comment. Reply to the thread noting the line shift.
265266
Do not post new comments. Note that existing threads cover all issues.
266267

267268
**Scenario E -- Violation has been fixed:**
268-
If an existing unresolved comment flags a violation that no longer exists, reply
269-
to the thread noting the fix: "_The violation flagged here appears to have been
270-
addressed in the latest changes._"
269+
If an existing unresolved comment flags a violation that no longer exists in
270+
the latest code:
271+
272+
- If the comment body contains the substring `posted-by: arm-api-reviewer-agent`
273+
(agent-posted): reply noting the fix and resolve the comment: "_This issue
274+
has been addressed in the latest changes. Resolving._"
275+
- If the comment was from a human reviewer (no agent marker): do NOT resolve
276+
it. Instead, reply noting the fix: "_The violation flagged in this comment
277+
appears to have been addressed in the latest code changes. The original
278+
reviewer may want to verify and resolve._"
271279

272280
---
273281

0 commit comments

Comments
 (0)