invar-tools 1.7.1__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/template_helpers.py +32 -0
- 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 +133 -7
- 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 +77 -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 +213 -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 +256 -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 +82 -0
- invar/templates/manifest.toml +8 -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 +98 -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/investigate/SKILL.md.jinja +15 -0
- invar/templates/skills/propose/SKILL.md.jinja +33 -0
- invar/templates/skills/review/SKILL.md.jinja +346 -71
- {invar_tools-1.7.1.dist-info → invar_tools-1.10.0.dist-info}/METADATA +326 -19
- 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.7.1.dist-info/RECORD +0 -112
- /invar/templates/examples/{workflow.md → python/workflow.md} +0 -0
- {invar_tools-1.7.1.dist-info → invar_tools-1.10.0.dist-info}/WHEEL +0 -0
- {invar_tools-1.7.1.dist-info → invar_tools-1.10.0.dist-info}/entry_points.txt +0 -0
- {invar_tools-1.7.1.dist-info → invar_tools-1.10.0.dist-info}/licenses/LICENSE +0 -0
- {invar_tools-1.7.1.dist-info → invar_tools-1.10.0.dist-info}/licenses/LICENSE-GPL +0 -0
- {invar_tools-1.7.1.dist-info → invar_tools-1.10.0.dist-info}/licenses/NOTICE +0 -0
|
@@ -10,9 +10,49 @@ _invar:
|
|
|
10
10
|
# Development Mode
|
|
11
11
|
|
|
12
12
|
> **Purpose:** Implement solution following USBV workflow with verification.
|
|
13
|
+
> **Mindset:** CONTRACTS before code — no exceptions.
|
|
14
|
+
|
|
15
|
+
## Scope Boundaries
|
|
16
|
+
|
|
17
|
+
**This skill IS for:**
|
|
18
|
+
- Implementing features ("add", "create", "build")
|
|
19
|
+
- Fixing bugs ("fix", "resolve")
|
|
20
|
+
- Modifying existing code ("update", "change")
|
|
21
|
+
- Writing tests and contracts
|
|
22
|
+
|
|
23
|
+
**This skill is NOT for:**
|
|
24
|
+
- Exploring unclear requirements → switch to `/investigate`
|
|
25
|
+
- Choosing between approaches → switch to `/propose`
|
|
26
|
+
- Reviewing completed work → switch to `/review`
|
|
27
|
+
|
|
28
|
+
**Drift detection:** If requirements are unclear → STOP, exit to `/investigate` first.
|
|
13
29
|
|
|
14
30
|
## Entry Actions (REQUIRED)
|
|
15
31
|
|
|
32
|
+
### Session Restore (if continuing from summary)
|
|
33
|
+
|
|
34
|
+
When conversation begins with a previous session summary:
|
|
35
|
+
|
|
36
|
+
1. **ALWAYS display Check-In first** — even when continuing
|
|
37
|
+
2. **Determine current phase** from todo items:
|
|
38
|
+
| Todo keywords | Phase |
|
|
39
|
+
|---------------|-------|
|
|
40
|
+
| "research", "understand", "analyze" | UNDERSTAND |
|
|
41
|
+
| "contract", "design", "specify" | SPECIFY |
|
|
42
|
+
| "implement", "code", "build" | BUILD |
|
|
43
|
+
| "verify", "test", "guard" | VALIDATE |
|
|
44
|
+
3. **Display phase header** before resuming work
|
|
45
|
+
4. **Re-read context.md** for project state
|
|
46
|
+
|
|
47
|
+
```
|
|
48
|
+
# Example session restore:
|
|
49
|
+
✓ Check-In: Invar | Main | dirty
|
|
50
|
+
|
|
51
|
+
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
|
|
52
|
+
📍 /develop → BUILD (3/4) [resumed]
|
|
53
|
+
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
|
|
54
|
+
```
|
|
55
|
+
|
|
16
56
|
### Context Refresh (DX-54)
|
|
17
57
|
|
|
18
58
|
Before any workflow action:
|
|
@@ -56,10 +96,11 @@ If task appears simple (4+ signals: single file, clear target, additive change,
|
|
|
56
96
|
|
|
57
97
|
### 2. SPECIFY
|
|
58
98
|
|
|
59
|
-
- **Contracts FIRST:** Write
|
|
60
|
-
- **
|
|
99
|
+
- **Contracts FIRST:** Write contracts before implementation
|
|
100
|
+
- **Examples:** Add examples for expected behavior
|
|
61
101
|
- **Design:** Decompose complex tasks into sub-functions
|
|
62
102
|
|
|
103
|
+
{% if language == "python" %}
|
|
63
104
|
```python
|
|
64
105
|
# SPECIFY before BUILD:
|
|
65
106
|
@pre(lambda x: x > 0)
|
|
@@ -71,6 +112,25 @@ def calculate(x: int) -> int:
|
|
|
71
112
|
"""
|
|
72
113
|
... # Implementation comes in BUILD
|
|
73
114
|
```
|
|
115
|
+
{% elif language == "typescript" %}
|
|
116
|
+
```typescript
|
|
117
|
+
// SPECIFY before BUILD:
|
|
118
|
+
import { z } from 'zod';
|
|
119
|
+
|
|
120
|
+
const CalculateInput = z.number().positive();
|
|
121
|
+
const CalculateOutput = z.number().nonnegative();
|
|
122
|
+
|
|
123
|
+
/**
|
|
124
|
+
* @example
|
|
125
|
+
* calculate(10) // => 100
|
|
126
|
+
*/
|
|
127
|
+
function calculate(x: number): number {
|
|
128
|
+
const validated = CalculateInput.parse(x);
|
|
129
|
+
// Implementation comes in BUILD
|
|
130
|
+
return CalculateOutput.parse(result);
|
|
131
|
+
}
|
|
132
|
+
```
|
|
133
|
+
{% endif %}
|
|
74
134
|
|
|
75
135
|
#### Function-Level Gates (DX-63)
|
|
76
136
|
|
|
@@ -123,6 +183,25 @@ If any NO → Stop. Write contract first.
|
|
|
123
183
|
|
|
124
184
|
### 3. BUILD
|
|
125
185
|
|
|
186
|
+
#### New Function Gate (MANDATORY)
|
|
187
|
+
|
|
188
|
+
**Before writing ANY new Core function, STOP and verify:**
|
|
189
|
+
|
|
190
|
+
| Check | If NO → Action |
|
|
191
|
+
|-------|----------------|
|
|
192
|
+
| Contract shown in SPECIFY phase? | ⛔ STOP. Return to SPECIFY. |
|
|
193
|
+
| Doctest written? | ⛔ STOP. Write doctest first. |
|
|
194
|
+
|
|
195
|
+
```
|
|
196
|
+
⛔ GATE VIOLATION: Writing new function without prior contract.
|
|
197
|
+
→ Return to SPECIFY phase. Show contract first.
|
|
198
|
+
```
|
|
199
|
+
|
|
200
|
+
**Exempt from gate:**
|
|
201
|
+
- Shell functions (no @pre/@post required)
|
|
202
|
+
- Editing existing functions (contract already exists)
|
|
203
|
+
- Non-Python files
|
|
204
|
+
|
|
126
205
|
**For complex tasks:** Enter Plan Mode first, get user approval.
|
|
127
206
|
|
|
128
207
|
**Implementation rules:**
|
|
@@ -181,6 +260,7 @@ For multiple tasks:
|
|
|
181
260
|
|
|
182
261
|
Quick reference for resolving common Guard errors:
|
|
183
262
|
|
|
263
|
+
{% if language == "python" %}
|
|
184
264
|
| Error | Cause | Quick Fix |
|
|
185
265
|
|-------|-------|-----------|
|
|
186
266
|
| `forbidden_import: io` | I/O library in Core | Use `iter(s.splitlines())` not `io.StringIO` |
|
|
@@ -199,6 +279,18 @@ Check the "Suggested:" line in Guard output.
|
|
|
199
279
|
|
|
200
280
|
**Note:** Use `from deal import pre, post` for lambda-based contracts.
|
|
201
281
|
`invar_runtime.pre/post` are for Contract objects like `NonEmpty`.
|
|
282
|
+
{% elif language == "typescript" %}
|
|
283
|
+
| Error | Cause | Quick Fix |
|
|
284
|
+
|-------|-------|-----------|
|
|
285
|
+
| `forbidden_import: fs` | fs module in Core | Accept path as parameter instead |
|
|
286
|
+
| `forbidden_import: path` | path module in Core | Accept string path as parameter |
|
|
287
|
+
| `missing_contract` | Core function without contract comments | Add @pre/@post comments |
|
|
288
|
+
| `empty_contract` | Contract with no condition | Add meaningful condition |
|
|
289
|
+
| `file_size` | File > 500 lines | Extract functions to new module |
|
|
290
|
+
| `shell_result` | Shell function missing Result | Return `Result<T, E>` type |
|
|
291
|
+
|
|
292
|
+
**Tip:** For `missing_contract`, Guard automatically suggests contracts based on parameter types.
|
|
293
|
+
{% endif %}
|
|
202
294
|
|
|
203
295
|
## Timeout Handling
|
|
204
296
|
|
|
@@ -333,8 +425,11 @@ Agent:
|
|
|
333
425
|
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
|
|
334
426
|
📍 /develop → SPECIFY (2/4)
|
|
335
427
|
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
|
|
336
|
-
|
|
428
|
+
{% if language == "python" %}
|
|
337
429
|
@pre(lambda source, path: len(source.strip()) > 0)
|
|
430
|
+
{% elif language == "typescript" %}
|
|
431
|
+
const SourceInput = z.string().refine(s => s.trim().length > 0);
|
|
432
|
+
{% endif %}
|
|
338
433
|
|
|
339
434
|
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
|
|
340
435
|
📍 /develop → BUILD (3/4)
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
# Invar Extension Skills Registry
|
|
2
|
+
# This file defines available extension skills for `invar skill` commands
|
|
3
|
+
|
|
4
|
+
version: "1.0"
|
|
5
|
+
|
|
6
|
+
extensions:
|
|
7
|
+
invar-onboard:
|
|
8
|
+
name: "invar-onboard"
|
|
9
|
+
description: "Legacy project migration to Invar framework"
|
|
10
|
+
tier: T1
|
|
11
|
+
triggers:
|
|
12
|
+
- "onboard"
|
|
13
|
+
- "migrate to invar"
|
|
14
|
+
- "can this project use invar"
|
|
15
|
+
- "invar assessment"
|
|
16
|
+
isolation: false
|
|
17
|
+
files:
|
|
18
|
+
- "SKILL.md"
|
|
19
|
+
- "patterns"
|
|
20
|
+
- "templates"
|
|
21
|
+
|
|
22
|
+
acceptance:
|
|
23
|
+
name: "acceptance"
|
|
24
|
+
description: "Requirements acceptance review (PRD alignment)"
|
|
25
|
+
tier: T0
|
|
26
|
+
triggers:
|
|
27
|
+
- "acceptance"
|
|
28
|
+
- "check requirements"
|
|
29
|
+
- "PRD alignment"
|
|
30
|
+
- "acceptance review"
|
|
31
|
+
- "verify requirements"
|
|
32
|
+
isolation: true # Uses context isolation by default
|
|
33
|
+
files:
|
|
34
|
+
- "SKILL.md"
|
|
35
|
+
|
|
36
|
+
security:
|
|
37
|
+
name: "security"
|
|
38
|
+
description: "Security audit (OWASP Top 10)"
|
|
39
|
+
tier: T0
|
|
40
|
+
triggers:
|
|
41
|
+
- "security"
|
|
42
|
+
- "audit"
|
|
43
|
+
- "vulnerabilities"
|
|
44
|
+
- "OWASP"
|
|
45
|
+
isolation: true # Uses context isolation by default
|
|
46
|
+
files:
|
|
47
|
+
- "SKILL.md"
|
|
48
|
+
- "patterns/_common.yaml"
|
|
49
|
+
- "patterns/python.yaml"
|
|
50
|
+
- "patterns/typescript.yaml"
|
|
51
|
+
|
|
52
|
+
refactor:
|
|
53
|
+
name: "refactor"
|
|
54
|
+
description: "Refactoring strategy and execution"
|
|
55
|
+
tier: T1
|
|
56
|
+
status: pending_discussion
|
|
57
|
+
triggers:
|
|
58
|
+
- "refactor"
|
|
59
|
+
- "clean up"
|
|
60
|
+
- "simplify"
|
|
61
|
+
- "restructure"
|
|
62
|
+
isolation: false
|
|
63
|
+
files:
|
|
64
|
+
- "SKILL.md"
|
|
65
|
+
|
|
66
|
+
debug:
|
|
67
|
+
name: "debug"
|
|
68
|
+
description: "Root cause analysis"
|
|
69
|
+
tier: T1
|
|
70
|
+
status: pending_discussion
|
|
71
|
+
triggers:
|
|
72
|
+
- "debug"
|
|
73
|
+
- "why does"
|
|
74
|
+
- "root cause"
|
|
75
|
+
- "error"
|
|
76
|
+
- "bug"
|
|
77
|
+
isolation: false
|
|
78
|
+
files:
|
|
79
|
+
- "SKILL.md"
|
|
80
|
+
|
|
81
|
+
test-strategy:
|
|
82
|
+
name: "test-strategy"
|
|
83
|
+
description: "Test strategy design"
|
|
84
|
+
tier: T1
|
|
85
|
+
status: pending_discussion
|
|
86
|
+
triggers:
|
|
87
|
+
- "test strategy"
|
|
88
|
+
- "how to test"
|
|
89
|
+
- "what to test"
|
|
90
|
+
- "testing plan"
|
|
91
|
+
isolation: false
|
|
92
|
+
files:
|
|
93
|
+
- "SKILL.md"
|
|
@@ -0,0 +1,383 @@
|
|
|
1
|
+
<!--invar:skill-->
|
|
2
|
+
# /acceptance — Requirements Acceptance Review
|
|
3
|
+
|
|
4
|
+
> Extension Skill | Tier: T0 | Isolation: Default
|
|
5
|
+
|
|
6
|
+
## Purpose
|
|
7
|
+
|
|
8
|
+
Verify implementation satisfies requirements with adversarial rigor. This skill performs PRD alignment review, checking that all requirements are implemented and edge cases are handled.
|
|
9
|
+
|
|
10
|
+
## Triggers
|
|
11
|
+
|
|
12
|
+
Use this skill when user says: "acceptance", "check requirements", "PRD alignment", "acceptance review", "verify requirements"
|
|
13
|
+
|
|
14
|
+
## Relationship to Core Skills
|
|
15
|
+
|
|
16
|
+
- `/review` = Code quality (bugs, contracts, security)
|
|
17
|
+
- `/acceptance` = Feature completeness (requirements coverage)
|
|
18
|
+
|
|
19
|
+
---
|
|
20
|
+
|
|
21
|
+
## Core Principles
|
|
22
|
+
|
|
23
|
+
| Principle | Description |
|
|
24
|
+
|-----------|-------------|
|
|
25
|
+
| **Skeptical by default** | Assume feature is NOT implemented until proven otherwise |
|
|
26
|
+
| **Evidence required** | "Implemented" requires file:line proof, not intuition |
|
|
27
|
+
| **Deep challenge** | Every requirement gets adversarial scenarios, no shortcuts |
|
|
28
|
+
| **Graceful degradation** | Works without Invar contracts (falls back to code analysis) |
|
|
29
|
+
| **Polluter pays** | External verification must restore state, or use dry-run |
|
|
30
|
+
|
|
31
|
+
---
|
|
32
|
+
|
|
33
|
+
## Depth Levels
|
|
34
|
+
|
|
35
|
+
| Level | Scope | Use Case |
|
|
36
|
+
|-------|-------|----------|
|
|
37
|
+
| `--quick` | P0 (Must-have) only, skip NFR/UI | Fast feedback, CI gates |
|
|
38
|
+
| `--standard` | P0 + P1, sample challenges | Normal development |
|
|
39
|
+
| `--deep` (default) | ALL requirements, full challenge, external verify | Release readiness |
|
|
40
|
+
|
|
41
|
+
**Default is `--deep`** — thorough verification is the norm.
|
|
42
|
+
|
|
43
|
+
---
|
|
44
|
+
|
|
45
|
+
## Workflow
|
|
46
|
+
|
|
47
|
+
### Step 0: Isolation Check
|
|
48
|
+
|
|
49
|
+
```
|
|
50
|
+
Parse depth: --quick / --standard / --deep (default)
|
|
51
|
+
|
|
52
|
+
If --deep (default):
|
|
53
|
+
┌─────────────────────────────────────────────────────────┐
|
|
54
|
+
│ SPAWN ISOLATED AGENT │
|
|
55
|
+
│ │
|
|
56
|
+
│ Collect inputs: │
|
|
57
|
+
│ • PRD path (smart search or user-provided) │
|
|
58
|
+
│ • Design paths (if found) │
|
|
59
|
+
│ • Code scope (files/directories to review) │
|
|
60
|
+
│ │
|
|
61
|
+
│ Spawn Task agent with: │
|
|
62
|
+
│ • QA Acceptance Reviewer persona (see below) │
|
|
63
|
+
│ • NO conversation history │
|
|
64
|
+
│ • Only the collected inputs │
|
|
65
|
+
│ │
|
|
66
|
+
│ → Isolated agent executes steps 1-5 below │
|
|
67
|
+
│ → Returns structured report │
|
|
68
|
+
└─────────────────────────────────────────────────────────┘
|
|
69
|
+
|
|
70
|
+
If --quick or --standard:
|
|
71
|
+
└─ Continue in same context with persona switch
|
|
72
|
+
```
|
|
73
|
+
|
|
74
|
+
### Step 1: Entry
|
|
75
|
+
|
|
76
|
+
- Detect Invar (Enhanced/Standalone mode)
|
|
77
|
+
- Locate PRD: smart search or user-provided path
|
|
78
|
+
- Locate Design: design/, mockups/, figma/ (if exists)
|
|
79
|
+
|
|
80
|
+
**Invar Detection:**
|
|
81
|
+
- File-based: `INVAR.md` exists OR `.invar/` directory exists
|
|
82
|
+
- Context-based: `invar_guard` tool available in session
|
|
83
|
+
- Enhanced Mode → Use invar_guard, invar_sig, invar_map
|
|
84
|
+
- Standalone Mode → Use Read, Grep, Glob, Bash only
|
|
85
|
+
|
|
86
|
+
### Step 2: Parse — Extract Requirements
|
|
87
|
+
|
|
88
|
+
Read PRD and extract:
|
|
89
|
+
- **FR (Functional):** What system must DO
|
|
90
|
+
- **NFR (Non-Functional):** Performance, security, UX
|
|
91
|
+
- **EC (Edge Case):** Explicitly mentioned scenarios
|
|
92
|
+
- **UI (UI/UX):** Visual/interaction requirements (if any)
|
|
93
|
+
|
|
94
|
+
**Output format:**
|
|
95
|
+
```markdown
|
|
96
|
+
| ID | Type | Requirement | Priority |
|
|
97
|
+
|-------|------|--------------------------|----------|
|
|
98
|
+
| FR-1 | FR | User can login with email| Must |
|
|
99
|
+
| NFR-1 | NFR | Response time < 200ms | Should |
|
|
100
|
+
| UI-1 | UI | Login button is blue #007| Could |
|
|
101
|
+
```
|
|
102
|
+
|
|
103
|
+
### Step 3: Map — Link to Implementation (Skeptical)
|
|
104
|
+
|
|
105
|
+
**DEFAULT STATUS: ❌ Missing** (upgrade only with evidence)
|
|
106
|
+
|
|
107
|
+
**Evidence Sources (priority order):**
|
|
108
|
+
1. Invar contracts (@pre/@post matching requirement)
|
|
109
|
+
2. Type signatures + docstrings
|
|
110
|
+
3. Test cases covering the requirement
|
|
111
|
+
4. Code implementation (read and verify)
|
|
112
|
+
|
|
113
|
+
**Enhanced Mode:**
|
|
114
|
+
- `invar_sig` to find functions + contracts
|
|
115
|
+
- Cross-reference contracts with requirements
|
|
116
|
+
|
|
117
|
+
**Standalone Mode (no contracts):**
|
|
118
|
+
- Grep for requirement keywords
|
|
119
|
+
- Read docstrings, type hints, comments
|
|
120
|
+
- Trace code flow to verify implementation
|
|
121
|
+
|
|
122
|
+
**Output format:**
|
|
123
|
+
```markdown
|
|
124
|
+
| ID | Requirement | Evidence | Status |
|
|
125
|
+
|------|--------------|--------------------| ------------|
|
|
126
|
+
| FR-1 | User login | auth.py:45 @post | ✅ Complete |
|
|
127
|
+
| FR-2 | Password reset| - | ❌ Missing |
|
|
128
|
+
| FR-3 | Email verify | email.py:30 (partial)| ⚠️ Partial|
|
|
129
|
+
```
|
|
130
|
+
|
|
131
|
+
### Step 4: Challenge — Deep Adversarial Scenarios
|
|
132
|
+
|
|
133
|
+
For **EVERY** requirement (no shortcuts):
|
|
134
|
+
|
|
135
|
+
**Functional (FR):**
|
|
136
|
+
- "What if input is empty/null/malformed?"
|
|
137
|
+
- "What if user lacks permission?"
|
|
138
|
+
- "What if dependent service fails?"
|
|
139
|
+
- "What if called twice/concurrently?"
|
|
140
|
+
|
|
141
|
+
**Non-Functional (NFR):**
|
|
142
|
+
- "Is there evidence this is measured?"
|
|
143
|
+
- "What's the worst-case scenario?"
|
|
144
|
+
- "How does it degrade under load?"
|
|
145
|
+
|
|
146
|
+
**Edge Cases (EC):**
|
|
147
|
+
- "Is boundary explicitly handled?"
|
|
148
|
+
- "What's the error message?"
|
|
149
|
+
- "Is it tested?"
|
|
150
|
+
|
|
151
|
+
**UI/UX (UI):**
|
|
152
|
+
- "Does implementation match design spec?"
|
|
153
|
+
- "Are design tokens correct (colors, spacing)?"
|
|
154
|
+
- "Is interaction behavior as specified?"
|
|
155
|
+
|
|
156
|
+
**Output format:**
|
|
157
|
+
```markdown
|
|
158
|
+
| Scenario | Expected | Actual | Gap? |
|
|
159
|
+
|-----------------------|--------------|---------|------|
|
|
160
|
+
| Wrong password 5x | Lock account | No lock | ❌ |
|
|
161
|
+
| Empty email | Error msg | Crash | ❌ |
|
|
162
|
+
| Concurrent login | Queue/reject | Race bug| ❌ |
|
|
163
|
+
```
|
|
164
|
+
|
|
165
|
+
### Step 5: Verify — External Tool Validation
|
|
166
|
+
|
|
167
|
+
**POLLUTER PAYS PRINCIPLE:**
|
|
168
|
+
```
|
|
169
|
+
Before running external verification:
|
|
170
|
+
1. Can state be restored? (snapshot, rollback, reset)
|
|
171
|
+
→ YES: Run freely, restore after
|
|
172
|
+
→ NO: Must use dry-run / read-only mode
|
|
173
|
+
|
|
174
|
+
Examples:
|
|
175
|
+
• DB: Use transaction + rollback, or test DB
|
|
176
|
+
• Files: Backup → run → restore
|
|
177
|
+
• API: Use sandbox/test endpoint
|
|
178
|
+
• Destructive: MUST dry-run (--dry-run, --whatif)
|
|
179
|
+
```
|
|
180
|
+
|
|
181
|
+
**Web Projects:**
|
|
182
|
+
- Playwright/Puppeteer for E2E flows
|
|
183
|
+
- curl/httpie for API endpoints
|
|
184
|
+
- Lighthouse for performance NFRs
|
|
185
|
+
|
|
186
|
+
**CLI Projects:**
|
|
187
|
+
- Actually invoke commands with test inputs
|
|
188
|
+
- Verify exit codes and output format
|
|
189
|
+
|
|
190
|
+
**Library Projects:**
|
|
191
|
+
- Run existing test suite
|
|
192
|
+
- Execute doctest examples
|
|
193
|
+
|
|
194
|
+
**NFR Benchmarks:**
|
|
195
|
+
```bash
|
|
196
|
+
# Response Time
|
|
197
|
+
time curl -s http://localhost:8000/api/endpoint
|
|
198
|
+
hyperfine 'curl -s http://localhost:8000/api/endpoint'
|
|
199
|
+
|
|
200
|
+
# Load Testing
|
|
201
|
+
wrk -t4 -c100 -d30s http://localhost:8000/api/endpoint
|
|
202
|
+
|
|
203
|
+
# Memory
|
|
204
|
+
/usr/bin/time -v python script.py
|
|
205
|
+
```
|
|
206
|
+
|
|
207
|
+
**UI/UX Deep Verification (4 levels):**
|
|
208
|
+
1. **Level 1: Design Tokens** — Colors, Typography, Spacing
|
|
209
|
+
2. **Level 2: Layout** — Flexbox/Grid alignment, Responsive breakpoints
|
|
210
|
+
3. **Level 3: Interaction** — Hover/focus states, Animation, Keyboard nav
|
|
211
|
+
4. **Level 4: Visual Regression** — Screenshot comparison (if baseline exists)
|
|
212
|
+
|
|
213
|
+
### Step 6: Report — Coverage Matrix + Integration
|
|
214
|
+
|
|
215
|
+
```markdown
|
|
216
|
+
## Validation Report
|
|
217
|
+
|
|
218
|
+
**PRD:** docs/requirements.md
|
|
219
|
+
**Design:** design/mockups/ (if found)
|
|
220
|
+
**Mode:** Enhanced (Invar detected) / Standalone
|
|
221
|
+
|
|
222
|
+
### Coverage Summary
|
|
223
|
+
| Status | Count | Percent |
|
|
224
|
+
|-------------|-------|---------|
|
|
225
|
+
| ✅ Complete | 7 | 58% |
|
|
226
|
+
| ⚠️ Partial | 3 | 25% |
|
|
227
|
+
| ❌ Missing | 2 | 17% |
|
|
228
|
+
|
|
229
|
+
### Critical Gaps
|
|
230
|
+
1. FR-2: Password reset — Not implemented
|
|
231
|
+
2. NFR-1: Response time — Not measured
|
|
232
|
+
|
|
233
|
+
### Adversarial Findings
|
|
234
|
+
| Finding | Severity | Location |
|
|
235
|
+
|----------------------------|----------|---------------|
|
|
236
|
+
| Account lockout missing | High | auth.py |
|
|
237
|
+
| Input validation incomplete| Medium | forms.py:23 |
|
|
238
|
+
|
|
239
|
+
### UI/UX Discrepancies (if applicable)
|
|
240
|
+
| Element | Design | Actual | Action |
|
|
241
|
+
|--------------|-----------|-----------|--------------|
|
|
242
|
+
| Login button | #0070f3 | #007bff | Update color |
|
|
243
|
+
|
|
244
|
+
### NFR Verification Results
|
|
245
|
+
| Requirement | Target | Measured | Status |
|
|
246
|
+
|-------------------|----------|----------|-----------|
|
|
247
|
+
| Response time | < 200ms | 145ms | ✅ Pass |
|
|
248
|
+
| Memory usage | < 100MB | 89MB | ✅ Pass |
|
|
249
|
+
|
|
250
|
+
### Suggested /develop Tasks
|
|
251
|
+
|
|
252
|
+
**High Priority (Must-have gaps):**
|
|
253
|
+
1. FR-2: Password reset
|
|
254
|
+
- Scope: auth/ module
|
|
255
|
+
- Estimate: ~80 LOC, 2 new functions
|
|
256
|
+
|
|
257
|
+
2. Account lockout (adversarial finding)
|
|
258
|
+
- Scope: auth/session.py
|
|
259
|
+
- Estimate: ~30 LOC
|
|
260
|
+
|
|
261
|
+
### Next Actions
|
|
262
|
+
1. [ ] Implement FR-2 (use /develop)
|
|
263
|
+
2. [ ] Add account lockout (use /develop)
|
|
264
|
+
3. [ ] Run load test for NFR verification
|
|
265
|
+
```
|
|
266
|
+
|
|
267
|
+
---
|
|
268
|
+
|
|
269
|
+
## PRD Smart Search
|
|
270
|
+
|
|
271
|
+
When user says "PRD" without path:
|
|
272
|
+
|
|
273
|
+
```
|
|
274
|
+
Search order:
|
|
275
|
+
1. docs/prd.md, docs/PRD.md, docs/requirements.md
|
|
276
|
+
2. *.prd.md, *requirements*.md, *spec*.md
|
|
277
|
+
3. README.md (Requirements section)
|
|
278
|
+
4. .invar/prd.md
|
|
279
|
+
|
|
280
|
+
If multiple → ask user to select
|
|
281
|
+
If none → ask user for path
|
|
282
|
+
```
|
|
283
|
+
|
|
284
|
+
---
|
|
285
|
+
|
|
286
|
+
## Design File Detection
|
|
287
|
+
|
|
288
|
+
```
|
|
289
|
+
Search order:
|
|
290
|
+
1. design/, mockups/, figma/
|
|
291
|
+
2. *.fig, *.sketch (metadata only)
|
|
292
|
+
3. docs/design/, docs/ui/
|
|
293
|
+
4. .invar/design/
|
|
294
|
+
|
|
295
|
+
If found → enable UI/UX verification
|
|
296
|
+
If not → skip UI checks, note in report
|
|
297
|
+
```
|
|
298
|
+
|
|
299
|
+
---
|
|
300
|
+
|
|
301
|
+
## Contract Fallback Strategy
|
|
302
|
+
|
|
303
|
+
When Invar contracts are not available:
|
|
304
|
+
|
|
305
|
+
| Fallback Level | Evidence Source | Confidence |
|
|
306
|
+
|----------------|-----------------|------------|
|
|
307
|
+
| 1. Type hints | `def login(email: str) -> User` | Medium |
|
|
308
|
+
| 2. Docstrings | `"""Returns user if valid credentials."""` | Medium |
|
|
309
|
+
| 3. Test cases | `test_login_success()` exists | High |
|
|
310
|
+
| 4. Code trace | Read implementation, verify logic | Low |
|
|
311
|
+
|
|
312
|
+
**Important:** Without contracts, increase skepticism. Code that "looks implemented" may have subtle bugs.
|
|
313
|
+
|
|
314
|
+
---
|
|
315
|
+
|
|
316
|
+
## QA Acceptance Reviewer Persona
|
|
317
|
+
|
|
318
|
+
Used in `--deep` mode (isolated agent):
|
|
319
|
+
|
|
320
|
+
```
|
|
321
|
+
You are an independent QA Acceptance Reviewer.
|
|
322
|
+
|
|
323
|
+
CRITICAL RULES:
|
|
324
|
+
1. You have NEVER seen this code before
|
|
325
|
+
2. You do NOT know what the developer intended
|
|
326
|
+
3. Assume NOTHING works until you verify evidence
|
|
327
|
+
4. Your job is to FIND GAPS, not confirm success
|
|
328
|
+
5. Be adversarial — challenge every claim
|
|
329
|
+
|
|
330
|
+
INPUT YOU WILL RECEIVE:
|
|
331
|
+
- PRD/Requirements document
|
|
332
|
+
- Code files to review
|
|
333
|
+
- Design specs (optional)
|
|
334
|
+
|
|
335
|
+
INPUT YOU WILL NOT RECEIVE:
|
|
336
|
+
- Development conversation history
|
|
337
|
+
- Developer's explanations
|
|
338
|
+
- Prior context about design decisions
|
|
339
|
+
|
|
340
|
+
OUTPUT: Structured Validation Report (see Step 6)
|
|
341
|
+
```
|
|
342
|
+
|
|
343
|
+
---
|
|
344
|
+
|
|
345
|
+
## CLI Override
|
|
346
|
+
|
|
347
|
+
Override isolation level per-invocation:
|
|
348
|
+
|
|
349
|
+
```
|
|
350
|
+
/acceptance → Uses --deep (default, spawns isolated agent)
|
|
351
|
+
/acceptance --quick → Same context, persona hint only
|
|
352
|
+
/acceptance --standard → Same context, persona switch
|
|
353
|
+
/acceptance --deep → Spawns isolated agent (explicit)
|
|
354
|
+
```
|
|
355
|
+
|
|
356
|
+
**No external configuration required.** Defaults are in this SKILL.md.
|
|
357
|
+
|
|
358
|
+
---
|
|
359
|
+
|
|
360
|
+
## Installation
|
|
361
|
+
|
|
362
|
+
```bash
|
|
363
|
+
# Via CLI
|
|
364
|
+
invar skill add acceptance
|
|
365
|
+
|
|
366
|
+
# Manual copy
|
|
367
|
+
cp -r /path/to/extensions/acceptance .claude/skills/
|
|
368
|
+
```
|
|
369
|
+
|
|
370
|
+
---
|
|
371
|
+
|
|
372
|
+
*Extension Skill v1.0 — LX-07*
|
|
373
|
+
<!--/invar:skill--><!--invar:extensions-->
|
|
374
|
+
<!-- ========================================================================
|
|
375
|
+
EXTENSIONS REGION - USER EDITABLE
|
|
376
|
+
Add project-specific extensions here. This section is preserved on update.
|
|
377
|
+
|
|
378
|
+
Examples of what to add:
|
|
379
|
+
- Custom acceptance criteria templates
|
|
380
|
+
- Project-specific requirement categories
|
|
381
|
+
- Domain-specific validation rules
|
|
382
|
+
======================================================================== -->
|
|
383
|
+
<!--/invar:extensions-->
|