spec-test 0.3.3__tar.gz → 0.3.4__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 (58) hide show
  1. {spec_test-0.3.3 → spec_test-0.3.4}/CLAUDE.md +15 -0
  2. {spec_test-0.3.3 → spec_test-0.3.4}/PKG-INFO +1 -1
  3. {spec_test-0.3.3 → spec_test-0.3.4}/pyproject.toml +1 -1
  4. {spec_test-0.3.3 → spec_test-0.3.4}/src/spec_test/runner.py +107 -0
  5. {spec_test-0.3.3 → spec_test-0.3.4}/src/spec_test/verifier.py +75 -15
  6. {spec_test-0.3.3 → spec_test-0.3.4}/.claude/skills/README.md +0 -0
  7. {spec_test-0.3.3 → spec_test-0.3.4}/.claude/skills/spec-feature.md +0 -0
  8. {spec_test-0.3.3 → spec_test-0.3.4}/.claude/skills/spec-implement.md +0 -0
  9. {spec_test-0.3.3 → spec_test-0.3.4}/.claude/skills/spec-issue.md +0 -0
  10. {spec_test-0.3.3 → spec_test-0.3.4}/.claude/skills/spec-review.md +0 -0
  11. {spec_test-0.3.3 → spec_test-0.3.4}/.claude/skills/spec-verify.md +0 -0
  12. {spec_test-0.3.3 → spec_test-0.3.4}/.claude/skills/spec-workflow.md +0 -0
  13. {spec_test-0.3.3 → spec_test-0.3.4}/.github/workflows/publish.yml +0 -0
  14. {spec_test-0.3.3 → spec_test-0.3.4}/.gitignore +0 -0
  15. {spec_test-0.3.3 → spec_test-0.3.4}/README.md +0 -0
  16. {spec_test-0.3.3 → spec_test-0.3.4}/design/issues/001-core-spec-test.md +0 -0
  17. {spec_test-0.3.3 → spec_test-0.3.4}/design/issues/001-example.md +0 -0
  18. {spec_test-0.3.3 → spec_test-0.3.4}/design/issues/002-runtime-contracts.md +0 -0
  19. {spec_test-0.3.3 → spec_test-0.3.4}/design/issues/003-hypothesis-integration.md +0 -0
  20. {spec_test-0.3.3 → spec_test-0.3.4}/design/issues/004-z3-formal-proofs.md +0 -0
  21. {spec_test-0.3.3 → spec_test-0.3.4}/design/issues/005-spec-issue-verification.md +0 -0
  22. {spec_test-0.3.3 → spec_test-0.3.4}/design/issues/006-git-workflow-integration.md +0 -0
  23. {spec_test-0.3.3 → spec_test-0.3.4}/design/prompts/migrate-v1-to-v2.md +0 -0
  24. {spec_test-0.3.3 → spec_test-0.3.4}/design/specs/contracts.md +0 -0
  25. {spec_test-0.3.3 → spec_test-0.3.4}/design/specs/example.md +0 -0
  26. {spec_test-0.3.3 → spec_test-0.3.4}/design/specs/git-workflow.md +0 -0
  27. {spec_test-0.3.3 → spec_test-0.3.4}/design/specs/hypothesis-integration.md +0 -0
  28. {spec_test-0.3.3 → spec_test-0.3.4}/design/specs/spec-spec-test.md +0 -0
  29. {spec_test-0.3.3 → spec_test-0.3.4}/design/specs/z3-proofs.md +0 -0
  30. {spec_test-0.3.3 → spec_test-0.3.4}/prompt.md +0 -0
  31. {spec_test-0.3.3 → spec_test-0.3.4}/src/spec_test/__init__.py +0 -0
  32. {spec_test-0.3.3 → spec_test-0.3.4}/src/spec_test/cli.py +0 -0
  33. {spec_test-0.3.3 → spec_test-0.3.4}/src/spec_test/collector.py +0 -0
  34. {spec_test-0.3.3 → spec_test-0.3.4}/src/spec_test/contracts.py +0 -0
  35. {spec_test-0.3.3 → spec_test-0.3.4}/src/spec_test/decorators.py +0 -0
  36. {spec_test-0.3.3 → spec_test-0.3.4}/src/spec_test/prover.py +0 -0
  37. {spec_test-0.3.3 → spec_test-0.3.4}/src/spec_test/pytest_plugin.py +0 -0
  38. {spec_test-0.3.3 → spec_test-0.3.4}/src/spec_test/reporter.py +0 -0
  39. {spec_test-0.3.3 → spec_test-0.3.4}/src/spec_test/skills/README.md +0 -0
  40. {spec_test-0.3.3 → spec_test-0.3.4}/src/spec_test/skills/spec-feature/SKILL.md +0 -0
  41. {spec_test-0.3.3 → spec_test-0.3.4}/src/spec_test/skills/spec-implement/SKILL.md +0 -0
  42. {spec_test-0.3.3 → spec_test-0.3.4}/src/spec_test/skills/spec-issue/SKILL.md +0 -0
  43. {spec_test-0.3.3 → spec_test-0.3.4}/src/spec_test/skills/spec-review/SKILL.md +0 -0
  44. {spec_test-0.3.3 → spec_test-0.3.4}/src/spec_test/skills/spec-verify/SKILL.md +0 -0
  45. {spec_test-0.3.3 → spec_test-0.3.4}/src/spec_test/skills/spec-workflow/SKILL.md +0 -0
  46. {spec_test-0.3.3 → spec_test-0.3.4}/src/spec_test/types.py +0 -0
  47. {spec_test-0.3.3 → spec_test-0.3.4}/tests/__init__.py +0 -0
  48. {spec_test-0.3.3 → spec_test-0.3.4}/tests/conftest.py +0 -0
  49. {spec_test-0.3.3 → spec_test-0.3.4}/tests/test_cli.py +0 -0
  50. {spec_test-0.3.3 → spec_test-0.3.4}/tests/test_collector.py +0 -0
  51. {spec_test-0.3.3 → spec_test-0.3.4}/tests/test_contracts.py +0 -0
  52. {spec_test-0.3.3 → spec_test-0.3.4}/tests/test_decorators.py +0 -0
  53. {spec_test-0.3.3 → spec_test-0.3.4}/tests/test_git_workflow.py +0 -0
  54. {spec_test-0.3.3 → spec_test-0.3.4}/tests/test_prover.py +0 -0
  55. {spec_test-0.3.3 → spec_test-0.3.4}/tests/test_reporter.py +0 -0
  56. {spec_test-0.3.3 → spec_test-0.3.4}/tests/test_runner.py +0 -0
  57. {spec_test-0.3.3 → spec_test-0.3.4}/tests/test_verifier.py +0 -0
  58. {spec_test-0.3.3 → spec_test-0.3.4}/uv.lock +0 -0
