Root Makefile with timeout-protected test targets: - Tier 1 (<30s): make test, make test-unit, make test-frontend - Tier 2 (smart): make test-related F=file.py (via @RELATION BINDS_TO) - Tier 3 (<5min): make test-integration (Docker, --run-integration) - Coverage: make coverage (backend + frontend) - Lint: make lint (ruff + eslint) Smart test selector (scripts/find-related-tests.py): - Extracts module names from #region anchors, class/function defs - Searches 400 BINDS_TO entries across all test files - Confidence scoring: exact > case-insensitive > substring > heuristic - Fallback: filename-based fuzzy matching OpenCode commands: - /test.all — full suite + coverage - /test.unit — fast unit tests (<30s) - /test.related — smart selection by file - /test.coverage — coverage reports with thresholds Speckit workflow updated: - speckit.test.md: raw pytest → make targets with timeout safety - speckit.plan.md: quickstart uses make targets - speckit.tasks.md: verification uses make targets - speckit.implement.md: default stack uses make targets Frontend: added 'coverage' script to package.json
3.2 KiB
description, handoffs, tools
| description | handoffs | tools | ||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| Find and run tests related to a specific source file using @RELATION BINDS_TO annotations. |
|
bash, grep, axiom_search, read |
User Input
$ARGUMENTS
Goal
Given a source file path, find and run ONLY the tests that are semantically related to that file. This uses the @RELATION BINDS_TO -> [ModuleName] annotations in test files to trace dependencies.
This is the most efficient verification — avoid running the full suite when only one module changed.
Required Skills
MANDATORY USE skill({name="semantics-testing"}) — BINDS_TO conventions, test contracts.
MANDATORY USE skill({name="semantics-contracts"}) — relation syntax, verifiable edit loop.
Execution Steps
1. Identify the source file
$ARGUMENTS should be a path to a source file (e.g., backend/src/plugins/migration.py). If the user provides a directory, pick the most recently modified file or ask for clarification.
2. Run the smart test selector
make test-related F="$ARGUMENTS"
Or directly:
python3 scripts/find-related-tests.py --file "$ARGUMENTS" --verbose --run
This script:
- Extracts module/class names from the source file (#region anchors, class/function defs)
- Searches all test files for
@RELATION BINDS_TO -> [ModuleName]annotations - Returns matching test files with confidence scores (exact > case-insensitive > substring > heuristic)
3. Interpret results
If tests are found and pass: ✅ Report success.
If tests are found and fail: Read the failing test code, identify root cause, handoff to Fix Related Test Failures.
If no related tests found: Two possibilities:
- The source file genuinely has no tests — report as coverage gap.
- The
@RELATION BINDS_TOannotation is missing from the test file — handoff to semantic-curator for annotation.
4. (Optional) Verify with axiom
If the smart selector found 0 results, try axiom's semantic search as a fallback:
axiom_search operation="trace_related_tests" contract_id="<module_contract_id>"
Output Format
## Related Test Results for `$ARGUMENTS`
### Matched Tests
- [exact] backend/tests/plugins/test_migration_plugin.py (via 'MigrationPlugin')
- [substr] backend/tests/api/test_migration.py (via 'MigrationApi')
### Results
- Total: N | Passed: N | Failed: N
- Time: X.Xs
### Coverage Gap (if no tests found)
- Source file has no linked tests.
- Recommended: create test file with @RELATION BINDS_TO -> [ModuleName]
Constraints
- NEVER run the full test suite as a fallback — only matched tests.
- If the selector finds 20+ related tests, report the count and ask if user wants to run all or narrow scope.
- Heuristic matches (score=0) should be clearly flagged as low-confidence.