doc-tspec-validator

Original🇺🇸 English
Translated

Validate Test Specification (TSPEC) documents against Layer 10 schema standards

4installs
Added on

NPX Install

npx skill4agent add vladm3105/aidoc-flow-framework doc-tspec-validator

Tags

Translated version includes tags in frontmatter

doc-tspec-validator

Validate Test Specification (TSPEC) documents against Layer 10 schema standards.

Purpose

Validates TSPEC documents for:
  • YAML frontmatter metadata compliance
  • Section structure (test specification sections)
  • Document Control completeness
  • Cumulative tagging (8 required: @brd, @prd, @ears, @bdd, @adr, @sys, @req, @spec)
  • TASKS-Ready scoring
  • File naming convention (TSPEC-NN_{slug}.md or {TYPE}-NN_{slug}.md)
  • Element ID format (TSPEC.NN.TT.SS where TT is 40-43)
  • Test type validation (UTEST/ITEST/STEST/FTEST)

Activation

Invoke when:
  • User requests validation of TSPEC documents
  • After creating/modifying TSPEC artifacts
  • Before generating downstream artifacts (TASKS)
  • As part of quality gate checks
  • Validating test coverage matrices

Schema Reference

ItemValue
TSPEC Index
ai_dev_flow/10_TSPEC/TSPEC-00_index.md
UTEST Template
ai_dev_flow/10_TSPEC/UTEST/UTEST-MVP-TEMPLATE.md
ITEST Template
ai_dev_flow/10_TSPEC/ITEST/ITEST-MVP-TEMPLATE.md
STEST Template
ai_dev_flow/10_TSPEC/STEST/STEST-MVP-TEMPLATE.md
FTEST Template
ai_dev_flow/10_TSPEC/FTEST/FTEST-MVP-TEMPLATE.md
Layer10
Artifact TypeTSPEC

Validation Checklist

0. Folder Structure Validation (BLOCKING)

Nested Folder Rule: ALL TSPEC documents MUST be in nested folders regardless of size.
Required Structure:
TSPEC TypeRequired Location
UTEST
docs/10_TSPEC/UTEST/UTEST-NN_{slug}/UTEST-NN_{slug}.md
ITEST
docs/10_TSPEC/ITEST/ITEST-NN_{slug}/ITEST-NN_{slug}.md
STEST
docs/10_TSPEC/STEST/STEST-NN_{slug}/STEST-NN_{slug}.md
FTEST
docs/10_TSPEC/FTEST/FTEST-NN_{slug}/FTEST-NN_{slug}.md
Validation:
1. Check document is inside a nested folder: docs/10_TSPEC/{TYPE}/{TYPE}-NN_{slug}/
2. Verify folder name matches TSPEC ID pattern: {TYPE}-NN_{slug}
3. Verify file name matches folder: {TYPE}-NN_{slug}.md
4. Parent path must be: docs/10_TSPEC/{TYPE}/
Example Valid Structure:
docs/10_TSPEC/
├── UTEST/
│   ├── UTEST-01_auth_service/
│   │   ├── UTEST-01_auth_service.md   ✓ Valid
│   │   ├── UTEST-01.R_review_report_v001.md
│   │   └── .drift_cache.json
│   └── UTEST-02_session_service/
│       └── UTEST-02_session_service.md ✓ Valid
├── ITEST/
│   └── ITEST-01_api_integration/
│       └── ITEST-01_api_integration.md ✓ Valid
├── STEST/
│   └── STEST-01_deployment_smoke/
│       └── STEST-01_deployment_smoke.md ✓ Valid
└── FTEST/
    └── FTEST-01_user_workflow/
        └── FTEST-01_user_workflow.md   ✓ Valid
Invalid Structure:
docs/10_TSPEC/
├── UTEST/
│   ├── UTEST-01_auth_service.md       ✗ NOT in nested folder
Error Codes:
CodeSeverityDescription
TSPEC-E030ERRORTSPEC not in nested folder (BLOCKING)
TSPEC-E031ERRORFolder name doesn't match TSPEC ID
TSPEC-E032ERRORFile name doesn't match folder name
TSPEC-E033ERRORTSPEC not in correct type subdirectory
This check is BLOCKING - TSPEC must pass folder structure validation before other checks proceed.

