@teevee98/synapse-hub 3.10.0 → 4.1.0

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 (199) hide show
  1. package/.agents/rules/context-engineering.md +3 -3
  2. package/.agents/rules/mandatory-playwright-live.md +18 -4
  3. package/.agents/rules/security_testing_rules.md +8 -5
  4. package/.agents/rules/stack-auto-router.md +11 -4
  5. package/.agents/skills/{playwright-webapp-testing → 01-web-automation/playwright-webapp-testing}/SKILL.md +18 -1
  6. package/.agents/skills/05-security-and-compliance/wcag-audit-patterns/SKILL.md +116 -0
  7. package/.agents/workflows/generate_manual_testcases_rbt.md +1 -1
  8. package/Dockerfile +14 -6
  9. package/README.en.md +2 -2
  10. package/README.md +2 -2
  11. package/agentskills.json +16 -2
  12. package/docs/ARCHITECTURE.en.md +1 -1
  13. package/docs/ARCHITECTURE.md +1 -1
  14. package/package.json +1 -1
  15. package/plugin.json +1 -1
  16. package/skills_manifest.json +505 -394
  17. package/synapse.config.json +17 -1
  18. package/tools/__init__.py +1 -1
  19. package/tools/ast_cache.py +171 -0
  20. package/tools/author_integrity.py +7 -2
  21. package/tools/benchmark_swarm_context.py +242 -151
  22. package/tools/browser_helpers.js +2 -2
  23. package/tools/build_consolidated_report.py +6 -6
  24. package/tools/cache_resolver.py +11 -6
  25. package/tools/check_version_sync.py +56 -0
  26. package/tools/cli.py +16 -3
  27. package/tools/core/file_lock.py +187 -14
  28. package/tools/core/process_supervisor.py +25 -0
  29. package/tools/core/telemetry.py +139 -1
  30. package/tools/core/token_estimator.py +145 -0
  31. package/tools/count_tokens.py +28 -0
  32. package/tools/dashboard_generator.py +6 -6
  33. package/tools/debt_harvester.py +20 -9
  34. package/tools/diagram_architect.py +0 -1
  35. package/tools/distill_log.py +266 -89
  36. package/tools/git_pre_commit_guard.py +6 -4
  37. package/tools/git_worktree_manager.py +1 -1
  38. package/tools/infer_linter.py +2 -2
  39. package/tools/lint_ai_docs.py +19 -5
  40. package/tools/mcp_docx_server.py +1 -1
  41. package/tools/mcp_excel_server.py +1 -1
  42. package/tools/mcp_server.py +1 -1
  43. package/tools/mechanical_ui_gate.py +1 -1
  44. package/tools/micro_mutator.py +51 -10
  45. package/tools/pairwise_generator.py +0 -1
  46. package/tools/pentest_scope_guard.py +328 -0
  47. package/tools/perf/benchmark_perf_runner.py +226 -0
  48. package/tools/pinpoint_failure.py +14 -2
  49. package/tools/rules_router.py +596 -0
  50. package/tools/token_telemetry.py +224 -0
  51. package/tools/ui_server.py +1 -1
  52. package/tools/update_sentinel.py +3 -3
  53. package/tools/verify_all.py +67 -7
  54. package/tools/wcag_audit.py +1 -1
  55. package/tools/welcome_page.py +1 -1
  56. package/.agents/skills/wcag-audit-patterns/SKILL.md +0 -77
  57. /package/.agents/skills/{auth-session-and-cookie-manager → 01-web-automation/auth-session-and-cookie-manager}/SKILL.md +0 -0
  58. /package/.agents/skills/{auth-session-and-cookie-manager → 01-web-automation/auth-session-and-cookie-manager}/examples/multi_role_auth_matrix.md +0 -0
  59. /package/.agents/skills/{auth-session-and-cookie-manager → 01-web-automation/auth-session-and-cookie-manager}/examples/storage_state_sample.json +0 -0
  60. /package/.agents/skills/{bats-testing-patterns → 01-web-automation/bats-testing-patterns}/SKILL.md +0 -0
  61. /package/.agents/skills/{bats-testing-patterns → 01-web-automation/bats-testing-patterns}/examples/cli_runner_test.bats +0 -0
  62. /package/.agents/skills/{bats-testing-patterns → 01-web-automation/bats-testing-patterns}/resources/implementation-playbook.md +0 -0
  63. /package/.agents/skills/{clean-pom-crafter → 01-web-automation/clean-pom-crafter}/SKILL.md +0 -0
  64. /package/.agents/skills/{clean-pom-crafter → 01-web-automation/clean-pom-crafter}/examples/standard_test_case.groovy +0 -0
  65. /package/.agents/skills/{clean-pom-crafter → 01-web-automation/clean-pom-crafter}/references/pom_patterns.groovy +0 -0
  66. /package/.agents/skills/{e2e-testing-patterns → 01-web-automation/e2e-testing-patterns}/SKILL.md +0 -0
  67. /package/.agents/skills/{e2e-testing-patterns → 01-web-automation/e2e-testing-patterns}/examples/playwright_sharded_config.ts +0 -0
  68. /package/.agents/skills/{e2e-testing-patterns → 01-web-automation/e2e-testing-patterns}/resources/implementation-playbook.md +0 -0
  69. /package/.agents/skills/{katalon-cli-runner → 01-web-automation/katalon-cli-runner}/SKILL.md +0 -0
  70. /package/.agents/skills/{katalon-cli-runner → 01-web-automation/katalon-cli-runner}/examples/headless_kre_exec.sh +0 -0
  71. /package/.agents/skills/{katalon-cli-runner → 01-web-automation/katalon-cli-runner}/references/groovy-patterns.md +0 -0
  72. /package/.agents/skills/{katalon-cli-runner → 01-web-automation/katalon-cli-runner}/references/katalon-api.md +0 -0
  73. /package/.agents/skills/{katalon-cli-runner → 01-web-automation/katalon-cli-runner}/references/runner_commands.md +0 -0
  74. /package/.agents/skills/{lam-script-generator → 01-web-automation/lam-script-generator}/SKILL.md +0 -0
  75. /package/.agents/skills/{lam-script-generator → 01-web-automation/lam-script-generator}/examples/user_story_sample.md +0 -0
  76. /package/.agents/skills/{mobile-appium-som → 01-web-automation/mobile-appium-som}/SKILL.md +0 -0
  77. /package/.agents/skills/{mobile-appium-som → 01-web-automation/mobile-appium-som}/examples/BaseScreen.java +0 -0
  78. /package/.agents/skills/{mobile-appium-som → 01-web-automation/mobile-appium-som}/examples/LoginScreen.java +0 -0
  79. /package/.agents/skills/{mobile-appium-som → 01-web-automation/mobile-appium-som}/examples/TC_MobileLogin.java +0 -0
  80. /package/.agents/skills/{playwright-live-interaction → 01-web-automation/playwright-live-interaction}/SKILL.md +0 -0
  81. /package/.agents/skills/{playwright-live-interaction → 01-web-automation/playwright-live-interaction}/examples/live_probe_script.js +0 -0
  82. /package/.agents/skills/{playwright-live-interaction → 01-web-automation/playwright-live-interaction}/references/advanced_superpowers.md +0 -0
  83. /package/.agents/skills/{playwright-live-interaction → 01-web-automation/playwright-live-interaction}/references/compact_accessibility_snapshots.md +0 -0
  84. /package/.agents/skills/{playwright-live-interaction → 01-web-automation/playwright-live-interaction}/references/recipes.md +0 -0
  85. /package/.agents/skills/{playwright-live-interaction → 01-web-automation/playwright-live-interaction}/references/swarm_orchestration.md +0 -0
  86. /package/.agents/skills/{playwright-webapp-testing → 01-web-automation/playwright-webapp-testing}/examples/server_lifecycle_playwright.py +0 -0
  87. /package/.agents/skills/{web-agent-gym-benchmarking → 01-web-automation/web-agent-gym-benchmarking}/SKILL.md +0 -0
  88. /package/.agents/skills/{web-agent-gym-benchmarking → 01-web-automation/web-agent-gym-benchmarking}/examples/benchmark_report_sample.json +0 -0
  89. /package/.agents/skills/{web-agent-gym-benchmarking → 01-web-automation/web-agent-gym-benchmarking}/examples/enterprise_tasks_suite.json +0 -0
  90. /package/.agents/skills/{architecture-decision-records → 02-test-design/architecture-decision-records}/SKILL.md +0 -0
  91. /package/.agents/skills/{architecture-decision-records → 02-test-design/architecture-decision-records}/examples/0001-record-architecture-decisions.md +0 -0
  92. /package/.agents/skills/{gherkin-to-suite → 02-test-design/gherkin-to-suite}/SKILL.md +0 -0
  93. /package/.agents/skills/{gherkin-to-suite → 02-test-design/gherkin-to-suite}/examples/checkout.feature +0 -0
  94. /package/.agents/skills/{gherkin-to-suite → 02-test-design/gherkin-to-suite}/examples/suite_report_sample.json +0 -0
  95. /package/.agents/skills/{rbt-manual-testing → 02-test-design/rbt-manual-testing}/SKILL.md +0 -0
  96. /package/.agents/skills/{rbt-manual-testing → 02-test-design/rbt-manual-testing}/examples/checkout_rbt_manual_suite.md +0 -0
  97. /package/.agents/skills/{rbt-manual-testing → 02-test-design/rbt-manual-testing}/references/field_validation_checklist.md +0 -0
  98. /package/.agents/skills/{review-spec → 02-test-design/review-spec}/SKILL.md +0 -0
  99. /package/.agents/skills/{review-spec → 02-test-design/review-spec}/examples/pocock_grilling_decision_rubric.md +0 -0
  100. /package/.agents/skills/{review-spec → 02-test-design/review-spec}/examples/sample_spec_review.md +0 -0
  101. /package/.agents/skills/{tot-exploratory-testing → 02-test-design/tot-exploratory-testing}/SKILL.md +0 -0
  102. /package/.agents/skills/{tot-exploratory-testing → 02-test-design/tot-exploratory-testing}/examples/payment_gateway_tot_tree.json +0 -0
  103. /package/.agents/skills/{tot-exploratory-testing → 02-test-design/tot-exploratory-testing}/examples/tot_graph_sample.json +0 -0
  104. /package/.agents/skills/{api-network-mocking-interception → 03-api-and-contracts/api-network-mocking-interception}/SKILL.md +0 -0
  105. /package/.agents/skills/{api-network-mocking-interception → 03-api-and-contracts/api-network-mocking-interception}/examples/network_route_stub.json +0 -0
  106. /package/.agents/skills/{api-spec-to-e2e-matrix → 03-api-and-contracts/api-spec-to-e2e-matrix}/SKILL.md +0 -0
  107. /package/.agents/skills/{api-spec-to-e2e-matrix → 03-api-and-contracts/api-spec-to-e2e-matrix}/examples/sample_openapi.json +0 -0
  108. /package/.agents/skills/{consumer-driven-contract-testing → 03-api-and-contracts/consumer-driven-contract-testing}/SKILL.md +0 -0
  109. /package/.agents/skills/{consumer-driven-contract-testing → 03-api-and-contracts/consumer-driven-contract-testing}/examples/order_service_pact.json +0 -0
  110. /package/.agents/skills/{backend-load-and-stress-patterns → 04-performance-and-load/backend-load-and-stress-patterns}/SKILL.md +0 -0
  111. /package/.agents/skills/{backend-load-and-stress-patterns → 04-performance-and-load/backend-load-and-stress-patterns}/examples/k6_load_test_sample.js +0 -0
  112. /package/.agents/skills/{backend-load-and-stress-patterns → 04-performance-and-load/backend-load-and-stress-patterns}/references/k6_load_template.js +0 -0
  113. /package/.agents/skills/{lean-impact-scoreboard → 04-performance-and-load/lean-impact-scoreboard}/SKILL.md +0 -0
  114. /package/.agents/skills/{lean-impact-scoreboard → 04-performance-and-load/lean-impact-scoreboard}/examples/sample_benchmark_gain.md +0 -0
  115. /package/.agents/skills/{lean-impact-scoreboard → 04-performance-and-load/lean-impact-scoreboard}/examples/sample_scoreboard.md +0 -0
  116. /package/.agents/skills/{web-vitals-and-performance-profiler → 04-performance-and-load/web-vitals-and-performance-profiler}/SKILL.md +0 -0
  117. /package/.agents/skills/{web-vitals-and-performance-profiler → 04-performance-and-load/web-vitals-and-performance-profiler}/examples/cwv_budget_policy.json +0 -0
  118. /package/.agents/skills/{web-vitals-and-performance-profiler → 04-performance-and-load/web-vitals-and-performance-profiler}/examples/playwright_cwv_profiler_fixture.ts +0 -0
  119. /package/.agents/skills/{security-dast-sentinel → 05-security-and-compliance/security-dast-sentinel}/SKILL.md +0 -0
  120. /package/.agents/skills/{security-dast-sentinel → 05-security-and-compliance/security-dast-sentinel}/examples/dast_scan_config.json +0 -0
  121. /package/.agents/skills/{security-dast-sentinel → 05-security-and-compliance/security-dast-sentinel}/references/AI-AND-LLM.md +0 -0
  122. /package/.agents/skills/{security-dast-sentinel → 05-security-and-compliance/security-dast-sentinel}/references/ATTACK-CLASSES.md +0 -0
  123. /package/.agents/skills/{security-dast-sentinel → 05-security-and-compliance/security-dast-sentinel}/references/dast_recipes.ts +0 -0
  124. /package/.agents/skills/{skillspector-security-guard → 05-security-and-compliance/skillspector-security-guard}/SKILL.md +0 -0
  125. /package/.agents/skills/{skillspector-security-guard → 05-security-and-compliance/skillspector-security-guard}/examples/audit_threat_vectors_report.json +0 -0
  126. /package/.agents/skills/{skillspector-security-guard → 05-security-and-compliance/skillspector-security-guard}/examples/safe_mcp_config.json +0 -0
  127. /package/.agents/skills/{wcag-audit-patterns → 05-security-and-compliance/wcag-audit-patterns}/examples/wcag_compliance_checklist.json +0 -0
  128. /package/.agents/skills/{wcag-audit-patterns → 05-security-and-compliance/wcag-audit-patterns}/resources/implementation-playbook.md +0 -0
  129. /package/.agents/skills/{agentless-qa-repair → 06-healing-and-resilience/agentless-qa-repair}/SKILL.md +0 -0
  130. /package/.agents/skills/{agentless-qa-repair → 06-healing-and-resilience/agentless-qa-repair}/examples/healing_report_sample.json +0 -0
  131. /package/.agents/skills/{agentless-qa-repair → 06-healing-and-resilience/agentless-qa-repair}/examples/three_phase_repair_workflow.md +0 -0
  132. /package/.agents/skills/{antigravity-test-sentinel → 06-healing-and-resilience/antigravity-test-sentinel}/SKILL.md +0 -0
  133. /package/.agents/skills/{antigravity-test-sentinel → 06-healing-and-resilience/antigravity-test-sentinel}/examples/dod_gate_policy.json +0 -0
  134. /package/.agents/skills/{antigravity-test-sentinel → 06-healing-and-resilience/antigravity-test-sentinel}/examples/sprint_dod_enforcement.md +0 -0
  135. /package/.agents/skills/{failure-autopsy-and-healing → 06-healing-and-resilience/failure-autopsy-and-healing}/SKILL.md +0 -0
  136. /package/.agents/skills/{failure-autopsy-and-healing → 06-healing-and-resilience/failure-autopsy-and-healing}/examples/closed_loop_healing_walkthrough.md +0 -0
  137. /package/.agents/skills/{failure-autopsy-and-healing → 06-healing-and-resilience/failure-autopsy-and-healing}/examples/sample_junit_failure.xml +0 -0
  138. /package/.agents/skills/{failure-autopsy-and-healing → 06-healing-and-resilience/failure-autopsy-and-healing}/references/healing_matrix.md +0 -0
  139. /package/.agents/skills/{failure-autopsy-and-healing → 06-healing-and-resilience/failure-autopsy-and-healing}/references/qa_investigation_protocol.md +0 -0
  140. /package/.agents/skills/{failure-autopsy-and-healing → 06-healing-and-resilience/failure-autopsy-and-healing}/scripts/triage_failures.sh +0 -0
  141. /package/.agents/skills/{flaky-test-sentinel-and-quarantine → 06-healing-and-resilience/flaky-test-sentinel-and-quarantine}/SKILL.md +0 -0
  142. /package/.agents/skills/{flaky-test-sentinel-and-quarantine → 06-healing-and-resilience/flaky-test-sentinel-and-quarantine}/examples/quarantine_registry.json +0 -0
  143. /package/.agents/skills/{self-healing-locator → 06-healing-and-resilience/self-healing-locator}/SKILL.md +0 -0
  144. /package/.agents/skills/{self-healing-locator → 06-healing-and-resilience/self-healing-locator}/examples/aom_diff_sample.json +0 -0
  145. /package/.agents/skills/{systematic-debugging → 06-healing-and-resilience/systematic-debugging}/SKILL.md +0 -0
  146. /package/.agents/skills/{systematic-debugging → 06-healing-and-resilience/systematic-debugging}/examples/four_phase_case.md +0 -0
  147. /package/.agents/skills/{test-driven-development → 06-healing-and-resilience/test-driven-development}/SKILL.md +0 -0
  148. /package/.agents/skills/{test-driven-development → 06-healing-and-resilience/test-driven-development}/examples/red_green_refactor_qa.md +0 -0
  149. /package/.agents/skills/{verification-before-completion → 06-healing-and-resilience/verification-before-completion}/SKILL.md +0 -0
  150. /package/.agents/skills/{verification-before-completion → 06-healing-and-resilience/verification-before-completion}/examples/evidence_log_example.md +0 -0
  151. /package/.agents/skills/{visual-regression-sentinel → 06-healing-and-resilience/visual-regression-sentinel}/SKILL.md +0 -0
  152. /package/.agents/skills/{visual-regression-sentinel → 06-healing-and-resilience/visual-regression-sentinel}/examples/visual_mask_rules.json +0 -0
  153. /package/.agents/skills/{db-state-verifier-and-seeder → 07-data-and-state/db-state-verifier-and-seeder}/SKILL.md +0 -0
  154. /package/.agents/skills/{db-state-verifier-and-seeder → 07-data-and-state/db-state-verifier-and-seeder}/examples/db_fixture_seed.json +0 -0
  155. /package/.agents/skills/{file-and-report-validator → 07-data-and-state/file-and-report-validator}/SKILL.md +0 -0
  156. /package/.agents/skills/{file-and-report-validator → 07-data-and-state/file-and-report-validator}/examples/sample_export_schema.json +0 -0
  157. /package/.agents/skills/{synthetic-test-data-generator → 07-data-and-state/synthetic-test-data-generator}/SKILL.md +0 -0
  158. /package/.agents/skills/{synthetic-test-data-generator → 07-data-and-state/synthetic-test-data-generator}/examples/idempotent_data_recipe.json +0 -0
  159. /package/.agents/skills/{code-refactoring-refactor-clean → 08-code-quality/code-refactoring-refactor-clean}/SKILL.md +0 -0
  160. /package/.agents/skills/{code-refactoring-refactor-clean → 08-code-quality/code-refactoring-refactor-clean}/examples/refactored_page_sample.groovy +0 -0
  161. /package/.agents/skills/{code-refactoring-refactor-clean → 08-code-quality/code-refactoring-refactor-clean}/examples/refactored_playwright_pom.ts +0 -0
  162. /package/.agents/skills/{code-refactoring-refactor-clean → 08-code-quality/code-refactoring-refactor-clean}/resources/implementation-playbook.md +0 -0
  163. /package/.agents/skills/{graphify-impact-analyzer → 08-code-quality/graphify-impact-analyzer}/SKILL.md +0 -0
  164. /package/.agents/skills/{graphify-impact-analyzer → 08-code-quality/graphify-impact-analyzer}/examples/dependency_blast_radius.json +0 -0
  165. /package/.agents/skills/{lean-code-ladder → 08-code-quality/lean-code-ladder}/SKILL.md +0 -0
  166. /package/.agents/skills/{lean-code-ladder → 08-code-quality/lean-code-ladder}/examples/ladder_walkthrough.md +0 -0
  167. /package/.agents/skills/{repo-quality-audit → 08-code-quality/repo-quality-audit}/SKILL.md +0 -0
  168. /package/.agents/skills/{repo-quality-audit → 08-code-quality/repo-quality-audit}/examples/sample_audit_walkthrough.md +0 -0
  169. /package/.agents/skills/{repo-quality-audit → 08-code-quality/repo-quality-audit}/examples/sample_repo_audit.md +0 -0
  170. /package/.agents/skills/{senior-code-review → 08-code-quality/senior-code-review}/SKILL.md +0 -0
  171. /package/.agents/skills/{senior-code-review → 08-code-quality/senior-code-review}/examples/sample_review_walkthrough.md +0 -0
  172. /package/.agents/skills/{surgical-coding-principles → 08-code-quality/surgical-coding-principles}/SKILL.md +0 -0
  173. /package/.agents/skills/{surgical-coding-principles → 08-code-quality/surgical-coding-principles}/examples/surgical_vs_scope_creep.md +0 -0
  174. /package/.agents/skills/{technical-debt-harvester → 08-code-quality/technical-debt-harvester}/SKILL.md +0 -0
  175. /package/.agents/skills/{technical-debt-harvester → 08-code-quality/technical-debt-harvester}/examples/sample_debt_ledger.md +0 -0
  176. /package/.agents/skills/{technical-debt-harvester → 08-code-quality/technical-debt-harvester}/examples/sample_ledger_output.md +0 -0
  177. /package/.agents/skills/{github-actions-templates → 09-ci-and-devops/github-actions-templates}/SKILL.md +0 -0
  178. /package/.agents/skills/{github-actions-templates → 09-ci-and-devops/github-actions-templates}/examples/matrix_test_pipeline.yml +0 -0
  179. /package/.agents/skills/{actor-qa-swarm → 10-agent-orchestration/actor-qa-swarm}/SKILL.md +0 -0
  180. /package/.agents/skills/{actor-qa-swarm → 10-agent-orchestration/actor-qa-swarm}/examples/broker_sharding_sample.json +0 -0
  181. /package/.agents/skills/{agent-orchestration-multi-agent-optimize → 10-agent-orchestration/agent-orchestration-multi-agent-optimize}/SKILL.md +0 -0
  182. /package/.agents/skills/{agent-orchestration-multi-agent-optimize → 10-agent-orchestration/agent-orchestration-multi-agent-optimize}/examples/swarm_workload_config.json +0 -0
  183. /package/.agents/skills/{event-stream-qa-orchestrator → 10-agent-orchestration/event-stream-qa-orchestrator}/SKILL.md +0 -0
  184. /package/.agents/skills/{event-stream-qa-orchestrator → 10-agent-orchestration/event-stream-qa-orchestrator}/examples/timeline_sample.jsonl +0 -0
  185. /package/.agents/skills/{persistent-planning-files → 10-agent-orchestration/persistent-planning-files}/SKILL.md +0 -0
  186. /package/.agents/skills/{persistent-planning-files → 10-agent-orchestration/persistent-planning-files}/examples/task_plan_example.md +0 -0
  187. /package/.agents/skills/{qa-memory-os → 10-agent-orchestration/qa-memory-os}/SKILL.md +0 -0
  188. /package/.agents/skills/{qa-memory-os → 10-agent-orchestration/qa-memory-os}/examples/archival_memory_sample.json +0 -0
  189. /package/.agents/skills/{meta-prompt-crafter → 11-ai-and-prompting/meta-prompt-crafter}/SKILL.md +0 -0
  190. /package/.agents/skills/{meta-prompt-crafter → 11-ai-and-prompting/meta-prompt-crafter}/examples/qa_prompt_template.md +0 -0
  191. /package/.agents/skills/{mipro-prompt-compiler → 11-ai-and-prompting/mipro-prompt-compiler}/SKILL.md +0 -0
  192. /package/.agents/skills/{mipro-prompt-compiler → 11-ai-and-prompting/mipro-prompt-compiler}/examples/compiled_module_sample.json +0 -0
  193. /package/.agents/skills/{mipro-prompt-compiler → 11-ai-and-prompting/mipro-prompt-compiler}/examples/dspy_assertion_optimizer_case.md +0 -0
  194. /package/.agents/skills/{qa-aci-interface → 11-ai-and-prompting/qa-aci-interface}/SKILL.md +0 -0
  195. /package/.agents/skills/{qa-aci-interface → 11-ai-and-prompting/qa-aci-interface}/examples/surgical_code_window_walkthrough.md +0 -0
  196. /package/.agents/skills/{qa-aci-interface → 11-ai-and-prompting/qa-aci-interface}/examples/surgical_edit_sample.json +0 -0
  197. /package/.agents/skills/{token-and-context-optimizer → 11-ai-and-prompting/token-and-context-optimizer}/SKILL.md +0 -0
  198. /package/.agents/skills/{token-and-context-optimizer → 11-ai-and-prompting/token-and-context-optimizer}/examples/distilled_log_sample.txt +0 -0
  199. /package/.agents/skills/{token-and-context-optimizer → 11-ai-and-prompting/token-and-context-optimizer}/references/context_engineering_guide.md +0 -0
