invar-tools 1.8.0__py3-none-any.whl → 1.11.0__py3-none-any.whl
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.
- invar/__init__.py +8 -0
- invar/core/doc_edit.py +187 -0
- invar/core/doc_parser.py +563 -0
- invar/core/language.py +88 -0
- invar/core/models.py +106 -0
- invar/core/patterns/detector.py +6 -1
- invar/core/patterns/p0_exhaustive.py +15 -3
- invar/core/patterns/p0_literal.py +15 -3
- invar/core/patterns/p0_newtype.py +15 -3
- invar/core/patterns/p0_nonempty.py +15 -3
- invar/core/patterns/p0_validation.py +15 -3
- invar/core/patterns/registry.py +5 -1
- invar/core/patterns/types.py +5 -1
- invar/core/property_gen.py +4 -0
- invar/core/rules.py +84 -18
- invar/core/sync_helpers.py +27 -1
- invar/core/ts_parsers.py +286 -0
- invar/core/ts_sig_parser.py +310 -0
- invar/mcp/handlers.py +408 -0
- invar/mcp/server.py +288 -143
- invar/node_tools/MANIFEST +7 -0
- invar/node_tools/__init__.py +51 -0
- invar/node_tools/fc-runner/cli.js +77 -0
- invar/node_tools/quick-check/cli.js +28 -0
- invar/node_tools/ts-analyzer/cli.js +480 -0
- invar/shell/claude_hooks.py +35 -12
- invar/shell/commands/doc.py +409 -0
- invar/shell/commands/guard.py +41 -1
- invar/shell/commands/init.py +154 -16
- invar/shell/commands/perception.py +157 -33
- invar/shell/commands/skill.py +187 -0
- invar/shell/commands/template_sync.py +65 -13
- invar/shell/commands/uninstall.py +60 -12
- invar/shell/commands/update.py +6 -14
- invar/shell/contract_coverage.py +1 -0
- invar/shell/doc_tools.py +459 -0
- invar/shell/fs.py +67 -13
- invar/shell/pi_hooks.py +6 -0
- invar/shell/prove/crosshair.py +3 -0
- invar/shell/prove/guard_ts.py +902 -0
- invar/shell/skill_manager.py +355 -0
- invar/shell/template_engine.py +28 -4
- invar/shell/templates.py +4 -4
- invar/templates/claude-md/python/critical-rules.md +33 -0
- invar/templates/claude-md/python/quick-reference.md +24 -0
- invar/templates/claude-md/typescript/critical-rules.md +40 -0
- invar/templates/claude-md/typescript/quick-reference.md +24 -0
- invar/templates/claude-md/universal/check-in.md +25 -0
- invar/templates/claude-md/universal/skills.md +73 -0
- invar/templates/claude-md/universal/workflow.md +55 -0
- invar/templates/commands/{audit.md → audit.md.jinja} +18 -1
- invar/templates/config/AGENT.md.jinja +58 -0
- invar/templates/config/CLAUDE.md.jinja +16 -209
- invar/templates/config/context.md.jinja +19 -0
- invar/templates/examples/{README.md → python/README.md} +2 -0
- invar/templates/examples/{conftest.py → python/conftest.py} +1 -1
- invar/templates/examples/{contracts.py → python/contracts.py} +81 -4
- invar/templates/examples/python/core_shell.py +227 -0
- invar/templates/examples/python/functional.py +613 -0
- invar/templates/examples/typescript/README.md +31 -0
- invar/templates/examples/typescript/contracts.ts +163 -0
- invar/templates/examples/typescript/core_shell.ts +374 -0
- invar/templates/examples/typescript/functional.ts +601 -0
- invar/templates/examples/typescript/workflow.md +95 -0
- invar/templates/hooks/PostToolUse.sh.jinja +10 -1
- invar/templates/hooks/PreToolUse.sh.jinja +38 -0
- invar/templates/hooks/Stop.sh.jinja +1 -1
- invar/templates/hooks/UserPromptSubmit.sh.jinja +7 -0
- invar/templates/hooks/pi/invar.ts.jinja +9 -0
- invar/templates/manifest.toml +7 -6
- invar/templates/onboard/assessment.md.jinja +214 -0
- invar/templates/onboard/patterns/python.md +347 -0
- invar/templates/onboard/patterns/typescript.md +452 -0
- invar/templates/onboard/roadmap.md.jinja +168 -0
- invar/templates/protocol/INVAR.md.jinja +51 -0
- invar/templates/protocol/python/architecture-examples.md +41 -0
- invar/templates/protocol/python/contracts-syntax.md +56 -0
- invar/templates/protocol/python/markers.md +44 -0
- invar/templates/protocol/python/tools.md +24 -0
- invar/templates/protocol/python/troubleshooting.md +38 -0
- invar/templates/protocol/typescript/architecture-examples.md +52 -0
- invar/templates/protocol/typescript/contracts-syntax.md +73 -0
- invar/templates/protocol/typescript/markers.md +48 -0
- invar/templates/protocol/typescript/tools.md +65 -0
- invar/templates/protocol/typescript/troubleshooting.md +104 -0
- invar/templates/protocol/universal/architecture.md +36 -0
- invar/templates/protocol/universal/completion.md +14 -0
- invar/templates/protocol/universal/contracts-concept.md +37 -0
- invar/templates/protocol/universal/header.md +17 -0
- invar/templates/protocol/universal/session.md +17 -0
- invar/templates/protocol/universal/six-laws.md +10 -0
- invar/templates/protocol/universal/usbv.md +14 -0
- invar/templates/protocol/universal/visible-workflow.md +25 -0
- invar/templates/skills/develop/SKILL.md.jinja +85 -3
- invar/templates/skills/extensions/_registry.yaml +93 -0
- invar/templates/skills/extensions/acceptance/SKILL.md +383 -0
- invar/templates/skills/extensions/invar-onboard/SKILL.md +448 -0
- invar/templates/skills/extensions/invar-onboard/patterns/python.md +347 -0
- invar/templates/skills/extensions/invar-onboard/patterns/typescript.md +452 -0
- invar/templates/skills/extensions/invar-onboard/templates/assessment.md.jinja +214 -0
- invar/templates/skills/extensions/invar-onboard/templates/roadmap.md.jinja +168 -0
- invar/templates/skills/extensions/security/SKILL.md +382 -0
- invar/templates/skills/extensions/security/patterns/_common.yaml +126 -0
- invar/templates/skills/extensions/security/patterns/python.yaml +155 -0
- invar/templates/skills/extensions/security/patterns/typescript.yaml +194 -0
- invar/templates/skills/review/SKILL.md.jinja +220 -248
- {invar_tools-1.8.0.dist-info → invar_tools-1.11.0.dist-info}/METADATA +336 -12
- invar_tools-1.11.0.dist-info/RECORD +178 -0
- invar/templates/examples/core_shell.py +0 -127
- invar/templates/protocol/INVAR.md +0 -310
- invar_tools-1.8.0.dist-info/RECORD +0 -116
- /invar/templates/examples/{workflow.md → python/workflow.md} +0 -0
- {invar_tools-1.8.0.dist-info → invar_tools-1.11.0.dist-info}/WHEEL +0 -0
- {invar_tools-1.8.0.dist-info → invar_tools-1.11.0.dist-info}/entry_points.txt +0 -0
- {invar_tools-1.8.0.dist-info → invar_tools-1.11.0.dist-info}/licenses/LICENSE +0 -0
- {invar_tools-1.8.0.dist-info → invar_tools-1.11.0.dist-info}/licenses/LICENSE-GPL +0 -0
- {invar_tools-1.8.0.dist-info → invar_tools-1.11.0.dist-info}/licenses/NOTICE +0 -0
|
@@ -1,146 +1,161 @@
|
|
|
1
1
|
---
|
|
2
2
|
name: review
|
|
3
|
-
description:
|
|
3
|
+
description: Adversarial code review. Code is GUILTY until proven INNOCENT. Every round spawns isolated subagent reviewing FULL scope.
|
|
4
4
|
_invar:
|
|
5
|
-
version: "
|
|
5
|
+
version: "7.0"
|
|
6
6
|
managed: skill
|
|
7
7
|
---
|
|
8
8
|
<!--invar:skill-->
|
|
9
9
|
|
|
10
|
-
# Review
|
|
10
|
+
# Review Skill (Adversarial)
|
|
11
11
|
|
|
12
|
-
|
|
13
|
-
> **Mindset:** REJECTION-FIRST. Code is GUILTY until proven INNOCENT.
|
|
14
|
-
> **Success Metric:** Issues FOUND, not code approved. Zero issues = you failed to look hard enough.
|
|
15
|
-
> **Workflow:** AUTOMATIC Reviewer↔Fixer loop until quality_met or max_rounds (no human confirmation).
|
|
12
|
+
## Mandatory Rules (MUST follow, NO exceptions)
|
|
16
13
|
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
**
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
- Auditing escape hatches
|
|
23
|
-
- Security review
|
|
24
|
-
|
|
25
|
-
**This skill is NOT for:**
|
|
26
|
-
- Implementing new features → switch to `/develop`
|
|
27
|
-
- Understanding how code works → switch to `/investigate`
|
|
28
|
-
- Deciding on architecture → switch to `/propose`
|
|
29
|
-
|
|
30
|
-
**Drift detection:** If you're writing significant new code (not fixes) → STOP, you're in wrong skill.
|
|
14
|
+
1. **EVERY round MUST spawn isolated subagent** (Task tool with model=opus)
|
|
15
|
+
2. **EVERY round reviews FULL scope** (all files, not just changes)
|
|
16
|
+
3. **Code is GUILTY until proven INNOCENT**
|
|
17
|
+
4. **NO user confirmation between rounds** — just do it
|
|
18
|
+
5. **MAX_ROUNDS = 5**
|
|
31
19
|
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
```
|
|
35
|
-
MAX_ROUNDS = 5 # Maximum review-fix cycles
|
|
36
|
-
AUTO_TRANSITION = true # No human confirmation between roles
|
|
37
|
-
```
|
|
20
|
+
**Violation = Review Invalid.** If you skip subagent or review only changes, the review is worthless.
|
|
38
21
|
|
|
39
|
-
|
|
22
|
+
---
|
|
40
23
|
|
|
41
|
-
|
|
24
|
+
## Scope Classification (DX-75)
|
|
42
25
|
|
|
43
|
-
|
|
44
|
-
|------|---------------|
|
|
45
|
-
| "Seems fine" | You failed to find the bug |
|
|
46
|
-
| "Makes sense" | You're rationalizing, not reviewing |
|
|
47
|
-
| "Edge case is unlikely" | Edge cases ARE bugs |
|
|
48
|
-
| "Comment explains it" | Comments don't fix code |
|
|
49
|
-
| "Assessed as acceptable" | "Assessed" ≠ "Fixed" |
|
|
26
|
+
**Before starting, classify the scope:**
|
|
50
27
|
|
|
51
|
-
|
|
28
|
+
| Classification | Criteria | Strategy |
|
|
29
|
+
|----------------|----------|----------|
|
|
30
|
+
| **SMALL** | <5 files AND <1500 lines | THOROUGH (no enumeration) |
|
|
31
|
+
| **MEDIUM** | 5-10 files OR 1500-5000 lines | HYBRID (enum + open) |
|
|
32
|
+
| **LARGE** | >10 files OR >5000 lines | CHUNKED (parallel subagents) |
|
|
52
33
|
|
|
53
|
-
**
|
|
34
|
+
**Why different strategies?**
|
|
35
|
+
- SMALL: Pre-enumeration causes "checklist mentality" — you only verify listed items, miss variants
|
|
36
|
+
- LARGE: Without enumeration, attention drifts — later files get less scrutiny
|
|
54
37
|
|
|
55
|
-
|
|
56
|
-
|------|-----------------|-----------|
|
|
57
|
-
| **REVIEWER** | Find issues, judge fixes, declare quality_met | Write code, rationalize issues |
|
|
58
|
-
| **FIXER** | Implement fixes only | Declare quality_met, dismiss issues |
|
|
38
|
+
---
|
|
59
39
|
|
|
60
|
-
|
|
40
|
+
## Strategy: THOROUGH (SMALL scope)
|
|
61
41
|
|
|
62
42
|
```
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
43
|
+
┌─────────────────────────────────────────────────────────────┐
|
|
44
|
+
│ THOROUGH STRATEGY (for SMALL scope) │
|
|
45
|
+
│ ───────────────────────────────────────────────────────────│
|
|
46
|
+
│ │
|
|
47
|
+
│ ⚠️ DO NOT pre-enumerate issues or patterns │
|
|
48
|
+
│ ⚠️ DO NOT use grep/sig to "find issues first" │
|
|
49
|
+
│ │
|
|
50
|
+
│ Instead: │
|
|
51
|
+
│ 1. Read each file COMPLETELY, line by line │
|
|
52
|
+
│ 2. Apply checklist A-G as you read │
|
|
53
|
+
│ 3. Trust your judgment to find issues │
|
|
54
|
+
│ 4. Look for VARIANTS and EDGE CASES │
|
|
55
|
+
│ │
|
|
56
|
+
│ Why: Pre-enumeration narrows focus to known patterns. │
|
|
57
|
+
│ Small scope = you CAN read everything thoroughly. │
|
|
58
|
+
│ This finds issues that pattern matching misses. │
|
|
59
|
+
└─────────────────────────────────────────────────────────────┘
|
|
74
60
|
```
|
|
75
61
|
|
|
76
|
-
##
|
|
77
|
-
|
|
78
|
-
**ONLY the Reviewer role can declare `quality_met`.**
|
|
79
|
-
|
|
80
|
-
Before declaring exit:
|
|
81
|
-
1. Re-read EVERY issue found
|
|
82
|
-
2. For each issue, verify: "Is this ACTUALLY fixed, or did I rationalize it?"
|
|
83
|
-
3. Ask: "Would I accept this excuse from someone else's code?"
|
|
84
|
-
|
|
85
|
-
**Self-Check Questions:**
|
|
86
|
-
- Did I write code AND declare quality_met? → Role confusion detected
|
|
87
|
-
- Did I say "assessed" instead of "fixed"? → Rationalization detected
|
|
88
|
-
- Did any MAJOR become a comment instead of code? → Fix failed
|
|
89
|
-
|
|
90
|
-
## Fault-Finding Persona
|
|
62
|
+
## Strategy: HYBRID (MEDIUM scope)
|
|
91
63
|
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
-
|
|
101
|
-
-
|
|
102
|
-
-
|
|
103
|
-
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
64
|
+
```
|
|
65
|
+
┌─────────────────────────────────────────────────────────────┐
|
|
66
|
+
│ HYBRID STRATEGY (for MEDIUM scope) │
|
|
67
|
+
│ ───────────────────────────────────────────────────────────│
|
|
68
|
+
│ │
|
|
69
|
+
│ Phase 0: ENUMERATE (Main Agent) │
|
|
70
|
+
│ ┌─────────────────────────────────────────────────────┐ │
|
|
71
|
+
│ │ Use grep/invar_sig to find: │ │
|
|
72
|
+
│ │ - All @pre/@post contracts │ │
|
|
73
|
+
│ │ - All @invar:allow escape hatches │ │
|
|
74
|
+
│ │ - Hardcoded strings (secrets?) │ │
|
|
75
|
+
│ │ - subprocess/exec/eval calls │ │
|
|
76
|
+
│ │ - bare except clauses │ │
|
|
77
|
+
│ │ Create issue_map with file:line for each │ │
|
|
78
|
+
│ └─────────────────────────────────────────────────────┘ │
|
|
79
|
+
│ │
|
|
80
|
+
│ Phase 1: GUIDED REVIEW (Isolated Subagent) │
|
|
81
|
+
│ ┌─────────────────────────────────────────────────────┐ │
|
|
82
|
+
│ │ Pass issue_map to subagent │ │
|
|
83
|
+
│ │ Subagent verifies each item │ │
|
|
84
|
+
│ │ Reports: "Checked N/M items from issue_map" │ │
|
|
85
|
+
│ └─────────────────────────────────────────────────────┘ │
|
|
86
|
+
│ │
|
|
87
|
+
│ Phase 2: OPEN DISCOVERY (Same Subagent) │
|
|
88
|
+
│ ┌─────────────────────────────────────────────────────┐ │
|
|
89
|
+
│ │ "Now forget the issue_map. │ │
|
|
90
|
+
│ │ Look for issues NOT in the map: │ │
|
|
91
|
+
│ │ - Variants of listed patterns │ │
|
|
92
|
+
│ │ - Logic errors │ │
|
|
93
|
+
│ │ - Edge cases" │ │
|
|
94
|
+
│ │ Reports: "Found N additional issues" │ │
|
|
95
|
+
│ └─────────────────────────────────────────────────────┘ │
|
|
96
|
+
└─────────────────────────────────────────────────────────────┘
|
|
97
|
+
```
|
|
112
98
|
|
|
113
|
-
|
|
99
|
+
## Strategy: CHUNKED (LARGE scope)
|
|
114
100
|
|
|
115
101
|
```
|
|
116
|
-
|
|
117
|
-
|
|
102
|
+
┌─────────────────────────────────────────────────────────────┐
|
|
103
|
+
│ CHUNKED STRATEGY (for LARGE scope) │
|
|
104
|
+
│ ───────────────────────────────────────────────────────────│
|
|
105
|
+
│ │
|
|
106
|
+
│ 1. Split files into chunks of ~3-5 files each │
|
|
107
|
+
│ │
|
|
108
|
+
│ 2. For each chunk (can be parallel): │
|
|
109
|
+
│ - Spawn isolated subagent │
|
|
110
|
+
│ - Use HYBRID strategy within chunk │
|
|
111
|
+
│ │
|
|
112
|
+
│ 3. Cross-chunk analysis: │
|
|
113
|
+
│ - Check cross-file dependencies │
|
|
114
|
+
│ - Check API consistency │
|
|
115
|
+
│ │
|
|
116
|
+
│ 4. Merge all findings, deduplicate │
|
|
117
|
+
│ │
|
|
118
|
+
│ Why: Prevents "attention fatigue" on file 8+ of 15. │
|
|
119
|
+
│ Each chunk gets fresh attention. │
|
|
120
|
+
└─────────────────────────────────────────────────────────────┘
|
|
118
121
|
```
|
|
119
122
|
|
|
120
|
-
|
|
123
|
+
---
|
|
121
124
|
|
|
122
|
-
|
|
125
|
+
## 2-Step Loop (MANDATORY workflow)
|
|
123
126
|
|
|
124
|
-
Look for `review_suggested` warning:
|
|
125
127
|
```
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
128
|
+
┌─────────────────────────────────────────────────────────────┐
|
|
129
|
+
│ Round N: │
|
|
130
|
+
│ │
|
|
131
|
+
│ 1. REVIEWER [Subagent] ─────────────────────────────────── │
|
|
132
|
+
│ • Spawn NEW isolated agent (Task tool) │
|
|
133
|
+
│ • Use strategy based on scope classification │
|
|
134
|
+
│ • Review ALL files in scope (full checklist A-G) │
|
|
135
|
+
│ • Return: issues[] or APPROVED │
|
|
136
|
+
│ │
|
|
137
|
+
│ 2. FIXER [Main Agent] ──────────────────────────────────── │
|
|
138
|
+
│ • Fix CRITICAL/MAJOR issues with CODE │
|
|
139
|
+
│ • Run invar_guard() │
|
|
140
|
+
│ • Cannot declare quality_met │
|
|
141
|
+
│ │
|
|
142
|
+
│ → Loop until: APPROVED OR max_rounds OR no_progress │
|
|
143
|
+
└─────────────────────────────────────────────────────────────┘
|
|
129
144
|
```
|
|
130
145
|
|
|
131
|
-
|
|
146
|
+
**Why new subagent each round?**
|
|
147
|
+
- Main agent has context contamination from fixing
|
|
148
|
+
- "Fresh eyes" impossible in same context
|
|
149
|
+
- Round 2+ drifts to "verify my fixes" not "find problems"
|
|
132
150
|
|
|
133
|
-
|
|
134
|
-
|-----------|------|
|
|
135
|
-
| `review_suggested` present | **Isolated** (spawn sub-agent) |
|
|
136
|
-
| `--isolated` flag | **Isolated** |
|
|
137
|
-
| Default (no trigger) | **Quick** (same context) |
|
|
151
|
+
---
|
|
138
152
|
|
|
139
|
-
## Review Checklist
|
|
153
|
+
## Review Checklist (apply to ALL files)
|
|
140
154
|
|
|
141
|
-
> **Principle:** Only items requiring semantic judgment. Mechanical checks
|
|
155
|
+
> **Principle:** Only items requiring semantic judgment. Mechanical checks handled by Guard.
|
|
142
156
|
|
|
143
157
|
### A. Contract Semantic Value
|
|
158
|
+
|
|
144
159
|
- [ ] Does @pre constrain inputs beyond type checking?
|
|
145
160
|
- Bad: `@pre(lambda x: isinstance(x, int))`
|
|
146
161
|
- Good: `@pre(lambda x: x > 0 and x < MAX_VALUE)`
|
|
@@ -151,203 +166,160 @@ WARNING: review_suggested - Low contract coverage
|
|
|
151
166
|
- [ ] Are boundary conditions explicit in contracts?
|
|
152
167
|
|
|
153
168
|
### B. Doctest Coverage
|
|
154
|
-
|
|
155
|
-
- [ ] Do doctests cover boundary cases?
|
|
156
|
-
- [ ] Do doctests cover error cases?
|
|
169
|
+
|
|
170
|
+
- [ ] Do doctests cover normal, boundary, and error cases?
|
|
157
171
|
- [ ] Are doctests testing behavior, not just syntax?
|
|
158
172
|
|
|
159
173
|
### C. Code Quality
|
|
174
|
+
|
|
160
175
|
- [ ] Is duplicated code worth extracting?
|
|
161
176
|
- [ ] Is naming consistent and clear?
|
|
162
177
|
- [ ] Is complexity justified?
|
|
163
178
|
|
|
164
179
|
### D. Escape Hatch Audit
|
|
180
|
+
|
|
165
181
|
- [ ] Is each @invar:allow justification valid?
|
|
166
182
|
- [ ] Could refactoring eliminate the need?
|
|
167
|
-
- [ ] Is there a pattern suggesting systematic issues?
|
|
168
183
|
|
|
169
184
|
### E. Logic Verification
|
|
185
|
+
|
|
170
186
|
- [ ] Do contracts correctly capture intended behavior?
|
|
171
187
|
- [ ] Are there paths that bypass contract checks?
|
|
172
188
|
- [ ] Are there implicit assumptions not in contracts?
|
|
173
|
-
- [ ] Is there dead code or unreachable branches?
|
|
174
189
|
|
|
175
190
|
### F. Security
|
|
191
|
+
|
|
176
192
|
- [ ] Are inputs validated against security threats (injection, XSS)?
|
|
177
193
|
- [ ] No hardcoded secrets (API keys, passwords, tokens)?
|
|
178
194
|
- [ ] Are authentication/authorization checks correct?
|
|
179
|
-
- [ ] Is sensitive data properly protected?
|
|
180
195
|
|
|
181
|
-
### G. Error Handling
|
|
196
|
+
### G. Error Handling
|
|
197
|
+
|
|
182
198
|
- [ ] Are exceptions caught at appropriate level?
|
|
183
199
|
- [ ] Are error messages clear without leaking sensitive info?
|
|
184
|
-
- [ ] Are critical operations logged for debugging?
|
|
185
200
|
- [ ] Is there graceful degradation on failure?
|
|
186
201
|
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
These are checked by Guard or linters - don't duplicate:
|
|
190
|
-
- Core/Shell separation → Guard (forbidden_import, impure_call)
|
|
191
|
-
- Shell returns Result[T,E] → Guard (shell_result)
|
|
192
|
-
- Missing contracts → Guard (missing_contract)
|
|
193
|
-
- File/function size limits → Guard (file_size, function_size)
|
|
194
|
-
- Entry point thickness → Guard (entry_point_too_thick)
|
|
195
|
-
- Escape hatch count → Guard (review_suggested)
|
|
202
|
+
---
|
|
196
203
|
|
|
197
|
-
##
|
|
204
|
+
## Subagent Prompt Templates
|
|
198
205
|
|
|
199
|
-
|
|
206
|
+
### THOROUGH (SMALL scope)
|
|
200
207
|
|
|
201
208
|
```
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
│ │ 2. Update verification table │ │
|
|
229
|
-
│ │ 3. IF all CRITICAL/MAJOR fixed → quality_met, EXIT │ │
|
|
230
|
-
│ │ 4. IF round >= MAX_ROUNDS → max_rounds, EXIT │ │
|
|
231
|
-
│ │ 5. IF no progress → no_improvement, EXIT │ │
|
|
232
|
-
│ │ 6. ELSE → round++, LOOP to REVIEWER [Round N+1] │ │
|
|
233
|
-
│ └─────────────────────────────────────────────────────────┘ │
|
|
234
|
-
│ │
|
|
235
|
-
│ EXIT: Generate final report │
|
|
236
|
-
└─────────────────────────────────────────────────────────────────┘
|
|
209
|
+
You are an independent Adversarial Code Reviewer.
|
|
210
|
+
|
|
211
|
+
RULES:
|
|
212
|
+
1. Code is GUILTY until proven INNOCENT
|
|
213
|
+
2. You did NOT write this code — no emotional attachment
|
|
214
|
+
3. Find reasons to REJECT, not accept
|
|
215
|
+
4. Be specific: file:line + concrete fix
|
|
216
|
+
|
|
217
|
+
STRATEGY: THOROUGH READING
|
|
218
|
+
- Read each file COMPLETELY, line by line
|
|
219
|
+
- DO NOT pre-scan for patterns — just READ
|
|
220
|
+
- Look for VARIANTS and EDGE CASES
|
|
221
|
+
- Trust your judgment
|
|
222
|
+
|
|
223
|
+
SCOPE: [list all files]
|
|
224
|
+
|
|
225
|
+
Apply checklist A-G to each file.
|
|
226
|
+
|
|
227
|
+
OUTPUT FORMAT:
|
|
228
|
+
## Verdict: APPROVED | NEEDS WORK | REJECTED
|
|
229
|
+
## Critical Issues (must fix)
|
|
230
|
+
| ID | File:Line | Issue | Fix |
|
|
231
|
+
## Major Issues (should fix)
|
|
232
|
+
| ID | File:Line | Issue | Fix |
|
|
233
|
+
## Minor Issues (backlog)
|
|
234
|
+
| ID | File:Line | Issue | Fix |
|
|
237
235
|
```
|
|
238
236
|
|
|
239
|
-
|
|
237
|
+
### HYBRID (MEDIUM scope)
|
|
240
238
|
|
|
241
|
-
**Maintain this state throughout the loop:**
|
|
242
|
-
|
|
243
|
-
```markdown
|
|
244
|
-
## Review State
|
|
245
|
-
- **Round:** N / MAX_ROUNDS
|
|
246
|
-
- **Role:** REVIEWER | FIXER
|
|
247
|
-
- **Issues Found:** [count]
|
|
248
|
-
- **Issues Fixed:** [count]
|
|
249
|
-
- **Guard Status:** PASS | FAIL
|
|
250
239
|
```
|
|
240
|
+
You are an independent Adversarial Code Reviewer.
|
|
241
|
+
|
|
242
|
+
RULES:
|
|
243
|
+
1. Code is GUILTY until proven INNOCENT
|
|
244
|
+
2. You did NOT write this code — no emotional attachment
|
|
245
|
+
3. Find reasons to REJECT, not accept
|
|
246
|
+
4. Be specific: file:line + concrete fix
|
|
247
|
+
|
|
248
|
+
STRATEGY: HYBRID (two passes)
|
|
251
249
|
|
|
252
|
-
|
|
250
|
+
PASS 1 - GUIDED:
|
|
251
|
+
Using this issue_map, verify each potential issue:
|
|
252
|
+
[issue_map from Phase 0]
|
|
253
253
|
|
|
254
|
-
|
|
255
|
-
|----------|----------|-------------|--------|----------|
|
|
256
|
-
| MAJOR-1 | MAJOR | 1 | ✅ Fixed (R2) | Code change at line X |
|
|
257
|
-
| MAJOR-2 | MAJOR | 1 | ❌ Unfixed | Fix attempted but failed |
|
|
258
|
-
| MAJOR-3 | MAJOR | 2 | 🔄 New | Found during re-verification |
|
|
259
|
-
| ... | ... | ... | ... | ... |
|
|
254
|
+
Report: "Verified X/Y items from issue_map"
|
|
260
255
|
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
-
|
|
265
|
-
-
|
|
256
|
+
PASS 2 - OPEN DISCOVERY:
|
|
257
|
+
Now FORGET the issue_map. Read the code fresh.
|
|
258
|
+
Look for issues NOT in the map:
|
|
259
|
+
- Variants of listed patterns
|
|
260
|
+
- Logic errors
|
|
261
|
+
- Edge cases
|
|
266
262
|
|
|
267
|
-
|
|
263
|
+
Report: "Found N additional issues not in issue_map"
|
|
268
264
|
|
|
269
|
-
|
|
265
|
+
SCOPE: [list all files]
|
|
270
266
|
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
|
275
|
-
|
|
267
|
+
OUTPUT FORMAT:
|
|
268
|
+
## Verdict: APPROVED | NEEDS WORK | REJECTED
|
|
269
|
+
## From Issue Map (Pass 1)
|
|
270
|
+
| ID | File:Line | Issue | Fix |
|
|
271
|
+
## Additional Findings (Pass 2)
|
|
272
|
+
| ID | File:Line | Issue | Fix |
|
|
273
|
+
```
|
|
276
274
|
|
|
277
|
-
|
|
275
|
+
---
|
|
278
276
|
|
|
279
|
-
|
|
277
|
+
## Exit Conditions
|
|
280
278
|
|
|
281
279
|
| Condition | Exit Reason | Result |
|
|
282
280
|
|-----------|-------------|--------|
|
|
283
|
-
|
|
|
284
|
-
|
|
|
285
|
-
|
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
4. Guard passes after all fixes
|
|
293
|
-
|
|
294
|
-
**Automatic quality_not_met:**
|
|
295
|
-
- Any MAJOR "fixed" with comment instead of code
|
|
296
|
-
- Any issue marked "assessed" or "acceptable"
|
|
297
|
-
- Fixer role declared quality_met (role violation)
|
|
298
|
-
- Infinite loop detected (no progress)
|
|
299
|
-
|
|
300
|
-
## Exit Report (Generated Automatically)
|
|
301
|
-
|
|
302
|
-
```markdown
|
|
281
|
+
| Subagent returns APPROVED | `quality_met` | Ready for merge |
|
|
282
|
+
| round >= 5 | `max_rounds` | Manual review needed |
|
|
283
|
+
| Same issues 2 rounds | `no_improvement` | Architectural issue |
|
|
284
|
+
|
|
285
|
+
---
|
|
286
|
+
|
|
287
|
+
## Exit Report
|
|
288
|
+
|
|
289
|
+
```
|
|
303
290
|
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
|
|
304
291
|
📋 REVIEW COMPLETE
|
|
305
292
|
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
|
|
306
293
|
|
|
307
|
-
**
|
|
308
|
-
**
|
|
309
|
-
**
|
|
310
|
-
|
|
311
|
-
|
|
294
|
+
**Scope:** SMALL | MEDIUM | LARGE
|
|
295
|
+
**Strategy:** THOROUGH | HYBRID | CHUNKED
|
|
296
|
+
**Exit:** quality_met | max_rounds | no_improvement
|
|
297
|
+
**Rounds:** N / 5
|
|
298
|
+
**Guard:** PASS | FAIL
|
|
312
299
|
|
|
300
|
+
## Issues Table
|
|
313
301
|
| Issue | Severity | Round | Status | Evidence |
|
|
314
|
-
|-------|----------|-------|--------|----------|
|
|
315
|
-
| MAJOR-1 | MAJOR | 1→2 | ✅ Fixed | Code at file.py:123 |
|
|
316
|
-
| ... | ... | ... | ... | ... |
|
|
317
302
|
|
|
318
|
-
##
|
|
303
|
+
## Round Summary
|
|
304
|
+
| Round | Found | Fixed |
|
|
319
305
|
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
- Fix Rate: Y/X (Z%)
|
|
323
|
-
- New Issues from Fixes: N
|
|
306
|
+
✓ Final: guard PASS | X errors, Y warnings
|
|
307
|
+
```
|
|
324
308
|
|
|
325
|
-
|
|
309
|
+
---
|
|
326
310
|
|
|
327
|
-
|
|
328
|
-
- [x] No "assessed as acceptable" rationalizations
|
|
329
|
-
- [x] Guard passes after all changes
|
|
330
|
-
- [x] Role separation maintained throughout
|
|
311
|
+
## Scope Boundaries
|
|
331
312
|
|
|
332
|
-
|
|
313
|
+
**IS for:** Finding bugs, verifying contracts, security review
|
|
314
|
+
**NOT for:** New features → /develop | Understanding → /investigate
|
|
333
315
|
|
|
334
|
-
|
|
335
|
-
- [ ] Needs manual review (max_rounds)
|
|
336
|
-
- [ ] Architectural refactor needed (no_improvement)
|
|
316
|
+
## Excluded (Covered by Guard)
|
|
337
317
|
|
|
338
|
-
|
|
339
|
-
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
Add project-specific extensions here. This section is preserved on update.
|
|
346
|
-
|
|
347
|
-
Examples of what to add:
|
|
348
|
-
- Project-specific security review checklists
|
|
349
|
-
- Custom severity definitions
|
|
350
|
-
- Domain-specific code patterns to check
|
|
351
|
-
- Team code review standards
|
|
352
|
-
======================================================================== -->
|
|
318
|
+
Don't duplicate mechanical checks:
|
|
319
|
+
- Core/Shell separation → Guard
|
|
320
|
+
- Missing contracts → Guard
|
|
321
|
+
- File/function size → Guard
|
|
322
|
+
|
|
323
|
+
<!--/invar:skill--><!--invar:extensions-->
|
|
324
|
+
<!-- User extensions preserved on update -->
|
|
353
325
|
<!--/invar:extensions-->
|