synapse-hub 2.6.0 → 3.0.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 (143) hide show
  1. package/.agents/agents/failure-analyst.md +4 -0
  2. package/.agents/agents/live-explorer.md +2 -0
  3. package/.agents/agents/orchestrator.md +16 -0
  4. package/.agents/agents/pom-crafter.md +10 -0
  5. package/.agents/agents/quality-gatekeeper.md +5 -0
  6. package/.agents/agents/test-runner.md +8 -0
  7. package/.agents/rules/git-push-protocol.md +1 -1
  8. package/.agents/rules/graphify.md +2 -0
  9. package/.agents/rules/mandatory-playwright-live.md +9 -9
  10. package/.agents/rules/mobile_appium_rules.md +8 -1
  11. package/.agents/skills/actor-qa-swarm/SKILL.md +77 -0
  12. package/.agents/skills/actor-qa-swarm/examples/broker_sharding_sample.json +12 -0
  13. package/.agents/skills/agentless-qa-repair/SKILL.md +69 -0
  14. package/.agents/skills/agentless-qa-repair/examples/healing_report_sample.json +17 -0
  15. package/.agents/skills/api-spec-to-e2e-matrix/SKILL.md +1 -1
  16. package/.agents/skills/clean-pom-crafter/SKILL.md +2 -2
  17. package/.agents/skills/db-state-verifier-and-seeder/SKILL.md +4 -4
  18. package/.agents/skills/event-stream-qa-orchestrator/SKILL.md +79 -0
  19. package/.agents/skills/event-stream-qa-orchestrator/examples/timeline_sample.jsonl +2 -0
  20. package/.agents/skills/failure-autopsy-and-healing/SKILL.md +2 -2
  21. package/.agents/skills/failure-autopsy-and-healing/scripts/triage_failures.sh +6 -21
  22. package/.agents/skills/katalon-cli-runner/SKILL.md +1 -1
  23. package/.agents/skills/lean-impact-scoreboard/SKILL.md +1 -1
  24. package/.agents/skills/mipro-prompt-compiler/SKILL.md +59 -0
  25. package/.agents/skills/mipro-prompt-compiler/examples/compiled_module_sample.json +22 -0
  26. package/.agents/skills/qa-aci-interface/SKILL.md +67 -0
  27. package/.agents/skills/qa-aci-interface/examples/surgical_edit_sample.json +12 -0
  28. package/.agents/skills/qa-memory-os/SKILL.md +80 -0
  29. package/.agents/skills/qa-memory-os/examples/archival_memory_sample.json +21 -0
  30. package/.agents/skills/repo-quality-audit/SKILL.md +1 -1
  31. package/.agents/skills/review-spec/SKILL.md +60 -0
  32. package/.agents/skills/review-spec/examples/sample_spec_review.md +33 -0
  33. package/.agents/skills/senior-code-review/SKILL.md +1 -1
  34. package/.agents/skills/synthetic-test-data-generator/SKILL.md +2 -2
  35. package/.agents/skills/technical-debt-harvester/SKILL.md +1 -1
  36. package/.agents/skills/tot-exploratory-testing/SKILL.md +59 -0
  37. package/.agents/skills/tot-exploratory-testing/examples/tot_graph_sample.json +35 -0
  38. package/.agents/skills/wcag-audit-patterns/SKILL.md +2 -2
  39. package/.agents/skills/web-agent-gym-benchmarking/SKILL.md +62 -0
  40. package/.agents/skills/web-agent-gym-benchmarking/examples/benchmark_report_sample.json +22 -0
  41. package/CLAUDE.md +2 -2
  42. package/README.en.md +70 -291
  43. package/README.md +68 -303
  44. package/docs/ARCHITECTURE.md +54 -8
  45. package/docs/CONTRIBUTING.md +1 -1
  46. package/docs/QUALITY_GATES.md +113 -0
  47. package/docs/research/EXTERNAL_AGENT_SKILLS_SURVEY.md +1062 -0
  48. package/package.json +1 -1
  49. package/scripts/package_dist.py +2 -1
  50. package/skills_manifest.json +92 -11
  51. package/synapse.config.json +1 -1
  52. package/templates/ai_bridges/CLAUDE.md +2 -2
  53. package/templates/ai_bridges/copilot-instructions.md +2 -2
  54. package/tools/TOOLS_RUNBOOK.md +1 -1
  55. package/tools/__init__.py +18 -1
  56. package/tools/_openapi_parser.py +158 -0
  57. package/tools/agent_canary.py +42 -30
  58. package/tools/agentless_patcher.py +417 -0
  59. package/tools/analyze_project.py +12 -11
  60. package/tools/api_drift_sentinel.py +4 -4
  61. package/tools/api_fuzzer.py +8 -8
  62. package/tools/auto_heal.py +23 -5
  63. package/tools/auto_heal_reflexion.py +2 -2
  64. package/tools/autogen_qa_broker.py +318 -0
  65. package/tools/browser_helpers.js +2 -2
  66. package/tools/browsergym_eval.py +236 -0
  67. package/tools/bug_reporter.py +11 -13
  68. package/tools/bump_version.py +75 -5
  69. package/tools/cache_resolver.py +78 -83
  70. package/tools/check_env.py +9 -1
  71. package/tools/check_version_sync.py +40 -3
  72. package/tools/ci_healing_hook.py +5 -7
  73. package/tools/cli.py +5 -7
  74. package/tools/config_decoupler.py +2 -3
  75. package/tools/core/__init__.py +52 -0
  76. package/tools/count_tokens.py +22 -20
  77. package/tools/dashboard_generator.py +628 -999
  78. package/tools/db_sandbox.py +69 -53
  79. package/tools/debt_harvester.py +3 -3
  80. package/tools/distill_log.py +3 -3
  81. package/tools/dspy_qa_signatures.py +3 -4
  82. package/tools/export_postman_collection.py +8 -8
  83. package/tools/flaky_detector.py +2 -2
  84. package/tools/fuzz_payloads.py +5 -5
  85. package/tools/generate_allure_report.py +1 -1
  86. package/tools/generate_jmx_plan.py +4 -4
  87. package/tools/gherkin_suite.py +1 -1
  88. package/tools/git_pre_commit_guard.py +2 -2
  89. package/tools/goldfish_review.py +2 -2
  90. package/tools/heal/__init__.py +28 -0
  91. package/tools/heal_pr_automator.py +29 -4
  92. package/tools/heuristic_locator_matcher.py +2 -2
  93. package/tools/infer_linter.py +8 -8
  94. package/tools/interview_story.py +0 -1
  95. package/tools/jtl_analyzer.py +11 -11
  96. package/tools/lint/__init__.py +30 -0
  97. package/tools/lint_ai_docs.py +42 -0
  98. package/tools/lookup_tc.py +1 -1
  99. package/tools/matrix_sharder.py +15 -13
  100. package/tools/mcp/__init__.py +16 -0
  101. package/tools/mcp_excel_server.py +2 -2
  102. package/tools/mcp_server.py +3 -4
  103. package/tools/md_to_xlsx.py +26 -26
  104. package/tools/micro_mutator.py +11 -12
  105. package/tools/mipro_assertion_tuner.py +207 -0
  106. package/tools/network_mock_shield.py +27 -27
  107. package/tools/newman_analyzer.py +2 -3
  108. package/tools/omni_emitter.py +5 -8
  109. package/tools/omni_parser.py +5 -5
  110. package/tools/omni_transpiler.py +5 -5
  111. package/tools/output_formatter.py +19 -0
  112. package/tools/perf/__init__.py +24 -0
  113. package/tools/pinpoint_failure.py +13 -1
  114. package/tools/project_state.py +4 -2
  115. package/tools/qa_event_stream.py +336 -0
  116. package/tools/repo_map.py +8 -8
  117. package/tools/report/__init__.py +32 -0
  118. package/tools/reversible_sandbox.py +5 -2
  119. package/tools/safety_firewall.py +2 -2
  120. package/tools/senior_code_review.py +2 -2
  121. package/tools/setup_project.py +10 -12
  122. package/tools/skill_collision_guard.py +3 -3
  123. package/tools/skill_vault.py +12 -3
  124. package/tools/skillspector.py +5 -7
  125. package/tools/smart_visual_masker.py +4 -6
  126. package/tools/spec_drift_sentinel.py +1 -2
  127. package/tools/swe_qa_aci.py +369 -0
  128. package/tools/synapse_qa_bench.py +3 -3
  129. package/tools/sync_agent_rules.py +18 -4
  130. package/tools/telemetry_correlator.py +3 -2
  131. package/tools/test_memory_os.py +419 -0
  132. package/tools/textgrad_mutation_optimizer.py +3 -3
  133. package/tools/tms_sync_bridge.py +5 -5
  134. package/tools/tot_exploratory_tester.py +239 -0
  135. package/tools/traffic_session_converter.py +9 -9
  136. package/tools/universal_ir.py +2 -3
  137. package/tools/update_sentinel.py +6 -9
  138. package/tools/verify_all.py +10 -0
  139. package/tools/visual_diff_canvas.py +1 -2
  140. package/tools/visual_som_helper.py +15 -13
  141. package/tools/watch_mode.py +1 -1
  142. package/tools/wcag_audit.py +22 -1
  143. package/tools/welcome_page.py +5 -6
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "synapse-hub",
3
- "version": "2.6.0",
3
+ "version": "3.0.0",
4
4
  "description": "Enterprise AI Agent Intelligence Hub & Autonomous Skill Network",
5
5
  "publishConfig": {
6
6
  "access": "public"
@@ -37,6 +37,7 @@ EXCLUDE_DIRS = {
37
37
  "__pycache__",
38
38
  ".pytest_cache",
39
39
  ".mypy_cache",
40
+ ".ruff_cache",
40
41
  ".idea",
41
42
  ".vscode",
42
43
  "agent_qa.egg-info",
@@ -280,7 +281,7 @@ def create_package(output_zip: str = "agent-skills.zip") -> Path:
280
281
  total_size += full_path.stat().st_size
281
282
 
282
283
  zip_size_mb = out_path.stat().st_size / (1024 * 1024)
283
- print(f"✅ Packaging complete:")
284
+ print("✅ Packaging complete:")
284
285
  print(f" • Total files packaged : {total_files}")
285
286
  print(f" • Uncompressed size : {total_size / (1024 * 1024):.2f} MB")
286
287
  print(f" • Archive size (.zip) : {zip_size_mb:.2f} MB")
@@ -1,15 +1,18 @@
1
1
  {
2
2
  "$schema": "https://json-schema.org/draft/2020-12/schema",
3
3
  "name": "Enterprise Agent Skills Hub",
4
- "version": "2.6.0",
5
- "description": "Unified Catalog of 42 Specialized Skills for Autonomous AI Agents in Enterprise Software Quality Engineering, Performance, and Architecture.",
6
- "totalSkills": 42,
4
+ "version": "3.0.0",
5
+ "description": "Unified Catalog of 51 Specialized Skills for Autonomous AI Agents in Enterprise Software Quality Engineering, Performance, and Architecture.",
6
+ "totalSkills": 51,
7
7
  "categories": {
8
8
  "context_and_optimization": [
9
9
  "token-and-context-optimizer",
10
10
  "agent-orchestration-multi-agent-optimize",
11
11
  "persistent-planning-files",
12
- "meta-prompt-crafter"
12
+ "meta-prompt-crafter",
13
+ "qa-memory-os",
14
+ "event-stream-qa-orchestrator",
15
+ "actor-qa-swarm"
13
16
  ],
14
17
  "test_automation_and_execution": [
15
18
  "clean-pom-crafter",
@@ -22,7 +25,9 @@
22
25
  "gherkin-to-suite",
23
26
  "auth-session-and-cookie-manager",
24
27
  "backend-load-and-stress-patterns",
25
- "rbt-manual-testing"
28
+ "rbt-manual-testing",
29
+ "web-agent-gym-benchmarking",
30
+ "tot-exploratory-testing"
26
31
  ],
27
32
  "verification_and_resilience": [
28
33
  "antigravity-test-sentinel",
@@ -38,7 +43,8 @@
38
43
  "flaky-test-sentinel-and-quarantine",
39
44
  "test-driven-development",
40
45
  "systematic-debugging",
41
- "verification-before-completion"
46
+ "verification-before-completion",
47
+ "agentless-qa-repair"
42
48
  ],
43
49
  "architecture_and_analysis": [
44
50
  "api-spec-to-e2e-matrix",
@@ -53,7 +59,10 @@
53
59
  "graphify-impact-analyzer",
54
60
  "wcag-audit-patterns",
55
61
  "github-actions-templates",
56
- "web-vitals-and-performance-profiler"
62
+ "web-vitals-and-performance-profiler",
63
+ "qa-aci-interface",
64
+ "mipro-prompt-compiler",
65
+ "review-spec"
57
66
  ]
58
67
  },
59
68
  "profiles": {
@@ -483,7 +492,7 @@
483
492
  "name": "Senior Code Review",
484
493
  "category": "architecture_and_analysis",
485
494
  "path": ".agents/skills/senior-code-review/SKILL.md",
486
- "summary": "Quality review of a code change: verify logic correctness, security boundaries, real concurrency/load, missing test coverage, execution speed, and eliminate bloat.",
495
+ "summary": "Review code changes across logic, security, concurrency, and test coverage. Use when conducting pull request reviews, diff inspections, or auditing commit changes before merge.",
487
496
  "version": "1.0.0"
488
497
  },
489
498
  {
@@ -491,7 +500,7 @@
491
500
  "name": "Repo Quality Audit",
492
501
  "category": "architecture_and_analysis",
493
502
  "path": ".agents/skills/repo-quality-audit/SKILL.md",
494
- "summary": "Quality audit of a whole codebase: bugs, security risks, concurrency and scale bottlenecks, missing test coverage, and code bloat with 'Fix this first' priority.",
503
+ "summary": "Comprehensive codebase quality audit covering bugs, security, bottlenecks, and bloat. Use when auditing an entire project, evaluating repository health, or prioritizing technical debt.",
495
504
  "version": "1.0.0"
496
505
  },
497
506
  {
@@ -499,7 +508,7 @@
499
508
  "name": "Technical Debt Harvester",
500
509
  "category": "architecture_and_analysis",
501
510
  "path": ".agents/skills/technical-debt-harvester/SKILL.md",
502
- "summary": "Harvest shortcut: comments into a tracked debt ledger so deliberate compromises do not rot into forgotten tech debt.",
511
+ "summary": "Harvest shortcut: comments into a tracked technical debt ledger. Use when auditing code compromises, tracking deferred refactorings, or scanning for shortcut markers.",
503
512
  "version": "1.0.0"
504
513
  },
505
514
  {
@@ -507,7 +516,79 @@
507
516
  "name": "Lean Impact Scoreboard",
508
517
  "category": "architecture_and_analysis",
509
518
  "path": ".agents/skills/lean-impact-scoreboard/SKILL.md",
510
- "summary": "Display the measured impact scoreboard (code reduction %, token optimization %, cost reduction %, test rigor) from lean engineering benchmarks.",
519
+ "summary": "Display empirical impact scoreboards (code reduction, token savings, mutation rigor). Use when reviewing lean engineering benchmarks, token throughput, or reporting quality metrics.",
520
+ "version": "1.0.0"
521
+ },
522
+ {
523
+ "id": "agentless-qa-repair",
524
+ "name": "Agentless QA Repair",
525
+ "category": "verification_and_resilience",
526
+ "path": ".agents/skills/agentless-qa-repair/SKILL.md",
527
+ "summary": "Repair broken test scripts and Page Classes using an Agentless 3-phase flow: localization, candidate synthesis, and minimal diff validation.",
528
+ "version": "1.0.0"
529
+ },
530
+ {
531
+ "id": "qa-aci-interface",
532
+ "name": "QA Agent-Computer Interface",
533
+ "category": "architecture_and_analysis",
534
+ "path": ".agents/skills/qa-aci-interface/SKILL.md",
535
+ "summary": "Safe Agent-Computer Interface for inspecting code windows (40-50 lines), surgical editing with pre-commit AST checks, and distilled test execution.",
536
+ "version": "1.0.0"
537
+ },
538
+ {
539
+ "id": "qa-memory-os",
540
+ "name": "QA Test Memory OS",
541
+ "category": "context_and_optimization",
542
+ "path": ".agents/skills/qa-memory-os/SKILL.md",
543
+ "summary": "Hierarchical 3-tier memory operating system for test automation: Core Memory blocks, Recall step logs, and Archival semantic store with AUT version scoping.",
544
+ "version": "1.0.0"
545
+ },
546
+ {
547
+ "id": "event-stream-qa-orchestrator",
548
+ "name": "EventStream QA Orchestrator",
549
+ "category": "context_and_optimization",
550
+ "path": ".agents/skills/event-stream-qa-orchestrator/SKILL.md",
551
+ "summary": "Immutable EventStream orchestrator recording deterministic action/observation timelines with SHA-256 hash chains and reversible checkpoint rollbacks.",
552
+ "version": "1.0.0"
553
+ },
554
+ {
555
+ "id": "web-agent-gym-benchmarking",
556
+ "name": "Web Agent Gym Benchmarking",
557
+ "category": "test_automation_and_execution",
558
+ "path": ".agents/skills/web-agent-gym-benchmarking/SKILL.md",
559
+ "summary": "Empirical benchmark harness evaluating web agents and Page Classes against standardized enterprise tasks with headless <200ms latency budgets and ground-truth DB state verification.",
560
+ "version": "1.0.0"
561
+ },
562
+ {
563
+ "id": "tot-exploratory-testing",
564
+ "name": "Tree-of-Thoughts Exploratory Testing",
565
+ "category": "test_automation_and_execution",
566
+ "path": ".agents/skills/tot-exploratory-testing/SKILL.md",
567
+ "summary": "Non-linear Tree/Graph-of-Thoughts exploratory testing engine exploring Happy Path, Boundary/Race, and Negative/Chaos branches with Beam Search risk scoring and multi-hypothesis RCA.",
568
+ "version": "1.0.0"
569
+ },
570
+ {
571
+ "id": "actor-qa-swarm",
572
+ "name": "Actor QA Swarm",
573
+ "category": "context_and_optimization",
574
+ "path": ".agents/skills/actor-qa-swarm/SKILL.md",
575
+ "summary": "Asynchronous Actor Model message broker and matrix sharding coordinator for multi-agent test execution.",
576
+ "version": "1.0.0"
577
+ },
578
+ {
579
+ "id": "mipro-prompt-compiler",
580
+ "name": "MIPROv2 Prompt Compiler",
581
+ "category": "architecture_and_analysis",
582
+ "path": ".agents/skills/mipro-prompt-compiler/SKILL.md",
583
+ "summary": "MIPROv2 Bayesian teleprompter optimizer and few-shot compiler tuning prompt instructions against AST mutation kill scores.",
584
+ "version": "1.0.0"
585
+ },
586
+ {
587
+ "id": "review-spec",
588
+ "name": "Review Spec (Goldfish Protocol)",
589
+ "category": "architecture_and_analysis",
590
+ "path": ".agents/skills/review-spec/SKILL.md",
591
+ "summary": "Stress-test specifications, user stories, and BDD feature files with zero-context rigor. Use when reviewing requirements, user stories, or acceptance criteria before code generation.",
511
592
  "version": "1.0.0"
512
593
  }
513
594
  ]
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "$schema": "https://raw.githubusercontent.com/TeeVee998/Synapse-Hub/main/docs/schemas/synapse.config.schema.json",
3
- "version": "2.6.0",
3
+ "version": "3.0.0",
4
4
  "quality_gates": {
5
5
  "mutation_min_score": 80,
6
6
  "gates": {
@@ -1,6 +1,6 @@
1
1
  # CLAUDE.md — Synapse-Hub Guidelines for Claude Code
2
2
 
3
- > **Author & Creator:** Thế Vị (@TeeVee998) <https://github.com/TeeVee998/Synapse-Hub>
3
+ > **Author & Creator:** Thế Vị (@TeeVee998) <https://github.com/TeeVee998/Synapse-Hub>
4
4
  > **License:** MIT License (Mandatory Attribution Preservation)
5
5
 
6
6
  <!-- ============================================================================== -->
@@ -17,7 +17,7 @@ In accordance with the MIT License, the original copyright notice crediting **Th
17
17
  ---
18
18
 
19
19
  ## ⚡ Quick Commands
20
- - Verify 9 Quality Gates: `npx synapse-hub verify` (or `python tools/verify_all.py`)
20
+ - Verify 10 Quality Gates: `npx synapse-hub verify` (or `python tools/verify_all.py`)
21
21
  - Project Health Audit: `npx synapse-hub analyze` (or `python tools/analyze_project.py`)
22
22
  - Code Linter & Fake-Pass Sentinel: `npx synapse-hub lint` (or `python tools/infer_linter.py`)
23
23
  - Verify Author Attribution: `python tools/author_integrity.py`
@@ -6,8 +6,8 @@
6
6
  <!-- ============================================================================== -->
7
7
 
8
8
 
9
- > **Project:** Synapse-Hub Enterprise QA Automation
10
- > **Author:** Thế Vị (@TeeVee998) — MIT License
9
+ > **Project:** Synapse-Hub Enterprise QA Automation
10
+ > **Author:** Thế Vị (@TeeVee998) — MIT License
11
11
 
12
12
  ## Coding Invariants
13
13
  - Enforce Clean Page Object Model (POM) with Flat Architecture.
@@ -15,7 +15,7 @@
15
15
  | **Flaky Test Detection & Quarantine Governance ("flaky")** | `tools/flaky_detector.py` | `agent-qa flaky --detect` (or `npx synapse-hub flaky`) |
16
16
  | **Executive Project Health & Quality Dashboard ("dashboard")** | `tools/dashboard_generator.py` | `agent-qa dashboard` (or `npx synapse-hub dashboard`) |
17
17
  | **Clean Uninstall of AI Bridges & Global Plugins ("uninstall")** | `tools/cli.py` | `agent-qa uninstall` (or `npx synapse-hub uninstall`) |
18
- | **Comprehensive Health & AST Analysis ("analyze project")** | `tools/analyze_project.py` | `python tools/analyze_project.py [target]` (or `agent-qa analyze`).<br/>*Post-Audit:* Stages, commits, and pushes `PROJECT_HEALTH_REPORT.md` & `repo_map.txt` to project Git. |
18
+ | **Comprehensive Health & AST Analysis ("analyze project")** | `tools/analyze_project.py` | `python tools/analyze_project.py [target]` (or `agent-qa analyze`).<br/>*Post-Audit:* Stages and commits `PROJECT_HEALTH_REPORT.md` & `repo_map.txt` locally; confirms with user before pushing to remote. |
19
19
  | **Action Safety Firewall (Environment Protection)** | `tools/safety_firewall.py` | `python tools/safety_firewall.py --text "Delete" --action click` (or `agent-qa safety-check`) |
20
20
  | **API Contract Drift (Breaking Change Detection)** | `tools/api_drift_sentinel.py` | `python tools/api_drift_sentinel.py --old base.json --new curr.json` (or `agent-qa contract-drift`) |
21
21
  | **Autonomous API Fuzzing & Chaos Breaker** | `tools/api_fuzzer.py` | `agent-qa fuzz-api --base-url <url> --spec <swagger.json>` (Catches 500, DB leaks, SLA breach) |
package/tools/__init__.py CHANGED
@@ -4,12 +4,29 @@ Synapse Hub — Enterprise AI Agent Quality Engineering & Automated Testing Tool
4
4
  Author: Thế Vị (@TeeVee998)
5
5
  Repository: https://github.com/TeeVee998/Synapse-Hub
6
6
  License: MIT
7
+
8
+ Domain Packages:
9
+ - tools.core: Execution engines, 10 DoD Quality Gates, setup, CLI, AST maps.
10
+ - tools.lint: Static code defect, encoding, author integrity, and AI doc sentinels.
11
+ - tools.report: HTML dashboards, spreadsheets, telemetry correlation, and metrics.
12
+ - tools.heal: Locator healing, episodic Reflexion memory, and agentless patching.
13
+ - tools.perf: Flakiness detection, JMeter plans, BFCL benchmarks, and matrix sharding.
14
+ - tools.mcp: Model Context Protocol servers (core QA and Excel manipulation).
7
15
  """
8
16
 
9
- __version__ = "2.6.0"
17
+ __version__ = "3.0.0"
10
18
  __author__ = "Thế Vị (@TeeVee998)"
11
19
 
20
+ # Expose domain packages
21
+ from tools import core, heal, lint, mcp, perf, report # noqa: F401
22
+
12
23
  __all__ = [
24
+ "core",
25
+ "heal",
26
+ "lint",
27
+ "mcp",
28
+ "perf",
29
+ "report",
13
30
  "verify_all",
14
31
  "infer_linter",
15
32
  "micro_mutator",
@@ -0,0 +1,158 @@
1
+ #!/usr/bin/env python3
2
+ # SPDX-FileCopyrightText: Copyright (c) 2026 Thế Vị (@TeeVee998). All rights reserved.
3
+ # SPDX-License-Identifier: MIT
4
+ # Project: Synapse-Hub (https://github.com/TeeVee998/Synapse-Hub)
5
+
6
+ """
7
+ tools/_openapi_parser.py — Shared OpenAPI & Swagger Specification Parser
8
+ -------------------------------------------------------------------------
9
+ Internal shared helper module consolidating OpenAPI 3.0 and Swagger 2.0
10
+ schema ingestion, $ref dereferencing, endpoint extraction, and boundary
11
+ value test scenario synthesis across API testing tools.
12
+ """
13
+
14
+ import os
15
+ import sys
16
+ import json
17
+ from typing import Dict, Any, List
18
+
19
+ if hasattr(sys.stdout, 'reconfigure'):
20
+ try:
21
+ sys.stdout.reconfigure(encoding='utf-8')
22
+ sys.stderr.reconfigure(encoding='utf-8')
23
+ except Exception:
24
+ pass
25
+
26
+
27
+ def load_spec(spec_input: Any) -> Dict[str, Any]:
28
+ """
29
+ Loads OpenAPI / Swagger spec from a file path, raw JSON string, or dict.
30
+ """
31
+ if isinstance(spec_input, dict):
32
+ return spec_input
33
+ if isinstance(spec_input, str):
34
+ if os.path.exists(spec_input):
35
+ with open(spec_input, "r", encoding="utf-8") as f:
36
+ return json.load(f)
37
+ try:
38
+ return json.loads(spec_input)
39
+ except Exception:
40
+ raise ValueError(f"Unable to parse spec input as JSON file or string: {spec_input[:100]}")
41
+ raise TypeError(f"Expected dict, str path, or JSON string; got {type(spec_input)}")
42
+
43
+
44
+ def resolve_ref(spec_data: Dict[str, Any], ref_str: str) -> Dict[str, Any]:
45
+ """
46
+ Resolves local JSON pointers such as '#/components/schemas/User' or '#/definitions/User'.
47
+ """
48
+ if not ref_str.startswith("#/"):
49
+ return {}
50
+ parts = ref_str[2:].split("/")
51
+ curr = spec_data
52
+ for p in parts:
53
+ if isinstance(curr, dict) and p in curr:
54
+ curr = curr[p]
55
+ else:
56
+ return {}
57
+ return curr if isinstance(curr, dict) else {}
58
+
59
+
60
+ def extract_endpoints(spec_data: Dict[str, Any]) -> List[Dict[str, Any]]:
61
+ """
62
+ Parses paths and HTTP operations into a normalized list of API endpoints.
63
+ """
64
+ endpoints = []
65
+ paths = spec_data.get("paths", {})
66
+
67
+ for path, methods in paths.items():
68
+ if not isinstance(methods, dict):
69
+ continue
70
+ for method, details in methods.items():
71
+ if method.lower() not in ("get", "post", "put", "delete", "patch", "options", "head"):
72
+ continue
73
+ if not isinstance(details, dict):
74
+ continue
75
+
76
+ summary = details.get("summary", details.get("operationId", f"{method.upper()} {path}"))
77
+ operation_id = details.get("operationId", f"{method.lower()}_{path.replace('/', '_').strip('_')}")
78
+ tags = details.get("tags", ["General"])
79
+
80
+ # Parameters (Path, Query, Header)
81
+ parameters = details.get("parameters", [])
82
+
83
+ # Request Body Schema (OpenAPI 3.0 application/json)
84
+ req_content = details.get("requestBody", {}).get("content", {})
85
+ schema = req_content.get("application/json", {}).get("schema", {})
86
+ if "$ref" in schema:
87
+ schema = resolve_ref(spec_data, schema["$ref"])
88
+
89
+ # Swagger 2.0 body parameter fallback
90
+ if not schema:
91
+ for param in parameters:
92
+ if param.get("in") == "body" and "schema" in param:
93
+ s = param["schema"]
94
+ schema = resolve_ref(spec_data, s["$ref"]) if "$ref" in s else s
95
+ break
96
+
97
+ # Response schemas
98
+ responses = details.get("responses", {})
99
+
100
+ endpoints.append({
101
+ "path": path,
102
+ "method": method.upper(),
103
+ "summary": summary,
104
+ "operation_id": operation_id,
105
+ "tags": tags,
106
+ "parameters": parameters,
107
+ "request_schema": schema,
108
+ "responses": responses
109
+ })
110
+
111
+ return endpoints
112
+
113
+
114
+ def generate_boundary_scenarios(field_name: str, field_schema: Dict[str, Any]) -> List[Dict[str, Any]]:
115
+ """
116
+ Generates standard positive and boundary value test scenarios for a given field schema.
117
+ """
118
+ boundaries = []
119
+ f_type = field_schema.get("type", "string")
120
+
121
+ if f_type == "string":
122
+ min_l = field_schema.get("minLength", 1)
123
+ max_l = field_schema.get("maxLength", 50)
124
+ boundaries.append({"scenario": f"{field_name} Empty String", "value": "", "expected": 400})
125
+ boundaries.append({
126
+ "scenario": f"{field_name} Below MinLength ({min_l - 1} chars)",
127
+ "value": "A" * max(0, min_l - 1),
128
+ "expected": 400 if min_l > 0 else 200
129
+ })
130
+ boundaries.append({
131
+ "scenario": f"{field_name} Exact MaxLength ({max_l} chars)",
132
+ "value": "A" * max_l,
133
+ "expected": 200
134
+ })
135
+ boundaries.append({
136
+ "scenario": f"{field_name} Exceed MaxLength ({max_l + 1} chars)",
137
+ "value": "A" * (max_l + 1),
138
+ "expected": 400
139
+ })
140
+ boundaries.append({
141
+ "scenario": f"{field_name} Special & XSS Payload",
142
+ "value": "<script>alert(1)</script>",
143
+ "expected": 400
144
+ })
145
+
146
+ elif f_type in ("integer", "number"):
147
+ minimum = field_schema.get("minimum", 0)
148
+ maximum = field_schema.get("maximum", 1000)
149
+ boundaries.append({"scenario": f"{field_name} Negative Value ({minimum - 1})", "value": minimum - 1, "expected": 400})
150
+ boundaries.append({"scenario": f"{field_name} Boundary Minimum ({minimum})", "value": minimum, "expected": 200})
151
+ boundaries.append({"scenario": f"{field_name} Boundary Maximum ({maximum})", "value": maximum, "expected": 200})
152
+ boundaries.append({"scenario": f"{field_name} Exceed Maximum ({maximum + 1})", "value": maximum + 1, "expected": 400})
153
+ boundaries.append({"scenario": f"{field_name} 32-bit Integer Overflow", "value": 2147483648, "expected": 400})
154
+
155
+ elif f_type == "boolean":
156
+ boundaries.append({"scenario": f"{field_name} Invalid String Instead of Boolean", "value": "not_a_bool", "expected": 400})
157
+
158
+ return boundaries
@@ -85,15 +85,20 @@ class OverlayInterceptVector(MutationVector):
85
85
  healed = False
86
86
  patch = None
87
87
  if os.path.exists(CACHE_DB):
88
- conn = sqlite3.connect(CACHE_DB)
89
- cur = conn.cursor()
90
- cur.execute("SELECT groovy_patch FROM healing_cache WHERE error_signature LIKE '%ElementClickIntercepted%' LIMIT 1")
91
- row = cur.fetchone()
92
- conn.close()
93
- if row:
94
- patch = row[0]
95
- if "click" in patch and ("JavascriptExecutor" in patch or "jsClick" in patch or "clickJS" in patch):
96
- healed = True
88
+ try:
89
+ conn = sqlite3.connect(CACHE_DB)
90
+ try:
91
+ cur = conn.cursor()
92
+ cur.execute("SELECT groovy_patch FROM healing_cache WHERE error_signature LIKE '%ElementClickIntercepted%' LIMIT 1")
93
+ row = cur.fetchone()
94
+ if row:
95
+ patch = row[0]
96
+ if "click" in patch and ("JavascriptExecutor" in patch or "jsClick" in patch or "clickJS" in patch):
97
+ healed = True
98
+ finally:
99
+ conn.close()
100
+ except sqlite3.Error:
101
+ healed = False
97
102
 
98
103
  elapsed_ms = (time.time() - start) * 1000
99
104
  return {
@@ -121,15 +126,20 @@ class LocatorDriftVector(MutationVector):
121
126
  healed = False
122
127
  patch = None
123
128
  if os.path.exists(CACHE_DB):
124
- conn = sqlite3.connect(CACHE_DB)
125
- cur = conn.cursor()
126
- cur.execute("SELECT groovy_patch FROM healing_cache WHERE error_signature LIKE '%StaleElement%' LIMIT 1")
127
- row = cur.fetchone()
128
- conn.close()
129
- if row:
130
- patch = row[0]
131
- if "retry" in patch.lower() or "for (" in patch or "findElement" in patch:
132
- healed = True
129
+ try:
130
+ conn = sqlite3.connect(CACHE_DB)
131
+ try:
132
+ cur = conn.cursor()
133
+ cur.execute("SELECT groovy_patch FROM healing_cache WHERE error_signature LIKE '%StaleElement%' LIMIT 1")
134
+ row = cur.fetchone()
135
+ if row:
136
+ patch = row[0]
137
+ if "retry" in patch.lower() or "for (" in patch or "findElement" in patch:
138
+ healed = True
139
+ finally:
140
+ conn.close()
141
+ except sqlite3.Error:
142
+ healed = False
133
143
 
134
144
  elapsed_ms = (time.time() - start) * 1000
135
145
  return {
@@ -201,12 +211,14 @@ class DataCollisionVector(MutationVector):
201
211
  if os.path.exists(CACHE_DB):
202
212
  try:
203
213
  conn = sqlite3.connect(CACHE_DB)
204
- cur = conn.cursor()
205
- cur.execute("SELECT groovy_patch FROM healing_cache WHERE error_signature LIKE '%Duplicate_Code%'")
206
- row = cur.fetchone()
207
- conn.close()
208
- if row and ("uniqueCode" in row[0] or "currentTimeMillis" in row[0]):
209
- healed = True
214
+ try:
215
+ cur = conn.cursor()
216
+ cur.execute("SELECT groovy_patch FROM healing_cache WHERE error_signature LIKE '%Duplicate_Code%'")
217
+ row = cur.fetchone()
218
+ if row and ("uniqueCode" in row[0] or "currentTimeMillis" in row[0]):
219
+ healed = True
220
+ finally:
221
+ conn.close()
210
222
  except sqlite3.Error:
211
223
  healed = False
212
224
 
@@ -247,7 +259,7 @@ class BomContaminationVector(MutationVector):
247
259
  # 1. Inject BOM
248
260
  with open(test_file, "wb") as f:
249
261
  f.write(b"\xef\xbb\xbf// Test BOM contamination\n")
250
-
262
+
251
263
  # 2. Detect BOM
252
264
  with open(test_file, "rb") as f:
253
265
  header = f.read(3)
@@ -261,7 +273,7 @@ class BomContaminationVector(MutationVector):
261
273
  cleaned = raw[3:]
262
274
  with open(test_file, "wb") as f:
263
275
  f.write(cleaned)
264
-
276
+
265
277
  # Re-verify
266
278
  with open(test_file, "rb") as f:
267
279
  if f.read(3) != b"\xef\xbb\xbf":
@@ -297,7 +309,7 @@ class MachinePathLeakVector(MutationVector):
297
309
  sample_path = "C:\\Workspace\\Project\\tools\\verify_all.py"
298
310
  detected = "C:\\" in sample_path or sample_path.startswith("/")
299
311
  healed = False
300
-
312
+
301
313
  # Simulate relative path conversion
302
314
  relative_path = os.path.relpath(os.path.join(REPO_ROOT, "tools", "verify_all.py"), REPO_ROOT)
303
315
  if not relative_path.startswith("/") and "C:" not in relative_path:
@@ -328,7 +340,7 @@ class RawXPathInScriptVector(MutationVector):
328
340
  start = time.time()
329
341
  sample_bad_script = 'WebUI.click(findTestObject("Object Repository/button_Save"))'
330
342
  detected = "findTestObject" in sample_bad_script or "By.xpath" in sample_bad_script
331
-
343
+
332
344
  # Self-healing translation: convert to Clean POM method call
333
345
  healed_script = "CommonCategoryPage.saveCareer(careerCode, careerName)"
334
346
  healed = "findTestObject" not in healed_script and "CommonCategoryPage" in healed_script
@@ -393,7 +405,7 @@ class CanaryArena:
393
405
  print(f"{BOLD}{CYAN} (Dry-Run Simulation Benchmark - Heuristic Evaluation) {RESET}")
394
406
  print(f"{BOLD}{CYAN}======================================================================{RESET}")
395
407
  print(f"Target Repository : {REPO_ROOT}")
396
- print(f"Evaluation Mode : Isolated Memory Sandbox & Offline Local Resolvers")
408
+ print("Evaluation Mode : Isolated Memory Sandbox & Offline Local Resolvers")
397
409
  print(f"Total Vectors : {len(self.vectors)} Failure Vectors")
398
410
  print(f"Timestamp : {datetime.now().strftime('%Y-%m-%d %H:%M:%S')}\n")
399
411
 
@@ -442,7 +454,7 @@ class CanaryArena:
442
454
  print(f" Autonomous Healing Rate : {GREEN if resolution_rate == 100 else RED}{resolution_rate:.1f}% ({healed_count}/{len(self.vectors)}){RESET}")
443
455
  print(f" Mean Time To Repair (MTTR): {GREEN}{avg_mttr:.2f} ms{RESET} per incident")
444
456
  print(f" Total Token Consumption : {GREEN}{total_tokens} tokens{RESET} (100% Offline Local)")
445
-
457
+
446
458
  # Run verify_all gate
447
459
  print(f"\n{BOLD}[POST-BENCHMARK DoD INTEGRITY CHECK]{RESET}")
448
460
  verify_script = os.path.join(SCRIPT_DIR, "verify_all.py")