invar-tools 1.8.0__py3-none-any.whl → 1.10.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/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 +307 -0
- 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/guard.py +36 -1
- invar/shell/commands/init.py +82 -3
- 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/fs.py +66 -13
- invar/shell/pi_hooks.py +6 -0
- invar/shell/prove/guard_ts.py +899 -0
- invar/shell/skill_manager.py +353 -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 +39 -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 +331 -71
- {invar_tools-1.8.0.dist-info → invar_tools-1.10.0.dist-info}/METADATA +304 -12
- invar_tools-1.10.0.dist-info/RECORD +173 -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.10.0.dist-info}/WHEEL +0 -0
- {invar_tools-1.8.0.dist-info → invar_tools-1.10.0.dist-info}/entry_points.txt +0 -0
- {invar_tools-1.8.0.dist-info → invar_tools-1.10.0.dist-info}/licenses/LICENSE +0 -0
- {invar_tools-1.8.0.dist-info → invar_tools-1.10.0.dist-info}/licenses/LICENSE-GPL +0 -0
- {invar_tools-1.8.0.dist-info → invar_tools-1.10.0.dist-info}/licenses/NOTICE +0 -0
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
---
|
|
2
2
|
name: review
|
|
3
|
-
description: Fault-finding code review with REJECTION-FIRST mindset
|
|
3
|
+
description: Fault-finding code review with REJECTION-FIRST mindset. Code is GUILTY until proven INNOCENT. Two-step loop (Review→Fix) with full-scope review each round. Use after development, when Guard reports review_suggested, or user explicitly requests review.
|
|
4
4
|
_invar:
|
|
5
|
-
version: "
|
|
5
|
+
version: "5.3"
|
|
6
6
|
managed: skill
|
|
7
7
|
---
|
|
8
8
|
<!--invar:skill-->
|
|
@@ -12,7 +12,97 @@ _invar:
|
|
|
12
12
|
> **Purpose:** Find problems that Guard, doctests, and property tests missed.
|
|
13
13
|
> **Mindset:** REJECTION-FIRST. Code is GUILTY until proven INNOCENT.
|
|
14
14
|
> **Success Metric:** Issues FOUND, not code approved. Zero issues = you failed to look hard enough.
|
|
15
|
-
> **Workflow:**
|
|
15
|
+
> **Workflow:** Two-step loop: Review → Fix → Review → Fix → ... (full scope each round, no separate "verify" step).
|
|
16
|
+
|
|
17
|
+
## Depth Levels (DX-70)
|
|
18
|
+
|
|
19
|
+
| Level | Context | Use Case |
|
|
20
|
+
|-------|---------|----------|
|
|
21
|
+
| (default) | Same context | Reviewing **others' code** only |
|
|
22
|
+
| `--deep` | **Isolated agent** | Self-review, before merge, maximum objectivity |
|
|
23
|
+
|
|
24
|
+
**Default:** Same context — **only appropriate for code you did NOT write**.
|
|
25
|
+
|
|
26
|
+
**`--deep` mode:** Spawns isolated agent with no conversation history. **Required when:**
|
|
27
|
+
- You wrote or modified the code being reviewed (self-review)
|
|
28
|
+
- Before merge/PR
|
|
29
|
+
- Maximum objectivity needed
|
|
30
|
+
|
|
31
|
+
### ⚠️ Same-Context Review Limitations (CRITICAL)
|
|
32
|
+
|
|
33
|
+
**Same-context review CANNOT be objective for self-written code because:**
|
|
34
|
+
|
|
35
|
+
| Cognitive Bias | Effect |
|
|
36
|
+
|----------------|--------|
|
|
37
|
+
| **Intent over code** | You "know" what it's supposed to do, so you don't see what it actually does |
|
|
38
|
+
| **Context memory** | You "remember" reading code, so you skip re-reading carefully |
|
|
39
|
+
| **Confirmation bias** | You look for "code works" evidence, not "code fails" evidence |
|
|
40
|
+
| **Completion pressure** | Subconscious goal becomes "finish review" not "find bugs" |
|
|
41
|
+
|
|
42
|
+
**Evidence:** In DX-71 review, same-context missed 2 CRITICAL + 4 MAJOR issues that
|
|
43
|
+
isolated agent found immediately. "Fresh eyes" claims don't work in same context.
|
|
44
|
+
|
|
45
|
+
### Mandatory Self-Review Detection (DX-72)
|
|
46
|
+
|
|
47
|
+
**Before starting review, you MUST check:**
|
|
48
|
+
|
|
49
|
+
```
|
|
50
|
+
If ANY file in review scope was edited by agent this session:
|
|
51
|
+
┌──────────────────────────────────────────────────────────────┐
|
|
52
|
+
│ 🚨 SELF-REVIEW DETECTED — Isolation Required │
|
|
53
|
+
│ │
|
|
54
|
+
│ You modified files in the review scope this session. │
|
|
55
|
+
│ Same-context review has proven cognitive blind spots. │
|
|
56
|
+
│ │
|
|
57
|
+
│ Options: │
|
|
58
|
+
│ [1] Use --deep (RECOMMENDED) — Spawn isolated agent │
|
|
59
|
+
│ [2] Acknowledge risk — User explicitly accepts limitations │
|
|
60
|
+
│ │
|
|
61
|
+
│ If user says "continue" or "quick review": │
|
|
62
|
+
│ → Proceed but add WARNING to final report │
|
|
63
|
+
│ → Report MUST state: "Self-review without isolation" │
|
|
64
|
+
└──────────────────────────────────────────────────────────────┘
|
|
65
|
+
```
|
|
66
|
+
|
|
67
|
+
**Default action:** If user doesn't specify, use `--deep` for self-review.
|
|
68
|
+
|
|
69
|
+
### --deep Mode Execution
|
|
70
|
+
|
|
71
|
+
When `--deep` is selected:
|
|
72
|
+
|
|
73
|
+
1. Collect minimal inputs:
|
|
74
|
+
- Files to review
|
|
75
|
+
- Contracts (if available)
|
|
76
|
+
- Test files (if available)
|
|
77
|
+
|
|
78
|
+
2. Spawn Task agent with:
|
|
79
|
+
- **Adversarial Code Reviewer persona** (see Appendix)
|
|
80
|
+
- NO conversation history
|
|
81
|
+
- Only the collected inputs
|
|
82
|
+
|
|
83
|
+
3. Isolated agent returns structured review report
|
|
84
|
+
|
|
85
|
+
4. Main agent fixes issues (if any)
|
|
86
|
+
|
|
87
|
+
5. **CRITICAL: Spawn NEW isolated agent for Round 2+ Review**
|
|
88
|
+
|
|
89
|
+
### --deep Mode Loop (MANDATORY)
|
|
90
|
+
|
|
91
|
+
```
|
|
92
|
+
while not quality_met:
|
|
93
|
+
report = spawn_NEW_isolated_reviewer(files) # 每轮新 agent
|
|
94
|
+
if report.has_critical_or_major:
|
|
95
|
+
main_agent.fix(report.issues) # 主 agent 修复
|
|
96
|
+
else:
|
|
97
|
+
quality_met = True
|
|
98
|
+
```
|
|
99
|
+
|
|
100
|
+
**Why new agent each round?**
|
|
101
|
+
- Main agent has context contamination from fixing
|
|
102
|
+
- "Fresh eyes" cannot be achieved in same context
|
|
103
|
+
- Round 2 in same context drifts to "verify my fixes" not "find problems"
|
|
104
|
+
|
|
105
|
+
---
|
|
16
106
|
|
|
17
107
|
## Scope Boundaries
|
|
18
108
|
|
|
@@ -34,8 +124,12 @@ _invar:
|
|
|
34
124
|
```
|
|
35
125
|
MAX_ROUNDS = 5 # Maximum review-fix cycles
|
|
36
126
|
AUTO_TRANSITION = true # No human confirmation between roles
|
|
127
|
+
ASK_USER = never # NEVER ask user, just do it
|
|
37
128
|
```
|
|
38
129
|
|
|
130
|
+
**CRITICAL: After finding issues, IMMEDIATELY switch to FIXER role and fix them.**
|
|
131
|
+
**DO NOT ask "Proceed with fixes?" or similar — just fix and continue.**
|
|
132
|
+
|
|
39
133
|
## Prime Directive: Reject Until Proven Correct
|
|
40
134
|
|
|
41
135
|
**You are the PROSECUTOR, not the defense attorney.**
|
|
@@ -54,25 +148,23 @@ AUTO_TRANSITION = true # No human confirmation between roles
|
|
|
54
148
|
|
|
55
149
|
| Role | Allowed Actions | Forbidden |
|
|
56
150
|
|------|-----------------|-----------|
|
|
57
|
-
| **REVIEWER** | Find issues
|
|
151
|
+
| **REVIEWER** | Find issues (full scope), declare quality_met | Write code, rationalize issues |
|
|
58
152
|
| **FIXER** | Implement fixes only | Declare quality_met, dismiss issues |
|
|
59
153
|
|
|
60
154
|
**Role Transition Markers (REQUIRED):**
|
|
61
155
|
|
|
62
156
|
```
|
|
63
157
|
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
|
|
64
|
-
🔍 REVIEWER [Round N] —
|
|
158
|
+
🔍 REVIEWER [Round N] — Full scope review
|
|
65
159
|
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
|
|
66
160
|
|
|
67
161
|
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
|
|
68
162
|
🔧 FIXER [Round N] — Implementing fixes
|
|
69
163
|
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
|
|
70
|
-
|
|
71
|
-
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
|
|
72
|
-
✅ REVIEWER [Round N] — Verifying fixes
|
|
73
|
-
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
|
|
74
164
|
```
|
|
75
165
|
|
|
166
|
+
**NO separate "Verify" step.** After Fix, go directly to next round's Review.
|
|
167
|
+
|
|
76
168
|
## Quality Gate Authority
|
|
77
169
|
|
|
78
170
|
**ONLY the Reviewer role can declare `quality_met`.**
|
|
@@ -100,7 +192,87 @@ You ARE here to:
|
|
|
100
192
|
- Find bugs, logic errors, edge cases
|
|
101
193
|
- Challenge whether contracts have semantic value
|
|
102
194
|
- Check if code matches contracts (not if code "seems right")
|
|
103
|
-
|
|
195
|
+
|
|
196
|
+
## Fresh Eyes Mandate (Round 2+) — ENFORCED
|
|
197
|
+
|
|
198
|
+
**For rounds after the first, you MUST adopt "fresh eyes" mindset:**
|
|
199
|
+
|
|
200
|
+
> "I am a different reviewer who has never seen this code or the previous fixes."
|
|
201
|
+
|
|
202
|
+
| Trap | Correction |
|
|
203
|
+
|------|------------|
|
|
204
|
+
| "I just fixed this" | Irrelevant. Review it like new code. |
|
|
205
|
+
| "This was fine last round" | Maybe you missed something. Check again. |
|
|
206
|
+
| "The fix looks correct" | That's FIXER thinking. Find what's WRONG. |
|
|
207
|
+
|
|
208
|
+
### Why This Exists
|
|
209
|
+
|
|
210
|
+
Round 2+ in the same context naturally drifts toward "verify my fixes" instead of
|
|
211
|
+
"find all problems". This cognitive bias causes issues to slip through:
|
|
212
|
+
- Attention focuses on recently-fixed areas
|
|
213
|
+
- Brain skips content it "remembers" reading
|
|
214
|
+
- Subconscious goal becomes "complete task" not "find bugs"
|
|
215
|
+
|
|
216
|
+
### Mandatory Actions (Round 2+)
|
|
217
|
+
|
|
218
|
+
**Before declaring quality_met, you MUST:**
|
|
219
|
+
|
|
220
|
+
1. **RE-READ all files using Read tool**
|
|
221
|
+
```
|
|
222
|
+
❌ WRONG: Rely on context memory ("I already read this")
|
|
223
|
+
✅ RIGHT: Call Read() for each file in scope, every round
|
|
224
|
+
```
|
|
225
|
+
|
|
226
|
+
2. **Systematic audit per code block** (for documentation/examples)
|
|
227
|
+
```
|
|
228
|
+
For each code block:
|
|
229
|
+
- List all symbols USED (types, functions, classes)
|
|
230
|
+
- List all IMPORTS shown
|
|
231
|
+
- Verify: every used symbol has corresponding import
|
|
232
|
+
```
|
|
233
|
+
|
|
234
|
+
3. **Section-by-section explicit check**
|
|
235
|
+
```
|
|
236
|
+
□ Section 1 checked
|
|
237
|
+
□ Section 2 checked
|
|
238
|
+
□ Section 3 checked
|
|
239
|
+
... (every section, not "looks fine overall")
|
|
240
|
+
```
|
|
241
|
+
|
|
242
|
+
4. **Verbalize findings before exit**
|
|
243
|
+
```
|
|
244
|
+
❌ WRONG: "Verified fixes, looks good"
|
|
245
|
+
✅ RIGHT: "Re-read 5 files, checked 23 sections, found 0 new issues"
|
|
246
|
+
```
|
|
247
|
+
|
|
248
|
+
### Round 2+ Workflow Diagram
|
|
249
|
+
|
|
250
|
+
```
|
|
251
|
+
FIXER [Round N] completes
|
|
252
|
+
↓
|
|
253
|
+
┌─────────────────────────────────────────┐
|
|
254
|
+
│ REVIEWER [Round N+1] — MANDATORY STEPS │
|
|
255
|
+
│ │
|
|
256
|
+
│ 1. Call Read() for EVERY file in scope │
|
|
257
|
+
│ (Do NOT skip, do NOT rely on memory)│
|
|
258
|
+
│ │
|
|
259
|
+
│ 2. For each file: │
|
|
260
|
+
│ □ Check section by section │
|
|
261
|
+
│ □ Audit imports vs usage │
|
|
262
|
+
│ □ Look for issues MISSED before │
|
|
263
|
+
│ │
|
|
264
|
+
│ 3. Verbalize: "Read X files, checked │
|
|
265
|
+
│ Y sections, found Z issues" │
|
|
266
|
+
│ │
|
|
267
|
+
│ 4. Only THEN: EXIT CHECK │
|
|
268
|
+
└─────────────────────────────────────────┘
|
|
269
|
+
```
|
|
270
|
+
|
|
271
|
+
**Full scope means:**
|
|
272
|
+
1. Re-run the ENTIRE checklist (A through G)
|
|
273
|
+
2. Review ALL files in scope, not just recent fixes
|
|
274
|
+
3. Check if fixes introduced NEW issues
|
|
275
|
+
4. Look for issues you missed in previous rounds
|
|
104
276
|
|
|
105
277
|
## Entry Actions
|
|
106
278
|
|
|
@@ -119,7 +291,27 @@ Before any workflow action:
|
|
|
119
291
|
|
|
120
292
|
## Mode Selection
|
|
121
293
|
|
|
122
|
-
### Check
|
|
294
|
+
### Step 1: Check Self-Review (MANDATORY)
|
|
295
|
+
|
|
296
|
+
```python
|
|
297
|
+
# Pseudo-code for self-review detection
|
|
298
|
+
files_in_scope = get_review_scope()
|
|
299
|
+
files_edited_this_session = get_agent_edits()
|
|
300
|
+
|
|
301
|
+
if files_in_scope & files_edited_this_session:
|
|
302
|
+
# SELF-REVIEW DETECTED
|
|
303
|
+
if user_said("--deep") or user_said("deep review"):
|
|
304
|
+
mode = ISOLATED
|
|
305
|
+
elif user_said("quick") or user_said("continue"):
|
|
306
|
+
mode = SAME_CONTEXT
|
|
307
|
+
add_warning_to_report = True # "Self-review without isolation"
|
|
308
|
+
else:
|
|
309
|
+
# Default: recommend --deep, wait for user choice
|
|
310
|
+
show_self_review_warning()
|
|
311
|
+
mode = ISOLATED # Default to safe option
|
|
312
|
+
```
|
|
313
|
+
|
|
314
|
+
### Step 2: Check Guard Output
|
|
123
315
|
|
|
124
316
|
Look for `review_suggested` warning:
|
|
125
317
|
```
|
|
@@ -128,25 +320,28 @@ WARNING: review_suggested - Security-sensitive path detected
|
|
|
128
320
|
WARNING: review_suggested - Low contract coverage
|
|
129
321
|
```
|
|
130
322
|
|
|
131
|
-
### Select Mode
|
|
323
|
+
### Select Mode (Final Decision)
|
|
132
324
|
|
|
133
|
-
| Condition | Mode |
|
|
134
|
-
|
|
135
|
-
|
|
|
136
|
-
|
|
|
137
|
-
|
|
|
325
|
+
| Condition | Mode | Notes |
|
|
326
|
+
|-----------|------|-------|
|
|
327
|
+
| Self-review detected | **Isolated** (default) | Unless user explicitly accepts risk |
|
|
328
|
+
| `review_suggested` present | **Isolated** | Guard recommends isolation |
|
|
329
|
+
| `--deep` flag | **Isolated** | User requested |
|
|
330
|
+
| Others' code, no triggers | **Quick** (same context) | Only valid for non-self code |
|
|
138
331
|
|
|
139
332
|
## Review Checklist
|
|
140
333
|
|
|
141
334
|
> **Principle:** Only items requiring semantic judgment. Mechanical checks are handled by Guard.
|
|
142
335
|
|
|
143
336
|
### A. Contract Semantic Value
|
|
337
|
+
|
|
144
338
|
- [ ] Does @pre constrain inputs beyond type checking?
|
|
145
339
|
- Bad: `@pre(lambda x: isinstance(x, int))`
|
|
146
340
|
- Good: `@pre(lambda x: x > 0 and x < MAX_VALUE)`
|
|
147
341
|
- [ ] Does @post verify meaningful output properties?
|
|
148
342
|
- Bad: `@post(lambda result: result is not None)`
|
|
149
343
|
- Good: `@post(lambda result: len(result) == len(input))`
|
|
344
|
+
|
|
150
345
|
- [ ] Could someone implement correctly from contracts alone?
|
|
151
346
|
- [ ] Are boundary conditions explicit in contracts?
|
|
152
347
|
|
|
@@ -194,21 +389,37 @@ These are checked by Guard or linters - don't duplicate:
|
|
|
194
389
|
- Entry point thickness → Guard (entry_point_too_thick)
|
|
195
390
|
- Escape hatch count → Guard (review_suggested)
|
|
196
391
|
|
|
197
|
-
## Auto-Loop Workflow (
|
|
392
|
+
## Auto-Loop Workflow (FULLY AUTOMATIC)
|
|
198
393
|
|
|
199
|
-
**The loop runs AUTOMATICALLY until exit condition is met.**
|
|
394
|
+
**The loop runs AUTOMATICALLY until exit condition is met. NO user interaction.**
|
|
395
|
+
|
|
396
|
+
**Two-step cycle: Review → Fix → Review → Fix → ...**
|
|
397
|
+
|
|
398
|
+
⚠️ **NEVER ask user:**
|
|
399
|
+
- "Proceed with fixes?"
|
|
400
|
+
- "Should I fix these?"
|
|
401
|
+
- "Do you want me to continue?"
|
|
402
|
+
|
|
403
|
+
**Just do it.** Find issues → Fix them → Review again → Repeat until done.
|
|
200
404
|
|
|
201
405
|
```
|
|
202
406
|
┌─────────────────────────────────────────────────────────────────┐
|
|
203
407
|
│ START: round = 1, issues = [] │
|
|
204
408
|
│ │
|
|
205
409
|
│ ┌─────────────────────────────────────────────────────────┐ │
|
|
206
|
-
│ │ 🔍 REVIEWER [Round N]
|
|
207
|
-
│ │ 1.
|
|
208
|
-
│ │ 2.
|
|
209
|
-
│ │ 3.
|
|
210
|
-
│ │ 4.
|
|
211
|
-
│ │ 5.
|
|
410
|
+
│ │ 🔍 REVIEWER [Round N] — Full Scope Review │ │
|
|
411
|
+
│ │ 1. Apply FULL checklist (A-G) to ENTIRE scope │ │
|
|
412
|
+
│ │ 2. Find ALL issues (don't stop at first) │ │
|
|
413
|
+
│ │ 3. Classify: CRITICAL / MAJOR / MINOR │ │
|
|
414
|
+
│ │ 4. Check previous fixes: CODE or just COMMENT? │ │
|
|
415
|
+
│ │ 5. Check if fixes introduced NEW issues │ │
|
|
416
|
+
│ │ 6. Update issues table │ │
|
|
417
|
+
│ │ │ │
|
|
418
|
+
│ │ EXIT CHECK: │ │
|
|
419
|
+
│ │ - IF no CRITICAL/MAJOR found → quality_met, EXIT │ │
|
|
420
|
+
│ │ - IF round >= MAX_ROUNDS → max_rounds, EXIT │ │
|
|
421
|
+
│ │ - IF no progress (same issues 2 rounds) → EXIT │ │
|
|
422
|
+
│ │ - ELSE → AUTO-TRANSITION to FIXER │ │
|
|
212
423
|
│ └─────────────────────────────────────────────────────────┘ │
|
|
213
424
|
│ ↓ (automatic) │
|
|
214
425
|
│ ┌─────────────────────────────────────────────────────────┐ │
|
|
@@ -216,26 +427,20 @@ These are checked by Guard or linters - don't duplicate:
|
|
|
216
427
|
│ │ 1. Fix EACH CRITICAL/MAJOR issue with CODE │ │
|
|
217
428
|
│ │ 2. Run invar_guard() after fixes │ │
|
|
218
429
|
│ │ 3. NO declaring quality_met (forbidden) │ │
|
|
219
|
-
│ │ 4.
|
|
220
|
-
│
|
|
221
|
-
│ ↓ (automatic) │
|
|
222
|
-
│ ┌─────────────────────────────────────────────────────────┐ │
|
|
223
|
-
│ │ ✅ REVIEWER [Round N] — Verification │ │
|
|
224
|
-
│ │ 1. Re-verify EACH fix: │ │
|
|
225
|
-
│ │ - Is fix CODE or just COMMENT? │ │
|
|
226
|
-
│ │ - Does fix actually address issue? │ │
|
|
227
|
-
│ │ - Did fix introduce new issues? │ │
|
|
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] │ │
|
|
430
|
+
│ │ 4. round++ │ │
|
|
431
|
+
│ │ 5. AUTO-TRANSITION to REVIEWER [Round N+1] │ │
|
|
233
432
|
│ └─────────────────────────────────────────────────────────┘ │
|
|
433
|
+
│ ↓ (automatic, fresh eyes) │
|
|
434
|
+
│ [LOOP BACK TO REVIEWER] │
|
|
234
435
|
│ │
|
|
235
436
|
│ EXIT: Generate final report │
|
|
236
437
|
└─────────────────────────────────────────────────────────────────┘
|
|
237
438
|
```
|
|
238
439
|
|
|
440
|
+
**Key change from v5.1:** No separate "Verify" step. Each round's Review is a
|
|
441
|
+
full-scope audit with the same rigor as Round 1. This prevents the "verification
|
|
442
|
+
mindset" trap where standards unconsciously lower after fixing.
|
|
443
|
+
|
|
239
444
|
## Loop State Tracking
|
|
240
445
|
|
|
241
446
|
**Maintain this state throughout the loop:**
|
|
@@ -249,20 +454,25 @@ These are checked by Guard or linters - don't duplicate:
|
|
|
249
454
|
- **Guard Status:** PASS | FAIL
|
|
250
455
|
```
|
|
251
456
|
|
|
252
|
-
##
|
|
457
|
+
## Issues Table (Updated Each Round)
|
|
253
458
|
|
|
254
|
-
| Issue ID | Severity | Round Found | Status | Evidence |
|
|
255
|
-
|
|
256
|
-
| MAJOR-1 | MAJOR | 1 | ✅ Fixed
|
|
257
|
-
| MAJOR-2 | MAJOR | 1 | ❌ Unfixed | Fix
|
|
258
|
-
| MAJOR-3 | MAJOR | 2 |
|
|
259
|
-
|
|
|
459
|
+
| Issue ID | Severity | Round Found | Round Fixed | Status | Evidence |
|
|
460
|
+
|----------|----------|-------------|-------------|--------|----------|
|
|
461
|
+
| MAJOR-1 | MAJOR | 1 | 1 | ✅ Fixed | Code change at file.py:123 |
|
|
462
|
+
| MAJOR-2 | MAJOR | 1 | - | ❌ Unfixed | Fix was comment, not code |
|
|
463
|
+
| MAJOR-3 | MAJOR | 2 | - | 🆕 New | Found in Round 2 review |
|
|
464
|
+
| MINOR-1 | MINOR | 1 | - | ⏭️ Backlog | Deferred (non-blocking) |
|
|
260
465
|
|
|
261
466
|
**Status Legend:**
|
|
262
|
-
- ✅ Fixed
|
|
263
|
-
- ❌ Unfixed — Fix failed
|
|
264
|
-
-
|
|
265
|
-
- ⏭️ Backlog — MINOR, deferred to later
|
|
467
|
+
- ✅ Fixed — Actually fixed with CODE (not comments)
|
|
468
|
+
- ❌ Unfixed — Fix failed, was just a comment, or not addressed
|
|
469
|
+
- 🆕 New — Found in a later round (fix may have introduced it, or missed earlier)
|
|
470
|
+
- ⏭️ Backlog — MINOR, deferred to later (non-blocking)
|
|
471
|
+
|
|
472
|
+
**Round 2+ Review MUST check:**
|
|
473
|
+
1. Are previous ✅ Fixed items ACTUALLY fixed? (Re-verify with fresh eyes)
|
|
474
|
+
2. Did fixes introduce NEW issues?
|
|
475
|
+
3. Did we miss anything in earlier rounds?
|
|
266
476
|
|
|
267
477
|
If ANY ❌ exists for CRITICAL/MAJOR after MAX_ROUNDS → quality_not_met
|
|
268
478
|
|
|
@@ -276,26 +486,28 @@ If ANY ❌ exists for CRITICAL/MAJOR after MAX_ROUNDS → quality_not_met
|
|
|
276
486
|
|
|
277
487
|
## Exit Conditions (Auto-Loop)
|
|
278
488
|
|
|
279
|
-
**Exit
|
|
489
|
+
**Exit is checked at the START of each REVIEWER phase (before finding issues):**
|
|
280
490
|
|
|
281
491
|
| Condition | Exit Reason | Result |
|
|
282
492
|
|-----------|-------------|--------|
|
|
283
|
-
|
|
|
493
|
+
| Round N Review finds 0 CRITICAL/MAJOR | `quality_met` | ✅ Ready for merge |
|
|
284
494
|
| Round >= MAX_ROUNDS | `max_rounds` | ⚠️ Manual review needed |
|
|
285
495
|
| No progress (same issues 2 rounds) | `no_improvement` | ❌ Architectural issue |
|
|
286
|
-
| Guard fails after fix | Continue loop | 🔄 More fixes needed |
|
|
287
496
|
|
|
288
497
|
**quality_met requires ALL of:**
|
|
289
|
-
1.
|
|
290
|
-
2.
|
|
291
|
-
3.
|
|
292
|
-
4.
|
|
498
|
+
1. Current round's FULL SCOPE review found zero CRITICAL/MAJOR
|
|
499
|
+
2. All previous issues verified as fixed (with code, not comments)
|
|
500
|
+
3. Guard passes
|
|
501
|
+
4. Issues table complete with evidence
|
|
293
502
|
|
|
294
503
|
**Automatic quality_not_met:**
|
|
295
504
|
- Any MAJOR "fixed" with comment instead of code
|
|
296
505
|
- Any issue marked "assessed" or "acceptable"
|
|
297
506
|
- Fixer role declared quality_met (role violation)
|
|
298
|
-
-
|
|
507
|
+
- Same CRITICAL/MAJOR persists for 2+ rounds
|
|
508
|
+
|
|
509
|
+
**Important:** quality_met is declared when a Review round finds NO new issues,
|
|
510
|
+
not when fixes are applied. This ensures the final state is actually reviewed.
|
|
299
511
|
|
|
300
512
|
## Exit Report (Generated Automatically)
|
|
301
513
|
|
|
@@ -306,29 +518,45 @@ If ANY ❌ exists for CRITICAL/MAJOR after MAX_ROUNDS → quality_not_met
|
|
|
306
518
|
|
|
307
519
|
**Exit Reason:** quality_met | max_rounds | no_improvement
|
|
308
520
|
**Total Rounds:** N / MAX_ROUNDS
|
|
521
|
+
**Final Round Result:** 0 CRITICAL/MAJOR found (quality_met) | X issues remain
|
|
309
522
|
**Guard Status:** PASS | FAIL
|
|
523
|
+
**Review Mode:** Isolated | Same-context (self-review⚠️)
|
|
310
524
|
|
|
311
|
-
##
|
|
525
|
+
## Issues Table
|
|
312
526
|
|
|
313
|
-
| Issue | Severity |
|
|
314
|
-
|
|
315
|
-
| MAJOR-1 | MAJOR |
|
|
316
|
-
|
|
|
527
|
+
| Issue | Severity | Found | Fixed | Status | Evidence |
|
|
528
|
+
|-------|----------|-------|-------|--------|----------|
|
|
529
|
+
| MAJOR-1 | MAJOR | R1 | R1 | ✅ Fixed | Code at file.py:123 |
|
|
530
|
+
| MAJOR-2 | MAJOR | R2 | R2 | ✅ Fixed | Added validation |
|
|
531
|
+
| ... | ... | ... | ... | ... | ... |
|
|
317
532
|
|
|
318
|
-
##
|
|
533
|
+
## Round Summary
|
|
319
534
|
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
535
|
+
| Round | Issues Found | Issues Fixed | New from Fixes |
|
|
536
|
+
|-------|--------------|--------------|----------------|
|
|
537
|
+
| 1 | 3 | 3 | 0 |
|
|
538
|
+
| 2 | 1 | 1 | 0 |
|
|
539
|
+
| 3 | 0 | - | - | ← quality_met
|
|
324
540
|
|
|
325
|
-
## Self-Check (
|
|
541
|
+
## Self-Check (Final Review Round)
|
|
326
542
|
|
|
543
|
+
- [x] Applied FULL checklist (A-G) with fresh eyes
|
|
327
544
|
- [x] All fixes are CODE, not comments
|
|
328
545
|
- [x] No "assessed as acceptable" rationalizations
|
|
329
546
|
- [x] Guard passes after all changes
|
|
330
547
|
- [x] Role separation maintained throughout
|
|
331
548
|
|
|
549
|
+
## Self-Review Warning (if applicable)
|
|
550
|
+
|
|
551
|
+
⚠️ **This was a same-context self-review.** Cognitive biases may have caused
|
|
552
|
+
issues to be missed. For higher confidence, run `--deep` review before merge.
|
|
553
|
+
|
|
554
|
+
Known blind spots in self-review:
|
|
555
|
+
- Exception handlers that silently lose data
|
|
556
|
+
- Path traversal / security issues in user input
|
|
557
|
+
- Edge cases in validation logic
|
|
558
|
+
- Documentation-implementation mismatches
|
|
559
|
+
|
|
332
560
|
## Recommendation
|
|
333
561
|
|
|
334
562
|
- [x] Ready for merge (quality_met)
|
|
@@ -338,8 +566,40 @@ If ANY ❌ exists for CRITICAL/MAJOR after MAX_ROUNDS → quality_not_met
|
|
|
338
566
|
**MINOR (Backlog):**
|
|
339
567
|
- [list deferred items]
|
|
340
568
|
```
|
|
341
|
-
|
|
342
|
-
|
|
569
|
+
## Appendix: Adversarial Code Reviewer Persona
|
|
570
|
+
|
|
571
|
+
Used in `--deep` mode (isolated agent):
|
|
572
|
+
|
|
573
|
+
```
|
|
574
|
+
You are an independent Adversarial Code Reviewer.
|
|
575
|
+
|
|
576
|
+
CRITICAL RULES:
|
|
577
|
+
1. Code is GUILTY until proven INNOCENT
|
|
578
|
+
2. You did NOT write this code — no emotional attachment
|
|
579
|
+
3. Find reasons to REJECT, not accept
|
|
580
|
+
4. Be specific and actionable (file:line, concrete fix)
|
|
581
|
+
5. Your job is to find bugs, not approve code
|
|
582
|
+
|
|
583
|
+
INPUT YOU WILL RECEIVE:
|
|
584
|
+
- Code files to review
|
|
585
|
+
- Contracts (if available)
|
|
586
|
+
- Test files (if available)
|
|
587
|
+
|
|
588
|
+
INPUT YOU WILL NOT RECEIVE:
|
|
589
|
+
- Development conversation history
|
|
590
|
+
- Developer's explanations
|
|
591
|
+
- Prior context about design decisions
|
|
592
|
+
|
|
593
|
+
OUTPUT FORMAT:
|
|
594
|
+
Produce structured Review Report with:
|
|
595
|
+
1. Verdict: APPROVED / NEEDS WORK / REJECTED
|
|
596
|
+
2. Critical issues (must fix)
|
|
597
|
+
3. Major issues (should fix)
|
|
598
|
+
4. Minor issues (nice to fix)
|
|
599
|
+
5. Positive observations (what's done well)
|
|
600
|
+
```
|
|
601
|
+
|
|
602
|
+
<!--/invar:skill--><!--invar:extensions-->
|
|
343
603
|
<!-- ========================================================================
|
|
344
604
|
EXTENSIONS REGION - USER EDITABLE
|
|
345
605
|
Add project-specific extensions here. This section is preserved on update.
|