Spec Loop Closer
Prerequisites & Dependencies
- Python 3.10+ (for assertion mapping logic)
- Access to project source files and test directories
- No external runtime dependencies
Execution Steps
Materialize requirements: Parse the user's original request/task description and extract each distinct requirement/acceptance criterion.
Map to checkable assertions: For each requirement, define a machine-verifiable check:
- Grep-able token: A unique string that can be found with
grepin the implemented code - Executable test: A pytest/unit test that passes/fails based on the requirement
- Numeric threshold: A specific value that can be computed and compared (e.g., "response time < 200ms")
- Enum/constraint check: A field that must match one of a set of allowed values
- Grep-able token: A unique string that can be found with
Create assertion mapping table: Produce a structured table listing:
- Requirement ID (auto-generated or user-assigned)
- Original requirement text
- Assertion type (grep/test/threshold/enum)
- Concrete check expression or test code
- Status (mapped / pending / blocked)
Block until all mapped: Implementation must not report "done" until every requirement has a corresponding mapped assertion with a machine-runnable check.
Post-implementation verification: Run each assertion manually or via automation to confirm all pass before marking the task complete.
Assertion Mapping Table Example
| ID | Requirement | Type | Check |
|---|---|---|---|
| R1 | "User must be able to reset password via email" | grep | grep -r "reset.password.email" --include="*.py" . |
| R2 | "API must return 401 for unauthenticated calls" | test | pytest -k "auth" --tb=short |
| R3 | "Response time < 200ms under load" | threshold | `hey -n 100 -qps 10 https://api.example.com/ping |
Windows PowerShell Notes
- Use
Select-Stringinstead ofgrepfor Windows pattern matching - Numeric threshold checks should use
[regex]::Match()for PowerShell parsing - Assertion mapping table can be saved as
spec-assertions.jsonfor machine consumption