1. Metadata Validation

yaml
Required custom_fields:
  document_type: ["tspec", "utest", "itest", "stest", "ftest", "template"]
  artifact_type: "TSPEC"
  layer: 10
  architecture_approaches: [array format]
  priority: ["primary", "shared", "fallback"]
  development_status: ["active", "draft", "deprecated", "reference"]

Required tags:
  - tspec (or utest, itest, stest, ftest)
  - layer-10-artifact

Forbidden tag patterns:
  - "^test-specification$"
  - "^tspec-\\d{3}$"
  - "^unit-test$"
  - "^integration-test$"

2. Structure Validation

Required Sections (All TSPEC Types):
SectionTitleRequired
1Document ControlMANDATORY
2Test ScopeMANDATORY
3Test Case IndexMANDATORY
4Test Case DetailsMANDATORY
5Coverage MatrixMANDATORY
6TraceabilityMANDATORY
7Error CasesMANDATORY
Section Format:
## N. Title
(numbered H2 headings)

3. Document Control Required Fields

FieldDescriptionRequired
StatusDraft/Review/Approved/ImplementedMANDATORY
VersionSemantic versioning (X.Y.Z)MANDATORY
Date CreatedYYYY-MM-DD formatMANDATORY
Last UpdatedYYYY-MM-DD formatMANDATORY
AuthorTest author nameMANDATORY
ComponentComponent/module under testMANDATORY
SPEC ReferenceSPEC-NNMANDATORY
Coverage TargetXX%MANDATORY
TASKS-Ready Score
XX/100 (Target: see type-specific)
MANDATORY

4. Test Type Element Codes

Test TypeCodeAbbreviationTASKS-Ready Target
Unit Test40UTEST>=90%
Integration Test41ITEST>=85%
Smoke Test42STEST100%
Functional Test43FTEST>=85%

5. Element ID Format

Pattern:
TSPEC.{DOC_NUM}.{ELEM_TYPE}.{SEQ}
(4 segments, dot-separated)
Valid Element Type Codes: 40, 41, 42, 43 only
Examples:
Element IDValidTest Type
TSPEC.01.40.01
YesUnit Test
TSPEC.01.41.01
YesIntegration Test
TSPEC.01.42.01
YesSmoke Test
TSPEC.01.43.01
YesFunctional Test
TSPEC.01.44.01
NoInvalid code (44 not in 40-43)
TC-001
NoLegacy pattern
UT-001
NoLegacy pattern
Deprecated Patterns (Do NOT use):
  • TC-XXX
    - Use
    TSPEC.NN.TT.SS
    instead
  • UT-XXX
    - Use
    TSPEC.NN.40.SS
    instead
  • IT-XXX
    - Use
    TSPEC.NN.41.SS
    instead
  • ST-XXX
    - Use
    TSPEC.NN.42.SS
    instead
  • FT-XXX
    - Use
    TSPEC.NN.43.SS
    instead

6. Naming Compliance (doc-naming integration)

File Naming Patterns:
PatternExampleDocument Type
UTEST-NN_{slug}.md
UTEST-01_auth_service_unit.md
Unit Test
ITEST-NN_{slug}.md
ITEST-01_api_integration.md
Integration Test
STEST-NN_{slug}.md
STEST-01_deployment_smoke.md
Smoke Test
FTEST-NN_{slug}.md
FTEST-01_order_processing.md
Functional Test
Directory Structure:
docs/10_TSPEC/
  UTEST/
    UTEST-01_{slug}.md
  ITEST/
    ITEST-01_{slug}.md
  STEST/
    STEST-01_{slug}.md
  FTEST/
    FTEST-01_{slug}.md
  TSPEC-00_TRACEABILITY_MATRIX.md

7. Cumulative Tagging Requirements

