This directory contains essential utility scripts for maintaining the TNFR Python Engine codebase. Only scripts actively used in CI/CD, build system, or core TNFR functionality are maintained here.
run_tests.sh - Test execution script (used in release workflow)check_language.py - English-only policy enforcementgenerate_stubs.py - Type stub generation and synchronizationcheck_changelog.py - Changelog validation for PRssync-readme-docs.py - Documentation synchronizationverify_internal_references.py - Internal reference validationrun_reproducible_benchmarks.py - Reproducible benchmark executioncompare_manifests.py - Build manifest comparisontnfr_is_prime.py - Prime number verification using TNFR physicsgenerate_stubs.py)This script helps prevent drift between Python implementations (.py) and type stubs (.pyi) by:
.py is newer than .pyi)stubgenpython scripts/generate_stubs.py
# or
make stubsGenerates .pyi stub files for any .py modules that don't have them.
python scripts/generate_stubs.py --check
# or
make stubs-checkReturns exit code 1 if any stubs are missing. Useful in CI pipelines.
python scripts/generate_stubs.py --check-sync
# or
make stubs-check-syncReturns exit code 1 if any .py files are newer than their corresponding .pyi stubs.
python scripts/generate_stubs.py --sync
# or
make stubs-syncRegenerates stub files for any modules where the .py file is newer than the .pyi file.
python scripts/generate_stubs.py --dry-runShows what would be done without making changes.
Run make help to see all available targets:
make stubs - Generate missing stub filesmake stubs-check - Check for missing stubs (used in pre-commit)make stubs-check-sync - Check for outdated stubs (used in CI)make stubs-sync - Regenerate outdated stubsmake help - Display all available Make targetsThe .pre-commit-config.yaml includes a hook that runs --check before commits to ensure no stubs are missing.
The type-check workflow includes two validation steps:
- name: Check stub files exist
run: python scripts/generate_stubs.py --check
- name: Check stub file synchronization
run: python scripts/generate_stubs.py --check-syncThis dual-layer check ensures:
The script compares file modification times:
.py file in src/tnfr/.pyi file existsmtime (modification time).py mtime > .pyi mtime, the stub is outdatedThis ensures that whenever a Python file is modified, its stub can be regenerated to stay in sync.
When writing factory functions, follow these steps to maintain stub synchronization:
.py with full type annotationsmake stubs-sync.pyi matches your signatures.py and .pyi togetherSee Architecture Guide — Factory Patterns for factory function guidelines.
If stubgen fails for a module:
.py filemypy is installed: pip install mypyIf the generated stub contains only Any types:
stubgen with --verbose for more detailsIf a file is reported as outdated but hasn't changed:
git operations that update mtimesmake stubs-sync to regenerate and resolverun_reproducible_benchmarks.py - Run benchmarks with deterministic seeds and generate checksums for artifactsThis script ensures reproducibility by:
Usage:
# Run all benchmarks with default seed
python scripts/run_reproducible_benchmarks.py
# Run specific benchmarks with custom seed
python scripts/run_reproducible_benchmarks.py \
--benchmarks comprehensive_cache_profiler full_pipeline_profile \
--seed 123 \
--output-dir artifacts
# Verify checksums against existing manifest
python scripts/run_reproducible_benchmarks.py --verify artifacts/manifest.json
# Use make targets
make reproduce # Run benchmarks with deterministic seeds
make reproduce-verify # Verify checksumsverify_internal_references.py - Verify internal markdown links in docs, notebooks, and scriptsrun_pip_audit.sh - Run pip-audit to scan for dependency vulnerabilitiescheck_changelog.py - Validate changelog formatrollback_release.py - Rollback failed releasespost_security_summary.py - Post security scan resultsgenerate_security_dashboard.py - Generate security reportsrun_pip_audit.sh)Scans installed Python dependencies for known security vulnerabilities using pip-audit.
Purpose:
Usage:
# Run basic audit
./scripts/run_pip_audit.sh
# Install pip-audit and run audit
./scripts/run_pip_audit.sh --install
# Generate JSON report for detailed analysis
./scripts/run_pip_audit.sh --json
# Show help
./scripts/run_pip_audit.sh --helpWhen to Use:
Integration:
.github/workflows/pip-audit.yml workflow behaviorSee SECURITY.md for the complete security update process.
check_language.py - Enforce language policylanguage_policy_data.py - Language policy configurationverify_consolidation.py - Verify code consolidationFor more information on individual scripts, see their inline documentation.