@teevee98/synapse-hub 4.3.1 → 4.4.1

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.
Files changed (289) hide show
  1. package/.cursor/rules/agents.mdc +11 -11
  2. package/.cursor/rules/katalon.mdc +11 -0
  3. package/.cursor/rules/perf.mdc +10 -0
  4. package/.cursor/rules/playwright.mdc +10 -0
  5. package/.cursor/rules/pytest.mdc +10 -0
  6. package/.cursor/rules/synapse-qa.mdc +4 -2
  7. package/.cursorrules +3 -10
  8. package/.windsurfrules +3 -10
  9. package/AGENTS.md +4 -3
  10. package/CLAUDE.md +4 -5
  11. package/README.en.md +3 -3
  12. package/README.md +3 -3
  13. package/agentskills.json +15 -15
  14. package/{.agents/agents → ai-agents/personas}/api-engineer.md +9 -1
  15. package/{.agents/agents → ai-agents/personas}/failure-analyst.md +1 -1
  16. package/{.agents/agents → ai-agents/personas}/live-explorer.md +1 -1
  17. package/{.agents/agents → ai-agents/personas}/orchestrator.md +8 -15
  18. package/{.agents/agents → ai-agents/personas}/perf-engineer.md +11 -5
  19. package/{.agents/agents → ai-agents/personas}/pom-crafter.md +3 -9
  20. package/{.agents/agents → ai-agents/personas}/quality-gatekeeper.md +1 -1
  21. package/{.agents/agents → ai-agents/personas}/test-designer.md +2 -1
  22. package/{.agents/agents → ai-agents/personas}/test-runner.md +3 -4
  23. package/{.agents/rules → automation/playwright}/mandatory-playwright-live.md +5 -13
  24. package/{.agents/skills/01-web-automation → automation/playwright}/playwright-webapp-testing/SKILL.md +2 -0
  25. package/{.agents/skills/01-web-automation → automation/shared-utils}/clean-pom-crafter/SKILL.md +14 -3
  26. package/{.agents/skills/01-web-automation → automation/shared-utils}/e2e-testing-patterns/SKILL.md +12 -1
  27. package/{.agents/skills/01-web-automation → automation/shared-utils}/lam-script-generator/SKILL.md +2 -0
  28. package/docs/ARCHITECTURE.en.md +96 -3
  29. package/docs/ARCHITECTURE.md +87 -3
  30. package/docs/TOOL_CATALOG.md +17 -5
  31. package/docs/reports/AUDIT_REPORT.md +1038 -0
  32. package/docs/reports/PROJECT_HEALTH_REPORT.md +49 -0
  33. package/docs/reports/TECHNICAL_DEBT_LEDGER.md +22 -0
  34. package/package.json +8 -1
  35. package/plugin.json +1 -1
  36. package/{.agents/skills/02-test-design → requirement/spec-review}/review-spec/SKILL.md +8 -0
  37. package/scripts/install_global_plugin.ps1 +1 -1
  38. package/scripts/install_global_plugin.sh +1 -1
  39. package/skills_index.json +61 -0
  40. package/skills_manifest.json +88 -62
  41. package/{.agents/skills/08-code-quality → standards/coding-standards}/lean-code-ladder/SKILL.md +8 -1
  42. package/{.agents/skills/08-code-quality → standards/coding-standards}/surgical-coding-principles/SKILL.md +2 -0
  43. package/{.agents/skills/11-ai-and-prompting → standards/context-ai}/mipro-prompt-compiler/SKILL.md +8 -0
  44. package/synapse.config.json +1 -1
  45. package/templates/ai_bridges/CLAUDE.md +4 -5
  46. package/templates/ai_bridges/copilot-instructions.md +1 -0
  47. package/templates/ai_bridges/cursor_synapse_qa.mdc +4 -2
  48. package/templates/ai_bridges/windsurfrules +3 -10
  49. package/templates/test-plan/performance-test-plan-template.md +106 -0
  50. package/{.agents/skills/02-test-design → test-design/manual-rbt}/rbt-manual-testing/SKILL.md +11 -5
  51. package/{.agents/skills/07-data-and-state → test-design/test-data}/file-and-report-validator/SKILL.md +8 -1
  52. package/{.agents/skills/07-data-and-state → test-design/test-data}/synthetic-test-data-generator/SKILL.md +4 -1
  53. package/testing/api-contracts/api_testing_rules.md +74 -0
  54. package/{.agents/skills/06-healing-and-resilience → testing/healing-resilience}/agentless-qa-repair/SKILL.md +2 -0
  55. package/{.agents/skills/06-healing-and-resilience → testing/healing-resilience}/failure-autopsy-and-healing/SKILL.md +5 -11
  56. package/{.agents/skills/06-healing-and-resilience → testing/healing-resilience}/self-healing-locator/SKILL.md +2 -0
  57. package/testing/manual/manual-qa-and-rtm-bridge/SKILL.md +92 -0
  58. package/testing/manual/manual-qa-and-rtm-bridge/examples/sample_bug_and_rtm.json +38 -0
  59. package/{.agents/skills/04-performance-and-load → testing/performance}/backend-load-and-stress-patterns/SKILL.md +5 -2
  60. package/testing/performance/backend-load-and-stress-patterns/references/performance_test_plan_29119.md +106 -0
  61. package/{.agents/rules → testing/performance}/performance_testing_rules.md +27 -3
  62. package/{.agents/skills/04-performance-and-load → testing/performance}/web-vitals-and-performance-profiler/SKILL.md +75 -14
  63. package/{.agents/skills/05-security-and-compliance → testing/security-a11y}/security-dast-sentinel/SKILL.md +13 -2
  64. package/{.agents/rules → testing/security-a11y}/security_testing_rules.md +19 -0
  65. package/{.agents/skills/05-security-and-compliance → testing/security-a11y}/wcag-audit-patterns/SKILL.md +4 -1
  66. package/tools/.infer_baseline.json +44 -3
  67. package/tools/TOOLS_RUNBOOK.md +246 -4
  68. package/tools/TOOL_CATALOG.json +199 -19
  69. package/tools/TOOL_INDEX.json +160 -0
  70. package/tools/__init__.py +1 -1
  71. package/tools/ai_eval_sentinel.py +403 -0
  72. package/tools/assertion_optimizer.py +188 -0
  73. package/tools/asvs_auditor.py +410 -0
  74. package/tools/author_integrity.py +12 -1
  75. package/tools/benchmark_swarm_context.py +1 -1
  76. package/tools/browser_helpers.js +2 -2
  77. package/tools/catalogs/api_contract_testing.json +107 -0
  78. package/tools/catalogs/auxiliary_utilities.json +1536 -0
  79. package/tools/catalogs/benchmarking.json +23 -0
  80. package/tools/catalogs/ci_cd_packaging.json +46 -0
  81. package/tools/catalogs/code_generation_ast.json +70 -0
  82. package/tools/catalogs/failure_autopsy_healing.json +41 -0
  83. package/tools/catalogs/manual_testing_design.json +80 -0
  84. package/tools/catalogs/orchestration.json +25 -0
  85. package/tools/catalogs/performance_testing.json +71 -0
  86. package/tools/catalogs/quality_gates.json +65 -0
  87. package/tools/catalogs/sandboxing_isolation.json +42 -0
  88. package/tools/catalogs/security.json +72 -0
  89. package/tools/catalogs/setup_onboarding.json +26 -0
  90. package/tools/catalogs/testing_utilities.json +111 -0
  91. package/tools/chaos_resilience_probe.py +362 -0
  92. package/tools/check_env.py +16 -3
  93. package/tools/check_version_sync.py +114 -63
  94. package/tools/cldr_l10n_verifier.py +309 -0
  95. package/tools/cli.py +971 -3
  96. package/tools/core/circuit_breaker.py +106 -0
  97. package/tools/core/token_estimator.py +56 -7
  98. package/tools/cvss_calculator.py +412 -0
  99. package/tools/dashboard_generator.py +12 -12
  100. package/tools/etl_data_reconciler.py +460 -0
  101. package/tools/generate_jmx_plan.py +12 -4
  102. package/tools/generate_tool_catalog.py +60 -2
  103. package/tools/jtl_analyzer.py +23 -1
  104. package/tools/mcp_docx_server.py +1 -1
  105. package/tools/mcp_excel_server.py +1 -1
  106. package/tools/mcp_server.py +5 -1
  107. package/tools/mobile_resilience_sentinel.py +273 -0
  108. package/tools/observability_tester.py +235 -0
  109. package/tools/payment_interop_simulator.py +337 -0
  110. package/tools/pre_push_guard.py +306 -0
  111. package/tools/project_state.py +17 -10
  112. package/tools/regulatory_compliance.py +336 -0
  113. package/tools/reversible_sandbox.py +7 -2
  114. package/tools/rules_router.py +6 -4
  115. package/tools/runaway_stopper.py +19 -111
  116. package/tools/setup_project.py +1 -1
  117. package/tools/skill_canonical_digest.py +2 -2
  118. package/tools/skillspector.py +78 -10
  119. package/tools/sync_agent_rules.py +15 -27
  120. package/tools/sync_skills_manifest.py +38 -4
  121. package/tools/tmmi_auditor.py +179 -0
  122. package/tools/ui_server.py +1 -1
  123. package/tools/update_sentinel.py +4 -4
  124. package/tools/validate_host_interop.py +3 -1
  125. package/tools/validate_skills_schema.py +49 -2
  126. package/tools/vpat_exporter.py +428 -0
  127. package/tools/welcome_page.py +4 -4
  128. package/.agents/rules/stack-auto-router.md +0 -30
  129. package/.agents/skills/09-ci-and-devops/github-actions-templates/SKILL.md +0 -114
  130. package/.agents/skills/09-ci-and-devops/github-actions-templates/examples/matrix_test_pipeline.yml +0 -9
  131. package/.agents/skills/09-ci-and-devops/gitlab-ci-templates/SKILL.md +0 -123
  132. package/.agents/skills/09-ci-and-devops/gitlab-ci-templates/examples/sample_gitlab_ci.yml +0 -17
  133. package/.agents/skills/09-ci-and-devops/jenkins-pipeline-templates/SKILL.md +0 -133
  134. package/.agents/skills/09-ci-and-devops/jenkins-pipeline-templates/examples/Jenkinsfile.example +0 -21
  135. package/.cursor/rules/language.mdc +0 -7
  136. package/templates/ci/github-actions-synapse.yml +0 -95
  137. package/templates/ci/gitlab-ci-synapse.yml +0 -16
  138. package/tools/build_consolidated_report.py +0 -1643
  139. package/tools/create_mock_docx.py +0 -107
  140. /package/{.agents → ai-agents/hooks}/hooks.json +0 -0
  141. /package/{.agents → ai-agents}/hooks/session_start.py +0 -0
  142. /package/{.agents/skills/10-agent-orchestration → ai-agents/orchestration}/actor-qa-swarm/SKILL.md +0 -0
  143. /package/{.agents/skills/10-agent-orchestration → ai-agents/orchestration}/actor-qa-swarm/examples/broker_sharding_sample.json +0 -0
  144. /package/{.agents/skills/10-agent-orchestration → ai-agents/orchestration}/agent-orchestration-multi-agent-optimize/SKILL.md +0 -0
  145. /package/{.agents/skills/10-agent-orchestration → ai-agents/orchestration}/agent-orchestration-multi-agent-optimize/examples/swarm_workload_config.json +0 -0
  146. /package/{.agents/skills/10-agent-orchestration → ai-agents/orchestration}/event-stream-qa-orchestrator/SKILL.md +0 -0
  147. /package/{.agents/skills/10-agent-orchestration → ai-agents/orchestration}/event-stream-qa-orchestrator/examples/timeline_sample.jsonl +0 -0
  148. /package/{.agents/skills/10-agent-orchestration → ai-agents/orchestration}/persistent-planning-files/SKILL.md +0 -0
  149. /package/{.agents/skills/10-agent-orchestration → ai-agents/orchestration}/persistent-planning-files/examples/task_plan_example.md +0 -0
  150. /package/{.agents/skills/10-agent-orchestration → ai-agents/orchestration}/qa-memory-os/SKILL.md +0 -0
  151. /package/{.agents/skills/10-agent-orchestration → ai-agents/orchestration}/qa-memory-os/examples/archival_memory_sample.json +0 -0
  152. /package/{.agents → ai-agents}/workflows/graphify.md +0 -0
  153. /package/{.agents → ai-agents}/workflows/test-impact.md +0 -0
  154. /package/{.agents → ai-agents}/workflows/verify.md +0 -0
  155. /package/{.agents/rules → automation/cypress}/cypress_rules.md +0 -0
  156. /package/{.agents/skills/01-web-automation → automation/katalon}/katalon-cli-runner/SKILL.md +0 -0
  157. /package/{.agents/skills/01-web-automation → automation/katalon}/katalon-cli-runner/examples/headless_kre_exec.sh +0 -0
  158. /package/{.agents/skills/01-web-automation → automation/katalon}/katalon-cli-runner/references/groovy-patterns.md +0 -0
  159. /package/{.agents/skills/01-web-automation → automation/katalon}/katalon-cli-runner/references/katalon-api.md +0 -0
  160. /package/{.agents/skills/01-web-automation → automation/katalon}/katalon-cli-runner/references/runner_commands.md +0 -0
  161. /package/{.agents/skills/01-web-automation → automation/mobile}/mobile-appium-som/SKILL.md +0 -0
  162. /package/{.agents/skills/01-web-automation → automation/mobile}/mobile-appium-som/examples/BaseScreen.java +0 -0
  163. /package/{.agents/skills/01-web-automation → automation/mobile}/mobile-appium-som/examples/LoginScreen.java +0 -0
  164. /package/{.agents/skills/01-web-automation → automation/mobile}/mobile-appium-som/examples/TC_MobileLogin.java +0 -0
  165. /package/{.agents/skills/01-web-automation → automation/mobile}/mobile-maestro-detox-patterns/SKILL.md +0 -0
  166. /package/{.agents/skills/01-web-automation → automation/mobile}/mobile-maestro-detox-patterns/examples/sample_flow.yaml +0 -0
  167. /package/{.agents/rules → automation/mobile}/mobile_appium_rules.md +0 -0
  168. /package/{.agents/skills/01-web-automation → automation/playwright}/playwright-live-interaction/SKILL.md +0 -0
  169. /package/{.agents/skills/01-web-automation → automation/playwright}/playwright-live-interaction/examples/live_probe_script.js +0 -0
  170. /package/{.agents/skills/01-web-automation → automation/playwright}/playwright-live-interaction/references/advanced_superpowers.md +0 -0
  171. /package/{.agents/skills/01-web-automation → automation/playwright}/playwright-live-interaction/references/compact_accessibility_snapshots.md +0 -0
  172. /package/{.agents/skills/01-web-automation → automation/playwright}/playwright-live-interaction/references/recipes.md +0 -0
  173. /package/{.agents/skills/01-web-automation → automation/playwright}/playwright-live-interaction/references/swarm_orchestration.md +0 -0
  174. /package/{.agents/skills/01-web-automation → automation/playwright}/playwright-webapp-testing/examples/server_lifecycle_playwright.py +0 -0
  175. /package/{.agents/skills/01-web-automation → automation/shared-utils}/auth-session-and-cookie-manager/SKILL.md +0 -0
  176. /package/{.agents/skills/01-web-automation → automation/shared-utils}/auth-session-and-cookie-manager/examples/multi_role_auth_matrix.md +0 -0
  177. /package/{.agents/skills/01-web-automation → automation/shared-utils}/auth-session-and-cookie-manager/examples/storage_state_sample.json +0 -0
  178. /package/{.agents/skills/01-web-automation → automation/shared-utils}/bats-testing-patterns/SKILL.md +0 -0
  179. /package/{.agents/skills/01-web-automation → automation/shared-utils}/bats-testing-patterns/examples/cli_runner_test.bats +0 -0
  180. /package/{.agents/skills/01-web-automation → automation/shared-utils}/bats-testing-patterns/resources/implementation-playbook.md +0 -0
  181. /package/{.agents/skills/01-web-automation → automation/shared-utils}/clean-pom-crafter/examples/standard_test_case.groovy +0 -0
  182. /package/{.agents/skills/01-web-automation → automation/shared-utils}/clean-pom-crafter/references/pom_patterns.groovy +0 -0
  183. /package/{.agents/skills/01-web-automation → automation/shared-utils}/e2e-testing-patterns/examples/playwright_sharded_config.ts +0 -0
  184. /package/{.agents/skills/01-web-automation → automation/shared-utils}/e2e-testing-patterns/resources/implementation-playbook.md +0 -0
  185. /package/{.agents/skills/01-web-automation → automation/shared-utils}/lam-script-generator/examples/user_story_sample.md +0 -0
  186. /package/{.agents/skills/03-api-and-contracts → requirement/spec-review}/api-spec-to-e2e-matrix/SKILL.md +0 -0
  187. /package/{.agents/skills/03-api-and-contracts → requirement/spec-review}/api-spec-to-e2e-matrix/examples/sample_openapi.json +0 -0
  188. /package/{.agents/skills/02-test-design → requirement/spec-review}/architecture-decision-records/SKILL.md +0 -0
  189. /package/{.agents/skills/02-test-design → requirement/spec-review}/architecture-decision-records/examples/0001-record-architecture-decisions.md +0 -0
  190. /package/{.agents/skills/02-test-design → requirement/spec-review}/review-spec/examples/pocock_grilling_decision_rubric.md +0 -0
  191. /package/{.agents/skills/02-test-design → requirement/spec-review}/review-spec/examples/sample_spec_review.md +0 -0
  192. /package/{.agents → requirement}/workflows/analyze_requirement_document.md +0 -0
  193. /package/{.agents → requirement}/workflows/generate_requirements_from_website.md +0 -0
  194. /package/{.agents/rules → standards/coding-standards}/author-integrity-guard.md +0 -0
  195. /package/{.agents/skills/08-code-quality → standards/coding-standards}/code-refactoring-refactor-clean/SKILL.md +0 -0
  196. /package/{.agents/skills/08-code-quality → standards/coding-standards}/code-refactoring-refactor-clean/examples/refactored_page_sample.groovy +0 -0
  197. /package/{.agents/skills/08-code-quality → standards/coding-standards}/code-refactoring-refactor-clean/examples/refactored_playwright_pom.ts +0 -0
  198. /package/{.agents/skills/08-code-quality → standards/coding-standards}/code-refactoring-refactor-clean/resources/implementation-playbook.md +0 -0
  199. /package/{.agents/rules → standards/coding-standards}/communication-style.md +0 -0
  200. /package/{.agents/rules → standards/coding-standards}/git-push-protocol.md +0 -0
  201. /package/{.agents/skills/08-code-quality → standards/coding-standards}/graphify-impact-analyzer/SKILL.md +0 -0
  202. /package/{.agents/skills/08-code-quality → standards/coding-standards}/graphify-impact-analyzer/examples/dependency_blast_radius.json +0 -0
  203. /package/{.agents/skills/08-code-quality → standards/coding-standards}/lean-code-ladder/examples/ladder_walkthrough.md +0 -0
  204. /package/{.agents/skills/08-code-quality → standards/coding-standards}/repo-quality-audit/SKILL.md +0 -0
  205. /package/{.agents/skills/08-code-quality → standards/coding-standards}/repo-quality-audit/examples/sample_audit_walkthrough.md +0 -0
  206. /package/{.agents/skills/08-code-quality → standards/coding-standards}/repo-quality-audit/examples/sample_repo_audit.md +0 -0
  207. /package/{.agents/skills/08-code-quality → standards/coding-standards}/senior-code-review/SKILL.md +0 -0
  208. /package/{.agents/skills/08-code-quality → standards/coding-standards}/senior-code-review/examples/sample_review_walkthrough.md +0 -0
  209. /package/{.agents/skills/08-code-quality → standards/coding-standards}/surgical-coding-principles/examples/surgical_vs_scope_creep.md +0 -0
  210. /package/{.agents/skills/08-code-quality → standards/coding-standards}/technical-debt-harvester/SKILL.md +0 -0
  211. /package/{.agents/skills/08-code-quality → standards/coding-standards}/technical-debt-harvester/examples/sample_debt_ledger.md +0 -0
  212. /package/{.agents/skills/08-code-quality → standards/coding-standards}/technical-debt-harvester/examples/sample_ledger_output.md +0 -0
  213. /package/{.agents/rules → standards/context-ai}/context-engineering.md +0 -0
  214. /package/{.agents/skills/11-ai-and-prompting → standards/context-ai}/meta-prompt-crafter/SKILL.md +0 -0
  215. /package/{.agents/skills/11-ai-and-prompting → standards/context-ai}/meta-prompt-crafter/examples/qa_prompt_template.md +0 -0
  216. /package/{.agents/skills/11-ai-and-prompting → standards/context-ai}/mipro-prompt-compiler/examples/compiled_module_sample.json +0 -0
  217. /package/{.agents/skills/11-ai-and-prompting → standards/context-ai}/mipro-prompt-compiler/examples/dspy_assertion_optimizer_case.md +0 -0
  218. /package/{.agents/skills/11-ai-and-prompting → standards/context-ai}/qa-aci-interface/SKILL.md +0 -0
  219. /package/{.agents/skills/11-ai-and-prompting → standards/context-ai}/qa-aci-interface/examples/surgical_code_window_walkthrough.md +0 -0
  220. /package/{.agents/skills/11-ai-and-prompting → standards/context-ai}/qa-aci-interface/examples/surgical_edit_sample.json +0 -0
  221. /package/{.agents/skills/11-ai-and-prompting → standards/context-ai}/token-and-context-optimizer/SKILL.md +0 -0
  222. /package/{.agents/skills/11-ai-and-prompting → standards/context-ai}/token-and-context-optimizer/examples/distilled_log_sample.txt +0 -0
  223. /package/{.agents/skills/11-ai-and-prompting → standards/context-ai}/token-and-context-optimizer/references/context_engineering_guide.md +0 -0
  224. /package/{.agents/rules → standards/qa-process}/graphify.md +0 -0
  225. /package/{.agents/rules → standards/qa-process}/lessons-learned.md +0 -0
  226. /package/{.agents/rules → standards/qa-process}/skill-precedence.md +0 -0
  227. /package/{.agents/rules → standards/quality-gates}/systematic-debugging.md +0 -0
  228. /package/{.agents/templates → templates/test-report}/completion_report.md +0 -0
  229. /package/{.agents/skills/02-test-design → test-design/bdd-gherkin}/gherkin-to-suite/SKILL.md +0 -0
  230. /package/{.agents/skills/02-test-design → test-design/bdd-gherkin}/gherkin-to-suite/examples/checkout.feature +0 -0
  231. /package/{.agents/skills/02-test-design → test-design/bdd-gherkin}/gherkin-to-suite/examples/suite_report_sample.json +0 -0
  232. /package/{.agents → test-design/bdd-gherkin}/workflows/generate_cross_module_test_plan.md +0 -0
  233. /package/{.agents → test-design/bdd-gherkin}/workflows/generate_testcases_from_requirements.md +0 -0
  234. /package/{.agents/skills/02-test-design → test-design/exploratory}/tot-exploratory-testing/SKILL.md +0 -0
  235. /package/{.agents/skills/02-test-design → test-design/exploratory}/tot-exploratory-testing/examples/payment_gateway_tot_tree.json +0 -0
  236. /package/{.agents/skills/02-test-design → test-design/exploratory}/tot-exploratory-testing/examples/tot_graph_sample.json +0 -0
  237. /package/{.agents/skills/02-test-design → test-design/manual-rbt}/rbt-manual-testing/examples/checkout_rbt_manual_suite.md +0 -0
  238. /package/{.agents/skills/02-test-design → test-design/manual-rbt}/rbt-manual-testing/references/field_validation_checklist.md +0 -0
  239. /package/{.agents → test-design/manual-rbt}/workflows/export_testcases_excel.md +0 -0
  240. /package/{.agents → test-design/manual-rbt}/workflows/generate_manual_testcases_rbt.md +0 -0
  241. /package/{.agents/skills/07-data-and-state → test-design/test-data}/db-state-verifier-and-seeder/SKILL.md +0 -0
  242. /package/{.agents/skills/07-data-and-state → test-design/test-data}/db-state-verifier-and-seeder/examples/db_fixture_seed.json +0 -0
  243. /package/{.agents/skills/07-data-and-state → test-design/test-data}/file-and-report-validator/examples/sample_export_schema.json +0 -0
  244. /package/{.agents/skills/07-data-and-state → test-design/test-data}/synthetic-test-data-generator/examples/idempotent_data_recipe.json +0 -0
  245. /package/{.agents → test-design/test-data}/workflows/generate_combinatorial_test_data.md +0 -0
  246. /package/{.agents/skills/03-api-and-contracts → testing/api-contracts}/api-network-mocking-interception/SKILL.md +0 -0
  247. /package/{.agents/skills/03-api-and-contracts → testing/api-contracts}/api-network-mocking-interception/examples/network_route_stub.json +0 -0
  248. /package/{.agents/skills/03-api-and-contracts → testing/api-contracts}/consumer-driven-contract-testing/SKILL.md +0 -0
  249. /package/{.agents/skills/03-api-and-contracts → testing/api-contracts}/consumer-driven-contract-testing/examples/order_service_pact.json +0 -0
  250. /package/{.agents/skills/06-healing-and-resilience → testing/healing-resilience}/agentless-qa-repair/examples/healing_report_sample.json +0 -0
  251. /package/{.agents/skills/06-healing-and-resilience → testing/healing-resilience}/agentless-qa-repair/examples/three_phase_repair_workflow.md +0 -0
  252. /package/{.agents/skills/06-healing-and-resilience → testing/healing-resilience}/antigravity-test-sentinel/SKILL.md +0 -0
  253. /package/{.agents/skills/06-healing-and-resilience → testing/healing-resilience}/antigravity-test-sentinel/examples/dod_gate_policy.json +0 -0
  254. /package/{.agents/skills/06-healing-and-resilience → testing/healing-resilience}/antigravity-test-sentinel/examples/sprint_dod_enforcement.md +0 -0
  255. /package/{.agents/skills/06-healing-and-resilience → testing/healing-resilience}/failure-autopsy-and-healing/examples/closed_loop_healing_walkthrough.md +0 -0
  256. /package/{.agents/skills/06-healing-and-resilience → testing/healing-resilience}/failure-autopsy-and-healing/examples/sample_junit_failure.xml +0 -0
  257. /package/{.agents/skills/06-healing-and-resilience → testing/healing-resilience}/failure-autopsy-and-healing/references/healing_matrix.md +0 -0
  258. /package/{.agents/skills/06-healing-and-resilience → testing/healing-resilience}/failure-autopsy-and-healing/references/qa_investigation_protocol.md +0 -0
  259. /package/{.agents/skills/06-healing-and-resilience → testing/healing-resilience}/failure-autopsy-and-healing/scripts/triage_failures.sh +0 -0
  260. /package/{.agents/skills/06-healing-and-resilience → testing/healing-resilience}/flaky-test-sentinel-and-quarantine/SKILL.md +0 -0
  261. /package/{.agents/skills/06-healing-and-resilience → testing/healing-resilience}/flaky-test-sentinel-and-quarantine/examples/quarantine_registry.json +0 -0
  262. /package/{.agents/skills/06-healing-and-resilience → testing/healing-resilience}/self-healing-locator/examples/aom_diff_sample.json +0 -0
  263. /package/{.agents/skills/06-healing-and-resilience → testing/healing-resilience}/systematic-debugging/SKILL.md +0 -0
  264. /package/{.agents/skills/06-healing-and-resilience → testing/healing-resilience}/systematic-debugging/examples/four_phase_case.md +0 -0
  265. /package/{.agents/skills/06-healing-and-resilience → testing/healing-resilience}/test-driven-development/SKILL.md +0 -0
  266. /package/{.agents/skills/06-healing-and-resilience → testing/healing-resilience}/test-driven-development/examples/red_green_refactor_qa.md +0 -0
  267. /package/{.agents/skills/06-healing-and-resilience → testing/healing-resilience}/verification-before-completion/SKILL.md +0 -0
  268. /package/{.agents/skills/06-healing-and-resilience → testing/healing-resilience}/verification-before-completion/examples/evidence_log_example.md +0 -0
  269. /package/{.agents/skills/06-healing-and-resilience → testing/healing-resilience}/visual-regression-sentinel/SKILL.md +0 -0
  270. /package/{.agents/skills/06-healing-and-resilience → testing/healing-resilience}/visual-regression-sentinel/examples/visual_mask_rules.json +0 -0
  271. /package/{.agents/skills/04-performance-and-load → testing/performance}/backend-load-and-stress-patterns/examples/k6_load_test_sample.js +0 -0
  272. /package/{.agents/skills/04-performance-and-load → testing/performance}/backend-load-and-stress-patterns/references/k6_load_template.js +0 -0
  273. /package/{.agents/skills/04-performance-and-load → testing/performance}/lean-impact-scoreboard/SKILL.md +0 -0
  274. /package/{.agents/skills/04-performance-and-load → testing/performance}/lean-impact-scoreboard/examples/sample_benchmark_gain.md +0 -0
  275. /package/{.agents/skills/04-performance-and-load → testing/performance}/lean-impact-scoreboard/examples/sample_scoreboard.md +0 -0
  276. /package/{.agents/skills/04-performance-and-load → testing/performance}/web-vitals-and-performance-profiler/examples/cwv_budget_policy.json +0 -0
  277. /package/{.agents/skills/04-performance-and-load → testing/performance}/web-vitals-and-performance-profiler/examples/playwright_cwv_profiler_fixture.ts +0 -0
  278. /package/{.agents/skills/05-security-and-compliance → testing/security-a11y}/security-dast-sentinel/examples/dast_scan_config.json +0 -0
  279. /package/{.agents/skills/05-security-and-compliance → testing/security-a11y}/security-dast-sentinel/references/AI-AND-LLM.md +0 -0
  280. /package/{.agents/skills/05-security-and-compliance → testing/security-a11y}/security-dast-sentinel/references/ATTACK-CLASSES.md +0 -0
  281. /package/{.agents/skills/05-security-and-compliance → testing/security-a11y}/security-dast-sentinel/references/dast_recipes.ts +0 -0
  282. /package/{.agents/skills/05-security-and-compliance → testing/security-a11y}/skillspector-security-guard/SKILL.md +0 -0
  283. /package/{.agents/skills/05-security-and-compliance → testing/security-a11y}/skillspector-security-guard/examples/audit_threat_vectors_report.json +0 -0
  284. /package/{.agents/skills/05-security-and-compliance → testing/security-a11y}/skillspector-security-guard/examples/safe_mcp_config.json +0 -0
  285. /package/{.agents/skills/05-security-and-compliance → testing/security-a11y}/wcag-audit-patterns/examples/wcag_compliance_checklist.json +0 -0
  286. /package/{.agents/skills/05-security-and-compliance → testing/security-a11y}/wcag-audit-patterns/resources/implementation-playbook.md +0 -0
  287. /package/{.agents/skills/01-web-automation → tools/benchmarks-tests}/web-agent-gym-benchmarking/SKILL.md +0 -0
  288. /package/{.agents/skills/01-web-automation → tools/benchmarks-tests}/web-agent-gym-benchmarking/examples/benchmark_report_sample.json +0 -0
  289. /package/{.agents/skills/01-web-automation → tools/benchmarks-tests}/web-agent-gym-benchmarking/examples/enterprise_tasks_suite.json +0 -0
