@agentic-qe/v3 3.0.0-alpha.6 → 3.0.0-alpha.8

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 (612) hide show
  1. package/assets/agents/v3/subagents/v3-qe-code-reviewer.md +339 -0
  2. package/assets/agents/v3/subagents/v3-qe-integration-reviewer.md +344 -0
  3. package/assets/agents/v3/subagents/v3-qe-performance-reviewer.md +351 -0
  4. package/assets/agents/v3/subagents/v3-qe-security-reviewer.md +374 -0
  5. package/assets/agents/v3/subagents/v3-qe-tdd-green.md +334 -0
  6. package/assets/agents/v3/subagents/v3-qe-tdd-red.md +329 -0
  7. package/assets/agents/v3/subagents/v3-qe-tdd-refactor.md +361 -0
  8. package/assets/agents/v3/v3-qe-accessibility-auditor.md +266 -0
  9. package/assets/agents/v3/v3-qe-bdd-generator.md +279 -0
  10. package/assets/agents/v3/v3-qe-chaos-engineer.md +265 -0
  11. package/assets/agents/v3/v3-qe-code-complexity.md +298 -0
  12. package/assets/agents/v3/v3-qe-code-intelligence.md +262 -0
  13. package/assets/agents/v3/v3-qe-contract-validator.md +267 -0
  14. package/assets/agents/v3/v3-qe-coverage-specialist.md +227 -0
  15. package/assets/agents/v3/v3-qe-defect-predictor.md +251 -0
  16. package/assets/agents/v3/v3-qe-dependency-mapper.md +277 -0
  17. package/assets/agents/v3/v3-qe-deployment-advisor.md +275 -0
  18. package/assets/agents/v3/v3-qe-flaky-hunter.md +248 -0
  19. package/assets/agents/v3/v3-qe-fleet-commander.md +293 -0
  20. package/assets/agents/v3/v3-qe-gap-detector.md +260 -0
  21. package/assets/agents/v3/v3-qe-graphql-tester.md +308 -0
  22. package/assets/agents/v3/v3-qe-impact-analyzer.md +299 -0
  23. package/assets/agents/v3/v3-qe-integration-tester.md +238 -0
  24. package/assets/agents/v3/v3-qe-kg-builder.md +273 -0
  25. package/assets/agents/v3/v3-qe-learning-coordinator.md +226 -0
  26. package/assets/agents/v3/v3-qe-load-tester.md +280 -0
  27. package/assets/agents/v3/v3-qe-metrics-optimizer.md +300 -0
  28. package/assets/agents/v3/v3-qe-mutation-tester.md +301 -0
  29. package/assets/agents/v3/v3-qe-parallel-executor.md +240 -0
  30. package/assets/agents/v3/v3-qe-pattern-learner.md +271 -0
  31. package/assets/agents/v3/v3-qe-performance-tester.md +262 -0
  32. package/assets/agents/v3/v3-qe-property-tester.md +247 -0
  33. package/assets/agents/v3/v3-qe-quality-gate.md +218 -0
  34. package/assets/agents/v3/v3-qe-queen-coordinator.md +214 -0
  35. package/assets/agents/v3/v3-qe-qx-partner.md +313 -0
  36. package/assets/agents/v3/v3-qe-regression-analyzer.md +322 -0
  37. package/assets/agents/v3/v3-qe-requirements-validator.md +360 -0
  38. package/assets/agents/v3/v3-qe-responsive-tester.md +311 -0
  39. package/assets/agents/v3/v3-qe-retry-handler.md +256 -0
  40. package/assets/agents/v3/v3-qe-risk-assessor.md +273 -0
  41. package/assets/agents/v3/v3-qe-root-cause-analyzer.md +286 -0
  42. package/assets/agents/v3/v3-qe-security-auditor.md +299 -0
  43. package/assets/agents/v3/v3-qe-security-scanner.md +235 -0
  44. package/assets/agents/v3/v3-qe-tdd-specialist.md +239 -0
  45. package/assets/agents/v3/v3-qe-test-architect.md +233 -0
  46. package/assets/agents/v3/v3-qe-transfer-specialist.md +295 -0
  47. package/assets/agents/v3/v3-qe-visual-tester.md +232 -0
  48. package/assets/skills/accessibility-testing/SKILL.md +216 -0
  49. package/assets/skills/agentdb-advanced/SKILL.md +550 -0
  50. package/assets/skills/agentdb-learning/SKILL.md +545 -0
  51. package/assets/skills/agentdb-memory-patterns/SKILL.md +339 -0
  52. package/assets/skills/agentdb-optimization/SKILL.md +509 -0
  53. package/assets/skills/agentdb-vector-search/SKILL.md +339 -0
  54. package/assets/skills/agentic-jujutsu/SKILL.md +645 -0
  55. package/assets/skills/agentic-quality-engineering/SKILL.md +335 -0
  56. package/assets/skills/api-testing-patterns/SKILL.md +294 -0
  57. package/assets/skills/aqe-v2-v3-migration/skill.md +322 -0
  58. package/assets/skills/brutal-honesty-review/README.md +218 -0
  59. package/assets/skills/brutal-honesty-review/SKILL.md +235 -0
  60. package/assets/skills/brutal-honesty-review/resources/assessment-rubrics.md +295 -0
  61. package/assets/skills/brutal-honesty-review/resources/review-template.md +102 -0
  62. package/assets/skills/brutal-honesty-review/scripts/assess-code.sh +179 -0
  63. package/assets/skills/brutal-honesty-review/scripts/assess-tests.sh +223 -0
  64. package/assets/skills/bug-reporting-excellence/SKILL.md +225 -0
  65. package/assets/skills/chaos-engineering-resilience/SKILL.md +158 -0
  66. package/assets/skills/cicd-pipeline-qe-orchestrator/README.md +304 -0
  67. package/assets/skills/cicd-pipeline-qe-orchestrator/SKILL.md +315 -0
  68. package/assets/skills/cicd-pipeline-qe-orchestrator/resources/workflows/microservice-pipeline.md +239 -0
  69. package/assets/skills/cicd-pipeline-qe-orchestrator/resources/workflows/mobile-pipeline.md +375 -0
  70. package/assets/skills/cicd-pipeline-qe-orchestrator/resources/workflows/monolith-pipeline.md +268 -0
  71. package/assets/skills/code-review-quality/SKILL.md +227 -0
  72. package/assets/skills/compatibility-testing/SKILL.md +205 -0
  73. package/assets/skills/compliance-testing/SKILL.md +225 -0
  74. package/assets/skills/consultancy-practices/SKILL.md +202 -0
  75. package/assets/skills/context-driven-testing/SKILL.md +196 -0
  76. package/assets/skills/contract-testing/SKILL.md +222 -0
  77. package/assets/skills/database-testing/SKILL.md +244 -0
  78. package/assets/skills/exploratory-testing-advanced/SKILL.md +201 -0
  79. package/assets/skills/flow-nexus-neural/SKILL.md +738 -0
  80. package/assets/skills/flow-nexus-platform/SKILL.md +1157 -0
  81. package/assets/skills/flow-nexus-swarm/SKILL.md +610 -0
  82. package/assets/skills/github-code-review/SKILL.md +1140 -0
  83. package/assets/skills/github-multi-repo/SKILL.md +874 -0
  84. package/assets/skills/github-project-management/SKILL.md +1277 -0
  85. package/assets/skills/github-release-management/SKILL.md +1081 -0
  86. package/assets/skills/github-workflow-automation/SKILL.md +1065 -0
  87. package/assets/skills/hive-mind-advanced/SKILL.md +712 -0
  88. package/assets/skills/holistic-testing-pact/SKILL.md +171 -0
  89. package/assets/skills/hooks-automation/SKILL.md +1201 -0
  90. package/assets/skills/localization-testing/SKILL.md +221 -0
  91. package/assets/skills/mobile-testing/SKILL.md +219 -0
  92. package/assets/skills/mutation-testing/SKILL.md +229 -0
  93. package/assets/skills/n8n-expression-testing/SKILL.md +434 -0
  94. package/assets/skills/n8n-integration-testing-patterns/SKILL.md +540 -0
  95. package/assets/skills/n8n-security-testing/SKILL.md +599 -0
  96. package/assets/skills/n8n-trigger-testing-strategies/SKILL.md +541 -0
  97. package/assets/skills/n8n-workflow-testing-fundamentals/SKILL.md +447 -0
  98. package/assets/skills/pair-programming/SKILL.md +1202 -0
  99. package/assets/skills/performance-analysis/SKILL.md +563 -0
  100. package/assets/skills/performance-testing/SKILL.md +310 -0
  101. package/assets/skills/quality-metrics/SKILL.md +225 -0
  102. package/assets/skills/reasoningbank-agentdb/SKILL.md +446 -0
  103. package/assets/skills/reasoningbank-intelligence/SKILL.md +201 -0
  104. package/assets/skills/refactoring-patterns/SKILL.md +205 -0
  105. package/assets/skills/regression-testing/SKILL.md +227 -0
  106. package/assets/skills/risk-based-testing/SKILL.md +206 -0
  107. package/assets/skills/security-testing/SKILL.md +306 -0
  108. package/assets/skills/sherlock-review/SKILL.md +250 -0
  109. package/assets/skills/shift-left-testing/SKILL.md +225 -0
  110. package/assets/skills/shift-right-testing/SKILL.md +227 -0
  111. package/assets/skills/six-thinking-hats/README.md +190 -0
  112. package/assets/skills/six-thinking-hats/SKILL.md +280 -0
  113. package/assets/skills/six-thinking-hats/resources/examples/api-testing-example.md +345 -0
  114. package/assets/skills/six-thinking-hats/resources/templates/solo-session-template.md +167 -0
  115. package/assets/skills/six-thinking-hats/resources/templates/team-session-template.md +336 -0
  116. package/assets/skills/skill-builder/SKILL.md +910 -0
  117. package/assets/skills/sparc-methodology/SKILL.md +1115 -0
  118. package/assets/skills/stream-chain/SKILL.md +563 -0
  119. package/assets/skills/swarm-advanced/SKILL.md +973 -0
  120. package/assets/skills/swarm-orchestration/SKILL.md +179 -0
  121. package/assets/skills/tdd-london-chicago/SKILL.md +244 -0
  122. package/assets/skills/technical-writing/SKILL.md +178 -0
  123. package/assets/skills/test-automation-strategy/SKILL.md +230 -0
  124. package/assets/skills/test-data-management/SKILL.md +270 -0
  125. package/assets/skills/test-design-techniques/SKILL.md +244 -0
  126. package/assets/skills/test-environment-management/SKILL.md +243 -0
  127. package/assets/skills/test-reporting-analytics/SKILL.md +214 -0
  128. package/assets/skills/testability-scoring/README.md +71 -0
  129. package/assets/skills/testability-scoring/SKILL.md +346 -0
  130. package/assets/skills/testability-scoring/resources/templates/config.template.js +84 -0
  131. package/assets/skills/testability-scoring/resources/templates/testability-scoring.spec.template.js +532 -0
  132. package/assets/skills/testability-scoring/scripts/generate-html-report.js +1007 -0
  133. package/assets/skills/testability-scoring/scripts/run-assessment.sh +70 -0
  134. package/assets/skills/v3-qe-chaos-resilience/SKILL.md +238 -0
  135. package/assets/skills/v3-qe-code-intelligence/SKILL.md +209 -0
  136. package/assets/skills/v3-qe-contract-testing/SKILL.md +218 -0
  137. package/assets/skills/v3-qe-coverage-analysis/SKILL.md +187 -0
  138. package/assets/skills/v3-qe-defect-intelligence/SKILL.md +205 -0
  139. package/assets/skills/v3-qe-learning-optimization/SKILL.md +238 -0
  140. package/assets/skills/v3-qe-quality-assessment/SKILL.md +213 -0
  141. package/assets/skills/v3-qe-requirements-validation/SKILL.md +248 -0
  142. package/assets/skills/v3-qe-test-execution/SKILL.md +182 -0
  143. package/assets/skills/v3-qe-test-generation/SKILL.md +141 -0
  144. package/assets/skills/v3-qe-visual-accessibility/SKILL.md +242 -0
  145. package/assets/skills/verification-quality/SKILL.md +649 -0
  146. package/assets/skills/visual-testing-advanced/SKILL.md +219 -0
  147. package/assets/skills/xp-practices/SKILL.md +229 -0
  148. package/dist/cli/bundle.js +23 -13
  149. package/dist/init/agents-installer.js +4 -4
  150. package/dist/init/agents-installer.js.map +1 -1
  151. package/dist/init/init-wizard.d.ts.map +1 -1
  152. package/dist/init/init-wizard.js +15 -5
  153. package/dist/init/init-wizard.js.map +1 -1
  154. package/dist/init/skills-installer.js +4 -4
  155. package/dist/init/skills-installer.js.map +1 -1
  156. package/package.json +7 -1
  157. package/docs/analysis/V3-INIT-REQUIREMENTS-ANALYSIS.md +0 -352
  158. package/implementation/README.md +0 -90
  159. package/implementation/adrs/ADR-030-coherence-gated-quality-gates.md +0 -312
  160. package/implementation/adrs/ADR-031-strange-loop-self-awareness.md +0 -484
  161. package/implementation/adrs/ADR-032-time-crystal-scheduling.md +0 -530
  162. package/implementation/adrs/ADR-033-early-exit-testing.md +0 -634
  163. package/implementation/adrs/ADR-034-neural-topology-optimizer.md +0 -589
  164. package/implementation/adrs/ADR-035-causal-discovery.md +0 -610
  165. package/implementation/adrs/ADR-036-result-persistence.md +0 -326
  166. package/implementation/adrs/ADR-037-v3-qe-agent-naming.md +0 -105
  167. package/implementation/adrs/ADR-038-v3-qe-memory-unification.md +0 -154
  168. package/implementation/adrs/ADR-039-v3-qe-mcp-optimization.md +0 -179
  169. package/implementation/adrs/ADR-040-v3-qe-agentic-flow-integration.md +0 -240
  170. package/implementation/adrs/ADR-041-v3-qe-cli-enhancement.md +0 -296
  171. package/implementation/adrs/ADR-042-v3-qe-token-tracking-integration.md +0 -517
  172. package/implementation/adrs/v3-adrs.md +0 -2783
  173. package/implementation/planning/AQE-V3-MASTER-PLAN.md +0 -815
  174. package/security-scan-report-2026-01-11.md +0 -410
  175. package/security-verification-report-2026-01-11.md +0 -278
  176. package/src/benchmarks/performance-benchmarks.ts +0 -646
  177. package/src/benchmarks/run-benchmarks.ts +0 -324
  178. package/src/causal-discovery/causal-graph.ts +0 -450
  179. package/src/causal-discovery/discovery-engine.ts +0 -438
  180. package/src/causal-discovery/index.ts +0 -117
  181. package/src/causal-discovery/types.ts +0 -456
  182. package/src/causal-discovery/weight-matrix.ts +0 -453
  183. package/src/cli/commands/qe-tools.ts +0 -634
  184. package/src/cli/index.ts +0 -1976
  185. package/src/compatibility/agent-mapper.ts +0 -291
  186. package/src/compatibility/cli-adapter.ts +0 -277
  187. package/src/compatibility/config-migrator.ts +0 -334
  188. package/src/compatibility/index.ts +0 -112
  189. package/src/compatibility/mcp-adapter.ts +0 -248
  190. package/src/compatibility/types.ts +0 -156
  191. package/src/coordination/claims/claim-repository.ts +0 -636
  192. package/src/coordination/claims/claim-service.ts +0 -675
  193. package/src/coordination/claims/handoff-manager.ts +0 -535
  194. package/src/coordination/claims/index.ts +0 -276
  195. package/src/coordination/claims/interfaces.ts +0 -687
  196. package/src/coordination/claims/work-stealing.ts +0 -436
  197. package/src/coordination/cross-domain-router.ts +0 -492
  198. package/src/coordination/index.ts +0 -127
  199. package/src/coordination/interfaces.ts +0 -691
  200. package/src/coordination/protocol-executor.ts +0 -760
  201. package/src/coordination/protocols/code-intelligence-index.ts +0 -855
  202. package/src/coordination/protocols/defect-investigation.ts +0 -1184
  203. package/src/coordination/protocols/index.ts +0 -11
  204. package/src/coordination/protocols/learning-consolidation.ts +0 -1181
  205. package/src/coordination/protocols/morning-sync.ts +0 -1055
  206. package/src/coordination/protocols/quality-gate.ts +0 -1566
  207. package/src/coordination/protocols/security-audit.ts +0 -1587
  208. package/src/coordination/queen-coordinator.ts +0 -1176
  209. package/src/coordination/result-saver.ts +0 -780
  210. package/src/coordination/task-executor.ts +0 -1146
  211. package/src/coordination/workflow-orchestrator.ts +0 -1917
  212. package/src/domains/chaos-resilience/coordinator.ts +0 -1032
  213. package/src/domains/chaos-resilience/index.ts +0 -143
  214. package/src/domains/chaos-resilience/interfaces.ts +0 -659
  215. package/src/domains/chaos-resilience/plugin.ts +0 -691
  216. package/src/domains/chaos-resilience/services/chaos-engineer.ts +0 -1097
  217. package/src/domains/chaos-resilience/services/index.ts +0 -19
  218. package/src/domains/chaos-resilience/services/load-tester.ts +0 -799
  219. package/src/domains/chaos-resilience/services/performance-profiler.ts +0 -792
  220. package/src/domains/code-intelligence/coordinator.ts +0 -631
  221. package/src/domains/code-intelligence/index.ts +0 -86
  222. package/src/domains/code-intelligence/interfaces.ts +0 -162
  223. package/src/domains/code-intelligence/plugin.ts +0 -451
  224. package/src/domains/code-intelligence/services/impact-analyzer.ts +0 -567
  225. package/src/domains/code-intelligence/services/index.ts +0 -26
  226. package/src/domains/code-intelligence/services/knowledge-graph.ts +0 -1067
  227. package/src/domains/code-intelligence/services/semantic-analyzer.ts +0 -901
  228. package/src/domains/contract-testing/coordinator.ts +0 -1038
  229. package/src/domains/contract-testing/index.ts +0 -122
  230. package/src/domains/contract-testing/interfaces.ts +0 -458
  231. package/src/domains/contract-testing/plugin.ts +0 -746
  232. package/src/domains/contract-testing/services/api-compatibility.ts +0 -748
  233. package/src/domains/contract-testing/services/contract-validator.ts +0 -1700
  234. package/src/domains/contract-testing/services/index.ts +0 -19
  235. package/src/domains/contract-testing/services/schema-validator.ts +0 -1102
  236. package/src/domains/coverage-analysis/coordinator.ts +0 -485
  237. package/src/domains/coverage-analysis/index.ts +0 -114
  238. package/src/domains/coverage-analysis/interfaces.ts +0 -142
  239. package/src/domains/coverage-analysis/plugin.ts +0 -172
  240. package/src/domains/coverage-analysis/services/coverage-analyzer.ts +0 -449
  241. package/src/domains/coverage-analysis/services/coverage-embedder.ts +0 -733
  242. package/src/domains/coverage-analysis/services/coverage-parser.ts +0 -753
  243. package/src/domains/coverage-analysis/services/gap-detector.ts +0 -592
  244. package/src/domains/coverage-analysis/services/hnsw-index.ts +0 -728
  245. package/src/domains/coverage-analysis/services/index.ts +0 -61
  246. package/src/domains/coverage-analysis/services/risk-scorer.ts +0 -540
  247. package/src/domains/coverage-analysis/services/sublinear-analyzer.ts +0 -747
  248. package/src/domains/defect-intelligence/coordinator.ts +0 -635
  249. package/src/domains/defect-intelligence/index.ts +0 -83
  250. package/src/domains/defect-intelligence/interfaces.ts +0 -152
  251. package/src/domains/defect-intelligence/plugin.ts +0 -483
  252. package/src/domains/defect-intelligence/services/causal-root-cause-analyzer.ts +0 -494
  253. package/src/domains/defect-intelligence/services/defect-predictor.ts +0 -852
  254. package/src/domains/defect-intelligence/services/index.ts +0 -37
  255. package/src/domains/defect-intelligence/services/pattern-learner.ts +0 -738
  256. package/src/domains/defect-intelligence/services/root-cause-analyzer.ts +0 -637
  257. package/src/domains/domain-interface.ts +0 -77
  258. package/src/domains/index.ts +0 -23
  259. package/src/domains/learning-optimization/coordinator.ts +0 -1215
  260. package/src/domains/learning-optimization/index.ts +0 -127
  261. package/src/domains/learning-optimization/interfaces.ts +0 -570
  262. package/src/domains/learning-optimization/plugin.ts +0 -851
  263. package/src/domains/learning-optimization/services/index.ts +0 -29
  264. package/src/domains/learning-optimization/services/learning-coordinator.ts +0 -972
  265. package/src/domains/learning-optimization/services/metrics-optimizer.ts +0 -915
  266. package/src/domains/learning-optimization/services/production-intel.ts +0 -971
  267. package/src/domains/learning-optimization/services/transfer-specialist.ts +0 -723
  268. package/src/domains/quality-assessment/coherence/gate-controller.ts +0 -549
  269. package/src/domains/quality-assessment/coherence/index.ts +0 -211
  270. package/src/domains/quality-assessment/coherence/lambda-calculator.ts +0 -384
  271. package/src/domains/quality-assessment/coherence/partition-detector.ts +0 -469
  272. package/src/domains/quality-assessment/coherence/types.ts +0 -384
  273. package/src/domains/quality-assessment/coordinator.ts +0 -605
  274. package/src/domains/quality-assessment/index.ts +0 -97
  275. package/src/domains/quality-assessment/interfaces.ts +0 -152
  276. package/src/domains/quality-assessment/plugin.ts +0 -496
  277. package/src/domains/quality-assessment/services/coherence-gate.ts +0 -358
  278. package/src/domains/quality-assessment/services/deployment-advisor.ts +0 -571
  279. package/src/domains/quality-assessment/services/index.ts +0 -34
  280. package/src/domains/quality-assessment/services/quality-analyzer.ts +0 -670
  281. package/src/domains/quality-assessment/services/quality-gate.ts +0 -384
  282. package/src/domains/requirements-validation/coordinator.ts +0 -812
  283. package/src/domains/requirements-validation/index.ts +0 -92
  284. package/src/domains/requirements-validation/interfaces.ts +0 -303
  285. package/src/domains/requirements-validation/plugin.ts +0 -576
  286. package/src/domains/requirements-validation/services/bdd-scenario-writer.ts +0 -676
  287. package/src/domains/requirements-validation/services/index.ts +0 -20
  288. package/src/domains/requirements-validation/services/requirements-validator.ts +0 -559
  289. package/src/domains/requirements-validation/services/testability-scorer.ts +0 -639
  290. package/src/domains/security-compliance/coordinator.ts +0 -757
  291. package/src/domains/security-compliance/index.ts +0 -120
  292. package/src/domains/security-compliance/interfaces.ts +0 -434
  293. package/src/domains/security-compliance/plugin.ts +0 -509
  294. package/src/domains/security-compliance/services/compliance-validator.ts +0 -1226
  295. package/src/domains/security-compliance/services/index.ts +0 -31
  296. package/src/domains/security-compliance/services/security-auditor.ts +0 -2227
  297. package/src/domains/security-compliance/services/security-scanner.ts +0 -2354
  298. package/src/domains/security-compliance/services/semgrep-integration.ts +0 -289
  299. package/src/domains/test-execution/coordinator.ts +0 -426
  300. package/src/domains/test-execution/index.ts +0 -76
  301. package/src/domains/test-execution/interfaces.ts +0 -119
  302. package/src/domains/test-execution/plugin.ts +0 -208
  303. package/src/domains/test-execution/services/flaky-detector.ts +0 -1240
  304. package/src/domains/test-execution/services/index.ts +0 -8
  305. package/src/domains/test-execution/services/retry-handler.ts +0 -820
  306. package/src/domains/test-execution/services/test-executor.ts +0 -885
  307. package/src/domains/test-generation/coordinator.ts +0 -656
  308. package/src/domains/test-generation/index.ts +0 -77
  309. package/src/domains/test-generation/interfaces.ts +0 -118
  310. package/src/domains/test-generation/plugin.ts +0 -397
  311. package/src/domains/test-generation/services/index.ts +0 -23
  312. package/src/domains/test-generation/services/pattern-matcher.ts +0 -1725
  313. package/src/domains/test-generation/services/test-generator.ts +0 -2750
  314. package/src/domains/visual-accessibility/coordinator.ts +0 -860
  315. package/src/domains/visual-accessibility/index.ts +0 -116
  316. package/src/domains/visual-accessibility/interfaces.ts +0 -435
  317. package/src/domains/visual-accessibility/plugin.ts +0 -568
  318. package/src/domains/visual-accessibility/services/accessibility-tester.ts +0 -982
  319. package/src/domains/visual-accessibility/services/axe-core-audit.ts +0 -630
  320. package/src/domains/visual-accessibility/services/index.ts +0 -28
  321. package/src/domains/visual-accessibility/services/responsive-tester.ts +0 -934
  322. package/src/domains/visual-accessibility/services/visual-tester.ts +0 -458
  323. package/src/early-exit/early-exit-controller.ts +0 -490
  324. package/src/early-exit/early-exit-decision.ts +0 -391
  325. package/src/early-exit/index.ts +0 -115
  326. package/src/early-exit/quality-signal.ts +0 -389
  327. package/src/early-exit/speculative-executor.ts +0 -505
  328. package/src/early-exit/types.ts +0 -407
  329. package/src/feedback/coverage-learner.ts +0 -456
  330. package/src/feedback/feedback-loop.ts +0 -426
  331. package/src/feedback/index.ts +0 -72
  332. package/src/feedback/pattern-promotion.ts +0 -373
  333. package/src/feedback/quality-score-calculator.ts +0 -334
  334. package/src/feedback/test-outcome-tracker.ts +0 -450
  335. package/src/feedback/types.ts +0 -497
  336. package/src/index.ts +0 -224
  337. package/src/init/agents-installer.ts +0 -536
  338. package/src/init/index.ts +0 -80
  339. package/src/init/init-wizard.ts +0 -1061
  340. package/src/init/project-analyzer.ts +0 -696
  341. package/src/init/self-configurator.ts +0 -488
  342. package/src/init/skills-installer.ts +0 -467
  343. package/src/init/types.ts +0 -432
  344. package/src/integrations/ruvector/ast-complexity.ts +0 -470
  345. package/src/integrations/ruvector/coverage-router.ts +0 -594
  346. package/src/integrations/ruvector/diff-risk-classifier.ts +0 -759
  347. package/src/integrations/ruvector/fallback.ts +0 -942
  348. package/src/integrations/ruvector/graph-boundaries.ts +0 -809
  349. package/src/integrations/ruvector/index.ts +0 -363
  350. package/src/integrations/ruvector/interfaces.ts +0 -609
  351. package/src/integrations/ruvector/q-learning-router.ts +0 -550
  352. package/src/kernel/agent-coordinator.ts +0 -165
  353. package/src/kernel/agentdb-backend.ts +0 -504
  354. package/src/kernel/event-bus.ts +0 -129
  355. package/src/kernel/hybrid-backend.ts +0 -538
  356. package/src/kernel/index.ts +0 -28
  357. package/src/kernel/interfaces.ts +0 -257
  358. package/src/kernel/kernel.ts +0 -285
  359. package/src/kernel/memory-backend.ts +0 -169
  360. package/src/kernel/memory-factory.ts +0 -293
  361. package/src/kernel/plugin-loader.ts +0 -179
  362. package/src/learning/index.ts +0 -219
  363. package/src/learning/pattern-store.ts +0 -990
  364. package/src/learning/qe-guidance.ts +0 -832
  365. package/src/learning/qe-hooks.ts +0 -644
  366. package/src/learning/qe-patterns.ts +0 -449
  367. package/src/learning/qe-reasoning-bank.ts +0 -951
  368. package/src/learning/real-embeddings.ts +0 -277
  369. package/src/learning/real-qe-reasoning-bank.ts +0 -833
  370. package/src/learning/sqlite-persistence.ts +0 -554
  371. package/src/mcp/entry.ts +0 -59
  372. package/src/mcp/handlers/agent-handlers.ts +0 -285
  373. package/src/mcp/handlers/core-handlers.ts +0 -317
  374. package/src/mcp/handlers/domain-handlers.ts +0 -1444
  375. package/src/mcp/handlers/index.ts +0 -57
  376. package/src/mcp/handlers/memory-handlers.ts +0 -338
  377. package/src/mcp/handlers/task-handlers.ts +0 -363
  378. package/src/mcp/index.ts +0 -30
  379. package/src/mcp/metrics/index.ts +0 -14
  380. package/src/mcp/metrics/metrics-collector.ts +0 -503
  381. package/src/mcp/protocol-server.ts +0 -752
  382. package/src/mcp/security/cve-prevention.ts +0 -742
  383. package/src/mcp/security/index.ts +0 -356
  384. package/src/mcp/security/oauth21-provider.ts +0 -821
  385. package/src/mcp/security/rate-limiter.ts +0 -615
  386. package/src/mcp/security/sampling-server.ts +0 -662
  387. package/src/mcp/security/schema-validator.ts +0 -855
  388. package/src/mcp/server.ts +0 -657
  389. package/src/mcp/tool-registry.ts +0 -391
  390. package/src/mcp/tools/base.ts +0 -399
  391. package/src/mcp/tools/chaos-resilience/inject.ts +0 -699
  392. package/src/mcp/tools/code-intelligence/analyze.ts +0 -745
  393. package/src/mcp/tools/contract-testing/validate.ts +0 -708
  394. package/src/mcp/tools/coverage-analysis/index.ts +0 -770
  395. package/src/mcp/tools/defect-intelligence/predict.ts +0 -466
  396. package/src/mcp/tools/index.ts +0 -214
  397. package/src/mcp/tools/learning-optimization/optimize.ts +0 -772
  398. package/src/mcp/tools/quality-assessment/evaluate.ts +0 -385
  399. package/src/mcp/tools/registry.ts +0 -248
  400. package/src/mcp/tools/requirements-validation/validate.ts +0 -394
  401. package/src/mcp/tools/security-compliance/scan.ts +0 -365
  402. package/src/mcp/tools/test-execution/execute.ts +0 -291
  403. package/src/mcp/tools/test-generation/generate.ts +0 -544
  404. package/src/mcp/tools/visual-accessibility/index.ts +0 -791
  405. package/src/mcp/transport/index.ts +0 -31
  406. package/src/mcp/transport/stdio.ts +0 -318
  407. package/src/mcp/types.ts +0 -543
  408. package/src/neural-optimizer/index.ts +0 -111
  409. package/src/neural-optimizer/replay-buffer.ts +0 -455
  410. package/src/neural-optimizer/swarm-topology.ts +0 -508
  411. package/src/neural-optimizer/topology-optimizer.ts +0 -828
  412. package/src/neural-optimizer/types.ts +0 -481
  413. package/src/neural-optimizer/value-network.ts +0 -351
  414. package/src/optimization/auto-tuner.ts +0 -817
  415. package/src/optimization/index.ts +0 -77
  416. package/src/optimization/metric-collectors.ts +0 -474
  417. package/src/optimization/qe-workers.ts +0 -704
  418. package/src/optimization/tuning-algorithm.ts +0 -401
  419. package/src/optimization/types.ts +0 -314
  420. package/src/routing/index.ts +0 -51
  421. package/src/routing/qe-agent-registry.ts +0 -963
  422. package/src/routing/qe-task-router.ts +0 -564
  423. package/src/routing/routing-feedback.ts +0 -365
  424. package/src/routing/types.ts +0 -406
  425. package/src/shared/embeddings/embedding-cache.ts +0 -157
  426. package/src/shared/embeddings/index.ts +0 -50
  427. package/src/shared/embeddings/nomic-embedder.ts +0 -404
  428. package/src/shared/embeddings/ollama-client.ts +0 -195
  429. package/src/shared/embeddings/types.ts +0 -147
  430. package/src/shared/entities/agent.ts +0 -141
  431. package/src/shared/entities/base-entity.ts +0 -79
  432. package/src/shared/entities/index.ts +0 -6
  433. package/src/shared/events/domain-events.ts +0 -259
  434. package/src/shared/events/index.ts +0 -5
  435. package/src/shared/git/git-analyzer.ts +0 -656
  436. package/src/shared/git/index.ts +0 -11
  437. package/src/shared/http/http-client.ts +0 -420
  438. package/src/shared/http/index.ts +0 -13
  439. package/src/shared/index.ts +0 -41
  440. package/src/shared/io/file-reader.ts +0 -525
  441. package/src/shared/io/index.ts +0 -25
  442. package/src/shared/llm/cache.ts +0 -473
  443. package/src/shared/llm/circuit-breaker.ts +0 -369
  444. package/src/shared/llm/cost-tracker.ts +0 -460
  445. package/src/shared/llm/index.ts +0 -140
  446. package/src/shared/llm/interfaces.ts +0 -629
  447. package/src/shared/llm/provider-manager.ts +0 -685
  448. package/src/shared/llm/providers/claude.ts +0 -524
  449. package/src/shared/llm/providers/index.ts +0 -8
  450. package/src/shared/llm/providers/ollama.ts +0 -575
  451. package/src/shared/llm/providers/openai.ts +0 -609
  452. package/src/shared/metrics/code-metrics.ts +0 -520
  453. package/src/shared/metrics/index.ts +0 -23
  454. package/src/shared/metrics/system-metrics.ts +0 -353
  455. package/src/shared/parsers/index.ts +0 -6
  456. package/src/shared/parsers/typescript-parser.ts +0 -841
  457. package/src/shared/security/compliance-patterns.ts +0 -666
  458. package/src/shared/security/index.ts +0 -30
  459. package/src/shared/security/osv-client.ts +0 -468
  460. package/src/shared/types/index.ts +0 -150
  461. package/src/shared/value-objects/index.ts +0 -273
  462. package/src/strange-loop/healing-controller.ts +0 -833
  463. package/src/strange-loop/index.ts +0 -104
  464. package/src/strange-loop/self-model.ts +0 -494
  465. package/src/strange-loop/strange-loop.ts +0 -446
  466. package/src/strange-loop/swarm-observer.ts +0 -448
  467. package/src/strange-loop/topology-analyzer.ts +0 -565
  468. package/src/strange-loop/types.ts +0 -640
  469. package/src/time-crystal/default-phases.ts +0 -520
  470. package/src/time-crystal/index.ts +0 -164
  471. package/src/time-crystal/oscillator.ts +0 -425
  472. package/src/time-crystal/phase-executor.ts +0 -521
  473. package/src/time-crystal/scheduler.ts +0 -1025
  474. package/src/time-crystal/test-runner.ts +0 -787
  475. package/src/time-crystal/types.ts +0 -421
  476. package/src/workers/base-worker.ts +0 -304
  477. package/src/workers/daemon.ts +0 -264
  478. package/src/workers/index.ts +0 -119
  479. package/src/workers/interfaces.ts +0 -393
  480. package/src/workers/worker-manager.ts +0 -424
  481. package/src/workers/workers/compliance-checker.ts +0 -445
  482. package/src/workers/workers/coverage-tracker.ts +0 -344
  483. package/src/workers/workers/defect-predictor.ts +0 -375
  484. package/src/workers/workers/flaky-detector.ts +0 -390
  485. package/src/workers/workers/index.ts +0 -17
  486. package/src/workers/workers/learning-consolidation.ts +0 -442
  487. package/src/workers/workers/performance-baseline.ts +0 -434
  488. package/src/workers/workers/quality-gate.ts +0 -419
  489. package/src/workers/workers/regression-monitor.ts +0 -357
  490. package/src/workers/workers/security-scan.ts +0 -349
  491. package/src/workers/workers/test-health.ts +0 -359
  492. package/tests/integration/code-intelligence/knowledge-graph-real.test.ts +0 -540
  493. package/tests/integration/coordination/cross-domain-router.test.ts +0 -403
  494. package/tests/integration/coordination/protocol-executor.test.ts +0 -454
  495. package/tests/integration/coordination/workflow-orchestrator.test.ts +0 -418
  496. package/tests/integration/feedback/feedback-loop-integration.test.ts +0 -560
  497. package/tests/integration/migration/v2-to-v3-migration.test.ts +0 -471
  498. package/tests/integration/parsers/typescript-parser.test.ts +0 -463
  499. package/tests/integration/security/vulnerability-detection.test.ts +0 -628
  500. package/tests/integration/test-execution/coordinator.test.ts +0 -410
  501. package/tests/integration/test-generation/coordinator.test.ts +0 -361
  502. package/tests/mocks/index.ts +0 -228
  503. package/tests/time-crystal/default-phases.test.ts +0 -476
  504. package/tests/time-crystal/oscillator.test.ts +0 -541
  505. package/tests/time-crystal/phase-executor.test.ts +0 -653
  506. package/tests/time-crystal/scheduler.test.ts +0 -626
  507. package/tests/time-crystal/test-runner.test.ts +0 -594
  508. package/tests/unit/causal-discovery/causal-graph.test.ts +0 -504
  509. package/tests/unit/causal-discovery/causal-root-cause-analyzer.test.ts +0 -347
  510. package/tests/unit/causal-discovery/discovery-engine.test.ts +0 -435
  511. package/tests/unit/causal-discovery/weight-matrix.test.ts +0 -328
  512. package/tests/unit/cli/cli.test.ts +0 -341
  513. package/tests/unit/cli/commands.test.ts +0 -414
  514. package/tests/unit/cli/init-command.test.ts +0 -274
  515. package/tests/unit/cli/migrate-command.test.ts +0 -396
  516. package/tests/unit/coordination/claims/claim-service.test.ts +0 -949
  517. package/tests/unit/coordination/claims/handoff-manager.test.ts +0 -773
  518. package/tests/unit/coordination/claims/work-stealing.test.ts +0 -492
  519. package/tests/unit/coordination/queen-coordinator.test.ts +0 -966
  520. package/tests/unit/coordination/result-saver.test.ts +0 -653
  521. package/tests/unit/coordination/task-executor.test.ts +0 -810
  522. package/tests/unit/domains/chaos-resilience/chaos-engineer.test.ts +0 -484
  523. package/tests/unit/domains/chaos-resilience/load-tester.test.ts +0 -559
  524. package/tests/unit/domains/chaos-resilience/performance-profiler.test.ts +0 -490
  525. package/tests/unit/domains/code-intelligence/impact-analyzer.test.ts +0 -560
  526. package/tests/unit/domains/code-intelligence/knowledge-graph.test.ts +0 -460
  527. package/tests/unit/domains/code-intelligence/semantic-analyzer.test.ts +0 -584
  528. package/tests/unit/domains/contract-testing/api-compatibility.test.ts +0 -483
  529. package/tests/unit/domains/contract-testing/contract-validator.test.ts +0 -370
  530. package/tests/unit/domains/contract-testing/schema-validator.test.ts +0 -610
  531. package/tests/unit/domains/coverage-analysis/coverage-embedder.test.ts +0 -298
  532. package/tests/unit/domains/coverage-analysis/hnsw-index.test.ts +0 -292
  533. package/tests/unit/domains/coverage-analysis/sublinear-analyzer.test.ts +0 -506
  534. package/tests/unit/domains/defect-intelligence/defect-predictor.test.ts +0 -370
  535. package/tests/unit/domains/defect-intelligence/pattern-learner.test.ts +0 -546
  536. package/tests/unit/domains/defect-intelligence/root-cause-analyzer.test.ts +0 -534
  537. package/tests/unit/domains/learning-optimization/learning-coordinator.test.ts +0 -541
  538. package/tests/unit/domains/learning-optimization/metrics-optimizer.test.ts +0 -552
  539. package/tests/unit/domains/learning-optimization/production-intel.test.ts +0 -589
  540. package/tests/unit/domains/learning-optimization/transfer-specialist.test.ts +0 -453
  541. package/tests/unit/domains/quality-assessment/coherence-gate.test.ts +0 -1006
  542. package/tests/unit/domains/quality-assessment/deployment-advisor.test.ts +0 -515
  543. package/tests/unit/domains/quality-assessment/quality-analyzer.test.ts +0 -401
  544. package/tests/unit/domains/quality-assessment/quality-gate.test.ts +0 -324
  545. package/tests/unit/domains/requirements-validation/bdd-scenario-writer.test.ts +0 -479
  546. package/tests/unit/domains/requirements-validation/requirements-validator.test.ts +0 -452
  547. package/tests/unit/domains/requirements-validation/testability-scorer.test.ts +0 -505
  548. package/tests/unit/domains/security-compliance/compliance-validator.test.ts +0 -500
  549. package/tests/unit/domains/security-compliance/security-auditor.test.ts +0 -498
  550. package/tests/unit/domains/security-compliance/security-scanner.test.ts +0 -412
  551. package/tests/unit/domains/visual-accessibility/accessibility-tester.test.ts +0 -432
  552. package/tests/unit/domains/visual-accessibility/responsive-tester.test.ts +0 -506
  553. package/tests/unit/domains/visual-accessibility/visual-tester.test.ts +0 -412
  554. package/tests/unit/early-exit/early-exit-controller.test.ts +0 -548
  555. package/tests/unit/early-exit/early-exit-decision.test.ts +0 -617
  556. package/tests/unit/early-exit/index.test.ts +0 -254
  557. package/tests/unit/early-exit/quality-signal.test.ts +0 -589
  558. package/tests/unit/early-exit/speculative-executor.test.ts +0 -453
  559. package/tests/unit/feedback/coverage-learner.test.ts +0 -288
  560. package/tests/unit/feedback/feedback-loop.test.ts +0 -458
  561. package/tests/unit/feedback/pattern-promotion.test.ts +0 -390
  562. package/tests/unit/feedback/quality-score-calculator.test.ts +0 -364
  563. package/tests/unit/feedback/test-outcome-tracker.test.ts +0 -243
  564. package/tests/unit/init/init-wizard.test.ts +0 -881
  565. package/tests/unit/init/project-analyzer.test.ts +0 -807
  566. package/tests/unit/init/self-configurator.test.ts +0 -493
  567. package/tests/unit/integrations/ruvector/ast-complexity.test.ts +0 -240
  568. package/tests/unit/integrations/ruvector/coverage-router.test.ts +0 -366
  569. package/tests/unit/integrations/ruvector/diff-risk-classifier.test.ts +0 -340
  570. package/tests/unit/integrations/ruvector/graph-boundaries.test.ts +0 -355
  571. package/tests/unit/integrations/ruvector/q-learning-router.test.ts +0 -314
  572. package/tests/unit/kernel/agent-coordinator.test.ts +0 -220
  573. package/tests/unit/kernel/event-bus.test.ts +0 -197
  574. package/tests/unit/learning/qe-reasoning-bank.test.ts +0 -666
  575. package/tests/unit/learning/real-qe-reasoning-bank.benchmark.test.ts +0 -415
  576. package/tests/unit/mcp/mcp-server.test.ts +0 -544
  577. package/tests/unit/mcp/metrics/metrics-collector.test.ts +0 -340
  578. package/tests/unit/mcp/security/cve-prevention.test.ts +0 -512
  579. package/tests/unit/mcp/security/oauth21-provider.test.ts +0 -624
  580. package/tests/unit/mcp/security/rate-limiter.test.ts +0 -410
  581. package/tests/unit/mcp/security/sampling-server.test.ts +0 -420
  582. package/tests/unit/mcp/security/schema-validator.test.ts +0 -494
  583. package/tests/unit/mcp/tools/base.test.ts +0 -336
  584. package/tests/unit/mcp/tools/domain-tools.test.ts +0 -759
  585. package/tests/unit/mcp/tools/registry.test.ts +0 -240
  586. package/tests/unit/neural-optimizer/replay-buffer.test.ts +0 -403
  587. package/tests/unit/neural-optimizer/swarm-topology.test.ts +0 -473
  588. package/tests/unit/neural-optimizer/topology-optimizer.test.ts +0 -595
  589. package/tests/unit/neural-optimizer/value-network.test.ts +0 -343
  590. package/tests/unit/optimization/auto-tuner.test.ts +0 -506
  591. package/tests/unit/optimization/metric-collectors.test.ts +0 -352
  592. package/tests/unit/optimization/qe-workers.test.ts +0 -407
  593. package/tests/unit/optimization/tuning-algorithm.test.ts +0 -467
  594. package/tests/unit/routing/qe-agent-registry.test.ts +0 -229
  595. package/tests/unit/routing/qe-task-router.test.ts +0 -390
  596. package/tests/unit/routing/routing-feedback.test.ts +0 -339
  597. package/tests/unit/shared/embeddings/nomic-embedder.test.ts +0 -419
  598. package/tests/unit/shared/http/http-client.test.ts +0 -719
  599. package/tests/unit/shared/io/file-reader.test.ts +0 -511
  600. package/tests/unit/shared/llm/cache.test.ts +0 -391
  601. package/tests/unit/shared/llm/circuit-breaker.test.ts +0 -293
  602. package/tests/unit/shared/llm/cost-tracker.test.ts +0 -431
  603. package/tests/unit/shared/llm/provider-manager.test.ts +0 -550
  604. package/tests/unit/shared/llm/providers.test.ts +0 -532
  605. package/tests/unit/shared/parsers/typescript-parser.test.ts +0 -693
  606. package/tests/unit/shared/value-objects.test.ts +0 -184
  607. package/tests/unit/strange-loop/strange-loop.test.ts +0 -1170
  608. package/tests/unit/workers/base-worker.test.ts +0 -341
  609. package/tests/unit/workers/daemon.test.ts +0 -291
  610. package/tests/unit/workers/worker-manager.test.ts +0 -284
  611. package/tsconfig.json +0 -32
  612. package/vitest.config.ts +0 -27
