spec-test 0.3.3__tar.gz → 0.4.0__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 (167) hide show
  1. spec_test-0.4.0/.claude/skills/README.md +1 -0
  2. spec_test-0.4.0/.claude/skills/spec-feature.md +1 -0
  3. spec_test-0.4.0/.claude/skills/spec-implement.md +1 -0
  4. spec_test-0.4.0/.claude/skills/spec-issue.md +1 -0
  5. spec_test-0.4.0/.claude/skills/spec-review.md +1 -0
  6. spec_test-0.4.0/.claude/skills/spec-verify.md +1 -0
  7. spec_test-0.4.0/.claude/skills/spec-workflow.md +1 -0
  8. spec_test-0.4.0/.github/workflows/verify.yml +83 -0
  9. spec_test-0.4.0/CLAUDE.md +32 -0
  10. spec_test-0.4.0/PKG-INFO +509 -0
  11. spec_test-0.4.0/README.md +482 -0
  12. spec_test-0.4.0/adapters/rust/.gitignore +1 -0
  13. spec_test-0.4.0/adapters/rust/Cargo.lock +141 -0
  14. spec_test-0.4.0/adapters/rust/Cargo.toml +14 -0
  15. spec_test-0.4.0/adapters/rust/README.md +100 -0
  16. spec_test-0.4.0/adapters/rust/macros/Cargo.toml +12 -0
  17. spec_test-0.4.0/adapters/rust/macros/src/lib.rs +40 -0
  18. spec_test-0.4.0/adapters/rust/src/bin/verify.rs +127 -0
  19. spec_test-0.4.0/adapters/rust/src/lib.rs +37 -0
  20. spec_test-0.4.0/adapters/rust/src/proofs/kani.rs +32 -0
  21. spec_test-0.4.0/adapters/rust/syntax/Cargo.toml +8 -0
  22. spec_test-0.4.0/adapters/rust/syntax/src/lib.rs +27 -0
  23. spec_test-0.4.0/adapters/rust/test_verify_kani.py +155 -0
  24. spec_test-0.4.0/adapters/rust/tests/cli.rs +22 -0
  25. spec_test-0.4.0/adapters/rust/trace/Cargo.toml +11 -0
  26. spec_test-0.4.0/adapters/rust/trace/src/main.rs +180 -0
  27. spec_test-0.4.0/adapters/rust/verify_kani.py +242 -0
  28. spec_test-0.4.0/adapters/rust/verify_scenarios.py +30 -0
  29. spec_test-0.4.0/adapters/typescript/.gitignore +3 -0
  30. spec_test-0.4.0/adapters/typescript/README.md +61 -0
  31. spec_test-0.4.0/adapters/typescript/fixtures/status.fixture.ts +14 -0
  32. spec_test-0.4.0/adapters/typescript/fixtures/vitest.config.ts +9 -0
  33. spec_test-0.4.0/adapters/typescript/package-lock.json +1332 -0
  34. spec_test-0.4.0/adapters/typescript/package.json +19 -0
  35. spec_test-0.4.0/adapters/typescript/src/contract.ts +23 -0
  36. spec_test-0.4.0/adapters/typescript/src/queue.ts +27 -0
  37. spec_test-0.4.0/adapters/typescript/src/reporter.ts +100 -0
  38. spec_test-0.4.0/adapters/typescript/src/spec.ts +28 -0
  39. spec_test-0.4.0/adapters/typescript/test/queue.test.ts +59 -0
  40. spec_test-0.4.0/adapters/typescript/test/reporter.test.ts +75 -0
  41. spec_test-0.4.0/adapters/typescript/trace.mjs +110 -0
  42. spec_test-0.4.0/adapters/typescript/trace.test.mjs +51 -0
  43. spec_test-0.4.0/adapters/typescript/tsconfig.json +12 -0
  44. spec_test-0.4.0/adapters/typescript/vitest.config.ts +9 -0
  45. spec_test-0.4.0/design/features/verification/domain-rule-workflow.md +82 -0
  46. spec_test-0.4.0/design/features/verification/execute-downstream-rules.md +41 -0
  47. spec_test-0.4.0/design/features/verification/run-directly-linked-tests.md +26 -0
  48. spec_test-0.4.0/design/issues/003-hypothesis-integration.md +124 -0
  49. {spec_test-0.3.3 → spec_test-0.4.0}/design/issues/005-spec-issue-verification.md +5 -3
  50. spec_test-0.4.0/design/issues/007-evidence-and-native-adapters.md +17 -0
  51. {spec_test-0.3.3 → spec_test-0.4.0}/design/specs/example.md +2 -2
  52. {spec_test-0.3.3 → spec_test-0.4.0}/design/specs/git-workflow.md +1 -1
  53. {spec_test-0.3.3 → spec_test-0.4.0}/design/specs/hypothesis-integration.md +21 -15
  54. spec_test-0.4.0/design/specs/queue-only/queue.md +33 -0
  55. spec_test-0.4.0/design/specs/verification-evidence.md +50 -0
  56. {spec_test-0.3.3 → spec_test-0.4.0}/design/specs/z3-proofs.md +78 -75
  57. spec_test-0.4.0/design/verification-scope.toml +80 -0
  58. spec_test-0.4.0/examples/README.md +14 -0
  59. spec_test-0.4.0/examples/receiving/README.md +26 -0
  60. spec_test-0.4.0/examples/receiving/design/features/inventory/receive-stock.md +24 -0
  61. spec_test-0.4.0/examples/receiving/design/impact.toml +8 -0
  62. spec_test-0.4.0/examples/receiving/pytest.ini +2 -0
  63. spec_test-0.4.0/examples/receiving/receiving.py +53 -0
  64. spec_test-0.4.0/examples/receiving/replay.py +126 -0
  65. spec_test-0.4.0/examples/receiving/tests/fixtures/restore_balance.py +27 -0
  66. spec_test-0.4.0/examples/receiving/tests/fixtures/retry-after-restart.json +57 -0
  67. spec_test-0.4.0/examples/receiving/tests/test_receiving.py +157 -0
  68. spec_test-0.4.0/examples/receiving/verification/.gitignore +1 -0
  69. spec_test-0.4.0/examples/work-budget/README.md +40 -0
  70. spec_test-0.4.0/examples/work-budget/design/features/planning/work-budget.md +39 -0
  71. spec_test-0.4.0/examples/work-budget/design/issues/work-budget.md +10 -0
  72. spec_test-0.4.0/examples/work-budget/design/specs/work-budget.md +3 -0
  73. spec_test-0.4.0/examples/work-budget/tests/test_work_budget.py +43 -0
  74. spec_test-0.4.0/examples/work-budget/verification/baseline.json +40 -0
  75. spec_test-0.4.0/examples/work-budget/verification/omitted-scenario.md +5 -0
  76. spec_test-0.4.0/examples/work-budget/work_budget.py +53 -0
  77. {spec_test-0.3.3 → spec_test-0.4.0}/pyproject.toml +11 -1
  78. {spec_test-0.3.3 → spec_test-0.4.0}/src/spec_test/__init__.py +7 -1
  79. spec_test-0.4.0/src/spec_test/cli.py +826 -0
  80. spec_test-0.4.0/src/spec_test/collector.py +177 -0
  81. {spec_test-0.3.3 → spec_test-0.4.0}/src/spec_test/decorators.py +10 -0
  82. spec_test-0.4.0/src/spec_test/direct-vitest.mjs +45 -0
  83. spec_test-0.4.0/src/spec_test/direct.py +134 -0
  84. spec_test-0.4.0/src/spec_test/docs_export.py +237 -0
  85. spec_test-0.4.0/src/spec_test/downstream.py +253 -0
  86. spec_test-0.4.0/src/spec_test/evidence.py +125 -0
  87. spec_test-0.4.0/src/spec_test/impact.py +303 -0
  88. spec_test-0.4.0/src/spec_test/property_testing.py +149 -0
  89. spec_test-0.4.0/src/spec_test/prover.py +592 -0
  90. spec_test-0.4.0/src/spec_test/pytest_receipt.py +102 -0
  91. spec_test-0.4.0/src/spec_test/repo_plan.py +183 -0
  92. {spec_test-0.3.3 → spec_test-0.4.0}/src/spec_test/reporter.py +18 -2
  93. spec_test-0.4.0/src/spec_test/runner.py +213 -0
  94. spec_test-0.4.0/src/spec_test/skills/README.md +14 -0
  95. spec_test-0.4.0/src/spec_test/skills/spec-feature/SKILL.md +25 -0
  96. {spec_test-0.3.3 → spec_test-0.4.0}/src/spec_test/skills/spec-implement/SKILL.md +21 -0
  97. spec_test-0.4.0/src/spec_test/skills/spec-issue/SKILL.md +8 -0
  98. spec_test-0.4.0/src/spec_test/skills/spec-review/SKILL.md +13 -0
  99. {spec_test-0.3.3 → spec_test-0.4.0}/src/spec_test/skills/spec-verify/SKILL.md +36 -4
  100. spec_test-0.4.0/src/spec_test/skills/spec-workflow/SKILL.md +17 -0
  101. spec_test-0.4.0/src/spec_test/templates/starter-feature.md +21 -0
  102. spec_test-0.4.0/src/spec_test/trace.py +110 -0
  103. {spec_test-0.3.3 → spec_test-0.4.0}/src/spec_test/types.py +25 -3
  104. spec_test-0.4.0/src/spec_test/verification_scope.py +49 -0
  105. spec_test-0.4.0/src/spec_test/verifier.py +111 -0
  106. {spec_test-0.3.3 → spec_test-0.4.0}/tests/test_cli.py +17 -12
  107. spec_test-0.4.0/tests/test_direct.py +185 -0
  108. spec_test-0.4.0/tests/test_docs_export.py +97 -0
  109. spec_test-0.4.0/tests/test_dogfood_evidence.py +57 -0
  110. spec_test-0.4.0/tests/test_downstream.py +121 -0
  111. spec_test-0.4.0/tests/test_downstream_controls.py +166 -0
  112. spec_test-0.4.0/tests/test_evidence.py +305 -0
  113. spec_test-0.4.0/tests/test_example_workflow.py +61 -0
  114. {spec_test-0.3.3 → spec_test-0.4.0}/tests/test_git_workflow.py +104 -3
  115. spec_test-0.4.0/tests/test_impact.py +128 -0
  116. spec_test-0.4.0/tests/test_proof_cli_policy.py +53 -0
  117. spec_test-0.4.0/tests/test_property_cli.py +224 -0
  118. spec_test-0.4.0/tests/test_property_testing.py +233 -0
  119. spec_test-0.4.0/tests/test_prover.py +735 -0
  120. spec_test-0.4.0/tests/test_repo_plan.py +123 -0
  121. spec_test-0.4.0/tests/test_required_scenarios.py +150 -0
  122. spec_test-0.4.0/tests/test_trace.py +106 -0
  123. {spec_test-0.3.3 → spec_test-0.4.0}/uv.lock +220 -2
  124. spec_test-0.4.0/verification/domain-rule-workflow.json +41 -0
  125. spec_test-0.3.3/.claude/skills/README.md +0 -177
  126. spec_test-0.3.3/.claude/skills/spec-feature.md +0 -209
  127. spec_test-0.3.3/.claude/skills/spec-implement.md +0 -546
  128. spec_test-0.3.3/.claude/skills/spec-issue.md +0 -216
  129. spec_test-0.3.3/.claude/skills/spec-review.md +0 -274
  130. spec_test-0.3.3/.claude/skills/spec-verify.md +0 -256
  131. spec_test-0.3.3/.claude/skills/spec-workflow.md +0 -297
  132. spec_test-0.3.3/CLAUDE.md +0 -71
  133. spec_test-0.3.3/PKG-INFO +0 -426
  134. spec_test-0.3.3/README.md +0 -404
  135. spec_test-0.3.3/design/issues/003-hypothesis-integration.md +0 -94
  136. spec_test-0.3.3/src/spec_test/cli.py +0 -714
  137. spec_test-0.3.3/src/spec_test/collector.py +0 -134
  138. spec_test-0.3.3/src/spec_test/prover.py +0 -507
  139. spec_test-0.3.3/src/spec_test/runner.py +0 -167
  140. spec_test-0.3.3/src/spec_test/skills/README.md +0 -177
  141. spec_test-0.3.3/src/spec_test/skills/spec-feature/SKILL.md +0 -212
  142. spec_test-0.3.3/src/spec_test/skills/spec-issue/SKILL.md +0 -219
  143. spec_test-0.3.3/src/spec_test/skills/spec-review/SKILL.md +0 -277
  144. spec_test-0.3.3/src/spec_test/skills/spec-workflow/SKILL.md +0 -300
  145. spec_test-0.3.3/src/spec_test/verifier.py +0 -120
  146. spec_test-0.3.3/tests/test_prover.py +0 -267
  147. {spec_test-0.3.3 → spec_test-0.4.0}/.github/workflows/publish.yml +0 -0
  148. {spec_test-0.3.3 → spec_test-0.4.0}/.gitignore +0 -0
  149. {spec_test-0.3.3 → spec_test-0.4.0}/design/issues/001-core-spec-test.md +0 -0
  150. {spec_test-0.3.3 → spec_test-0.4.0}/design/issues/001-example.md +0 -0
  151. {spec_test-0.3.3 → spec_test-0.4.0}/design/issues/002-runtime-contracts.md +0 -0
  152. {spec_test-0.3.3 → spec_test-0.4.0}/design/issues/004-z3-formal-proofs.md +0 -0
  153. {spec_test-0.3.3 → spec_test-0.4.0}/design/issues/006-git-workflow-integration.md +0 -0
  154. {spec_test-0.3.3 → spec_test-0.4.0}/design/prompts/migrate-v1-to-v2.md +0 -0
  155. {spec_test-0.3.3 → spec_test-0.4.0}/design/specs/contracts.md +0 -0
  156. {spec_test-0.3.3 → spec_test-0.4.0}/design/specs/spec-spec-test.md +0 -0
  157. {spec_test-0.3.3 → spec_test-0.4.0}/prompt.md +0 -0
  158. {spec_test-0.3.3 → spec_test-0.4.0}/src/spec_test/contracts.py +0 -0
  159. {spec_test-0.3.3 → spec_test-0.4.0}/src/spec_test/pytest_plugin.py +0 -0
  160. {spec_test-0.3.3 → spec_test-0.4.0}/tests/__init__.py +0 -0
  161. {spec_test-0.3.3 → spec_test-0.4.0}/tests/conftest.py +0 -0
  162. {spec_test-0.3.3 → spec_test-0.4.0}/tests/test_collector.py +0 -0
  163. {spec_test-0.3.3 → spec_test-0.4.0}/tests/test_contracts.py +0 -0
  164. {spec_test-0.3.3 → spec_test-0.4.0}/tests/test_decorators.py +0 -0
  165. {spec_test-0.3.3 → spec_test-0.4.0}/tests/test_reporter.py +0 -0
  166. {spec_test-0.3.3 → spec_test-0.4.0}/tests/test_runner.py +0 -0
  167. {spec_test-0.3.3 → spec_test-0.4.0}/tests/test_verifier.py +0 -0