@@ -62,6 +62,20 @@ Follow **Functional Core, Imperative Shell** with **Dependency Injection**:
62
62
  └─────────────────────────────────────────┘
63
63
  ```
64
64
 
65
+ ## Versioning
66
+
67
+ Follow semantic versioning (0.MINOR.PATCH) in pre-1.0:
68
+
69
+ - **PATCH** (0.x.Y): Bug fixes, performance improvements, refactoring
70
+ - **MINOR** (0.X.0): New features, breaking changes (API changes)
71
+ - **MAJOR** (X.0.0): Reserved for 1.0.0+ stable release
72
+
73
+ Examples:
74
+ - Performance optimization: 0.3.3 → 0.3.4 ✓
75
+ - Bug fix: 0.3.3 → 0.3.4 ✓
76
+ - New feature: 0.3.3 → 0.4.0 ✓
77
+ - Breaking change: 0.3.3 → 0.4.0 ✓
78
+
65
79
  ## Rules
66
80
 
67
81
  1. Write an issue before writing specs
@@ -69,3 +83,4 @@ Follow **Functional Core, Imperative Shell** with **Dependency Injection**:
69
83
  3. Every spec ID must have a corresponding `@spec` test
70
84
  4. Run `spec-test verify` before committing
71
85
  5. Prefer pure functions; push side effects to the edges
86
+ 6. Use patch versions (0.x.Y) for fixes and optimizations
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: spec-test
3
- Version: 0.3.3
3
+ Version: 0.3.4
4
4
  Summary: Make AI-generated code trustworthy through mathematical verification
5
5
  Author: Pulse Team
6
6
  License: MIT
@@ -1,6 +1,6 @@
1
1
  [project]
2
2
  name = "spec-test"
3
- version = "0.3.3"
3
+ version = "0.3.4"
4
4
  description = "Make AI-generated code trustworthy through mathematical verification"
5
5
  authors = [{ name = "Pulse Team" }]
6
6
  readme = "README.md"
@@ -140,6 +140,113 @@ def run_test(test_path: str, tests_dir: Path) -> tuple[bool, Optional[str]]:
140
140
  return passed, error_message
141
141
 
142
142
 
143
+ def run_tests_batch(test_paths: list[str], tests_dir: Path) -> dict[str, tuple[bool, Optional[str]]]:
144
+ """
145
+ Run multiple tests in a single pytest invocation for performance.
146
+
147
+ Returns:
148
+ Dict mapping test_path -> (passed, error_message)
149
+ """
150
+ if not test_paths:
151
+ return {}
152
+
153
+ # Run all tests in a single pytest invocation
154
+ result = subprocess.run(
155
+ [
156
+ sys.executable,
157
+ "-m",
158
+ "pytest",
159
+ *test_paths,
160
+ "-v",
161
+ "--tb=line", # Shorter output for batch runs
162
+ "--no-header",
163
+ "-p",
164
+ "no:spec_test", # Disable our plugin to avoid recursion
165
+ ],
166
+ capture_output=True,
167
+ text=True,
168
+ cwd=Path.cwd(),
169
+ env=_get_env_with_pythonpath(),
170
+ )
171
+
172
+ # Parse pytest output to extract per-test results
173
+ results: dict[str, tuple[bool, Optional[str]]] = {}
174
+
175
+ # Parse the output - look for test result lines
176
+ output = result.stdout + result.stderr
177
+ lines = output.split('\n')
178
+
179
+ for line in lines:
180
+ # Match pytest verbose output: "test_file.py::test_name PASSED" or "FAILED"
181
+ # Example: "tests/test_contracts.py::test_contract_validates_preconditions PASSED [ 50%]"
182
+ if '::' in line:
183
+ # Check for status keywords
184
+ status_found = None
185
+ for status_keyword in ['PASSED', 'FAILED', 'ERROR', 'SKIPPED']:
186
+ if status_keyword in line:
187
+ status_found = status_keyword
188
+ break
189
+
190
+ if status_found:
191
+ # Extract test identifier (everything before the status)
192
+ # Split on whitespace and get the first part
193
+ parts = line.split()
194
+ if len(parts) >= 2:
195
+ test_identifier = parts[0]
196
+
197
+ # Match against our test paths
198
+ # pytest outputs can be relative (with ../ prefix) or absolute
199
+ # Our test_paths are typically absolute
200
+ for test_path in test_paths:
201
+ # Normalize both paths by resolving them and comparing
202
+ # Split into file path and test node (::test_name)
203
+ test_path_parts = test_path.split('::')
204
+ test_id_parts = test_identifier.split('::')
205
+
206
+ # Match if the test nodes (after ::) match
207
+ # and the file paths resolve to the same file
208
+ matches = False
209
+
210
+ if test_path == test_identifier:
211
+ # Exact match
212
+ matches = True
213
+ elif len(test_path_parts) == len(test_id_parts) and test_path_parts[1:] == test_id_parts[1:]:
214
+ # Test nodes match, now check if file paths point to same file
215
+ try:
216
+ # Normalize the pytest output path (might have ../ prefix)
217
+ # by resolving it from current working directory
218
+ test_id_file = Path(test_id_parts[0]).resolve()
219
+ test_path_file = Path(test_path_parts[0]).resolve()
220
+
221
+ if test_id_file == test_path_file:
222
+ matches = True
223
+ except (ValueError, OSError):
224
+ # If path resolution fails, fall back to string matching
225
+ if test_path_parts[0].endswith(test_id_parts[0]) or test_id_parts[0].endswith(test_path_parts[0]):
226
+ matches = True
227
+
228
+ if matches:
229
+ if status_found in ['PASSED']:
230
+ results[test_path] = (True, None)
231
+ elif status_found in ['FAILED']:
232
+ # Extract error from subsequent lines (simplified)
233
+ error_msg = f"Test failed: {test_identifier}"
234
+ results[test_path] = (False, error_msg)
235
+ elif status_found in ['ERROR']:
236
+ error_msg = f"Test error: {test_identifier}"
237
+ results[test_path] = (False, error_msg)
238
+ elif status_found in ['SKIPPED']:
239
+ results[test_path] = (True, None) # Treat skipped as passing for spec purposes
240
+ break
241
+
242
+ # Mark any tests that didn't appear in output as failed
243
+ for test_path in test_paths:
244
+ if test_path not in results:
245
+ results[test_path] = (False, "Test did not run or was not found")
246
+
247
+ return results
248
+
249
+
143
250
  def run_tests_by_spec_id(spec_id: str, tests_dir: Path) -> tuple[bool, Optional[str]]:
144
251
  """Run all tests for a given spec ID."""
145
252
  result = subprocess.run(
@@ -7,7 +7,7 @@ from rich.console import Console
7
7
  from rich.progress import Progress, SpinnerColumn, TextColumn
8
8
 
9
9
  from .collector import collect_specs
10
- from .runner import discover_spec_tests, run_test
10
+ from .runner import discover_spec_tests, run_test, run_tests_batch
11
11
  from .types import (
12
12
  SpecRequirement,
13
13
  SpecResult,
@@ -49,20 +49,31 @@ class SpecVerifier:
49
49
  # Discover tests
50
50
  spec_tests = discover_spec_tests(self.tests_dir)
51
51
 
52
+ # Build list of specs that need testing (skip SKIP and MANUAL)
53
+ specs_to_test = [
54
+ spec for spec in specs
55
+ if spec.verification_type not in [VerificationType.SKIP, VerificationType.MANUAL]
56
+ and spec.id in spec_tests
57
+ ]
58
+
59
+ # Batch run all tests in a single pytest invocation for performance
60
+ test_results = {}
61
+ if specs_to_test:
62
+ test_paths = [spec_tests[spec.id].test_path for spec in specs_to_test]
63
+ with Progress(
64
+ SpinnerColumn(),
65
+ TextColumn("[progress.description]{task.description}"),
66
+ console=self.console,
67
+ transient=True,
68
+ ) as progress:
69
+ progress.add_task("Running tests...", total=None)
70
+ test_results = run_tests_batch(test_paths, self.tests_dir)
71
+
72
+ # Map results back to specs
52
73
  results: list[SpecResult] = []
53
-
54
- with Progress(
55
- SpinnerColumn(),
56
- TextColumn("[progress.description]{task.description}"),
57
- console=self.console,
58
- transient=True,
59
- ) as progress:
60
- task = progress.add_task("Verifying specs...", total=len(specs))
61
-
62
- for spec in specs:
63
- result = self._verify_spec(spec, spec_tests, verbose)
64
- results.append(result)
65
- progress.advance(task)
74
+ for spec in specs:
75
+ result = self._verify_spec_with_cache(spec, spec_tests, test_results, verbose)
76
+ results.append(result)
66
77
 
67
78
  return VerificationReport(results=results)
68
79
 
@@ -72,7 +83,7 @@ class SpecVerifier:
72
83
  spec_tests: dict[str, SpecTest],
73
84
  verbose: bool,
74
85
  ) -> SpecResult:
75
- """Verify a single specification."""
86
+ """Verify a single specification (used for single-spec verification)."""
76
87
 
77
88
  # Handle SKIP verification type
78
89
  if spec.verification_type == VerificationType.SKIP:
@@ -108,6 +119,55 @@ class SpecVerifier:
108
119
  error_message=error,
109
120
  )
110
121
 
122
+ def _verify_spec_with_cache(
123
+ self,
124
+ spec: SpecRequirement,
125
+ spec_tests: dict[str, SpecTest],
126
+ test_results: dict[str, tuple[bool, Optional[str]]],
127
+ verbose: bool,
128
+ ) -> SpecResult:
129
+ """Verify a single specification using cached test results."""
130
+
131
+ # Handle SKIP verification type
132
+ if spec.verification_type == VerificationType.SKIP:
133
+ return SpecResult(
134
+ spec=spec,
135
+ status=SpecStatus.SKIPPED,
136
+ error_message="Skipped",
137
+ )
138
+
139
+ # Handle manual verification type
140
+ if spec.verification_type == VerificationType.MANUAL:
141
+ return SpecResult(
142
+ spec=spec,
143
+ status=SpecStatus.SKIPPED,
144
+ error_message="Manual verification required",
145
+ )
146
+
147
+ # Standard test verification
148
+ if spec.id not in spec_tests:
149
+ return SpecResult(
150
+ spec=spec,
151
+ status=SpecStatus.PENDING,
152
+ error_message=f"No test found for {spec.id}",
153
+ )
154
+
155
+ test = spec_tests[spec.id]
156
+
157
+ # Look up result from batch run
158
+ if test.test_path in test_results:
159
+ passed, error = test_results[test.test_path]
160
+ else:
161
+ # Fallback: test wasn't in batch (shouldn't happen)
162
+ passed, error = False, "Test not found in batch results"
163
+
164
+ return SpecResult(
165
+ spec=spec,
166
+ status=SpecStatus.PASSING if passed else SpecStatus.FAILING,
167
+ test=test,
168
+ error_message=error,
169
+ )
170
+
111
171
  def verify_single(self, spec_id: str) -> Optional[SpecResult]:
112
172
  """Verify a single spec by ID."""
113
173
  specs = collect_specs(self.specs_dir)
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes