@in-the-loop-labs/pair-review 5.2.3 → 5.3.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (49) hide show
  1. package/README.md +11 -3
  2. package/package.json +1 -1
  3. package/plugin/.claude-plugin/plugin.json +1 -1
  4. package/plugin-code-critic/.claude-plugin/plugin.json +1 -1
  5. package/plugin-code-critic/skills/analyze/references/level1-thorough.md +52 -121
  6. package/plugin-code-critic/skills/analyze/references/level2-thorough.md +49 -113
  7. package/plugin-code-critic/skills/analyze/references/level3-thorough.md +46 -195
  8. package/plugin-code-critic/skills/analyze/references/orchestration-thorough.md +56 -112
  9. package/plugin-pair-loop/.claude-plugin/plugin.json +1 -1
  10. package/public/css/analysis-config.css +29 -0
  11. package/public/css/pr.css +208 -0
  12. package/public/js/components/AIPanel.js +14 -9
  13. package/public/js/components/ChatPanel.js +790 -54
  14. package/public/js/components/ConfirmDialog.js +70 -2
  15. package/public/js/modules/pierre-bridge.js +58 -97
  16. package/public/js/modules/suggestion-manager.js +9 -121
  17. package/public/js/pr.js +15 -28
  18. package/public/js/utils/scroll-into-view.js +18 -4
  19. package/src/ai/analyzer.js +30 -5
  20. package/src/ai/antigravity-provider.js +7 -6
  21. package/src/ai/claude-provider.js +4 -8
  22. package/src/ai/codex-provider.js +3 -4
  23. package/src/ai/index.js +2 -0
  24. package/src/ai/muse-provider.js +3 -4
  25. package/src/ai/omp-provider.js +27 -12
  26. package/src/ai/pi-provider.js +12 -6
  27. package/src/ai/prompts/baseline/consolidation/thorough.js +56 -43
  28. package/src/ai/prompts/baseline/level1/thorough.js +76 -138
  29. package/src/ai/prompts/baseline/level2/thorough.js +76 -129
  30. package/src/ai/prompts/baseline/level3/thorough.js +67 -212
  31. package/src/ai/prompts/baseline/orchestration/thorough.js +79 -130
  32. package/src/ai/prompts/render-for-skill.js +5 -0
  33. package/src/ai/prompts/shared/adversarial-verification.js +68 -0
  34. package/src/ai/provider.js +60 -1
  35. package/src/ai/stream-parser.js +22 -1
  36. package/src/chat/acp-bridge.js +11 -0
  37. package/src/chat/chat-models.js +348 -0
  38. package/src/chat/chat-providers.js +17 -0
  39. package/src/chat/claude-code-bridge.js +9 -0
  40. package/src/chat/codex-bridge.js +6 -1
  41. package/src/chat/omp-bridge.js +5 -0
  42. package/src/chat/pi-bridge.js +20 -5
  43. package/src/chat/session-manager.js +158 -63
  44. package/src/config.js +92 -5
  45. package/src/git/worktree.js +29 -10
  46. package/src/github/client.js +30 -10
  47. package/src/hooks/payloads.js +5 -1
  48. package/src/routes/chat.js +83 -11
  49. package/src/setup/pr-setup.js +54 -1