@@ -1,1102 +0,0 @@
1
- /**
2
- * Agentic QE v3 - Schema Validation Service
3
- * Implements ISchemaValidationService for schema validation (JSON Schema, OpenAPI, GraphQL)
4
- */
5
-
6
- import { v4 as uuidv4 } from 'uuid';
7
- import { Result, ok, err } from '../../../shared/types/index.js';
8
- import type { MemoryBackend } from '../../../kernel/interfaces.js';
9
- import type {
10
- ISchemaValidationService,
11
- SchemaDefinition,
12
- SchemaValidationResult,
13
- SchemaError,
14
- GraphQLValidationResult,
15
- GraphQLError,
16
- SchemaComparisonResult,
17
- SchemaModification,
18
- } from '../interfaces.js';
19
-
20
- /**
21
- * Configuration for the schema validator
22
- */
23
- export interface SchemaValidatorConfig {
24
- strictMode: boolean;
25
- allowAdditionalProperties: boolean;
26
- maxRecursionDepth: number;
27
- inferenceMinSamples: number;
28
- }
29
-
30
- const DEFAULT_CONFIG: SchemaValidatorConfig = {
31
- strictMode: false,
32
- allowAdditionalProperties: true,
33
- maxRecursionDepth: 10,
34
- inferenceMinSamples: 3,
35
- };
36
-
37
- /**
38
- * Schema Validation Service Implementation
39
- * Validates data against various schema formats
40
- */
41
- export class SchemaValidatorService implements ISchemaValidationService {
42
- private readonly config: SchemaValidatorConfig;
43
-
44
- constructor(
45
- private readonly memory: MemoryBackend,
46
- config: Partial<SchemaValidatorConfig> = {}
47
- ) {
48
- this.config = { ...DEFAULT_CONFIG, ...config };
49
- }
50
-
51
- /**
52
- * Validate JSON Schema
53
- */
54
- async validateJsonSchema(
55
- data: unknown,
56
- schema: object
57
- ): Promise<Result<SchemaValidationResult>> {
58
- try {
59
- const errors: SchemaError[] = [];
60
-
61
- this.validateValue(data, schema as Record<string, unknown>, '', errors, 0);
62
-
63
- const result: SchemaValidationResult = {
64
- isValid: errors.length === 0,
65
- errors,
66
- };
67
-
68
- return ok(result);
69
- } catch (error) {
70
- return err(error instanceof Error ? error : new Error(String(error)));
71
- }
72
- }
73
-
74
- /**
75
- * Validate GraphQL schema
76
- */
77
- async validateGraphQLSchema(schema: string): Promise<Result<GraphQLValidationResult>> {
78
- try {
79
- const errors: GraphQLError[] = [];
80
- let typeCount = 0;
81
- let queryCount = 0;
82
- let mutationCount = 0;
83
-
84
- // GraphQL schema parsing and validation using line-based analysis
85
- const lines = schema.split('\n');
86
- let inType = false;
87
- let inQuery = false;
88
- let inMutation = false;
89
- let braceDepth = 0;
90
-
91
- for (let lineNum = 0; lineNum < lines.length; lineNum++) {
92
- const line = lines[lineNum].trim();
93
-
94
- // Skip comments and empty lines
95
- if (line.startsWith('#') || line === '') continue;
96
-
97
- // Detect type definitions
98
- if (line.startsWith('type ')) {
99
- const typeName = line.split(/\s+/)[1]?.replace(/{.*/, '').trim();
100
-
101
- if (typeName === 'Query') {
102
- inQuery = true;
103
- } else if (typeName === 'Mutation') {
104
- inMutation = true;
105
- } else {
106
- typeCount++;
107
- }
108
- inType = true;
109
- }
110
-
111
- // Track brace depth
112
- braceDepth += (line.match(/{/g) || []).length;
113
- braceDepth -= (line.match(/}/g) || []).length;
114
-
115
- // Count fields in Query/Mutation
116
- if (inQuery && line.includes(':') && !line.startsWith('type')) {
117
- queryCount++;
118
- }
119
- if (inMutation && line.includes(':') && !line.startsWith('type')) {
120
- mutationCount++;
121
- }
122
-
123
- // Reset when type ends
124
- if (braceDepth === 0 && inType) {
125
- inType = false;
126
- inQuery = false;
127
- inMutation = false;
128
- }
129
-
130
- // Basic syntax validation
131
- if (line.includes('::')) {
132
- errors.push({
133
- message: 'Invalid double colon in type definition',
134
- locations: [{ line: lineNum + 1, column: line.indexOf('::') + 1 }],
135
- });
136
- }
137
- }
138
-
139
- // Check for unbalanced braces
140
- if (braceDepth !== 0) {
141
- errors.push({
142
- message: 'Unbalanced braces in schema',
143
- locations: [{ line: lines.length, column: 1 }],
144
- });
145
- }
146
-
147
- // Check for required types
148
- if (!schema.includes('type Query') && !schema.includes('schema {')) {
149
- errors.push({
150
- message: 'GraphQL schema must have a Query type or schema definition',
151
- locations: [{ line: 1, column: 1 }],
152
- });
153
- }
154
-
155
- return ok({
156
- isValid: errors.length === 0,
157
- errors,
158
- typeCount,
159
- queryCount,
160
- mutationCount,
161
- });
162
- } catch (error) {
163
- return err(error instanceof Error ? error : new Error(String(error)));
164
- }
165
- }
166
-
167
- /**
168
- * Compare schemas for compatibility
169
- */
170
- async compareSchemas(
171
- oldSchema: SchemaDefinition,
172
- newSchema: SchemaDefinition
173
- ): Promise<Result<SchemaComparisonResult>> {
174
- try {
175
- const additions: string[] = [];
176
- const removals: string[] = [];
177
- const modifications: SchemaModification[] = [];
178
-
179
- // Only compare same type schemas
180
- if (oldSchema.type !== newSchema.type) {
181
- return ok({
182
- isCompatible: false,
183
- additions: [],
184
- removals: [],
185
- modifications: [
186
- {
187
- path: 'type',
188
- oldType: oldSchema.type,
189
- newType: newSchema.type,
190
- isBreaking: true,
191
- },
192
- ],
193
- });
194
- }
195
-
196
- switch (oldSchema.type) {
197
- case 'json-schema':
198
- case 'openapi':
199
- this.compareJsonSchemas(
200
- oldSchema.content,
201
- newSchema.content,
202
- additions,
203
- removals,
204
- modifications
205
- );
206
- break;
207
-
208
- case 'graphql':
209
- this.compareGraphQLSchemas(
210
- oldSchema.content,
211
- newSchema.content,
212
- additions,
213
- removals,
214
- modifications
215
- );
216
- break;
217
-
218
- case 'protobuf':
219
- this.compareProtobufSchemas(
220
- oldSchema.content,
221
- newSchema.content,
222
- additions,
223
- removals,
224
- modifications
225
- );
226
- break;
227
-
228
- case 'avro':
229
- this.compareAvroSchemas(
230
- oldSchema.content,
231
- newSchema.content,
232
- additions,
233
- removals,
234
- modifications
235
- );
236
- break;
237
- }
238
-
239
- const hasBreakingChanges = modifications.some((m) => m.isBreaking) || removals.length > 0;
240
-
241
- // Store comparison result
242
- await this.storeComparisonResult(oldSchema, newSchema, {
243
- isCompatible: !hasBreakingChanges,
244
- additions,
245
- removals,
246
- modifications,
247
- });
248
-
249
- return ok({
250
- isCompatible: !hasBreakingChanges,
251
- additions,
252
- removals,
253
- modifications,
254
- });
255
- } catch (error) {
256
- return err(error instanceof Error ? error : new Error(String(error)));
257
- }
258
- }
259
-
260
- /**
261
- * Generate schema from sample data
262
- */
263
- async inferSchema(samples: unknown[]): Promise<Result<SchemaDefinition>> {
264
- try {
265
- if (samples.length === 0) {
266
- return err(new Error('At least one sample is required for schema inference'));
267
- }
268
-
269
- if (samples.length < this.config.inferenceMinSamples) {
270
- // Warning: fewer samples may lead to incomplete schema
271
- }
272
-
273
- const inferredSchema = this.inferFromSamples(samples);
274
-
275
- const schemaDefinition: SchemaDefinition = {
276
- id: `inferred-${uuidv4().slice(0, 8)}`,
277
- name: 'InferredSchema',
278
- type: 'json-schema',
279
- content: JSON.stringify(inferredSchema, null, 2),
280
- };
281
-
282
- // Store inferred schema
283
- await this.memory.set(
284
- `contract-testing:schema:${schemaDefinition.id}`,
285
- schemaDefinition,
286
- { namespace: 'contract-testing' }
287
- );
288
-
289
- return ok(schemaDefinition);
290
- } catch (error) {
291
- return err(error instanceof Error ? error : new Error(String(error)));
292
- }
293
- }
294
-
295
- // ============================================================================
296
- // Private Validation Methods
297
- // ============================================================================
298
-
299
- private validateValue(
300
- value: unknown,
301
- schema: Record<string, unknown>,
302
- path: string,
303
- errors: SchemaError[],
304
- depth: number
305
- ): void {
306
- if (depth > this.config.maxRecursionDepth) {
307
- errors.push({
308
- path,
309
- keyword: 'maxDepth',
310
- message: 'Maximum recursion depth exceeded',
311
- params: { maxDepth: this.config.maxRecursionDepth },
312
- });
313
- return;
314
- }
315
-
316
- // Handle nullable
317
- if (value === null) {
318
- if (schema.nullable === true || schema.type === 'null') {
319
- return;
320
- }
321
- if (this.config.strictMode) {
322
- errors.push({
323
- path,
324
- keyword: 'type',
325
- message: 'Value cannot be null',
326
- params: {},
327
- });
328
- }
329
- return;
330
- }
331
-
332
- const schemaType = schema.type as string | string[] | undefined;
333
-
334
- // Handle oneOf, anyOf, allOf
335
- if (schema.oneOf) {
336
- this.validateOneOf(value, schema.oneOf as Record<string, unknown>[], path, errors, depth);
337
- return;
338
- }
339
- if (schema.anyOf) {
340
- this.validateAnyOf(value, schema.anyOf as Record<string, unknown>[], path, errors, depth);
341
- return;
342
- }
343
- if (schema.allOf) {
344
- this.validateAllOf(value, schema.allOf as Record<string, unknown>[], path, errors, depth);
345
- return;
346
- }
347
-
348
- // Validate type
349
- if (schemaType) {
350
- const types = Array.isArray(schemaType) ? schemaType : [schemaType];
351
- const actualType = this.getJsonType(value);
352
-
353
- if (!types.some((t) => this.typesMatch(actualType, t))) {
354
- errors.push({
355
- path,
356
- keyword: 'type',
357
- message: `Expected type '${types.join(' | ')}' but got '${actualType}'`,
358
- params: { expectedType: types, actualType },
359
- });
360
- return;
361
- }
362
- }
363
-
364
- // Type-specific validation
365
- if (typeof value === 'object' && value !== null && !Array.isArray(value)) {
366
- this.validateObject(value as Record<string, unknown>, schema, path, errors, depth);
367
- } else if (Array.isArray(value)) {
368
- this.validateArray(value, schema, path, errors, depth);
369
- } else if (typeof value === 'string') {
370
- this.validateString(value, schema, path, errors);
371
- } else if (typeof value === 'number') {
372
- this.validateNumber(value, schema, path, errors);
373
- }
374
-
375
- // Validate enum
376
- if (schema.enum) {
377
- const enumValues = schema.enum as unknown[];
378
- if (!enumValues.includes(value)) {
379
- errors.push({
380
- path,
381
- keyword: 'enum',
382
- message: `Value must be one of: ${enumValues.map((v) => JSON.stringify(v)).join(', ')}`,
383
- params: { allowedValues: enumValues },
384
- });
385
- }
386
- }
387
-
388
- // Validate const
389
- if ('const' in schema) {
390
- if (value !== schema.const) {
391
- errors.push({
392
- path,
393
- keyword: 'const',
394
- message: `Value must be ${JSON.stringify(schema.const)}`,
395
- params: { expected: schema.const },
396
- });
397
- }
398
- }
399
- }
400
-
401
- private validateObject(
402
- value: Record<string, unknown>,
403
- schema: Record<string, unknown>,
404
- path: string,
405
- errors: SchemaError[],
406
- depth: number
407
- ): void {
408
- const properties = (schema.properties as Record<string, Record<string, unknown>>) || {};
409
- const required = (schema.required as string[]) || [];
410
- const additionalProperties = schema.additionalProperties;
411
-
412
- // Check required properties
413
- for (const prop of required) {
414
- if (!(prop in value)) {
415
- errors.push({
416
- path: path ? `${path}.${prop}` : prop,
417
- keyword: 'required',
418
- message: `Required property '${prop}' is missing`,
419
- params: { missingProperty: prop },
420
- });
421
- }
422
- }
423
-
424
- // Validate each property
425
- for (const [prop, propValue] of Object.entries(value)) {
426
- const propPath = path ? `${path}.${prop}` : prop;
427
-
428
- if (prop in properties) {
429
- this.validateValue(propValue, properties[prop], propPath, errors, depth + 1);
430
- } else if (this.config.strictMode && additionalProperties === false) {
431
- errors.push({
432
- path: propPath,
433
- keyword: 'additionalProperties',
434
- message: `Property '${prop}' is not allowed`,
435
- params: { additionalProperty: prop },
436
- });
437
- } else if (typeof additionalProperties === 'object') {
438
- this.validateValue(
439
- propValue,
440
- additionalProperties as Record<string, unknown>,
441
- propPath,
442
- errors,
443
- depth + 1
444
- );
445
- }
446
- }
447
-
448
- // Validate minProperties / maxProperties
449
- const propCount = Object.keys(value).length;
450
- if (typeof schema.minProperties === 'number' && propCount < schema.minProperties) {
451
- errors.push({
452
- path,
453
- keyword: 'minProperties',
454
- message: `Object must have at least ${schema.minProperties} properties`,
455
- params: { limit: schema.minProperties, actual: propCount },
456
- });
457
- }
458
- if (typeof schema.maxProperties === 'number' && propCount > schema.maxProperties) {
459
- errors.push({
460
- path,
461
- keyword: 'maxProperties',
462
- message: `Object must have at most ${schema.maxProperties} properties`,
463
- params: { limit: schema.maxProperties, actual: propCount },
464
- });
465
- }
466
- }
467
-
468
- private validateArray(
469
- value: unknown[],
470
- schema: Record<string, unknown>,
471
- path: string,
472
- errors: SchemaError[],
473
- depth: number
474
- ): void {
475
- const items = schema.items as Record<string, unknown> | undefined;
476
-
477
- // Validate items
478
- if (items) {
479
- for (let i = 0; i < value.length; i++) {
480
- this.validateValue(value[i], items, `${path}[${i}]`, errors, depth + 1);
481
- }
482
- }
483
-
484
- // Validate minItems / maxItems
485
- if (typeof schema.minItems === 'number' && value.length < schema.minItems) {
486
- errors.push({
487
- path,
488
- keyword: 'minItems',
489
- message: `Array must have at least ${schema.minItems} items`,
490
- params: { limit: schema.minItems, actual: value.length },
491
- });
492
- }
493
- if (typeof schema.maxItems === 'number' && value.length > schema.maxItems) {
494
- errors.push({
495
- path,
496
- keyword: 'maxItems',
497
- message: `Array must have at most ${schema.maxItems} items`,
498
- params: { limit: schema.maxItems, actual: value.length },
499
- });
500
- }
501
-
502
- // Validate uniqueItems
503
- if (schema.uniqueItems === true) {
504
- const seen = new Set<string>();
505
- for (let i = 0; i < value.length; i++) {
506
- const serialized = JSON.stringify(value[i]);
507
- if (seen.has(serialized)) {
508
- errors.push({
509
- path: `${path}[${i}]`,
510
- keyword: 'uniqueItems',
511
- message: 'Array items must be unique',
512
- params: { duplicateIndex: i },
513
- });
514
- }
515
- seen.add(serialized);
516
- }
517
- }
518
- }
519
-
520
- private validateString(
521
- value: string,
522
- schema: Record<string, unknown>,
523
- path: string,
524
- errors: SchemaError[]
525
- ): void {
526
- if (typeof schema.minLength === 'number' && value.length < schema.minLength) {
527
- errors.push({
528
- path,
529
- keyword: 'minLength',
530
- message: `String must be at least ${schema.minLength} characters`,
531
- params: { limit: schema.minLength, actual: value.length },
532
- });
533
- }
534
- if (typeof schema.maxLength === 'number' && value.length > schema.maxLength) {
535
- errors.push({
536
- path,
537
- keyword: 'maxLength',
538
- message: `String must be at most ${schema.maxLength} characters`,
539
- params: { limit: schema.maxLength, actual: value.length },
540
- });
541
- }
542
- if (typeof schema.pattern === 'string') {
543
- const regex = new RegExp(schema.pattern);
544
- if (!regex.test(value)) {
545
- errors.push({
546
- path,
547
- keyword: 'pattern',
548
- message: `String must match pattern '${schema.pattern}'`,
549
- params: { pattern: schema.pattern },
550
- });
551
- }
552
- }
553
-
554
- // Validate format
555
- if (typeof schema.format === 'string') {
556
- this.validateFormat(value, schema.format, path, errors);
557
- }
558
- }
559
-
560
- private validateNumber(
561
- value: number,
562
- schema: Record<string, unknown>,
563
- path: string,
564
- errors: SchemaError[]
565
- ): void {
566
- if (typeof schema.minimum === 'number') {
567
- if (schema.exclusiveMinimum === true) {
568
- if (value <= schema.minimum) {
569
- errors.push({
570
- path,
571
- keyword: 'exclusiveMinimum',
572
- message: `Number must be greater than ${schema.minimum}`,
573
- params: { limit: schema.minimum, actual: value },
574
- });
575
- }
576
- } else if (value < schema.minimum) {
577
- errors.push({
578
- path,
579
- keyword: 'minimum',
580
- message: `Number must be at least ${schema.minimum}`,
581
- params: { limit: schema.minimum, actual: value },
582
- });
583
- }
584
- }
585
-
586
- if (typeof schema.maximum === 'number') {
587
- if (schema.exclusiveMaximum === true) {
588
- if (value >= schema.maximum) {
589
- errors.push({
590
- path,
591
- keyword: 'exclusiveMaximum',
592
- message: `Number must be less than ${schema.maximum}`,
593
- params: { limit: schema.maximum, actual: value },
594
- });
595
- }
596
- } else if (value > schema.maximum) {
597
- errors.push({
598
- path,
599
- keyword: 'maximum',
600
- message: `Number must be at most ${schema.maximum}`,
601
- params: { limit: schema.maximum, actual: value },
602
- });
603
- }
604
- }
605
-
606
- if (typeof schema.multipleOf === 'number') {
607
- const remainder = value % schema.multipleOf;
608
- if (Math.abs(remainder) > 1e-10) {
609
- errors.push({
610
- path,
611
- keyword: 'multipleOf',
612
- message: `Number must be a multiple of ${schema.multipleOf}`,
613
- params: { multipleOf: schema.multipleOf, actual: value },
614
- });
615
- }
616
- }
617
- }
618
-
619
- private validateFormat(
620
- value: string,
621
- format: string,
622
- path: string,
623
- errors: SchemaError[]
624
- ): void {
625
- let isValid = true;
626
-
627
- switch (format) {
628
- case 'email':
629
- isValid = /^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(value);
630
- break;
631
- case 'uri':
632
- case 'url':
633
- try {
634
- new URL(value);
635
- } catch {
636
- isValid = false;
637
- }
638
- break;
639
- case 'uuid':
640
- isValid = /^[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i.test(value);
641
- break;
642
- case 'date':
643
- isValid = !isNaN(Date.parse(value)) && /^\d{4}-\d{2}-\d{2}$/.test(value);
644
- break;
645
- case 'date-time':
646
- isValid = !isNaN(Date.parse(value));
647
- break;
648
- case 'time':
649
- isValid = /^\d{2}:\d{2}(:\d{2})?/.test(value);
650
- break;
651
- case 'ipv4':
652
- isValid = /^(\d{1,3}\.){3}\d{1,3}$/.test(value);
653
- break;
654
- case 'ipv6':
655
- isValid = /^([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}$/.test(value);
656
- break;
657
- default:
658
- // Unknown format, skip validation
659
- return;
660
- }
661
-
662
- if (!isValid) {
663
- errors.push({
664
- path,
665
- keyword: 'format',
666
- message: `String must be a valid ${format}`,
667
- params: { format },
668
- });
669
- }
670
- }
671
-
672
- private validateOneOf(
673
- value: unknown,
674
- schemas: Record<string, unknown>[],
675
- path: string,
676
- errors: SchemaError[],
677
- depth: number
678
- ): void {
679
- const validCount = schemas.reduce((count, schema) => {
680
- const subErrors: SchemaError[] = [];
681
- this.validateValue(value, schema, path, subErrors, depth + 1);
682
- return count + (subErrors.length === 0 ? 1 : 0);
683
- }, 0);
684
-
685
- if (validCount !== 1) {
686
- errors.push({
687
- path,
688
- keyword: 'oneOf',
689
- message: `Value must match exactly one schema (matched ${validCount})`,
690
- params: { matched: validCount },
691
- });
692
- }
693
- }
694
-
695
- private validateAnyOf(
696
- value: unknown,
697
- schemas: Record<string, unknown>[],
698
- path: string,
699
- errors: SchemaError[],
700
- depth: number
701
- ): void {
702
- const hasValid = schemas.some((schema) => {
703
- const subErrors: SchemaError[] = [];
704
- this.validateValue(value, schema, path, subErrors, depth + 1);
705
- return subErrors.length === 0;
706
- });
707
-
708
- if (!hasValid) {
709
- errors.push({
710
- path,
711
- keyword: 'anyOf',
712
- message: 'Value must match at least one schema',
713
- params: {},
714
- });
715
- }
716
- }
717
-
718
- private validateAllOf(
719
- value: unknown,
720
- schemas: Record<string, unknown>[],
721
- path: string,
722
- errors: SchemaError[],
723
- depth: number
724
- ): void {
725
- for (const schema of schemas) {
726
- this.validateValue(value, schema, path, errors, depth + 1);
727
- }
728
- }
729
-
730
- private getJsonType(value: unknown): string {
731
- if (value === null) return 'null';
732
- if (Array.isArray(value)) return 'array';
733
- if (typeof value === 'number') {
734
- return Number.isInteger(value) ? 'integer' : 'number';
735
- }
736
- return typeof value;
737
- }
738
-
739
- private typesMatch(actual: string, expected: string): boolean {
740
- if (actual === expected) return true;
741
- if (expected === 'number' && actual === 'integer') return true;
742
- return false;
743
- }
744
-
745
- // ============================================================================
746
- // Schema Comparison Methods
747
- // ============================================================================
748
-
749
- private compareJsonSchemas(
750
- oldContent: string,
751
- newContent: string,
752
- additions: string[],
753
- removals: string[],
754
- modifications: SchemaModification[]
755
- ): void {
756
- try {
757
- const oldSchema = JSON.parse(oldContent) as Record<string, unknown>;
758
- const newSchema = JSON.parse(newContent) as Record<string, unknown>;
759
-
760
- this.compareSchemaObjects(oldSchema, newSchema, '', additions, removals, modifications);
761
- } catch {
762
- modifications.push({
763
- path: '',
764
- oldType: 'unparseable',
765
- newType: 'unparseable',
766
- isBreaking: true,
767
- });
768
- }
769
- }
770
-
771
- private compareSchemaObjects(
772
- oldSchema: Record<string, unknown>,
773
- newSchema: Record<string, unknown>,
774
- path: string,
775
- additions: string[],
776
- removals: string[],
777
- modifications: SchemaModification[]
778
- ): void {
779
- const oldProps = (oldSchema.properties as Record<string, unknown>) || {};
780
- const newProps = (newSchema.properties as Record<string, unknown>) || {};
781
- const oldRequired = new Set((oldSchema.required as string[]) || []);
782
- const newRequired = new Set((newSchema.required as string[]) || []);
783
-
784
- // Check for removed properties
785
- for (const prop of Object.keys(oldProps)) {
786
- if (!(prop in newProps)) {
787
- const propPath = path ? `${path}.${prop}` : prop;
788
- removals.push(propPath);
789
- }
790
- }
791
-
792
- // Check for added properties
793
- for (const prop of Object.keys(newProps)) {
794
- if (!(prop in oldProps)) {
795
- const propPath = path ? `${path}.${prop}` : prop;
796
- additions.push(propPath);
797
-
798
- // New required property is breaking
799
- if (newRequired.has(prop)) {
800
- modifications.push({
801
- path: propPath,
802
- oldType: 'undefined',
803
- newType: 'required',
804
- isBreaking: true,
805
- });
806
- }
807
- }
808
- }
809
-
810
- // Check for type changes
811
- if (oldSchema.type !== newSchema.type) {
812
- modifications.push({
813
- path: path || 'root',
814
- oldType: String(oldSchema.type || 'any'),
815
- newType: String(newSchema.type || 'any'),
816
- isBreaking: true,
817
- });
818
- }
819
-
820
- // Check for required changes
821
- const newRequiredArray = Array.from(newRequired);
822
- for (const prop of newRequiredArray) {
823
- if (!oldRequired.has(prop) && prop in oldProps) {
824
- const propPath = path ? `${path}.${prop}` : prop;
825
- modifications.push({
826
- path: propPath,
827
- oldType: 'optional',
828
- newType: 'required',
829
- isBreaking: true,
830
- });
831
- }
832
- }
833
- }
834
-
835
- private compareGraphQLSchemas(
836
- oldContent: string,
837
- newContent: string,
838
- additions: string[],
839
- removals: string[],
840
- _modifications: SchemaModification[]
841
- ): void {
842
- // Extract types from both schemas (simplified)
843
- const oldTypes = this.extractGraphQLTypes(oldContent);
844
- const newTypes = this.extractGraphQLTypes(newContent);
845
-
846
- for (const typeName of oldTypes) {
847
- if (!newTypes.includes(typeName)) {
848
- removals.push(`type:${typeName}`);
849
- }
850
- }
851
-
852
- for (const typeName of newTypes) {
853
- if (!oldTypes.includes(typeName)) {
854
- additions.push(`type:${typeName}`);
855
- }
856
- }
857
- }
858
-
859
- private extractGraphQLTypes(schema: string): string[] {
860
- const types: string[] = [];
861
- const typeRegex = /type\s+(\w+)/g;
862
- let match;
863
- while ((match = typeRegex.exec(schema)) !== null) {
864
- types.push(match[1]);
865
- }
866
- return types;
867
- }
868
-
869
- private compareProtobufSchemas(
870
- oldContent: string,
871
- newContent: string,
872
- additions: string[],
873
- removals: string[],
874
- _modifications: SchemaModification[]
875
- ): void {
876
- // Extract messages from both schemas
877
- const oldMessages = this.extractProtobufMessages(oldContent);
878
- const newMessages = this.extractProtobufMessages(newContent);
879
-
880
- for (const msg of oldMessages) {
881
- if (!newMessages.includes(msg)) {
882
- removals.push(`message:${msg}`);
883
- }
884
- }
885
-
886
- for (const msg of newMessages) {
887
- if (!oldMessages.includes(msg)) {
888
- additions.push(`message:${msg}`);
889
- }
890
- }
891
- }
892
-
893
- private extractProtobufMessages(schema: string): string[] {
894
- const messages: string[] = [];
895
- const msgRegex = /message\s+(\w+)/g;
896
- let match;
897
- while ((match = msgRegex.exec(schema)) !== null) {
898
- messages.push(match[1]);
899
- }
900
- return messages;
901
- }
902
-
903
- private compareAvroSchemas(
904
- oldContent: string,
905
- newContent: string,
906
- _additions: string[],
907
- _removals: string[],
908
- modifications: SchemaModification[]
909
- ): void {
910
- try {
911
- const oldSchema = JSON.parse(oldContent) as Record<string, unknown>;
912
- const newSchema = JSON.parse(newContent) as Record<string, unknown>;
913
-
914
- // Compare type
915
- if (oldSchema.type !== newSchema.type) {
916
- modifications.push({
917
- path: 'type',
918
- oldType: String(oldSchema.type),
919
- newType: String(newSchema.type),
920
- isBreaking: true,
921
- });
922
- }
923
-
924
- // Compare name
925
- if (oldSchema.name !== newSchema.name) {
926
- modifications.push({
927
- path: 'name',
928
- oldType: String(oldSchema.name),
929
- newType: String(newSchema.name),
930
- isBreaking: true,
931
- });
932
- }
933
- } catch {
934
- modifications.push({
935
- path: '',
936
- oldType: 'unparseable',
937
- newType: 'unparseable',
938
- isBreaking: true,
939
- });
940
- }
941
- }
942
-
943
- // ============================================================================
944
- // Schema Inference
945
- // ============================================================================
946
-
947
- private inferFromSamples(samples: unknown[]): Record<string, unknown> {
948
- if (samples.length === 0) {
949
- return { type: 'null' };
950
- }
951
-
952
- // Merge inferred types from all samples
953
- const types = samples.map((s) => this.inferType(s));
954
- return this.mergeTypes(types);
955
- }
956
-
957
- private inferType(value: unknown): Record<string, unknown> {
958
- if (value === null) {
959
- return { type: 'null' };
960
- }
961
-
962
- if (Array.isArray(value)) {
963
- if (value.length === 0) {
964
- return { type: 'array', items: {} };
965
- }
966
- const itemTypes = value.map((item) => this.inferType(item));
967
- return { type: 'array', items: this.mergeTypes(itemTypes) };
968
- }
969
-
970
- if (typeof value === 'object') {
971
- const properties: Record<string, Record<string, unknown>> = {};
972
- const required: string[] = [];
973
-
974
- for (const [key, val] of Object.entries(value as Record<string, unknown>)) {
975
- properties[key] = this.inferType(val);
976
- if (val !== undefined) {
977
- required.push(key);
978
- }
979
- }
980
-
981
- return { type: 'object', properties, required };
982
- }
983
-
984
- if (typeof value === 'string') {
985
- const format = this.inferStringFormat(value);
986
- return format ? { type: 'string', format } : { type: 'string' };
987
- }
988
-
989
- if (typeof value === 'number') {
990
- return Number.isInteger(value) ? { type: 'integer' } : { type: 'number' };
991
- }
992
-
993
- if (typeof value === 'boolean') {
994
- return { type: 'boolean' };
995
- }
996
-
997
- return {};
998
- }
999
-
1000
- private inferStringFormat(value: string): string | null {
1001
- if (/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(value)) return 'email';
1002
- if (/^[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i.test(value)) return 'uuid';
1003
- if (/^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}/.test(value)) return 'date-time';
1004
- if (/^\d{4}-\d{2}-\d{2}$/.test(value)) return 'date';
1005
- try {
1006
- new URL(value);
1007
- return 'uri';
1008
- } catch {
1009
- return null;
1010
- }
1011
- }
1012
-
1013
- private mergeTypes(types: Record<string, unknown>[]): Record<string, unknown> {
1014
- if (types.length === 0) return {};
1015
- if (types.length === 1) return types[0];
1016
-
1017
- // Get unique types
1018
- const typeSet = new Set(types.map((t) => t.type as string));
1019
-
1020
- if (typeSet.size === 1) {
1021
- // All same type, merge properties if object
1022
- const baseType = types[0].type as string;
1023
-
1024
- if (baseType === 'object') {
1025
- const allProperties = new Map<string, Record<string, unknown>[]>();
1026
- const allRequired = new Set<string>();
1027
-
1028
- for (const type of types) {
1029
- const props = (type.properties as Record<string, Record<string, unknown>>) || {};
1030
- const req = (type.required as string[]) || [];
1031
-
1032
- for (const [key, val] of Object.entries(props)) {
1033
- if (!allProperties.has(key)) {
1034
- allProperties.set(key, []);
1035
- }
1036
- allProperties.get(key)!.push(val);
1037
- }
1038
-
1039
- for (const r of req) {
1040
- allRequired.add(r);
1041
- }
1042
- }
1043
-
1044
- const mergedProps: Record<string, Record<string, unknown>> = {};
1045
- const allPropertiesEntries = Array.from(allProperties.entries());
1046
- for (const [key, vals] of allPropertiesEntries) {
1047
- mergedProps[key] = this.mergeTypes(vals);
1048
- }
1049
-
1050
- // Only required if in all samples
1051
- const allRequiredArray = Array.from(allRequired);
1052
- const commonRequired = allRequiredArray.filter((r) =>
1053
- types.every((t) => ((t.required as string[]) || []).includes(r))
1054
- );
1055
-
1056
- return {
1057
- type: 'object',
1058
- properties: mergedProps,
1059
- required: commonRequired,
1060
- };
1061
- }
1062
-
1063
- if (baseType === 'array') {
1064
- const itemTypes = types
1065
- .map((t) => t.items as Record<string, unknown>)
1066
- .filter((i) => i && Object.keys(i).length > 0);
1067
- return {
1068
- type: 'array',
1069
- items: itemTypes.length > 0 ? this.mergeTypes(itemTypes) : {},
1070
- };
1071
- }
1072
-
1073
- return types[0];
1074
- }
1075
-
1076
- // Multiple types - use anyOf
1077
- return {
1078
- anyOf: types,
1079
- };
1080
- }
1081
-
1082
- private async storeComparisonResult(
1083
- oldSchema: SchemaDefinition,
1084
- newSchema: SchemaDefinition,
1085
- result: SchemaComparisonResult
1086
- ): Promise<void> {
1087
- const key = `contract-testing:schema-comparison:${oldSchema.id}:${newSchema.id}:${Date.now()}`;
1088
- await this.memory.set(
1089
- key,
1090
- {
1091
- oldSchemaId: oldSchema.id,
1092
- newSchemaId: newSchema.id,
1093
- isCompatible: result.isCompatible,
1094
- timestamp: new Date().toISOString(),
1095
- },
1096
- {
1097
- namespace: 'contract-testing',
1098
- ttl: 86400 * 30, // 30 days
1099
- }
1100
- );
1101
- }
1102
- }