spec-test 0.3.0__tar.gz → 0.3.2__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (55) hide show
  1. {spec_test-0.3.0 → spec_test-0.3.2}/PKG-INFO +1 -1
  2. spec_test-0.3.2/design/issues/001-example.md +26 -0
  3. spec_test-0.3.2/design/specs/example.md +14 -0
  4. {spec_test-0.3.0 → spec_test-0.3.2}/pyproject.toml +1 -1
  5. {spec_test-0.3.0 → spec_test-0.3.2}/src/spec_test/__init__.py +1 -1
  6. {spec_test-0.3.0 → spec_test-0.3.2}/src/spec_test/cli.py +52 -14
  7. spec_test-0.3.2/src/spec_test/skills/README.md +177 -0
  8. spec_test-0.3.2/src/spec_test/skills/spec-feature/SKILL.md +212 -0
  9. spec_test-0.3.2/src/spec_test/skills/spec-implement/SKILL.md +549 -0
  10. spec_test-0.3.2/src/spec_test/skills/spec-issue/SKILL.md +219 -0
  11. spec_test-0.3.2/src/spec_test/skills/spec-review/SKILL.md +277 -0
  12. spec_test-0.3.2/src/spec_test/skills/spec-verify/SKILL.md +259 -0
  13. spec_test-0.3.2/src/spec_test/skills/spec-workflow/SKILL.md +300 -0
  14. {spec_test-0.3.0 → spec_test-0.3.2/.claude}/skills/README.md +0 -0
  15. {spec_test-0.3.0 → spec_test-0.3.2/.claude}/skills/spec-feature.md +0 -0
  16. {spec_test-0.3.0 → spec_test-0.3.2/.claude}/skills/spec-implement.md +0 -0
  17. {spec_test-0.3.0 → spec_test-0.3.2/.claude}/skills/spec-issue.md +0 -0
  18. {spec_test-0.3.0 → spec_test-0.3.2/.claude}/skills/spec-review.md +0 -0
  19. {spec_test-0.3.0 → spec_test-0.3.2/.claude}/skills/spec-verify.md +0 -0
  20. {spec_test-0.3.0 → spec_test-0.3.2/.claude}/skills/spec-workflow.md +0 -0
  21. {spec_test-0.3.0 → spec_test-0.3.2}/.github/workflows/publish.yml +0 -0
  22. {spec_test-0.3.0 → spec_test-0.3.2}/.gitignore +0 -0
  23. {spec_test-0.3.0 → spec_test-0.3.2}/CLAUDE.md +0 -0
  24. {spec_test-0.3.0 → spec_test-0.3.2}/README.md +0 -0
  25. {spec_test-0.3.0 → spec_test-0.3.2}/design/issues/001-core-spec-test.md +0 -0
  26. {spec_test-0.3.0 → spec_test-0.3.2}/design/issues/002-runtime-contracts.md +0 -0
  27. {spec_test-0.3.0 → spec_test-0.3.2}/design/issues/003-hypothesis-integration.md +0 -0
  28. {spec_test-0.3.0 → spec_test-0.3.2}/design/issues/004-z3-formal-proofs.md +0 -0
  29. {spec_test-0.3.0 → spec_test-0.3.2}/design/issues/005-spec-issue-verification.md +0 -0
  30. {spec_test-0.3.0 → spec_test-0.3.2}/design/prompts/migrate-v1-to-v2.md +0 -0
  31. {spec_test-0.3.0 → spec_test-0.3.2}/design/specs/contracts.md +0 -0
  32. {spec_test-0.3.0 → spec_test-0.3.2}/design/specs/hypothesis-integration.md +0 -0
  33. {spec_test-0.3.0 → spec_test-0.3.2}/design/specs/spec-spec-test.md +0 -0
  34. {spec_test-0.3.0 → spec_test-0.3.2}/design/specs/z3-proofs.md +0 -0
  35. {spec_test-0.3.0 → spec_test-0.3.2}/prompt.md +0 -0
  36. {spec_test-0.3.0 → spec_test-0.3.2}/src/spec_test/collector.py +0 -0
  37. {spec_test-0.3.0 → spec_test-0.3.2}/src/spec_test/contracts.py +0 -0
  38. {spec_test-0.3.0 → spec_test-0.3.2}/src/spec_test/decorators.py +0 -0
  39. {spec_test-0.3.0 → spec_test-0.3.2}/src/spec_test/prover.py +0 -0
  40. {spec_test-0.3.0 → spec_test-0.3.2}/src/spec_test/pytest_plugin.py +0 -0
  41. {spec_test-0.3.0 → spec_test-0.3.2}/src/spec_test/reporter.py +0 -0
  42. {spec_test-0.3.0 → spec_test-0.3.2}/src/spec_test/runner.py +0 -0
  43. {spec_test-0.3.0 → spec_test-0.3.2}/src/spec_test/types.py +0 -0
  44. {spec_test-0.3.0 → spec_test-0.3.2}/src/spec_test/verifier.py +0 -0
  45. {spec_test-0.3.0 → spec_test-0.3.2}/tests/__init__.py +0 -0
  46. {spec_test-0.3.0 → spec_test-0.3.2}/tests/conftest.py +0 -0
  47. {spec_test-0.3.0 → spec_test-0.3.2}/tests/test_cli.py +0 -0
  48. {spec_test-0.3.0 → spec_test-0.3.2}/tests/test_collector.py +0 -0
  49. {spec_test-0.3.0 → spec_test-0.3.2}/tests/test_contracts.py +0 -0
  50. {spec_test-0.3.0 → spec_test-0.3.2}/tests/test_decorators.py +0 -0
  51. {spec_test-0.3.0 → spec_test-0.3.2}/tests/test_prover.py +0 -0
  52. {spec_test-0.3.0 → spec_test-0.3.2}/tests/test_reporter.py +0 -0
  53. {spec_test-0.3.0 → spec_test-0.3.2}/tests/test_runner.py +0 -0
  54. {spec_test-0.3.0 → spec_test-0.3.2}/tests/test_verifier.py +0 -0
  55. {spec_test-0.3.0 → spec_test-0.3.2}/uv.lock +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: spec-test
