2.5 KiB
2.5 KiB
description, handoffs
| description | handoffs | |||||||||
|---|---|---|---|---|---|---|---|---|---|---|
| Run semantic validation and functional tests for a specific feature, module, or file. |
|
User Input
$ARGUMENTS
Input format: Can be a file path, a directory, or a feature name.
Outline
-
Context Analysis:
- Determine the target scope (Backend vs Frontend vs Full Feature).
- Read
semantic_protocol.mdto load validation rules.
-
Phase 1: Semantic Static Analysis (The "Compiler" Check)
- Command: Use
grepor script to verify Protocol compliance before running code. - Check:
- Does the file start with
[DEF:...]header? - Are
@TIERand@PURPOSEdefined? - Are imports located after the contracts?
- Do functions marked "Critical" have
@PRE/@POSTtags?
- Does the file start with
- Action: If this phase fails, STOP and report "Semantic Compilation Failed". Do not run runtime tests.
- Command: Use
-
Phase 2: Environment Prep
- Detect project type:
- Python: Check if
.venvis active. - Svelte: Check if
node_modulesexists.
- Python: Check if
- Command: Run linter (e.g.,
ruff check,eslint) to catch syntax errors immediately.
- Detect project type:
-
Phase 3: Test Execution (Runtime)
-
Select the test runner based on the file path:
- Backend (
*.py):- Command:
pytest <path_to_test_file> -v - If no specific test file exists, try to find it by convention:
tests/test_<module_name>.py.
- Command:
- Frontend (
*.svelte,*.ts):- Command:
npm run test -- <path_to_component>
- Command:
- Backend (
-
Verification:
- Analyze output logs.
- If tests fail, summarize the failure (AssertionError, Timeout, etc.).
-
-
Phase 4: Contract Coverage Check (Manual/LLM verify)
- Review the test cases executed.
- Question: Do the tests explicitly verify the
@POSTguarantees defined in the module header? - Report: Mark as "Weak Coverage" if contracts exist but aren't tested.
Execution Rules
- Fail Fast: If semantic headers are missing, don't waste time running pytest.
- No Silent Failures: Always output the full error log if a command fails.
- Auto-Correction Hint: If a test fails, suggest the specific
speckit.implementcommand to fix it.
Example Commands
- Python:
pytest backend/tests/test_auth.py - Svelte:
npm run test:unit -- src/components/Button.svelte - Lint:
ruff check backend/src/api/