@teevee98/synapse-hub 0.0.0-stage → 3.8.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.agents/agents/api-engineer.md +67 -0
- package/.agents/agents/failure-analyst.md +75 -0
- package/.agents/agents/live-explorer.md +70 -0
- package/.agents/agents/orchestrator.md +104 -0
- package/.agents/agents/perf-engineer.md +74 -0
- package/.agents/agents/pom-crafter.md +112 -0
- package/.agents/agents/quality-gatekeeper.md +87 -0
- package/.agents/agents/test-designer.md +73 -0
- package/.agents/agents/test-runner.md +67 -0
- package/.agents/rules/author-integrity-guard.md +33 -0
- package/.agents/rules/communication-style.md +18 -0
- package/.agents/rules/context-engineering.md +37 -0
- package/.agents/rules/git-push-protocol.md +33 -0
- package/.agents/rules/graphify.md +14 -0
- package/.agents/rules/lessons-learned.md +25 -0
- package/.agents/rules/mandatory-playwright-live.md +25 -0
- package/.agents/rules/mobile_appium_rules.md +43 -0
- package/.agents/rules/performance_testing_rules.md +35 -0
- package/.agents/rules/skill-precedence.md +29 -0
- package/.agents/rules/systematic-debugging.md +36 -0
- package/.agents/skills/actor-qa-swarm/SKILL.md +77 -0
- package/.agents/skills/actor-qa-swarm/examples/broker_sharding_sample.json +12 -0
- package/.agents/skills/agent-orchestration-multi-agent-optimize/SKILL.md +88 -0
- package/.agents/skills/agent-orchestration-multi-agent-optimize/examples/swarm_workload_config.json +15 -0
- package/.agents/skills/agentless-qa-repair/SKILL.md +69 -0
- package/.agents/skills/agentless-qa-repair/examples/healing_report_sample.json +17 -0
- package/.agents/skills/agentless-qa-repair/examples/three_phase_repair_workflow.md +40 -0
- package/.agents/skills/antigravity-test-sentinel/SKILL.md +63 -0
- package/.agents/skills/antigravity-test-sentinel/examples/dod_gate_policy.json +11 -0
- package/.agents/skills/antigravity-test-sentinel/examples/sprint_dod_enforcement.md +47 -0
- package/.agents/skills/api-network-mocking-interception/SKILL.md +142 -0
- package/.agents/skills/api-network-mocking-interception/examples/network_route_stub.json +9 -0
- package/.agents/skills/api-spec-to-e2e-matrix/SKILL.md +80 -0
- package/.agents/skills/api-spec-to-e2e-matrix/examples/sample_openapi.json +19 -0
- package/.agents/skills/architecture-decision-records/SKILL.md +64 -0
- package/.agents/skills/architecture-decision-records/examples/0001-record-architecture-decisions.md +12 -0
- package/.agents/skills/auth-session-and-cookie-manager/SKILL.md +75 -0
- package/.agents/skills/auth-session-and-cookie-manager/examples/multi_role_auth_matrix.md +70 -0
- package/.agents/skills/auth-session-and-cookie-manager/examples/storage_state_sample.json +11 -0
- package/.agents/skills/backend-load-and-stress-patterns/SKILL.md +85 -0
- package/.agents/skills/backend-load-and-stress-patterns/examples/k6_load_test_sample.js +13 -0
- package/.agents/skills/backend-load-and-stress-patterns/references/k6_load_template.js +82 -0
- package/.agents/skills/bats-testing-patterns/SKILL.md +100 -0
- package/.agents/skills/bats-testing-patterns/examples/cli_runner_test.bats +6 -0
- package/.agents/skills/bats-testing-patterns/resources/implementation-playbook.md +614 -0
- package/.agents/skills/clean-pom-crafter/SKILL.md +110 -0
- package/.agents/skills/clean-pom-crafter/examples/standard_test_case.groovy +28 -0
- package/.agents/skills/clean-pom-crafter/references/pom_patterns.groovy +138 -0
- package/.agents/skills/code-refactoring-refactor-clean/SKILL.md +64 -0
- package/.agents/skills/code-refactoring-refactor-clean/examples/refactored_page_sample.groovy +9 -0
- package/.agents/skills/code-refactoring-refactor-clean/examples/refactored_playwright_pom.ts +52 -0
- package/.agents/skills/code-refactoring-refactor-clean/resources/implementation-playbook.md +881 -0
- package/.agents/skills/consumer-driven-contract-testing/SKILL.md +147 -0
- package/.agents/skills/consumer-driven-contract-testing/examples/order_service_pact.json +45 -0
- package/.agents/skills/db-state-verifier-and-seeder/SKILL.md +123 -0
- package/.agents/skills/db-state-verifier-and-seeder/examples/db_fixture_seed.json +12 -0
- package/.agents/skills/e2e-testing-patterns/SKILL.md +103 -0
- package/.agents/skills/e2e-testing-patterns/examples/playwright_sharded_config.ts +12 -0
- package/.agents/skills/e2e-testing-patterns/resources/implementation-playbook.md +522 -0
- package/.agents/skills/event-stream-qa-orchestrator/SKILL.md +79 -0
- package/.agents/skills/event-stream-qa-orchestrator/examples/timeline_sample.jsonl +2 -0
- package/.agents/skills/failure-autopsy-and-healing/SKILL.md +66 -0
- package/.agents/skills/failure-autopsy-and-healing/examples/closed_loop_healing_walkthrough.md +48 -0
- package/.agents/skills/failure-autopsy-and-healing/examples/sample_junit_failure.xml +8 -0
- package/.agents/skills/failure-autopsy-and-healing/references/healing_matrix.md +64 -0
- package/.agents/skills/failure-autopsy-and-healing/references/qa_investigation_protocol.md +56 -0
- package/.agents/skills/failure-autopsy-and-healing/scripts/triage_failures.sh +83 -0
- package/.agents/skills/file-and-report-validator/SKILL.md +90 -0
- package/.agents/skills/file-and-report-validator/examples/sample_export_schema.json +14 -0
- package/.agents/skills/flaky-test-sentinel-and-quarantine/SKILL.md +114 -0
- package/.agents/skills/flaky-test-sentinel-and-quarantine/examples/quarantine_registry.json +11 -0
- package/.agents/skills/gherkin-to-suite/SKILL.md +103 -0
- package/.agents/skills/gherkin-to-suite/examples/checkout.feature +39 -0
- package/.agents/skills/gherkin-to-suite/examples/suite_report_sample.json +334 -0
- package/.agents/skills/github-actions-templates/SKILL.md +77 -0
- package/.agents/skills/github-actions-templates/examples/matrix_test_pipeline.yml +8 -0
- package/.agents/skills/graphify-impact-analyzer/SKILL.md +76 -0
- package/.agents/skills/graphify-impact-analyzer/examples/dependency_blast_radius.json +8 -0
- package/.agents/skills/katalon-cli-runner/SKILL.md +76 -0
- package/.agents/skills/katalon-cli-runner/examples/headless_kre_exec.sh +3 -0
- package/.agents/skills/katalon-cli-runner/references/groovy-patterns.md +209 -0
- package/.agents/skills/katalon-cli-runner/references/katalon-api.md +155 -0
- package/.agents/skills/katalon-cli-runner/references/runner_commands.md +67 -0
- package/.agents/skills/lam-script-generator/SKILL.md +123 -0
- package/.agents/skills/lam-script-generator/examples/user_story_sample.md +8 -0
- package/.agents/skills/lean-code-ladder/SKILL.md +94 -0
- package/.agents/skills/lean-code-ladder/examples/ladder_walkthrough.md +37 -0
- package/.agents/skills/lean-impact-scoreboard/SKILL.md +48 -0
- package/.agents/skills/lean-impact-scoreboard/examples/sample_benchmark_gain.md +20 -0
- package/.agents/skills/lean-impact-scoreboard/examples/sample_scoreboard.md +15 -0
- package/.agents/skills/meta-prompt-crafter/SKILL.md +107 -0
- package/.agents/skills/meta-prompt-crafter/examples/qa_prompt_template.md +35 -0
- package/.agents/skills/mipro-prompt-compiler/SKILL.md +59 -0
- package/.agents/skills/mipro-prompt-compiler/examples/compiled_module_sample.json +22 -0
- package/.agents/skills/mipro-prompt-compiler/examples/dspy_assertion_optimizer_case.md +46 -0
- package/.agents/skills/mobile-appium-som/SKILL.md +88 -0
- package/.agents/skills/mobile-appium-som/examples/BaseScreen.java +88 -0
- package/.agents/skills/mobile-appium-som/examples/LoginScreen.java +46 -0
- package/.agents/skills/mobile-appium-som/examples/TC_MobileLogin.java +43 -0
- package/.agents/skills/persistent-planning-files/SKILL.md +108 -0
- package/.agents/skills/persistent-planning-files/examples/task_plan_example.md +56 -0
- package/.agents/skills/playwright-live-interaction/SKILL.md +131 -0
- package/.agents/skills/playwright-live-interaction/examples/live_probe_script.js +5 -0
- package/.agents/skills/playwright-live-interaction/references/advanced_superpowers.md +160 -0
- package/.agents/skills/playwright-live-interaction/references/compact_accessibility_snapshots.md +75 -0
- package/.agents/skills/playwright-live-interaction/references/recipes.md +388 -0
- package/.agents/skills/playwright-live-interaction/references/swarm_orchestration.md +134 -0
- package/.agents/skills/playwright-webapp-testing/SKILL.md +93 -0
- package/.agents/skills/playwright-webapp-testing/examples/server_lifecycle_playwright.py +63 -0
- package/.agents/skills/qa-aci-interface/SKILL.md +67 -0
- package/.agents/skills/qa-aci-interface/examples/surgical_code_window_walkthrough.md +40 -0
- package/.agents/skills/qa-aci-interface/examples/surgical_edit_sample.json +12 -0
- package/.agents/skills/qa-memory-os/SKILL.md +80 -0
- package/.agents/skills/qa-memory-os/examples/archival_memory_sample.json +21 -0
- package/.agents/skills/rbt-manual-testing/SKILL.md +137 -0
- package/.agents/skills/rbt-manual-testing/examples/checkout_rbt_manual_suite.md +25 -0
- package/.agents/skills/rbt-manual-testing/references/field_validation_checklist.md +29 -0
- package/.agents/skills/repo-quality-audit/SKILL.md +68 -0
- package/.agents/skills/repo-quality-audit/examples/sample_audit_walkthrough.md +15 -0
- package/.agents/skills/repo-quality-audit/examples/sample_repo_audit.md +33 -0
- package/.agents/skills/review-spec/SKILL.md +60 -0
- package/.agents/skills/review-spec/examples/pocock_grilling_decision_rubric.md +40 -0
- package/.agents/skills/review-spec/examples/sample_spec_review.md +33 -0
- package/.agents/skills/security-dast-sentinel/SKILL.md +119 -0
- package/.agents/skills/security-dast-sentinel/examples/dast_scan_config.json +10 -0
- package/.agents/skills/security-dast-sentinel/references/AI-AND-LLM.md +113 -0
- package/.agents/skills/security-dast-sentinel/references/ATTACK-CLASSES.md +89 -0
- package/.agents/skills/security-dast-sentinel/references/dast_recipes.ts +33 -0
- package/.agents/skills/self-healing-locator/SKILL.md +86 -0
- package/.agents/skills/self-healing-locator/examples/aom_diff_sample.json +16 -0
- package/.agents/skills/senior-code-review/SKILL.md +108 -0
- package/.agents/skills/senior-code-review/examples/sample_review_walkthrough.md +29 -0
- package/.agents/skills/skillspector-security-guard/SKILL.md +57 -0
- package/.agents/skills/skillspector-security-guard/examples/audit_threat_vectors_report.json +35 -0
- package/.agents/skills/skillspector-security-guard/examples/safe_mcp_config.json +12 -0
- package/.agents/skills/surgical-coding-principles/SKILL.md +89 -0
- package/.agents/skills/surgical-coding-principles/examples/surgical_vs_scope_creep.md +46 -0
- package/.agents/skills/synthetic-test-data-generator/SKILL.md +135 -0
- package/.agents/skills/synthetic-test-data-generator/examples/idempotent_data_recipe.json +9 -0
- package/.agents/skills/systematic-debugging/SKILL.md +100 -0
- package/.agents/skills/systematic-debugging/examples/four_phase_case.md +44 -0
- package/.agents/skills/technical-debt-harvester/SKILL.md +70 -0
- package/.agents/skills/technical-debt-harvester/examples/sample_debt_ledger.md +25 -0
- package/.agents/skills/technical-debt-harvester/examples/sample_ledger_output.md +20 -0
- package/.agents/skills/test-driven-development/SKILL.md +114 -0
- package/.agents/skills/test-driven-development/examples/red_green_refactor_qa.md +78 -0
- package/.agents/skills/token-and-context-optimizer/SKILL.md +70 -0
- package/.agents/skills/token-and-context-optimizer/examples/distilled_log_sample.txt +3 -0
- package/.agents/skills/token-and-context-optimizer/references/context_engineering_guide.md +49 -0
- package/.agents/skills/tot-exploratory-testing/SKILL.md +59 -0
- package/.agents/skills/tot-exploratory-testing/examples/payment_gateway_tot_tree.json +62 -0
- package/.agents/skills/tot-exploratory-testing/examples/tot_graph_sample.json +35 -0
- package/.agents/skills/verification-before-completion/SKILL.md +100 -0
- package/.agents/skills/verification-before-completion/examples/evidence_log_example.md +46 -0
- package/.agents/skills/visual-regression-sentinel/SKILL.md +82 -0
- package/.agents/skills/visual-regression-sentinel/examples/visual_mask_rules.json +9 -0
- package/.agents/skills/wcag-audit-patterns/SKILL.md +77 -0
- package/.agents/skills/wcag-audit-patterns/examples/wcag_compliance_checklist.json +10 -0
- package/.agents/skills/wcag-audit-patterns/resources/implementation-playbook.md +541 -0
- package/.agents/skills/web-agent-gym-benchmarking/SKILL.md +62 -0
- package/.agents/skills/web-agent-gym-benchmarking/examples/benchmark_report_sample.json +22 -0
- package/.agents/skills/web-agent-gym-benchmarking/examples/enterprise_tasks_suite.json +38 -0
- package/.agents/skills/web-vitals-and-performance-profiler/SKILL.md +65 -0
- package/.agents/skills/web-vitals-and-performance-profiler/examples/cwv_budget_policy.json +6 -0
- package/.agents/skills/web-vitals-and-performance-profiler/examples/playwright_cwv_profiler_fixture.ts +118 -0
- package/.agents/templates/completion_report.md +57 -0
- package/.agents/workflows/analyze_requirement_document.md +18 -0
- package/.agents/workflows/export_testcases_excel.md +32 -0
- package/.agents/workflows/generate_combinatorial_test_data.md +28 -0
- package/.agents/workflows/generate_cross_module_test_plan.md +37 -0
- package/.agents/workflows/generate_manual_testcases_rbt.md +56 -0
- package/.agents/workflows/generate_requirements_from_website.md +25 -0
- package/.agents/workflows/generate_testcases_from_requirements.md +21 -0
- package/.agents/workflows/graphify.md +10 -0
- package/.agents/workflows/test-impact.md +15 -0
- package/.agents/workflows/verify.md +34 -0
- package/.cursor/rules/agents.mdc +16 -0
- package/.cursor/rules/language.mdc +7 -0
- package/.cursor/rules/synapse-qa.mdc +24 -0
- package/.cursorrules +27 -0
- package/.dockerignore +53 -0
- package/.pre-commit-hooks.yaml +14 -0
- package/.windsurfrules +26 -0
- package/AGENTS.md +86 -0
- package/CLAUDE.md +54 -0
- package/Dockerfile +81 -0
- package/LICENSE +52 -0
- package/NOTICE +264 -0
- package/README.en.md +172 -0
- package/README.md +171 -2
- package/action.yml +51 -0
- package/agentskills.json +16 -0
- package/bin/agent-qa.js +138 -0
- package/docker-compose.yml +74 -0
- package/docs/ARCHITECTURE.en.md +197 -0
- package/docs/ARCHITECTURE.md +198 -0
- package/docs/CI_CD_INTEGRATION.en.md +170 -0
- package/docs/CI_CD_INTEGRATION.md +170 -0
- package/docs/CLI_REFERENCE.en.md +175 -0
- package/docs/CLI_REFERENCE.md +177 -0
- package/docs/CONTRIBUTING.en.md +49 -0
- package/docs/CONTRIBUTING.md +49 -0
- package/docs/PERFORMANCE_AUDIT_REPORT.md +784 -0
- package/docs/PLUGIN_DEVELOPMENT_GUIDE.md +127 -0
- package/docs/QUALITY_GATES.en.md +121 -0
- package/docs/QUALITY_GATES.md +121 -0
- package/docs/TOKEN_QUOTA_PLAYBOOK.md +41 -0
- package/docs/TOOL_CATALOG.md +129 -0
- package/docs/adopted-ecosystem-tools.md +96 -0
- package/docs/research/EXTERNAL_AGENT_SKILLS_SURVEY.md +1062 -0
- package/docs/research/agent_skill_training_analysis.md +1359 -0
- package/docs/schemas/synapse.config.schema.json +87 -0
- package/package.json +94 -4
- package/plugin.json +31 -0
- package/scripts/generate_skill_examples.py +244 -0
- package/scripts/install.ps1 +112 -0
- package/scripts/install_global_plugin.ps1 +94 -0
- package/scripts/install_global_plugin.sh +49 -0
- package/scripts/lint_skills.ps1 +57 -0
- package/scripts/package_dist.py +337 -0
- package/scripts/setup.sh +59 -0
- package/scripts/update_hub.ps1 +19 -0
- package/scripts/update_hub.sh +15 -0
- package/skills_manifest.json +854 -0
- package/synapse.config.json +32 -0
- package/templates/PROJECT_AI_GUIDE_TEMPLATE.md +111 -0
- package/templates/PROJECT_STATE_TEMPLATE.md +20 -0
- package/templates/ai_bridges/CLAUDE.md +54 -0
- package/templates/ai_bridges/copilot-instructions.md +20 -0
- package/templates/ai_bridges/cursor_synapse_qa.mdc +24 -0
- package/templates/ai_bridges/windsurfrules +26 -0
- package/templates/ci/github-actions-synapse.yml +95 -0
- package/templates/ci/gitlab-ci-synapse.yml +16 -0
- package/templates/ui/index.html +1069 -0
- package/templates/welcome.html.tmpl +2079 -0
- package/tools/.infer_baseline.json +30 -0
- package/tools/TOOLS_RUNBOOK.md +1553 -0
- package/tools/TOOL_CATALOG.json +1769 -0
- package/tools/__init__.py +43 -0
- package/tools/_openapi_parser.py +158 -0
- package/tools/agent_canary.py +525 -0
- package/tools/agentless_patcher.py +417 -0
- package/tools/analyze_project.py +258 -0
- package/tools/api_drift_sentinel.py +208 -0
- package/tools/api_fuzzer.py +762 -0
- package/tools/author_integrity.py +184 -0
- package/tools/auto_heal.py +271 -0
- package/tools/auto_heal_reflexion.py +532 -0
- package/tools/autogen_qa_broker.py +844 -0
- package/tools/benchmark_swarm_context.py +394 -0
- package/tools/browser_helpers.js +746 -0
- package/tools/browsergym_eval.py +236 -0
- package/tools/bug_reporter.py +252 -0
- package/tools/bump_version.py +423 -0
- package/tools/cache_resolver.py +1214 -0
- package/tools/check_env.py +426 -0
- package/tools/check_version_sync.py +256 -0
- package/tools/ci_healing_hook.py +126 -0
- package/tools/cli.py +1598 -0
- package/tools/config_decoupler.py +253 -0
- package/tools/contract_validator.py +141 -0
- package/tools/core/__init__.py +70 -0
- package/tools/core/adapters.py +431 -0
- package/tools/core/circuit_breaker.py +263 -0
- package/tools/core/cli_runtime.py +66 -0
- package/tools/core/file_lock.py +159 -0
- package/tools/core/i18n.py +394 -0
- package/tools/core/memory_bus.py +905 -0
- package/tools/core/process_supervisor.py +332 -0
- package/tools/core/telemetry.py +329 -0
- package/tools/count_tokens.py +1267 -0
- package/tools/create_mock_docx.py +104 -0
- package/tools/dashboard_generator.py +2419 -0
- package/tools/db_sandbox.py +675 -0
- package/tools/debt_harvester.py +237 -0
- package/tools/distill_log.py +161 -0
- package/tools/dspy_qa_signatures.py +356 -0
- package/tools/e2e_flow_prober.py +132 -0
- package/tools/export_postman_collection.py +945 -0
- package/tools/flaky_detector.py +389 -0
- package/tools/fsm_enforcer.py +450 -0
- package/tools/fsm_middleware.py +401 -0
- package/tools/fuzz_payloads.py +197 -0
- package/tools/generate_allure_report.py +88 -0
- package/tools/generate_api_matrix.py +193 -0
- package/tools/generate_jmx_plan.py +1322 -0
- package/tools/generate_sbom.py +252 -0
- package/tools/generate_tc_from_story.py +203 -0
- package/tools/generate_test_reports.py +133 -0
- package/tools/generate_tool_catalog.py +482 -0
- package/tools/gherkin_suite.py +758 -0
- package/tools/git_pre_commit_guard.py +298 -0
- package/tools/goldfish_review.py +366 -0
- package/tools/heal/__init__.py +28 -0
- package/tools/heal_pr_automator.py +220 -0
- package/tools/heuristic_locator_matcher.py +351 -0
- package/tools/hub_publisher.py +623 -0
- package/tools/humanize_linter.py +438 -0
- package/tools/infer_linter.py +977 -0
- package/tools/init_config.py +307 -0
- package/tools/interview_story.py +116 -0
- package/tools/jira_sync.py +566 -0
- package/tools/jtl_analyzer.py +474 -0
- package/tools/lint/__init__.py +30 -0
- package/tools/lint_ai_docs.py +374 -0
- package/tools/lookup_tc.py +165 -0
- package/tools/lookup_xpath.py +167 -0
- package/tools/matrix_sharder.py +148 -0
- package/tools/mcp/__init__.py +18 -0
- package/tools/mcp_docx_server.ps1 +13 -0
- package/tools/mcp_docx_server.py +851 -0
- package/tools/mcp_excel_server.ps1 +13 -0
- package/tools/mcp_excel_server.py +441 -0
- package/tools/mcp_server.py +724 -0
- package/tools/md_to_xlsx.py +327 -0
- package/tools/micro_mutator.py +887 -0
- package/tools/mipro_assertion_tuner.py +210 -0
- package/tools/network_mock_shield.py +311 -0
- package/tools/newman_analyzer.py +384 -0
- package/tools/omni_emitter.py +579 -0
- package/tools/omni_parser.py +450 -0
- package/tools/omni_transpiler.py +168 -0
- package/tools/openxml_guard.py +438 -0
- package/tools/output_formatter.py +182 -0
- package/tools/package_release.py +325 -0
- package/tools/perf/__init__.py +24 -0
- package/tools/pinpoint_failure.py +190 -0
- package/tools/project_state.py +171 -0
- package/tools/qa_event_stream.py +358 -0
- package/tools/repo_map.py +346 -0
- package/tools/report/__init__.py +32 -0
- package/tools/reversible_sandbox.py +344 -0
- package/tools/safety_firewall.py +437 -0
- package/tools/security_coverage_ledger.py +538 -0
- package/tools/security_scanner.py +229 -0
- package/tools/senior_code_review.py +393 -0
- package/tools/setup_project.py +770 -0
- package/tools/skill_collision_guard.py +304 -0
- package/tools/skill_profiles.py +217 -0
- package/tools/skill_vault.py +481 -0
- package/tools/skillspector.py +1278 -0
- package/tools/smart_visual_masker.py +132 -0
- package/tools/spec_drift_sentinel.py +438 -0
- package/tools/swe_qa_aci.py +369 -0
- package/tools/synapse_observer.py +485 -0
- package/tools/synapse_qa_bench.py +190 -0
- package/tools/sync_agent_rules.py +274 -0
- package/tools/telemetry_correlator.py +397 -0
- package/tools/template_excel_exporter.py +514 -0
- package/tools/templates/jmeter-distributed/README.md +54 -0
- package/tools/templates/jmeter-distributed/docker-compose.yml +83 -0
- package/tools/test_impact.py +419 -0
- package/tools/test_memory_os.py +462 -0
- package/tools/textgrad_mutation_optimizer.py +237 -0
- package/tools/tms_sync_bridge.py +834 -0
- package/tools/tot_exploratory_tester.py +239 -0
- package/tools/trace_data_flow.py +240 -0
- package/tools/traffic_session_converter.py +256 -0
- package/tools/trend_analytics.py +314 -0
- package/tools/ui_server.py +401 -0
- package/tools/universal_ir.py +488 -0
- package/tools/update_sentinel.py +383 -0
- package/tools/validate_groovy_scripts.py +173 -0
- package/tools/verify_all.py +1259 -0
- package/tools/visual_diff_canvas.py +143 -0
- package/tools/visual_som_helper.py +550 -0
- package/tools/watch_mode.py +308 -0
- package/tools/wcag_audit.py +239 -0
- package/tools/welcome_page.py +290 -0
|
@@ -0,0 +1,1259 @@
|
|
|
1
|
+
#!/usr/bin/env python3
|
|
2
|
+
# SPDX-FileCopyrightText: Copyright (c) 2026 Thế Vị (@TeeVee998). All rights reserved.
|
|
3
|
+
# SPDX-License-Identifier: MIT
|
|
4
|
+
# Project: Synapse-Hub (https://github.com/TeeVee998/Synapse-Hub)
|
|
5
|
+
|
|
6
|
+
"""
|
|
7
|
+
Enterprise Multi-Project DoD Verifier (One Command Quality Gate)
|
|
8
|
+
---------------------------------------------------------
|
|
9
|
+
Consolidates all definition-of-done criteria into a single executable command.
|
|
10
|
+
|
|
11
|
+
Verifies:
|
|
12
|
+
Gate 0: Author Attribution & Copyright Integrity: Verifies author provenance (Thế Vị @TeeVee998).
|
|
13
|
+
Gate 1: 100% UTF-8 No BOM across all repository files (8 extensions).
|
|
14
|
+
Gate 2: Path Portability: Zero absolute machine paths (file:///C:, /Users/...).
|
|
15
|
+
Gate 3: Clean POM & Flat Architecture: Zero raw XPaths or findTestObject in Scripts/.
|
|
16
|
+
Gate 4: AI Docs & Artifacts Anti-Drift: No hallucinated PageClasses, Suites, or Tools.
|
|
17
|
+
Gate 5: Cleanup Blacklist: No temporary properties or debug dump files on disk.
|
|
18
|
+
Gate 6: Credential Security: No plaintext passwords in Profiles/default.glbl or repository.
|
|
19
|
+
Gate 7: Static Defect Sentinel: Meta Infer-style AST scan for fake passes and empty catches.
|
|
20
|
+
Gate 8: Syntactic Micro-Mutation Sentinel: Injects syntactic faults to eliminate tautological tests (Mutation Score >= 80%).
|
|
21
|
+
Gate 9: Tier-2 Skill Collision Guard: Addy Osmani offline TF-IDF cosine similarity check (similarity < 0.75).
|
|
22
|
+
Gate 10: Performance & SLA Sentinel: Enforces P95/P99 latency budgets and max error rate gates on JTL/k6 reports.
|
|
23
|
+
|
|
24
|
+
Supports:
|
|
25
|
+
- Hub Mode: Verifies the centralized QA Hub / skills repository integrity.
|
|
26
|
+
- Target Mode: Verifies enterprise automation target test suites (e.g. Katalon/Playwright).
|
|
27
|
+
|
|
28
|
+
Usage:
|
|
29
|
+
python3 tools/verify_all.py [--mode auto|hub|target]
|
|
30
|
+
"""
|
|
31
|
+
|
|
32
|
+
import os
|
|
33
|
+
import sys
|
|
34
|
+
import subprocess
|
|
35
|
+
import glob
|
|
36
|
+
import re
|
|
37
|
+
import json
|
|
38
|
+
import io
|
|
39
|
+
from datetime import datetime
|
|
40
|
+
import ast
|
|
41
|
+
import builtins
|
|
42
|
+
import argparse
|
|
43
|
+
|
|
44
|
+
# Enforce UTF-8 stdout encoding and guard against non-blocking stream BlockingIOError
|
|
45
|
+
for stream in (sys.stdout, sys.stderr):
|
|
46
|
+
if hasattr(stream, 'fileno'):
|
|
47
|
+
try:
|
|
48
|
+
os.set_blocking(stream.fileno(), True)
|
|
49
|
+
except Exception:
|
|
50
|
+
pass
|
|
51
|
+
if hasattr(stream, 'reconfigure'):
|
|
52
|
+
try:
|
|
53
|
+
stream.reconfigure(encoding='utf-8', line_buffering=True)
|
|
54
|
+
except Exception:
|
|
55
|
+
pass
|
|
56
|
+
|
|
57
|
+
|
|
58
|
+
def safe_print(text="", stream=sys.stdout):
|
|
59
|
+
"""Safely prints text to the given stream, handling BlockingIOError or encoding issues."""
|
|
60
|
+
try:
|
|
61
|
+
if text:
|
|
62
|
+
stream.write(f"{text}\n")
|
|
63
|
+
else:
|
|
64
|
+
stream.write("\n")
|
|
65
|
+
stream.flush()
|
|
66
|
+
except BlockingIOError:
|
|
67
|
+
try:
|
|
68
|
+
if hasattr(stream, 'fileno'):
|
|
69
|
+
os.set_blocking(stream.fileno(), True)
|
|
70
|
+
stream.write(f"{text}\n")
|
|
71
|
+
stream.flush()
|
|
72
|
+
except OSError as err:
|
|
73
|
+
_ = err
|
|
74
|
+
except Exception:
|
|
75
|
+
try:
|
|
76
|
+
print(text)
|
|
77
|
+
except Exception as fallback_err:
|
|
78
|
+
_ = fallback_err
|
|
79
|
+
|
|
80
|
+
BOM_EXTENSIONS = (
|
|
81
|
+
".groovy", ".tc", ".ts", ".glbl", ".md", ".py", ".json", ".ps1",
|
|
82
|
+
".java", ".yaml", ".yml", ".xml"
|
|
83
|
+
)
|
|
84
|
+
|
|
85
|
+
# Module-level paths
|
|
86
|
+
SCRIPT_DIR = os.path.dirname(os.path.abspath(__file__))
|
|
87
|
+
REPO_ROOT = os.path.abspath(os.path.join(SCRIPT_DIR, ".."))
|
|
88
|
+
|
|
89
|
+
# Machine-specific absolute path patterns for Gate 2
|
|
90
|
+
FORBIDDEN_PATH_PATTERNS = [
|
|
91
|
+
(re.compile(r'file:///[a-zA-Z]:', re.IGNORECASE), "Machine file URI (file:///...)"),
|
|
92
|
+
(re.compile(r'\b[a-zA-Z]:\\Users\\[a-zA-Z0-9_\-]+\\', re.IGNORECASE), "Windows User directory path"),
|
|
93
|
+
(re.compile(r'\b/Users/[a-zA-Z0-9_\-]+/', re.IGNORECASE), "macOS/Unix User directory path"),
|
|
94
|
+
(re.compile(r'\b/home/[a-zA-Z0-9_\-]+/', re.IGNORECASE), "Linux User home directory path"),
|
|
95
|
+
(re.compile(r'\b[a-zA-Z]:[/\\](?:agent-skills|workspace|jenkins|builds)\b', re.IGNORECASE), "Machine-specific repository path"),
|
|
96
|
+
(re.compile(r'[/\\\\]legacy_abs_path[/\\\\]', re.IGNORECASE), "Legacy absolute path reference"),
|
|
97
|
+
]
|
|
98
|
+
|
|
99
|
+
|
|
100
|
+
def print_header(title):
|
|
101
|
+
print("\n" + "=" * 70)
|
|
102
|
+
print(f" {title}")
|
|
103
|
+
print("=" * 70)
|
|
104
|
+
|
|
105
|
+
|
|
106
|
+
def detect_repo_mode(repo_root):
|
|
107
|
+
"""Detects whether the repository is a QA Hub or a Target Test Suite."""
|
|
108
|
+
has_groovy_tests = any(
|
|
109
|
+
f.endswith(".groovy")
|
|
110
|
+
for f in glob.glob(os.path.join(repo_root, "Scripts", "**", "*.groovy"), recursive=True)
|
|
111
|
+
)
|
|
112
|
+
has_katalon_project = (
|
|
113
|
+
os.path.exists(os.path.join(repo_root, ".project"))
|
|
114
|
+
or os.path.isdir(os.path.join(repo_root, "Keywords", "pages"))
|
|
115
|
+
)
|
|
116
|
+
has_playwright_project = (
|
|
117
|
+
os.path.exists(os.path.join(repo_root, "playwright.config.ts"))
|
|
118
|
+
or os.path.exists(os.path.join(repo_root, "playwright.config.js"))
|
|
119
|
+
)
|
|
120
|
+
|
|
121
|
+
if has_groovy_tests or has_katalon_project or has_playwright_project:
|
|
122
|
+
return "TARGET"
|
|
123
|
+
|
|
124
|
+
if (
|
|
125
|
+
os.path.exists(os.path.join(repo_root, "skills_manifest.json"))
|
|
126
|
+
or os.path.isdir(os.path.join(repo_root, ".agents", "skills"))
|
|
127
|
+
):
|
|
128
|
+
return "HUB"
|
|
129
|
+
|
|
130
|
+
return "TARGET"
|
|
131
|
+
|
|
132
|
+
|
|
133
|
+
def resolve_target_repo(cli_target=None, cli_repo=None):
|
|
134
|
+
"""
|
|
135
|
+
Resolves the target repository path with the following precedence:
|
|
136
|
+
1. Explicit CLI argument (--repo / --path or positional target).
|
|
137
|
+
2. Environment variable TARGET_PROJECT_DIR.
|
|
138
|
+
3. Current Working Directory (if different from Hub and contains project markers).
|
|
139
|
+
4. Default fallback: QA Hub root (parent of tools/).
|
|
140
|
+
"""
|
|
141
|
+
hub_root = os.path.abspath(os.path.join(SCRIPT_DIR, ".."))
|
|
142
|
+
|
|
143
|
+
# 1. Explicit CLI flag or positional target
|
|
144
|
+
chosen = cli_repo or cli_target
|
|
145
|
+
if chosen:
|
|
146
|
+
resolved = os.path.abspath(chosen)
|
|
147
|
+
if not os.path.exists(resolved):
|
|
148
|
+
raise FileNotFoundError(f"Specified target repository path does not exist: {resolved}")
|
|
149
|
+
return resolved
|
|
150
|
+
|
|
151
|
+
# 2. Environment variable
|
|
152
|
+
env_dir = os.environ.get("TARGET_PROJECT_DIR")
|
|
153
|
+
if env_dir and os.path.exists(env_dir):
|
|
154
|
+
return os.path.abspath(env_dir)
|
|
155
|
+
|
|
156
|
+
# 3. Current Working Directory detection
|
|
157
|
+
cwd = os.path.abspath(os.getcwd())
|
|
158
|
+
if cwd.lower() != hub_root.lower():
|
|
159
|
+
project_markers = [
|
|
160
|
+
"Scripts", "Keywords", "Test Cases", "Test Suites",
|
|
161
|
+
"playwright.config.ts", "playwright.config.js",
|
|
162
|
+
".project", "pom.xml", "build.gradle", "package.json", "tests"
|
|
163
|
+
]
|
|
164
|
+
if any(os.path.exists(os.path.join(cwd, marker)) for marker in project_markers):
|
|
165
|
+
return cwd
|
|
166
|
+
|
|
167
|
+
# 4. Default fallback to QA Hub root
|
|
168
|
+
return hub_root
|
|
169
|
+
|
|
170
|
+
|
|
171
|
+
def gate_0_author_integrity(repo_root, mode="AUTO"):
|
|
172
|
+
"""Gate 0: Verifies author attribution and MIT license provenance across source manifests."""
|
|
173
|
+
print("\n[GATE 0] Verifying Author Attribution & MIT License Integrity...")
|
|
174
|
+
try:
|
|
175
|
+
from author_integrity import (
|
|
176
|
+
verify_author_attribution,
|
|
177
|
+
get_canonical_watermark,
|
|
178
|
+
verify_author_fingerprint,
|
|
179
|
+
DEFAULT_REPO_ROOT,
|
|
180
|
+
)
|
|
181
|
+
except ImportError:
|
|
182
|
+
import sys
|
|
183
|
+
sys.path.insert(0, os.path.dirname(os.path.abspath(__file__)))
|
|
184
|
+
from author_integrity import (
|
|
185
|
+
verify_author_attribution,
|
|
186
|
+
get_canonical_watermark,
|
|
187
|
+
verify_author_fingerprint,
|
|
188
|
+
DEFAULT_REPO_ROOT,
|
|
189
|
+
)
|
|
190
|
+
|
|
191
|
+
# 1. Author metadata hash verification
|
|
192
|
+
if not verify_author_fingerprint():
|
|
193
|
+
print("[FAIL] Author attribution reference mismatch! Original creator ('Thế Vị @TeeVee998') has been altered.")
|
|
194
|
+
return False
|
|
195
|
+
|
|
196
|
+
# 2. In HUB mode, verify the Hub repository itself.
|
|
197
|
+
# In TARGET mode, verify the Hub tools root to guarantee engine integrity.
|
|
198
|
+
check_root = repo_root if mode == "HUB" else DEFAULT_REPO_ROOT
|
|
199
|
+
valid, violations = verify_author_attribution(check_root)
|
|
200
|
+
license_violations = [v for v in violations if "LICENSE" in v]
|
|
201
|
+
if license_violations:
|
|
202
|
+
print("[FAIL] Author Attribution & MIT License Violated:")
|
|
203
|
+
for v in license_violations:
|
|
204
|
+
print(f" • {v}")
|
|
205
|
+
print(" Under MIT License, original author copyright notice to 'Thế Vị (@TeeVee998)' must be preserved in LICENSE.")
|
|
206
|
+
return False
|
|
207
|
+
elif not valid:
|
|
208
|
+
# Informational notices for downstream forks with customized package.json / README
|
|
209
|
+
print("[INFO] Downstream attribution notice:")
|
|
210
|
+
for v in violations:
|
|
211
|
+
print(f" • {v}")
|
|
212
|
+
print(f"[PASS] Author Attribution & MIT License Provenance verified intact: {get_canonical_watermark()}")
|
|
213
|
+
return True
|
|
214
|
+
|
|
215
|
+
|
|
216
|
+
MOJIBAKE_INDICATORS = (
|
|
217
|
+
"\u00c3\u00a1", # á
|
|
218
|
+
"\u00c3\u00a3", # ã
|
|
219
|
+
"\u00c3\u00a9", # é
|
|
220
|
+
"\u00c3\u00a8", # è
|
|
221
|
+
"\u00c3\u00b3", # ó
|
|
222
|
+
"\u00c3\u00b2", # ò
|
|
223
|
+
"\ufffd", # replacement char
|
|
224
|
+
"\u00e2\u20ac\u2014", # double encoded em-dash
|
|
225
|
+
"\u00e2\u20ac\u0153", # double encoded open quote
|
|
226
|
+
"\u00e2\u20ac\u009d", # double encoded close quote
|
|
227
|
+
)
|
|
228
|
+
|
|
229
|
+
|
|
230
|
+
def gate_1_bom_check(repo_root, mode="AUTO"):
|
|
231
|
+
"""Gate 1: Verifies 100% UTF-8 encoding with zero Byte Order Mark (BOM) bytes and zero corrupted control characters."""
|
|
232
|
+
print("\n[GATE 1] Scanning UTF-8 No BOM and Encoding Integrity across repository...")
|
|
233
|
+
ignored_dirs = {".git", ".gradle", "node_modules", "allure-results", "graphify-out", "__pycache__", ".pytest_cache", ".ruff_cache", ".mypy_cache", "build", "dist", "claude-ecosystem-repos", "external_repos", "teamwork"}
|
|
234
|
+
ignored_files = {"verify_all.py", "test_tools.py"}
|
|
235
|
+
bom_violations = []
|
|
236
|
+
mojibake_violations = []
|
|
237
|
+
for root, dirs, files in os.walk(repo_root):
|
|
238
|
+
dirs[:] = [d for d in dirs if d not in ignored_dirs]
|
|
239
|
+
for f in files:
|
|
240
|
+
if f.endswith(BOM_EXTENSIONS):
|
|
241
|
+
full_path = os.path.join(root, f)
|
|
242
|
+
rel_path = os.path.relpath(full_path, repo_root)
|
|
243
|
+
if f in ignored_files:
|
|
244
|
+
continue
|
|
245
|
+
try:
|
|
246
|
+
with open(full_path, "rb") as fp:
|
|
247
|
+
raw = fp.read()
|
|
248
|
+
if raw[:3] == b"\xef\xbb\xbf":
|
|
249
|
+
bom_violations.append(rel_path)
|
|
250
|
+
try:
|
|
251
|
+
text = raw.decode("utf-8")
|
|
252
|
+
if any(ind in text for ind in MOJIBAKE_INDICATORS):
|
|
253
|
+
mojibake_violations.append(rel_path)
|
|
254
|
+
# Check for unescaped corrupted control characters (< 0x20 except \n, \r, \t)
|
|
255
|
+
bad_ctrl = [c for c in text if ord(c) < 32 and c not in ('\n', '\r', '\t')]
|
|
256
|
+
if bad_ctrl:
|
|
257
|
+
mojibake_violations.append(f"{rel_path} (Contains {len(bad_ctrl)} corrupted control char(s) e.g. {repr(bad_ctrl[0])})")
|
|
258
|
+
except UnicodeDecodeError:
|
|
259
|
+
mojibake_violations.append(f"{rel_path} (Invalid UTF-8 decode)")
|
|
260
|
+
except (OSError, PermissionError):
|
|
261
|
+
continue
|
|
262
|
+
|
|
263
|
+
failed = False
|
|
264
|
+
if bom_violations:
|
|
265
|
+
print(f"[FAIL] {len(bom_violations)} files contain UTF-8 BOM bytes:")
|
|
266
|
+
for v in bom_violations:
|
|
267
|
+
print(f" - {v}")
|
|
268
|
+
failed = True
|
|
269
|
+
if mojibake_violations:
|
|
270
|
+
print(f"[FAIL] {len(mojibake_violations)} files contain Mojibake / Corrupted Encoding:")
|
|
271
|
+
for v in mojibake_violations:
|
|
272
|
+
print(f" - {v}")
|
|
273
|
+
failed = True
|
|
274
|
+
|
|
275
|
+
if failed:
|
|
276
|
+
return False
|
|
277
|
+
|
|
278
|
+
print("[PASS] 100% UTF-8 No BOM & Clean Encoding verified across all source files.")
|
|
279
|
+
return True
|
|
280
|
+
|
|
281
|
+
|
|
282
|
+
def gate_2_path_portability(repo_root, mode="AUTO"):
|
|
283
|
+
"""Gate 2: Scans for and rejects machine-specific absolute filepaths in code."""
|
|
284
|
+
print("\n[GATE 2] Checking Path Portability (Zero absolute machine paths in repo sources)...")
|
|
285
|
+
ignored_dirs = {
|
|
286
|
+
".git", ".gradle", "node_modules", "allure-results", "Screenshots",
|
|
287
|
+
"Reports", "reports", "TestReports", "testreports", "Libs", ".settings", "graphify-out",
|
|
288
|
+
"__pycache__", ".pytest_cache", ".ruff_cache", ".mypy_cache", "agent_qa.egg-info", "dist", "build", "claude-ecosystem-repos", "external_repos", "teamwork"
|
|
289
|
+
}
|
|
290
|
+
ignored_files = {
|
|
291
|
+
".project", ".classpath", ".DS_Store", "memory_cache.db",
|
|
292
|
+
"verify_all.py", "git_pre_commit_guard.py", "agent_canary.py", "repo_map.txt", "repo_map.json",
|
|
293
|
+
"PROJECT_HEALTH_REPORT.md", "PROJECT_STATE.md"
|
|
294
|
+
}
|
|
295
|
+
violations = []
|
|
296
|
+
for root, dirs, files in os.walk(repo_root):
|
|
297
|
+
dirs[:] = [d for d in dirs if d not in ignored_dirs]
|
|
298
|
+
for f in files:
|
|
299
|
+
if f.startswith(".temp-") or f in ignored_files or f.endswith(
|
|
300
|
+
(".pyc", ".db", ".png", ".jpg", ".zip", ".tar", ".gz", ".xlsx", ".class", ".prefs")
|
|
301
|
+
):
|
|
302
|
+
continue
|
|
303
|
+
full_path = os.path.join(root, f)
|
|
304
|
+
rel_path = os.path.relpath(full_path, repo_root)
|
|
305
|
+
|
|
306
|
+
# Skip historical documentation, gitignore, or temporary coverage files
|
|
307
|
+
if "FINAL_REPORT.md" in rel_path or ".gitignore" in rel_path or ".coverage" in rel_path:
|
|
308
|
+
continue
|
|
309
|
+
|
|
310
|
+
try:
|
|
311
|
+
with open(full_path, "r", encoding="utf-8", errors="ignore") as fp:
|
|
312
|
+
for line_no, line in enumerate(fp, 1):
|
|
313
|
+
for pattern, desc in FORBIDDEN_PATH_PATTERNS:
|
|
314
|
+
if pattern.search(line):
|
|
315
|
+
violations.append((rel_path, line_no, desc))
|
|
316
|
+
except (OSError, PermissionError):
|
|
317
|
+
continue
|
|
318
|
+
|
|
319
|
+
if violations:
|
|
320
|
+
print(f"[FAIL] {len(violations)} forbidden machine paths found:")
|
|
321
|
+
for rel_path, line_no, term in violations:
|
|
322
|
+
print(f" - {rel_path}:{line_no} contains '{term}'")
|
|
323
|
+
return False
|
|
324
|
+
print("[PASS] Zero machine-specific absolute paths detected in source files.")
|
|
325
|
+
return True
|
|
326
|
+
|
|
327
|
+
|
|
328
|
+
def is_page_class_path(file_path: str) -> bool:
|
|
329
|
+
"""Return True if the file path indicates a Page Class / Object Repository rather than a test script."""
|
|
330
|
+
if not file_path:
|
|
331
|
+
return False
|
|
332
|
+
fp = file_path.replace("\\", "/").lower()
|
|
333
|
+
# Directory checks for dedicated Page Class subfolders
|
|
334
|
+
if any(p in fp for p in ["/pages/", "pages/", "/page_objects/", "page_objects/", "/object repository/", "/object-repository/"]):
|
|
335
|
+
return True
|
|
336
|
+
base = os.path.basename(fp)
|
|
337
|
+
if base.endswith("page.js") or base.endswith("page.ts") or base.endswith("page.groovy") or base.endswith("page.py") or "basepage" in base:
|
|
338
|
+
return True
|
|
339
|
+
return False
|
|
340
|
+
|
|
341
|
+
|
|
342
|
+
def gate_3_clean_pom(repo_root, mode="AUTO"):
|
|
343
|
+
"""Gate 3: Enforces Clean Page Object Model by rejecting raw selectors in test scripts."""
|
|
344
|
+
print("\n[GATE 3] Checking Clean POM & Flat Architecture in Test Scripts...")
|
|
345
|
+
effective_mode = detect_repo_mode(repo_root) if mode == "AUTO" else mode
|
|
346
|
+
if effective_mode == "HUB":
|
|
347
|
+
examples_dir = os.path.join(repo_root, "examples")
|
|
348
|
+
if os.path.isdir(examples_dir):
|
|
349
|
+
print("[HUB MODE] Verifying Clean POM across reference example suites (examples/)...")
|
|
350
|
+
test_dirs = ["examples"]
|
|
351
|
+
else:
|
|
352
|
+
print("[N/A] Hub Mode: Not Applicable (Clean POM rules apply to target test suites in Spokes).")
|
|
353
|
+
return True
|
|
354
|
+
else:
|
|
355
|
+
test_dirs = ["Scripts", "tests", "test", "e2e", "specs", "cypress"]
|
|
356
|
+
test_files = []
|
|
357
|
+
for td in test_dirs:
|
|
358
|
+
d = os.path.join(repo_root, td)
|
|
359
|
+
if os.path.isdir(d):
|
|
360
|
+
for ext in ("*.groovy", "*.ts", "*.js", "*.py", "*.java"):
|
|
361
|
+
test_files.extend(glob.glob(os.path.join(d, "**", ext), recursive=True))
|
|
362
|
+
|
|
363
|
+
if not test_files:
|
|
364
|
+
print("[N/A] No test scripts present in candidate directories (Scripts/, tests/, e2e/).")
|
|
365
|
+
return True
|
|
366
|
+
|
|
367
|
+
LOCATOR_CALL_PATTERN = re.compile(
|
|
368
|
+
r'(?:\.(?:click|dblclick|fill|type|press|check|locator|waitForSelector|hover|selectOption)|cy\.(?:get|find)|driver\.find[A-Za-z]*|WebUI\.[a-zA-Z]+)\s*\(\s*[\x22\x27](?P<sel>[^\x22\x27]+)[\x22\x27]'
|
|
369
|
+
)
|
|
370
|
+
RAW_XPATH_PATTERN = re.compile(r'[\x22\x27](?:xpath=|\/{2}[a-zA-Z*@\[])[^\x22\x27]*[\x22\x27]')
|
|
371
|
+
|
|
372
|
+
violations = []
|
|
373
|
+
for full_path in sorted(set(test_files)):
|
|
374
|
+
rel_path = os.path.relpath(full_path, repo_root)
|
|
375
|
+
if is_page_class_path(rel_path):
|
|
376
|
+
continue
|
|
377
|
+
try:
|
|
378
|
+
with open(full_path, "r", encoding="utf-8", errors="ignore") as fp:
|
|
379
|
+
for line_no, line in enumerate(fp, 1):
|
|
380
|
+
stripped = line.strip()
|
|
381
|
+
if stripped.startswith("//") or stripped.startswith("/*") or stripped.startswith("#"):
|
|
382
|
+
continue
|
|
383
|
+
# Ignore standard navigation statements to prevent false-positive XPath violations on URLs
|
|
384
|
+
if re.search(r'\.(?:goto|get|open|navigate)\s*\(\s*[\x22\x27]https?:\/\/', stripped):
|
|
385
|
+
continue
|
|
386
|
+
if "findTestObject" in line:
|
|
387
|
+
violations.append((rel_path, line_no, "Raw findTestObject"))
|
|
388
|
+
continue
|
|
389
|
+
# Check locator calls taking raw CSS/XPath selectors
|
|
390
|
+
m = LOCATOR_CALL_PATTERN.search(stripped)
|
|
391
|
+
if m:
|
|
392
|
+
sel = m.group('sel').strip()
|
|
393
|
+
if any(sel.startswith(p) for p in ('.', '#', '//', 'xpath=', '[')) or ' > ' in sel:
|
|
394
|
+
violations.append((rel_path, line_no, f"Raw CSS/XPath Selector in Test Script: '{sel}'"))
|
|
395
|
+
continue
|
|
396
|
+
if RAW_XPATH_PATTERN.search(stripped):
|
|
397
|
+
violations.append((rel_path, line_no, "Raw XPath literal in Test Script"))
|
|
398
|
+
except (OSError, PermissionError):
|
|
399
|
+
continue
|
|
400
|
+
|
|
401
|
+
if violations:
|
|
402
|
+
print(f"[FAIL] {len(violations)} Clean POM violations in test scripts:")
|
|
403
|
+
for rel_path, line_no, reason in violations:
|
|
404
|
+
print(f" - {rel_path}:{line_no} ({reason})")
|
|
405
|
+
return False
|
|
406
|
+
print("[PASS] 100% Clean POM compliance (all locators encapsulated in Page Classes).")
|
|
407
|
+
return True
|
|
408
|
+
|
|
409
|
+
|
|
410
|
+
def gate_4_ai_docs_lint(repo_root, mode="AUTO"):
|
|
411
|
+
"""Gate 4: Reconciles PROJECT_AI_GUIDE.md against physical AST to prevent hallucinated classes."""
|
|
412
|
+
print("\n[GATE 4] Running AI Documentation & Artifact Linter...")
|
|
413
|
+
linter_script = os.path.join(SCRIPT_DIR, "lint_ai_docs.py")
|
|
414
|
+
if not os.path.exists(linter_script):
|
|
415
|
+
linter_script = os.path.join(repo_root, "tools", "lint_ai_docs.py")
|
|
416
|
+
if not os.path.exists(linter_script):
|
|
417
|
+
print("[FAIL] lint_ai_docs.py not found in tools/!")
|
|
418
|
+
return False
|
|
419
|
+
|
|
420
|
+
try:
|
|
421
|
+
res = subprocess.run([sys.executable, linter_script, repo_root], stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True, timeout=60.0)
|
|
422
|
+
except subprocess.TimeoutExpired:
|
|
423
|
+
print("[FAIL] lint_ai_docs.py timed out after 60s!")
|
|
424
|
+
return False
|
|
425
|
+
if res.returncode != 0:
|
|
426
|
+
safe_print(res.stdout)
|
|
427
|
+
safe_print(res.stderr)
|
|
428
|
+
return False
|
|
429
|
+
print("[PASS] Zero documentation drift / zero hallucinated PageClasses & Suites.")
|
|
430
|
+
return True
|
|
431
|
+
|
|
432
|
+
|
|
433
|
+
def gate_5_cleanup_blacklist(repo_root, mode="AUTO"):
|
|
434
|
+
"""Gate 5: Scans for prohibited temporary files, heap dumps, and local cache artifacts."""
|
|
435
|
+
print("\n[GATE 5] Checking Temporary File Blacklist...")
|
|
436
|
+
blacklist_patterns = [
|
|
437
|
+
os.path.join(repo_root, "Reports", "batch*.properties"),
|
|
438
|
+
os.path.join(repo_root, "*_debug.txt"),
|
|
439
|
+
os.path.join(repo_root, "debug_output.txt"),
|
|
440
|
+
os.path.join(repo_root, "*.tmp"),
|
|
441
|
+
os.path.join(repo_root, ".temp-*"),
|
|
442
|
+
os.path.join(repo_root, "*_tmp.db"),
|
|
443
|
+
os.path.join(repo_root, "temp_*.db"),
|
|
444
|
+
os.path.join(repo_root, "nonexistent_*.db"),
|
|
445
|
+
os.path.join(repo_root, "*.heapsnapshot"),
|
|
446
|
+
os.path.join(repo_root, "*.hprof"),
|
|
447
|
+
]
|
|
448
|
+
# Allowed test artifact directories exempted from heap dump cleanups
|
|
449
|
+
exempt_prefixes = (
|
|
450
|
+
os.path.normpath(os.path.join(repo_root, "Reports", "perf")),
|
|
451
|
+
os.path.normpath(os.path.join(repo_root, ".synapse", "heapsnapshots")),
|
|
452
|
+
)
|
|
453
|
+
found = []
|
|
454
|
+
for pattern in blacklist_patterns:
|
|
455
|
+
for f in glob.glob(pattern):
|
|
456
|
+
norm_f = os.path.normpath(f)
|
|
457
|
+
if any(norm_f.startswith(prefix) for prefix in exempt_prefixes):
|
|
458
|
+
continue
|
|
459
|
+
if os.path.isfile(f):
|
|
460
|
+
found.append(os.path.relpath(f, repo_root))
|
|
461
|
+
|
|
462
|
+
if found:
|
|
463
|
+
print(f"[FAIL] {len(found)} blacklisted temporary files found on disk:")
|
|
464
|
+
for f in found:
|
|
465
|
+
print(f" - {f}")
|
|
466
|
+
return False
|
|
467
|
+
print("[PASS] Temporary file blacklist is clean.")
|
|
468
|
+
return True
|
|
469
|
+
|
|
470
|
+
|
|
471
|
+
def gate_6_credential_security(repo_root, mode="AUTO"):
|
|
472
|
+
"""Gate 6: Scans for plaintext passwords, API tokens, and private keys across codebase."""
|
|
473
|
+
print("\n[GATE 6] Checking Credential Security across repository...")
|
|
474
|
+
violations = []
|
|
475
|
+
|
|
476
|
+
# 1. Target project check: Profiles/default.glbl
|
|
477
|
+
glbl_file = os.path.join(repo_root, "Profiles", "default.glbl")
|
|
478
|
+
if os.path.exists(glbl_file):
|
|
479
|
+
try:
|
|
480
|
+
with open(glbl_file, "r", encoding="utf-8") as fp:
|
|
481
|
+
content = fp.read()
|
|
482
|
+
# Extract PASSWORD entity block
|
|
483
|
+
m = re.search(r'<name>PASSWORD</name>.*?<protected>(.*?)</protected>', content, re.DOTALL)
|
|
484
|
+
if not m:
|
|
485
|
+
m = re.search(r'<protected>(.*?)</protected>.*?<name>PASSWORD</name>', content, re.DOTALL)
|
|
486
|
+
if m:
|
|
487
|
+
protected_val = m.group(1).strip().lower()
|
|
488
|
+
if protected_val != "true":
|
|
489
|
+
violations.append((glbl_file, 1, f"PASSWORD in Profiles/default.glbl has protected={protected_val} (must be 'true')"))
|
|
490
|
+
else:
|
|
491
|
+
print("[WARN] PASSWORD entity not found in Profiles/default.glbl")
|
|
492
|
+
|
|
493
|
+
# Check for plaintext password leaks in glbl
|
|
494
|
+
if re.search(r'(?i)\b(?:Pass(?:word)?@?\d+|Admin@?\d+|Root@?\d+|Default@?\d+)\b', content): # gate6-allowlist
|
|
495
|
+
violations.append((glbl_file, 1, "Plaintext default password found in default.glbl"))
|
|
496
|
+
except Exception as e:
|
|
497
|
+
print(f"[WARN] Error reading default.glbl: {e}")
|
|
498
|
+
|
|
499
|
+
# 2. Universal Repository Scan for Hardcoded Plaintext Secrets
|
|
500
|
+
# High-confidence token patterns that must NEVER be bypassed by generic indicators
|
|
501
|
+
token_patterns = [
|
|
502
|
+
(re.compile(r'\bghp_[0-9a-zA-Z]{36}\b'), "GitHub Personal Access Token"),
|
|
503
|
+
(re.compile(r'\bgithub_pat_[0-9a-zA-Z_]{82}\b'), "GitHub Fine-Grained Personal Access Token"),
|
|
504
|
+
(re.compile(r'\bAKIA[0-9A-Z]{16}\b'), "AWS Access Key ID"),
|
|
505
|
+
(re.compile(r'\bsk_(?:live|test)_[0-9a-zA-Z]{24,}\b'), "Stripe Secret Key"),
|
|
506
|
+
(re.compile(r'\bxox[baprs]-[0-9a-zA-Z-]{10,}\b'), "Slack API Token"),
|
|
507
|
+
(re.compile(r'\bAIza[0-9A-Za-z-_]{35}\b'), "Google API Key"),
|
|
508
|
+
(re.compile(r'-----BEGIN (?:RSA )?PRIVATE KEY-----'), "Private Key Header"),
|
|
509
|
+
]
|
|
510
|
+
|
|
511
|
+
password_patterns = [
|
|
512
|
+
(re.compile(r'(?i)\b(?:Pass(?:word)?@?\d+|Admin@?\d+|Root@?\d+|Default@?\d+)\b'), "Known Default Password"),
|
|
513
|
+
(re.compile(r'(?i)\b(?:password|passwd|pwd)\s*[:=]\s*[\x22\x27][^\x22\x27]{4,}[\x22\x27]'), "Hardcoded Plaintext Password Assignment"),
|
|
514
|
+
]
|
|
515
|
+
|
|
516
|
+
password_allowlist_indicators = [
|
|
517
|
+
"System.getenv", "os.getenv", "os.environ", "process.env",
|
|
518
|
+
"dummy", "placeholder", "***", "<password>", "your_password",
|
|
519
|
+
"test_password", "NEO4J_PASSWORD", "DynamicTestPwd",
|
|
520
|
+
"secret_patterns", "<name>PASSWORD</name>", 'password = ""', "password = ''",
|
|
521
|
+
"type=str", "help="
|
|
522
|
+
]
|
|
523
|
+
|
|
524
|
+
ignored_dirs = {
|
|
525
|
+
".git", ".gradle", "node_modules", "allure-results", "Screenshots",
|
|
526
|
+
"Reports", "reports", "TestReports", "testreports", "Libs", ".settings", "graphify-out",
|
|
527
|
+
"__pycache__", ".pytest_cache", ".ruff_cache", ".mypy_cache", "agent_qa.egg-info", "dist", "build", "claude-ecosystem-repos", "external_repos", "teamwork"
|
|
528
|
+
}
|
|
529
|
+
|
|
530
|
+
for root, dirs, files in os.walk(repo_root):
|
|
531
|
+
dirs[:] = [d for d in dirs if d not in ignored_dirs]
|
|
532
|
+
for f in files:
|
|
533
|
+
if not f.endswith((".py", ".groovy", ".ts", ".js", ".json", ".txt", ".md", ".yml", ".yaml", ".properties", ".sh", ".ps1", ".glbl")):
|
|
534
|
+
continue
|
|
535
|
+
full_path = os.path.join(root, f)
|
|
536
|
+
rel_path = os.path.relpath(full_path, repo_root)
|
|
537
|
+
|
|
538
|
+
# Skip self scanning of pattern definitions in verify_all.py or scanner tests
|
|
539
|
+
if rel_path in ("tools\\verify_all.py", "tools/verify_all.py", "tests\\test_tools.py", "tests/test_tools.py"):
|
|
540
|
+
continue
|
|
541
|
+
|
|
542
|
+
try:
|
|
543
|
+
with open(full_path, "r", encoding="utf-8", errors="ignore") as fp:
|
|
544
|
+
for line_no, line in enumerate(fp, 1):
|
|
545
|
+
# Strict explicit allowlist comment
|
|
546
|
+
if "# gate6-allowlist" in line:
|
|
547
|
+
continue
|
|
548
|
+
|
|
549
|
+
# Check high-confidence token patterns (NEVER skipped by dummy, mock_, or # nosec)
|
|
550
|
+
for pat, desc in token_patterns:
|
|
551
|
+
if pat.search(line):
|
|
552
|
+
violations.append((rel_path, line_no, desc))
|
|
553
|
+
|
|
554
|
+
# Check password patterns (subject to password_allowlist_indicators)
|
|
555
|
+
if not any(ind in line for ind in password_allowlist_indicators):
|
|
556
|
+
for pat, desc in password_patterns:
|
|
557
|
+
if pat.search(line):
|
|
558
|
+
violations.append((rel_path, line_no, desc))
|
|
559
|
+
except (OSError, PermissionError):
|
|
560
|
+
continue
|
|
561
|
+
except (OSError, PermissionError):
|
|
562
|
+
continue
|
|
563
|
+
|
|
564
|
+
if violations:
|
|
565
|
+
print(f"[FAIL] {len(violations)} hardcoded secrets/credentials detected on disk:")
|
|
566
|
+
for rel_path, line_no, desc in violations:
|
|
567
|
+
print(f" - {rel_path}:{line_no} contains '{desc}'")
|
|
568
|
+
return False
|
|
569
|
+
|
|
570
|
+
print("[PASS] 100% Verified: Zero hardcoded plaintext credentials or secret tokens across repository.")
|
|
571
|
+
return True
|
|
572
|
+
|
|
573
|
+
|
|
574
|
+
def check_python_ast_integrity(repo_root):
|
|
575
|
+
"""
|
|
576
|
+
Performs static AST validation across all Python files in the repository.
|
|
577
|
+
Enforces F821 parity (zero undefined variable names) and zero syntax errors.
|
|
578
|
+
"""
|
|
579
|
+
builtin_names = set(dir(builtins)) | {'__file__', '__name__', '__doc__', '__package__'}
|
|
580
|
+
py_files = []
|
|
581
|
+
ignored = {'.git', 'node_modules', '__pycache__', '.venv', 'venv', 'claude-ecosystem-repos', 'build', 'dist', '.gradle', 'external_repos', 'teamwork'}
|
|
582
|
+
|
|
583
|
+
for root, dirs, files in os.walk(repo_root):
|
|
584
|
+
dirs[:] = [d for d in dirs if d not in ignored]
|
|
585
|
+
for f in files:
|
|
586
|
+
if f.endswith('.py'):
|
|
587
|
+
py_files.append(os.path.join(root, f))
|
|
588
|
+
|
|
589
|
+
violations = []
|
|
590
|
+
|
|
591
|
+
for file_path in sorted(py_files):
|
|
592
|
+
rel_path = os.path.relpath(file_path, repo_root)
|
|
593
|
+
try:
|
|
594
|
+
with open(file_path, 'r', encoding='utf-8', errors='ignore') as fp:
|
|
595
|
+
content = fp.read()
|
|
596
|
+
tree = ast.parse(content, file_path)
|
|
597
|
+
except SyntaxError as e:
|
|
598
|
+
violations.append((rel_path, e.lineno or 1, f"SyntaxError: {e.msg}"))
|
|
599
|
+
continue
|
|
600
|
+
|
|
601
|
+
module_names = set(builtin_names)
|
|
602
|
+
for stmt in tree.body:
|
|
603
|
+
if isinstance(stmt, (ast.FunctionDef, ast.AsyncFunctionDef, ast.ClassDef)):
|
|
604
|
+
module_names.add(stmt.name)
|
|
605
|
+
elif isinstance(stmt, ast.Import):
|
|
606
|
+
for a in stmt.names:
|
|
607
|
+
module_names.add(a.asname or a.name.split('.')[0])
|
|
608
|
+
elif isinstance(stmt, ast.ImportFrom):
|
|
609
|
+
for a in stmt.names:
|
|
610
|
+
module_names.add(a.asname or a.name)
|
|
611
|
+
elif isinstance(stmt, (ast.Assign, ast.AnnAssign)):
|
|
612
|
+
targets = [stmt.target] if isinstance(stmt, ast.AnnAssign) else stmt.targets
|
|
613
|
+
for t in targets:
|
|
614
|
+
for n in ast.walk(t):
|
|
615
|
+
if isinstance(n, ast.Name):
|
|
616
|
+
module_names.add(n.id)
|
|
617
|
+
for n in ast.walk(stmt):
|
|
618
|
+
if hasattr(ast, 'NamedExpr') and isinstance(n, ast.NamedExpr) and isinstance(getattr(n, 'target', None), ast.Name):
|
|
619
|
+
module_names.add(n.target.id)
|
|
620
|
+
|
|
621
|
+
class ScopeVisitor(ast.NodeVisitor):
|
|
622
|
+
def __init__(self):
|
|
623
|
+
self.scopes = [set(module_names)]
|
|
624
|
+
self.file_violations = []
|
|
625
|
+
|
|
626
|
+
def visit_FunctionDef(self, node):
|
|
627
|
+
self.scopes[-1].add(node.name)
|
|
628
|
+
fn_scope = set(self.scopes[-1])
|
|
629
|
+
for arg in node.args.posonlyargs + node.args.args + node.args.kwonlyargs:
|
|
630
|
+
fn_scope.add(arg.arg)
|
|
631
|
+
if node.args.vararg:
|
|
632
|
+
fn_scope.add(node.args.vararg.arg)
|
|
633
|
+
if node.args.kwarg:
|
|
634
|
+
fn_scope.add(node.args.kwarg.arg)
|
|
635
|
+
self.scopes.append(fn_scope)
|
|
636
|
+
self.generic_visit(node)
|
|
637
|
+
self.scopes.pop()
|
|
638
|
+
|
|
639
|
+
visit_AsyncFunctionDef = visit_FunctionDef
|
|
640
|
+
|
|
641
|
+
def visit_ClassDef(self, node):
|
|
642
|
+
self.scopes[-1].add(node.name)
|
|
643
|
+
cls_scope = set(self.scopes[-1])
|
|
644
|
+
self.scopes.append(cls_scope)
|
|
645
|
+
self.generic_visit(node)
|
|
646
|
+
self.scopes.pop()
|
|
647
|
+
|
|
648
|
+
def visit_Assign(self, node):
|
|
649
|
+
for t in node.targets:
|
|
650
|
+
for n in ast.walk(t):
|
|
651
|
+
if isinstance(n, ast.Name):
|
|
652
|
+
self.scopes[-1].add(n.id)
|
|
653
|
+
self.generic_visit(node)
|
|
654
|
+
|
|
655
|
+
def visit_AnnAssign(self, node):
|
|
656
|
+
if isinstance(node.target, ast.Name):
|
|
657
|
+
self.scopes[-1].add(node.target.id)
|
|
658
|
+
self.generic_visit(node)
|
|
659
|
+
|
|
660
|
+
def visit_For(self, node):
|
|
661
|
+
for n in ast.walk(node.target):
|
|
662
|
+
if isinstance(n, ast.Name):
|
|
663
|
+
self.scopes[-1].add(n.id)
|
|
664
|
+
self.generic_visit(node)
|
|
665
|
+
|
|
666
|
+
def visit_With(self, node):
|
|
667
|
+
for item in node.items:
|
|
668
|
+
if item.optional_vars:
|
|
669
|
+
for n in ast.walk(item.optional_vars):
|
|
670
|
+
if isinstance(n, ast.Name):
|
|
671
|
+
self.scopes[-1].add(n.id)
|
|
672
|
+
self.generic_visit(node)
|
|
673
|
+
|
|
674
|
+
def visit_ExceptHandler(self, node):
|
|
675
|
+
if node.name:
|
|
676
|
+
self.scopes[-1].add(node.name)
|
|
677
|
+
self.generic_visit(node)
|
|
678
|
+
|
|
679
|
+
def visit_NamedExpr(self, node):
|
|
680
|
+
if isinstance(node.target, ast.Name):
|
|
681
|
+
for s in self.scopes:
|
|
682
|
+
s.add(node.target.id)
|
|
683
|
+
self.generic_visit(node)
|
|
684
|
+
|
|
685
|
+
def visit_Match(self, node):
|
|
686
|
+
for case in getattr(node, 'cases', []):
|
|
687
|
+
pattern = getattr(case, 'pattern', None)
|
|
688
|
+
if pattern:
|
|
689
|
+
for n in ast.walk(pattern):
|
|
690
|
+
name = getattr(n, 'name', None)
|
|
691
|
+
if isinstance(name, str):
|
|
692
|
+
self.scopes[-1].add(name)
|
|
693
|
+
rest = getattr(n, 'rest', None)
|
|
694
|
+
if isinstance(rest, str):
|
|
695
|
+
self.scopes[-1].add(rest)
|
|
696
|
+
self.generic_visit(node)
|
|
697
|
+
|
|
698
|
+
def visit_Global(self, node):
|
|
699
|
+
for name in node.names:
|
|
700
|
+
for s in self.scopes:
|
|
701
|
+
s.add(name)
|
|
702
|
+
self.generic_visit(node)
|
|
703
|
+
|
|
704
|
+
def visit_Nonlocal(self, node):
|
|
705
|
+
for name in node.names:
|
|
706
|
+
self.scopes[-1].add(name)
|
|
707
|
+
self.generic_visit(node)
|
|
708
|
+
|
|
709
|
+
def visit_Import(self, node):
|
|
710
|
+
for a in node.names:
|
|
711
|
+
self.scopes[-1].add(a.asname or a.name.split('.')[0])
|
|
712
|
+
|
|
713
|
+
def visit_ImportFrom(self, node):
|
|
714
|
+
for a in node.names:
|
|
715
|
+
self.scopes[-1].add(a.asname or a.name)
|
|
716
|
+
|
|
717
|
+
def visit_ListComp(self, node):
|
|
718
|
+
comp_scope = set(self.scopes[-1])
|
|
719
|
+
for gen in node.generators:
|
|
720
|
+
for n in ast.walk(gen.target):
|
|
721
|
+
if isinstance(n, ast.Name):
|
|
722
|
+
comp_scope.add(n.id)
|
|
723
|
+
self.scopes.append(comp_scope)
|
|
724
|
+
self.generic_visit(node)
|
|
725
|
+
self.scopes.pop()
|
|
726
|
+
|
|
727
|
+
visit_SetComp = visit_ListComp
|
|
728
|
+
visit_GeneratorExp = visit_ListComp
|
|
729
|
+
visit_DictComp = visit_ListComp
|
|
730
|
+
|
|
731
|
+
def visit_Lambda(self, node):
|
|
732
|
+
lam_scope = set(self.scopes[-1])
|
|
733
|
+
for arg in node.args.posonlyargs + node.args.args + node.args.kwonlyargs:
|
|
734
|
+
lam_scope.add(arg.arg)
|
|
735
|
+
if node.args.vararg:
|
|
736
|
+
lam_scope.add(node.args.vararg.arg)
|
|
737
|
+
if node.args.kwarg:
|
|
738
|
+
lam_scope.add(node.args.kwarg.arg)
|
|
739
|
+
self.scopes.append(lam_scope)
|
|
740
|
+
self.generic_visit(node)
|
|
741
|
+
self.scopes.pop()
|
|
742
|
+
|
|
743
|
+
def visit_Name(self, node):
|
|
744
|
+
if isinstance(node.ctx, ast.Load):
|
|
745
|
+
if node.id.startswith('__') and node.id.endswith('__'):
|
|
746
|
+
return
|
|
747
|
+
if not any(node.id in s for s in reversed(self.scopes)):
|
|
748
|
+
self.file_violations.append((rel_path, node.lineno, f"Undefined name '{node.id}' (F821)"))
|
|
749
|
+
|
|
750
|
+
visitor = ScopeVisitor()
|
|
751
|
+
visitor.visit(tree)
|
|
752
|
+
violations.extend(visitor.file_violations)
|
|
753
|
+
|
|
754
|
+
return violations
|
|
755
|
+
|
|
756
|
+
|
|
757
|
+
def gate_7_infer_linter(repo_root, mode="AUTO"):
|
|
758
|
+
"""Gate 7: Runs Meta Infer-style static defect sentinel catching fake passes, 0 assert, and sleeps."""
|
|
759
|
+
print("\n[GATE 7] Running Meta Infer-Style Static Defect & Fake-Pass Sentinel...")
|
|
760
|
+
effective_mode = detect_repo_mode(repo_root) if mode == "AUTO" else mode
|
|
761
|
+
|
|
762
|
+
# Static Python AST & Undefined Name (F821) Sentinel
|
|
763
|
+
ast_violations = check_python_ast_integrity(repo_root)
|
|
764
|
+
if ast_violations:
|
|
765
|
+
print(f"[FAIL] Static Python AST Sentinel detected {len(ast_violations)} syntax errors or undefined names:")
|
|
766
|
+
for rel_file, line_no, desc in ast_violations:
|
|
767
|
+
print(f" - {rel_file}:{line_no} -> {desc}")
|
|
768
|
+
return False
|
|
769
|
+
print("[PASS] 100% Python AST integrity verified (zero syntax errors, zero undefined variables).")
|
|
770
|
+
|
|
771
|
+
# In HUB mode: dogfood tools/ with baseline to prevent new unbaselined defects
|
|
772
|
+
if effective_mode == "HUB":
|
|
773
|
+
baseline_file = os.path.join(repo_root, "tools", ".infer_baseline.json")
|
|
774
|
+
infer_script = os.path.join(repo_root, "tools", "infer_linter.py")
|
|
775
|
+
if os.path.exists(baseline_file) and os.path.exists(infer_script):
|
|
776
|
+
tools_dir = os.path.join(repo_root, "tools")
|
|
777
|
+
try:
|
|
778
|
+
res = subprocess.run([
|
|
779
|
+
sys.executable, infer_script, "--strict", "--baseline", baseline_file, "--dir", tools_dir
|
|
780
|
+
], stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True, timeout=60.0)
|
|
781
|
+
if res.returncode != 0:
|
|
782
|
+
print("[FAIL] Hub internal tools contain unbaselined critical defects:")
|
|
783
|
+
safe_print(res.stdout)
|
|
784
|
+
return False
|
|
785
|
+
except subprocess.TimeoutExpired:
|
|
786
|
+
print("[FAIL] infer_linter.py timed out after 60s!")
|
|
787
|
+
return False
|
|
788
|
+
except (OSError, subprocess.SubprocessError) as err:
|
|
789
|
+
print(f"[WARN] Failed to execute infer_linter: {err}")
|
|
790
|
+
|
|
791
|
+
# Hub Mode Version Synchronization Verification
|
|
792
|
+
try:
|
|
793
|
+
import check_version_sync
|
|
794
|
+
synced, versions, canonical = check_version_sync.check_sync(repo_root)
|
|
795
|
+
if not synced:
|
|
796
|
+
print(f"[FAIL] Gate 7 Version Synchronization: Inconsistent versions detected across manifests: {versions}")
|
|
797
|
+
return False
|
|
798
|
+
except (ImportError, OSError) as err:
|
|
799
|
+
print(f"[WARN] Failed to run check_version_sync: {err}")
|
|
800
|
+
|
|
801
|
+
# Hub Mode Regression Test Suite Verification
|
|
802
|
+
if "PYTEST_CURRENT_TEST" not in os.environ and os.environ.get("SYNAPSE_GATE7_TESTING") != "1":
|
|
803
|
+
safe_print("[GATE 7] Executing Hub Regression Test Suite (pytest tests -q)...")
|
|
804
|
+
tests_dir = os.path.join(repo_root, "tests")
|
|
805
|
+
if os.path.isdir(tests_dir):
|
|
806
|
+
env = os.environ.copy()
|
|
807
|
+
env["SYNAPSE_GATE7_TESTING"] = "1"
|
|
808
|
+
env["SYNAPSE_LANG"] = "en"
|
|
809
|
+
pytest_cmd = [sys.executable, "-m", "pytest", "tests", "-q"]
|
|
810
|
+
import importlib.util
|
|
811
|
+
if importlib.util.find_spec("xdist") is not None:
|
|
812
|
+
pytest_cmd.extend(["-n", "auto"])
|
|
813
|
+
try:
|
|
814
|
+
test_res = subprocess.run(
|
|
815
|
+
pytest_cmd,
|
|
816
|
+
cwd=repo_root,
|
|
817
|
+
stdout=subprocess.PIPE,
|
|
818
|
+
stderr=subprocess.PIPE,
|
|
819
|
+
text=True,
|
|
820
|
+
timeout=240.0,
|
|
821
|
+
env=env
|
|
822
|
+
)
|
|
823
|
+
if test_res.returncode != 0:
|
|
824
|
+
safe_print("[FAIL] Gate 7 Hub Regression Test Suite Failed:")
|
|
825
|
+
safe_print(test_res.stdout or test_res.stderr)
|
|
826
|
+
return False
|
|
827
|
+
safe_print("[PASS] 100% Hub regression test suite passed.")
|
|
828
|
+
except subprocess.TimeoutExpired:
|
|
829
|
+
safe_print("[FAIL] Gate 7 Hub Regression Test Suite timed out after 240s!")
|
|
830
|
+
return False
|
|
831
|
+
except (OSError, subprocess.SubprocessError) as err:
|
|
832
|
+
safe_print(f"[FAIL] Gate 7 Failed to run test suite: {err}")
|
|
833
|
+
return False
|
|
834
|
+
else:
|
|
835
|
+
safe_print(f"[FAIL] Gate 7 Hub Mode: Missing mandatory 'tests/' directory at {tests_dir}!")
|
|
836
|
+
return False
|
|
837
|
+
else:
|
|
838
|
+
safe_print("[PASS] Hub Mode Regression Test Suite: Verified via active parent test runner.")
|
|
839
|
+
|
|
840
|
+
test_dirs = ["tests"] if effective_mode == "HUB" else ["Scripts", "tests", "test", "e2e", "specs", "cypress"]
|
|
841
|
+
has_tests = False
|
|
842
|
+
target_scan_dir = None
|
|
843
|
+
for td in test_dirs:
|
|
844
|
+
d = os.path.join(repo_root, td)
|
|
845
|
+
if os.path.isdir(d):
|
|
846
|
+
for ext in ("*.groovy", "*.ts", "*.js", "*.py", "*.java"):
|
|
847
|
+
if glob.glob(os.path.join(d, "**", ext), recursive=True):
|
|
848
|
+
has_tests = True
|
|
849
|
+
target_scan_dir = d
|
|
850
|
+
break
|
|
851
|
+
if has_tests:
|
|
852
|
+
break
|
|
853
|
+
|
|
854
|
+
if not has_tests:
|
|
855
|
+
print("[N/A] No test scripts (Groovy/TS/JS/Py) present in candidate test directories.")
|
|
856
|
+
return True
|
|
857
|
+
|
|
858
|
+
infer_script = os.path.join(SCRIPT_DIR, "infer_linter.py")
|
|
859
|
+
if not os.path.exists(infer_script):
|
|
860
|
+
infer_script = os.path.join(repo_root, "tools", "infer_linter.py")
|
|
861
|
+
|
|
862
|
+
if os.path.exists(infer_script):
|
|
863
|
+
try:
|
|
864
|
+
target_baseline = os.path.join(repo_root, ".infer_baseline.json")
|
|
865
|
+
cmd = [sys.executable, infer_script, "--strict", "--dir", target_scan_dir]
|
|
866
|
+
if os.path.exists(target_baseline):
|
|
867
|
+
cmd.extend(["--baseline", target_baseline])
|
|
868
|
+
res = subprocess.run(cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True, encoding="utf-8", errors="replace", timeout=60.0)
|
|
869
|
+
if res.returncode != 0:
|
|
870
|
+
print("[FAIL] Static Defect Sentinel detected critical issues in test scripts:")
|
|
871
|
+
safe_print(res.stdout)
|
|
872
|
+
return False
|
|
873
|
+
except subprocess.TimeoutExpired:
|
|
874
|
+
print("[FAIL] infer_linter.py timed out after 60s!")
|
|
875
|
+
return False
|
|
876
|
+
print("[PASS] Zero critical defects / zero swallowed exceptions across active test suites.")
|
|
877
|
+
return True
|
|
878
|
+
|
|
879
|
+
|
|
880
|
+
def gate_8_micro_mutator(repo_root, mode="AUTO", test_cmd=""):
|
|
881
|
+
"""Gate 8: Runs syntactic mutation testing and verifies assertion sensitivity score >= 80%."""
|
|
882
|
+
eval_mode_desc = f"DYNAMIC EXECUTION MODE ({test_cmd})" if test_cmd else "HEURISTIC STATIC MODE"
|
|
883
|
+
print(f"\n[GATE 8] Running Assertion Sensitivity & Syntactic Mutation Sentinel [{eval_mode_desc}] (Min Score >= 80%)...")
|
|
884
|
+
scripts_dir = os.path.join(repo_root, "Scripts")
|
|
885
|
+
tests_dir = os.path.join(repo_root, "tests")
|
|
886
|
+
|
|
887
|
+
target_dir = None
|
|
888
|
+
if os.path.isdir(scripts_dir):
|
|
889
|
+
groovy_files = [f for f in glob.glob(os.path.join(scripts_dir, "**", "*.groovy"), recursive=True)]
|
|
890
|
+
if groovy_files:
|
|
891
|
+
target_dir = scripts_dir
|
|
892
|
+
if not target_dir and os.path.isdir(tests_dir):
|
|
893
|
+
test_files = [f for f in glob.glob(os.path.join(tests_dir, "**", "*.*"), recursive=True) if f.endswith((".py", ".ts", ".js", ".groovy"))]
|
|
894
|
+
if test_files:
|
|
895
|
+
target_dir = tests_dir
|
|
896
|
+
|
|
897
|
+
if not target_dir:
|
|
898
|
+
if mode == "HUB":
|
|
899
|
+
print(f"[N/A] Hub Mode: Not Applicable (Assertion Sensitivity & Syntactic Mutation applies to target test suites in Spokes) [{eval_mode_desc}].")
|
|
900
|
+
return True
|
|
901
|
+
else:
|
|
902
|
+
print("[N/A] No automated test scripts found in Scripts/ or tests/ to mutate.")
|
|
903
|
+
return True
|
|
904
|
+
|
|
905
|
+
mutator_script = os.path.join(SCRIPT_DIR, "micro_mutator.py")
|
|
906
|
+
if not os.path.exists(mutator_script):
|
|
907
|
+
mutator_script = os.path.join(repo_root, "tools", "micro_mutator.py")
|
|
908
|
+
|
|
909
|
+
if not os.path.exists(mutator_script):
|
|
910
|
+
print("[FAIL] micro_mutator.py not found in tools/! Gate 8 requires micro_mutator.py (fail-closed).")
|
|
911
|
+
return False
|
|
912
|
+
|
|
913
|
+
cfg = load_synapse_config(repo_root)
|
|
914
|
+
qg_cfg = cfg.get("quality_gates", {})
|
|
915
|
+
min_score_val = float(qg_cfg.get("mutation_min_score", 80.0))
|
|
916
|
+
min_score_str = str(min_score_val)
|
|
917
|
+
allow_empty_val = bool(qg_cfg.get("allow_empty_mutations", False))
|
|
918
|
+
|
|
919
|
+
if not test_cmd:
|
|
920
|
+
test_cmd = qg_cfg.get("test_cmd") or cfg.get("test_cmd", "")
|
|
921
|
+
|
|
922
|
+
baseline_dir = os.path.join(repo_root, "reports")
|
|
923
|
+
os.makedirs(baseline_dir, exist_ok=True)
|
|
924
|
+
baseline_file = os.path.join(baseline_dir, "mutant_baseline.json")
|
|
925
|
+
|
|
926
|
+
cmd = [sys.executable, mutator_script, target_dir, "--min-score", min_score_str, "--baseline", baseline_file, "--json"]
|
|
927
|
+
if test_cmd:
|
|
928
|
+
cmd.extend(["--test-cmd", test_cmd])
|
|
929
|
+
if allow_empty_val:
|
|
930
|
+
cmd.append("--allow-empty")
|
|
931
|
+
try:
|
|
932
|
+
res = subprocess.run(cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True, timeout=120.0)
|
|
933
|
+
except subprocess.TimeoutExpired:
|
|
934
|
+
print("[FAIL] Assertion Sensitivity Sentinel timed out after 120s!")
|
|
935
|
+
return False
|
|
936
|
+
if res.returncode != 0:
|
|
937
|
+
try:
|
|
938
|
+
data = json.loads(res.stdout)
|
|
939
|
+
if data.get("total_mutants", 0) == 0 or data.get("no_mutants_generated"):
|
|
940
|
+
if allow_empty_val:
|
|
941
|
+
print(f"[N/A] Zero mutable expressions detected in {target_dir} (Allowed by configuration). Gate 8 skipped.")
|
|
942
|
+
return True
|
|
943
|
+
else:
|
|
944
|
+
print(f"[FAIL] Gate 8 REJECTED: Zero mutable expressions detected in {target_dir}! Test suite must contain mutable logic or assertions. (Fail-closed)")
|
|
945
|
+
return False
|
|
946
|
+
print("[FAIL] Assertion Sensitivity Sentinel REJECTED: Score < 80% or unasserted logic found.")
|
|
947
|
+
print(f" Assertion Sensitivity: {data.get('mutation_score', 0)}% (Required: >= 80%)")
|
|
948
|
+
print(f" Mutants Caught: {data.get('killed', 0)} / {data.get('total_mutants', 0)}")
|
|
949
|
+
except (json.JSONDecodeError, ValueError, KeyError):
|
|
950
|
+
if res.stdout:
|
|
951
|
+
safe_print(res.stdout)
|
|
952
|
+
return False
|
|
953
|
+
else:
|
|
954
|
+
try:
|
|
955
|
+
data = json.loads(res.stdout)
|
|
956
|
+
mode_label = f"DYNAMIC ({test_cmd})" if test_cmd else "STATIC AST HEURISTIC"
|
|
957
|
+
print(f"[PASS] Assertion Sensitivity [{mode_label}]: {data.get('mutation_score', 100)}% >= 80% (Caught {data.get('killed', 0)}/{data.get('total_mutants', 0)} syntactic mutants). Zero unasserted logic branches.")
|
|
958
|
+
if not test_cmd:
|
|
959
|
+
print(" ℹ️ Note: Evaluated via static AST dataflow analysis. Pass --test-cmd '<command>' to execute live mutant runs.")
|
|
960
|
+
if os.path.exists(baseline_file):
|
|
961
|
+
print(f" Mutant Baseline: Recorded {data.get('killed', 0)}/{data.get('total_mutants', 0)} mutants ({data.get('mutation_score', 100)}%) into reports/mutant_baseline.json")
|
|
962
|
+
except (json.JSONDecodeError, ValueError, KeyError):
|
|
963
|
+
print(f"[PASS] Assertion Sensitivity Sentinel passed: Score >= 80% [{eval_mode_desc}].")
|
|
964
|
+
return True
|
|
965
|
+
|
|
966
|
+
|
|
967
|
+
def gate_9_skill_collision(repo_root, mode="AUTO"):
|
|
968
|
+
"""Gate 9: Scans skill descriptions and rules to ensure semantic trigger overlap remains < 0.75."""
|
|
969
|
+
print("\n[GATE 9] Running Tier-2 Skill Routing & Collision Guard (Addy Osmani Pattern)...")
|
|
970
|
+
guard_script = os.path.join(SCRIPT_DIR, "skill_collision_guard.py")
|
|
971
|
+
if not os.path.exists(guard_script):
|
|
972
|
+
guard_script = os.path.join(repo_root, "tools", "skill_collision_guard.py")
|
|
973
|
+
if not os.path.exists(guard_script):
|
|
974
|
+
print("[FAIL] skill_collision_guard.py not found in tools/!")
|
|
975
|
+
return False
|
|
976
|
+
|
|
977
|
+
skills_dir = os.path.join(repo_root, ".agents", "skills")
|
|
978
|
+
rules_dir = os.path.join(repo_root, ".agents", "rules")
|
|
979
|
+
if not os.path.exists(skills_dir):
|
|
980
|
+
print("[PASS] Target project mode: .agents/skills/ not present (SKIPPED).")
|
|
981
|
+
return True
|
|
982
|
+
|
|
983
|
+
cmd = [sys.executable, guard_script, "--dir", skills_dir, "--threshold", "0.75"]
|
|
984
|
+
if os.path.exists(rules_dir):
|
|
985
|
+
cmd.extend(["--scan-rules", "--rules-dir", rules_dir])
|
|
986
|
+
|
|
987
|
+
try:
|
|
988
|
+
res = subprocess.run(cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True, timeout=60.0)
|
|
989
|
+
except subprocess.TimeoutExpired:
|
|
990
|
+
print("[FAIL] skill_collision_guard.py timed out after 60s!")
|
|
991
|
+
return False
|
|
992
|
+
|
|
993
|
+
if res.returncode != 0:
|
|
994
|
+
safe_print(res.stdout)
|
|
995
|
+
safe_print(res.stderr)
|
|
996
|
+
return False
|
|
997
|
+
print("[PASS] 100% Verified: 0 skill description and rule collisions detected (similarity < 0.75).")
|
|
998
|
+
return True
|
|
999
|
+
|
|
1000
|
+
|
|
1001
|
+
def gate_10_performance_sla(repo_root, mode="AUTO"):
|
|
1002
|
+
"""Gate 10: Performance & SLA Sentinel: Ingests perf test results (.jtl, k6_summary.json) and enforces SLA thresholds."""
|
|
1003
|
+
print("\n[GATE 10] Running Performance & SLA Sentinel...")
|
|
1004
|
+
perf_dirs = [
|
|
1005
|
+
os.path.join(repo_root, "Reports", "perf"),
|
|
1006
|
+
os.path.join(repo_root, "Reports"),
|
|
1007
|
+
os.path.join(repo_root, ".synapse", "perf")
|
|
1008
|
+
]
|
|
1009
|
+
|
|
1010
|
+
jtl_candidates = []
|
|
1011
|
+
k6_candidates = []
|
|
1012
|
+
for pdir in perf_dirs:
|
|
1013
|
+
if os.path.exists(pdir):
|
|
1014
|
+
jtl_candidates.extend(glob.glob(os.path.join(pdir, "*.jtl")))
|
|
1015
|
+
jtl_candidates.extend(glob.glob(os.path.join(pdir, "*_results.csv")))
|
|
1016
|
+
k6_candidates.extend(glob.glob(os.path.join(pdir, "*k6*.json")))
|
|
1017
|
+
k6_candidates.extend(glob.glob(os.path.join(pdir, "summary.json")))
|
|
1018
|
+
|
|
1019
|
+
if not jtl_candidates and not k6_candidates:
|
|
1020
|
+
print("[PASS] Gate 10: Performance & SLA Sentinel (No active perf runs found in Reports/perf/ - SKIPPED/PASS).")
|
|
1021
|
+
return True
|
|
1022
|
+
|
|
1023
|
+
cfg = load_synapse_config(repo_root)
|
|
1024
|
+
perf_cfg = cfg.get("performance", {}).get("sla", {})
|
|
1025
|
+
sla_p95 = perf_cfg.get("p95_ms", 500.0)
|
|
1026
|
+
sla_p99 = perf_cfg.get("p99_ms", 1000.0)
|
|
1027
|
+
max_error_rate = perf_cfg.get("max_error_rate_pct", 1.0)
|
|
1028
|
+
|
|
1029
|
+
try:
|
|
1030
|
+
try:
|
|
1031
|
+
from tools.jtl_analyzer import parse_jtl, evaluate_sla
|
|
1032
|
+
except ImportError:
|
|
1033
|
+
sys.path.insert(0, SCRIPT_DIR)
|
|
1034
|
+
from jtl_analyzer import parse_jtl, evaluate_sla
|
|
1035
|
+
except Exception as e:
|
|
1036
|
+
print(f"[WARN] jtl_analyzer not available: {e}")
|
|
1037
|
+
return True
|
|
1038
|
+
|
|
1039
|
+
all_passed = True
|
|
1040
|
+
|
|
1041
|
+
# 1. Evaluate Apache JMeter JTL / CSV results
|
|
1042
|
+
for jtl_path in jtl_candidates:
|
|
1043
|
+
rel_path = os.path.relpath(jtl_path, repo_root)
|
|
1044
|
+
try:
|
|
1045
|
+
per_sampler, agg_raw = parse_jtl(jtl_path)
|
|
1046
|
+
if not per_sampler:
|
|
1047
|
+
continue
|
|
1048
|
+
agg_stats = agg_raw.compute()
|
|
1049
|
+
passed, violations = evaluate_sla(
|
|
1050
|
+
agg_stats,
|
|
1051
|
+
sla_p95=sla_p95,
|
|
1052
|
+
sla_p99=sla_p99,
|
|
1053
|
+
max_error_rate=max_error_rate
|
|
1054
|
+
)
|
|
1055
|
+
if not passed:
|
|
1056
|
+
all_passed = False
|
|
1057
|
+
print(f"[FAIL] SLA breach detected in {rel_path}:")
|
|
1058
|
+
for v in violations:
|
|
1059
|
+
print(f" 🔴 {v}")
|
|
1060
|
+
else:
|
|
1061
|
+
print(f"[PASS] SLA compliant in {rel_path} (P95: {agg_stats['p95_ms']}ms, Error: {agg_stats['error_rate_pct']}%)")
|
|
1062
|
+
except Exception as e:
|
|
1063
|
+
print(f"[WARN] Failed to parse JTL {rel_path}: {e}")
|
|
1064
|
+
|
|
1065
|
+
# 2. Evaluate k6 summary export JSON
|
|
1066
|
+
for k6_path in k6_candidates:
|
|
1067
|
+
rel_path = os.path.relpath(k6_path, repo_root)
|
|
1068
|
+
try:
|
|
1069
|
+
with open(k6_path, "r", encoding="utf-8") as f:
|
|
1070
|
+
data = json.load(f)
|
|
1071
|
+
metrics = data.get("metrics", {})
|
|
1072
|
+
dur = metrics.get("http_req_duration", {}).get("values", {})
|
|
1073
|
+
p95 = dur.get("p(95)", 0.0)
|
|
1074
|
+
err_rate = metrics.get("http_req_failed", {}).get("values", {}).get("rate", 0.0) * 100.0
|
|
1075
|
+
|
|
1076
|
+
violations = []
|
|
1077
|
+
if p95 > sla_p95:
|
|
1078
|
+
violations.append(f"P95 Latency SLA Breached: {p95:.1f}ms > {sla_p95}ms")
|
|
1079
|
+
if err_rate > max_error_rate:
|
|
1080
|
+
violations.append(f"Error Rate SLA Breached: {err_rate:.2f}% > {max_error_rate}%")
|
|
1081
|
+
|
|
1082
|
+
if violations:
|
|
1083
|
+
all_passed = False
|
|
1084
|
+
print(f"[FAIL] k6 SLA breach detected in {rel_path}:")
|
|
1085
|
+
for v in violations:
|
|
1086
|
+
print(f" 🔴 {v}")
|
|
1087
|
+
else:
|
|
1088
|
+
print(f"[PASS] k6 SLA compliant in {rel_path} (P95: {p95:.1f}ms, Error: {err_rate:.2f}%)")
|
|
1089
|
+
except Exception as e:
|
|
1090
|
+
print(f"[WARN] Failed to parse k6 summary {rel_path}: {e}")
|
|
1091
|
+
|
|
1092
|
+
if all_passed:
|
|
1093
|
+
print(f"[PASS] 100% Performance SLA Compliant (P95 <= {sla_p95}ms, Error Rate <= {max_error_rate}%).")
|
|
1094
|
+
return True
|
|
1095
|
+
return False
|
|
1096
|
+
|
|
1097
|
+
|
|
1098
|
+
def load_synapse_config(repo_root=None, config_path=None):
|
|
1099
|
+
"""Loads configuration from synapse.config.json if present."""
|
|
1100
|
+
if config_path and os.path.exists(config_path):
|
|
1101
|
+
try:
|
|
1102
|
+
with open(config_path, "r", encoding="utf-8") as f:
|
|
1103
|
+
return json.load(f)
|
|
1104
|
+
except (OSError, json.JSONDecodeError):
|
|
1105
|
+
return {}
|
|
1106
|
+
root = repo_root or REPO_ROOT
|
|
1107
|
+
cand = os.path.join(root, "synapse.config.json")
|
|
1108
|
+
if os.path.exists(cand):
|
|
1109
|
+
try:
|
|
1110
|
+
with open(cand, "r", encoding="utf-8") as f:
|
|
1111
|
+
return json.load(f)
|
|
1112
|
+
except (OSError, json.JSONDecodeError):
|
|
1113
|
+
return {}
|
|
1114
|
+
return {}
|
|
1115
|
+
|
|
1116
|
+
|
|
1117
|
+
def format_gates_junit(gate_results, repo_root):
|
|
1118
|
+
"""Formats 11 DoD Quality Gates result into JUnit XML testsuite."""
|
|
1119
|
+
total = len(gate_results)
|
|
1120
|
+
failures = len([g for g in gate_results if not g[1]])
|
|
1121
|
+
lines = [
|
|
1122
|
+
'<?xml version="1.0" encoding="utf-8"?>',
|
|
1123
|
+
f'<testsuite name="synapse-quality-gates" tests="{total}" failures="{failures}" errors="0">'
|
|
1124
|
+
]
|
|
1125
|
+
for name, success, reason in gate_results:
|
|
1126
|
+
cname = "synapse.quality_gates"
|
|
1127
|
+
tname = name.split(":")[0].strip().replace(" ", "_")
|
|
1128
|
+
lines.append(f' <testcase classname="{cname}" name="{tname}">')
|
|
1129
|
+
if not success:
|
|
1130
|
+
lines.append(f' <failure message="Quality Gate Failed: {name}">{name} failed in repository {repo_root} ({reason})</failure>')
|
|
1131
|
+
lines.append(' </testcase>')
|
|
1132
|
+
lines.append('</testsuite>')
|
|
1133
|
+
return "\n".join(lines)
|
|
1134
|
+
|
|
1135
|
+
|
|
1136
|
+
def run_all_gates(repo_root, mode="AUTO", test_cmd="", output_format="text", config_path=None):
|
|
1137
|
+
"""Programmatic entrypoint to execute all 11 DoD Quality Gates with config and format support."""
|
|
1138
|
+
effective_mode = detect_repo_mode(repo_root) if mode.upper() == "AUTO" else mode.upper()
|
|
1139
|
+
cfg = load_synapse_config(repo_root, config_path=config_path)
|
|
1140
|
+
qg_cfg = cfg.get("quality_gates", {})
|
|
1141
|
+
gate_toggles = qg_cfg.get("gates", {})
|
|
1142
|
+
|
|
1143
|
+
if output_format == "text":
|
|
1144
|
+
print_header(f"ENTERPRISE AUTOMATION - ONE-COMMAND DoD VERIFICATION [{effective_mode} MODE]")
|
|
1145
|
+
print(f"Target Repository: {repo_root}")
|
|
1146
|
+
print(f"Operational Mode : {effective_mode}")
|
|
1147
|
+
|
|
1148
|
+
gates = [
|
|
1149
|
+
("gate_0_author_integrity", "Gate 0: Author Attribution & Integrity", gate_0_author_integrity),
|
|
1150
|
+
("gate_1_bom_check", "Gate 1: UTF-8 No BOM", gate_1_bom_check),
|
|
1151
|
+
("gate_2_path_portability", "Gate 2: Path Portability", gate_2_path_portability),
|
|
1152
|
+
("gate_3_clean_pom", "Gate 3: Clean POM & Flat Architecture", gate_3_clean_pom),
|
|
1153
|
+
("gate_4_ai_docs_lint", "Gate 4: AI Documentation Linter", gate_4_ai_docs_lint),
|
|
1154
|
+
("gate_5_cleanup_blacklist", "Gate 5: Temporary Files Blacklist", gate_5_cleanup_blacklist),
|
|
1155
|
+
("gate_6_credential_security", "Gate 6: Credential Security", gate_6_credential_security),
|
|
1156
|
+
("gate_7_infer_linter", "Gate 7: Static Defect Sentinel", gate_7_infer_linter),
|
|
1157
|
+
("gate_8_micro_mutator", "Gate 8: Assertion Sensitivity & Syntactic Mutation Sentinel", lambda r, mode: gate_8_micro_mutator(r, mode=mode, test_cmd=test_cmd)),
|
|
1158
|
+
("gate_9_skill_collision", "Gate 9: Tier-2 Skill Routing & Collision Guard", gate_9_skill_collision),
|
|
1159
|
+
("gate_10_performance_sla", "Gate 10: Performance & SLA Sentinel", gate_10_performance_sla),
|
|
1160
|
+
]
|
|
1161
|
+
|
|
1162
|
+
all_passed = True
|
|
1163
|
+
gate_results = []
|
|
1164
|
+
|
|
1165
|
+
if output_format in ("json", "junit"):
|
|
1166
|
+
old_stdout = sys.stdout
|
|
1167
|
+
sys.stdout = io.StringIO()
|
|
1168
|
+
try:
|
|
1169
|
+
for g_key, name, gate_fn in gates:
|
|
1170
|
+
if gate_toggles.get(g_key) is False:
|
|
1171
|
+
gate_results.append((name, True, "SKIPPED_BY_CONFIG"))
|
|
1172
|
+
continue
|
|
1173
|
+
success = gate_fn(repo_root, mode=effective_mode)
|
|
1174
|
+
gate_results.append((name, success, "PASS" if success else "FAIL"))
|
|
1175
|
+
if not success:
|
|
1176
|
+
all_passed = False
|
|
1177
|
+
finally:
|
|
1178
|
+
sys.stdout = old_stdout
|
|
1179
|
+
else:
|
|
1180
|
+
for g_key, name, gate_fn in gates:
|
|
1181
|
+
if gate_toggles.get(g_key) is False:
|
|
1182
|
+
print(f"\n[{name.split(':')[0].upper()}] Disabled via synapse.config.json (SKIPPED)")
|
|
1183
|
+
gate_results.append((name, True, "SKIPPED_BY_CONFIG"))
|
|
1184
|
+
continue
|
|
1185
|
+
|
|
1186
|
+
success = gate_fn(repo_root, mode=effective_mode)
|
|
1187
|
+
gate_results.append((name, success, "PASS" if success else "FAIL"))
|
|
1188
|
+
if not success:
|
|
1189
|
+
all_passed = False
|
|
1190
|
+
|
|
1191
|
+
passed_count = sum(1 for _, passed, status in gate_results if passed and status == "PASS")
|
|
1192
|
+
skipped_count = sum(1 for _, _, status in gate_results if status in ("SKIPPED_BY_CONFIG", "SKIPPED"))
|
|
1193
|
+
failed_count = sum(1 for _, passed, status in gate_results if not passed or status == "FAIL")
|
|
1194
|
+
|
|
1195
|
+
if output_format == "json":
|
|
1196
|
+
res_doc = {
|
|
1197
|
+
"timestamp": datetime.now().isoformat(),
|
|
1198
|
+
"target": repo_root,
|
|
1199
|
+
"mode": effective_mode,
|
|
1200
|
+
"all_passed": all_passed and failed_count == 0,
|
|
1201
|
+
"summary": {
|
|
1202
|
+
"total": len(gates),
|
|
1203
|
+
"passed": passed_count,
|
|
1204
|
+
"skipped": skipped_count,
|
|
1205
|
+
"failed": failed_count
|
|
1206
|
+
},
|
|
1207
|
+
"gates": [{"name": g[0], "passed": g[1], "status": g[2]} for g in gate_results]
|
|
1208
|
+
}
|
|
1209
|
+
print(json.dumps(res_doc, indent=2))
|
|
1210
|
+
return 0 if (all_passed and failed_count == 0) else 1
|
|
1211
|
+
|
|
1212
|
+
if output_format == "junit":
|
|
1213
|
+
print(format_gates_junit(gate_results, repo_root))
|
|
1214
|
+
return 0 if (all_passed and failed_count == 0) else 1
|
|
1215
|
+
|
|
1216
|
+
print("\n" + "=" * 70)
|
|
1217
|
+
if all_passed and failed_count == 0 and skipped_count == 0:
|
|
1218
|
+
print(f"[ALL {len(gates)} QUALITY GATES PASSED - 100% DoD COMPLIANT]")
|
|
1219
|
+
print(" Repository is 100% compliant, secure, and ready for execution/CI/CD.")
|
|
1220
|
+
print("=" * 70 + "\n")
|
|
1221
|
+
return 0
|
|
1222
|
+
elif all_passed and failed_count == 0 and skipped_count > 0:
|
|
1223
|
+
print(f"[QUALITY GATES PASSED: {passed_count}/{len(gates)} PASSED, {skipped_count} SKIPPED BY CONFIG]")
|
|
1224
|
+
print(" Note: Some gates were disabled via synapse.config.json.")
|
|
1225
|
+
print("=" * 70 + "\n")
|
|
1226
|
+
return 0
|
|
1227
|
+
else:
|
|
1228
|
+
print(f"[DoD BLOCKED] {failed_count} OF {len(gates)} QUALITY GATES FAILED.")
|
|
1229
|
+
print(" Please review the errors above and resolve them before proceeding.")
|
|
1230
|
+
print("=" * 70 + "\n")
|
|
1231
|
+
return 1
|
|
1232
|
+
|
|
1233
|
+
|
|
1234
|
+
def main():
|
|
1235
|
+
parser = argparse.ArgumentParser(description="Enterprise DoD Verification Sentinel")
|
|
1236
|
+
parser.add_argument("target", nargs="?", default=None,
|
|
1237
|
+
help="Target repository path to verify (defaults to auto-detection from CWD or Hub)")
|
|
1238
|
+
parser.add_argument("--repo", "--path", dest="repo_path", default=None,
|
|
1239
|
+
help="Target repository path to verify")
|
|
1240
|
+
parser.add_argument("--mode", choices=["auto", "hub", "target"], default="auto",
|
|
1241
|
+
help="Execution mode (auto-detect, hub, or target test project)")
|
|
1242
|
+
parser.add_argument("--format", choices=["text", "json", "junit"], default="text",
|
|
1243
|
+
help="Output report format (default: text)")
|
|
1244
|
+
parser.add_argument("--config", help="Path to synapse.config.json")
|
|
1245
|
+
parser.add_argument("--test-cmd", default="",
|
|
1246
|
+
help="Optional test command for Gate 8 dynamic mutation testing (e.g. 'pytest' or 'npx playwright test')")
|
|
1247
|
+
args = parser.parse_args()
|
|
1248
|
+
|
|
1249
|
+
try:
|
|
1250
|
+
repo_root = resolve_target_repo(cli_target=args.target, cli_repo=args.repo_path)
|
|
1251
|
+
except FileNotFoundError as e:
|
|
1252
|
+
print(f"[ERROR] {e}")
|
|
1253
|
+
return 1
|
|
1254
|
+
|
|
1255
|
+
return run_all_gates(repo_root, mode=args.mode, test_cmd=args.test_cmd, output_format=args.format, config_path=args.config)
|
|
1256
|
+
|
|
1257
|
+
|
|
1258
|
+
if __name__ == "__main__":
|
|
1259
|
+
sys.exit(main())
|