3
- Version: 0.3.0
3
+ Version: 0.3.2
4
4
  Summary: Make AI-generated code trustworthy through mathematical verification
5
5
  Author: Pulse Team
6
6
  License: MIT
@@ -0,0 +1,26 @@
1
+ # ISSUE-001: Example Feature
2
+
3
+ ## Summary
4
+ Brief description of what this feature/change is about.
5
+
6
+ ## Motivation
7
+ Why are we doing this? What problem does it solve?
8
+
9
+ ## Detailed Description
10
+ Full details of the intended behavior, edge cases, and considerations.
11
+
12
+ ## Pros
13
+ - List benefits
14
+
15
+ ## Cons
16
+ - List drawbacks or trade-offs
17
+
18
+ ## Related Specs
19
+ - [EXAMPLE-001](../specs/example.md)
20
+ - [EXAMPLE-002](../specs/example.md)
21
+
22
+ ## Status
23
+ - [ ] Issue written
24
+ - [ ] Specs defined
25
+ - [ ] Implementation complete
26
+ - [ ] Tests passing
@@ -0,0 +1,14 @@
1
+ # Example Specification
2
+
3
+ ## Overview
4
+ This is an example specification file. Replace with your actual specs.
5
+
6
+ ## Related Issue
7
+ - [ISSUE-001](../issues/001-example.md)
8
+
9
+ ## Requirements
10
+
11
+ ### Core Features
12
+ - **EXAMPLE-001**: The system should do something useful
13
+ - **EXAMPLE-002**: The system should handle errors gracefully
14
+ - **EXAMPLE-003** [manual]: Code follows project naming conventions
@@ -1,6 +1,6 @@
1
1
  [project]
2
2
  name = "spec-test"
3
- version = "0.3.0"
3
+ version = "0.3.2"
4
4
  description = "Make AI-generated code trustworthy through mathematical verification"
5
5
  authors = [{ name = "Pulse Team" }]
6
6
  readme = "README.md"
@@ -31,7 +31,7 @@ from .types import (
31
31
  )