@@ -0,0 +1 @@
1
+ ../../src/spec_test/skills/README.md
@@ -0,0 +1 @@
1
+ ../../src/spec_test/skills/spec-feature/SKILL.md
@@ -0,0 +1 @@
1
+ ../../src/spec_test/skills/spec-implement/SKILL.md
@@ -0,0 +1 @@
1
+ ../../src/spec_test/skills/spec-issue/SKILL.md
@@ -0,0 +1 @@
1
+ ../../src/spec_test/skills/spec-review/SKILL.md
@@ -0,0 +1 @@
1
+ ../../src/spec_test/skills/spec-verify/SKILL.md
@@ -0,0 +1 @@
1
+ ../../src/spec_test/skills/spec-workflow/SKILL.md
@@ -0,0 +1,83 @@
1
+ name: Verify
2
+
3
+ on:
4
+ pull_request:
5
+ push:
6
+ branches: [main]
7
+
8
+ permissions:
9
+ contents: read
10
+
11
+ jobs:
12
+ verification:
13
+ runs-on: ubuntu-latest
14
+ steps:
15
+ - uses: actions/checkout@v4
16
+ - uses: astral-sh/setup-uv@v4
17
+ - uses: actions/setup-node@v4
18
+ with:
19
+ node-version: '24'
20
+ - name: Install zsh for shell portability checks
21
+ run: |
22
+ sudo apt-get update -qq
23
+ sudo apt-get install -y --no-install-recommends zsh
24
+ - name: Python without optional engines
25
+ run: uv run --locked pytest -q
26
+ - name: Python with Z3 and Hypothesis
27
+ run: uv run --locked --extra all pytest -q
28
+ - name: Rust tests and evidence
29
+ run: |
30
+ cargo test --locked --workspace --manifest-path adapters/rust/Cargo.toml
31
+ uv run --locked python adapters/rust/verify_scenarios.py > "$RUNNER_TEMP/rust-evidence.json"
32
+ - name: Validate Rust source links
33
+ run: |
34
+ mapfile -d '' -t sources < <(git ls-files -z -- 'adapters/rust/src/*.rs')
35
+ cargo run --locked --quiet --manifest-path adapters/rust/Cargo.toml \
36
+ -p spec-test-rust-trace -- "${sources[@]}" > "$RUNNER_TEMP/rust-trace.json"
37
+ uv run --locked spec-test trace --specs design/specs/queue-only \
38
+ --index "$RUNNER_TEMP/rust-trace.json" --require QUEUE-001
39
+ - name: Optional proof adapter parser tests
40
+ run: uv run --locked python -m unittest discover -s adapters/rust -p 'test_verify_*.py'
41
+ - name: TypeScript tests and evidence
42
+ run: |
43
+ npm --prefix adapters/typescript ci --no-audit --no-fund
44
+ npm --prefix adapters/typescript run verify
45
+ uv run --locked pytest -q tests/test_direct.py::test_actual_vitest_source_index_runs_exact_helper
46
+ - name: Validate TypeScript source links
47
+ run: |
48
+ node --test adapters/typescript/trace.test.mjs
49
+ node adapters/typescript/trace.mjs adapters/typescript/src/queue.ts \
50
+ adapters/typescript/test/queue.test.ts > "$RUNNER_TEMP/ts-trace.json"
51
+ uv run --locked spec-test trace --specs design/specs/queue-only \
52
+ --index "$RUNNER_TEMP/ts-trace.json" --require QUEUE-001
53
+ uv run --locked spec-test trace --specs design/specs/queue-only \
54
+ --index "$RUNNER_TEMP/rust-trace.json" --index "$RUNNER_TEMP/ts-trace.json" \
55
+ --require QUEUE-001
56
+ - name: Combine the actual native receipts
57
+ run: |
58
+ uv run --locked spec-test verify --require-issues --specs design/specs/queue-only \
59
+ --evidence "$RUNNER_TEMP/rust-evidence.json" \
60
+ --evidence adapters/typescript/.vitest/spec-evidence.json
61
+ - name: Verify the reviewed supported requirements
62
+ run: |
63
+ uv run --locked --extra all spec-test verify --require-issues \
64
+ --scope design/verification-scope.toml \
65
+ --evidence "$RUNNER_TEMP/rust-evidence.json" \
66
+ --evidence adapters/typescript/.vitest/spec-evidence.json
67
+ - name: Exercise Receiving across a process restart
68
+ run: |
69
+ cd examples/receiving
70
+ PYTHONPATH=. uv run --locked pytest -q tests
71
+ PYTHONPATH=. uv run --locked spec-test verify --require-features
72
+ uv run --locked spec-test docs export
73
+ - name: Verify a runnable example with an installed package
74
+ run: |
75
+ export UV_PROJECT_ENVIRONMENT="$RUNNER_TEMP/spec-test-example-env"
76
+ uv sync --locked --extra all --no-editable --no-dev
77
+ cd examples/work-budget
78
+ export PYTHONPATH=.
79
+ test "$("$UV_PROJECT_ENVIRONMENT/bin/python" -m work_budget 7 3 8 2)" \
80
+ = '{"allocations": [3, 4, 0], "remaining": 0}'
81
+ "$UV_PROJECT_ENVIRONMENT/bin/spec-test" verify --require-issues \
82
+ --proofs --proof-module work_budget --fail-on-unknown \
83
+ --evidence-output "$RUNNER_TEMP/work-budget-evidence.json"
@@ -0,0 +1,32 @@
1
+ # Spec-test agent instructions
2
+
3
+ Write new features in `design/features/<bounded-context>/<feature>.md`. Start with **User intent**, name the domain rules, and describe the observations and assumptions under which each rule holds. Use the existing owner and retain its rule ID when changing behavior. Legacy specs, issues and architectural decisions remain linkable.
4
+
5
+ Use `spec-feature` and the Nessa `spec-test` skill to prepare the plan and its independent adversarial review. Link each required scenario to an executed check. The code reviewer uses the accepted intent, obligations, implementation and observed results. Follow `spec-review` for the handoff. Record review decisions in the feature and evidence in verification output.
6
+
7
+ ```markdown
8
+ - **CART-001**: Opening a confirmed order shows the agreed price.
9
+ Required scenarios: open-after-confirmation, open-after-price-change
10
+ ```
11
+
12
+ ```python
13
+ @spec("CART-001", "Retain the agreed price", scenario="open-after-price-change")
14
+ def test_agreed_price_survives_price_change():
15
+ ...
16
+ ```
17
+
18
+ Run `spec-test list-specs` to discover rules, `spec-test verify` to reconcile results and `spec-test docs export` to render feature plans in Nessa Docs. Use `spec-test plan` for native check discovery.
19
+
20
+ ## Versioning
21
+
22
+ Follow semantic versioning (0.MINOR.PATCH) in pre-1.0:
23
+
24
+ - **PATCH** (0.x.Y): Bug fixes, performance improvements, refactoring
25
+ - **MINOR** (0.X.0): New features, breaking changes (API changes)
26
+ - **MAJOR** (X.0.0): Reserved for 1.0.0+ stable release
27
+
28
+ Examples:
29
+ - Performance optimization: 0.3.3 → 0.3.4 ✓
30
+ - Bug fix: 0.3.3 → 0.3.4 ✓
31
+ - New feature: 0.3.3 → 0.4.0 ✓
32
+ - Breaking change: 0.3.3 → 0.4.0 ✓
@@ -0,0 +1,509 @@
1
+ Metadata-Version: 2.5
2
+ Name: spec-test
3
+ Version: 0.4.0
4
+ Summary: Make AI-generated code trustworthy through mathematical verification
5
+ Author: Pulse Team
6
+ License: MIT
7
+ Requires-Python: >=3.11
8
+ Requires-Dist: filelock>=3.13
9
+ Requires-Dist: pydantic>=2.0.0
10
+ Requires-Dist: pytest-cov>=4.0.0
11
+ Requires-Dist: pytest>=8.0.0
12
+ Requires-Dist: pyyaml>=6.0
13
+ Requires-Dist: rich>=13.0.0
14
+ Requires-Dist: typer>=0.9.0
15
+ Provides-Extra: all
16
+ Requires-Dist: hypothesis<7,>=6.100; extra == 'all'
17
+ Requires-Dist: z3-solver>=4.12.0; extra == 'all'
18
+ Provides-Extra: dev
19
+ Requires-Dist: mypy>=1.0.0; extra == 'dev'
20
+ Requires-Dist: pytest-cov>=4.0.0; extra == 'dev'
21
+ Requires-Dist: ruff>=0.1.0; extra == 'dev'
22
+ Provides-Extra: hypothesis
23
+ Requires-Dist: hypothesis<7,>=6.100; extra == 'hypothesis'
24
+ Provides-Extra: z3
25
+ Requires-Dist: z3-solver>=4.12.0; extra == 'z3'
26
+ Description-Content-Type: text/markdown
27
+
28
+ # spec-test
29
+
30
+ Spec-test links the behavior a user asks for to the plan, implementation and checks that exercise it. Write each independently checkable domain rule once, give it a stable ID, and name the scenarios the rule requires. Review the plan and code against that intent. Verification reports the evidence for each rule and any missing or failing cases.
31
+
32
+ ## Quick Start
33
+
34
+ Want to run a complete project first? Start with [the work-budget example](examples/work-budget/),
35
+ which links an implementation to written requirements, tests, and a scoped Z3 proof.
36
+ The [examples index](examples/) also points to the Rust and TypeScript adapter projects.
37
+
38
+ ### Installation
39
+
40
+ ```bash
41
+ pip install spec-test
42
+
43
+ # With Z3 formal proofs (optional)
44
+ pip install spec-test[z3]
45
+ ```
46
+
47
+ ### 1. Initialize Project
48
+
49
+ ```bash
50
+ spec-test init
51
+ ```
52
+
53
+ A fresh project gets a feature in `design/features/verification/verify-starter.md`, an agent guide, and the spec-test workflow skills.
54
+
55
+ ### 2. Write the feature
56
+
57
+ Keep its intent, domain rules, plan and review in one Markdown file such as `design/features/identity/sign-in.md`. Use an existing rule ID when the behavior already has an owner. Historical `design/issues/`, `design/specs/` and ADR links can remain at their original paths.
58
+
59
+ ```markdown
60
+ # Sign in
61
+
62
+ ## User intent
63
+
64
+ A returning customer can open their account with valid credentials. A failed attempt should leave the account signed out.
65
+
66
+ ## Requirements
67
+
68
+ - **AUTH-001**: A customer with valid credentials can sign in.
69
+ Required scenarios: valid-credentials
70
+ - **AUTH-002**: Invalid credentials leave the account signed out.
71
+
72
+ ## Plan
73
+
74
+ - [ ] `check-credentials` Exercise the supported sign-in entry point.
75
+ - [ ] `check-account-access` Read the account as the caller after each outcome.
76
+
77
+ ## Adversarial review
78
+
79
+ A handler could return success and issue a token that never opens the account. Exercise the account read with the issued token.
80
+ ```
81
+
82
+ Review each plan against the original request before implementing. Use `spec-test docs export` to project it into the Nessa Docs reader.
83
+
84
+ ### 3. Implement with Tests
85
+
86
+ ```python
87
+ from spec_test import spec
88
+
89
+ @spec("AUTH-001", "User can login with valid email and password", scenario="valid-credentials")
90
+ def test_login_success():
91
+ result = login("user@example.com", "password123")
92
+ assert result.success
93
+ assert result.token is not None
94
+ ```
95
+
96
+ ### 4. Add Runtime Contracts
97
+
98
+ ```python
99
+ from spec_test import contract
100
+
101
+ @contract(
102
+ spec="AUTH-001",
103
+ requires=[
104
+ lambda email, password: "@" in email,
105
+ lambda email, password: len(password) >= 8,
106
+ ],
107
+ ensures=[
108
+ lambda result: result.token is not None,
109
+ ],
110
+ )
111
+ def login(email: str, password: str) -> LoginResult:
112
+ user = db.get_user(email)
113
+ if verify_password(password, user.password_hash):
114
+ return LoginResult(success=True, token=generate_jwt(user))
115
+ return LoginResult(success=False, token=None)
116
+ ```
117
+
118
+ ### 5. Verify
119
+
120
+ ```bash
121
+ $ spec-test verify
122
+
123
+ ╭─────────────────────────────────────────╮
124
+ │ Specification Verification Report │
125
+ ╰─────────────────────────────────────────╯
126
+
127
+ ✓ AUTH-001: A customer with valid credentials can sign in.
128
+ ! AUTH-002: No test
129
+ ```
130
+
131
+ ## Architecture: Functional Core, Imperative Shell
132
+
133
+ All code should follow this pattern with **Dependency Injection**:
134
+
135
+ ```
136
+ ┌─────────────────────────────────────────────────────────────┐
137
+ │ Imperative Shell │
138
+ │ (thin layer, injected dependencies) │
139
+ │ ┌───────────────────────────────────────────────────────┐ │
140
+ │ │ Functional Core │ │
141
+ │ │ (pure functions, all business logic) │ │
142
+ │ │ │ │
143
+ │ │ • Deterministic (same input → same output) │ │
144
+ │ │ • No side effects │ │
145
+ │ │ • Easy to test (unit tests) │ │
146
+ │ │ • Can be formally proven (Z3) │ │
147
+ │ └───────────────────────────────────────────────────────┘ │
148
+ │ │
149
+ │ • Database, Email, API calls via DI │
150
+ │ • Testable with mocks │
151
+ │ • Integration tests verify real I/O │
152
+ └─────────────────────────────────────────────────────────────┘
153
+ ```
154
+
155
+ ### Example
156
+
157
+ ```python
158
+ # FUNCTIONAL CORE: Pure function, no dependencies
159
+ def calculate_total(items: list[Item]) -> Decimal:
160
+ return sum(item.price * item.quantity for item in items)
161
+
162
+ # IMPERATIVE SHELL: Thin layer with injected dependencies
163
+ class OrderService:
164
+ def __init__(self, db: Database, email: EmailSender): # DI
165
+ self.db = db
166
+ self.email = email
167
+
168
+ def place_order(self, items: list[Item]) -> Order:
169
+ total = calculate_total(items) # Call pure function
170
+ order = Order(items=items, total=total)
171
+ self.db.save(order) # Injected dependency
172
+ self.email.send_confirmation() # Injected dependency
173
+ return order
174
+ ```
175
+
176
+ ### Testing Strategy
177
+
178
+ ```
179
+ ┌─────────────┬────────────────┬─────────────────────┬───────────┐
180
+ │ Test Type │ What │ How │ Speed │
181
+ ├─────────────┼────────────────┼─────────────────────┼───────────┤
182
+ │ Unit │ Pure functions │ Direct call │ Fast (ms) │
183
+ ├─────────────┼────────────────┼─────────────────────┼───────────┤
184
+ │ Mock │ Service wiring │ Inject mocks via DI │ Fast (ms) │
185
+ ├─────────────┼────────────────┼─────────────────────┼───────────┤
186
+ │ Integration │ Real I/O works │ Real DB/API │ Slow (s) │
187
+ └─────────────┴────────────────┴─────────────────────┴───────────┘
188
+ ```
189
+
190
+ **Aim for ~90% unit/mock tests, ~10% integration tests.**
191
+
192
+ ## Verification Types
193
+
194
+ Mark specs with verification type in brackets:
195
+
196
+ | Type | Meaning |
197
+ |------|---------|
198
+ | (none) | Automated unit test |
199
+ | `[integration]` | Integration test (real I/O) |
200
+ | `[manual]` | Manual human verification |
201
+ | `[contract]` | Runtime contract verification |
202
+ | `[provable]` | Z3 formal proof |
203
+
204
+ ```markdown
205
+ - **AUTH-001**: User can login (unit test)
206
+ - **AUTH-010** [integration]: Session persists to database
207
+ - **AUTH-020** [manual]: UI follows brand guidelines
208
+ - **AUTH-030** [provable]: Token expiry is always positive
209
+ ```
210
+
211
+ ## Runtime Contracts
212
+
213
+ ### Basic Contract
214
+
215
+ ```python
216
+ from spec_test import contract
217
+
218
+ @contract(
219
+ spec="CART-001",
220
+ requires=[lambda items: len(items) > 0],
221
+ ensures=[lambda result: result >= 0],
222
+ )
223
+ def calculate_total(items: list[Item]) -> Decimal:
224
+ return sum(item.price * item.quantity for item in items)
225
+ ```
226
+
227
+ ### With Invariants
228
+
229
+ ```python
230
+ @contract(
231
+ spec="CART-002",
232
+ requires=[lambda items, discount: discount >= 0],
233
+ ensures=[lambda result: result >= 0],
234
+ invariants=[lambda items, discount: discount <= 100],
235
+ )
236
+ def apply_discount(items: list[Item], discount: int) -> Decimal:
237
+ total = calculate_total(items)
238
+ return total * (1 - discount / 100)
239
+ ```
240
+
241
+ ### Comparing Pre/Post State with `old()`
242
+
243
+ ```python
244
+ from spec_test import contract, Old
245
+
246
+ @contract(
247
+ spec="LIST-001",
248
+ capture_old=True,
249
+ ensures=[lambda result, old: len(result) == len(old.items) + 1],
250
+ )
251
+ def append_item(items: list, item) -> list:
252
+ return items + [item]
253
+ ```
254
+
255
+ ## Z3 Formal Proofs
256
+
257
+ For mathematical verification of pure functions:
258
+
259
+ ```bash
260
+ pip install spec-test[z3]
261
+ ```
262
+
263
+ ```python
264
+ # my_package/proofs.py (must be importable)
265
+ from spec_test import provable, contract
266
+
267
+ @provable(spec="MATH-001")
268
+ @contract(
269
+ requires=[lambda x, y: x >= 0, lambda x, y: y >= 0],
270
+ ensures=[lambda result: result >= 0],
271
+ )
272
+ def add_positive(x: int, y: int) -> int:
273
+ return x + y
274
+ ```
275
+
276
+ ```bash
277
+ $ spec-test verify --proofs --proof-module my_package.proofs --fail-on-unknown
278
+
279
+ ╭─────────────────────────────────────╮
280
+ │ Proof Verification Summary │
281
+ ╰─────────────────────────────────────╯
282
+ Proven: 1 | Refuted: 0 | Unknown: 0 | Skipped: 0
283
+ ```
284
+
285
+ The proof subset uses explicit Python `int` and `bool` values, including
286
+ arithmetic (`+`, `-`, `*`), comparisons, Boolean logic, and ternaries. Pure
287
+ `if`/`elif`/`else` statements and early returns are supported when every
288
+ structural path returns the declared type. Z3 checks the actual modeled return against every
289
+ postcondition, under every precondition. Unsupported code or predicates and
290
+ contradictory preconditions never count as proved. A refutation prints the input
291
+ values. Runtime checks remain on. Use `--fail-on-unknown` in CI to reject skipped
292
+ and unknown proofs as well as refutations. Only import proof modules you trust:
293
+ they run normal Python import code.
294
+
295
+ ## For AI Agents
296
+
297
+ spec-test is designed for AI-assisted development.
298
+
299
+ ### Workflow
300
+
301
+ ```
302
+ User intent → Draft rules and plan → Independent adversarial review → Implement → Verify
303
+ ```
304
+
305
+ The feature owns the user's intent, rule definitions, required scenarios and plan. Have a fresh reviewer read the original request and the actual feature. The [Nessa spec-test skill](https://github.com/nessalabs/skills/tree/wip/skills/engineering/spec-test) guides independent plan review. Give the code reviewer those same obligations and the observed evidence alongside the [Nessa pull-requests skill](https://github.com/nessalabs/skills/tree/wip/skills/engineering/pull-requests). Record findings in the existing feature and code review. See the [review workflow](src/spec_test/skills/spec-review/SKILL.md) and [Nessa installation options](https://github.com/nessalabs/skills#installation).
306
+
307
+ ### AI Agent Skills
308
+
309
+ Initialize with skills for Claude:
310
+
311
+ ```bash
312
+ spec-test init
313
+ ```
314
+
315
+ Installs skills to `.claude/skills/`:
316
+ - `spec-workflow/SKILL.md` - Complete development workflow
317
+ - `spec-issue/SKILL.md` - Following historical issue briefs
318
+ - `spec-feature/SKILL.md` - Writing user intent, rules and the feature plan
319
+ - `spec-review/SKILL.md` - Independent plan and code review
320
+ - `spec-implement/SKILL.md` - Implementation with architecture principles
321
+ - `spec-verify/SKILL.md` - Running verification
322
+
323
+ ## Commands
324
+
325
+ ```bash
326
+ spec-test verify # Verify all specs have passing tests
327
+ spec-test verify --proofs --proof-module my_package.proofs --fail-on-unknown
328
+ spec-test verify --coverage # Include code coverage analysis
329
+ spec-test list-specs # List all specifications
330
+ spec-test list-specs -i # Show related planning links for each rule
331
+ spec-test docs export --root . # Render feature plans for Nessa Docs
332
+ spec-test impact HEAD~1 HEAD # Explain changed rules across committed revisions
333
+ spec-test check AUTH-001 # Verify single spec
334
+ spec-test init # Initialize spec-test in a project
335
+ spec-test context # Output CLAUDE.md for LLM context
336
+ ```
337
+
338
+ ## Browse a feature plan and explain a change
339
+
340
+ Edit the feature under `design/features/<context>/`, then run `spec-test docs export --root .` and open that project in Nessa Docs. The Details view shows the intent, assumptions and review from the brief. Give a checklist item under `## Plan` a stable ID (for example, ``- [ ] \`record-delivery\` Record the accepted delivery``) to put it in the native Work view. Task progress belongs in Nessa Docs' work records. Export creates proposed pages and preserves project-owned pages and reference settings. A generated page that someone edits raises a conflict on the next export. Source briefs remain the place to revise a plan.
341
+
342
+ For change explanations, declare the dependencies you know in `design/impact.toml`. The [Receiving map](examples/receiving/design/impact.toml) links the receipt writer to stored receipts, the stock reader and the inventory rule. Run `spec-test impact BASE HEAD --root PROJECT` on two commits. Read the old and new paths, the required scenarios, and the reported gaps. Entity comparisons currently cover Python declarations. File and declared state edges can cross other source files within the project. Dynamic calls, external services and environmental inputs require explicit knowledge. Keep full CI while evaluating selective execution against failing changes.
343
+
344
+ ## Roadmap
345
+
346
+ > **Note:** spec-test is in active development.
347
+
348
+ - [x] Spec-to-test linking with `@spec` decorator
349
+ - [x] Runtime contracts with `@contract` (requires/ensures/invariants)
350
+ - [x] `old()` support for comparing pre/post state
351
+ - [x] Z3 proofs for single-return integer/Boolean functions
352
+ - [ ] Broader proof support and per-spec proof evidence in the main report
353
+ - [x] Feature-first workflow with `design/features/<bounded-context>/`
354
+ - [x] AI agent skills
355
+ - [ ] Hypothesis property testing integration
356
+ - [ ] Spec coverage reporting
357
+
358
+ ## Contributing
359
+
360
+ ```bash
361
+ git clone https://github.com/Varuas37/spec-test.git
362
+ cd spec-test
363
+ uv sync
364
+
365
+ # Run tests
366
+ uv run pytest
367
+
368
+ # Dogfood check: verify the real evidence reconciler
369
+ uv run --locked --extra all spec-test check EVID-012
370
+ ```
371
+
372
+ spec-test uses its own CLI in [CI](.github/workflows/verify.yml) to verify this
373
+ repository's supported requirements, including fresh Rust and TypeScript receipts.
374
+ The [evidence requirements](design/specs/verification-evidence.md) and their tests cover
375
+ how the actual verifier decides which evidence can satisfy a requirement. The
376
+ [scope file](design/verification-scope.toml) records what is still deferred, rather than
377
+ counting that work as verified.
378
+
379
+ ## License
380
+
381
+ MIT
382
+
383
+ ## Verification evidence and native adapter pilots
384
+
385
+ A spec tagged `[property]`, `[provable]`, or `[model]` requires the matching kind
386
+ of evidence. Untagged requirements expect tests. A model proof is not an
387
+ implementation proof. An expected failure, skipped case, or missing test run
388
+ does not satisfy an automated requirement. When more than one check is linked,
389
+ a failing check cannot be hidden by another passing one.
390
+
391
+ - `spec-test verify --require-issues` checks that every requirement has an existing
392
+ local issue link. Without the flag, missing or broken links are warnings.
393
+ - `spec-test verify --evidence path.json --evidence-output combined.json` consumes
394
+ an explicitly trusted runner receipt and exports the observed results. Supply
395
+ fresh receipts from the same checkout. The schema validates shape and refuses
396
+ duplicates, but does not authenticate the runner or source revision.
397
+ - `spec-test verify --scope design/verification-scope.toml` keeps the full report
398
+ and enforces strict evidence for the supported requirements. This project's
399
+ [reviewed scope](design/verification-scope.toml) lists the exact deferred IDs
400
+ and reasons. Deferrals neither pass nor disappear; a new missing requirement,
401
+ unexpected evidence for a deferred ID, a linked failure, or inconclusive
402
+ required evidence still blocks. Plain `verify` without the scope continues to require evidence
403
+ for the entire automated roadmap. Treat scope edits as product decisions
404
+ in code review, not a way to dismiss regressions.
405
+ - `spec-test review-packet --output review.json` exports manual and
406
+ `[ai_review]` requirements and optional hints. It calls no AI service and does
407
+ not mark anything as passed. Review those items against the exact commit or
408
+ artifact you inspected. In your PR or review log, record the revision,
409
+ `spec_id`, `review_input_sha256`, reviewer, observation, and disposition
410
+ (accepted, rejected, or not inspected). Re-export if the inputs change.
411
+ The digest identifies the exported item, not the source revision or reviewer.
412
+ Any AI suggestion is a draft until a human checks it. Do not pass this log
413
+ or the packet to `verify --evidence`: manual decisions stay outside automated
414
+ coverage.
415
+
416
+ Install `spec-test[hypothesis]` for generated implementation checks:
417
+
418
+ ```python
419
+ from spec_test import property_test
420
+
421
+ @property_test("MATH-020", "Doubling produces an even integer")
422
+ def test_even(x: int):
423
+ assert (2 * x) % 2 == 0
424
+ ```
425
+
426
+ The adapter accepts explicit Hypothesis strategies and settings, and keeps its
427
+ native shrinking and replay. It does not turn generated tests into proofs.
428
+
429
+ The [Rust](adapters/rust/) and [TypeScript](adapters/typescript/) pilots verify
430
+ the same [queue admission requirement](design/specs/queue-only/queue.md).
431
+ They produce the same receipt format without using the same test runner. Rust
432
+ also supplies a separately runnable Kani harness; the ordinary Rust receipt
433
+ marks it skipped. TypeScript checks the real implementation without claiming
434
+ a TypeScript solver proof.
435
+
436
+ ## Plan and run repository checks
437
+
438
+ From a Python, Rust or TypeScript project root:
439
+
440
+ ```sh
441
+ spec-test plan
442
+ spec-test run-checks --trust-repo
443
+ ```
444
+
445
+ `plan` only inspects manifests and prints the chosen commands as JSON. It
446
+ recognizes pytest, Cargo packages/workspaces, and Node packages with a test
447
+ script (using the declared package manager or an unambiguous lockfile).
448
+ Use `--root path` to inspect a subproject. Inspect the plan before running.
449
+ `run-checks` executes repository code, is not a sandbox, and does not install
450
+ dependencies. Only pass `--trust-repo` on a checkout you intend to execute.
451
+
452
+ For a monorepo, an unusual test setup, or a custom command, save a starter
453
+ with `spec-test plan --write-config` (never overwrites), or commit a
454
+ `spec-test.toml` with version 1 and one record per check:
455
+
456
+ ```toml
457
+ schema_version = 1
458
+
459
+ [[checks]]
460
+ id = "web"
461
+ language = "typescript"
462
+ cwd = "packages/web"
463
+ argv = ["pnpm", "test"]
464
+ ```
465
+
466
+ Use repository-relative working directories and argument arrays. An agent can
467
+ inspect or propose this config without executing anything. A native command
468
+ passing is not a spec-level receipt; use `spec-test verify --evidence …` for
469
+ requirement outcomes and optional prover receipts.
470
+
471
+ ### Run tests directly linked to changed files
472
+
473
+ From the project root, generate a current v1 trace index and pass it to the existing runner. This example uses the TypeScript pilot after its dependencies have been installed.
474
+
475
+ ```sh
476
+ node adapters/typescript/trace.mjs adapters/typescript/src/queue.ts \
477
+ adapters/typescript/test/queue.test.ts > /tmp/spec-test-ts-index.json
478
+ spec-test run-checks --since HEAD --index /tmp/spec-test-ts-index.json --trust-repo
479
+ ```
480
+
481
+ `--since HEAD` compares HEAD with the working tree. Use a base commit or a merge base to include committed branch changes. The command includes untracked, non-ignored files under `--root` and considers both names on a rename. Trace paths are relative to that root. Repeat `--index` for additional current indexes and keep generated indexes outside the checkout or in an ignored directory.
482
+
483
+ For each changed implementation file, spec-test runs the verification symbols linked to its rule IDs in the same language. For a changed verification file, it runs the indexed verification symbols in that file. A target reached multiple times executes once. Output names the changed path, rule, native test and outcome. Direct selection depends on the supplied index; v1 has no revision or completeness attestation, and this command follows no downstream dependencies.
484
+
485
+ The TypeScript runner supports the pilot’s top-level `specTest` and `specProperty` calls in packages with the plain `vitest run` test script and Vitest 4 installed. Python accepts supplied v1 rows with language `python` and exact pytest symbols such as `test_release` or `TestRelease::test_paid`, including their collected parameterizations. The repository ships source-index producers for TypeScript and Rust. Rust/Kani proof symbols, arbitrary annotated helpers and custom runner commands currently report incomplete. Use the normal project verification workflow for these.
486
+
487
+ Exit **0** means the directly selected tests ran and passed. Exit **1** means a selected run failed. Exit **2** means empty, incomplete, or invalid selection, including unmapped files and skipped or missing targets. On a mixed diff the mapped tests still run and every unmapped path is printed. To execute the ordinary native plan, omit both `--since` and `--index`.
488
+
489
+ ### Execute downstream rules affected by a Git diff
490
+
491
+ ```sh
492
+ spec-test run-checks --root . --since HEAD --impact --trust-repo --result-json /tmp/impact-result.json
493
+ ```
494
+
495
+ A changed writer can break an unchanged reader. This mode follows the dependency paths in both the base commit and the working tree, including declared state, event, and configuration dependencies. It prints the paths, runs each affected rule's collected pytest cases (including parameterizations), and records the observed test IDs and outcomes.
496
+
497
+ A project can attest that it has reviewed the downstream dependencies of specific files. In `design/impact.toml`, list those filenames before the dependency table. For example:
498
+
499
+ ```toml
500
+ closed_files = ["writer.py"]
501
+ [depends_on]
502
+ "state:receipts" = ["writer.py::record"]
503
+ "reader.py::count" = ["state:receipts"]
504
+ "READ-001" = ["reader.py::count"]
505
+ ```
506
+
507
+ This declaration is a maintained assertion about the project. An undeclared database reader, callback or remote service can invalidate it. Only claim closure when all consumer rules are represented. A narrower run requires closure for every changed file on both sides, a dependency path to a known rule, required scenarios in the spec, and runnable pytest bindings. An opaque change, modified dependency map or incomplete inventory widens execution to the configured native project suite. Pytest can account for tests it collects or explicitly deselects. A custom collector that silently hides an undeclared variant before discovery falls outside this guarantee. Coverage ends at the configured project boundary. External services need their own checks or a configured cross-service test.
508
+
509
+ The JSON distinguishes selected execution and full fallback, gives the reasons, and names tests that actually reached the call phase. Exit 1 means a check failed. Exit 2 means evidence is incomplete or no tests ran. Selective downstream execution currently supports pytest. Rust, TypeScript and custom plans run through their existing commands on fallback and lack per-scenario receipts in this mode.