Layer 10 Cumulative Tags (8 Required):
markdown
@brd: BRD.NN.TT.SS
@prd: PRD.NN.TT.SS
@ears: EARS.NN.25.SS
@bdd: BDD.NN.14.SS
@adr: ADR-NN
@sys: SYS.NN.26.SS
@req: REQ.NN.27.SS
@spec: SPEC-NN
Optional (9th tag if CTR exists):
markdown
@ctr: CTR-NN
Tag Format Convention:
NotationFormatArtifacts
DashTYPE-NNADR, SPEC, CTR
DotTYPE.NN.TT.SSBRD, PRD, EARS, BDD, SYS, REQ, TSPEC

8. Test Case Format Requirements

Each test case MUST include:
markdown
### TSPEC.NN.TT.SS: [Test Name]

**Category**: [Logic] | [State] | [Validation] | [Edge] | [Integration] | [Critical Path]

**Traceability**:
- @req: REQ.NN.27.XX
- @spec: SPEC-NN (Section X.Y)

**Input/Output Table**:

| Input | Expected Output | Notes |
|-------|-----------------|-------|
| `param1="valid"` | `True` | Happy path |
| `param1=""` | `ValidationError` | Empty input |

**Pseudocode**:
GIVEN valid input parameters
WHEN function_under_test(param1) is called
THEN result equals expected_output
AND no side effects occur

**Error Cases**:

| Error Condition | Expected Behavior |
|-----------------|-------------------|
| Invalid input type | Raise `TypeError` |

9. Coverage Matrix Validation

Required Format:
markdown
## Coverage Matrix

| REQ ID | REQ Title | Test IDs | Coverage |
|--------|-----------|----------|----------|
| REQ.NN.27.01 | [Title] | TSPEC.NN.40.01, TSPEC.NN.40.03 | Covered |
| REQ.NN.27.02 | [Title] | - | NOT COVERED |

**Coverage Summary**:
- Total REQ elements: [N]
- Covered: [N]
- Coverage: [XX]%

10. Type-Specific Requirements

UTEST (Unit Tests - Code 40)

RequirementValue
TASKS-Ready Target>=90%
Required Tags@req, @spec
Test Categories[Logic], [State], [Validation], [Edge]
Function Coverage>=90%
Branch Coverage>=80%

ITEST (Integration Tests - Code 41)

RequirementValue
TASKS-Ready Target>=85%
Required Tags@ctr, @sys, @spec
Test Categories[Integration], [Contract], [Sequence]
Sequence DiagramsRequired for complex interactions
Mock StrategyMust be documented

STEST (Smoke Tests - Code 42)

RequirementValue
TASKS-Ready Target100%
Required Tags@ears, @bdd, @req
Test Categories[Critical Path], [Health Check], [Deployment]
Execution Time<5 minutes total
Critical Path Coverage100%

FTEST (Functional Tests - Code 43)

RequirementValue
TASKS-Ready Target>=85%
Required Tags@sys, @threshold
Test Categories[Functional], [Scenario], [End-to-End]
SYS CoverageRequired
Threshold ReferencesMust include @threshold tags

Error Codes

