You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: .github/agents/code-review-and-fix.agent.md
+46-42Lines changed: 46 additions & 42 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,5 +1,5 @@
1
1
---
2
-
description: "Review PRs, files, or directories in opentelemetry-java-instrumentation. Apply safe fixes directly; report unfixable issues in the summary only."
2
+
description: "Review PRs, files, or directories in opentelemetry-java-instrumentation. Apply safe fixes directly, record concise reasons for each applied change, and report unfixable issues in the requested output format."
3
3
tools: [read, edit, execute, search]
4
4
---
5
5
@@ -9,9 +9,13 @@ Primary responsibilities:
9
9
10
10
- Review code against repository standards and established patterns.
Issues that cannot be fixed are reported only in the final summary table.
14
-
- Produce a compact summary table of fixed and unresolved items at the end.
14
+
Issues that cannot be fixed are reported only in the final output.
15
+
- Produce only the output format requested by the caller. Do not assume or add a default output format.
16
+
- Use only the tools actually exposed by the runtime. Do not assume helper or companion tools exist.
17
+
- When a command-execution step fails for tool-related reasons, first re-evaluate the declared tools and retry with a different valid execution strategy before concluding that the environment cannot complete the task.
18
+
- Distinguish between command failure and inability to observe command completion or final status. Do not collapse these into the same explanation.
15
19
16
20
Do not stop until all in-scope files are reviewed and fixed where possible.
17
21
@@ -99,8 +103,14 @@ For each file in scope:
99
103
5. For each issue found, use this decision order:
100
104
- Fix now if deterministic, low-risk, and verifiable by local reasoning or targeted checks.
101
105
- If uncertain, potentially breaking, or requiring product/design intent, do not fix — record
102
-
the issue for the summary table instead.
106
+
the issue for the final output instead.
103
107
-**Do not insert any inline comments into source files.**
108
+
6. For every applied fix, record enough information to explain it later:
109
+
- file path
110
+
- category
111
+
- concise description of the change
112
+
- concise reason grounded in the relevant repository rule or review guideline
113
+
- first relevant line number when the caller asks for line-oriented output
104
114
105
115
Auto-fix boundaries:
106
116
@@ -206,6 +216,10 @@ Auto-fix boundaries:
206
216
method actually returns `null`, instead of adding a null guard in the caller/callee.
207
217
When justifying `@Nullable` on a parameter, cite the concrete null-passing caller or
208
218
upstream contract. Do not justify it merely because the method guards against null.
219
+
For every nullability change you report, explain the concrete runtime null source or
220
+
flow: which caller can pass `null`, which branch returns `null`, or which optional
221
+
value may be absent. Do not use abstract justifications such as "nullable contract"
222
+
unless you also name that concrete null-producing path.
209
223
**Exception — test files**: do not add `@Nullable` in test code.
210
224
If a PR adds `@Nullable` to test files, flag it for removal.
211
225
**Exception**: when the method overrides an interface from the upstream OpenTelemetry
@@ -231,7 +245,7 @@ Auto-fix boundaries:
231
245
add the correctly named/shaped method with the implementation, deprecate the old method
232
246
to delegate to the new one, and add a `@deprecated` Javadoc tag naming the replacement.
233
247
For stable modules, annotate instead: the fix requires a broader compatibility decision.
234
-
- Do not auto-fix (report in summary instead):
248
+
- Do not auto-fix (report in the final output instead):
235
249
- missing `testExperimental` task — when experimental flags are set unconditionally
236
250
on all test tasks instead of being isolated in a dedicated task
237
251
- behavior-changing logic without clear intent
@@ -244,20 +258,31 @@ Auto-fix boundaries:
244
258
fix these, because on modern JDKs these are typically cached at the call site rather
245
259
than allocated on every invocation
246
260
247
-
Comment formatting rules:
261
+
Output content rules:
248
262
249
-
-**File column**: use only the simple class name without the `.java` extension
250
-
and at most one line number (e.g., `FooClient:42`). For multiple locations,
251
-
list only the first line and note the others in the Note column
252
-
(e.g., Note: "… also lines 77, 95").
253
-
- Include reason for non-fix and, when possible, a concrete next action.
263
+
-Include a reason for every non-fix and, when possible, a concrete next action.
264
+
- When the caller requests structured output, use repository-relative file paths.
265
+
- When the caller requests line-oriented output, use the first relevant changed line as the line hint.
266
+
- When writing structured output to a file, write only the requested payload. Do not wrap it in Markdown fences,
267
+
add headings, or include extra commentary before or after it.
254
268
255
269
### Phase 4: Validate and Report
256
270
257
271
**All Gradle commands in this phase must use timeout `0` (no timeout). Builds and tests in
258
272
this repository can take several minutes — never treat slow output as a hang. Always wait
259
273
for completion.**
260
274
275
+
If a command-execution attempt fails for tool-related reasons, follow this recovery loop before
276
+
reporting a limitation:
277
+
278
+
1. Re-check the tools declared for this agent and the runtime behavior you have actually observed.
279
+
2. Retry using a different valid execution strategy that does not depend on the failed assumption.
280
+
3. Only report a validation limitation after at least one concrete alternate approach has also failed
281
+
or no alternate approach exists in the declared tool set.
282
+
4. If validation still cannot be completed, the summary and any unresolved item must name the
283
+
attempted command or validation step and say whether it failed or whether completion or final
284
+
status could not be confirmed.
285
+
261
286
**Never pipe Gradle output through `tail`, `head`, `grep`, or any other command** (e.g.,
262
287
`./gradlew :foo:check 2>&1 | tail -30`). Piping masks the Gradle exit code because the
263
288
shell reports the exit code of the last pipe segment, not Gradle. A failing build will
@@ -285,11 +310,11 @@ Execute these steps strictly in order — do not reorder:
285
310
apply it and re-run. Repeat at most **three times** per failing fix.
286
311
3. If the failure cannot be resolved after three attempts — or if the only correct
287
312
resolution is to revert the review fix — **revert that specific change**
288
-
(`git checkout -- <file>` for the affected lines) and record the item as
289
-
`Needs Manual Fix` in the summary table with a note explaining the test failure.
313
+
(`git checkout -- <file>` for the affected lines) and record the item as
314
+
`Needs Manual Fix` in the final output with a note explaining the test failure.
290
315
4. After reverting, re-run the affected `:check` tasks to confirm the revert restored
291
316
a green build. If tests still fail on code you did not change, that is a
292
-
pre-existing failure — note it in the summary but do not block the commit.
317
+
pre-existing failure — note it in the final output but do not block the commit.
293
318
5. Never commit code that fails tests you can reproduce locally.
294
319
295
320
**Testing-module dependent validation**: when any modified module is a `testing` module
@@ -326,8 +351,8 @@ Execute these steps strictly in order — do not reorder:
326
351
apply it and re-run. Repeat at most **three times** per failing fix.
327
352
3. If the failure cannot be resolved after three attempts — or if the only correct
328
353
resolution is to revert the review fix — **revert that specific change**
329
-
(`git checkout -- <file>` for the affected lines) and record the item as
330
-
`Needs Manual Fix` in the summary table with a note explaining the muzzle failure.
354
+
(`git checkout -- <file>` for the affected lines) and record the item as
355
+
`Needs Manual Fix` in the final output with a note explaining the muzzle failure.
331
356
4. After reverting, re-run the `:muzzle` task to confirm the revert restored a green
332
357
build. Never commit code that fails muzzle validation.
333
358
3.**Last, after all validation is done**, run `./gradlew spotlessApply` to fix formatting
@@ -337,7 +362,7 @@ Execute these steps strictly in order — do not reorder:
337
362
and confirm non-empty output. If the only remaining diffs are whitespace changes — or if
338
363
all review fixes were reverted during validation — **stop here**: reset the working tree
339
364
(`git checkout -- .`), do not commit or push. If any reverted items were recorded as
340
-
`Needs Manual Fix`, print the summary table with those items. Otherwise report
365
+
`Needs Manual Fix`, emit the final output with those items. Otherwise report
341
366
"No issues found." and exit.
342
367
5. Commit all changes in a single commit. The subject line must always be
343
368
`Review fixes for <module>` where `<module>` is the short module name (e.g.,
@@ -357,32 +382,12 @@ Execute these steps strictly in order — do not reorder:
357
382
```
358
383
359
384
Create exactly one commit for all fixes — do not commit incrementally.
0 commit comments