@@ -4,28 +4,25 @@
4
4
  # Project: Synapse-Hub (https://github.com/TeeVee98/Synapse-Hub)
5
5
 
6
6
  """
7
- tools/benchmark_swarm_context.py — Empirical Context & Token Reduction Benchmark
7
+ tools/benchmark_swarm_context.py — Dual-Track Context & Token Reduction Benchmark
8
8
  --------------------------------------------------------------------------------
9
- Provides a deterministic, reproducible benchmark suite verifying the enterprise claim:
10
- "Reduces AI agent context token overhead by >= 40% across automated test lifecycles."
9
+ Provides a reproducible, dual-track benchmark verifying context engineering efficiency:
10
+ - Track 1 (Synthetic Micro-Workloads): Compares Naive DOM/Monolith vs Clean POM/AOM.
11
+ - Track 2 (Empirical Reference Suites): Real token & byte savings measured on actual
12
+ projects in examples/ (Playwright CRM, Pytest API, Katalon, Selenium).
11
13
 
12
- Compares two paradigms across 4 standard enterprise automation workloads:
13
- 1. Paradigm A (Baseline Naive LLM): Raw DOM/HTML dumps, repetitive auth flows, monolithic PageObjects.
14
- 2. Paradigm B (Synapse Hub Swarm): Compact AOM subtrees, Zero-Second Auth, Flat Clean POM, Pinpoint Triage.
15
-
16
- Usage:
17
- python tools/benchmark_swarm_context.py
18
- python tools/benchmark_swarm_context.py --verify-min-savings 40.0
19
- python tools/benchmark_swarm_context.py --json
14
+ Guarantees full scientific honesty: distinguishes synthetic estimates from real project metrics.
20
15
  """
