invar-tools 1.0.0__py3-none-any.whl → 1.3.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 +1 -0
- invar/core/contracts.py +80 -10
- invar/core/entry_points.py +367 -0
- invar/core/extraction.py +5 -6
- invar/core/format_specs.py +195 -0
- invar/core/format_strategies.py +197 -0
- invar/core/formatter.py +32 -10
- invar/core/hypothesis_strategies.py +50 -10
- invar/core/inspect.py +1 -1
- invar/core/lambda_helpers.py +3 -2
- invar/core/models.py +30 -18
- invar/core/must_use.py +2 -1
- invar/core/parser.py +13 -6
- invar/core/postcondition_scope.py +128 -0
- invar/core/property_gen.py +86 -42
- invar/core/purity.py +13 -7
- invar/core/purity_heuristics.py +5 -9
- invar/core/references.py +8 -6
- invar/core/review_trigger.py +370 -0
- invar/core/rule_meta.py +69 -2
- invar/core/rules.py +91 -28
- invar/core/shell_analysis.py +247 -0
- invar/core/shell_architecture.py +171 -0
- invar/core/strategies.py +7 -14
- invar/core/suggestions.py +92 -0
- invar/core/sync_helpers.py +238 -0
- invar/core/tautology.py +103 -37
- invar/core/template_parser.py +467 -0
- invar/core/timeout_inference.py +4 -7
- invar/core/utils.py +63 -18
- invar/core/verification_routing.py +155 -0
- invar/mcp/server.py +113 -13
- invar/shell/commands/__init__.py +11 -0
- invar/shell/{cli.py → commands/guard.py} +152 -44
- invar/shell/{init_cmd.py → commands/init.py} +200 -28
- invar/shell/commands/merge.py +256 -0
- invar/shell/commands/mutate.py +184 -0
- invar/shell/{perception.py → commands/perception.py} +2 -0
- invar/shell/commands/sync_self.py +113 -0
- invar/shell/commands/template_sync.py +366 -0
- invar/shell/{test_cmd.py → commands/test.py} +3 -1
- invar/shell/commands/update.py +48 -0
- invar/shell/config.py +247 -10
- invar/shell/coverage.py +351 -0
- invar/shell/fs.py +5 -2
- invar/shell/git.py +2 -0
- invar/shell/guard_helpers.py +116 -20
- invar/shell/guard_output.py +106 -24
- invar/shell/mcp_config.py +3 -0
- invar/shell/mutation.py +314 -0
- invar/shell/property_tests.py +75 -24
- invar/shell/prove/__init__.py +9 -0
- invar/shell/prove/accept.py +113 -0
- invar/shell/{prove.py → prove/crosshair.py} +69 -30
- invar/shell/prove/hypothesis.py +293 -0
- invar/shell/subprocess_env.py +393 -0
- invar/shell/template_engine.py +345 -0
- invar/shell/templates.py +53 -0
- invar/shell/testing.py +77 -37
- invar/templates/CLAUDE.md.template +86 -9
- invar/templates/aider.conf.yml.template +16 -14
- invar/templates/commands/audit.md +138 -0
- invar/templates/commands/guard.md +77 -0
- invar/templates/config/CLAUDE.md.jinja +206 -0
- invar/templates/config/context.md.jinja +92 -0
- invar/templates/config/pre-commit.yaml.jinja +44 -0
- invar/templates/context.md.template +33 -0
- invar/templates/cursorrules.template +25 -13
- invar/templates/examples/README.md +2 -0
- invar/templates/examples/conftest.py +3 -0
- invar/templates/examples/contracts.py +4 -2
- invar/templates/examples/core_shell.py +10 -4
- invar/templates/examples/workflow.md +81 -0
- invar/templates/manifest.toml +137 -0
- invar/templates/protocol/INVAR.md +210 -0
- invar/templates/skills/develop/SKILL.md.jinja +318 -0
- invar/templates/skills/investigate/SKILL.md.jinja +106 -0
- invar/templates/skills/propose/SKILL.md.jinja +104 -0
- invar/templates/skills/review/SKILL.md.jinja +125 -0
- invar_tools-1.3.0.dist-info/METADATA +377 -0
- invar_tools-1.3.0.dist-info/RECORD +95 -0
- invar_tools-1.3.0.dist-info/entry_points.txt +2 -0
- invar_tools-1.3.0.dist-info/licenses/LICENSE +190 -0
- invar_tools-1.3.0.dist-info/licenses/LICENSE-GPL +674 -0
- invar_tools-1.3.0.dist-info/licenses/NOTICE +63 -0
- invar/contracts.py +0 -152
- invar/decorators.py +0 -94
- invar/invariant.py +0 -57
- invar/resource.py +0 -99
- invar/shell/prove_fallback.py +0 -183
- invar/shell/update_cmd.py +0 -191
- invar/templates/INVAR.md +0 -134
- invar_tools-1.0.0.dist-info/METADATA +0 -321
- invar_tools-1.0.0.dist-info/RECORD +0 -64
- invar_tools-1.0.0.dist-info/entry_points.txt +0 -2
- invar_tools-1.0.0.dist-info/licenses/LICENSE +0 -21
- /invar/shell/{prove_cache.py → prove/cache.py} +0 -0
- {invar_tools-1.0.0.dist-info → invar_tools-1.3.0.dist-info}/WHEEL +0 -0
|
@@ -0,0 +1,318 @@
|
|
|
1
|
+
<!--invar:skill version="{{ version }}"-->
|
|
2
|
+
<!-- ========================================================================
|
|
3
|
+
SKILL REGION - DO NOT EDIT
|
|
4
|
+
This section is managed by Invar and will be overwritten on update.
|
|
5
|
+
To add project-specific extensions, use the "extensions" region below.
|
|
6
|
+
======================================================================== -->
|
|
7
|
+
---
|
|
8
|
+
name: develop
|
|
9
|
+
description: Implementation phase following USBV workflow. Use when task is clear and actionable - "add", "implement", "create", "fix", "update", "build", "write". Requires Check-In at start and Final at end.
|
|
10
|
+
---
|
|
11
|
+
|
|
12
|
+
# Development Mode
|
|
13
|
+
|
|
14
|
+
> **Purpose:** Implement solution following USBV workflow with verification.
|
|
15
|
+
|
|
16
|
+
## Entry Actions (REQUIRED)
|
|
17
|
+
|
|
18
|
+
### Context Refresh (DX-54)
|
|
19
|
+
|
|
20
|
+
Before any workflow action:
|
|
21
|
+
1. Read `.invar/context.md` (especially Key Rules section)
|
|
22
|
+
2. Display routing announcement
|
|
23
|
+
|
|
24
|
+
### Routing Announcement
|
|
25
|
+
|
|
26
|
+
```
|
|
27
|
+
📍 Routing: /develop — [trigger detected, e.g. "add", "fix", "implement"]
|
|
28
|
+
Task: [user's request summary]
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
### Simple Task Detection
|
|
32
|
+
|
|
33
|
+
If task appears simple (4+ signals: single file, clear target, additive change, <50 lines):
|
|
34
|
+
|
|
35
|
+
```
|
|
36
|
+
📊 Simple task (1 file, ~N lines).
|
|
37
|
+
Auto-orchestrate: investigate → develop → validate?
|
|
38
|
+
[Y/N]
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
- Y → Execute full cycle without intermediate confirmations
|
|
42
|
+
- N → Proceed with normal USBV checkpoints
|
|
43
|
+
- No response → Default to step-by-step (safe)
|
|
44
|
+
|
|
45
|
+
## USBV Workflow
|
|
46
|
+
|
|
47
|
+
### 1. UNDERSTAND
|
|
48
|
+
|
|
49
|
+
- **Intent:** What exactly needs to be done?
|
|
50
|
+
{% if syntax == "mcp" -%}
|
|
51
|
+
- **Inspect:** Use `invar_sig` to see existing contracts
|
|
52
|
+
{% else -%}
|
|
53
|
+
- **Inspect:** Use `invar sig` to see existing contracts
|
|
54
|
+
{% endif -%}
|
|
55
|
+
- **Context:** Read relevant code, understand patterns
|
|
56
|
+
- **Constraints:** What must NOT change?
|
|
57
|
+
|
|
58
|
+
### 2. SPECIFY
|
|
59
|
+
|
|
60
|
+
- **Contracts FIRST:** Write `@pre`/`@post` before implementation
|
|
61
|
+
- **Doctests:** Add examples for expected behavior
|
|
62
|
+
- **Design:** Decompose complex tasks into sub-functions
|
|
63
|
+
|
|
64
|
+
```python
|
|
65
|
+
# SPECIFY before BUILD:
|
|
66
|
+
@pre(lambda x: x > 0)
|
|
67
|
+
@post(lambda result: result >= 0)
|
|
68
|
+
def calculate(x: int) -> int:
|
|
69
|
+
"""
|
|
70
|
+
>>> calculate(10)
|
|
71
|
+
100
|
|
72
|
+
"""
|
|
73
|
+
... # Implementation comes in BUILD
|
|
74
|
+
```
|
|
75
|
+
|
|
76
|
+
### 3. BUILD
|
|
77
|
+
|
|
78
|
+
**For complex tasks:** Enter Plan Mode first, get user approval.
|
|
79
|
+
|
|
80
|
+
**Implementation rules:**
|
|
81
|
+
- Follow the contracts written in SPECIFY
|
|
82
|
+
{% if syntax == "mcp" -%}
|
|
83
|
+
- Run `invar_guard(changed=true)` frequently
|
|
84
|
+
{% else -%}
|
|
85
|
+
- Run `invar guard --changed` frequently
|
|
86
|
+
{% endif -%}
|
|
87
|
+
- Commit after each logical unit
|
|
88
|
+
|
|
89
|
+
**Commit format:**
|
|
90
|
+
```bash
|
|
91
|
+
git add . && git commit -m "feat: [description]
|
|
92
|
+
|
|
93
|
+
🤖 Generated with [Claude Code](https://claude.com/claude-code)
|
|
94
|
+
|
|
95
|
+
Co-Authored-By: Claude <noreply@anthropic.com>"
|
|
96
|
+
```
|
|
97
|
+
|
|
98
|
+
### 4. VALIDATE
|
|
99
|
+
|
|
100
|
+
{% if syntax == "mcp" -%}
|
|
101
|
+
- Run `invar_guard()` (full verification)
|
|
102
|
+
{% else -%}
|
|
103
|
+
- Run `invar guard` (full verification)
|
|
104
|
+
{% endif -%}
|
|
105
|
+
- All TodoWrite items complete
|
|
106
|
+
- Integration works (if applicable)
|
|
107
|
+
|
|
108
|
+
## Task Batching
|
|
109
|
+
|
|
110
|
+
For multiple tasks:
|
|
111
|
+
1. Create TodoWrite with all items upfront
|
|
112
|
+
2. Execute sequentially (not parallel)
|
|
113
|
+
3. After each task:
|
|
114
|
+
- Commit changes
|
|
115
|
+
{% if syntax == "mcp" -%}
|
|
116
|
+
- Run `invar_guard(changed=true)`
|
|
117
|
+
{% else -%}
|
|
118
|
+
- Run `invar guard --changed`
|
|
119
|
+
{% endif -%}
|
|
120
|
+
- Update TodoWrite
|
|
121
|
+
4. **Limits:** Max 5 tasks OR 4 hours OR Guard failure
|
|
122
|
+
|
|
123
|
+
## Failure Handling
|
|
124
|
+
|
|
125
|
+
| Guard Result | Action |
|
|
126
|
+
|--------------|--------|
|
|
127
|
+
| Static fixable (missing contract) | Auto-fix, retry (max 2) |
|
|
128
|
+
| Test failure | Report to user, ask for guidance |
|
|
129
|
+
| Contract violation | Report, suggest `/investigate` |
|
|
130
|
+
| Repeated failure | Stop, ask user |
|
|
131
|
+
|
|
132
|
+
## Common Guard Errors
|
|
133
|
+
|
|
134
|
+
Quick reference for resolving common Guard errors:
|
|
135
|
+
|
|
136
|
+
| Error | Cause | Quick Fix |
|
|
137
|
+
|-------|-------|-----------|
|
|
138
|
+
| `forbidden_import: io` | I/O library in Core | Use `iter(s.splitlines())` not `io.StringIO` |
|
|
139
|
+
| `forbidden_import: os` | os module in Core | Accept `Path` as parameter instead |
|
|
140
|
+
| `forbidden_import: pathlib` | pathlib in Core | Accept `Path` or `str` as parameter |
|
|
141
|
+
| `internal_import` | Import inside function | Move import to module top |
|
|
142
|
+
| `missing_contract` | Core function without @pre/@post | Add contract before implementation |
|
|
143
|
+
| `empty_contract` | Contract with no condition | Add meaningful condition |
|
|
144
|
+
| `redundant_type_contract` | Contract only checks types | Add semantic constraints (bounds, relationships) |
|
|
145
|
+
| `partial_contract` | Only some params validated | Validate all params or document why partial |
|
|
146
|
+
| `file_size` | File > 500 lines | Extract functions to new module |
|
|
147
|
+
| `shell_result` | Shell function missing Result | Return `Result[T, E]` from `returns` |
|
|
148
|
+
|
|
149
|
+
**Tip:** For `missing_contract`, Guard automatically suggests contracts based on parameter types.
|
|
150
|
+
Check the "Suggested:" line in Guard output.
|
|
151
|
+
|
|
152
|
+
**Note:** Use `from deal import pre, post` for lambda-based contracts.
|
|
153
|
+
`invar_runtime.pre/post` are for Contract objects like `NonEmpty`.
|
|
154
|
+
|
|
155
|
+
## Timeout Handling
|
|
156
|
+
|
|
157
|
+
| Threshold | Duration | Action |
|
|
158
|
+
|-----------|----------|--------|
|
|
159
|
+
| Warning | 3 hours (75%) | Soft warning with options |
|
|
160
|
+
| Hard stop | 4 hours (max) | Save state, exit |
|
|
161
|
+
|
|
162
|
+
**75% Warning:**
|
|
163
|
+
```
|
|
164
|
+
⏱ Time check: /develop has been running for 3 hours.
|
|
165
|
+
Remaining estimate: [based on TodoWrite progress]
|
|
166
|
+
|
|
167
|
+
Options:
|
|
168
|
+
A: Continue (1 hour max remaining)
|
|
169
|
+
B: Wrap up current task and exit
|
|
170
|
+
C: Checkpoint and pause for later
|
|
171
|
+
|
|
172
|
+
Choice? (auto-continue in 2 minutes if no response)
|
|
173
|
+
```
|
|
174
|
+
|
|
175
|
+
**Hard Stop:**
|
|
176
|
+
```
|
|
177
|
+
⏱ /develop reached 4-hour limit.
|
|
178
|
+
|
|
179
|
+
Completed: [N]/[M] tasks
|
|
180
|
+
Current task: [description] - [%] complete
|
|
181
|
+
|
|
182
|
+
Saving state for resume. Run '/develop --resume' to continue.
|
|
183
|
+
```
|
|
184
|
+
|
|
185
|
+
## Exit Actions (REQUIRED)
|
|
186
|
+
|
|
187
|
+
### Final
|
|
188
|
+
|
|
189
|
+
{% if syntax == "mcp" -%}
|
|
190
|
+
```python
|
|
191
|
+
invar_guard()
|
|
192
|
+
```
|
|
193
|
+
{% else -%}
|
|
194
|
+
```bash
|
|
195
|
+
invar guard
|
|
196
|
+
```
|
|
197
|
+
{% endif %}
|
|
198
|
+
|
|
199
|
+
**Display:**
|
|
200
|
+
```
|
|
201
|
+
✓ Final: guard [PASS/FAIL] | [errors] errors, [warnings] warnings
|
|
202
|
+
```
|
|
203
|
+
|
|
204
|
+
### Auto-Review (DX-41)
|
|
205
|
+
|
|
206
|
+
If Guard outputs `review_suggested`:
|
|
207
|
+
|
|
208
|
+
```
|
|
209
|
+
⚠ review_suggested: [reason]
|
|
210
|
+
|
|
211
|
+
📍 Routing: /review — review_suggested triggered
|
|
212
|
+
Task: Review [N files changed]
|
|
213
|
+
```
|
|
214
|
+
|
|
215
|
+
Proceed directly to /review skill. User can say "skip" to bypass.
|
|
216
|
+
|
|
217
|
+
## Phase Visibility (DX-51)
|
|
218
|
+
|
|
219
|
+
**USBV phases must be visually distinct.** On each phase transition, display a phase header:
|
|
220
|
+
|
|
221
|
+
### Phase Header Format
|
|
222
|
+
|
|
223
|
+
```
|
|
224
|
+
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
|
|
225
|
+
📍 /develop → SPECIFY (2/4)
|
|
226
|
+
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
|
|
227
|
+
```
|
|
228
|
+
|
|
229
|
+
### Compact Format (brief updates)
|
|
230
|
+
|
|
231
|
+
```
|
|
232
|
+
📍 VALIDATE — Running guard...
|
|
233
|
+
```
|
|
234
|
+
|
|
235
|
+
### Three-Layer Visibility
|
|
236
|
+
|
|
237
|
+
| Layer | What | Tool |
|
|
238
|
+
|-------|------|------|
|
|
239
|
+
| Skill | `/develop` | Routing announcement |
|
|
240
|
+
| Phase | `SPECIFY (2/4)` | Phase header (this section) |
|
|
241
|
+
| Tasks | Concrete items | TodoWrite |
|
|
242
|
+
|
|
243
|
+
**Phase headers are SEPARATE from TodoWrite.**
|
|
244
|
+
- Phase = where you are in workflow (visible in output)
|
|
245
|
+
- TodoWrite = what tasks need doing (visible in status panel)
|
|
246
|
+
|
|
247
|
+
**BUILD is internal work** — show header but no detailed breakdown.
|
|
248
|
+
|
|
249
|
+
## Tool Selection
|
|
250
|
+
|
|
251
|
+
| I want to... | Use |
|
|
252
|
+
|--------------|-----|
|
|
253
|
+
{% if syntax == "mcp" -%}
|
|
254
|
+
| See contracts | `invar_sig <file>` |
|
|
255
|
+
| Find entry points | `invar_map --top 10` |
|
|
256
|
+
| Verify code | `invar_guard` |
|
|
257
|
+
{% else -%}
|
|
258
|
+
| See contracts | `invar sig <file>` |
|
|
259
|
+
| Find entry points | `invar map --top 10` |
|
|
260
|
+
| Verify code | `invar guard` |
|
|
261
|
+
{% endif -%}
|
|
262
|
+
| Edit symbol | Serena `replace_symbol_body` |
|
|
263
|
+
| Add after symbol | Serena `insert_after_symbol` |
|
|
264
|
+
| Rename symbol | Serena `rename_symbol` |
|
|
265
|
+
|
|
266
|
+
## Example
|
|
267
|
+
|
|
268
|
+
```
|
|
269
|
+
User: "Add input validation to parse_source"
|
|
270
|
+
|
|
271
|
+
Agent:
|
|
272
|
+
📍 Routing: /develop — "add" trigger detected
|
|
273
|
+
Task: Add input validation to parse_source
|
|
274
|
+
|
|
275
|
+
✓ Check-In: Invar | main | clean
|
|
276
|
+
|
|
277
|
+
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
|
|
278
|
+
📍 /develop → UNDERSTAND (1/4)
|
|
279
|
+
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
|
|
280
|
+
|
|
281
|
+
- Current: accepts any string
|
|
282
|
+
- Need: reject whitespace-only strings
|
|
283
|
+
- File: src/invar/core/parser.py
|
|
284
|
+
|
|
285
|
+
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
|
|
286
|
+
📍 /develop → SPECIFY (2/4)
|
|
287
|
+
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
|
|
288
|
+
|
|
289
|
+
@pre(lambda source, path: len(source.strip()) > 0)
|
|
290
|
+
|
|
291
|
+
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
|
|
292
|
+
📍 /develop → BUILD (3/4)
|
|
293
|
+
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
|
|
294
|
+
|
|
295
|
+
[Implementation...]
|
|
296
|
+
|
|
297
|
+
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
|
|
298
|
+
📍 /develop → VALIDATE (4/4)
|
|
299
|
+
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
|
|
300
|
+
|
|
301
|
+
✓ guard PASS | 0 errors, 1 warning
|
|
302
|
+
|
|
303
|
+
✓ Final: guard PASS | 0 errors, 1 warning
|
|
304
|
+
```
|
|
305
|
+
<!--/invar:skill-->
|
|
306
|
+
|
|
307
|
+
<!--invar:extensions-->
|
|
308
|
+
<!-- ========================================================================
|
|
309
|
+
EXTENSIONS REGION - USER EDITABLE
|
|
310
|
+
Add project-specific extensions here. This section is preserved on update.
|
|
311
|
+
|
|
312
|
+
Examples of what to add:
|
|
313
|
+
- Project-specific validation steps
|
|
314
|
+
- Custom commit message formats
|
|
315
|
+
- Additional tool integrations
|
|
316
|
+
- Team-specific workflows
|
|
317
|
+
======================================================================== -->
|
|
318
|
+
<!--/invar:extensions-->
|
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
<!--invar:skill version="{{ version }}"-->
|
|
2
|
+
<!-- ========================================================================
|
|
3
|
+
SKILL REGION - DO NOT EDIT
|
|
4
|
+
This section is managed by Invar and will be overwritten on update.
|
|
5
|
+
To add project-specific extensions, use the "extensions" region below.
|
|
6
|
+
======================================================================== -->
|
|
7
|
+
---
|
|
8
|
+
name: investigate
|
|
9
|
+
description: Exploration and understanding phase. Use when task is vague, needs analysis, or requires understanding before action. Triggers on "why", "what is", "how does", "explain", "understand", "analyze", "investigate", "explore". NO CODE CHANGES in this phase.
|
|
10
|
+
---
|
|
11
|
+
|
|
12
|
+
# Investigation Mode
|
|
13
|
+
|
|
14
|
+
> **Purpose:** Understand before acting. Gather information, analyze code, report findings.
|
|
15
|
+
|
|
16
|
+
## Constraints
|
|
17
|
+
|
|
18
|
+
**FORBIDDEN in this phase:**
|
|
19
|
+
- Edit, Write (no code changes)
|
|
20
|
+
- git commit (nothing to commit)
|
|
21
|
+
- Creating new files
|
|
22
|
+
|
|
23
|
+
**ALLOWED:**
|
|
24
|
+
- Read, Glob, Grep (exploration)
|
|
25
|
+
{% if syntax == "mcp" -%}
|
|
26
|
+
- invar_sig, invar_map (perception)
|
|
27
|
+
{% else -%}
|
|
28
|
+
- invar sig, invar map (perception)
|
|
29
|
+
{% endif -%}
|
|
30
|
+
- WebSearch, WebFetch (research)
|
|
31
|
+
|
|
32
|
+
## Entry Actions
|
|
33
|
+
|
|
34
|
+
### Context Refresh (DX-54)
|
|
35
|
+
|
|
36
|
+
Before any workflow action:
|
|
37
|
+
1. Read `.invar/context.md` (especially Key Rules section)
|
|
38
|
+
2. Display routing announcement
|
|
39
|
+
|
|
40
|
+
### Routing Announcement
|
|
41
|
+
|
|
42
|
+
```
|
|
43
|
+
📍 Routing: /investigate — [reason, e.g. "task is vague", "trigger 'why'"]
|
|
44
|
+
Task: [user's request summary]
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
### Entry Steps
|
|
48
|
+
|
|
49
|
+
1. Display routing announcement (above)
|
|
50
|
+
{% if syntax == "mcp" -%}
|
|
51
|
+
2. Run `invar_map(top=10)` for codebase orientation
|
|
52
|
+
{% else -%}
|
|
53
|
+
2. Run `invar map --top 10` for codebase orientation
|
|
54
|
+
{% endif -%}
|
|
55
|
+
3. Explore relevant code and documentation
|
|
56
|
+
|
|
57
|
+
## Tool Selection
|
|
58
|
+
|
|
59
|
+
| I want to... | Use |
|
|
60
|
+
|--------------|-----|
|
|
61
|
+
{% if syntax == "mcp" -%}
|
|
62
|
+
| See function contracts | `invar_sig(target="<file>")` |
|
|
63
|
+
| Find entry points | `invar_map(top=10)` |
|
|
64
|
+
{% else -%}
|
|
65
|
+
| See function contracts | `invar sig <file>` |
|
|
66
|
+
| Find entry points | `invar map --top 10` |
|
|
67
|
+
{% endif -%}
|
|
68
|
+
| Search code patterns | Grep with regex |
|
|
69
|
+
| Explore codebase | Task(Explore) agent |
|
|
70
|
+
|
|
71
|
+
## Exit Format
|
|
72
|
+
|
|
73
|
+
```markdown
|
|
74
|
+
### Investigation Complete
|
|
75
|
+
|
|
76
|
+
**Topic:** [what was investigated]
|
|
77
|
+
|
|
78
|
+
**Findings:**
|
|
79
|
+
1. [Key finding 1]
|
|
80
|
+
2. [Key finding 2]
|
|
81
|
+
3. [Key finding 3]
|
|
82
|
+
|
|
83
|
+
**Details:**
|
|
84
|
+
[Detailed explanation with file:line references]
|
|
85
|
+
|
|
86
|
+
**Recommendation:**
|
|
87
|
+
- [ ] /propose — Design decision needed
|
|
88
|
+
- [ ] /develop — Ready to implement [specific task]
|
|
89
|
+
- [ ] More investigation — [what's still unclear]
|
|
90
|
+
|
|
91
|
+
**Next step?**
|
|
92
|
+
```
|
|
93
|
+
<!--/invar:skill-->
|
|
94
|
+
|
|
95
|
+
<!--invar:extensions-->
|
|
96
|
+
<!-- ========================================================================
|
|
97
|
+
EXTENSIONS REGION - USER EDITABLE
|
|
98
|
+
Add project-specific extensions here. This section is preserved on update.
|
|
99
|
+
|
|
100
|
+
Examples of what to add:
|
|
101
|
+
- Project-specific investigation checklists
|
|
102
|
+
- Custom analysis tools or scripts
|
|
103
|
+
- Domain-specific research sources
|
|
104
|
+
- Team documentation references
|
|
105
|
+
======================================================================== -->
|
|
106
|
+
<!--/invar:extensions-->
|
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
<!--invar:skill version="{{ version }}"-->
|
|
2
|
+
<!-- ========================================================================
|
|
3
|
+
SKILL REGION - DO NOT EDIT
|
|
4
|
+
This section is managed by Invar and will be overwritten on update.
|
|
5
|
+
To add project-specific extensions, use the "extensions" region below.
|
|
6
|
+
======================================================================== -->
|
|
7
|
+
---
|
|
8
|
+
name: propose
|
|
9
|
+
description: Decision facilitation phase. Use when design decision is needed, multiple approaches are valid, or user asks "should we", "how should", "which", "compare", "design", "architect". Presents options with trade-offs for human choice.
|
|
10
|
+
---
|
|
11
|
+
|
|
12
|
+
# Proposal Mode
|
|
13
|
+
|
|
14
|
+
> **Purpose:** Facilitate human decision-making with clear options and trade-offs.
|
|
15
|
+
|
|
16
|
+
## Entry Actions
|
|
17
|
+
|
|
18
|
+
### Context Refresh (DX-54)
|
|
19
|
+
|
|
20
|
+
Before any workflow action:
|
|
21
|
+
1. Read `.invar/context.md` (especially Key Rules section)
|
|
22
|
+
2. Display routing announcement
|
|
23
|
+
|
|
24
|
+
### Routing Announcement
|
|
25
|
+
|
|
26
|
+
```
|
|
27
|
+
📍 Routing: /propose — [trigger detected, e.g. "should we", "compare", "design"]
|
|
28
|
+
Task: [decision topic summary]
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
### Entry Steps
|
|
32
|
+
|
|
33
|
+
1. Display routing announcement (above)
|
|
34
|
+
2. Explore relevant context if needed
|
|
35
|
+
|
|
36
|
+
## Output Formats
|
|
37
|
+
|
|
38
|
+
### Quick Decision (2-4 options)
|
|
39
|
+
|
|
40
|
+
```markdown
|
|
41
|
+
### Decision: [Topic]
|
|
42
|
+
|
|
43
|
+
| Option | Description | Pros | Cons |
|
|
44
|
+
|--------|-------------|------|------|
|
|
45
|
+
| A: [name] | [brief] | [pros] | [cons] |
|
|
46
|
+
| B: [name] | [brief] | [pros] | [cons] |
|
|
47
|
+
|
|
48
|
+
**Recommendation:** [A/B] because [concise reason]
|
|
49
|
+
|
|
50
|
+
**Your choice?**
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
### Formal Proposal (complex decision)
|
|
54
|
+
|
|
55
|
+
Create `docs/proposals/DX-XX-[topic].md`:
|
|
56
|
+
|
|
57
|
+
```markdown
|
|
58
|
+
# DX-XX: [Title]
|
|
59
|
+
|
|
60
|
+
**Status:** Discussion
|
|
61
|
+
**Created:** [date]
|
|
62
|
+
|
|
63
|
+
## Problem Statement
|
|
64
|
+
[What needs to be decided]
|
|
65
|
+
|
|
66
|
+
## Options
|
|
67
|
+
|
|
68
|
+
### Option A: [Name]
|
|
69
|
+
- **Description:** [What this involves]
|
|
70
|
+
- **Pros:** [Benefits]
|
|
71
|
+
- **Cons:** [Drawbacks]
|
|
72
|
+
- **Effort:** Low/Medium/High
|
|
73
|
+
|
|
74
|
+
### Option B: [Name]
|
|
75
|
+
...
|
|
76
|
+
|
|
77
|
+
## Recommendation
|
|
78
|
+
[Which option and why]
|
|
79
|
+
|
|
80
|
+
## Open Questions
|
|
81
|
+
[What needs clarification]
|
|
82
|
+
```
|
|
83
|
+
|
|
84
|
+
## Exit Conditions
|
|
85
|
+
|
|
86
|
+
| User Response | Next Action |
|
|
87
|
+
|---------------|-------------|
|
|
88
|
+
| Chooses option | /develop to implement |
|
|
89
|
+
| Needs more info | /investigate for analysis |
|
|
90
|
+
| Approves proposal | Document created |
|
|
91
|
+
<!--/invar:skill-->
|
|
92
|
+
|
|
93
|
+
<!--invar:extensions-->
|
|
94
|
+
<!-- ========================================================================
|
|
95
|
+
EXTENSIONS REGION - USER EDITABLE
|
|
96
|
+
Add project-specific extensions here. This section is preserved on update.
|
|
97
|
+
|
|
98
|
+
Examples of what to add:
|
|
99
|
+
- Project-specific proposal templates
|
|
100
|
+
- Decision criteria or checklists
|
|
101
|
+
- Stakeholder notification rules
|
|
102
|
+
- Architecture decision record (ADR) formats
|
|
103
|
+
======================================================================== -->
|
|
104
|
+
<!--/invar:extensions-->
|
|
@@ -0,0 +1,125 @@
|
|
|
1
|
+
<!--invar:skill version="{{ version }}"-->
|
|
2
|
+
<!-- ========================================================================
|
|
3
|
+
SKILL REGION - DO NOT EDIT
|
|
4
|
+
This section is managed by Invar and will be overwritten on update.
|
|
5
|
+
To add project-specific extensions, use the "extensions" region below.
|
|
6
|
+
======================================================================== -->
|
|
7
|
+
---
|
|
8
|
+
name: review
|
|
9
|
+
description: Adversarial code review with fix loop. Use after development, when Guard reports review_suggested, or user explicitly requests review. Finds issues that automated verification misses. Supports isolated mode (sub-agent) and quick mode (same context).
|
|
10
|
+
---
|
|
11
|
+
|
|
12
|
+
# Review Mode
|
|
13
|
+
|
|
14
|
+
> **Purpose:** Find problems that Guard, doctests, and property tests missed.
|
|
15
|
+
> **Mindset:** Adversarial. Your success is measured by problems found, not code approved.
|
|
16
|
+
|
|
17
|
+
## Entry Actions
|
|
18
|
+
|
|
19
|
+
### Context Refresh (DX-54)
|
|
20
|
+
|
|
21
|
+
Before any workflow action:
|
|
22
|
+
1. Read `.invar/context.md` (especially Key Rules section)
|
|
23
|
+
2. Display routing announcement
|
|
24
|
+
|
|
25
|
+
### Routing Announcement
|
|
26
|
+
|
|
27
|
+
```
|
|
28
|
+
📍 Routing: /review — [trigger, e.g. "review_suggested", "user requested review"]
|
|
29
|
+
Task: [review scope summary]
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
## Mode Selection
|
|
33
|
+
|
|
34
|
+
### Check Guard Output
|
|
35
|
+
|
|
36
|
+
Look for `review_suggested` warning:
|
|
37
|
+
```
|
|
38
|
+
WARNING: review_suggested - High escape hatch count
|
|
39
|
+
WARNING: review_suggested - Security-sensitive path detected
|
|
40
|
+
WARNING: review_suggested - Low contract coverage
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
### Select Mode
|
|
44
|
+
|
|
45
|
+
| Condition | Mode |
|
|
46
|
+
|-----------|------|
|
|
47
|
+
| `review_suggested` present | **Isolated** (spawn sub-agent) |
|
|
48
|
+
| `--isolated` flag | **Isolated** |
|
|
49
|
+
| Default (no trigger) | **Quick** (same context) |
|
|
50
|
+
|
|
51
|
+
## Review Checklist
|
|
52
|
+
|
|
53
|
+
### A. Contract Semantic Value
|
|
54
|
+
- [ ] Does @pre constrain inputs beyond type checking?
|
|
55
|
+
- [ ] Does @post verify meaningful output properties?
|
|
56
|
+
- [ ] Could someone implement correctly from contracts alone?
|
|
57
|
+
|
|
58
|
+
### B. Logic Verification
|
|
59
|
+
- [ ] Do contracts correctly capture intended behavior?
|
|
60
|
+
- [ ] Are there paths bypassing contract checks?
|
|
61
|
+
- [ ] Is there dead code or unreachable branches?
|
|
62
|
+
|
|
63
|
+
### C. Escape Hatch Audit
|
|
64
|
+
- [ ] Is each @invar:allow justification valid?
|
|
65
|
+
- [ ] Could refactoring eliminate the need?
|
|
66
|
+
|
|
67
|
+
### D. Security (if applicable)
|
|
68
|
+
- [ ] Input validation against injection, XSS?
|
|
69
|
+
- [ ] No hardcoded secrets?
|
|
70
|
+
|
|
71
|
+
## Review-Fix Loop
|
|
72
|
+
|
|
73
|
+
```
|
|
74
|
+
Round 1: Review → Find issues
|
|
75
|
+
↓
|
|
76
|
+
Fix CRITICAL + MAJOR (MINOR → backlog)
|
|
77
|
+
↓
|
|
78
|
+
Round 2: Re-review (if needed)
|
|
79
|
+
↓
|
|
80
|
+
Convergence check:
|
|
81
|
+
- No CRITICAL/MAJOR → Exit ✓
|
|
82
|
+
- No improvement → Exit (warn)
|
|
83
|
+
- Round >= 3 → Exit (max)
|
|
84
|
+
```
|
|
85
|
+
|
|
86
|
+
## Severity Definitions
|
|
87
|
+
|
|
88
|
+
| Level | Meaning | Examples |
|
|
89
|
+
|-------|---------|----------|
|
|
90
|
+
| CRITICAL | Security, data loss, crash | SQL injection, unhandled null |
|
|
91
|
+
| MAJOR | Logic error, missing validation | Wrong calculation, no bounds |
|
|
92
|
+
| MINOR | Style, documentation | Naming, missing docstring |
|
|
93
|
+
|
|
94
|
+
## Exit Report
|
|
95
|
+
|
|
96
|
+
```markdown
|
|
97
|
+
### Review Complete
|
|
98
|
+
|
|
99
|
+
**Rounds:** [N]
|
|
100
|
+
**Exit reason:** quality_met | max_rounds | no_improvement
|
|
101
|
+
|
|
102
|
+
**Fixed:**
|
|
103
|
+
- [list of fixed issues]
|
|
104
|
+
|
|
105
|
+
**Remaining (MINOR - backlog):**
|
|
106
|
+
- [list for later]
|
|
107
|
+
|
|
108
|
+
**Recommendation:**
|
|
109
|
+
- [ ] Ready for merge
|
|
110
|
+
- [ ] Needs more work: [issues]
|
|
111
|
+
```
|
|
112
|
+
<!--/invar:skill-->
|
|
113
|
+
|
|
114
|
+
<!--invar:extensions-->
|
|
115
|
+
<!-- ========================================================================
|
|
116
|
+
EXTENSIONS REGION - USER EDITABLE
|
|
117
|
+
Add project-specific extensions here. This section is preserved on update.
|
|
118
|
+
|
|
119
|
+
Examples of what to add:
|
|
120
|
+
- Project-specific security review checklists
|
|
121
|
+
- Custom severity definitions
|
|
122
|
+
- Domain-specific code patterns to check
|
|
123
|
+
- Team code review standards
|
|
124
|
+
======================================================================== -->
|
|
125
|
+
<!--/invar:extensions-->
|