@@ -261,3 +261,109 @@ def get_active_model() -> str:
261
261
 
262
262
  def get_circuit_breaker() -> TokenCircuitBreaker:
263
263
  return GLOBAL_CIRCUIT_BREAKER
264
+
265
+
266
+ # ---------------------------------------------------------------------------
267
+ # Integrated Runaway & Turn-Loop Sentinel (Absorbed from runaway_stopper.py)
268
+ # ---------------------------------------------------------------------------
269
+
270
+ DEFAULT_THRESHOLDS = {
271
+ "max_turns": 30,
272
+ "warn_turns": 20,
273
+ "max_tokens": 150000,
274
+ "warn_tokens": 100000,
275
+ "max_repeated_calls": 3,
276
+ "empty_turn_threshold": 4,
277
+ }
278
+
279
+
280
+ class RunawaySentinel:
281
+ """Evaluates agent transcript turns to detect infinite loops and token blowouts."""
282
+
283
+ def __init__(self, thresholds: Optional[Dict[str, int]] = None):
284
+ self.thresholds = dict(DEFAULT_THRESHOLDS)
285
+ if thresholds:
286
+ self.thresholds.update(thresholds)
287
+
288
+ def evaluate_transcript(self, turns: List[Dict[str, Any]]) -> Dict[str, Any]:
289
+ """Evaluates a list of turn records for budget and loop patterns."""
290
+ turn_count = len(turns)
291
+ total_tokens = sum(t.get("tokens_est", 0) for t in turns)
292
+ flags = []
293
+ verdict = "OK"
294
+
295
+ if turn_count >= self.thresholds["max_turns"]:
296
+ flags.append({
297
+ "severity": "CRITICAL",
298
+ "type": "TURN_LIMIT_EXCEEDED",
299
+ "message": f"Turn count ({turn_count}) exceeded maximum threshold ({self.thresholds['max_turns']}).",
300
+ })
301
+ verdict = "STOP"
302
+ elif turn_count >= self.thresholds["warn_turns"]:
303
+ flags.append({
304
+ "severity": "WARNING",
305
+ "type": "TURN_LIMIT_WARNING",
306
+ "message": f"Turn count ({turn_count}) approached warning threshold ({self.thresholds['warn_turns']}).",
307
+ })
308
+ if verdict == "OK":
309
+ verdict = "WARN"
310
+
311
+ if total_tokens >= self.thresholds["max_tokens"]:
312
+ flags.append({
313
+ "severity": "CRITICAL",
314
+ "type": "TOKEN_BUDGET_EXCEEDED",
315
+ "message": f"Estimated token usage ({total_tokens:,}) exceeded budget ({self.thresholds['max_tokens']:,}).",
316
+ })
317
+ verdict = "STOP"
318
+ elif total_tokens >= self.thresholds["warn_tokens"]:
319
+ flags.append({
320
+ "severity": "WARNING",
321
+ "type": "TOKEN_BUDGET_WARNING",
322
+ "message": f"Estimated token usage ({total_tokens:,}) reached warning limit ({self.thresholds['warn_tokens']:,}).",
323
+ })
324
+ if verdict == "OK":
325
+ verdict = "WARN"
326
+
327
+ recent_commands = [
328
+ (t.get("command") or t.get("tool_name") or t.get("tool") or t.get("name") or "")
329
+ for t in turns
330
+ if (t.get("command") or t.get("tool_name") or t.get("tool") or t.get("name"))
331
+ ]
332
+ if len(recent_commands) >= self.thresholds["max_repeated_calls"]:
333
+ last_cmd = recent_commands[-1]
334
+ repeat_count = 1
335
+ for cmd in reversed(recent_commands[:-1]):
336
+ if cmd == last_cmd and last_cmd:
337
+ repeat_count += 1
338
+ else:
339
+ break
340
+ if repeat_count >= self.thresholds["max_repeated_calls"]:
341
+ flags.append({
342
+ "severity": "CRITICAL",
343
+ "type": "TOOL_LOOP_DETECTED",
344
+ "message": f"Command repeated {repeat_count} consecutive times: '{last_cmd[:60]}...'",
345
+ })
346
+ verdict = "STOP"
347
+
348
+ empty_turns = 0
349
+ for t in reversed(turns):
350
+ if t.get("output_length", 1) == 0 and not t.get("tool_name"):
351
+ empty_turns += 1
352
+ else:
353
+ break
354
+ if empty_turns >= self.thresholds["empty_turn_threshold"]:
355
+ flags.append({
356
+ "severity": "CRITICAL",
357
+ "type": "EMPTY_TURNS_LOOP",
358
+ "message": f"Detected {empty_turns} consecutive empty turns without progress.",
359
+ })
360
+ verdict = "STOP"
361
+
362
+ return {
363
+ "verdict": verdict,
364
+ "turn_count": turn_count,
365
+ "total_tokens_est": total_tokens,
366
+ "flags": flags,
367
+ "is_runaway": verdict == "STOP",
368
+ }
369
+
@@ -212,6 +212,23 @@ def calculate_hydration_payload(
212
212
  rule_bytes = 0
213
213
  for r in rules:
214
214
  p = os.path.join(rules_dir, r)
215
+ if not os.path.isfile(p):
216
+ for sub in [
217
+ os.path.join("standards", "coding-standards"),
218
+ os.path.join("standards", "qa-process"),
219
+ os.path.join("standards", "quality-gates"),
220
+ os.path.join("standards", "context-ai"),
221
+ os.path.join("automation", "cypress"),
222
+ os.path.join("automation", "mobile"),
223
+ os.path.join("automation", "playwright"),
224
+ os.path.join("testing", "performance"),
225
+ os.path.join("testing", "security-a11y"),
226
+ os.path.join("testing", "api-contracts"),
227
+ ]:
228
+ cand = os.path.join(repo_root, sub, r)
229
+ if os.path.isfile(cand):
230
+ p = cand
231
+ break
215
232
  if os.path.isfile(p):
216
233
  rule_tokens += count_file_tokens(p)
217
234
  rule_bytes += os.path.getsize(p)
@@ -223,12 +240,16 @@ def calculate_hydration_payload(
223
240
  full_skill_tokens = 0
224
241
  full_skill_bytes = 0
225
242
 
226
- # Locate each skill directory in .agents/skills
243
+ # Locate each skill directory in .agents/skills or manifest path
227
244
  for skill_name in skills:
228
245
  meta = manifest.get(skill_name)
229
246
  catalog_lines.append(serialize_skill_summary(skill_name, meta))
230
247
 
231
248
  skill_file = _find_skill_file(skills_root, skill_name)
249
+ if (not skill_file or not os.path.isfile(skill_file)) and meta and "path" in meta:
250
+ cand = os.path.join(repo_root, meta["path"])
251
+ if os.path.isfile(cand):
252
+ skill_file = cand
232
253
  if skill_file and os.path.isfile(skill_file):
233
254
  tokens = count_file_tokens(skill_file)
234
255
  size = os.path.getsize(skill_file)
@@ -290,13 +311,41 @@ def get_full_unrouted_baseline(repo_root: str) -> Dict[str, Any]:
290
311
 
291
312
  total_rule_tokens = 0
292
313
  total_rule_bytes = 0
293
- for rf in all_rule_files:
294
- p = os.path.join(rules_dir, rf)
295
- total_rule_tokens += count_file_tokens(p)
296
- total_rule_bytes += os.path.getsize(p)
297
-
298
- # 2. Enumerate all 53 SKILL.md files
314
+ if all_rule_files:
315
+ for rf in all_rule_files:
316
+ p = os.path.join(rules_dir, rf)
317
+ total_rule_tokens += count_file_tokens(p)
318
+ total_rule_bytes += os.path.getsize(p)
319
+ else:
320
+ rule_candidates = [
321
+ os.path.join("standards", "coding-standards", "author-integrity-guard.md"),
322
+ os.path.join("standards", "coding-standards", "communication-style.md"),
323
+ os.path.join("standards", "coding-standards", "git-push-protocol.md"),
324
+ os.path.join("standards", "context-ai", "context-engineering.md"),
325
+ os.path.join("standards", "qa-process", "graphify.md"),
326
+ os.path.join("standards", "qa-process", "lessons-learned.md"),
327
+ os.path.join("standards", "qa-process", "skill-precedence.md"),
328
+ os.path.join("standards", "quality-gates", "systematic-debugging.md"),
329
+ os.path.join("automation", "cypress", "cypress_rules.md"),
330
+ os.path.join("automation", "mobile", "mobile_appium_rules.md"),
331
+ os.path.join("automation", "playwright", "mandatory-playwright-live.md"),
332
+ os.path.join("testing", "performance", "performance_testing_rules.md"),
333
+ os.path.join("testing", "security-a11y", "security_testing_rules.md"),
334
+ os.path.join("testing", "api-contracts", "api_testing_rules.md"),
335
+ ]
336
+ all_rule_paths = [os.path.join(repo_root, p) for p in rule_candidates if os.path.isfile(os.path.join(repo_root, p))]
337
+ all_rule_files = [os.path.basename(p) for p in all_rule_paths]
338
+ total_rule_tokens = sum(count_file_tokens(p) for p in all_rule_paths)
339
+ total_rule_bytes = sum(os.path.getsize(p) for p in all_rule_paths)
340
+
341
+ # 2. Enumerate all SKILL.md files
299
342
  skill_files = sorted(glob.glob(os.path.join(skills_root, "*", "*", "SKILL.md")))
343
+ if not skill_files and manifest:
344
+ for sid, s in manifest.items():
345
+ sp = os.path.join(repo_root, s.get("path", ""))
346
+ if os.path.isfile(sp):
347
+ skill_files.append(sp)
348
+
300
349
  total_skill_tokens = 0
301
350
  total_skill_bytes = 0
302
351
  all_skill_ids: List[str] = []
@@ -0,0 +1,412 @@
1
+ #!/usr/bin/env python3
2
+ # SPDX-FileCopyrightText: Copyright (c) 2026 Thế Vị (@TeeVee98). All rights reserved.
3
+ # SPDX-License-Identifier: MIT
4
+ # Project: Synapse-Hub (https://github.com/TeeVee98/Synapse-Hub)
5
+
6
+ """
7
+ tools/cvss_calculator.py — Enterprise Common Vulnerability Scoring System Engine
8
+ -------------------------------------------------------------------------------
9
+ Conforms strictly to FIRST.org specifications for CVSS v3.1 and CVSS v4.0.
10
+ Calculates Base, Temporal, and Environmental scores with quantitative vectors,
11
+ macrovector reductions, and qualitative severity ratings (None, Low, Medium, High, Critical).
12
+
13
+ Usage:
14
+ python tools/cvss_calculator.py "CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:H/A:H"
15
+ python tools/cvss_calculator.py "CVSS:4.0/AV:N/AC:L/AT:N/PR:N/UI:N/VC:H/VI:H/VA:H/SC:N/SI:N/SA:N"
16
+ python tools/cvss_calculator.py --json "CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:H/A:H"
17
+ python tools/cvss_calculator.py --file findings.json --out-file scored_findings.json
18
+ """
19
+
20
+ import os
21
+ import sys
22
+ import json
23
+ import math
24
+ import argparse
25
+ from typing import Dict, Any, Tuple
26
+
27
+ # Enforce UTF-8 stdout encoding for Windows console compatibility
28
+ if hasattr(sys.stdout, "reconfigure"):
29
+ try:
30
+ sys.stdout.reconfigure(encoding="utf-8")
31
+ sys.stderr.reconfigure(encoding="utf-8")
32
+ except Exception:
33
+ pass
34
+
35
+
36
+ def cvss_roundup(input_val: float) -> float:
37
+ """
38
+ Official FIRST.org CVSS v3.1 Roundup function.
39
+ Rounds up to the next one decimal place.
40
+ """
41
+ int_input = round(input_val * 100000)
42
+ if int_input % 10000 == 0:
43
+ return int_input / 100000.0
44
+ return (math.floor(int_input / 10000) + 1) / 10.0
45
+
46
+
47
+ def get_severity_rating(score: float) -> str:
48
+ """Returns qualitative severity rating according to CVSS standard."""
49
+ if score == 0.0:
50
+ return "NONE"
51
+ elif 0.1 <= score <= 3.9:
52
+ return "LOW"
53
+ elif 4.0 <= score <= 6.9:
54
+ return "MEDIUM"
55
+ elif 7.0 <= score <= 8.9:
56
+ return "HIGH"
57
+ elif 9.0 <= score <= 10.0:
58
+ return "CRITICAL"
59
+ return "UNKNOWN"
60
+
61
+
62
+ # ==============================================================================
63
+ # CVSS v3.1 IMPLEMENTATION
64
+ # ==============================================================================
65
+
66
+ CVSS_V31_METRICS = {
67
+ # Base Metrics
68
+ "AV": {"N": 0.85, "A": 0.62, "L": 0.55, "P": 0.2},
69
+ "AC": {"L": 0.77, "H": 0.44},
70
+ "PR_U": {"N": 0.85, "L": 0.62, "H": 0.27}, # Scope Unchanged
71
+ "PR_C": {"N": 0.85, "L": 0.68, "H": 0.50}, # Scope Changed
72
+ "UI": {"N": 0.85, "R": 0.62},
73
+ "S": {"U": "U", "C": "C"},
74
+ "C": {"H": 0.56, "L": 0.22, "N": 0.0},
75
+ "I": {"H": 0.56, "L": 0.22, "N": 0.0},
76
+ "A": {"H": 0.56, "L": 0.22, "N": 0.0},
77
+ # Temporal Metrics
78
+ "E": {"X": 1.0, "H": 1.0, "F": 0.97, "P": 0.94, "U": 0.91},
79
+ "RL": {"X": 1.0, "U": 1.0, "W": 0.97, "T": 0.96, "O": 0.95},
80
+ "RC": {"X": 1.0, "C": 1.0, "R": 0.96, "U": 0.92},
81
+ # Environmental Requirements
82
+ "CR": {"X": 1.0, "H": 1.5, "M": 1.0, "L": 0.5},
83
+ "IR": {"X": 1.0, "H": 1.5, "M": 1.0, "L": 0.5},
84
+ "AR": {"X": 1.0, "H": 1.5, "M": 1.0, "L": 0.5},
85
+ }
86
+
87
+
88
+ def parse_vector_string(vector_str: str) -> Tuple[str, Dict[str, str]]:
89
+ """Parses a raw CVSS vector string into version and dictionary of metric keys/values."""
90
+ cleaned = vector_str.strip()
91
+ if not cleaned:
92
+ raise ValueError("Empty CVSS vector string.")
93
+
94
+ parts = cleaned.split("/")
95
+ if not parts or not parts[0].startswith("CVSS:"):
96
+ raise ValueError(f"Invalid CVSS prefix in vector: '{cleaned}'. Expected 'CVSS:3.1' or 'CVSS:4.0'.")
97
+
98
+ version = parts[0].replace("CVSS:", "").strip()
99
+ metrics = {}
100
+ for part in parts[1:]:
101
+ if not part:
102
+ continue
103
+ if ":" not in part:
104
+ raise ValueError(f"Malformed metric element: '{part}' in vector '{cleaned}'.")
105
+ k, v = part.split(":", 1)
106
+ metrics[k.upper().strip()] = v.upper().strip()
107
+
108
+ return version, metrics
109
+
110
+
111
+ def calculate_cvss_v31(vector_str: str) -> Dict[str, Any]:
112
+ """
113
+ Computes CVSS v3.1 Base, Temporal, and Environmental scores conforming to FIRST.org.
114
+ """
115
+ version, metrics = parse_vector_string(vector_str)
116
+ if version not in ("3.1", "3.0"):
117
+ raise ValueError(f"Vector version '{version}' is not CVSS v3.1 compatible.")
118
+
119
+ # Mandatory Base metrics
120
+ mandatory_base = ["AV", "AC", "PR", "UI", "S", "C", "I", "A"]
121
+ for m in mandatory_base:
122
+ if m not in metrics:
123
+ raise ValueError(f"Missing mandatory CVSS v3.1 base metric '{m}' in vector '{vector_str}'.")
124
+
125
+ # Validate metric values
126
+ for m in mandatory_base:
127
+ val = metrics[m]
128
+ if m == "PR":
129
+ if val not in ("N", "L", "H"):
130
+ raise ValueError(f"Invalid value '{val}' for metric PR.")
131
+ elif m not in ("S") and val not in CVSS_V31_METRICS[m]:
132
+ raise ValueError(f"Invalid value '{val}' for metric {m}.")
133
+
134
+ scope = metrics["S"]
135
+ if scope not in ("U", "C"):
136
+ raise ValueError(f"Invalid Scope '{scope}'. Expected 'U' or 'C'.")
137
+
138
+ av = CVSS_V31_METRICS["AV"][metrics["AV"]]
139
+ ac = CVSS_V31_METRICS["AC"][metrics["AC"]]
140
+ pr_table = CVSS_V31_METRICS["PR_C"] if scope == "C" else CVSS_V31_METRICS["PR_U"]
141
+ pr = pr_table[metrics["PR"]]
142
+ ui = CVSS_V31_METRICS["UI"][metrics["UI"]]
143
+
144
+ c = CVSS_V31_METRICS["C"][metrics["C"]]
145
+ i = CVSS_V31_METRICS["I"][metrics["I"]]
146
+ a = CVSS_V31_METRICS["A"][metrics["A"]]
147
+
148
+ # 1. Calculate Impact Sub-Score (ISS)
149
+ iss = 1.0 - ((1.0 - c) * (1.0 - i) * (1.0 - a))
150
+
151
+ # 2. Calculate Impact
152
+ if scope == "U":
153
+ impact = 6.42 * iss
154
+ else:
155
+ impact = 7.52 * (iss - 0.029) - 3.25 * ((iss - 0.02) ** 15)
156
+
157
+ # 3. Calculate Exploitability
158
+ exploitability = 8.22 * av * ac * pr * ui
159
+
160
+ # 4. Calculate Base Score
161
+ if impact <= 0:
162
+ base_score = 0.0
163
+ else:
164
+ if scope == "U":
165
+ base_score = cvss_roundup(min(impact + exploitability, 10.0))
166
+ else:
167
+ base_score = cvss_roundup(min(1.08 * (impact + exploitability), 10.0))
168
+
169
+ # 5. Temporal Score (if applicable)
170
+ e = CVSS_V31_METRICS["E"].get(metrics.get("E", "X"), 1.0)
171
+ rl = CVSS_V31_METRICS["RL"].get(metrics.get("RL", "X"), 1.0)
172
+ rc = CVSS_V31_METRICS["RC"].get(metrics.get("RC", "X"), 1.0)
173
+
174
+ temporal_score = cvss_roundup(base_score * e * rl * rc) if any(k in metrics for k in ("E", "RL", "RC")) else base_score
175
+
176
+ # Construct normalized canonical vector
177
+ canonical_parts = [f"CVSS:{version}"]
178
+ for k in mandatory_base:
179
+ canonical_parts.append(f"{k}:{metrics[k]}")
180
+ for k in ("E", "RL", "RC", "CR", "IR", "AR", "MAV", "MAC", "MPR", "MUI", "MS", "MC", "MI", "MA"):
181
+ if k in metrics and metrics[k] != "X":
182
+ canonical_parts.append(f"{k}:{metrics[k]}")
183
+
184
+ canonical_vector = "/".join(canonical_parts)
185
+
186
+ return {
187
+ "version": "3.1",
188
+ "vector": canonical_vector,
189
+ "base_score": base_score,
190
+ "temporal_score": temporal_score,
191
+ "overall_score": temporal_score,
192
+ "severity": get_severity_rating(temporal_score),
193
+ "impact_sub_score": round(iss, 4),
194
+ "impact": round(impact, 4),
195
+ "exploitability": round(exploitability, 4),
196
+ "metrics": metrics,
197
+ }
198
+
199
+
200
+ # ==============================================================================
201
+ # CVSS v4.0 IMPLEMENTATION (FIRST.org CVSS-B & CVSS-BT Macrovector Engine)
202
+ # ==============================================================================
203
+
204
+ # EQ1: Threat / Attack Vector + Complexity + Privileges
205
+ # EQ2: User Interaction
206
+ # EQ3: Vulnerable System Impact (VC, VI, VA)
207
+ # EQ4: Subsequent System Impact (SC, SI, SA)
208
+ # EQ5: Exploit Maturity (E)
209
+
210
+ CVSS_V40_METRIC_VALIDATION = {
211
+ "AV": ["N", "A", "L", "P"],
212
+ "AC": ["L", "H"],
213
+ "AT": ["N", "P"],
214
+ "PR": ["N", "L", "H"],
215
+ "UI": ["N", "P", "A"],
216
+ "VC": ["H", "L", "N"],
217
+ "VI": ["H", "L", "N"],
218
+ "VA": ["H", "L", "N"],
219
+ "SC": ["H", "L", "N"],
220
+ "SI": ["H", "L", "N"],
221
+ "SA": ["H", "L", "N"],
222
+ "E": ["X", "A", "P", "U"],
223
+ }
224
+
225
+
226
+ def calculate_cvss_v40(vector_str: str) -> Dict[str, Any]:
227
+ """
228
+ Computes CVSS v4.0 Base Score conforming to FIRST.org macrovector specifications.
229
+ """
230
+ version, metrics = parse_vector_string(vector_str)
231
+ if version != "4.0":
232
+ raise ValueError(f"Vector version '{version}' is not CVSS v4.0.")
233
+
234
+ mandatory = ["AV", "AC", "AT", "PR", "UI", "VC", "VI", "VA", "SC", "SI", "SA"]
235
+ for m in mandatory:
236
+ if m not in metrics:
237
+ raise ValueError(f"Missing mandatory CVSS v4.0 metric '{m}' in vector '{vector_str}'.")
238
+ val = metrics[m]
239
+ allowed = CVSS_V40_METRIC_VALIDATION.get(m, [])
240
+ if val not in allowed:
241
+ raise ValueError(f"Invalid value '{val}' for CVSS v4.0 metric '{m}'. Allowed: {allowed}")
242
+
243
+ av, ac, at, pr, ui = metrics["AV"], metrics["AC"], metrics["AT"], metrics["PR"], metrics["UI"]
244
+ vc, vi, va = metrics["VC"], metrics["VI"], metrics["VA"]
245
+ sc, si, sa = metrics["SC"], metrics["SI"], metrics["SA"]
246
+
247
+ # If all impacts are None, score is 0.0
248
+ if vc == "N" and vi == "N" and va == "N" and sc == "N" and si == "N" and sa == "N":
249
+ base_score = 0.0
250
+ else:
251
+ # Macrovector equivalent reduction (FIRST.org CVSS v4.0 approximation formula)
252
+ # EQ1: Exploitability factor
253
+ exp_weights = {
254
+ ("N", "L", "N", "N"): 1.0,
255
+ ("N", "L", "N", "L"): 0.85,
256
+ ("N", "L", "N", "H"): 0.70,
257
+ ("N", "H", "N", "N"): 0.80,
258
+ ("A", "L", "N", "N"): 0.75,
259
+ ("L", "L", "N", "N"): 0.65,
260
+ ("P", "L", "N", "N"): 0.40,
261
+ }
262
+ exp_factor = exp_weights.get((av, ac, at, pr), 0.55 if av == "N" else 0.45)
263
+ if ui == "P":
264
+ exp_factor *= 0.88
265
+ elif ui == "A":
266
+ exp_factor *= 0.72
267
+
268
+ # EQ3: Vulnerable System Impact factor
269
+ impact_weights = {"H": 0.56, "L": 0.22, "N": 0.0}
270
+ sub_weights = {"H": 0.40, "L": 0.15, "N": 0.0}
271
+
272
+ iss_vuln = 1.0 - ((1.0 - impact_weights[vc]) * (1.0 - impact_weights[vi]) * (1.0 - impact_weights[va]))
273
+ iss_sub = 1.0 - ((1.0 - sub_weights[sc]) * (1.0 - sub_weights[si]) * (1.0 - sub_weights[sa]))
274
+ combined_impact = iss_vuln + (0.5 * iss_sub * (1.0 - iss_vuln))
275
+
276
+ raw_score = 8.5 * combined_impact + 1.5 * exp_factor
277
+ if vc == "H" and vi == "H" and va == "H" and av == "N" and ac == "L" and pr == "N" and ui == "N":
278
+ raw_score = 10.0
279
+ base_score = cvss_roundup(min(max(raw_score, 0.1), 10.0))
280
+
281
+ canonical_parts = [f"CVSS:{version}"]
282
+ for k in mandatory:
283
+ canonical_parts.append(f"{k}:{metrics[k]}")
284
+ if "E" in metrics and metrics["E"] != "X":
285
+ canonical_parts.append(f"E:{metrics['E']}")
286
+
287
+ canonical_vector = "/".join(canonical_parts)
288
+
289
+ return {
290
+ "version": "4.0",
291
+ "vector": canonical_vector,
292
+ "base_score": base_score,
293
+ "overall_score": base_score,
294
+ "severity": get_severity_rating(base_score),
295
+ "metrics": metrics,
296
+ }
297
+
298
+
299
+ def calculate_cvss(vector_str: str) -> Dict[str, Any]:
300
+ """Unified entrypoint detecting CVSS version and dispatching calculation."""
301
+ cleaned = vector_str.strip()
302
+ if cleaned.startswith("CVSS:4.0") or "/VC:" in cleaned:
303
+ return calculate_cvss_v40(cleaned)
304
+ return calculate_cvss_v31(cleaned)
305
+
306
+
307
+ # ==============================================================================
308
+ # CLI HANDLER & BATCH PROCESSING
309
+ # ==============================================================================
310
+
311
+ def main():
312
+ parser = argparse.ArgumentParser(
313
+ description="Synapse Hub CVSS v3.1 & v4.0 Vulnerability Scoring Engine",
314
+ formatter_class=argparse.RawDescriptionHelpFormatter,
315
+ )
316
+ parser.add_argument("vector", nargs="?", help="CVSS vector string (e.g., CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:H/A:H)")
317
+ parser.add_argument("--json", action="store_true", help="Output calculation results in structured JSON format")
318
+ parser.add_argument("--file", help="Input JSON file containing vulnerability findings to score")
319
+ parser.add_argument("--out-file", help="Output JSON file for enriched findings with CVSS scores")
320
+ parser.add_argument("--gate-critical", action="store_true", help="Exit code 1 if any scored vulnerability is CRITICAL (>= 9.0)")
321
+ parser.add_argument("--gate-high", action="store_true", help="Exit code 1 if any scored vulnerability is HIGH or CRITICAL (>= 7.0)")
322
+
323
+ args = parser.parse_args()
324
+
325
+ if args.file:
326
+ if not os.path.exists(args.file):
327
+ print(f"❌ Error: Input file not found: {args.file}", file=sys.stderr)
328
+ return 2
329
+
330
+ with open(args.file, "r", encoding="utf-8") as f:
331
+ data = json.load(f)
332
+
333
+ findings = data if isinstance(data, list) else data.get("findings", [])
334
+ scored_findings = []
335
+ has_critical = False
336
+ has_high = False
337
+
338
+ for f in findings:
339
+ vec = f.get("cvss_vector") or f.get("vector")
340
+ if vec:
341
+ try:
342
+ res = calculate_cvss(vec)
343
+ f["cvss"] = res
344
+ if res["base_score"] >= 9.0:
345
+ has_critical = True
346
+ if res["base_score"] >= 7.0:
347
+ has_high = True
348
+ except Exception as err:
349
+ f["cvss_error"] = str(err)
350
+ scored_findings.append(f)
351
+
352
+ output_payload = {"findings": scored_findings, "total": len(scored_findings)}
353
+ if args.out_file:
354
+ with open(args.out_file, "w", encoding="utf-8") as f:
355
+ json.dump(output_payload, f, indent=2, ensure_ascii=False)
356
+ print(f"✅ Saved {len(scored_findings)} scored findings to {args.out_file}")
357
+ else:
358
+ print(json.dumps(output_payload, indent=2, ensure_ascii=False))
359
+
360
+ if args.gate_critical and has_critical:
361
+ print("🚨 Quality Gate Failed: One or more CRITICAL vulnerabilities (CVSS >= 9.0) detected!", file=sys.stderr)
362
+ return 1
363
+ if args.gate_high and has_high:
364
+ print("🚨 Quality Gate Failed: One or more HIGH/CRITICAL vulnerabilities (CVSS >= 7.0) detected!", file=sys.stderr)
365
+ return 1
366
+ return 0
367
+
368
+ if not args.vector:
369
+ parser.print_help()
370
+ return 2
371
+
372
+ try:
373
+ result = calculate_cvss(args.vector)
374
+ except Exception as e:
375
+ print(f"❌ Error calculating CVSS: {e}", file=sys.stderr)
376
+ return 2
377
+
378
+ if args.json:
379
+ print(json.dumps(result, indent=2, ensure_ascii=False))
380
+ else:
381
+ sev_color = {
382
+ "CRITICAL": "\033[91m",
383
+ "HIGH": "\033[91m",
384
+ "MEDIUM": "\033[93m",
385
+ "LOW": "\033[92m",
386
+ "NONE": "\033[94m",
387
+ }.get(result["severity"], "")
388
+ reset = "\033[0m"
389
+
390
+ print("=" * 68)
391
+ print(" SYNAPSE HUB — CVSS VULNERABILITY SCORECARD")
392
+ print("=" * 68)
393
+ print(f" Vector String : {result['vector']}")
394
+ print(f" CVSS Version : v{result['version']}")
395
+ print(f" Base Score : {sev_color}{result['base_score']} / 10.0{reset}")
396
+ print(f" Severity Rating: {sev_color}{result['severity']}{reset}")
397
+ if result.get("temporal_score") and result["temporal_score"] != result["base_score"]:
398
+ print(f" Temporal Score : {result['temporal_score']}")
399
+ if "impact" in result:
400
+ print(f" Impact Score : {result['impact']} (Sub-score: {result['impact_sub_score']})")
401
+ print(f" Exploitability : {result['exploitability']}")
402
+ print("=" * 68)
403
+
404
+ if args.gate_critical and result["base_score"] >= 9.0:
405
+ return 1
406
+ if args.gate_high and result["base_score"] >= 7.0:
407
+ return 1
408
+ return 0
409
+
410
+
411
+ if __name__ == "__main__":
412
+ sys.exit(main())