21
16
 
22
- import os
23
- import sys
24
- import json
25
- import re
17
+ from __future__ import annotations
18
+
26
19
  import argparse
27
20
  from datetime import datetime, timezone
28
- from typing import Dict, List, Any, Optional
21
+ import json
22
+ import os
23
+ import re
24
+ import sys
25
+ from typing import Any, Dict, List, Optional
29
26
 
30
27
  # Enforce UTF-8 console output
31
28
  if hasattr(sys.stdout, "reconfigure"):
@@ -37,21 +34,27 @@ if hasattr(sys.stdout, "reconfigure"):
37
34
 
38
35
  REPO_ROOT = os.path.abspath(os.path.join(os.path.dirname(__file__), ".."))
39
36
 
37
+ # Import core token estimator
38
+ try:
39
+ from tools.core.token_estimator import count_tokens, calculate_hydration_payload
40
+ except ImportError:
41
+ try:
42
+ from core.token_estimator import count_tokens, calculate_hydration_payload
43
+ except ImportError:
44
+ def count_tokens(text: str, model_hint: str = "cl100k") -> int:
45
+ if not text:
46
+ return 0
47
+ words = len(re.findall(r"\w+|[^\w\s]", text, re.UNICODE))
48
+ char_estimate = len(text) / 3.85
49
+ return int(max(words, char_estimate))
50
+
40
51
 
41
52
  def estimate_tokens(text: str) -> int:
42
- """
43
- Calculates deterministic token estimate calibrated against standard BPE tokenizers
44
- (cl100k_base / Gemini / Claude token density: ~3.8 - 4.0 chars per token).
45
- """
46
- if not text:
47
- return 0
48
- # Words + punctuation tokens
49
- words = len(re.findall(r"\w+|[^\w\s]", text, re.UNICODE))
50
- char_estimate = len(text) / 3.85
51
- return int(max(words, char_estimate))
52
-
53
-
54
- # Benchmark Workloads
53
+ """Wrapper for backward compatibility."""
54
+ return count_tokens(text)
55
+
56
+
57
+ # Track 1: Standard Deterministic Micro-Workloads
55
58
  WORKLOAD_SCENARIOS = [
56
59
  {
57
60
  "id": "SCN-01-AUTH",
@@ -149,18 +152,14 @@ WORKLOAD_SCENARIOS = [
149
152
  <tr data-id="108"><td>108</td><td>Aurora Biotech</td><td><span class="badge badge-warning">Pending</span></td><td>Starter</td><td>$1,200</td><td><button class="btn btn-sm btn-edit" onclick="editRow(108)">Edit</button><button class="btn btn-sm btn-del">Delete</button></td></tr>
150
153
  </tbody>
151
154
  </table>
152
- <div class="pagination-wrapper"><ul class="pagination"><li class="page-item active"><a>1</a></li><li><a>2</a></li><li><a>Next</a></li></ul></div>
153
155
  """,
154
156
  "synapse_payload": """
155
- class CustomersPage extends BasePage {
156
- static rowByCustomer(name: string) {
157
- return page.locator("tr", { hasText: name });
158
- }
159
- static editButton(customerName: string) {
160
- return this.rowByCustomer(customerName).getByRole("button", { name: "Edit" });
161
- }
157
+ {
158
+ "operation": "click_row_action",
159
+ "target_row": {"id": "103", "customer": "Omni Dynamics"},
160
+ "target_action": "edit",
161
+ "locator": "#customers-grid tr[data-id='103'] button.btn-edit"
162
162
  }
163
- // Targeted action: await CustomersPage.editButton('Omni Dynamics').click();
164
163
  """
165
164
  },
166
165
  {
@@ -168,48 +167,57 @@ class CustomersPage extends BasePage {
168
167
  "name": "Page Class Inspection & Refactoring",
169
168
  "description": "Reading and navigating a Page Class codebase to edit a single workflow method.",
170
169
  "baseline_payload": """
171
- // Monolithic legacy Page Object (300+ methods, all locator getters dumped in prompt)
172
- class CheckoutPage {
173
- get shippingFirstName() { return $('#shipping_fn'); }
174
- get shippingLastName() { return $('#shipping_ln'); }
175
- get shippingAddress1() { return $('#shipping_a1'); }
176
- get shippingAddress2() { return $('#shipping_a2'); }
177
- get shippingCity() { return $('#shipping_city'); }
178
- get shippingState() { return $('#shipping_state'); }
179
- get shippingZip() { return $('#shipping_zip'); }
180
- get shippingCountry() { return $('#shipping_country'); }
181
- get billingSameAsShipping() { return $('#billing_same'); }
182
- get billingFirstName() { return $('#billing_fn'); }
183
- get billingLastName() { return $('#billing_ln'); }
184
- get billingAddress1() { return $('#billing_a1'); }
185
- get billingCity() { return $('#billing_city'); }
186
- get billingState() { return $('#billing_state'); }
187
- get billingZip() { return $('#billing_zip'); }
188
- get paymentCreditCardOption() { return $('#pay_cc'); }
189
- get paymentCardNumber() { return $('#cc_number'); }
190
- get paymentCardExpiry() { return $('#cc_expiry'); }
191
- get paymentCardCvv() { return $('#cc_cvv'); }
192
- get paymentCardName() { return $('#cc_name'); }
193
- get termsAgreementCheckbox() { return $('#terms_cb'); }
194
- get placeOrderButton() { return $('#btn_place_order'); }
195
- get orderConfirmationNumber() { return $('#order_conf_no'); }
196
- get orderSummarySubtotal() { return $('#sum_subtotal'); }
197
- get orderSummaryTax() { return $('#sum_tax'); }
198
- get orderSummaryShipping() { return $('#sum_shipping'); }
199
- get orderSummaryTotal() { return $('#sum_total'); }
200
- // ... 150 more repetitive getter definitions ...
201
- fillShipping(data) { /* 40 lines */ }
202
- fillBilling(data) { /* 40 lines */ }
203
- fillPayment(data) { /* 40 lines */ }
204
- placeOrder() { /* 20 lines */ }
170
+ package com.enterprise.pages;
171
+
172
+ import org.openqa.selenium.By;
173
+ import org.openqa.selenium.WebDriver;
174
+ import org.openqa.selenium.WebElement;
175
+ import org.openqa.selenium.support.ui.ExpectedConditions;
176
+ import org.openqa.selenium.support.ui.WebDriverWait;
177
+ import java.time.Duration;
178
+
179
+ public class MonolithicCustomerPage {
180
+ private WebDriver driver;
181
+ private WebDriverWait wait;
182
+
183
+ private By usernameInput = By.id("username");
184
+ private By passwordInput = By.id("password");
185
+ private By loginBtn = By.cssSelector(".btn-primary");
186
+ private By customerGrid = By.id("customers-grid");
187
+ private By addCustomerBtn = By.xpath("//button[contains(text(), 'Add Customer')]");
188
+ private By nameField = By.name("customer_name");
189
+ private By emailField = By.name("customer_email");
190
+ private By saveBtn = By.cssSelector("button[type='submit']");
191
+ private By toastMsg = By.cssSelector(".toast-success");
192
+
193
+ public MonolithicCustomerPage(WebDriver driver) {
194
+ this.driver = driver;
195
+ this.wait = new WebDriverWait(driver, Duration.ofSeconds(10));
196
+ }
197
+
198
+ public void enterUsername(String u) { driver.findElement(usernameInput).sendKeys(u); }
199
+ public void enterPassword(String p) { driver.findElement(passwordInput).sendKeys(p); }
200
+ public void clickLogin() { driver.findElement(loginBtn).click(); }
201
+ public void navigateToCustomers() { driver.get("https://app.enterprise.internal/customers"); }
202
+ public void clickAdd() { driver.findElement(addCustomerBtn).click(); }
203
+ public void fillForm(String n, String e) {
204
+ driver.findElement(nameField).sendKeys(n);
205
+ driver.findElement(emailField).sendKeys(e);
206
+ }
207
+ public void save() { driver.findElement(saveBtn).click(); }
208
+ public boolean isSaved() { return wait.until(ExpectedConditions.visibilityOfElementLocated(toastMsg)).isDisplayed(); }
205
209
  }
206
210
  """,
207
211
  "synapse_payload": """
208
- // Synapse Clean POM (Flat Architecture + repo_map condensed index)
209
- // Indexed via tools/repo_map.py (AST signature only)
210
- class CheckoutPage extends BasePage {
211
- submitOrder(shipping: Address, card: PaymentCard): Promise<string>
212
- getSummaryTotal(): Promise<number>
212
+ // Clean Flat POM — CustomerPage.ts (Scoped business workflow method only)
213
+ export class CustomerPage extends BasePage {
214
+ async createCustomer(name: string, email: string): Promise<void> {
215
+ await this.page.click("button:has-text('Add Customer')");
216
+ await this.page.fill("input[name='customer_name']", name);
217
+ await this.page.fill("input[name='customer_email']", email);
218
+ await this.page.click("button[type='submit']");
219
+ await expect(this.page.locator(".toast-success")).toBeVisible();
220
+ }
213
221
  }
214
222
  """
215
223
  },
@@ -218,83 +226,82 @@ class CheckoutPage extends BasePage {
218
226
  "name": "Failure Autopsy & Triage Diagnostics",
219
227
  "description": "Diagnosing a flaky test run failure from execution reports and stacktraces.",
220
228
  "baseline_payload": """
221
- [15:23:01.102] DEBUG [runner.ts] Initializing browser session worker pid=48102
222
- [15:23:02.311] DEBUG [runner.ts] Loading extension background scripts
223
- [15:23:03.490] INFO [runner.ts] Navigating to https://staging.app.internal/orders/new
224
- [15:23:04.119] DEBUG [network.ts] GET /api/v1/user 200 OK (110ms)
225
- [15:23:04.250] DEBUG [network.ts] GET /assets/app.chunk.js 200 OK (45ms)
226
- [15:23:04.310] DEBUG [network.ts] GET /assets/vendor.chunk.js 200 OK (80ms)
227
- [15:23:05.100] DEBUG [network.ts] POST /telemetry/collect 204 No Content (30ms)
228
- [15:23:06.012] INFO [step.ts] Executing step: fillCustomerDetails
229
- [15:23:06.120] DEBUG [network.ts] GET /api/v1/customers/autocomplete?q=Acme 200 OK (150ms)
230
- [15:23:07.450] INFO [step.ts] Executing step: clickSubmitOrder
231
- [15:23:07.480] DEBUG [dom.ts] Clicking element: button#btn-submit-order
232
- [15:23:07.510] ERROR [locator.ts] ElementClickInterceptedException: element click intercepted: Element <button id="btn-submit-order" class="btn btn-primary" disabled="">...</button> is not clickable at point (520, 480). Other element would receive the click: <div class="modal-backdrop fade show"></div>
233
- (Session info: headless chrome=122.0.6261.94)
234
- at Object.checkErrors (node_modules/selenium-webdriver/lib/error.js:522:15)
235
- at parseHttpResponse (node_modules/selenium-webdriver/lib/http.js:601:13)
236
- at Executor.execute (node_modules/selenium-webdriver/lib/http.js:529:26)
237
- at WebDriver.execute (node_modules/selenium-webdriver/lib/webdriver.js:745:17)
238
- at toWireValue (node_modules/selenium-webdriver/lib/webdriver.js:145:15)
239
- at /build/app/tests/e2e/orders.spec.ts:89:12
240
- at processTicksAndRejections (node:internal/process/task_queues:95:5)
241
- [15:23:08.000] INFO [runner.ts] Capturing failure screenshot: Screenshots/FAILED_OrderTest_1709652188.png
242
- [15:23:08.500] INFO [runner.ts] Suite finished with 1 failure, 0 skipped, 12 passed.
229
+ 2026-11-12T14:02:11.891Z [INFO] Initializing ChromeDriver 124.0.6367.91 on port 45291
230
+ 2026-11-12T14:02:12.102Z [DEBUG] Starting session with capabilities: {browserName: chrome, acceptInsecureCerts: true}
231
+ 2026-11-12T14:02:13.450Z [INFO] Navigating to https://crm.internal/invoices/10928
232
+ 2026-11-12T14:02:14.200Z [INFO] Waiting for element locator: By.cssSelector("#invoice-status-badge")
233
+ 2026-11-12T14:02:24.250Z [ERROR] org.openqa.selenium.TimeoutException: Expected condition failed: waiting for visibility of element located by By.cssSelector("#invoice-status-badge") (tried for 10 second(s) with 500 milliseconds interval)
234
+ Build info: version: '4.19.1', revision: 'abe0ee07dc'
235
+ System info: os.name: 'Linux', os.arch: 'amd64', os.version: '6.5.0-28-generic', java.version: '17.0.10'
236
+ Driver info: org.openqa.selenium.chrome.ChromeDriver
237
+ Capabilities {acceptInsecureCerts: true, browserName: chrome, browserVersion: 124.0.6367.91}
238
+ Session ID: 49c8192a8310c8f18d726190ab7261a9
239
+ at org.openqa.selenium.support.ui.WebDriverWait.timeoutException(WebDriverWait.java:84)
240
+ at org.openqa.selenium.support.ui.FluentWait.until(FluentWait.java:228)
241
+ at com.enterprise.pages.InvoicePage.waitForStatus(InvoicePage.java:78)
242
+ at com.enterprise.tests.InvoiceFlowTest.testApproveInvoice(InvoiceFlowTest.java:45)
243
+ at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
244
+ at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:77)
245
+ at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
246
+ at java.base/java.lang.reflect.Method.invoke(Method.java:568)
247
+ at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:59)
243
248
  """,
244
249
  "synapse_payload": """
245
- {
246
- "failure_type": "ElementClickInterceptedException",
247
- "root_cause": "Modal backdrop overlay fading out (.modal-backdrop.fade.show)",
248
- "failing_target": "button#btn-submit-order",
249
- "source_location": "orders.spec.ts:89",
250
- "clean_pom_fix": "await page.locator('.modal-backdrop').waitFor({ state: 'detached' });"
251
- }
250
+ [LOG DISTILLER] Analyzed 24 lines (1,390 bytes).
251
+ ❌ FAILURES DETECTED [Exit Code: 1]: 1 failure block isolated.
252
+ Failing Script Location: InvoicePage.java:78 (testApproveInvoice:45)
253
+ --- Distilled Failure Block ---
254
+ TimeoutException: waiting for visibility of #invoice-status-badge (tried 10s)
255
+ at InvoicePage.waitForStatus(InvoicePage.java:78)
256
+ at InvoiceFlowTest.testApproveInvoice(InvoiceFlowTest.java:45)
252
257
  """
253
258
  }
254
259
  ]
255
260
 
256
261
 
257
262
  def load_workload_scenarios(dataset_dir: Optional[str] = None) -> List[Dict[str, Any]]:
258
- """Loads benchmark workloads from external standardized dataset or falls back to builtin."""
259
- target_dir = dataset_dir or os.path.join(REPO_ROOT, "tests", "fixtures", "benchmarks", "context_tokens")
260
- dataset_file = os.path.join(target_dir, "scenarios.json")
261
- if os.path.isfile(dataset_file):
262
- try:
263
- with open(dataset_file, "r", encoding="utf-8") as f:
264
- data = json.load(f)
265
- if isinstance(data, list) and len(data) >= 4:
266
- return data
267
- except (OSError, json.JSONDecodeError) as err:
268
- _ = err
269
- return WORKLOAD_SCENARIOS
263
+ """Loads workload scenarios from external dataset directory or falls back to built-in."""
264
+ if not dataset_dir:
265
+ return WORKLOAD_SCENARIOS
270
266
 
267
+ scenarios_path = os.path.join(dataset_dir, "scenarios.json")
268
+ if not os.path.exists(scenarios_path):
269
+ return WORKLOAD_SCENARIOS
271
270
 
272
- def run_benchmark(dataset_dir: Optional[str] = None) -> Dict[str, Any]:
273
- """Executes deterministic context reduction benchmark across all scenarios."""
271
+ try:
272
+ with open(scenarios_path, "r", encoding="utf-8") as f:
273
+ data = json.load(f)
274
+ return data.get("scenarios", WORKLOAD_SCENARIOS)
275
+ except Exception:
276
+ return WORKLOAD_SCENARIOS
277
+
278
+
279
+ def run_synthetic_benchmark(dataset_dir: Optional[str] = None) -> Dict[str, Any]:
280
+ """Runs Track 1: Deterministic Micro-Workloads Benchmark."""
281
+ scenarios = load_workload_scenarios(dataset_dir)
274
282
  results = []
275
283
  total_baseline_tokens = 0
276
284
  total_synapse_tokens = 0
277
285
 
278
- scenarios = load_workload_scenarios(dataset_dir)
279
286
  for scn in scenarios:
280
- b_tokens = estimate_tokens(scn["baseline_payload"])
281
- s_tokens = estimate_tokens(scn["synapse_payload"])
282
- savings_tokens = max(0, b_tokens - s_tokens)
283
- savings_pct = round((savings_tokens / max(1, b_tokens)) * 100.0, 2)
284
-
285
- total_baseline_tokens += b_tokens
286
- total_synapse_tokens += s_tokens
287
+ baseline_tokens = count_tokens(scn["baseline_payload"])
288
+ synapse_tokens = count_tokens(scn["synapse_payload"])
289
+ saved_tokens = baseline_tokens - synapse_tokens
290
+ savings_pct = round((saved_tokens / max(1, baseline_tokens)) * 100.0, 2)
287
291
 
288
292
  results.append({
289
293
  "id": scn["id"],
290
294
  "name": scn["name"],
291
295
  "description": scn["description"],
292
- "baseline_tokens": b_tokens,
293
- "synapse_tokens": s_tokens,
294
- "saved_tokens": savings_tokens,
295
- "savings_pct": savings_pct
296
+ "baseline_tokens": baseline_tokens,
297
+ "synapse_tokens": synapse_tokens,
298
+ "saved_tokens": saved_tokens,
299
+ "savings_pct": savings_pct,
296
300
  })
297
301
 
302
+ total_baseline_tokens += baseline_tokens
303
+ total_synapse_tokens += synapse_tokens
304
+
298
305
  net_savings_tokens = total_baseline_tokens - total_synapse_tokens
299
306
  net_savings_pct = round((net_savings_tokens / max(1, total_baseline_tokens)) * 100.0, 2)
300
307
 
@@ -305,53 +312,137 @@ def run_benchmark(dataset_dir: Optional[str] = None) -> Dict[str, Any]:
305
312
  "net_saved_tokens": net_savings_tokens,
306
313
  "net_savings_pct": net_savings_pct,
307
314
  "verified_claim_ge_40_pct": (net_savings_pct >= 40.0),
308
- "scenarios": results
315
+ "scenarios": results,
316
+ }
317
+
318
+
319
+ def run_empirical_projects_benchmark() -> Dict[str, Any]:
320
+ """Runs Track 2: Empirical Reference Suites Benchmark on real project directories."""
321
+ try:
322
+ from tools.rules_router import route_rules
323
+ except ImportError:
324
+ from rules_router import route_rules
325
+
326
+ project_folders = [
327
+ ("Playwright CRM Suite", os.path.join(REPO_ROOT, "examples", "playwright-crm-suite")),
328
+ ("Pytest API Suite", os.path.join(REPO_ROOT, "examples", "pytest-api-suite")),
329
+ ("Katalon Suite", os.path.join(REPO_ROOT, "examples", "katalon-suite")),
330
+ ("Selenium Suite", os.path.join(REPO_ROOT, "examples", "selenium-suite")),
331
+ ]
332
+
333
+ project_results = []
334
+ for name, p_path in project_folders:
335
+ if not os.path.isdir(p_path):
336
+ continue
337
+ routed = route_rules(p_path)
338
+ cat = routed["hydration_contracts"]["catalog_summary"]
339
+ hyd = routed["hydration_contracts"]["full_hydration"]
340
+ rf = routed["hydration_contracts"].get("retrieval_footprint", {})
341
+
342
+ project_results.append({
343
+ "project_name": name,
344
+ "detected_stacks": routed["detected_stacks"],
345
+ "confidence_score": routed["confidence_score"],
346
+ "catalog_baseline": cat["baseline_tokens"],
347
+ "catalog_routed": cat["routed_tokens"],
348
+ "catalog_saved_tokens": cat["tokens_saved"],
349
+ "catalog_reduction_pct": cat["reduction_pct"],
350
+ "hydrated_baseline": hyd["baseline_tokens"],
351
+ "hydrated_routed": hyd["routed_tokens"],
352
+ "hydrated_saved_tokens": hyd["tokens_saved"],
353
+ "hydrated_reduction_pct": hyd["reduction_pct"],
354
+ "avoided_disk_bytes": rf.get("avoided_bytes", 0),
355
+ })
356
+
357
+ return {
358
+ "timestamp": datetime.now(timezone.utc).isoformat(),
359
+ "projects_count": len(project_results),
360
+ "results": project_results,
361
+ }
362
+
363
+
364
+ def run_benchmark(dataset_dir: Optional[str] = None) -> Dict[str, Any]:
365
+ """Runs combined dual-track benchmark."""
366
+ synthetic = run_synthetic_benchmark(dataset_dir)
367
+ empirical = run_empirical_projects_benchmark()
368
+ return {
369
+ "timestamp": datetime.now(timezone.utc).isoformat(),
370
+ "synthetic_track": synthetic,
371
+ "empirical_track": empirical,
372
+ # Backward compatibility fields
373
+ "total_baseline_tokens": synthetic["total_baseline_tokens"],
374
+ "total_synapse_tokens": synthetic["total_synapse_tokens"],
375
+ "net_saved_tokens": synthetic["net_saved_tokens"],
376
+ "net_savings_pct": synthetic["net_savings_pct"],
377
+ "verified_claim_ge_40_pct": synthetic["verified_claim_ge_40_pct"],
378
+ "scenarios": synthetic["scenarios"],
309
379
  }
310
380
 
311
381
 
312
382
  def format_markdown_report(bench: Dict[str, Any]) -> str:
313
- """Formats benchmark results in a clean GitHub Flavored Markdown report."""
383
+ """Formats benchmark results in a clean, scientifically honest markdown report."""
384
+ syn = bench.get("synthetic_track", bench)
385
+ emp = bench.get("empirical_track", {})
386
+
314
387
  md = [
315
- "# Empirical Context & Token Reduction Benchmark",
388
+ "# Empirical Context & Token Reduction Benchmark (Dual-Track)",
316
389
  "",
317
- "> **Methodology:** Calibrated BPE Token Estimation comparing Naive Raw DOM / Monolithic LLM workflows",
318
- "> against Synapse Hub's Clean POM, Compact AOM Subtrees, Zero-Second Auth, and Pinpoint Triage.",
390
+ "> **Scientific Disclosure:** This benchmark distinguishes between:",
391
+ "> 1. **Track 1 (Synthetic Micro-Workloads):** Deterministic micro-workloads evaluating isolated context patterns.",
392
+ "> 2. **Track 2 (Empirical Reference Suites):** Live measurements on real example workspaces within the repository.",
319
393
  "",
320
- "## 1. Executive Summary Scoreboard",
394
+ "## Track 1: Deterministic Micro-Workload Benchmark (Synthetic)",
321
395
  "",
322
396
  "| Metric | Naive LLM Baseline | Synapse Hub Swarm | Empirical Impact |",
323
397
  "|---|:---:|:---:|:---:|",
324
- f"| **Total Tokens Consumed** | `{bench['total_baseline_tokens']:,}` tokens | `{bench['total_synapse_tokens']:,}` tokens | **-{bench['net_saved_tokens']:,} tokens** |",
325
- f"| **Context Efficiency Gain** | Baseline (100%) | Optimized ({100.0 - bench['net_savings_pct']:.1f}%) | **+{bench['net_savings_pct']}% reduction** |",
326
- f"| **Enterprise Threshold (>= 40%)** | — | — | **{'✅ PASS (Exceeded)' if bench['verified_claim_ge_40_pct'] else '❌ FAIL'}** |",
398
+ f"| **Total Tokens Consumed** | `{syn['total_baseline_tokens']:,}` tokens | `{syn['total_synapse_tokens']:,}` tokens | **-{syn['net_saved_tokens']:,} tokens** |",
399
+ f"| **Context Efficiency Gain** | Baseline (100%) | Optimized ({100.0 - syn['net_savings_pct']:.1f}%) | **+{syn['net_savings_pct']}% reduction** |",
400
+ f"| **Enterprise Threshold (>= 40%)** | — | — | **{'✅ PASS (Exceeded)' if syn['verified_claim_ge_40_pct'] else '❌ FAIL'}** |",
327
401
  "",
328
- "## 2. Workload Scenario Breakdown",
402
+ "### Scenario Breakdown",
329
403
  "",
330
404
  "| ID | Scenario | Baseline Tokens | Synapse Tokens | Tokens Saved | Reduction (%) | Status |",
331
- "|---|---|:---:|:---:|:---:|:---:|:---:|"
405
+ "|---|---|:---:|:---:|:---:|:---:|:---:|",
332
406
  ]
333
407
 
334
- for s in bench["scenarios"]:
408
+ for s in syn["scenarios"]:
335
409
  status_badge = "✅ PASS" if s["savings_pct"] >= 40.0 else "⚠️ WARN"
336
410
  md.append(f"| `{s['id']}` | **{s['name']}** | {s['baseline_tokens']:,} | {s['synapse_tokens']:,} | -{s['saved_tokens']:,} | **{s['savings_pct']}%** | {status_badge} |")
337
411
 
412
+ if emp and emp.get("results"):
413
+ md.extend([
414
+ "",
415
+ "## Track 2: Empirical Reference Suites Benchmark (Real Projects)",
416
+ "",
417
+ "| Reference Project | Detected Stack | Confidence | Catalog Summary Saved | Full Hydration Saved | Avoided Disk Read |",
418
+ "|---|---|:---:|:---:|:---:|:---:|",
419
+ ])
420
+ for p in emp["results"]:
421
+ stacks = ", ".join(p["detected_stacks"])
422
+ md.append(
423
+ f"| **{p['project_name']}** | `{stacks}` | {p['confidence_score']} | "
424
+ f"**{p['catalog_saved_tokens']:,}** ({p['catalog_reduction_pct']}%) | "
425
+ f"**{p['hydrated_saved_tokens']:,}** ({p['hydrated_reduction_pct']}%) | "
426
+ f"~{p['avoided_disk_bytes'] // 1024} KB |"
427
+ )
428
+
338
429
  md.extend([
339
430
  "",
340
- "## 3. Engineering Invariants & Optimization Drivers",
431
+ "## Key Optimization Drivers",
341
432
  "",
342
- "1. **Zero-Second Auth (`storageState.json`):** Bypasses repetitive login forms, CSRF tokens, and SSO redirect loops (saving ~80-90% auth context).",
343
- "2. **Accessibility Object Model (AOM):** Extracts compact semantic trees (< 500 tokens) instead of bloated 2,000+ line HTML trees containing inline SVG, CSS, and tracker tags.",
344
- "3. **Flat Clean POM Separation:** Page Classes maintain minimal, readable business workflows without polluting test scripts with raw CSS/XPath selectors.",
345
- "4. **Pinpoint Log Distillation:** Replaces 500-line stacktraces with distilled root-cause signatures (0.1s JUnit XML autopsy).",
433
+ "1. **Zero-Second Auth (`storageState.json`):** Bypasses repetitive login forms and CSRF redirect loops.",
434
+ "2. **Accessibility Object Model (AOM):** Extracts compact semantic trees (< 500 tokens) instead of bloated 2,000+ line raw HTML.",
435
+ "3. **Flat Clean POM Separation:** Scopes business methods without cluttering scripts with raw selectors.",
436
+ "4. **Pinpoint Log Distillation:** Replaces hundreds of lines of noise with focused, evidence-preserving triage blocks.",
346
437
  "",
347
- f"*Report generated: `{bench['timestamp']}` by `tools/benchmark_swarm_context.py`*"
438
+ f"*Report generated: `{bench.get('timestamp')}` by `tools/benchmark_swarm_context.py`*"
348
439
  ])
349
440
 
350
441
  return "\n".join(md)
351
442
 
352
443
 
353
444
  def main() -> int:
354
- parser = argparse.ArgumentParser(description="Empirical Context & Token Reduction Benchmark Harness")
445
+ parser = argparse.ArgumentParser(description="Dual-Track Context & Token Reduction Benchmark Harness")
355
446
  parser.add_argument("--verify-min-savings", type=float, default=40.0,
356
447
  help="Exit non-zero if net token savings is below this threshold (default: 40.0%%)")
357
448
  parser.add_argument("--dataset-dir", default=None,
@@ -13,7 +13,7 @@
13
13
  (function () {
14
14
  'use strict';
15
15
 
16
- if (window.__qa && window.__qa.__version === '3.10.0') {
16
+ if (window.__qa && window.__qa.__version === '4.1.0') {
17
17
  return window.__qa;
18
18
  }
19
19
 
@@ -47,7 +47,7 @@
47
47
  }
48
48
 
49
49
  const qa = {
50
- __version: '3.10.0',
50
+ __version: '4.1.0',
51
51
 
52
52
  /**
53
53
  * 1. Smart Action Batching
@@ -17,7 +17,7 @@ def robust_parse_cards(filename, start_index=1):
17
17
  # Split by repo-card
18
18
  raw_blocks = html.split('<div class="repo-card">')[1:]
19
19
  cards = []
20
-
20
+
21
21
  for i, block in enumerate(raw_blocks, start=start_index):
22
22
  # Determine the boundary of the card
23
23
  end_idx = len(block)
@@ -165,7 +165,7 @@ def build_consolidated_html():
165
165
  5: "<code>tools/runaway_stopper.py</code> (RunawaySentinel) · Bất biến Pure Headless Playwright CDP 1920x1080 (AGENTS.md)",
166
166
  6: "<code>tools/skill_collision_guard.py</code> (Gate 9 Addy Osmani Pattern) · Phân cấp 4 Persona FSM trong <code>.agents/skills/</code>",
167
167
  7: "<code>tools/mechanical_ui_gate.py</code> (Kiểm toán WCAG AA >= 4.5:1, thang chữ typographic) · <code>tests/test_ecosystem_integrations.py</code>",
168
- 8: "<code>.agents/skills/wcag-audit-patterns</code> · <code>.agents/skills/backend-load-and-stress-patterns</code>",
168
+ 8: "<code>.agents/skills/05-security-and-compliance/wcag-audit-patterns</code> · <code>.agents/skills/04-performance-and-load/backend-load-and-stress-patterns</code>",
169
169
  9: "<code>.github/copilot-instructions.md</code> (Quy tắc Clean POM và Smart Wait theo phạm vi file hẹp)",
170
170
  10: "<code>skills-lock.json</code> & <code>.skill-lock.json</code> v3 (Đăng ký 53 skills cho Vercel/Cursor/Antigravity)",
171
171
  11: "Bảng màu Dark Studio chuẩn WCAG AA và Typography Scale tích hợp trong báo cáo hợp nhất",
@@ -190,10 +190,10 @@ def build_consolidated_html():
190
190
  batch = r['batch']
191
191
  cols = r['cols']
192
192
  clean_name = r['clean_name']
193
-
193
+
194
194
  card_anchor = f'<a href="#repo-card-{idx}" class="anchor-link" title="Xem phân tích chuyên sâu #{idx}" aria-label="Chuyển đến hồ sơ {clean_name}">#{idx}</a> '
195
195
  github_link = f'<a href="https://github.com/{clean_name}" target="_blank" rel="noopener noreferrer" class="repo-github-link">{clean_name}</a>'
196
-
196
+
197
197
  row_str = f"""
198
198
  <tr class="eval-row-tr" data-repo-index="{idx}" data-batch="{batch}" data-category="{cat_slug}">
199
199
  <td class="font-bold">{card_anchor}<span class="repo-name">{github_link}</span></td>
@@ -218,7 +218,7 @@ def build_consolidated_html():
218
218
  batch = c['batch']
219
219
  badge_label = f"Đợt 1 · Repo #{idx}" if idx <= 10 else f"Đợt 2 · Repo #{idx}"
220
220
  evidence_code = code_evidence_map.get(idx, "<code>tests/test_ecosystem_integrations.py</code> · <code>NOTICE</code>")
221
-
221
+
222
222
  eval_items_html = []
223
223
  for ev in c['eval_rows']:
224
224
  lbl = ev['label']
@@ -231,7 +231,7 @@ def build_consolidated_html():
231
231
  """.strip())
232
232
 
233
233
  tags_html = " ".join([f'<span class="tag">{t}</span>' for t in c['tags']])
234
-
234
+
235
235
  card_str = f"""
236
236
  <div class="repo-card" id="repo-card-{idx}" data-repo-index="{idx}" data-batch="{batch}" data-category="{cat_slug}">
237
237
  <div class="repo-header">
@@ -96,24 +96,29 @@ def djb2_hash(s: str) -> str:
96
96
 
97
97
  def compute_error_fingerprint(error_type: str, error_msg: str, stack_anchor: str = "") -> str:
98
98
  """
99
- Computes a deterministic, normalized fingerprint hash for an error.
100
- Strips volatile elements (timestamps, hex addresses, line numbers) so semantically
101
- identical errors across test runs produce the identical fingerprint.
99
+ Computes a deterministic, normalized fingerprint hash for an error (Boost B5).
100
+ Strips volatile elements (timestamps, hex addresses, line numbers, durations) so semantically
101
+ identical errors across test runs produce the identical deterministic DJB2 fingerprint.
102
102
  """
103
103
  norm_type = (error_type or "").strip().lower()
104
104
  msg = error_msg or ""
105
105
  # Strip hex memory addresses
106
106
  msg = re.sub(r'0x[0-9a-fA-F]+', '0xADDR', msg)
107
- # Strip ISO/standard timestamps
107
+ # Strip ISO/standard timestamps (with or without date)
108
108
  msg = re.sub(r'\b\d{4}-\d{2}-\d{2}[T\s]\d{2}:\d{2}:\d{2}(?:\.\d+)?Z?\b', 'TIMESTAMP', msg)
109
- # Strip variable line numbers in filenames like "file.py:123"
109
+ msg = re.sub(r'\b\d{2}:\d{2}:\d{2}(?:\.\d+)?\b', 'TIMESTAMP', msg)
110
+ # Strip execution durations like 3000ms or 2.5s
111
+ msg = re.sub(r'\b\d+(?:\.\d+)?(?:ms|s)\b', 'DUR', msg)
112
+ # Strip variable line numbers in filenames like "file.py:123" or "line 42"
110
113
  msg = re.sub(r':\d+\b', ':LINE', msg)
114
+ msg = re.sub(r'\bline \d+\b', 'line LINE', msg, flags=re.IGNORECASE)
111
115
  # Collapse whitespace
112
116
  msg = re.sub(r'\s+', ' ', msg).strip()[:200]
113
117
 
114
- anchor = (stack_anchor or "").strip().lower()
118
+ anchor = (stack_anchor or "").strip().lower().replace('\\', '/')
115
119
  if anchor:
116
120
  anchor = re.sub(r':\d+\b', ':LINE', anchor)
121
+ anchor = re.sub(r'\bline \d+\b', 'line LINE', anchor, flags=re.IGNORECASE)
117
122
  raw = f"{norm_type}:{msg}@{anchor}"
118
123
  else:
119
124
  raw = f"{norm_type}:{msg}"