CodeSeverityDescription
TSPEC-E001ERRORMissing required tag 'tspec' (or type-specific: utest/itest/stest/ftest)
TSPEC-E002ERRORMissing required tag 'layer-10-artifact'
TSPEC-E003ERRORInvalid document_type value
TSPEC-E004ERRORInvalid architecture_approaches format (must be array)
TSPEC-E005ERRORForbidden tag pattern detected
TSPEC-E006ERRORMissing required section
TSPEC-E007ERRORMultiple H1 headings detected
TSPEC-E008ERRORSection numbering not sequential
TSPEC-E009ERRORDocument Control missing required fields
TSPEC-E010ERRORMissing Test Case Details (Section 4)
TSPEC-E011ERRORInvalid element type code (must be 40-43)
TSPEC-E012ERRORMissing cumulative tags (requires 8: @brd through @spec)
TSPEC-E013ERRORInvalid element ID format (not TSPEC.NN.TT.SS)
TSPEC-E014ERRORMissing upstream @spec tag
TSPEC-E015ERRORMissing Coverage Matrix (Section 5)
TSPEC-E016ERRORMissing SPEC Reference in Document Control
TSPEC-E017ERRORDeprecated ID pattern used (TC-XXX, UT-XXX, IT-XXX, ST-XXX, FT-XXX)
TSPEC-E018ERRORElement type code mismatch (e.g., using 40 in ITEST document)
TSPEC-E019ERRORMissing I/O table for test case
TSPEC-E020ERRORMissing traceability section
TSPEC-W001WARNINGFile name does not match format {TYPE}-NN_{slug}.md
TSPEC-W002WARNINGMissing pseudocode for complex test case
TSPEC-W003WARNINGTASKS-Ready Score below type-specific target
TSPEC-W004WARNINGCoverage percentage below target
TSPEC-W005WARNINGMissing error cases documentation
TSPEC-W006WARNINGMissing test fixtures documentation
TSPEC-W007WARNINGMissing mock strategy (ITEST only)
TSPEC-W008WARNINGExecution time exceeds 5 minutes (STEST only)
TSPEC-W009WARNINGMissing @threshold tags (FTEST only)
TSPEC-W010WARNINGMissing sequence diagrams for complex interactions (ITEST only)
TSPEC-I001INFOConsider adding performance targets for test execution
TSPEC-I002INFOConsider adding test data setup documentation
TSPEC-I003INFOConsider adding CI/CD integration notes

Validation Commands

bash
# Validate single TSPEC document
python ai_dev_flow/scripts/validate_tspec.py docs/10_TSPEC/UTEST/UTEST-01_example.md

# Validate all TSPEC documents in directory
python ai_dev_flow/scripts/validate_tspec.py docs/10_TSPEC/

# Validate by type
python ai_dev_flow/10_TSPEC/scripts/validate_utest.py docs/10_TSPEC/UTEST/
python ai_dev_flow/10_TSPEC/scripts/validate_itest.py docs/10_TSPEC/ITEST/
python ai_dev_flow/10_TSPEC/scripts/validate_stest.py docs/10_TSPEC/STEST/
python ai_dev_flow/10_TSPEC/scripts/validate_ftest.py docs/10_TSPEC/FTEST/

# Validate all TSPEC types
bash ai_dev_flow/10_TSPEC/scripts/validate_all_tspec.sh docs/10_TSPEC/

# Quality score validation
bash ai_dev_flow/10_TSPEC/scripts/validate_tspec_quality_score.sh docs/10_TSPEC/

# Validate with verbose output
python ai_dev_flow/scripts/validate_tspec.py docs/10_TSPEC/ --verbose

# Validate with auto-fix
python ai_dev_flow/scripts/validate_tspec.py docs/10_TSPEC/ --auto-fix

# Cross-document validation
python ai_dev_flow/scripts/validate_cross_document.py --document docs/10_TSPEC/UTEST/UTEST-01.md --auto-fix

# Cumulative tagging validation
python ai_dev_flow/scripts/validate_tags_against_docs.py \
  --artifact UTEST-01 \
  --expected-layers brd,prd,ears,bdd,adr,sys,req,spec \
  --strict

Validation Workflow

  1. Parse YAML frontmatter
  2. Check required metadata fields (document_type, artifact_type, layer)
  3. Validate tag taxonomy (tspec/utest/itest/stest/ftest, layer-10-artifact)
  4. Verify section structure (7 required sections)
  5. Validate Document Control table completeness
  6. Check SPEC Reference presence
  7. Validate element ID format (TSPEC.NN.TT.SS)
  8. Verify element type code matches document type:
    • UTEST: code 40
    • ITEST: code 41
    • STEST: code 42
    • FTEST: code 43
  9. Validate cumulative tags (8 required: @brd through @spec)
  10. Check Coverage Matrix completeness
  11. Validate I/O tables present for all test cases
  12. Check pseudocode for complex tests
  13. Verify error cases documented
  14. Calculate TASKS-Ready Score
  15. Verify file naming convention
  16. Detect deprecated patterns (TC-XXX, UT-XXX, etc.)
  17. Run type-specific validations
  18. Generate validation report

Auto-Fix Actions