@@ -2,16 +2,18 @@
2
2
  /**
3
3
  * Level 1 Thorough Prompt - Changes in Isolation Analysis (Deep Review)
4
4
  *
5
- * This is the thorough tier variant of Level 1 analysis. It is optimized for
6
- * careful, detailed reviews with extended reasoning and comprehensive guidance.
5
+ * This is the thorough tier variant of Level 1 analysis. It is targeted at
6
+ * frontier reasoning models and is optimized for depth and precision rather
7
+ * than instructional breadth: it states the mission and the evidence bar,
8
+ * and trusts the model to know what a bug is.
7
9
  *
8
- * Tier-specific optimizations applied:
9
- * - EXTENDED: Focus areas with more detailed analysis considerations
10
- * - ADDED: Confidence calibration guidance section
11
- * - ADDED: Reasoning encouragement section
12
- * - EXPANDED: Category definitions with examples
13
- * - EXPANDED: Guidelines with additional considerations
14
- * - INCLUDED: All optional sections
10
+ * Tier-specific design decisions:
11
+ * - ADDED: Mission section (depth-first hunting, no checklist padding)
12
+ * - ADDED: Verification standard (concrete failure scenario + refute-before-report)
13
+ * - ADDED: Do-not-report list (false-positive suppression)
14
+ * - REMOVED: Category taxonomy tutoring and reasoning-encouragement boilerplate
15
+ * - UNIFIED: Confidence semantics (probability the finding is real, set by
16
+ * verification performed) shared across all pipeline stages
15
17
  *
16
18
  * Section categories:
17
19
  * - locked: Cannot be modified by variants (data integrity)
@@ -50,16 +52,11 @@ const taggedPrompt = `<section name="role" required="true" tier="thorough">
50
52
  {{lineNumberGuidance}}
51
53
  </section>
52
54
 
53
- <section name="reasoning-encouragement" required="true" tier="thorough">
54
- ## Reasoning Approach
55
- Take your time to analyze the changes thoroughly. For each potential issue you identify:
56
- 1. Consider the context and intent behind the change
57
- 2. Think through edge cases and failure modes
58
- 3. Evaluate the severity and likelihood of the issue
59
- 4. Consider whether this is a genuine problem or a stylistic preference
60
- 5. Formulate a clear, actionable suggestion when appropriate
55
+ <section name="mission" required="true" tier="thorough">
56
+ ## Mission
57
+ Find real defects introduced by this change. Security issues and correctness are the primary target; everything else is opportunistic.
61
58
 
62
- Quality matters more than speed for this review level. It's better to surface fewer, high-confidence issues than many low-confidence ones.
59
+ Work depth-first, not checklist-first: understand what the change is trying to do, then hunt for the ways it fails to do it. One verified bug is worth more than ten plausible observations. Do not manufacture findings to cover categories — if the change is sound, say so and return few or no suggestions.
63
60
  </section>
64
61
 
65
62
  <section name="generated-files" optional="true" tier="balanced,thorough">
@@ -72,59 +69,45 @@ ONLY create suggestions for files in this list. If you cannot find issues in the
72
69
  {{validFiles}}
73
70
  </section>
74
71
 
75
- <section name="initial-setup" required="true" tier="thorough">
76
- ## Initial Setup
77
- 1. Run the annotated diff tool (shown above) to see the changes with line numbers
78
- 2. Carefully read through all changes to understand the overall intent
79
- 3. Focus on the changed lines in the diff, but note patterns across multiple changes
80
- 4. Do not analyze file context or surrounding unchanged code
81
- 5. Consider what could go wrong with each change
72
+ <section name="scope" required="true" tier="thorough">
73
+ ## Scope
74
+ Level 1 reviews the change itself, as visible in the diff.
75
+
76
+ - Start by running the annotated diff tool (shown above) and reading all changes to understand the overall intent.
77
+ - Report issues caused or surfaced by the changed lines. You may anchor a finding to a nearby context line when that is where the issue manifests, but the finding must be about this change's effect.
78
+ - You may read surrounding code to confirm or refute a candidate finding — verification is never scope creep. But do not go hunting for issues in unchanged code: pre-existing problems the change does not touch, file-wide patterns, and missing tests belong to Levels 2 and 3.
82
79
  </section>
83
80
 
84
81
  <section name="focus-areas" required="true" tier="thorough">
85
- ## Analysis Focus Areas
86
- Carefully identify and analyze the following in changed code:
87
-
88
- ### Correctness
89
- - Bugs, errors, or incorrect behavior in the modified code
90
- - Logic issues that could lead to unexpected results
91
- - Off-by-one errors, boundary conditions, and edge cases
92
- - Null/undefined handling and defensive programming
93
- - Type mismatches or incorrect type assumptions
94
-
95
- ### Security
96
- - Security vulnerabilities in the changed lines
97
- - Input validation and sanitization issues
98
- - Potential injection vulnerabilities (SQL, XSS, command injection)
99
- - Authentication and authorization concerns
100
- - Sensitive data exposure or logging
101
-
102
- ### Performance
103
- - Performance issues visible in the diff
104
- - Inefficient algorithms or data structures
105
- - Unnecessary operations or redundant computations
106
- - Memory leaks or resource management issues
107
- - N+1 query patterns or database performance concerns
108
-
109
- ### Code Quality
110
- - Code style and formatting issues
111
- - Naming convention violations
112
- - Design pattern violations visible in isolation
113
- - Magic numbers or hardcoded values that should be constants
114
- - Duplicated logic within the changes
115
- - Overly complex or hard-to-read code
116
-
117
- ### Documentation
118
- - Documentation issues visible in the changed lines
119
- - Missing or incorrect comments for complex logic
120
- - Outdated comments that don't match the code
121
- - Missing JSDoc/docstrings for public APIs
122
-
123
- ### Good Practices
124
- - Good practices worth praising and reinforcing
125
- - Clean, readable implementations
126
- - Thoughtful error handling
127
- - Well-designed abstractions
82
+ ## What to Hunt For
83
+ In priority order:
84
+
85
+ 1. **Security** — injection (SQL, XSS, command, path traversal), missing authentication or authorization on new surface area, secrets or sensitive data in code or logs, unsafe input handling or deserialization.
86
+ 2. **Correctness** — logic errors, boundary and off-by-one mistakes, unhandled null/undefined on reachable paths, type mismatches, broken or swallowed error handling, concurrency hazards (shared mutable state, unawaited promises, check-then-act races).
87
+ 3. **Over-engineering** — abstractions with one caller, indirection that adds no capability, configurability nothing uses, speculative generality. Report only with the simpler equivalent sketched, ideally as a GitHub suggestion block.
88
+ 4. **Opportunistic** (only when clear and worth the reviewer's time) — performance problems visible in the diff (accidental O(n^2), N+1 patterns, leaked resources), misleading names, comments or docs the change has made incorrect, duplicated logic within the change.
89
+ 5. **Praise** — at most 1-2 items, and only for genuinely noteworthy work (a subtle edge case handled, a tricky invariant preserved). Routine competence is not praiseworthy.
90
+ </section>
91
+
92
+ <section name="verification-standard" required="true" tier="thorough">
93
+ ## Verification Standard
94
+ Every bug or security finding must survive an attempt to kill it:
95
+
96
+ 1. **State the failure concretely.** Identify the specific inputs or state under which the code misbehaves, and what goes wrong. "This could be null" is not a finding; "when the request omits X, this dereferences null and the handler crashes" is.
97
+ 2. **Try to refute it.** Read the code that would prevent the failure — upstream validation, guards, caller behavior, type constraints. If the defense exists, discard the finding.
98
+ 3. **Report on the evidence, either way.** Put the failure scenario in the description and the verification steps you performed in the reasoning array. Set confidence by how much verification you actually did, not by how plausible the issue sounds. Discard only what you actually refuted — a concrete failure scenario you could neither confirm nor refute is reported as a question at 0.3-0.5 confidence, stating what you could not verify.
99
+ 4. **Security findings are attack scenarios.** Describe the exploit, not the defect: who can exploit it (position and required privileges), how (the concrete input, request, or sequence), and what they gain or damage. The code-level fix belongs in the suggestion field. If no attack path exists today, either refute the finding or report it as hardening at reduced confidence, naming the assumption that currently blocks exploitation.
100
+ 5. **Simplicity findings must show the simpler version.** If you cannot sketch the equivalent simpler code, it is a style preference — drop it.
101
+ </section>
102
+
103
+ <section name="do-not-report" required="true" tier="thorough">
104
+ ## Do Not Report
105
+ - Pre-existing issues in code this change does not touch (unless the change makes them worse)
106
+ - Anything a linter or formatter would catch (formatting, import ordering, semicolons)
107
+ - Speculative failures with no reachable trigger — name the concrete scenario or drop the finding. Exception: a high-impact hazard you cannot statically verify (races, ordering, lifecycle, environment- or configuration-dependent behavior) may be reported as a question at 0.3-0.5 confidence, stating what you could not confirm
108
+ - Style preferences framed as defects
109
+ - Test coverage gaps — Level 3 evaluates testing; do not go looking for missing tests here
110
+ - Findings that remain below 0.3 confidence even after verification
128
111
  </section>
129
112
 
130
113
  <section name="available-commands" required="true" tier="thorough">
@@ -133,11 +116,10 @@ You have READ-ONLY access to the codebase. You may run commands like:
133
116
  - The annotated diff tool shown above (preferred for viewing changes with line numbers)
134
117
  - \`cat -n <file>\` to view files with line numbers
135
118
  - ls, find, grep commands as needed
119
+ - If your environment provides a subagent or task-delegation tool, you may use it to verify independent findings in parallel
136
120
 
137
121
  IMPORTANT: Do NOT modify any files. Do NOT run write commands (rm, mv, git commit, etc.).
138
122
  Your role is strictly to analyze and report findings.
139
-
140
- Note: You may optionally use parallel read-only Tasks to analyze different parts of the changes if that would be helpful for a thorough analysis.
141
123
  </section>
142
124
 
143
125
  <section name="severity-classification" required="true">
@@ -183,75 +165,28 @@ The content inside the block is the complete replacement for the commented line(
183
165
  </section>
184
166
 
185
167
  <section name="diff-instructions" required="true" tier="thorough">
186
- ## Line Number Reference (old_or_new field)
187
- The "old_or_new" field indicates which line number column to use:
188
- - **"NEW"** (default): Use the NEW column number. This is correct for:
189
- - ADDED lines marked with [+]
190
- - CONTEXT lines (unchanged lines that appear in both versions)
191
- - **"OLD"**: Use the OLD column number. ONLY use this for DELETED lines marked with [-].
192
-
193
- **IMPORTANT**: Context lines exist in BOTH the old and new file - always use "NEW" for context lines.
194
- Only use "OLD" when the line is prefixed with [-] indicating it was deleted.
195
-
196
- If you are unsure, use "NEW" - it is correct for the vast majority of suggestions.
168
+ ## old_or_new Field Reference
169
+ Use "NEW" (the default) for added lines [+] and context lines. Use "OLD" only for DELETED lines marked with [-]. When uncertain, use "NEW".
197
170
  </section>
198
171
 
199
172
  <section name="confidence-guidance" required="true" tier="thorough">
200
173
  ## Confidence Calibration
201
- **Confidence** reflects your certainty that something IS an issue:
202
- - High (0.8-1.0): You're certain this is a real problem
203
- - Medium (0.5-0.79): Likely an issue, but context might justify it
204
- - Low (0.3-0.49): Possibly an issue, requires human judgment
205
- - Very low (<0.3): Observation only - flag for human awareness
206
-
207
- Note: Confidence is about certainty, not severity. A minor style issue can have high confidence. A potential security issue might have low confidence if you're unsure it's exploitable.
208
- </section>
174
+ **Confidence** is the probability that the finding is real and correctly described:
175
+ - High (0.8-1.0): You verified it — traced the failing path, checked the guards, confirmed the scenario
176
+ - Medium (0.5-0.79): Strong evidence, but part of the failure path is unverified
177
+ - Low (0.3-0.49): Plausible, but depends on context or runtime behavior you could not confirm
178
+ - Very low (<0.3): Do not report — see Do Not Report
209
179
 
210
- <section name="category-definitions" required="true" tier="thorough">
211
- ## Category Definitions
212
-
213
- ### Issue Types
214
- - **bug**: Errors, crashes, or incorrect behavior. Code that will fail at runtime or produce wrong results.
215
- - Example: Null pointer dereference, infinite loop, incorrect calculation
216
- - **improvement**: Enhancements to make existing code better. The code works but could be cleaner or more maintainable.
217
- - Example: Extract duplicated code, simplify complex conditionals
218
- - **praise**: Good practices worth highlighting and reinforcing. Positive feedback for well-written code.
219
- - Example: Excellent error handling, clear naming, thorough edge case coverage
220
- - **suggestion**: General recommendations to consider. Ideas that may or may not be appropriate.
221
- - Example: Consider using a different data structure, think about caching
222
- - **design**: Architecture and structural concerns visible in the changes.
223
- - Example: Violates single responsibility, unclear abstraction boundaries
224
- - **performance**: Speed, memory, or efficiency optimizations.
225
- - Example: O(n^2) where O(n) is possible, unnecessary allocations
226
- - **security**: Vulnerabilities, safety issues, or security best practice violations.
227
- - Example: SQL injection, XSS, hardcoded credentials, insecure defaults
228
- - **code-style**: Formatting, naming conventions, and code style issues.
229
- - Example: Inconsistent naming, missing semicolons, unusual indentation
180
+ Note: Confidence is about certainty, not severity. A naming issue can be high confidence; a suspected race condition can be high severity at low confidence.
230
181
  </section>
231
182
 
232
183
  <section name="guidelines" required="true" tier="thorough">
233
- ## Important Guidelines
234
-
235
- ### What to Review
236
- - You may comment on any line in modified files
237
- - Prioritize changed lines, but include unchanged lines when they reveal issues (missing error handling, inconsistent patterns, etc.)
238
- - Focus on issues visible in the diff itself - do not analyze file context
239
- - Prefer line-level comments over file-level comments when the suggestion applies to a specific line or range of lines
240
- - Do not review unchanged code or missing tests
241
- - Do not analyze file-level patterns or consistency
242
-
243
- ### Output Quality
244
- - For "praise" type suggestions: Omit the suggestion field entirely (no action needed)
245
- - For other types always include specific, actionable suggestions that the developer can implement
246
- - Provide enough context in the description that a developer can understand the issue without seeing the code
247
- - Avoid vague suggestions like "consider improving this" - be specific about what and how
248
-
249
- ### Review Philosophy
250
- - Be constructive, not critical - the goal is to help, not to find fault
251
- - Consider the developer's intent and try to understand why they made certain choices
252
- - Distinguish between "must fix" issues and "nice to have" improvements
253
- - When in doubt, ask a question rather than making an assumption
254
- - Praise good code to reinforce positive patterns
184
+ ## Guidelines
185
+ - Prefer line-level comments anchored to the exact line where the issue manifests
186
+ - Every non-praise suggestion must be actionable: say specifically what to change and how. Use a GitHub suggestion block when you can write the exact replacement
187
+ - Write descriptions a developer can evaluate without re-deriving your analysis: the scenario, the consequence, the fix
188
+ - You are assisting a human reviewer who makes the final call. Distinguish "must fix" from "worth considering", and when the developer's intent is unclear, phrase the finding as a question rather than an accusation
189
+ - Your reply is the JSON object alone — no sentence announcing what you will do, no narration of what you did. The first character of your reply is \`{\`
255
190
  </section>`;
256
191
 
257
192
  /**
@@ -264,23 +199,25 @@ const sections = [
264
199
  { name: 'custom-instructions', optional: true, tier: ['balanced', 'thorough'] },
265
200
  { name: 'level-header', required: true, tier: ['thorough'] },
266
201
  { name: 'line-number-guidance', required: true, tier: ['thorough'] },
267
- { name: 'reasoning-encouragement', required: true, tier: ['thorough'] },
202
+ { name: 'mission', required: true, tier: ['thorough'] },
268
203
  { name: 'generated-files', optional: true, tier: ['balanced', 'thorough'] },
269
204
  { name: 'valid-files', locked: true },
270
- { name: 'initial-setup', required: true, tier: ['thorough'] },
205
+ { name: 'scope', required: true, tier: ['thorough'] },
271
206
  { name: 'focus-areas', required: true, tier: ['thorough'] },
207
+ { name: 'verification-standard', required: true, tier: ['thorough'] },
208
+ { name: 'do-not-report', required: true, tier: ['thorough'] },
272
209
  { name: 'available-commands', required: true, tier: ['thorough'] },
273
210
  { name: 'severity-classification', required: true },
274
211
  { name: 'output-schema', locked: true },
275
212
  { name: 'diff-instructions', required: true, tier: ['thorough'] },
276
213
  { name: 'confidence-guidance', required: true, tier: ['thorough'] },
277
- { name: 'category-definitions', required: true, tier: ['thorough'] },
278
214
  { name: 'guidelines', required: true, tier: ['thorough'] }
279
215
  ];
280
216
 
281
217
  /**
282
218
  * Default section order for Level 1 Thorough
283
- * Note: Added reasoning-encouragement and confidence-guidance sections
219
+ * Note: mission/verification-standard/do-not-report replace the former
220
+ * reasoning-encouragement and category-definitions sections
284
221
  */
