- Overview
- Available Scripts
- generate_anchor.py
- validate_links.py
- audit_feature_coverage.py
- validate_heading_numbering.py
- apply_heading_corrections.py
- Heading Corrections Application Purpose
- Heading Corrections Application Usage
- Heading Corrections Application Features
- Heading Corrections Application Exit Codes
- Heading Corrections Application Requirements
- Heading Corrections Application Output Example
- Heading Corrections Application Integration
- Heading Corrections Application Workflow
- validate_req_references.py
- Requirement Reference Validation Purpose
- Requirement Reference Validation Usage
- Requirement Reference Validation Features
- Requirement Reference Validation Exit Codes
- Requirement Reference Validation Integration
- Requirement Reference Validation Requirements
- Requirement Reference Validation Output Example
- audit_requirements_coverage.py
- validate_go_code_blocks.py
- validate_api_go_defs_index.py
- validate_go_signature_sync.py
- validate_go_spec_references.py
- Go Specification References Validation Purpose
- Go Specification References Validation Usage
- Go Specification References Validation Features
- Go Specification References Validation Exit Codes
- Go Specification References Validation Integration
- Go Specification References Validation Requirements
- Go Specification References Validation Output Example
- apply_go_spec_references.py
- Go Specification References Application Purpose
- Go Specification References Application Usage
- Go Specification References Application Features
- Go Specification References Application Exit Codes
- Go Specification References Application Requirements
- Go Specification References Application Output Example
- Go Specification References Application Integration
- Go Specification References Application Workflow
- validate_go_spec_signature_consistency.py
- Go Signature Consistency Validation Purpose
- Go Signature Consistency Validation Usage
- Go Signature Consistency Validation Features
- Go Signature Consistency Validation Exit Codes
- Go Signature Consistency Validation Integration
- Go Signature Consistency Validation Requirements
- Go Signature Consistency Validation Output Example
- Go Linting Checks
- Common Features
- CI Integration
- Development
- Maintenance
- Utility Modules
- Related Documentation
This directory contains utility scripts for the NovusPack project.
Generates GitHub-style markdown anchors from markdown headings.
- Generates consistent markdown anchors for documentation links
- Implements GitHub's anchor generation algorithm
- Useful for creating links to specific sections in markdown files
- Supports headings with inline code (backticks)
# Generate anchor for the heading at a specific file line
python3 scripts/generate_anchor.py --line docs/tech_specs/api_core.md:42
# Output: #some-heading-anchor
# Print anchors for all headings in a file
python3 scripts/generate_anchor.py --file docs/tech_specs/api_core.md
# Output (one per heading):
# docs/tech_specs/api_core.md:1: H1 Title => #title
# Via Makefile (preferred)
make generate-anchor LINE="docs/tech_specs/api_core.md:42"
make generate-anchor FILE="docs/tech_specs/api_core.md"- Implements GitHub's markdown anchor generation algorithm
- Removes backticks but preserves their content (e.g.,
`code`->code) - Converts to lowercase
- Removes special characters except word characters, spaces, and hyphens
- Collapses sequences of spaces and hyphens into a single hyphen
- Strips leading and trailing hyphens
- Returns anchor with
#prefix for use in markdown links
The script is available via Makefile:
# Print anchors for all headings in a file
make generate-anchor FILE="docs/tech_specs/api_core.md"
# Print anchor for the heading at a specific line in a file
make generate-anchor LINE="docs/tech_specs/api_core.md:42"Note: This interface avoids passing heading text through the shell, which eliminates quoting issues (including backticks). If you must pass text containing backticks on the command line for other tooling, prefer single quotes and escape backticks as needed.
- Python 3.x (standard library only, no external dependencies)
Validates all internal markdown links and anchors in the documentation.
- Ensures all documentation cross-references are valid
- Prevents broken links in requirements and tech spec files
- Validates links in code comments within code blocks
- Checks that requirements files reference tech specs
# Basic validation
python3 scripts/validate_links.py
# With verbose output
python3 scripts/validate_links.py --verbose
# Save detailed report to file (use tmp/ for reports)
python3 scripts/validate_links.py --output tmp/validation_report.txt
# Check requirements coverage (ensures all requirements reference tech specs)
python3 scripts/validate_links.py --check-coverage
# Check specific file
python3 scripts/validate_links.py --path docs/tech_specs/api_file_management.md
# Check specific directory (recursive)
python3 scripts/validate_links.py --path docs/requirements
# Check multiple paths (comma-separated)
python3 scripts/validate_links.py --path docs/requirements,docs/tech_specs
# Show help
python3 scripts/validate_links.py --help- Validates 2,600+ internal links across 43+ markdown files
- Categorizes files by type (requirements, tech specs, other)
- Detects broken anchors, missing files, and internal anchor issues
- Excludes false positives from inline code and function signatures
- Validates links in code comments (e.g.,
// See [doc](file.md)) - Provides line numbers for all broken links
- Organized reporting by file type
- Uses file content caching to reduce I/O overhead
- Regex patterns compiled at module level for performance
- Exit code 1 on failures (suitable for CI)
0: All links valid1: Broken links found or coverage issues detected
The script is integrated into the CI pipeline:
# Run locally via Makefile (all files)
make validate-links
# Check specific files/directories
make validate-links PATHS="docs/requirements/core.md,docs/tech_specs"
# Part of full CI suite
make ci- Python 3.x (standard library only, no external dependencies)
Audits feature file coverage for requirements by checking which requirements have feature files that reference them using @REQ-* tags.
- Ensures all requirements are covered by BDD feature files
- Identifies requirements without corresponding feature tests
- Helps maintain test coverage quality
- Validates traceability from requirements to tests
# Basic audit
python3 scripts/audit_feature_coverage.py
# With verbose output
python3 scripts/audit_feature_coverage.py --verbose
# Check specific file
python3 scripts/audit_feature_coverage.py --path features/file_management/write.feature
# Check specific directory (recursive)
python3 scripts/audit_feature_coverage.py --path features/file_management
# Check multiple paths (comma-separated)
python3 scripts/audit_feature_coverage.py --path features/file_management,features/compression
# Show help
python3 scripts/audit_feature_coverage.py --help
# Run via Makefile
make audit-feature-coverage
# Part of combined coverage audit
make audit-coverage- Scans all requirements markdown files (excluding README.md and traceability.md)
- Excludes obsolete and documentation-only requirements
- Searches feature files for
@REQ-*tag references - Reports requirements without any feature coverage
- Provides summary statistics (total, covered, missing)
- Verbose mode shows detailed search progress
- Lists all uncovered requirements for easy remediation
0: All requirements have feature coverage1: One or more requirements have no feature coverage
The script is integrated into the CI pipeline:
# Run locally via Makefile (all files)
make audit-feature-coverage
# Part of combined coverage audit
# Note: This check is skipped when PATHS is specified, as it requires checking all requirements and feature files
make audit-coverage
# Part of full CI suite
make ciNote: When running make docs-check PATHS="...", this validation is automatically skipped because it requires checking all requirements and feature files to validate coverage properly.
- Python 3.x (standard library only, no external dependencies)
Validates markdown heading numbering consistency across all markdown files in the repository.
- Ensures consistent heading numbering structure in all documentation
- Validates that heading levels match number depth (H2=1 number, H3=2 numbers, etc.)
- Checks sequential numbering within each parent section
- Verifies child heading numbers match their parent section number
- Helps maintain professional documentation standards
# Basic validation
python3 scripts/validate_heading_numbering.py
# With verbose output
python3 scripts/validate_heading_numbering.py --verbose
# Save detailed report to file
python3 scripts/validate_heading_numbering.py --output report.txt
# Check specific file
python3 scripts/validate_heading_numbering.py --path docs/tech_specs/api_file_management.md
# Check specific directory (recursive)
python3 scripts/validate_heading_numbering.py --path docs/requirements
# Check multiple paths (comma-separated)
python3 scripts/validate_heading_numbering.py --path docs/requirements,docs/tech_specs
# Show help
python3 scripts/validate_heading_numbering.py --help- Scans all markdown files in the repository (excluding hidden directories)
- Validates numbered headings starting at H2 level and beyond
- Checks heading depth matches number depth:
- H2 sections: 1 number (e.g., "## 1 Title")
- H3 sections: 2 numbers (e.g., "### 1.1 Subtitle")
- H4 sections: 3 numbers (e.g., "#### 1.1.1 Details")
- And so on for deeper levels
- Validates sequential numbering within parent sections
- Ensures child heading numbers match parent prefixes
- Detects duplicate heading titles (excluding numbering) across all levels
- Allows backticks in headings; case inside backticks is not checked for Title Case
- Warns about H3+ headings with numbering exceeding 20 (e.g., "### 3.25")
- Warns about H4+ headings with single-word titles (e.g., "#### 1.2.3 Title")
- Warns about overly-deeply nested headings (H6 and beyond)
- Provides line numbers and detailed error messages
- Organized reporting by error type:
- Organizational heading errors (headings with no content)
- Heading numbering errors (numbering issues)
- Sorted headings output shows only headings with numbering errors (excludes duplicate-only errors)
- Regex patterns compiled at module level for performance
- Exit code 1 on failures (suitable for CI)
0: All heading numbering is valid1: Heading numbering errors found
The script is integrated into the CI pipeline:
# Run locally via Makefile (all files)
make validate-heading-numbering
# Check specific files/directories
make validate-heading-numbering PATHS="docs/requirements,docs/tech_specs"
# Part of full CI suite
make ci- Python 3.x (standard library only, no external dependencies)
======================================================================
Markdown Heading Numbering Validation
======================================================================
Scanning 58 markdown files...
======================================================================
Summary
======================================================================
Found 149 heading numbering error(s):
/path/to/file.md:
Line 486: Non-sequential numbering: got '6.1', expected '6.6' (previous was '6.5')
### 6.1 Breaking Changes Required
Line 745: Non-sequential numbering: got '10.1', expected '10.5' (previous was '10.4')
### 10.1 Key Changes
Line 892: Duplicate heading title 'Implementation Details' (also appears at line 234, line 567).
#### 12.3.7.2 Implementation Details
Found 3 warning(s):
/path/to/file.md:
Line 234: WARNING: H3 heading has numbering '3.25' where number 25 exceeds 20.
### 3.25 Deep Nesting Example
Line 567: WARNING: H4 heading has a single-word title 'Details'.
#### 1.2.3 Details
======================================================================
Sorted headings from first error (line 486) in /path/to/file.md:
======================================================================
The following headings should be in this order (sorted by numeric values):
Format: Line X: [CURRENT] -> [CORRECT] Title
Line 486: ## [6.1] -> [6.6] Breaking Changes Required
Line 745: ### [10.1] -> [10.5] Key Changes
Note: The example output above shows example headings that are part of the validation report format. These are displayed in code blocks and are not actual headings in the README file structure.
Automatically applies heading numbering corrections from validate_heading_numbering.py output to markdown files.
- Automatically fixes heading numbering errors identified by validation
- Applies corrections to multiple files in a single run
- Preserves heading formatting (periods, spacing)
- Reduces manual editing effort for large documentation sets
# Via Makefile - pipe from validation (reads from stdin)
make validate-heading-numbering PATHS="file.md" | make apply-heading-corrections
# Via Makefile - read from file
make apply-heading-corrections INPUT="tmp/heading_report.txt"
# Via Makefile - dry run (preview changes)
make apply-heading-corrections INPUT="tmp/heading_report.txt" DRY_RUN=1
# Direct usage - pipe from validation script (read from stdin)
python3 scripts/validate_heading_numbering.py --path file.md | \
python3 scripts/apply_heading_corrections.py
# Direct usage - read from saved output file
python3 scripts/apply_heading_corrections.py --input tmp/heading_report.txt
# Direct usage - dry run (preview changes without modifying files)
python3 scripts/apply_heading_corrections.py --input tmp/heading_report.txt --dry-run
# Direct usage - with verbose output
python3 scripts/apply_heading_corrections.py --input tmp/heading_report.txt --verbose
# Show help
python3 scripts/apply_heading_corrections.py --help- Parses correction output from
validate_heading_numbering.py - Extracts file paths and line numbers from validation output
- Groups corrections by file for efficient processing
- Applies corrections in reverse line order (prevents line number shifts)
- Preserves period formatting (H2 headings with/without periods)
- Handles multiple files in a single run
- Dry-run mode for safe preview of changes
- Detailed error reporting for failed corrections
0: All corrections applied successfully1: One or more corrections failed to apply
- Python 3.x (standard library only, no external dependencies)
- Output from
validate_heading_numbering.pyas input
Found 4 corrections to apply.
Processing tmp/test_multi_file1.md (2 corrections)...
Updated tmp/test_multi_file1.md
Processing tmp/test_multi_file2.md (2 corrections)...
Updated tmp/test_multi_file2.md
Applied 4 corrections, 0 failed.
The script can be used via Makefile or directly:
# Via Makefile - pipe from validation (reads from stdin)
make validate-heading-numbering PATHS="file.md" | make apply-heading-corrections
# Via Makefile - read from file
make apply-heading-corrections INPUT="tmp/report.txt"
# Via Makefile - dry run (preview changes)
make apply-heading-corrections INPUT="tmp/report.txt" DRY_RUN=1
# Direct usage - pipe from validation script
python3 scripts/validate_heading_numbering.py --path file.md | \
python3 scripts/apply_heading_corrections.py
# Direct usage - read from file
python3 scripts/apply_heading_corrections.py --input tmp/report.txt
# Direct usage - dry run first
python3 scripts/apply_heading_corrections.py --input tmp/report.txt --dry-runThe typical workflow is:
-
Validate headings and save output:
make validate-heading-numbering PATHS="docs/" --output tmp/heading_report.txt # Or directly: python3 scripts/validate_heading_numbering.py --path docs/ \ --output tmp/heading_report.txt
-
Review corrections (optional dry-run):
make apply-heading-corrections INPUT="tmp/heading_report.txt" DRY_RUN=1 # Or directly: python3 scripts/apply_heading_corrections.py \ --input tmp/heading_report.txt --dry-run
-
Apply corrections:
make apply-heading-corrections INPUT="tmp/heading_report.txt" # Or directly: python3 scripts/apply_heading_corrections.py \ --input tmp/heading_report.txt
-
Verify fixes:
make validate-heading-numbering PATHS="docs/" # Or directly: python3 scripts/validate_heading_numbering.py --path docs/
Validates that all requirement references in feature files are correct and point to existing requirement definitions in the documentation.
- Ensures all @REQ-* tags in feature files reference valid requirements
- Validates that requirement references point to the correct documentation file
- Detects missing requirement definitions
- Helps maintain traceability from feature files to requirements
- Prevents broken requirement references
# Basic validation
python3 scripts/validate_req_references.py
# With verbose output
python3 scripts/validate_req_references.py --verbose
# Check specific file
python3 scripts/validate_req_references.py --path features/file_management/write.feature
# Check specific directory (recursive)
python3 scripts/validate_req_references.py --path features/file_management
# Check multiple paths (comma-separated)
python3 scripts/validate_req_references.py --path features/file_management,features/compression
# Show help
python3 scripts/validate_req_references.py --help- Scans all 932 feature files for @REQ-* tags
- Extracts 1199 requirement definitions from 17 requirement files
- Maps requirement categories to the correct documentation files:
- REQ-API_BASIC-* -> basic_ops.md
- REQ-FILEMGMT-* -> file_mgmt.md
- REQ-COMPR-* -> compression.md
- REQ-SEC-* -> security.md
- And many more categories
- Validates requirement references exist in expected files
- Reports missing requirements
- Reports invalid references (wrong file)
- Reports errors in REQ ID format or unknown categories
- Provides summary statistics
- Verbose mode shows detailed scanning progress
0: All requirement references are valid1: Invalid references, missing requirements, or format errors found
The script is integrated into the CI pipeline:
# Run locally via Makefile (all files)
make validate-req-references
# Part of full CI suite
# Note: This check is skipped when PATHS is specified, as it requires checking all feature files
make ciNote: When running make docs-check PATHS="...", this validation is automatically skipped because it requires checking all feature files to validate references properly.
- Python 3.x (standard library only, no external dependencies)
=== Requirement Reference Validation ===
Loading requirement definitions...
Loaded 1199 requirement definitions from 17 files
Scanning feature files...
Found 1051 unique REQ tags across 932 feature files
=== Validation Results ===
=== Summary ===
Total unique REQ references: 1051
Valid references: 1026
Invalid references (wrong file): 0
Missing references: 25
Errors (format/category): 0
Audits requirements coverage for tech specs by checking which tech specs have requirements that reference them using inline markdown links.
- Ensures all tech specs are referenced by requirements documentation
- Identifies tech specs without requirement links
- Helps maintain documentation traceability
- Validates bidirectional linkage between requirements and specs
# Basic audit
python3 scripts/audit_requirements_coverage.py
# With verbose output
python3 scripts/audit_requirements_coverage.py --verbose
# Check specific file
python3 scripts/audit_requirements_coverage.py --path docs/requirements/core.md
# Check specific directory (recursive)
python3 scripts/audit_requirements_coverage.py --path docs/requirements
# Check multiple paths (comma-separated)
python3 scripts/audit_requirements_coverage.py --path docs/requirements/core.md,docs/requirements/security.md
# Show help
python3 scripts/audit_requirements_coverage.py --help
# Run via Makefile
make audit-requirements-coverage
# Part of combined coverage audit
make audit-coverage- Scans all tech spec markdown files (excluding index files)
- Searches requirement files for relative link references
- Reports specs without any requirement coverage
- Heading-level coverage checking: Analyzes H2+ headings within tech specs
- Intelligent classification: Categorizes headings as functional, architectural, organizational, or excluded
- Weighted architectural detection: Uses scoring system to identify architectural headings with high confidence
- Content analysis: Detects function signatures, type definitions, and example code in sections
- Organizational heading detection: Identifies purely organizational headings that should be restructured
- Provides detailed summary statistics with breakdown by classification type:
- Missing headings (errors): Functional headings requiring requirements
- Architectural headings (warnings): Design/structure headings flagged for review (don't require requirements)
- Missing headings (warnings): Other headings missing requirements
- Organizational headings (warnings): Headings with no direct content
- Verbose mode shows detailed search progress
- Lists all uncovered specs and headings for easy remediation
0: All tech specs are referenced by requirements and all functional headings have requirement coverage1: One or more tech specs have no requirement coverage, or functional headings are missing requirements
Note: Architectural headings are reported as warnings but do not cause the audit to fail, as they describe design/structure rather than testable behavior. These are reported for completeness and user review.
The script is integrated into the CI pipeline:
# Run locally via Makefile (all files)
make audit-requirements-coverage
# Part of combined coverage audit
# Note: This check is skipped when PATHS is specified, as it requires checking all tech specs and requirements
make audit-coverage
# Part of full CI suite
make ciNote: When running make docs-check PATHS="...", this validation is automatically skipped because it requires checking all tech specs and requirements to validate coverage properly.
The script uses an intelligent classification system to determine which headings need requirements:
- Headings with function signatures or type definitions
- Headings with functional keywords (behavior, operation, method, etc.)
- H2 headings by default (unless classified otherwise)
- These describe testable behavior and must have requirements
- Detected using weighted scoring system based on keywords
- High confidence indicators: "type definition", "system architecture", "interface definition" (+3 points)
- Medium confidence: "structure", "system", "interface", "architecture" (+2 points)
- Threshold: Score ≥ 2 to classify as architectural
- Negative weights for non-architectural phrases (e.g., "purpose", "usage", "management")
- These describe design/structure and are flagged for review but don't require requirements
- Headings with no direct content (only subheadings)
- Max 5 lines of prose, no code blocks
- Should be removed or restructured to reduce nesting
- Headings matching exclusion patterns (e.g., "best practices", "examples", "cross-references")
- Implementation detail headings
- Overview sections (section 0.x)
- Python 3.x (standard library only, no external dependencies)
Validates Go code blocks in tech specs documentation to ensure they follow conventions.
- Ensures each Go code block has at most one type or interface definition
- Validates that each Go code block is under a different heading
- Helps maintain consistent documentation structure
- Prevents code blocks from violating documentation standards
# Basic validation
python3 scripts/validate_go_code_blocks.py
# With verbose output
python3 scripts/validate_go_code_blocks.py --verbose
# Save detailed report to file
python3 scripts/validate_go_code_blocks.py --output dev_docs/go_code_blocks_audit.md
# Check specific file
python3 scripts/validate_go_code_blocks.py --path docs/tech_specs/api_file_management.md
# Check specific directory (recursive)
python3 scripts/validate_go_code_blocks.py --path docs/tech_specs
# Check multiple paths (comma-separated)
python3 scripts/validate_go_code_blocks.py --path docs/tech_specs/api_file_management.md,docs/tech_specs/api_core.md
# Show help
python3 scripts/validate_go_code_blocks.py --help- Scans all markdown files in
docs/tech_specs(or specified paths) - Detects Go code blocks (fenced code blocks with
golanguage identifier) - Counts type definitions in each code block:
- Struct definitions:
type Name struct - Interface definitions:
type Name interface - Generic type definitions:
type Name[T ...] struct/interface - Type aliases:
type Name SomeType(including built-in types)
- Struct definitions:
- Validates that each code block has at most one type/interface definition
- Checks that each code block is under a different heading
- Validates heading format: definition name and kind word (e.g.
`Package.Write` Method); definition names preferred in backticks; case inside backticks ignored - Emits
heading_prefer_backtickswarning when a definition name in a heading is not in backticks (suggests corrected heading) - When only warnings (e.g. heading_prefer_backticks) are found, the script exits 0
- Reports issues with file paths and line numbers
- Provides summary statistics and detailed breakdown
0: All Go code blocks comply with requirements, or only warnings (e.g. heading_prefer_backticks) were found1: One or more code blocks violate requirements (errors present)
The script is integrated into the documentation checks:
# Run locally via Makefile (all files)
make validate-go-code-blocks
# Check specific files/directories
make validate-go-code-blocks PATHS="docs/tech_specs/api_file_management.md,docs/tech_specs"
# Part of documentation checks (runs before heading validation)
make docs-check
# Part of full CI suite
make ci- Python 3.x (standard library only, no external dependencies)
======================================================================
Go Code Blocks Validation Summary
======================================================================
Files audited: 20
Total code blocks: 304
Total issues found: 38
Breakdown by issue type:
Duplicate Heading........ 6
Multiple Types........... 32
Validates that all Go API definitions in tech specs are listed in the Go definitions index.
Business logic and usage are documented in scripts/validate_api_go_defs_index.md.
Use make validate-go-defs-index to run the check.
Implementation details are in scripts/lib/go_defs_index/, including the placement scoring modules used by the validator.
- Ensures every discovered Go API definition in tech specs appears in the index.
- Detects missing index entries, orphaned entries, wrong-section entries, and incorrect link targets.
- Enforces description rules (minimum length and uniqueness).
- Reports low-confidence placements that require manual review.
# Run the validator (full scan).
make validate-go-defs-index
# Verbose output and write a report file.
make validate-go-defs-index VERBOSE=1 NO_COLOR=1 OUTPUT="tmp/go_defs_index.txt"
# Apply high-confidence index updates (interactive confirmation required).
make validate-go-defs-index APPLY=1- Scans
docs/tech_specs/*.mdfor```gocode blocks and extracts types, methods, and functions. - Builds an expected index tree using confidence-scored placement.
- Compares expected entries with current index entries and reports discrepancies.
- Validates index entry descriptions:
- Missing or too-short descriptions are errors.
- Duplicate description text across entries is an error.
- Emits ordering warnings when existing entries are out of order.
0: No errors found.1: Errors found.- With
NO_FAIL=1, the validator exits with0even when errors are found.
- Python 3.x
Validates Go type, method, and function signatures in implementation against tech specs.
- Ensures implementation signatures match tech spec definitions
- Detects signature mismatches (different parameters, return types, etc.)
- Identifies missing signatures in implementation (not yet implemented)
- Flags additional signatures in implementation not in specs (likely helpers)
- Validates proper context propagation
- Detects forbidden empty interface parameter types
- Warns about discouraged
anytype usage
# Basic validation
python3 scripts/validate_go_signature_sync.py
# With verbose output
python3 scripts/validate_go_signature_sync.py --verbose
# Save detailed report to file
python3 scripts/validate_go_signature_sync.py --output report.txt
# Specify custom directories
python3 scripts/validate_go_signature_sync.py \
--specs-dir docs/tech_specs \
--impl-dir api/go
# Exit with code 0 even if errors are found
python3 scripts/validate_go_signature_sync.py --no-fail
# Show help
python3 scripts/validate_go_signature_sync.py --help- Extracts all public signatures from Go implementation files
- Extracts all signatures from tech specs markdown files
- Compares normalized signatures for exact matches
- Detects empty interface parameter types (forbidden)
- Warns about
anytype usage (discouraged) - Filters out high-confidence helper functions (test files, internal packages, etc.)
- Identifies public API methods missing from specs (errors)
- Provides detailed location information for all mismatches
- Supports custom specs and implementation directories
0: All signatures are in sync1: Signature mismatches, missing signatures, or errors found
The script is integrated into the CI pipeline:
# Run locally via Makefile (all files)
make validate-go-signatures
# Part of Go CI checks
make ci-go
# Part of full CI suite
make ciNote: This validation is part of the Go CI workflow and runs automatically when Go code changes.
- Python 3.x (standard library only, no external dependencies)
======================================================================
Go Signature Sync Validation
======================================================================
Collecting signatures from Go implementation...
Found 245 public signatures in implementation
Collecting signatures from tech specs...
Found 250 public signatures in specs
Comparing signatures...
======================================================================
Errors
======================================================================
Found 3 signature mismatch(es):
Signature: Package.AddFile
Implementation: func (p *Package) AddFile(ctx context.Context, path string, source FileSource) error
Location: api/go/novus_package/package_writer.go:123
Specification: func (p *Package) AddFile(ctx context.Context, path string, source FileSource, opts *AddFileOptions) error
Location: docs/tech_specs/api_file_management.md:456
======================================================================
Warnings
======================================================================
Found 5 signature(s) in specs but not in implementation:
Package.RemoveFile
Signature: func (p *Package) RemoveFile(ctx context.Context, path string) error
Location: docs/tech_specs/api_file_management.md:789
Found 2 signature(s) in implementation but not in specs:
Package.internalHelper
Signature: func (p *Package) internalHelper() error
Location: api/go/novus_package/package_internal.go:45
(These may be helper functions, but should be checked)
Validates Go file specification references against tech spec files and the API definitions index.
- Ensures all
// Specification:comments in Go files reference valid tech spec sections - Validates that referenced files exist
- Validates that section anchors exist in those files
- Provides suggestions for correct reference format
- Uses API definitions index to suggest correct references based on function/type names
# Basic validation
python3 scripts/validate_go_spec_references.py
# With verbose output
python3 scripts/validate_go_spec_references.py --verbose
# Save detailed report to file
python3 scripts/validate_go_spec_references.py --output report.txt
# Specify custom repository root
python3 scripts/validate_go_spec_references.py --repo-root /path/to/repo
# Exit with code 0 even if errors are found
python3 scripts/validate_go_spec_references.py --no-fail
# Disable colored output
python3 scripts/validate_go_spec_references.py --no-color
# Show help
python3 scripts/validate_go_spec_references.py --help- Scans all Go files for
// Specification:comments - Validates reference format:
file_name.md: section_number heading_text - Also accepts anchor format:
file_name.md#anchor - Validates that spec files exist
- Validates that section numbers exist in spec files
- Validates that heading text matches actual headings
- Uses API definitions index to suggest correct references
- Extracts function/type names from Go code context for better suggestions
- Filters out section 0 and cross-reference sections (not source of truth)
- Provides parseable output format for automated fixes
0: All specification references are valid1: Invalid references, missing files, or format errors found
The script is integrated into the CI pipeline:
# Run locally via Makefile (all files)
make validate-go-spec-references
# Part of Go CI checks
make ci-go
# Part of full CI suite
make ciNote: This validation is part of the Go CI workflow and runs automatically when Go code changes.
- Python 3.x (standard library only, no external dependencies)
======================================================================
Go Specification References Validation
======================================================================
Scanning 156 Go files for specification references...
======================================================================
Errors
======================================================================
api/go/novus_package/package_writer.go:123: Invalid spec ref
Current: api_file_management.md: 2.1 AddFile
SUGGESTION: api_file_management.md: 2.1 AddFile Package Method
api/go/novus_package/package_reader.go:456: Invalid spec ref
Current: api_file_management.md#21-addfile
SUGGESTION: api_file_management.md: 2.1 AddFile Package Method
api/go/novus_package/package_writer.go:789: Invalid spec ref
Current: invalid_file.md: 1.1 SomeMethod
Also, spec file not found: invalid_file.md
Found 3 error(s)
Automatically applies specification reference updates from validate_go_spec_references.py output to Go files.
- Automatically fixes specification reference errors identified by validation
- Applies corrections to multiple files in a single run
- Preserves comment formatting and indentation
- Reduces manual editing effort for large codebases
# Via Makefile - read from file
make apply-go-spec-references INPUT="tmp/spec_ref_errors.txt"
# Via Makefile - dry run (preview changes)
make apply-go-spec-references INPUT="tmp/spec_ref_errors.txt" DRY_RUN=1
# Direct usage - read from saved output file
python3 scripts/apply_go_spec_references.py --input tmp/spec_ref_errors.txt
# Direct usage - dry run (preview changes without modifying files)
python3 scripts/apply_go_spec_references.py \
--input tmp/spec_ref_errors.txt --dry-run
# Direct usage - with verbose output
python3 scripts/apply_go_spec_references.py \
--input tmp/spec_ref_errors.txt --verbose
# Show help
python3 scripts/apply_go_spec_references.py --help- Parses correction output from
validate_go_spec_references.py - Extracts file paths and line numbers from validation output
- Groups corrections by file for efficient processing
- Applies corrections in reverse line order (prevents line number shifts)
- Preserves comment indentation and formatting
- Handles multiple files in a single run
- Dry-run mode for safe preview of changes
- Detailed error reporting for failed corrections
- Skips corrections that are already applied
0: All corrections applied successfully1: One or more corrections failed to apply
- Python 3.x (standard library only, no external dependencies)
- Output from
validate_go_spec_references.pyas input
Found 4 corrections to apply.
Processing api/go/novus_package/package_writer.go (2 corrections)...
Updated api/go/novus_package/package_writer.go
Processing api/go/novus_package/package_reader.go (2 corrections)...
Updated api/go/novus_package/package_reader.go
Applied 4 specification reference update(s), 0 skipped, 0 failed.
The script can be used via Makefile or directly:
# Via Makefile - read from file
make apply-go-spec-references INPUT="tmp/spec_ref_errors.txt"
# Via Makefile - dry run (preview changes)
make apply-go-spec-references INPUT="tmp/spec_ref_errors.txt" DRY_RUN=1
# Direct usage - read from file
python3 scripts/apply_go_spec_references.py --input tmp/spec_ref_errors.txt
# Direct usage - dry run first
python3 scripts/apply_go_spec_references.py \
--input tmp/spec_ref_errors.txt --dry-runThe typical workflow is:
-
Validate references and save output:
make validate-go-spec-references OUTPUT=tmp/spec_ref_errors.txt # Or directly: python3 scripts/validate_go_spec_references.py \ --output tmp/spec_ref_errors.txt -
Review corrections (optional dry-run):
make apply-go-spec-references INPUT="tmp/spec_ref_errors.txt" DRY_RUN=1 # Or directly: python3 scripts/apply_go_spec_references.py \ --input tmp/spec_ref_errors.txt --dry-run
-
Apply corrections:
make apply-go-spec-references INPUT="tmp/spec_ref_errors.txt" # Or directly: python3 scripts/apply_go_spec_references.py \ --input tmp/spec_ref_errors.txt
-
Verify fixes:
make validate-go-spec-references # Or directly: python3 scripts/validate_go_spec_references.py
Validates Go signature consistency within tech specs documentation.
- Ensures the same function, method, or type is not defined multiple times with different signatures
- Detects methods defined for interfaces that are NOT in the canonical interface definition
- Detects interface stubs with methods not in canonical definition
- Detects interface stub methods that differ from canonical definitions
- Identifies duplicate identical signatures
- Warns about type/interface stubs (expected when fleshing out methods in separate sections)
# Basic validation
python3 scripts/validate_go_spec_signature_consistency.py
# With verbose output
python3 scripts/validate_go_spec_signature_consistency.py --verbose
# Save detailed report to file
python3 scripts/validate_go_spec_signature_consistency.py \
--output tmp/signature_consistency_report.txt
# Check specific file
python3 scripts/validate_go_spec_signature_consistency.py \
--path docs/tech_specs/api_basic_operations.md
# Check specific directory (recursive)
python3 scripts/validate_go_spec_signature_consistency.py \
--path docs/tech_specs
# Check multiple paths (comma-separated)
python3 scripts/validate_go_spec_signature_consistency.py \
--path docs/tech_specs/api_basic_operations.md,docs/tech_specs/api_core.md
# Save detailed report to file
python3 scripts/validate_go_spec_signature_consistency.py \
--output tmp/signature_consistency_report.txt
# Exit with code 0 even if errors are found
python3 scripts/validate_go_spec_signature_consistency.py --no-fail
# Disable colored output
python3 scripts/validate_go_spec_signature_consistency.py --no-color
# Show help
python3 scripts/validate_go_spec_signature_consistency.py --help- Scans all markdown files in
docs/tech_specs(or specified paths) - Extracts all Go signatures from code blocks
- Detects duplicate signatures with different definitions
- Identifies canonical signatures using heuristics (heading level, body presence, etc.)
- Validates interface method consistency
- Checks for methods defined outside canonical interface definitions
- Validates stub methods match canonical definitions
- Filters out example code and signatures
- Provides detailed location information for all inconsistencies
- Suggests canonical signatures for duplicates
0: All signatures are consistent1: Signature inconsistencies found
The script is integrated into the documentation checks:
# Run locally via Makefile (all files)
make validate-go-spec-signature-consistency
# Check specific files/directories
make validate-go-spec-signature-consistency \
PATHS="docs/tech_specs/api_file_management.md,docs/tech_specs"
# Part of documentation checks (runs after code blocks validation)
make docs-check
# Part of full CI suite
make ci- Python 3.x (standard library only, no external dependencies)
======================================================================
Go Signature Consistency
======================================================================
Found 20 markdown file(s) to audit
Extracting signatures from api_basic_operations.md...
Extracting signatures from api_core.md...
Found 250 total signatures
Checking for signature inconsistencies...
======================================================================
Errors
======================================================================
ERROR: Signature inconsistency for 'Package.AddFile':
Signature: func (p *Package) AddFile(ctx context.Context, path string, source FileSource) error
Location: docs/tech_specs/api_file_management.md:456
Signature: func (p *Package) AddFile(ctx context.Context, path string, source FileSource, opts *AddFileOptions) error
Location: docs/tech_specs/api_file_management.md:789
ERROR: Method 'RemoveFile' is defined for interface 'PackageWriter' but is not in the canonical interface definition:
Canonical interface: docs/tech_specs/api_file_management.md:123
Methods in canonical: ['AddFile', 'GetFile', 'ListFiles']
Method location: docs/tech_specs/api_file_management.md:999
======================================================================
Warnings
======================================================================
WARNING: Type/interface stub detected for 'FileEntry':
Canonical: docs/tech_specs/api_file_management.md:123 (has_body=True, field_count=5)
Stub: docs/tech_specs/api_file_management.md:456 (has_body=False, field_count=0)
======================================================================
Summary
======================================================================
Signatures checked: 250
Unique definitions: 245
Errors found: 2
Warnings found: 1
The context propagation check ensures that functions calling other functions that require context.Context also require context.Context as a parameter. This enforces proper context propagation through the call chain, which is essential for handling timeouts, cancellations, and deadlines in Go applications.
- Ensures functions calling context-requiring functions also accept context
- Prevents functions from creating
context.Background()when they should accept context - Enforces proper context propagation through the call chain
- Helps maintain Go best practices for context handling
The check is automatically run as part of golangci-lint:
# Run via Makefile (includes contextcheck)
make lint-go
# Run as part of CI checks
make ci-go
# Run directly with golangci-lint
cd api/go
golangci-lint run ./...
# Run only contextcheck linter
golangci-lint run --enable-only=contextcheck ./...- Automatically detects functions that call context-requiring functions
- Flags functions that create
context.Background()instead of accepting context - Validates context parameter presence in function signatures
- Provides file and line number for each violation
- Integrated into golangci-lint for consistent checking
The check is configured in api/go/.golangci.yml:
version: "2"
linters:
enable:
- contextcheck0: No context propagation issues found1: Context propagation violations detected
The check is integrated into the CI pipeline:
# Run locally via Makefile
make lint-go
# Part of full CI suite
make ciThe check runs automatically in the lint-go-v1 job in .github/workflows/go-ci.yml.
- golangci-lint v2.7.0 or later
- Go 1.25 or later
generics/concurrency.go:253:38: Non-inherited new context, use function like `context.WithXXX` instead (contextcheck)
novus_package/package_lifecycle.go:109:33: Function `ValidatePath` should pass the context parameter (contextcheck)
novus_package/package_lifecycle.go:190:33: Function `ValidatePath` should pass the context parameter (contextcheck)
novus_package/package_lifecycle.go:481:33: Function `ValidatePath` should pass the context parameter (contextcheck)
4 issues:
* contextcheck: 4
Most validation and audit scripts support the --path (or -p) flag for targeted validation, and the Makefile targets support a PATHS variable:
- Single file: Check one specific file
- Single directory: Recursively check all files in a directory
- Multiple paths: Comma-separated list of files and/or directories
This feature is useful for:
- Validating only modified files during development
- Optimizing CI pipeline performance by checking specific paths
- Quick validation of a subset of the codebase
- Testing newly added documentation before full validation
Note: Some scripts require checking all files to validate properly and will skip when PATHS is specified:
validate-go-defs-index- requires all tech specs to validate the indexvalidate-req-references- requires all feature files to validate referencesaudit-feature-coverage- requires all requirements and feature files to validate coverageaudit-requirements-coverage- requires all tech specs and requirements to validate coveragevalidate-go-signature-sync- requires all implementation and spec files to compare signaturesvalidate-go-spec-references- requires all Go files to validate references
When running make docs-check PATHS="...", these checks are automatically skipped.
Examples (direct script usage):
# Single file
python3 scripts/validate_links.py --path docs/requirements/core.md
# Single directory (recursive)
python3 scripts/validate_req_references.py --path features/file_management
# Multiple paths (comma-separated)
python3 scripts/validate_heading_numbering.py --path docs/requirements,docs/tech_specs
# Combine files and directories
python3 scripts/audit_feature_coverage.py --path features/file_management/write.feature,features/compressionExamples (Makefile usage):
# Single file
make validate-links PATHS="docs/requirements/core.md"
# Single directory
make validate-heading-numbering PATHS="docs/tech_specs"
# Multiple paths (comma-separated)
make docs-check PATHS="docs/requirements,docs/tech_specs"
# Combine files and directories
make validate-go-code-blocks PATHS="docs/tech_specs/api_file_management.md,docs/tech_specs/api_core.md"Behavior:
- Gracefully handles non-existent paths (shows warning, continues with valid paths)
- Validates file types (shows warning if wrong extension)
- Maintains backward compatibility (no
--pathorPATHS= default full scan) - Makefile
PATHSvariable is passed to all scripts that support--path
All scripts in this directory should be:
- Executable:
chmod +x scripts/*.py - Integrated in Makefile: Add target in root
Makefile - Added to CI: Create workflow in
.github/workflows/ - Documented: Update this README
| Script/Check | Makefile Target | GitHub Workflow | Status |
|---|---|---|---|
validate_links.py |
make validate-links |
validate-links.yml |
✅ Active |
validate_heading_numbering.py |
make validate-heading-numbering |
validate-heading-numbering.yml |
✅ Active |
apply_heading_corrections.py |
make apply-heading-corrections |
N/A (utility script) | ✅ Active |
validate_req_references.py |
make validate-req-references |
validate-req-references.yml |
✅ Active |
audit_feature_coverage.py |
make audit-feature-coverage |
audit-coverage.yml |
✅ Active |
audit_requirements_coverage.py |
make audit-requirements-coverage |
audit-coverage.yml |
✅ Active |
validate_api_go_defs_index.py |
make validate-go-defs-index |
docs-check (via Makefile) |
✅ Active |
validate_go_code_blocks.py |
make validate-go-code-blocks |
docs-check (via Makefile) |
✅ Active |
validate_go_spec_signature_consistency.py |
make validate-go-spec-signature-consistency |
docs-check (via Makefile) |
✅ Active |
validate_go_signature_sync.py |
make validate-go-signatures |
go-ci.yml |
✅ Active |
validate_go_spec_references.py |
make validate-go-spec-references |
go-ci.yml |
✅ Active |
apply_go_spec_references.py |
make apply-go-spec-references |
N/A (utility script) | ✅ Active |
generate_anchor.py |
make generate-anchor |
N/A (utility script) | ✅ Active |
| Context Propagation Check | make lint-go |
go-ci.yml |
✅ Active |
When adding new scripts:
- Place script in
scripts/directory - Make it executable:
chmod +x scripts/your_script.py - Add shebang line:
#!/usr/bin/env python3 - Use
ValidationIssueclass fromscripts/lib/_validation_utils.pyfor all error/warning reporting - Maintain a single consolidated list of issues (filter by severity/type when displaying)
- Use shared utilities from
scripts/lib/_validation_utils.pyinstead of duplicating code:- Use
import_module_with_fallback()for module imports - Use
find_markdown_files()orfind_feature_files()for file finding - Use path validation functions (
is_safe_path(),validate_file_name(), etc.) - Use heading extraction functions instead of custom implementations
- Use
generate_anchor_from_heading()directly (no wrapper functions) - Use
FileContentCacheto avoid repeated file reads (pass as parameter to functions that read files)
- Use
- For performance, compile regex patterns at module level instead of inside functions
- Add type hints to function signatures for better code clarity and maintainability
- Extract magic numbers and strings to module-level constants for improved readability
- Keep functions focused and reasonably sized (prefer smaller, focused functions over large monolithic ones)
- Use consistent error handling with
ValidationIssueobjects and specific exception types - Add to root
Makefilewith appropriate target - Create GitHub workflow in
.github/workflows/ - Update this README
- Ensure script has
--helpoption - Use proper exit codes (0 = success, 1 = failure)
- Use
OutputBuilderfromscripts/lib/_validation_utils.pyfor consistent output formatting:add_success_message()when validation passes with no issues.add_failure_message()when there are errorsadd_warnings_only_message()when there are only warnings (exit 0; optionalverbose_hintfor run-with-verbose text).
- Ensure code passes Python linting:
make lint-python
When modifying existing scripts:
- Update the corresponding Makefile target if needed
- Update the GitHub workflow if behavior changes
- Update this README if usage changes
- Test locally with
make <target>before committing - Ensure backward compatibility or update all references
- Run
make lint-pythonto ensure code quality standards are met - Add type hints to new functions or when modifying function signatures
- Refactor large functions into smaller, focused helper functions when appropriate
Shared library details are documented in scripts/lib/README.md.
- Root Makefile - Build and CI targets
- GitHub Workflows - CI pipeline configuration