IssueAuto-Fix Action
Missing cumulative tagsAdd with upstream document reference
Invalid element ID formatConvert to TSPEC.NN.TT.SS format
Missing traceability sectionInsert from template
Missing Document Control fieldsAdd placeholder fields
Deprecated ID patternsConvert to unified format (TC-001 to TSPEC.NN.TT.01)
Wrong element type codeCorrect based on document type (UTEST=40, ITEST=41, etc.)
Missing Coverage MatrixInsert template structure
Missing TASKS-Ready ScoreCalculate and insert

Integration

  • Invoked by: doc-flow, doc-tspec (post-creation), quality-advisor
  • Feeds into: trace-check (cross-document validation)
  • Reports to: quality-advisor
  • Validates output from: doc-tspec skill

Output Format

TSPEC Validation Report
=======================
Document: UTEST-01_auth_service_unit.md
Type: UTEST (Unit Test)
Status: PASS/FAIL

TASKS-Ready Score: 92% (Target: >=90%) [PASS]

Cumulative Tags:
  @brd: BRD.01.01.01 [PRESENT]
  @prd: PRD.01.07.01 [PRESENT]
  @ears: EARS.01.25.01 [PRESENT]
  @bdd: BDD.01.14.01 [PRESENT]
  @adr: ADR-01 [PRESENT]
  @sys: SYS.01.26.01 [PRESENT]
  @req: REQ.01.27.01 [PRESENT]
  @spec: SPEC-01 [PRESENT]
  Tags: 8/8 [COMPLETE]

Coverage Summary:
  REQ Elements: 15/18 covered (83%)
  Target: >=90%
  Status: [BELOW TARGET]

Test Cases: 12
  Element IDs Valid: 12/12
  I/O Tables Present: 11/12
  Pseudocode Present: 10/12

Errors: 0
Warnings: 3
Info: 1

[TSPEC-W002] WARNING: Missing pseudocode for TSPEC.01.40.05
[TSPEC-W004] WARNING: Coverage percentage (83%) below target (90%)
[TSPEC-W019] WARNING: Missing I/O table for TSPEC.01.40.12
[TSPEC-I002] INFO: Consider adding test data setup documentation

Related Resources

  • TSPEC Skill:
    .claude/skills/doc-tspec/SKILL.md
  • Naming Standards:
    .claude/skills/doc-naming/SKILL.md
    (element IDs, element type codes)
  • Quality Advisor:
    .claude/skills/quality-advisor/SKILL.md
  • TSPEC Index:
    ai_dev_flow/10_TSPEC/TSPEC-00_index.md
  • Traceability Matrix Template:
    ai_dev_flow/10_TSPEC/TSPEC-00_TRACEABILITY_MATRIX-TEMPLATE.md
  • Shared Standards:
    .claude/skills/doc-flow/SHARED_CONTENT.md

Templates

  • ai_dev_flow/10_TSPEC/UTEST/UTEST-MVP-TEMPLATE.md
  • ai_dev_flow/10_TSPEC/ITEST/ITEST-MVP-TEMPLATE.md
  • ai_dev_flow/10_TSPEC/STEST/STEST-MVP-TEMPLATE.md
  • ai_dev_flow/10_TSPEC/FTEST/FTEST-MVP-TEMPLATE.md

Quality Gates

  • ai_dev_flow/10_TSPEC/UTEST/UTEST_MVP_QUALITY_GATES.md
  • ai_dev_flow/10_TSPEC/ITEST/ITEST_MVP_QUALITY_GATES.md
  • ai_dev_flow/10_TSPEC/STEST/STEST_MVP_QUALITY_GATES.md
  • ai_dev_flow/10_TSPEC/FTEST/FTEST_MVP_QUALITY_GATES.md

Version History

VersionDateChanges
1.12026-02-11Nested Folder Rule: Added Section 0 Folder Structure Validation (BLOCKING); TSPEC must be in
docs/10_TSPEC/{TYPE}/{TYPE}-NN_{slug}/
folders; Added error codes TSPEC-E030 through TSPEC-E033
1.02026-02-08Initial release: Full TSPEC validation for UTEST/ITEST/STEST/FTEST (codes 40-43), cumulative tagging (8 required), type-specific requirements, doc-naming integration