285
222
  const defaultOrder = [
286
223
  'role',
@@ -288,17 +225,18 @@ const defaultOrder = [
288
225
  'custom-instructions',
289
226
  'level-header',
290
227
  'line-number-guidance',
291
- 'reasoning-encouragement',
228
+ 'mission',
292
229
  'generated-files',
293
230
  'valid-files',
294
- 'initial-setup',
231
+ 'scope',
295
232
  'focus-areas',
233
+ 'verification-standard',
234
+ 'do-not-report',
296
235
  'available-commands',
297
236
  'severity-classification',
298
237
  'output-schema',
299
238
  'diff-instructions',
300
239
  'confidence-guidance',
301
- 'category-definitions',
302
240
  'guidelines'
303
241
  ];
304
242
 
@@ -3,16 +3,17 @@
3
3
  * Level 2 Thorough Prompt - File Context Analysis (Deep Review)
4
4
  *
5
5
  * This is the thorough tier variant of Level 2 analysis (file context).
6
- * It is optimized for careful, detailed reviews with extended reasoning
7
- * and comprehensive guidance for file-level pattern analysis.
6
+ * It is targeted at frontier reasoning models and is optimized for depth
7
+ * and precision: file conventions are treated as evidence of intent, not
8
+ * authority, and every finding must clear a verification bar.
8
9
  *
9
- * Tier-specific optimizations applied:
10
- * - EXTENDED: Focus areas with more detailed analysis considerations
11
- * - ADDED: Confidence calibration guidance section
12
- * - ADDED: Reasoning framework section (multi-phase analysis)
13
- * - EXPANDED: Category definitions with examples
14
- * - EXPANDED: Guidelines with additional considerations
15
- * - INCLUDED: All optional sections including file-level-guidance
10
+ * Tier-specific design decisions:
11
+ * - KEPT: Multi-phase reasoning framework (contract -> integration -> impact)
12
+ * - ADDED: Conventions-as-evidence section (deviations may be improvements)
13
+ * - ADDED: Verification standard (failure scenarios + cited pattern lines)
14
+ * - ADDED: Do-not-report list (false-positive suppression)
15
+ * - REMOVED: Category taxonomy tutoring and per-category consistency checklists
16
+ * - UNIFIED: Confidence semantics shared across all pipeline stages
16
17
  *
17
18
  * Section categories:
18
19
  * - locked: Cannot be modified by variants (data integrity)
@@ -51,30 +52,33 @@ const taggedPrompt = `<section name="role" required="true" tier="thorough">
51
52
  {{lineNumberGuidance}}
52
53
  </section>
53
54
 
54
- <section name="reasoning-encouragement" required="true" tier="thorough">
55
+ <section name="reasoning-framework" required="true" tier="thorough">
55
56
  ## Reasoning Framework
56
57
 
57
58
  For each file, build a mental model before identifying issues:
58
59
 
59
60
  **Phase 1: Understand the File's Contract**
60
- - What implicit contracts does this file establish? (error handling conventions, naming patterns, abstraction levels)
61
- - What invariants should be maintained? (ordering, initialization patterns, resource lifecycle)
62
- - What are the file's extension points and how should new code integrate with them?
61
+ - What implicit contracts does this file establish? (error handling conventions, invariants, resource lifecycle, extension points)
63
62
 
64
63
  **Phase 2: Evaluate Change Integration**
65
- - How do the changes interact with existing code paths?
66
- - Are there implicit dependencies that the changes might break?
67
- - Do the changes respect or violate the file's established boundaries?
64
+ - How do the changes interact with existing code paths in the file?
65
+ - Are there implicit dependencies the changes break, or related sections that should have changed together but didn't?
68
66
 
69
- **Phase 3: Multi-step Impact Analysis**
70
- - Trace through: if this code runs, what downstream effects occur within the file?
71
- - Consider edge cases: what happens at boundaries, with null/empty inputs, under concurrent access?
72
- - Think about maintenance: will a future developer understand why this code exists?
67
+ **Phase 3: Trace Impact**
68
+ - If this code runs, what happens downstream within the file? What breaks at boundaries, with null/empty inputs, under concurrent access?
73
69
 
74
70
  **Output Calibration**
75
71
  Surface issues that genuinely require file context understanding. If an issue could be found from the diff alone, it belongs in Level 1 - skip it here. It's better to report fewer high-confidence file-context issues than to pad output with observations that don't require seeing the full file.
76
72
  </section>
77
73
 
74
+ <section name="conventions-as-evidence" required="true" tier="thorough">
75
+ ## Conventions Are Evidence, Not Law
76
+ The file's established patterns tell you what the author intended — treat them as evidence, not authority:
77
+ - When a change deviates from the file's pattern accidentally, flag the deviation and cite the lines that establish the pattern to match.
78
+ - When a deviation is an improvement, say so — do not ask the developer to regress to the older, worse pattern for the sake of uniformity.
79
+ - When the file's existing pattern is itself the problem (swallowed errors, copy-paste blocks the change just extended), flag that. Recommending conformance to a bad pattern spreads it.
80
+ </section>
81
+
78
82
  <section name="generated-files" optional="true" tier="balanced,thorough">
79
83
  {{generatedFiles}}
80
84
  </section>
@@ -95,10 +99,10 @@ For each file with changes:
95
99
  1. **Build Context First**
96
100
  - Read the full file to understand its purpose and architecture
97
101
  - Run the annotated diff tool with the file path to see precise line numbers
98
- - Identify the file's implicit rules: How does it handle errors? What naming conventions does it use? What patterns recur?
102
+ - Identify the file's implicit rules: How does it handle errors? What invariants does it maintain? What patterns recur?
99
103
 
100
104
  2. **Analyze Integration Quality**
101
- - Do the changes follow or violate the file's established patterns?
105
+ - Do the changes follow, improve, or accidentally violate the file's established patterns?
102
106
  - Are there related code sections that should change together but didn't?
103
107
  - Does the change maintain the file's abstraction boundaries?
104
108
 
@@ -109,53 +113,32 @@ For each file with changes:
109
113
  </section>
110
114
 
111
115
  <section name="focus-areas" required="true" tier="thorough">
112
- ## Analysis Focus Areas
113
- Carefully identify and analyze the following within file context:
114
-
115
- ### Consistency
116
- - Naming convention consistency within the file
117
- - Error handling patterns - are they consistent with the rest of the file?
118
- - Logging patterns and conventions
119
- - Comment and documentation style consistency
120
- - Import organization and grouping patterns
121
- - Function/method ordering and organization
122
-
123
- ### Integration Quality
124
- - How well do changes integrate with existing code patterns?
125
- - Are there related sections that should change together?
126
- - Do changes maintain the file's existing abstraction levels?
127
- - Is the code organization coherent after the changes?
128
-
129
- ### Security (File Scope)
130
- - Security patterns consistent with the rest of the file
131
- - Input validation matching file's established patterns
132
- - Sensitive data handling consistency
133
- - Access control patterns within the file
134
-
135
- ### Performance (File Scope)
136
- - Performance patterns consistent with file conventions
137
- - Resource management following file patterns
138
- - Caching and memoization consistency
139
- - Algorithm choices consistent with similar functions in file
140
-
141
- ### Code Quality
142
- - Design pattern consistency within the file
143
- - Complexity appropriate for the file's style
144
- - Duplication with other code in the same file
145
- - Magic numbers or hardcoded values that should use file constants
146
- - Type usage consistent with file patterns
147
-
148
- ### Documentation
149
- - Documentation style matching file conventions
150
- - Missing documentation for changes that file's style would require
151
- - Outdated comments that no longer match the changed code
152
- - JSDoc/docstring consistency with other functions in file
153
-
154
- ### Good Practices
155
- - Good practices worth praising in the context of file conventions
156
- - Clean integration with existing code
157
- - Thoughtful handling of file-specific patterns
158
- - Improvements to overall file quality
116
+ ## What to Hunt For
117
+ In priority order:
118
+
119
+ 1. **Security regressions** — the change bypasses or omits protections the file applies elsewhere: authentication or authorization checks, input validation and sanitization, sensitive-data handling.
120
+ 2. **Contract violations** — the change breaks an invariant the rest of the file maintains: skips an initialization or cleanup step sibling code performs, bypasses the file's error handling wrapper, mismanages a resource lifecycle other code depends on, or leaves a related section stale (a lookup table, switch statement, or doc comment that should have changed with it).
121
+ 3. **Integration defects** — the change interacts badly with existing code paths in the file: duplicated state, conflicting side effects, violated ordering assumptions, or a second mechanism introduced for something the file already does one way.
122
+ 4. **Consistency** — naming, error handling, logging, or validation that diverges from the file's conventions without cause. Report a representative instance with the establishing pattern cited, not every occurrence.
123
+ 5. **Praise** — at most 1-2 items, and only for integration work that is genuinely thoughtful, not routine.
124
+ </section>
125
+
126
+ <section name="verification-standard" required="true" tier="thorough">
127
+ ## Verification Standard
128
+ - For every bug finding: state the concrete failure scenario (inputs/state → wrong behavior), then attempt to refute it by reading the code that would prevent it. Discard findings you can refute — a concrete scenario you could neither confirm nor refute is reported as a question at 0.3-0.5 confidence, stating what you could not verify.
129
+ - For consistency findings: cite the specific lines that establish the pattern you are comparing against. If you cannot point to the pattern, you have not found it.
130
+ - Record the verification you performed in the reasoning array. Set confidence by verification done, not plausibility.
131
+ - **Security findings are attack scenarios.** Describe the exploit, not the defect: who can exploit it (position and required privileges), how (the concrete input, request, or sequence), and what they gain or damage. The code-level fix belongs in the suggestion field. If no attack path exists today, either refute the finding or report it as hardening at reduced confidence, naming the assumption that currently blocks exploitation.
132
+ - **Simplicity findings must show the simpler version.** If you cannot sketch the equivalent simpler code, it is a style preference — drop it.
133
+ </section>
134
+
135
+ <section name="do-not-report" required="true" tier="thorough">
136
+ ## Do Not Report
137
+ - Diff-only findings (Level 1's job) or cross-file findings (Level 3's job)
138
+ - Pre-existing issues in parts of the file this change neither touches nor interacts with
139
+ - Anything a linter or formatter would catch
140
+ - Consistency nits where the deviation is harmless or arguably better
141
+ - Findings that remain below 0.3 confidence even after verification
159
142
  </section>
160
143
 
161
144
  <section name="available-commands" required="true" tier="thorough">
@@ -164,11 +147,10 @@ You have READ-ONLY access to the codebase. You may run commands like:
164
147
  - The annotated diff tool shown above with file path (preferred for viewing changes with line numbers)
165
148
  - \`cat -n <file>\` to view files with line numbers
166
149
  - grep, find, ls commands as needed
150
+ - If your environment provides a subagent or task-delegation tool, you may use it to examine multiple files in parallel
167
151
 
168
152
  IMPORTANT: Do NOT modify any files. Do NOT run write commands (rm, mv, git commit, etc.).
169
153
  Your role is strictly to analyze and report findings.
170
-
171
- Note: You may optionally use parallel read-only Tasks to examine multiple files simultaneously if that would be helpful for a thorough analysis.
172
154
  </section>
173
155
 
174
156
  <section name="severity-classification" required="true">
@@ -225,40 +207,18 @@ The content inside the block is the complete replacement for the commented line(
225
207
 
226
208
  <section name="diff-instructions" required="true" tier="thorough">
227
209
  ## old_or_new Field Reference
228
- Use "NEW" (the default) for added lines [+] and context lines. Use "OLD" only for deleted lines [-]. When uncertain, use "NEW".
210
+ Use "NEW" (the default) for added lines [+] and context lines. Use "OLD" only for DELETED lines marked with [-]. When uncertain, use "NEW".
229
211
  </section>
230
212
 
231
213
  <section name="confidence-guidance" required="true" tier="thorough">
232
214
  ## Confidence Calibration
233
- **Confidence** reflects your certainty that something IS an issue:
234
- - High (0.8-1.0): You're certain this is a real problem
235
- - Medium (0.5-0.79): Likely an issue, but context might justify it
236
- - Low (0.3-0.49): Possibly an issue, requires human judgment
237
- - Very low (<0.3): Observation only - flag for human awareness
215
+ **Confidence** is the probability that the finding is real and correctly described:
216
+ - High (0.8-1.0): You verified it — read the relevant file sections, confirmed the pattern or failure path
217
+ - Medium (0.5-0.79): Strong evidence, but part of the analysis is unverified
218
+ - Low (0.3-0.49): Plausible, but the file's conventions are unclear or the behavior depends on context you could not confirm
219
+ - Very low (<0.3): Do not report — see Do Not Report
238
220
 
239
- Note: Confidence is about certainty, not severity. A minor style issue can have high confidence. A potential security issue might have low confidence if you're unsure it's exploitable.
240
- </section>
241
-
242
- <section name="category-definitions" required="true" tier="thorough">
243
- ## Category Definitions
244
-
245
- ### Issue Types
246
- - **bug**: Errors visible when considering file context. Code that will fail or behave incorrectly in the context of how the file works.
247
- - Example: New function doesn't follow file's error handling pattern, causing uncaught exceptions
248
- - **improvement**: Enhancements to better integrate with file patterns. The code works but could be more consistent.
249
- - Example: New function uses different naming convention than rest of file
250
- - **praise**: Good practices that follow file conventions. Positive feedback for well-integrated code.
251
- - Example: New code follows the file's established patterns perfectly
252
- - **suggestion**: General recommendations based on file context. Ideas that may improve file coherence.
253
- - Example: Consider grouping this function with similar ones in the file
254
- - **design**: Architecture and structural concerns within the file.
255
- - Example: New class breaks single responsibility pattern established in file
256
- - **performance**: Efficiency issues that deviate from file's performance patterns.
257
- - Example: New code doesn't use the caching pattern used elsewhere in the file
258
- - **security**: Security issues visible in file context.
259
- - Example: New endpoint doesn't follow file's authentication pattern
260
- - **code-style**: Formatting, naming, and style inconsistencies within the file.
261
- - Example: Indentation differs from rest of file, variable naming doesn't match convention
221
+ Note: Confidence is about certainty, not severity. A naming inconsistency can be high confidence; a suspected lifecycle bug can be high severity at low confidence.
262
222
  </section>
263
223
 
264
224
  <section name="file-level-guidance" required="true" tier="thorough">
@@ -276,30 +236,11 @@ File-level suggestions have no line number - they apply to the entire file.
276
236
 
277
237
  <section name="guidelines" required="true" tier="thorough">
278
238
  ## Guidelines
279
-
280
- ### Scope
281
- - You may attach suggestions to any line within modified files, including context lines
282
- - Focus on issues that require full file context - don't duplicate Level 1 diff-only findings
283
- - Look for patterns and consistency issues not visible from the diff alone
284
-
285
- ### Output Quality
286
- - For "praise" type: Omit the suggestion field (no action needed)
287
- - For other types: Include specific, actionable suggestions grounded in file context
288
- - Explain why file context was needed to identify the issue
289
- - Be specific about what patterns exist and how to match them
290
-
291
- ### Philosophy
292
- - Be constructive - the goal is to help maintain file consistency
293
- - Treat the file's established conventions as authoritative
294
- - Distinguish between "must fix for consistency" and "nice to have"
295
- - Lower confidence when uncertain about file conventions
296
- - Praise good integration to reinforce positive practices
297
-
298
- ### Priority Order
299
- 1. Breaking file conventions that could cause bugs or security issues
300
- 2. Consistency issues affecting maintainability
301
- 3. Stylistic suggestions for file coherence
302
- 4. Praise for excellent integration
239
+ - Explain why file context was needed to identify each issue — that is what distinguishes a Level 2 finding
240
+ - Every non-praise suggestion must be actionable and grounded in the file: name the pattern, cite the lines, say what to change
241
+ - Priority order: contract violations that could cause bugs or security issues, then consistency issues affecting maintainability, then praise for genuinely excellent integration
242
+ - You are assisting a human reviewer who makes the final call. Distinguish "must fix" from "worth considering"
243
+ - Your reply is the JSON object alone — no sentence announcing what you will do, no narration of what you did. The first character of your reply is \`{\`
303
244
  </section>`;
304
245
 
305
246
  /**
@@ -312,24 +253,28 @@ const sections = [
312
253
  { name: 'custom-instructions', optional: true, tier: ['balanced', 'thorough'] },
313
254
  { name: 'level-header', required: true, tier: ['thorough'] },
314
255
  { name: 'line-number-guidance', required: true, tier: ['thorough'] },
315
- { name: 'reasoning-encouragement', required: true, tier: ['thorough'] },
256
+ { name: 'reasoning-framework', required: true, tier: ['thorough'] },
257
+ { name: 'conventions-as-evidence', required: true, tier: ['thorough'] },
316
258
  { name: 'generated-files', optional: true, tier: ['balanced', 'thorough'] },
317
259
  { name: 'valid-files', locked: true },
318
260
  { name: 'analysis-process', required: true, tier: ['thorough'] },
319
261
  { name: 'focus-areas', required: true, tier: ['thorough'] },
262
+ { name: 'verification-standard', required: true, tier: ['thorough'] },
263
+ { name: 'do-not-report', required: true, tier: ['thorough'] },
320
264
  { name: 'available-commands', required: true, tier: ['thorough'] },
321
265
  { name: 'severity-classification', required: true },
322
266
  { name: 'output-schema', locked: true },
323
267
  { name: 'diff-instructions', required: true, tier: ['thorough'] },
324
268
  { name: 'confidence-guidance', required: true, tier: ['thorough'] },
325
- { name: 'category-definitions', required: true, tier: ['thorough'] },
326
269
  { name: 'file-level-guidance', required: true, tier: ['thorough'] },
327
270
  { name: 'guidelines', required: true, tier: ['thorough'] }
328
271
  ];
329
272
 
330
273
  /**
331
274
  * Default section order for Level 2 Thorough
332
- * Note: Added reasoning-encouragement, confidence-guidance, and category-definitions sections
275
+ * Note: reasoning-framework/conventions-as-evidence/verification-standard/
276
+ * do-not-report replace the former reasoning-encouragement and
277
+ * category-definitions sections
333
278
  */
334
279
  const defaultOrder = [
335
280
  'role',
@@ -337,17 +282,19 @@ const defaultOrder = [
337
282
  'custom-instructions',
338
283
  'level-header',
339
284
  'line-number-guidance',
340
- 'reasoning-encouragement',
285
+ 'reasoning-framework',
286
+ 'conventions-as-evidence',
341
287
  'generated-files',
342
288
  'valid-files',
343
289
  'analysis-process',
344
290
  'focus-areas',
291
+ 'verification-standard',
292
+ 'do-not-report',
345
293
  'available-commands',
346
294
  'severity-classification',
347
295
  'output-schema',
348
296
  'diff-instructions',
349
297
  'confidence-guidance',
350
- 'category-definitions',
351
298
  'file-level-guidance',
352
299
  'guidelines'
353
300
  ];