32
32
  from .verifier import SpecVerifier
33
33
 
34
- __version__ = "0.3.0"
34
+ __version__ = "0.3.2"
35
35
 
36
36
  __all__ = [
37
37
  # Decorators
@@ -1,5 +1,6 @@
1
1
  """Command-line interface for spec-test."""
2
2
 
3
+ import shutil
3
4
  import subprocess
4
5
  import sys
5
6
  from importlib import resources
@@ -10,6 +11,7 @@ import typer
10
11
  from rich.console import Console
11
12
  from rich.panel import Panel
12
13
 
14
+ from . import __version__
13
15
  from .collector import collect_specs
14
16
  from .prover import (
15
17
  ProofResult,
@@ -26,6 +28,27 @@ app = typer.Typer(
26
28
  console = Console()
27
29
 
28
30
 
31
+ def version_callback(value: bool):
32
+ """Display version and exit."""
33
+ if value:
34
+ console.print(f"spec-test version {__version__}")
35
+ raise typer.Exit()
36
+
37
+
38
+ @app.callback()
39
+ def main(
40
+ version: Optional[bool] = typer.Option(
41
+ None,
42
+ "--version",
43
+ help="Show version and exit",
44
+ callback=version_callback,
45
+ is_eager=True,
46
+ ),
47
+ ):
48
+ """spec-test: Make AI-generated code trustworthy through mathematical verification."""
49
+ pass
50
+
51
+
29
52
  @app.command()
30
53
  def verify(
31
54
  specs_dir: Path = typer.Option(
@@ -424,9 +447,9 @@ def _install_skills(path: Path) -> list[str]:
424
447
  except (TypeError, AttributeError, FileNotFoundError):
425
448
  pass
426
449
 
427
- # Fall back to project root for development mode
428
- # __file__ is src/spec_test/cli.py, so .parent.parent.parent gets to project root
429
- dev_skills = Path(__file__).parent.parent.parent / "skills"
450
+ # Fall back to src/spec_test/skills for development mode
451
+ # __file__ is src/spec_test/cli.py
452
+ dev_skills = Path(__file__).parent / "skills"
430
453
  if dev_skills.exists() and dev_skills.is_dir():
431
454
  skills_sources.append(("dev", dev_skills))
432
455
 
@@ -440,18 +463,28 @@ def _install_skills(path: Path) -> list[str]:
440
463
 
441
464
  if source_type == "package":
442
465
  # Use importlib.resources traversable
443
- for skill_file in source_path.iterdir():
444
- if skill_file.is_file() and skill_file.name.endswith(".md"):
445
- dest = skills_dir / skill_file.name
446
- dest.write_text(skill_file.read_text())
447
- installed.append(skill_file.name)
466
+ for skill_item in source_path.iterdir():
467
+ # Copy skill directories (each contains SKILL.md)
468
+ if skill_item.is_dir() and skill_item.name.startswith("spec-"):
469
+ dest_dir = skills_dir / skill_item.name
470
+ dest_dir.mkdir(exist_ok=True)
471
+
472
+ # Copy SKILL.md from the skill directory
473
+ skill_file = skill_item / "SKILL.md"
474
+ if skill_file.exists():
475
+ dest_file = dest_dir / "SKILL.md"
476
+ dest_file.write_text(skill_file.read_text())
477
+ installed.append(skill_item.name)
448
478
  else:
449
479
  # Use regular Path for dev mode
450
- for skill_file in source_path.iterdir():
451
- if skill_file.is_file() and skill_file.name.endswith(".md"):
452
- dest = skills_dir / skill_file.name
453
- dest.write_text(skill_file.read_text())
454
- installed.append(skill_file.name)
480
+ for skill_item in source_path.iterdir():
481
+ # Copy skill directories (each contains SKILL.md)
482
+ if skill_item.is_dir() and skill_item.name.startswith("spec-"):
483
+ dest_dir = skills_dir / skill_item.name
484
+ if dest_dir.exists():
485
+ shutil.rmtree(dest_dir)
486
+ shutil.copytree(skill_item, dest_dir)
487
+ installed.append(skill_item.name)
455
488
 
456
489
  return sorted(installed)
457
490
 
@@ -585,9 +618,14 @@ spec-test check PREFIX-001 # Check single spec
585
618
  # Install AI agent skills
586
619
  installed_skills = _install_skills(path)
587
620
  if installed_skills:
588
- console.print("Installed AI agent skills to .claude/skills/")
621
+ console.print("\n[bold cyan]AI Agent Skills Installed[/bold cyan]")
622
+ console.print("Installed skills to .claude/skills/:")
589
623
  for skill in installed_skills:
590
624
  console.print(f" - {skill}")
625
+ console.print("\n[yellow]To use these skills with Claude Code:[/yellow]")
626
+ console.print(" Add them to your agent system by running:")
627
+ console.print(" [dim]claude-code skills add .claude/skills/*[/dim]")
628
+ console.print(" Then you can use them with: /spec-workflow, /spec-issue, etc.")
591
629
 
592
630
  console.print("\n[green]Ready! Run 'spec-test verify' to check your specs.[/green]")
593
631
 
@@ -0,0 +1,177 @@
1
+ # spec-test AI Agent Skills
2
+
3
+ ## Overview
4
+
5
+ These skills provide instructions for AI agents (like Claude) to effectively use spec-test for specification-driven development. When a user runs `spec-test init`, these skills are copied to the user's `.claude/skills/` directory.
6
+
7
+ ## Available Skills
8
+
9
+ | Skill | File | Purpose |
10
+ |-------|------|---------|
11
+ | Workflow | `spec-workflow.md` | Complete spec-driven development workflow |
12
+ | Create Issue | `spec-issue.md` | Document intentions before writing specs |
13
+ | Create Feature | `spec-feature.md` | Define features and write formal specifications |
14
+ | Implement Specs | `spec-implement.md` | Write code that matches specifications |
15
+ | Verify Specs | `spec-verify.md` | Run verification and fix issues |
16
+ | Review Specs | `spec-review.md` | Review specifications for completeness |
17
+
18
+ ## Installation
19
+
20
+ Skills are automatically installed when you run:
21
+
22
+ ```bash
23
+ spec-test init
24
+ ```
25
+
26
+ This copies skills to `.claude/skills/` in your project directory.
27
+
28
+ ### Manual Installation
29
+
30
+ To manually install skills, copy the contents of this directory to your project:
31
+
32
+ ```bash
33
+ mkdir -p .claude/skills
34
+ cp -r /path/to/spec-test/skills/*.md .claude/skills/
35
+ ```
36
+
37
+ ## Quick Start
38
+
39
+ 1. **Starting a new feature**: Use `spec-feature` to define requirements first
40
+ 2. **Writing code**: Use `spec-implement` to write tests and implementation
41
+ 3. **Checking your work**: Use `spec-verify` to ensure all specs pass
42
+ 4. **Code review**: Use `spec-review` to validate spec completeness
43
+
44
+ ## Workflow Summary
45
+
46
+ ```
47
+ Write Issue --> Define Specs --> Implement Code --> Verify --> Review
48
+ | | | | |
49
+ spec-issue spec-feature spec-implement spec-verify spec-review
50
+ (why) (what) (how) (check) (approve)
51
+ ```
52
+
53
+ See `spec-workflow.md` for the complete workflow guide.
54
+
55
+ ## Key Concepts
56
+
57
+ ### Specification IDs
58
+
59
+ Every requirement has a unique ID following the pattern `PREFIX-NNN`:
60
+
61
+ - `AUTH-001` - Authentication requirement 1
62
+ - `CART-003` - Shopping cart requirement 3
63
+ - `API-012` - API requirement 12
64
+
65
+ ### The `@spec` Decorator
66
+
67
+ Tests are linked to specs using the `@spec` decorator:
68
+
69
+ ```python
70
+ from spec_test import spec
71
+
72
+ @spec("AUTH-001", "User can log in with valid credentials")
73
+ def test_login_success():
74
+ result = login("user@example.com", "password123")
75
+ assert result.success
76
+ ```
77
+
78
+ ### Verification Types
79
+
80
+ Specs can have verification types in brackets:
81
+
82
+ - `**ID**: Description` - Automated test (default)
83
+ - `**ID** [integration]: Description` - Integration test (real I/O)
84
+ - `**ID** [manual]: Description` - Manual verification required
85
+ - `**ID** [contract]: Description` - Contract/property verification
86
+ - `**ID** [provable]: Description` - Z3 formal proof
87
+
88
+ ## Architecture Principles
89
+
90
+ All code should follow **Functional Core, Imperative Shell** with **Dependency Injection**:
91
+
92
+ ```
93
+ ┌─────────────────────────────────────────────────────────────┐
94
+ │ Imperative Shell │
95
+ │ (thin layer, injected dependencies) │
96
+ │ ┌───────────────────────────────────────────────────────┐ │
97
+ │ │ Functional Core │ │
98
+ │ │ (pure functions, all business logic) │ │
99
+ │ │ │ │
100
+ │ │ • Deterministic (same input → same output) │ │
101
+ │ │ • No side effects │ │
102
+ │ │ • Easy to test (unit tests) │ │
103
+ │ │ • Can be formally proven (Z3) │ │
104
+ │ └───────────────────────────────────────────────────────┘ │
105
+ │ │
106
+ │ • Database, Email, API calls via DI │
107
+ │ • Testable with mocks │
108
+ │ • Integration tests verify real I/O │
109
+ └─────────────────────────────────────────────────────────────┘
110
+ ```
111
+
112
+ ### Testing Strategy
113
+
114
+ ```
115
+ ┌─────────────┬────────────────┬─────────────────────┬───────────┐
116
+ │ Test Type │ What │ How │ Speed │
117
+ ├─────────────┼────────────────┼─────────────────────┼───────────┤
118
+ │ Unit │ Pure functions │ Direct call │ Fast (ms) │
119
+ ├─────────────┼────────────────┼─────────────────────┼───────────┤
120
+ │ Mock │ Service wiring │ Inject mocks via DI │ Fast (ms) │
121
+ ├─────────────┼────────────────┼─────────────────────┼───────────┤
122
+ │ Integration │ Real I/O works │ Real DB/API │ Slow (s) │
123
+ └─────────────┴────────────────┴─────────────────────┴───────────┘
124
+ ```
125
+
126
+ **Aim for ~90% unit/mock tests, ~10% integration tests.**
127
+
128
+ ### Example
129
+
130
+ ```python
131
+ # FUNCTIONAL CORE: Pure function, no dependencies
132
+ def calculate_total(items: list[Item]) -> Decimal:
133
+ return sum(item.price * item.quantity for item in items)
134
+
135
+ # IMPERATIVE SHELL: Thin layer with injected dependencies
136
+ class OrderService:
137
+ def __init__(self, db: Database, email: EmailSender): # DI
138
+ self.db = db
139
+ self.email = email
140
+
141
+ def place_order(self, items: list[Item]) -> Order:
142
+ total = calculate_total(items) # Call pure function
143
+ order = Order(items=items, total=total)
144
+ self.db.save(order) # Injected dependency
145
+ self.email.send_confirmation() # Injected dependency
146
+ return order
147
+
148
+ # TESTS
149
+ @spec("ORDER-001", "Total is sum of item prices")
150
+ def test_calculate_total(): # Unit test - pure function
151
+ items = [Item(price=Decimal("10"), quantity=2)]
152
+ assert calculate_total(items) == Decimal("20")
153
+
154
+ @spec("ORDER-002", "Order saved to database")
155
+ def test_order_saved(): # Mock test - inject mock
156
+ mock_db = MockDatabase()
157
+ service = OrderService(db=mock_db, email=MockEmail())
158
+ service.place_order([Item(...)])
159
+ assert len(mock_db.saved) == 1
160
+
161
+ @spec("ORDER-003", "Order persists to real database")
162
+ @pytest.mark.integration
163
+ def test_order_persists(): # Integration test - real I/O
164
+ service = OrderService(db=real_db, email=mock_email)
165
+ order = service.place_order([Item(...)])
166
+ assert real_db.get(order.id) is not None
167
+ ```
168
+
169
+ ## Commands Reference
170
+
171
+ ```bash
172
+ spec-test verify # Verify all specs have passing tests
173
+ spec-test list-specs # List all specifications
174
+ spec-test check ID # Check a single spec
175
+ spec-test init # Initialize spec-test in a project
176
+ spec-test context # Output CLAUDE.md for LLM context
177
+ ```
@@ -0,0 +1,212 @@
1
+ ---
2
+ name: spec-feature
3
+ description: Define Features and Specifications
4
+ ---
5
+
6
+ ## Overview
7
+
8
+ This skill guides you through defining a new feature using specification-driven development. The workflow ensures every feature is fully specified before implementation begins.
9
+
10
+ ## When to Use
11
+
12
+ - User asks to "add a feature" or "implement a new capability"
13
+ - User describes functionality that does not exist yet
14
+ - User wants to plan a feature before coding
15
+ - Starting work on a new user story or epic
16
+
17
+ ## Workflow
18
+
19
+ ### Step 1: Understand the Feature
20
+
21
+ Before writing specs, clarify:
22
+
23
+ 1. **What** does this feature do?
24
+ 2. **Who** is it for (user type/actor)?
25
+ 3. **Why** is it needed (business value)?
26
+ 4. **How** will users interact with it?
27
+
28
+ Ask clarifying questions if any of these are unclear.
29
+
30
+ ### Step 2: Create or Update Spec File
31
+
32
+ Specs live in `design/specs/*.md` files. Create a new file or add to an existing one.
33
+
34
+ **File naming**: `{domain}.md` (e.g., `auth.md`, `payments.md`)
35
+
36
+ ### Step 3: Write Specifications
37
+
38
+ Use this format for each requirement:
39
+
40
+ ```markdown
41
+ ## Feature Name
42
+
43
+ ### Overview
44
+ Brief description of the feature.
45
+
46
+ ### Requirements
47
+
48
+ #### Category Name
49
+ - **PREFIX-001**: First requirement description
50
+ - **PREFIX-002**: Second requirement description
51
+ - **PREFIX-003** [manual]: Requirement needing manual verification
52
+ ```
53
+
54
+ ### Step 4: Assign Spec IDs
55
+
56
+ Follow this convention:
57
+
58
+ - **PREFIX**: Short domain code (3-5 chars, uppercase)
59
+ - `AUTH` for authentication
60
+ - `CART` for shopping cart
61
+ - `API` for API endpoints
62
+ - `USER` for user management
63
+
64
+ - **NUMBER**: Sequential, zero-padded (001, 002, 003...)
65
+
66
+ ### Step 5: Verify Spec Coverage
67
+
68
+ Run to see what needs tests:
69
+
70
+ ```bash
71
+ spec-test list-specs
72
+ ```
73
+
74
+ ## Spec Format Reference
75
+
76
+ ### Basic Requirement
77
+
78
+ ```markdown
79
+ - **AUTH-001**: User can log in with email and password
80
+ ```
81
+
82
+ ### With Verification Type
83
+
84
+ ```markdown
85
+ - **AUTH-002** [manual]: Password reset email is sent within 5 minutes
86
+ - **AUTH-003** [contract]: Password hash uses bcrypt with cost factor 12
87
+ ```
88
+
89
+ ### Verification Types
90
+
91
+ | Type | Meaning | Test Type |
92
+ |------|---------|-----------|
93
+ | (none) | Automated unit test | Fast, pure function test |
94
+ | `[integration]` | Integration test required | Tests real I/O (DB, API, etc.) |
95
+ | `[manual]` | Manual verification | Human check required |
96
+ | `[contract]` | Contract/property-based | Runtime @contract verification |
97
+ | `[provable]` | Formal proof | Z3 mathematical verification |
98
+
99
+ ## Examples
100
+
101
+ ### Example 1: User Authentication Feature
102
+
103
+ ```markdown
104
+ # User Authentication Specification
105
+
106
+ ## Overview
107
+ Authentication system allowing users to sign up, log in, and manage sessions.
108
+
109
+ ## Requirements
110
+
111
+ ### Sign Up
112
+ - **AUTH-001**: User can create account with email and password
113
+ - **AUTH-002**: Email must be unique across all accounts
114
+ - **AUTH-003**: Password must be at least 8 characters
115
+ - **AUTH-004**: Password must contain uppercase, lowercase, and number
116
+
117
+ ### Login
118
+ - **AUTH-010**: User can log in with valid email and password
119
+ - **AUTH-011**: Login fails with invalid credentials
120
+ - **AUTH-012**: Account is locked after 5 failed attempts
121
+
122
+ ### Session Management
123
+ - **AUTH-020**: Successful login returns JWT token
124
+ - **AUTH-021**: Token expires after 24 hours
125
+ - **AUTH-022** [manual]: User can view active sessions
126
+ ```
127
+
128
+ ### Example 2: Shopping Cart Feature
129
+
130
+ ```markdown
131
+ # Shopping Cart Specification
132
+
133
+ ## Overview
134
+ Shopping cart allowing users to add, remove, and checkout items.
135
+
136
+ ## Requirements
137
+
138
+ ### Cart Operations
139
+ - **CART-001**: User can add item to cart
140
+ - **CART-002**: User can remove item from cart
141
+ - **CART-003**: User can update item quantity
142
+ - **CART-004**: Cart persists across sessions for logged-in users
143
+
144
+ ### Cart Calculations
145
+ - **CART-010**: Cart total is sum of (price * quantity) for all items
146
+ - **CART-011**: Cart applies percentage discounts correctly
147
+ - **CART-012**: Cart applies fixed amount discounts correctly
148
+ - **CART-013**: Discount cannot reduce total below zero
149
+ ```
150
+
151
+ ## Commands
152
+
153
+ ```bash
154
+ # List all specs to see current coverage
155
+ spec-test list-specs
156
+
157
+ # Check if your new specs are discovered
158
+ spec-test list-specs --specs specs
159
+
160
+ # Verify after writing tests
161
+ spec-test verify
162
+ ```
163
+
164
+ ## Architecture: Functional Core, Imperative Shell
165
+
166
+ When designing features, structure specs to separate:
167
+
168
+ **Functional Core** (pure logic, most specs):
169
+ - Business rules, calculations, validations
170
+ - Data transformations
171
+ - Decision logic
172
+
173
+ **Imperative Shell** (side effects, mark as `[integration]`):
174
+ - Database persistence
175
+ - External API calls
176
+ - Email/notification sending
177
+ - File I/O
178
+
179
+ ### Example: Separating Core and Shell Specs
180
+
181
+ ```markdown
182
+ ## Order Processing
183
+
184
+ ### Core Logic (unit testable, can use @provable)
185
+ - **ORDER-001**: Order total is sum of item prices
186
+ - **ORDER-002**: Tax calculated at configured rate
187
+ - **ORDER-003**: Discount cannot reduce total below zero
188
+ - **ORDER-004**: Invalid quantity rejected (must be > 0)
189
+
190
+ ### Integration (real I/O, mark as [integration])
191
+ - **ORDER-020** [integration]: Order persists to database
192
+ - **ORDER-021** [integration]: Confirmation email sent after order
193
+ - **ORDER-022** [integration]: Inventory decremented on order
194
+ ```
195
+
196
+ **Why this matters:**
197
+ - Core specs → fast unit tests, Z3 proofs possible
198
+ - Integration specs → slower tests, run separately, fewer of them
199
+ - Clear separation makes testing strategy obvious
200
+
201
+ ## Checklist
202
+
203
+ Before moving to implementation:
204
+
205
+ - [ ] Each requirement has a unique ID
206
+ - [ ] IDs follow PREFIX-NNN convention
207
+ - [ ] Requirements are testable (clear pass/fail criteria)
208
+ - [ ] Pure logic specs separated from I/O specs
209
+ - [ ] I/O specs marked with `[integration]`
210
+ - [ ] Manual verification items are marked `[manual]`
211
+ - [ ] Specs are saved in `design/specs/*.md`
212
+ - [ ] Running `spec-test list-specs` shows new specs