agentic-qe 3.6.9 → 3.6.10

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 (55) hide show
  1. package/.claude/skills/.validation/schemas/skill-eval.schema.json +11 -1
  2. package/.claude/skills/pr-review/SKILL.md +2 -2
  3. package/.claude/skills/qcsd-production-swarm/SKILL.md +2781 -0
  4. package/.claude/skills/qcsd-production-swarm/evals/qcsd-production-swarm.yaml +246 -0
  5. package/.claude/skills/qcsd-production-swarm/schemas/output.json +505 -0
  6. package/.claude/skills/qcsd-production-swarm/scripts/validate-config.json +25 -0
  7. package/.claude/skills/skills-manifest.json +5 -5
  8. package/package.json +1 -1
  9. package/scripts/benchmark-hnsw-loading.ts +480 -0
  10. package/scripts/benchmark-kg-assisted.ts +725 -0
  11. package/scripts/collect-production-telemetry.sh +291 -0
  12. package/scripts/detect-skill-conflicts.ts +347 -0
  13. package/scripts/eval-driven-workflow.ts +704 -0
  14. package/scripts/run-skill-eval.ts +210 -10
  15. package/scripts/score-skill-quality.ts +511 -0
  16. package/v3/CHANGELOG.md +19 -0
  17. package/v3/assets/skills/pr-review/SKILL.md +2 -2
  18. package/v3/dist/cli/bundle.js +1064 -363
  19. package/v3/dist/cli/commands/hooks.d.ts.map +1 -1
  20. package/v3/dist/cli/commands/hooks.js +143 -2
  21. package/v3/dist/cli/commands/hooks.js.map +1 -1
  22. package/v3/dist/cli/commands/test.d.ts.map +1 -1
  23. package/v3/dist/cli/commands/test.js +6 -0
  24. package/v3/dist/cli/commands/test.js.map +1 -1
  25. package/v3/dist/domains/test-generation/generators/jest-vitest-generator.d.ts.map +1 -1
  26. package/v3/dist/domains/test-generation/generators/jest-vitest-generator.js +58 -6
  27. package/v3/dist/domains/test-generation/generators/jest-vitest-generator.js.map +1 -1
  28. package/v3/dist/domains/test-generation/generators/mocha-generator.d.ts.map +1 -1
  29. package/v3/dist/domains/test-generation/generators/mocha-generator.js +79 -7
  30. package/v3/dist/domains/test-generation/generators/mocha-generator.js.map +1 -1
  31. package/v3/dist/domains/test-generation/generators/pytest-generator.d.ts +4 -0
  32. package/v3/dist/domains/test-generation/generators/pytest-generator.d.ts.map +1 -1
  33. package/v3/dist/domains/test-generation/generators/pytest-generator.js +77 -10
  34. package/v3/dist/domains/test-generation/generators/pytest-generator.js.map +1 -1
  35. package/v3/dist/domains/test-generation/interfaces/test-generator.interface.d.ts +21 -0
  36. package/v3/dist/domains/test-generation/interfaces/test-generator.interface.d.ts.map +1 -1
  37. package/v3/dist/domains/test-generation/interfaces.d.ts +21 -0
  38. package/v3/dist/domains/test-generation/interfaces.d.ts.map +1 -1
  39. package/v3/dist/domains/test-generation/services/test-generator.d.ts +22 -0
  40. package/v3/dist/domains/test-generation/services/test-generator.d.ts.map +1 -1
  41. package/v3/dist/domains/test-generation/services/test-generator.js +163 -3
  42. package/v3/dist/domains/test-generation/services/test-generator.js.map +1 -1
  43. package/v3/dist/kernel/unified-memory-hnsw.d.ts +29 -0
  44. package/v3/dist/kernel/unified-memory-hnsw.d.ts.map +1 -1
  45. package/v3/dist/kernel/unified-memory-hnsw.js +136 -0
  46. package/v3/dist/kernel/unified-memory-hnsw.js.map +1 -1
  47. package/v3/dist/kernel/unified-memory.d.ts +2 -2
  48. package/v3/dist/kernel/unified-memory.d.ts.map +1 -1
  49. package/v3/dist/kernel/unified-memory.js +7 -9
  50. package/v3/dist/kernel/unified-memory.js.map +1 -1
  51. package/v3/dist/learning/qe-hooks.d.ts.map +1 -1
  52. package/v3/dist/learning/qe-hooks.js +34 -3
  53. package/v3/dist/learning/qe-hooks.js.map +1 -1
  54. package/v3/dist/mcp/bundle.js +857 -329
  55. package/v3/package.json +1 -1
@@ -4597,13 +4597,78 @@ var init_sql_safety = __esm({
4597
4597
  }
4598
4598
  });
4599
4599
 
4600
+ // native-require:@ruvector/gnn
4601
+ var gnn_exports = {};
4602
+ __export(gnn_exports, {
4603
+ DotProductAttention: () => DotProductAttention2,
4604
+ FlashAttention: () => FlashAttention2,
4605
+ HyperbolicAttention: () => HyperbolicAttention2,
4606
+ LinearAttention: () => LinearAttention2,
4607
+ MoEAttention: () => MoEAttention2,
4608
+ MultiHeadAttention: () => MultiHeadAttention2,
4609
+ RuvectorLayer: () => RuvectorLayer2,
4610
+ SonaEngine: () => SonaEngine2,
4611
+ TensorCompress: () => TensorCompress2,
4612
+ default: () => gnn_default,
4613
+ differentiableSearch: () => differentiableSearch2,
4614
+ getCompressionLevel: () => getCompressionLevel2,
4615
+ hierarchicalForward: () => hierarchicalForward2,
4616
+ init: () => init2,
4617
+ pipeline: () => pipeline2
4618
+ });
4619
+ import { createRequire as createRequire2 } from "module";
4620
+ var __require3, __mod2, gnn_default, RuvectorLayer2, TensorCompress2, differentiableSearch2, hierarchicalForward2, getCompressionLevel2, init2, FlashAttention2, DotProductAttention2, MultiHeadAttention2, HyperbolicAttention2, LinearAttention2, MoEAttention2, SonaEngine2, pipeline2;
4621
+ var init_gnn = __esm({
4622
+ "native-require:@ruvector/gnn"() {
4623
+ __require3 = createRequire2(import.meta.url);
4624
+ __mod2 = __require3("@ruvector/gnn");
4625
+ gnn_default = __mod2;
4626
+ ({
4627
+ RuvectorLayer: RuvectorLayer2,
4628
+ TensorCompress: TensorCompress2,
4629
+ differentiableSearch: differentiableSearch2,
4630
+ hierarchicalForward: hierarchicalForward2,
4631
+ getCompressionLevel: getCompressionLevel2,
4632
+ init: init2,
4633
+ FlashAttention: FlashAttention2,
4634
+ DotProductAttention: DotProductAttention2,
4635
+ MultiHeadAttention: MultiHeadAttention2,
4636
+ HyperbolicAttention: HyperbolicAttention2,
4637
+ LinearAttention: LinearAttention2,
4638
+ MoEAttention: MoEAttention2,
4639
+ SonaEngine: SonaEngine2,
4640
+ pipeline: pipeline2
4641
+ } = __mod2 || {});
4642
+ }
4643
+ });
4644
+
4600
4645
  // src/kernel/unified-memory-hnsw.ts
4601
- var BinaryHeap, InMemoryHNSWIndex;
4646
+ function computeNorm(v62) {
4647
+ let sum = 0;
4648
+ for (let i58 = 0; i58 < v62.length; i58++) sum += v62[i58] * v62[i58];
4649
+ return Math.sqrt(sum);
4650
+ }
4651
+ function fastCosine(a37, b68, normA, normB) {
4652
+ const denom = normA * normB;
4653
+ if (denom === 0) return 0;
4654
+ let dot = 0;
4655
+ for (let i58 = 0; i58 < a37.length; i58++) dot += a37[i58] * b68[i58];
4656
+ return dot / denom;
4657
+ }
4658
+ var ruvectorDifferentiableSearch, ruvectorInit, BinaryHeap, InMemoryHNSWIndex, RuvectorFlatIndex;
4602
4659
  var init_unified_memory_hnsw = __esm({
4603
4660
  "src/kernel/unified-memory-hnsw.ts"() {
4604
4661
  "use strict";
4605
4662
  init_vector_math();
4606
4663
  init_constants();
4664
+ ruvectorDifferentiableSearch = null;
4665
+ ruvectorInit = null;
4666
+ try {
4667
+ const gnn = (init_gnn(), __toCommonJS(gnn_exports));
4668
+ ruvectorDifferentiableSearch = gnn.differentiableSearch;
4669
+ ruvectorInit = gnn.init;
4670
+ } catch {
4671
+ }
4607
4672
  BinaryHeap = class {
4608
4673
  data = [];
4609
4674
  compareFn;
@@ -4936,6 +5001,94 @@ var init_unified_memory_hnsw = __esm({
4936
5001
  this.currentMaxLevel = -1;
4937
5002
  }
4938
5003
  };
5004
+ RuvectorFlatIndex = class {
5005
+ ids = [];
5006
+ vectors = [];
5007
+ /** Pre-computed L2 norms for each vector (enables dot-product-only cosine). */
5008
+ norms = [];
5009
+ idToIndex = /* @__PURE__ */ new Map();
5010
+ initialized = false;
5011
+ constructor() {
5012
+ if (ruvectorInit && !this.initialized) {
5013
+ try {
5014
+ ruvectorInit();
5015
+ this.initialized = true;
5016
+ } catch {
5017
+ this.initialized = ruvectorDifferentiableSearch !== null;
5018
+ }
5019
+ }
5020
+ }
5021
+ add(id, embedding) {
5022
+ const f322 = new Float32Array(embedding);
5023
+ const norm = computeNorm(f322);
5024
+ if (this.idToIndex.has(id)) {
5025
+ const idx2 = this.idToIndex.get(id);
5026
+ this.vectors[idx2] = f322;
5027
+ this.norms[idx2] = norm;
5028
+ return;
5029
+ }
5030
+ const idx = this.ids.length;
5031
+ this.ids.push(id);
5032
+ this.vectors.push(f322);
5033
+ this.norms.push(norm);
5034
+ this.idToIndex.set(id, idx);
5035
+ }
5036
+ search(query, k68) {
5037
+ if (this.ids.length === 0) return [];
5038
+ const actualK = Math.min(k68, this.ids.length);
5039
+ if (ruvectorDifferentiableSearch && this.vectors.length > 0) {
5040
+ const queryF322 = new Float32Array(query);
5041
+ const queryNorm2 = computeNorm(queryF322);
5042
+ const result = ruvectorDifferentiableSearch(
5043
+ queryF322,
5044
+ this.vectors,
5045
+ actualK,
5046
+ 1
5047
+ );
5048
+ return result.indices.map((idx) => ({
5049
+ id: this.ids[idx],
5050
+ score: fastCosine(queryF322, this.vectors[idx], queryNorm2, this.norms[idx])
5051
+ }));
5052
+ }
5053
+ const queryF32 = new Float32Array(query);
5054
+ const queryNorm = computeNorm(queryF32);
5055
+ const scored = [];
5056
+ for (let i58 = 0; i58 < this.ids.length; i58++) {
5057
+ scored.push({
5058
+ id: this.ids[i58],
5059
+ score: fastCosine(queryF32, this.vectors[i58], queryNorm, this.norms[i58])
5060
+ });
5061
+ }
5062
+ scored.sort((a37, b68) => b68.score - a37.score);
5063
+ return scored.slice(0, actualK);
5064
+ }
5065
+ remove(id) {
5066
+ const idx = this.idToIndex.get(id);
5067
+ if (idx === void 0) return false;
5068
+ const lastIdx = this.ids.length - 1;
5069
+ if (idx !== lastIdx) {
5070
+ const lastId = this.ids[lastIdx];
5071
+ this.ids[idx] = lastId;
5072
+ this.vectors[idx] = this.vectors[lastIdx];
5073
+ this.norms[idx] = this.norms[lastIdx];
5074
+ this.idToIndex.set(lastId, idx);
5075
+ }
5076
+ this.ids.pop();
5077
+ this.vectors.pop();
5078
+ this.norms.pop();
5079
+ this.idToIndex.delete(id);
5080
+ return true;
5081
+ }
5082
+ clear() {
5083
+ this.ids = [];
5084
+ this.vectors = [];
5085
+ this.norms = [];
5086
+ this.idToIndex.clear();
5087
+ }
5088
+ size() {
5089
+ return this.ids.length;
5090
+ }
5091
+ };
4939
5092
  }
4940
5093
  });
4941
5094
 
@@ -6490,6 +6643,7 @@ __export(unified_memory_exports, {
6490
6643
  BinaryHeap: () => BinaryHeap,
6491
6644
  DEFAULT_UNIFIED_MEMORY_CONFIG: () => DEFAULT_UNIFIED_MEMORY_CONFIG,
6492
6645
  InMemoryHNSWIndex: () => InMemoryHNSWIndex,
6646
+ RuvectorFlatIndex: () => RuvectorFlatIndex,
6493
6647
  UnifiedMemoryManager: () => UnifiedMemoryManager,
6494
6648
  clearProjectRootCache: () => clearProjectRootCache,
6495
6649
  findProjectRoot: () => findProjectRoot,
@@ -6620,7 +6774,7 @@ var init_unified_memory = __esm({
6620
6774
  vectorsLoaded = false;
6621
6775
  initPromise = null;
6622
6776
  preparedStatements = /* @__PURE__ */ new Map();
6623
- vectorIndex = new InMemoryHNSWIndex();
6777
+ vectorIndex = new RuvectorFlatIndex();
6624
6778
  // CRDT store for distributed state synchronization
6625
6779
  crdtStore = null;
6626
6780
  constructor(config) {
@@ -6788,7 +6942,7 @@ var init_unified_memory = __esm({
6788
6942
  this.vectorIndex.add(row2.id, embedding);
6789
6943
  }
6790
6944
  this.vectorsLoaded = true;
6791
- console.log(`[UnifiedMemory] Loaded ${rows.length} vectors into HNSW index`);
6945
+ console.log(`[UnifiedMemory] Loaded ${rows.length} vectors into vector index (ruvector flat)`);
6792
6946
  }
6793
6947
  // ============================================================================
6794
6948
  // KV Store Operations (v2 compatible)
@@ -7092,9 +7246,8 @@ var init_unified_memory = __esm({
7092
7246
  return buffer;
7093
7247
  }
7094
7248
  bufferToFloatArray(buffer, dimensions) {
7095
- const arr = [];
7096
- for (let i58 = 0; i58 < dimensions; i58++) arr.push(buffer.readFloatLE(i58 * 4));
7097
- return arr;
7249
+ const f322 = new Float32Array(buffer.buffer, buffer.byteOffset, dimensions);
7250
+ return Array.from(f322);
7098
7251
  }
7099
7252
  };
7100
7253
  exitHandlersRegistered = false;
@@ -7105,45 +7258,45 @@ var init_unified_memory = __esm({
7105
7258
  // native-require:@xenova/transformers
7106
7259
  var transformers_exports = {};
7107
7260
  __export(transformers_exports, {
7108
- DotProductAttention: () => DotProductAttention2,
7109
- FlashAttention: () => FlashAttention2,
7110
- HyperbolicAttention: () => HyperbolicAttention2,
7111
- LinearAttention: () => LinearAttention2,
7112
- MoEAttention: () => MoEAttention2,
7113
- MultiHeadAttention: () => MultiHeadAttention2,
7114
- RuvectorLayer: () => RuvectorLayer2,
7115
- SonaEngine: () => SonaEngine2,
7116
- TensorCompress: () => TensorCompress2,
7261
+ DotProductAttention: () => DotProductAttention3,
7262
+ FlashAttention: () => FlashAttention3,
7263
+ HyperbolicAttention: () => HyperbolicAttention3,
7264
+ LinearAttention: () => LinearAttention3,
7265
+ MoEAttention: () => MoEAttention3,
7266
+ MultiHeadAttention: () => MultiHeadAttention3,
7267
+ RuvectorLayer: () => RuvectorLayer3,
7268
+ SonaEngine: () => SonaEngine3,
7269
+ TensorCompress: () => TensorCompress3,
7117
7270
  default: () => transformers_default,
7118
- differentiableSearch: () => differentiableSearch2,
7119
- getCompressionLevel: () => getCompressionLevel2,
7120
- hierarchicalForward: () => hierarchicalForward2,
7121
- init: () => init2,
7122
- pipeline: () => pipeline2
7271
+ differentiableSearch: () => differentiableSearch3,
7272
+ getCompressionLevel: () => getCompressionLevel3,
7273
+ hierarchicalForward: () => hierarchicalForward3,
7274
+ init: () => init3,
7275
+ pipeline: () => pipeline3
7123
7276
  });
7124
- import { createRequire as createRequire2 } from "module";
7125
- var __require3, __mod2, transformers_default, RuvectorLayer2, TensorCompress2, differentiableSearch2, hierarchicalForward2, getCompressionLevel2, init2, FlashAttention2, DotProductAttention2, MultiHeadAttention2, HyperbolicAttention2, LinearAttention2, MoEAttention2, SonaEngine2, pipeline2;
7277
+ import { createRequire as createRequire3 } from "module";
7278
+ var __require4, __mod3, transformers_default, RuvectorLayer3, TensorCompress3, differentiableSearch3, hierarchicalForward3, getCompressionLevel3, init3, FlashAttention3, DotProductAttention3, MultiHeadAttention3, HyperbolicAttention3, LinearAttention3, MoEAttention3, SonaEngine3, pipeline3;
7126
7279
  var init_transformers = __esm({
7127
7280
  "native-require:@xenova/transformers"() {
7128
- __require3 = createRequire2(import.meta.url);
7129
- __mod2 = __require3("@xenova/transformers");
7130
- transformers_default = __mod2;
7281
+ __require4 = createRequire3(import.meta.url);
7282
+ __mod3 = __require4("@xenova/transformers");
7283
+ transformers_default = __mod3;
7131
7284
  ({
7132
- RuvectorLayer: RuvectorLayer2,
7133
- TensorCompress: TensorCompress2,
7134
- differentiableSearch: differentiableSearch2,
7135
- hierarchicalForward: hierarchicalForward2,
7136
- getCompressionLevel: getCompressionLevel2,
7137
- init: init2,
7138
- FlashAttention: FlashAttention2,
7139
- DotProductAttention: DotProductAttention2,
7140
- MultiHeadAttention: MultiHeadAttention2,
7141
- HyperbolicAttention: HyperbolicAttention2,
7142
- LinearAttention: LinearAttention2,
7143
- MoEAttention: MoEAttention2,
7144
- SonaEngine: SonaEngine2,
7145
- pipeline: pipeline2
7146
- } = __mod2 || {});
7285
+ RuvectorLayer: RuvectorLayer3,
7286
+ TensorCompress: TensorCompress3,
7287
+ differentiableSearch: differentiableSearch3,
7288
+ hierarchicalForward: hierarchicalForward3,
7289
+ getCompressionLevel: getCompressionLevel3,
7290
+ init: init3,
7291
+ FlashAttention: FlashAttention3,
7292
+ DotProductAttention: DotProductAttention3,
7293
+ MultiHeadAttention: MultiHeadAttention3,
7294
+ HyperbolicAttention: HyperbolicAttention3,
7295
+ LinearAttention: LinearAttention3,
7296
+ MoEAttention: MoEAttention3,
7297
+ SonaEngine: SonaEngine3,
7298
+ pipeline: pipeline3
7299
+ } = __mod3 || {});
7147
7300
  }
7148
7301
  });
7149
7302
 
@@ -7171,10 +7324,10 @@ async function initializeModel(config = {}) {
7171
7324
  initPromise = (async () => {
7172
7325
  try {
7173
7326
  const transformers = await Promise.resolve().then(() => (init_transformers(), transformers_exports));
7174
- pipeline3 = transformers.pipeline;
7327
+ pipeline4 = transformers.pipeline;
7175
7328
  console.log(`[RealEmbeddings] Loading model: ${fullConfig.modelName}`);
7176
7329
  const startTime = performance.now();
7177
- embeddingModel = await pipeline3("feature-extraction", fullConfig.modelName, {
7330
+ embeddingModel = await pipeline4("feature-extraction", fullConfig.modelName, {
7178
7331
  quantized: fullConfig.quantized
7179
7332
  });
7180
7333
  const loadTime = performance.now() - startTime;
@@ -7292,20 +7445,20 @@ function getEmbeddingDimension() {
7292
7445
  return 384;
7293
7446
  }
7294
7447
  function resetInitialization() {
7295
- pipeline3 = null;
7448
+ pipeline4 = null;
7296
7449
  embeddingModel = null;
7297
7450
  initPromise = null;
7298
7451
  initializationFailed = false;
7299
7452
  failureReason = "";
7300
7453
  embeddingCache.clear();
7301
7454
  }
7302
- var pipeline3, embeddingModel, initPromise, initializationFailed, failureReason, DEFAULT_EMBEDDING_CONFIG, embeddingCache, CACHE_TTL_MS;
7455
+ var pipeline4, embeddingModel, initPromise, initializationFailed, failureReason, DEFAULT_EMBEDDING_CONFIG, embeddingCache, CACHE_TTL_MS;
7303
7456
  var init_real_embeddings = __esm({
7304
7457
  "src/learning/real-embeddings.ts"() {
7305
7458
  "use strict";
7306
7459
  init_vector_math();
7307
7460
  init_error_utils();
7308
- pipeline3 = null;
7461
+ pipeline4 = null;
7309
7462
  embeddingModel = null;
7310
7463
  initPromise = null;
7311
7464
  initializationFailed = false;
@@ -7526,6 +7679,105 @@ var init_unified_persistence = __esm({
7526
7679
  }
7527
7680
  });
7528
7681
 
7682
+ // src/learning/qe-patterns.ts
7683
+ function detectQEDomain(taskDescription) {
7684
+ for (const [domain, pattern] of Object.entries(QE_DOMAINS)) {
7685
+ if (pattern.test(taskDescription)) {
7686
+ return domain;
7687
+ }
7688
+ }
7689
+ return null;
7690
+ }
7691
+ function detectQEDomains(taskDescription) {
7692
+ const detected = [];
7693
+ for (const [domain, pattern] of Object.entries(QE_DOMAINS)) {
7694
+ if (pattern.test(taskDescription)) {
7695
+ detected.push(domain);
7696
+ }
7697
+ }
7698
+ return detected;
7699
+ }
7700
+ function mapQEDomainToAQE(qeDomain) {
7701
+ return qeDomain;
7702
+ }
7703
+ function calculateQualityScore(pattern) {
7704
+ const usageScore = Math.min(pattern.usageCount / 100, 1);
7705
+ return pattern.confidence * 0.3 + usageScore * 0.2 + pattern.successRate * 0.5;
7706
+ }
7707
+ function shouldPromotePattern(pattern, coherenceEnergy, coherenceThreshold = 0.4) {
7708
+ const meetsUsageCriteria = pattern.tier === "short-term" && pattern.successfulUses >= 3;
7709
+ const meetsQualityCriteria = pattern.successRate >= 0.7 && pattern.confidence >= 0.6;
7710
+ const meetsCoherenceCriteria = coherenceEnergy === void 0 || coherenceEnergy < coherenceThreshold;
7711
+ let blockReason;
7712
+ if (!meetsUsageCriteria) {
7713
+ blockReason = "insufficient_usage";
7714
+ } else if (!meetsQualityCriteria) {
7715
+ blockReason = "low_quality";
7716
+ } else if (!meetsCoherenceCriteria) {
7717
+ blockReason = "coherence_violation";
7718
+ }
7719
+ return {
7720
+ meetsUsageCriteria,
7721
+ meetsQualityCriteria,
7722
+ meetsCoherenceCriteria,
7723
+ blockReason
7724
+ };
7725
+ }
7726
+ function validateQEPattern(pattern) {
7727
+ const errors = [];
7728
+ if (!pattern.id) errors.push("Pattern ID is required");
7729
+ if (!pattern.patternType) errors.push("Pattern type is required");
7730
+ if (!pattern.qeDomain) errors.push("QE domain is required");
7731
+ if (!pattern.name) errors.push("Pattern name is required");
7732
+ if (!pattern.template?.content) errors.push("Template content is required");
7733
+ if (pattern.confidence !== void 0 && (pattern.confidence < 0 || pattern.confidence > 1)) {
7734
+ errors.push("Confidence must be between 0 and 1");
7735
+ }
7736
+ if (pattern.successRate !== void 0 && (pattern.successRate < 0 || pattern.successRate > 1)) {
7737
+ errors.push("Success rate must be between 0 and 1");
7738
+ }
7739
+ if (pattern.template?.variables) {
7740
+ const variableNames = /* @__PURE__ */ new Set();
7741
+ for (const variable of pattern.template.variables) {
7742
+ if (variableNames.has(variable.name)) {
7743
+ errors.push(`Duplicate variable name: ${variable.name}`);
7744
+ }
7745
+ variableNames.add(variable.name);
7746
+ if (!pattern.template.content.includes(`{{${variable.name}}}`)) {
7747
+ errors.push(
7748
+ `Variable ${variable.name} not referenced in template`
7749
+ );
7750
+ }
7751
+ }
7752
+ }
7753
+ return { valid: errors.length === 0, errors };
7754
+ }
7755
+ var QE_DOMAINS, QE_DOMAIN_LIST;
7756
+ var init_qe_patterns = __esm({
7757
+ "src/learning/qe-patterns.ts"() {
7758
+ "use strict";
7759
+ QE_DOMAINS = {
7760
+ // Core Testing Domains
7761
+ "test-generation": /test|spec|describe|it\(|expect|assert|mock|stub|fixture|tdd|bdd/i,
7762
+ "test-execution": /run|execute|parallel|retry|flaky|timeout|worker|orchestrat/i,
7763
+ "coverage-analysis": /coverage|branch|line|uncovered|gap|untested|percentage|sublinear/i,
7764
+ // Quality Domains
7765
+ "quality-assessment": /quality|gate|deploy|readiness|metric|threshold|sla|score/i,
7766
+ "defect-intelligence": /defect|bug|predict|root.?cause|regression|failure|incident/i,
7767
+ "requirements-validation": /requirement|bdd|gherkin|testabil|accept|criteri|scenario/i,
7768
+ // Analysis Domains
7769
+ "code-intelligence": /semantic|knowledge|graph|ast|symbol|reference|impact|depend/i,
7770
+ "security-compliance": /vuln|cve|owasp|xss|sqli|injection|csrf|auth|secret|compliance|sast|dast/i,
7771
+ "contract-testing": /contract|pact|openapi|swagger|graphql|schema|endpoint|api/i,
7772
+ // Specialized Testing Domains
7773
+ "visual-accessibility": /screenshot|visual|snapshot|pixel|percy|a11y|aria|wcag|screen.?reader|accessible|contrast/i,
7774
+ "chaos-resilience": /chaos|resilience|fault|inject|blast|recover|latency|failure|stress|load/i,
7775
+ "learning-optimization": /learn|pattern|optim|neural|embedding|vector|memory|adapt|train/i
7776
+ };
7777
+ QE_DOMAIN_LIST = Object.keys(QE_DOMAINS);
7778
+ }
7779
+ });
7780
+
7529
7781
  // src/coordination/consensus/model-provider.ts
7530
7782
  function buildVerificationPrompt(finding, options = {}) {
7531
7783
  const {
@@ -9354,45 +9606,45 @@ Format your response with: verdict (confirmed/rejected/uncertain), confidence (0
9354
9606
  // native-require:@ruvector/sona
9355
9607
  var sona_exports = {};
9356
9608
  __export(sona_exports, {
9357
- DotProductAttention: () => DotProductAttention3,
9358
- FlashAttention: () => FlashAttention3,
9359
- HyperbolicAttention: () => HyperbolicAttention3,
9360
- LinearAttention: () => LinearAttention3,
9361
- MoEAttention: () => MoEAttention3,
9362
- MultiHeadAttention: () => MultiHeadAttention3,
9363
- RuvectorLayer: () => RuvectorLayer3,
9364
- SonaEngine: () => SonaEngine3,
9365
- TensorCompress: () => TensorCompress3,
9609
+ DotProductAttention: () => DotProductAttention4,
9610
+ FlashAttention: () => FlashAttention4,
9611
+ HyperbolicAttention: () => HyperbolicAttention4,
9612
+ LinearAttention: () => LinearAttention4,
9613
+ MoEAttention: () => MoEAttention4,
9614
+ MultiHeadAttention: () => MultiHeadAttention4,
9615
+ RuvectorLayer: () => RuvectorLayer4,
9616
+ SonaEngine: () => SonaEngine4,
9617
+ TensorCompress: () => TensorCompress4,
9366
9618
  default: () => sona_default,
9367
- differentiableSearch: () => differentiableSearch3,
9368
- getCompressionLevel: () => getCompressionLevel3,
9369
- hierarchicalForward: () => hierarchicalForward3,
9370
- init: () => init3,
9371
- pipeline: () => pipeline4
9619
+ differentiableSearch: () => differentiableSearch4,
9620
+ getCompressionLevel: () => getCompressionLevel4,
9621
+ hierarchicalForward: () => hierarchicalForward4,
9622
+ init: () => init4,
9623
+ pipeline: () => pipeline5
9372
9624
  });
9373
- import { createRequire as createRequire3 } from "module";
9374
- var __require4, __mod3, sona_default, RuvectorLayer3, TensorCompress3, differentiableSearch3, hierarchicalForward3, getCompressionLevel3, init3, FlashAttention3, DotProductAttention3, MultiHeadAttention3, HyperbolicAttention3, LinearAttention3, MoEAttention3, SonaEngine3, pipeline4;
9625
+ import { createRequire as createRequire4 } from "module";
9626
+ var __require5, __mod4, sona_default, RuvectorLayer4, TensorCompress4, differentiableSearch4, hierarchicalForward4, getCompressionLevel4, init4, FlashAttention4, DotProductAttention4, MultiHeadAttention4, HyperbolicAttention4, LinearAttention4, MoEAttention4, SonaEngine4, pipeline5;
9375
9627
  var init_sona = __esm({
9376
9628
  "native-require:@ruvector/sona"() {
9377
- __require4 = createRequire3(import.meta.url);
9378
- __mod3 = __require4("@ruvector/sona");
9379
- sona_default = __mod3;
9629
+ __require5 = createRequire4(import.meta.url);
9630
+ __mod4 = __require5("@ruvector/sona");
9631
+ sona_default = __mod4;
9380
9632
  ({
9381
- RuvectorLayer: RuvectorLayer3,
9382
- TensorCompress: TensorCompress3,
9383
- differentiableSearch: differentiableSearch3,
9384
- hierarchicalForward: hierarchicalForward3,
9385
- getCompressionLevel: getCompressionLevel3,
9386
- init: init3,
9387
- FlashAttention: FlashAttention3,
9388
- DotProductAttention: DotProductAttention3,
9389
- MultiHeadAttention: MultiHeadAttention3,
9390
- HyperbolicAttention: HyperbolicAttention3,
9391
- LinearAttention: LinearAttention3,
9392
- MoEAttention: MoEAttention3,
9393
- SonaEngine: SonaEngine3,
9394
- pipeline: pipeline4
9395
- } = __mod3 || {});
9633
+ RuvectorLayer: RuvectorLayer4,
9634
+ TensorCompress: TensorCompress4,
9635
+ differentiableSearch: differentiableSearch4,
9636
+ hierarchicalForward: hierarchicalForward4,
9637
+ getCompressionLevel: getCompressionLevel4,
9638
+ init: init4,
9639
+ FlashAttention: FlashAttention4,
9640
+ DotProductAttention: DotProductAttention4,
9641
+ MultiHeadAttention: MultiHeadAttention4,
9642
+ HyperbolicAttention: HyperbolicAttention4,
9643
+ LinearAttention: LinearAttention4,
9644
+ MoEAttention: MoEAttention4,
9645
+ SonaEngine: SonaEngine4,
9646
+ pipeline: pipeline5
9647
+ } = __mod4 || {});
9396
9648
  }
9397
9649
  });
9398
9650
 
@@ -9534,7 +9786,7 @@ var init_sona_wrapper = __esm({
9534
9786
  qualityThreshold: this.config.qualityThreshold,
9535
9787
  enableSimd: this.config.enableSimd
9536
9788
  };
9537
- this.engine = SonaEngine3.withConfig(jsConfig);
9789
+ this.engine = SonaEngine4.withConfig(jsConfig);
9538
9790
  this.registry = new QESONAPatternRegistry(this.config.maxPatterns ?? 1e4);
9539
9791
  }
9540
9792
  /**
@@ -9963,45 +10215,45 @@ var init_sona_wrapper = __esm({
9963
10215
  // native-require:@ruvector/attention
9964
10216
  var attention_exports = {};
9965
10217
  __export(attention_exports, {
9966
- DotProductAttention: () => DotProductAttention4,
9967
- FlashAttention: () => FlashAttention4,
9968
- HyperbolicAttention: () => HyperbolicAttention4,
9969
- LinearAttention: () => LinearAttention4,
9970
- MoEAttention: () => MoEAttention4,
9971
- MultiHeadAttention: () => MultiHeadAttention4,
9972
- RuvectorLayer: () => RuvectorLayer4,
9973
- SonaEngine: () => SonaEngine4,
9974
- TensorCompress: () => TensorCompress4,
10218
+ DotProductAttention: () => DotProductAttention5,
10219
+ FlashAttention: () => FlashAttention5,
10220
+ HyperbolicAttention: () => HyperbolicAttention5,
10221
+ LinearAttention: () => LinearAttention5,
10222
+ MoEAttention: () => MoEAttention5,
10223
+ MultiHeadAttention: () => MultiHeadAttention5,
10224
+ RuvectorLayer: () => RuvectorLayer5,
10225
+ SonaEngine: () => SonaEngine5,
10226
+ TensorCompress: () => TensorCompress5,
9975
10227
  default: () => attention_default,
9976
- differentiableSearch: () => differentiableSearch4,
9977
- getCompressionLevel: () => getCompressionLevel4,
9978
- hierarchicalForward: () => hierarchicalForward4,
9979
- init: () => init4,
9980
- pipeline: () => pipeline5
10228
+ differentiableSearch: () => differentiableSearch5,
10229
+ getCompressionLevel: () => getCompressionLevel5,
10230
+ hierarchicalForward: () => hierarchicalForward5,
10231
+ init: () => init5,
10232
+ pipeline: () => pipeline6
9981
10233
  });
9982
- import { createRequire as createRequire4 } from "module";
9983
- var __require5, __mod4, attention_default, RuvectorLayer4, TensorCompress4, differentiableSearch4, hierarchicalForward4, getCompressionLevel4, init4, FlashAttention4, DotProductAttention4, MultiHeadAttention4, HyperbolicAttention4, LinearAttention4, MoEAttention4, SonaEngine4, pipeline5;
10234
+ import { createRequire as createRequire5 } from "module";
10235
+ var __require6, __mod5, attention_default, RuvectorLayer5, TensorCompress5, differentiableSearch5, hierarchicalForward5, getCompressionLevel5, init5, FlashAttention5, DotProductAttention5, MultiHeadAttention5, HyperbolicAttention5, LinearAttention5, MoEAttention5, SonaEngine5, pipeline6;
9984
10236
  var init_attention = __esm({
9985
10237
  "native-require:@ruvector/attention"() {
9986
- __require5 = createRequire4(import.meta.url);
9987
- __mod4 = __require5("@ruvector/attention");
9988
- attention_default = __mod4;
10238
+ __require6 = createRequire5(import.meta.url);
10239
+ __mod5 = __require6("@ruvector/attention");
10240
+ attention_default = __mod5;
9989
10241
  ({
9990
- RuvectorLayer: RuvectorLayer4,
9991
- TensorCompress: TensorCompress4,
9992
- differentiableSearch: differentiableSearch4,
9993
- hierarchicalForward: hierarchicalForward4,
9994
- getCompressionLevel: getCompressionLevel4,
9995
- init: init4,
9996
- FlashAttention: FlashAttention4,
9997
- DotProductAttention: DotProductAttention4,
9998
- MultiHeadAttention: MultiHeadAttention4,
9999
- HyperbolicAttention: HyperbolicAttention4,
10000
- LinearAttention: LinearAttention4,
10001
- MoEAttention: MoEAttention4,
10002
- SonaEngine: SonaEngine4,
10003
- pipeline: pipeline5
10004
- } = __mod4 || {});
10242
+ RuvectorLayer: RuvectorLayer5,
10243
+ TensorCompress: TensorCompress5,
10244
+ differentiableSearch: differentiableSearch5,
10245
+ hierarchicalForward: hierarchicalForward5,
10246
+ getCompressionLevel: getCompressionLevel5,
10247
+ init: init5,
10248
+ FlashAttention: FlashAttention5,
10249
+ DotProductAttention: DotProductAttention5,
10250
+ MultiHeadAttention: MultiHeadAttention5,
10251
+ HyperbolicAttention: HyperbolicAttention5,
10252
+ LinearAttention: LinearAttention5,
10253
+ MoEAttention: MoEAttention5,
10254
+ SonaEngine: SonaEngine5,
10255
+ pipeline: pipeline6
10256
+ } = __mod5 || {});
10005
10257
  }
10006
10258
  });
10007
10259
 
@@ -10159,23 +10411,23 @@ var init_attention_wrapper = __esm({
10159
10411
  static create(config) {
10160
10412
  switch (config.strategy) {
10161
10413
  case "flash":
10162
- return new FlashAttention4(config.dim, config.blockSize);
10414
+ return new FlashAttention5(config.dim, config.blockSize);
10163
10415
  case "dot-product":
10164
- return new DotProductAttention4(config.dim);
10416
+ return new DotProductAttention5(config.dim);
10165
10417
  case "multi-head":
10166
- return new MultiHeadAttention4(config.dim, config.numHeads ?? 8);
10418
+ return new MultiHeadAttention5(config.dim, config.numHeads ?? 8);
10167
10419
  case "hyperbolic":
10168
- return new HyperbolicAttention4(config.dim, config.curvature);
10420
+ return new HyperbolicAttention5(config.dim, config.curvature);
10169
10421
  case "linear":
10170
- return new LinearAttention4(config.dim, config.features);
10422
+ return new LinearAttention5(config.dim, config.features);
10171
10423
  case "moe":
10172
- return MoEAttention4.simple(
10424
+ return MoEAttention5.simple(
10173
10425
  config.dim,
10174
10426
  config.moeConfig?.numExperts ?? 8,
10175
10427
  config.moeConfig?.topK ?? 2
10176
10428
  );
10177
10429
  default:
10178
- return new FlashAttention4(config.dim, config.blockSize);
10430
+ return new FlashAttention5(config.dim, config.blockSize);
10179
10431
  }
10180
10432
  }
10181
10433
  };
@@ -10232,20 +10484,20 @@ var init_attention_wrapper = __esm({
10232
10484
  const keys = this.splitMatrix(K58, seqLen, dim);
10233
10485
  const values = this.splitMatrix(V45, seqLen, dim);
10234
10486
  let output;
10235
- if (this.attention instanceof FlashAttention4) {
10487
+ if (this.attention instanceof FlashAttention5) {
10236
10488
  output = this.attention.compute(query, keys, values);
10237
- } else if (this.attention instanceof DotProductAttention4) {
10489
+ } else if (this.attention instanceof DotProductAttention5) {
10238
10490
  output = this.attention.compute(query, keys, values);
10239
- } else if (this.attention instanceof MultiHeadAttention4) {
10491
+ } else if (this.attention instanceof MultiHeadAttention5) {
10240
10492
  output = this.attention.compute(query, keys, values);
10241
- } else if (this.attention instanceof HyperbolicAttention4) {
10493
+ } else if (this.attention instanceof HyperbolicAttention5) {
10242
10494
  output = this.attention.compute(query, keys, values);
10243
- } else if (this.attention instanceof LinearAttention4) {
10495
+ } else if (this.attention instanceof LinearAttention5) {
10244
10496
  output = this.attention.compute(query, keys, values);
10245
- } else if (this.attention instanceof MoEAttention4) {
10497
+ } else if (this.attention instanceof MoEAttention5) {
10246
10498
  output = this.attention.compute(query, keys, values);
10247
10499
  } else {
10248
- const fallback = new FlashAttention4(this.config.dim);
10500
+ const fallback = new FlashAttention5(this.config.dim);
10249
10501
  output = fallback.compute(query, keys, values);
10250
10502
  }
10251
10503
  const endTime = performance.now();
@@ -10490,65 +10742,20 @@ var init_attention_wrapper = __esm({
10490
10742
  }
10491
10743
  });
10492
10744
 
10493
- // native-require:@ruvector/gnn
10494
- var gnn_exports = {};
10495
- __export(gnn_exports, {
10496
- DotProductAttention: () => DotProductAttention5,
10497
- FlashAttention: () => FlashAttention5,
10498
- HyperbolicAttention: () => HyperbolicAttention5,
10499
- LinearAttention: () => LinearAttention5,
10500
- MoEAttention: () => MoEAttention5,
10501
- MultiHeadAttention: () => MultiHeadAttention5,
10502
- RuvectorLayer: () => RuvectorLayer5,
10503
- SonaEngine: () => SonaEngine5,
10504
- TensorCompress: () => TensorCompress5,
10505
- default: () => gnn_default,
10506
- differentiableSearch: () => differentiableSearch5,
10507
- getCompressionLevel: () => getCompressionLevel5,
10508
- hierarchicalForward: () => hierarchicalForward5,
10509
- init: () => init5,
10510
- pipeline: () => pipeline6
10511
- });
10512
- import { createRequire as createRequire5 } from "module";
10513
- var __require6, __mod5, gnn_default, RuvectorLayer5, TensorCompress5, differentiableSearch5, hierarchicalForward5, getCompressionLevel5, init5, FlashAttention5, DotProductAttention5, MultiHeadAttention5, HyperbolicAttention5, LinearAttention5, MoEAttention5, SonaEngine5, pipeline6;
10514
- var init_gnn = __esm({
10515
- "native-require:@ruvector/gnn"() {
10516
- __require6 = createRequire5(import.meta.url);
10517
- __mod5 = __require6("@ruvector/gnn");
10518
- gnn_default = __mod5;
10519
- ({
10520
- RuvectorLayer: RuvectorLayer5,
10521
- TensorCompress: TensorCompress5,
10522
- differentiableSearch: differentiableSearch5,
10523
- hierarchicalForward: hierarchicalForward5,
10524
- getCompressionLevel: getCompressionLevel5,
10525
- init: init5,
10526
- FlashAttention: FlashAttention5,
10527
- DotProductAttention: DotProductAttention5,
10528
- MultiHeadAttention: MultiHeadAttention5,
10529
- HyperbolicAttention: HyperbolicAttention5,
10530
- LinearAttention: LinearAttention5,
10531
- MoEAttention: MoEAttention5,
10532
- SonaEngine: SonaEngine5,
10533
- pipeline: pipeline6
10534
- } = __mod5 || {});
10535
- }
10536
- });
10537
-
10538
10745
  // src/integrations/ruvector/gnn-wrapper.ts
10539
10746
  var gnn_wrapper_exports = {};
10540
10747
  __export(gnn_wrapper_exports, {
10541
10748
  GNNLayerFactory: () => GNNLayerFactory,
10542
10749
  QEGNNEmbeddingIndex: () => QEGNNEmbeddingIndex,
10543
10750
  QEGNNIndexFactory: () => QEGNNIndexFactory,
10544
- RuvectorLayer: () => RuvectorLayer5,
10545
- TensorCompress: () => TensorCompress5,
10751
+ RuvectorLayer: () => RuvectorLayer2,
10752
+ TensorCompress: () => TensorCompress2,
10546
10753
  TensorCompressionFactory: () => TensorCompressionFactory,
10547
10754
  batchDifferentiableSearch: () => batchDifferentiableSearch,
10548
- differentiableSearch: () => differentiableSearch5,
10549
- getCompressionLevel: () => getCompressionLevel5,
10550
- hierarchicalForward: () => hierarchicalForward5,
10551
- init: () => init5,
10755
+ differentiableSearch: () => differentiableSearch2,
10756
+ getCompressionLevel: () => getCompressionLevel2,
10757
+ hierarchicalForward: () => hierarchicalForward2,
10758
+ init: () => init2,
10552
10759
  initGNN: () => initGNN,
10553
10760
  toFloat32Array: () => toFloat32Array2,
10554
10761
  toIEmbedding: () => toIEmbedding,
@@ -10556,7 +10763,7 @@ __export(gnn_wrapper_exports, {
10556
10763
  });
10557
10764
  function initGNN() {
10558
10765
  if (!gnnInitialized) {
10559
- const result = init5();
10766
+ const result = init2();
10560
10767
  gnnInitialized = true;
10561
10768
  return result;
10562
10769
  }
@@ -10597,7 +10804,7 @@ function batchDifferentiableSearch(queries, candidateEmbeddings, k68, temperatur
10597
10804
  );
10598
10805
  for (const query of queries) {
10599
10806
  const queryFloat32 = query instanceof Float32Array ? query : new Float32Array(query);
10600
- const result = differentiableSearch5(
10807
+ const result = differentiableSearch2(
10601
10808
  queryFloat32,
10602
10809
  candidatesFloat32,
10603
10810
  k68,
@@ -10635,7 +10842,7 @@ var init_gnn_wrapper = __esm({
10635
10842
  this.indexes = /* @__PURE__ */ new Map();
10636
10843
  this.nextId = /* @__PURE__ */ new Map();
10637
10844
  this.gnnLayers = /* @__PURE__ */ new Map();
10638
- this.compressor = new TensorCompress5();
10845
+ this.compressor = new TensorCompress2();
10639
10846
  initGNN();
10640
10847
  }
10641
10848
  /**
@@ -10696,7 +10903,7 @@ var init_gnn_wrapper = __esm({
10696
10903
  }
10697
10904
  const queryFloat32 = new Float32Array(query.vector);
10698
10905
  const candidateFloat32s = candidates.map((c70) => new Float32Array(c70.vector));
10699
- const result = differentiableSearch5(
10906
+ const result = differentiableSearch2(
10700
10907
  queryFloat32,
10701
10908
  candidateFloat32s,
10702
10909
  Math.min(k68, candidates.length),
@@ -10719,7 +10926,7 @@ var init_gnn_wrapper = __esm({
10719
10926
  const candidateVectors = candidates.map(
10720
10927
  (c70) => new Float32Array(c70.embedding.vector)
10721
10928
  );
10722
- const result = differentiableSearch5(
10929
+ const result = differentiableSearch2(
10723
10930
  queryVector,
10724
10931
  candidateVectors,
10725
10932
  Math.min(k68, candidates.length),
@@ -10740,7 +10947,7 @@ var init_gnn_wrapper = __esm({
10740
10947
  if (!this.gnnLayers.has(layerKey)) {
10741
10948
  const layers = [];
10742
10949
  for (const config of layerConfigs) {
10743
- const layer2 = new RuvectorLayer5(
10950
+ const layer2 = new RuvectorLayer2(
10744
10951
  config.inputDim,
10745
10952
  config.hiddenDim,
10746
10953
  config.heads,
@@ -10756,7 +10963,7 @@ var init_gnn_wrapper = __esm({
10756
10963
  const layerEmbeddingsFloat32 = layerEmbeddings.map(
10757
10964
  (layer2) => layer2.map((emb) => new Float32Array(emb))
10758
10965
  );
10759
- return Array.from(hierarchicalForward5(
10966
+ return Array.from(hierarchicalForward2(
10760
10967
  queryFloat32,
10761
10968
  layerEmbeddingsFloat32,
10762
10969
  [gnnLayerJson]
@@ -10771,7 +10978,7 @@ var init_gnn_wrapper = __esm({
10771
10978
  * - Cold data (low access): product quantization
10772
10979
  */
10773
10980
  compressEmbedding(embedding, accessFreq) {
10774
- const rawLevel = getCompressionLevel5(accessFreq);
10981
+ const rawLevel = getCompressionLevel2(accessFreq);
10775
10982
  const levelMap = {
10776
10983
  "none": "none",
10777
10984
  "half": "half",
@@ -10817,7 +11024,7 @@ var init_gnn_wrapper = __esm({
10817
11024
  * Get compression level for access frequency
10818
11025
  */
10819
11026
  getCompressionLevelForFrequency(accessFreq) {
10820
- return getCompressionLevel5(accessFreq);
11027
+ return getCompressionLevel2(accessFreq);
10821
11028
  }
10822
11029
  /**
10823
11030
  * Get index statistics
@@ -10961,7 +11168,7 @@ var init_gnn_wrapper = __esm({
10961
11168
  static getLayer(config) {
10962
11169
  const key = `${config.inputDim}-${config.hiddenDim}-${config.heads}-${config.dropout}`;
10963
11170
  if (!this.layers.has(key)) {
10964
- const layer = new RuvectorLayer5(
11171
+ const layer = new RuvectorLayer2(
10965
11172
  config.inputDim,
10966
11173
  config.hiddenDim,
10967
11174
  config.heads,
@@ -10975,7 +11182,7 @@ var init_gnn_wrapper = __esm({
10975
11182
  * Create layer from JSON
10976
11183
  */
10977
11184
  static layerFromJson(json) {
10978
- return RuvectorLayer5.fromJson(json);
11185
+ return RuvectorLayer2.fromJson(json);
10979
11186
  }
10980
11187
  /**
10981
11188
  * Clear cached layers
@@ -10985,7 +11192,7 @@ var init_gnn_wrapper = __esm({
10985
11192
  }
10986
11193
  };
10987
11194
  TensorCompressionFactory = class {
10988
- static compressor = new TensorCompress5();
11195
+ static compressor = new TensorCompress2();
10989
11196
  /**
10990
11197
  * Compress tensor with specific level
10991
11198
  */
@@ -11011,7 +11218,7 @@ var init_gnn_wrapper = __esm({
11011
11218
  * Get compression level for frequency
11012
11219
  */
11013
11220
  static getLevel(accessFreq) {
11014
- return getCompressionLevel5(accessFreq);
11221
+ return getCompressionLevel2(accessFreq);
11015
11222
  }
11016
11223
  };
11017
11224
  }
@@ -11028,14 +11235,14 @@ __export(wrappers_exports, {
11028
11235
  QE_FLASH_ATTENTION_CONFIG: () => QE_FLASH_ATTENTION_CONFIG,
11029
11236
  QE_PERFORMANCE_TARGETS: () => QE_PERFORMANCE_TARGETS,
11030
11237
  QE_SONA_CONFIG: () => QE_SONA_CONFIG,
11031
- RuvectorDotProductAttention: () => DotProductAttention4,
11032
- RuvectorFlashAttention: () => FlashAttention4,
11033
- RuvectorHyperbolicAttention: () => HyperbolicAttention4,
11034
- RuvectorLayer: () => RuvectorLayer5,
11035
- RuvectorLinearAttention: () => LinearAttention4,
11036
- RuvectorMoEAttention: () => MoEAttention4,
11037
- RuvectorMultiHeadAttention: () => MultiHeadAttention4,
11038
- TensorCompress: () => TensorCompress5,
11238
+ RuvectorDotProductAttention: () => DotProductAttention5,
11239
+ RuvectorFlashAttention: () => FlashAttention5,
11240
+ RuvectorHyperbolicAttention: () => HyperbolicAttention5,
11241
+ RuvectorLayer: () => RuvectorLayer2,
11242
+ RuvectorLinearAttention: () => LinearAttention5,
11243
+ RuvectorMoEAttention: () => MoEAttention5,
11244
+ RuvectorMultiHeadAttention: () => MultiHeadAttention5,
11245
+ TensorCompress: () => TensorCompress2,
11039
11246
  TensorCompressionFactory: () => TensorCompressionFactory,
11040
11247
  batchComputeAttention: () => batchComputeAttention,
11041
11248
  batchDifferentiableSearch: () => batchDifferentiableSearch,
@@ -11043,14 +11250,14 @@ __export(wrappers_exports, {
11043
11250
  createDomainQESONA: () => createDomainQESONA,
11044
11251
  createQEFlashAttention: () => createQEFlashAttention,
11045
11252
  createQESONA: () => createQESONA,
11046
- differentiableSearch: () => differentiableSearch5,
11047
- getCompressionLevel: () => getCompressionLevel5,
11253
+ differentiableSearch: () => differentiableSearch2,
11254
+ getCompressionLevel: () => getCompressionLevel2,
11048
11255
  getOptimalBlockConfig: () => getOptimalBlockConfig,
11049
11256
  getQEFlashAttentionConfig: () => getQEFlashAttentionConfig,
11050
11257
  getRuvectorPackageVersions: () => getRuvectorPackageVersions,
11051
11258
  getWorkloadTypes: () => getWorkloadTypes,
11052
- hierarchicalForward: () => hierarchicalForward5,
11053
- init: () => init5,
11259
+ hierarchicalForward: () => hierarchicalForward2,
11260
+ init: () => init2,
11054
11261
  initAllRuvectorPackages: () => initAllRuvectorPackages,
11055
11262
  initGNN: () => initGNN,
11056
11263
  toFloat32Array: () => toFloat32Array,
@@ -14209,105 +14416,6 @@ var init_dream = __esm({
14209
14416
  }
14210
14417
  });
14211
14418
 
14212
- // src/learning/qe-patterns.ts
14213
- function detectQEDomain(taskDescription) {
14214
- for (const [domain, pattern] of Object.entries(QE_DOMAINS)) {
14215
- if (pattern.test(taskDescription)) {
14216
- return domain;
14217
- }
14218
- }
14219
- return null;
14220
- }
14221
- function detectQEDomains(taskDescription) {
14222
- const detected = [];
14223
- for (const [domain, pattern] of Object.entries(QE_DOMAINS)) {
14224
- if (pattern.test(taskDescription)) {
14225
- detected.push(domain);
14226
- }
14227
- }
14228
- return detected;
14229
- }
14230
- function mapQEDomainToAQE(qeDomain) {
14231
- return qeDomain;
14232
- }
14233
- function calculateQualityScore(pattern) {
14234
- const usageScore = Math.min(pattern.usageCount / 100, 1);
14235
- return pattern.confidence * 0.3 + usageScore * 0.2 + pattern.successRate * 0.5;
14236
- }
14237
- function shouldPromotePattern(pattern, coherenceEnergy, coherenceThreshold = 0.4) {
14238
- const meetsUsageCriteria = pattern.tier === "short-term" && pattern.successfulUses >= 3;
14239
- const meetsQualityCriteria = pattern.successRate >= 0.7 && pattern.confidence >= 0.6;
14240
- const meetsCoherenceCriteria = coherenceEnergy === void 0 || coherenceEnergy < coherenceThreshold;
14241
- let blockReason;
14242
- if (!meetsUsageCriteria) {
14243
- blockReason = "insufficient_usage";
14244
- } else if (!meetsQualityCriteria) {
14245
- blockReason = "low_quality";
14246
- } else if (!meetsCoherenceCriteria) {
14247
- blockReason = "coherence_violation";
14248
- }
14249
- return {
14250
- meetsUsageCriteria,
14251
- meetsQualityCriteria,
14252
- meetsCoherenceCriteria,
14253
- blockReason
14254
- };
14255
- }
14256
- function validateQEPattern(pattern) {
14257
- const errors = [];
14258
- if (!pattern.id) errors.push("Pattern ID is required");
14259
- if (!pattern.patternType) errors.push("Pattern type is required");
14260
- if (!pattern.qeDomain) errors.push("QE domain is required");
14261
- if (!pattern.name) errors.push("Pattern name is required");
14262
- if (!pattern.template?.content) errors.push("Template content is required");
14263
- if (pattern.confidence !== void 0 && (pattern.confidence < 0 || pattern.confidence > 1)) {
14264
- errors.push("Confidence must be between 0 and 1");
14265
- }
14266
- if (pattern.successRate !== void 0 && (pattern.successRate < 0 || pattern.successRate > 1)) {
14267
- errors.push("Success rate must be between 0 and 1");
14268
- }
14269
- if (pattern.template?.variables) {
14270
- const variableNames = /* @__PURE__ */ new Set();
14271
- for (const variable of pattern.template.variables) {
14272
- if (variableNames.has(variable.name)) {
14273
- errors.push(`Duplicate variable name: ${variable.name}`);
14274
- }
14275
- variableNames.add(variable.name);
14276
- if (!pattern.template.content.includes(`{{${variable.name}}}`)) {
14277
- errors.push(
14278
- `Variable ${variable.name} not referenced in template`
14279
- );
14280
- }
14281
- }
14282
- }
14283
- return { valid: errors.length === 0, errors };
14284
- }
14285
- var QE_DOMAINS, QE_DOMAIN_LIST;
14286
- var init_qe_patterns = __esm({
14287
- "src/learning/qe-patterns.ts"() {
14288
- "use strict";
14289
- QE_DOMAINS = {
14290
- // Core Testing Domains
14291
- "test-generation": /test|spec|describe|it\(|expect|assert|mock|stub|fixture|tdd|bdd/i,
14292
- "test-execution": /run|execute|parallel|retry|flaky|timeout|worker|orchestrat/i,
14293
- "coverage-analysis": /coverage|branch|line|uncovered|gap|untested|percentage|sublinear/i,
14294
- // Quality Domains
14295
- "quality-assessment": /quality|gate|deploy|readiness|metric|threshold|sla|score/i,
14296
- "defect-intelligence": /defect|bug|predict|root.?cause|regression|failure|incident/i,
14297
- "requirements-validation": /requirement|bdd|gherkin|testabil|accept|criteri|scenario/i,
14298
- // Analysis Domains
14299
- "code-intelligence": /semantic|knowledge|graph|ast|symbol|reference|impact|depend/i,
14300
- "security-compliance": /vuln|cve|owasp|xss|sqli|injection|csrf|auth|secret|compliance|sast|dast/i,
14301
- "contract-testing": /contract|pact|openapi|swagger|graphql|schema|endpoint|api/i,
14302
- // Specialized Testing Domains
14303
- "visual-accessibility": /screenshot|visual|snapshot|pixel|percy|a11y|aria|wcag|screen.?reader|accessible|contrast/i,
14304
- "chaos-resilience": /chaos|resilience|fault|inject|blast|recover|latency|failure|stress|load/i,
14305
- "learning-optimization": /learn|pattern|optim|neural|embedding|vector|memory|adapt|train/i
14306
- };
14307
- QE_DOMAIN_LIST = Object.keys(QE_DOMAINS);
14308
- }
14309
- });
14310
-
14311
14419
  // src/integrations/agentic-flow/agent-booster/types.ts
14312
14420
  var ALL_TRANSFORM_TYPES, TRANSFORM_METADATA, DEFAULT_AGENT_BOOSTER_CONFIG, AgentBoosterError, TransformError, WasmUnavailableError, TransformTimeoutError, FileTooLargeError;
14313
14421
  var init_types4 = __esm({
@@ -38624,7 +38732,7 @@ var JestVitestGenerator = class extends BaseTestGenerator {
38624
38732
  * Generate complete test file from analysis
38625
38733
  */
38626
38734
  generateTests(context) {
38627
- const { moduleName, importPath, testType, patterns, analysis } = context;
38735
+ const { moduleName, importPath, testType, patterns, analysis, dependencies } = context;
38628
38736
  if (!analysis || analysis.functions.length === 0 && analysis.classes.length === 0) {
38629
38737
  return this.generateStubTests(context);
38630
38738
  }
@@ -38634,8 +38742,23 @@ var JestVitestGenerator = class extends BaseTestGenerator {
38634
38742
  const mockImport = this.framework === "vitest" ? ", vi" : "";
38635
38743
  let testCode = `${patternComment}import { describe, it, expect, beforeEach${mockImport} } from '${this.framework}';
38636
38744
  ${importStatement}
38637
-
38638
38745
  `;
38746
+ if (dependencies && dependencies.imports.length > 0) {
38747
+ const mockFn = this.framework === "vitest" ? "vi.fn()" : "jest.fn()";
38748
+ testCode += `
38749
+ // Auto-generated mocks from Knowledge Graph dependency analysis
38750
+ `;
38751
+ for (const dep of dependencies.imports.slice(0, 10)) {
38752
+ const depName = dep.split("/").pop()?.replace(/[^a-zA-Z0-9_]/g, "_") || dep;
38753
+ testCode += `${this.framework === "vitest" ? "vi" : "jest"}.mock('${dep}', () => ({ default: ${mockFn} }));
38754
+ `;
38755
+ }
38756
+ testCode += `
38757
+ `;
38758
+ } else {
38759
+ testCode += `
38760
+ `;
38761
+ }
38639
38762
  for (const fn of analysis.functions) {
38640
38763
  testCode += this.generateFunctionTests(fn, testType);
38641
38764
  }
@@ -38755,22 +38878,80 @@ ${importStatement}
38755
38878
  * Generate stub tests when no AST analysis is available
38756
38879
  */
38757
38880
  generateStubTests(context) {
38758
- const { moduleName, importPath, testType, patterns } = context;
38881
+ const { moduleName, importPath, testType, patterns, dependencies, similarCode } = context;
38759
38882
  const patternComment = this.generatePatternComment(patterns);
38760
38883
  const basicOpsTest = this.generateBasicOpsTest(moduleName, patterns);
38761
38884
  const edgeCaseTest = this.generateEdgeCaseTest(moduleName, patterns);
38762
38885
  const errorHandlingTest = this.generateErrorHandlingTest(moduleName, patterns);
38886
+ let mockDeclarations = "";
38887
+ if (dependencies && dependencies.imports.length > 0) {
38888
+ const mockFn = this.framework === "vitest" ? "vi.fn()" : "jest.fn()";
38889
+ mockDeclarations += `
38890
+ // Auto-generated mocks from Knowledge Graph dependency analysis
38891
+ `;
38892
+ for (const dep of dependencies.imports.slice(0, 10)) {
38893
+ mockDeclarations += `${this.mockUtil}.mock('${dep}', () => ({ default: ${mockFn} }));
38894
+ `;
38895
+ }
38896
+ }
38897
+ let similarityComment = "";
38898
+ if (similarCode && similarCode.snippets.length > 0) {
38899
+ similarityComment += ` // KG: Similar modules found - consider testing shared patterns:
38900
+ `;
38901
+ for (const s70 of similarCode.snippets.slice(0, 3)) {
38902
+ similarityComment += ` // - ${s70.file} (${(s70.score * 100).toFixed(0)}% similar)
38903
+ `;
38904
+ }
38905
+ similarityComment += `
38906
+ `;
38907
+ }
38908
+ let depTest = "";
38909
+ if (dependencies && dependencies.imports.length > 0) {
38910
+ depTest += `
38911
+ it('should interact with dependencies correctly', () => {
38912
+ `;
38913
+ depTest += ` // KG-informed: module depends on ${dependencies.imports.length} imports
38914
+ `;
38915
+ depTest += ` const instance = typeof ${moduleName} === 'function'
38916
+ `;
38917
+ depTest += ` ? new ${moduleName}()
38918
+ `;
38919
+ depTest += ` : ${moduleName};
38920
+ `;
38921
+ depTest += ` expect(instance).toBeDefined();
38922
+ `;
38923
+ depTest += ` });
38924
+ `;
38925
+ }
38926
+ let callerTest = "";
38927
+ if (dependencies && dependencies.importedBy.length > 0) {
38928
+ callerTest += `
38929
+ it('should expose stable API for ${dependencies.importedBy.length} consumers', () => {
38930
+ `;
38931
+ callerTest += ` // KG-informed: used by ${dependencies.importedBy.slice(0, 3).join(", ")}
38932
+ `;
38933
+ callerTest += ` const publicKeys = Object.keys(typeof ${moduleName} === 'function'
38934
+ `;
38935
+ callerTest += ` ? ${moduleName}.prototype || {}
38936
+ `;
38937
+ callerTest += ` : ${moduleName});
38938
+ `;
38939
+ callerTest += ` expect(publicKeys.length).toBeGreaterThan(0);
38940
+ `;
38941
+ callerTest += ` });
38942
+ `;
38943
+ }
38763
38944
  return `${patternComment}import { ${moduleName} } from '${importPath}';
38764
-
38945
+ ${mockDeclarations}
38765
38946
  describe('${moduleName}', () => {
38766
- describe('${testType} tests', () => {
38947
+ ${similarityComment} describe('${testType} tests', () => {
38767
38948
  it('should be defined', () => {
38768
38949
  expect(${moduleName}).toBeDefined();
38769
38950
  });
38770
38951
 
38771
38952
  ${basicOpsTest}
38772
38953
  ${edgeCaseTest}
38773
- ${errorHandlingTest}
38954
+ ${errorHandlingTest}${depTest}${callerTest}
38774
38955
  });
38775
38956
  });
38776
38957
  `;
@@ -38978,18 +39159,51 @@ var MochaGenerator = class extends BaseTestGenerator {
38978
39159
  * Generate complete test file from analysis
38979
39160
  */
38980
39161
  generateTests(context) {
38981
- const { moduleName, importPath, testType, patterns, analysis } = context;
39162
+ const { moduleName, importPath, testType, patterns, analysis, dependencies } = context;
38982
39163
  if (!analysis || analysis.functions.length === 0 && analysis.classes.length === 0) {
38983
39164
  return this.generateStubTests(context);
38984
39165
  }
38985
39166
  const patternComment = this.generatePatternComment(patterns);
38986
39167
  const exports = this.extractExports(analysis.functions, analysis.classes);
38987
39168
  const importStatement = this.generateImportStatement(exports, importPath, moduleName);
39169
+ let sinonImport = "";
39170
+ let stubSetup = "";
39171
+ if (dependencies && dependencies.imports.length > 0) {
39172
+ sinonImport = `import sinon from 'sinon';
39173
+ `;
39174
+ const depsToMock = dependencies.imports.slice(0, 5);
39175
+ stubSetup += ` // Auto-generated stubs from Knowledge Graph dependency analysis
39176
+ `;
39177
+ stubSetup += ` let stubs;
39178
+
39179
+ `;
39180
+ stubSetup += ` beforeEach(function() {
39181
+ `;
39182
+ stubSetup += ` stubs = {
39183
+ `;
39184
+ for (const dep of depsToMock) {
39185
+ const depName = dep.split("/").pop()?.replace(/[^a-zA-Z0-9_]/g, "_") || dep;
39186
+ stubSetup += ` ${depName}: sinon.stub(),
39187
+ `;
39188
+ }
39189
+ stubSetup += ` };
39190
+ `;
39191
+ stubSetup += ` });
39192
+
39193
+ `;
39194
+ stubSetup += ` afterEach(function() {
39195
+ `;
39196
+ stubSetup += ` sinon.restore();
39197
+ `;
39198
+ stubSetup += ` });
39199
+
39200
+ `;
39201
+ }
38988
39202
  let code = `${patternComment}import { expect } from 'chai';
38989
- ${importStatement}
39203
+ ${sinonImport}${importStatement}
38990
39204
 
38991
39205
  describe('${moduleName} - ${testType} tests', function() {
38992
- `;
39206
+ ${stubSetup}`;
38993
39207
  for (const fn of analysis.functions) {
38994
39208
  code += this.generateFunctionTests(fn, testType);
38995
39209
  }
@@ -39079,18 +39293,100 @@ describe('${moduleName} - ${testType} tests', function() {
39079
39293
  * Generate stub tests when no AST analysis is available
39080
39294
  */
39081
39295
  generateStubTests(context) {
39082
- const { moduleName, importPath, testType, patterns } = context;
39296
+ const { moduleName, importPath, testType, patterns, dependencies, similarCode } = context;
39083
39297
  const patternComment = this.generatePatternComment(patterns);
39084
39298
  const isAsync = patterns.some(
39085
39299
  (p74) => p74.name.toLowerCase().includes("async") || p74.name.toLowerCase().includes("promise")
39086
39300
  );
39087
39301
  const asyncSetup = isAsync ? "async " : "";
39302
+ let sinonImport = "";
39303
+ let stubSetup = "";
39304
+ let stubTeardown = "";
39305
+ if (dependencies && dependencies.imports.length > 0) {
39306
+ sinonImport = `import sinon from 'sinon';
39307
+ `;
39308
+ const depsToMock = dependencies.imports.slice(0, 5);
39309
+ stubSetup += `
39310
+ // Auto-generated stubs from Knowledge Graph dependency analysis
39311
+ `;
39312
+ stubSetup += ` let stubs;
39313
+
39314
+ `;
39315
+ stubSetup += ` beforeEach(function() {
39316
+ `;
39317
+ stubSetup += ` stubs = {
39318
+ `;
39319
+ for (const dep of depsToMock) {
39320
+ const depName = dep.split("/").pop()?.replace(/[^a-zA-Z0-9_]/g, "_") || dep;
39321
+ stubSetup += ` ${depName}: sinon.stub(),
39322
+ `;
39323
+ }
39324
+ stubSetup += ` };
39325
+ `;
39326
+ stubSetup += ` });
39327
+
39328
+ `;
39329
+ stubTeardown += ` afterEach(function() {
39330
+ `;
39331
+ stubTeardown += ` sinon.restore();
39332
+ `;
39333
+ stubTeardown += ` });
39334
+
39335
+ `;
39336
+ }
39337
+ let similarityComment = "";
39338
+ if (similarCode && similarCode.snippets.length > 0) {
39339
+ similarityComment += ` // KG: Similar modules found - consider testing shared patterns:
39340
+ `;
39341
+ for (const s70 of similarCode.snippets.slice(0, 3)) {
39342
+ similarityComment += ` // - ${s70.file} (${(s70.score * 100).toFixed(0)}% similar)
39343
+ `;
39344
+ }
39345
+ similarityComment += `
39346
+ `;
39347
+ }
39348
+ let depTest = "";
39349
+ if (dependencies && dependencies.imports.length > 0) {
39350
+ depTest += `
39351
+ it('should interact with dependencies correctly', function() {
39352
+ `;
39353
+ depTest += ` // KG-informed: module depends on ${dependencies.imports.length} imports
39354
+ `;
39355
+ depTest += ` const instance = typeof ${moduleName} === 'function'
39356
+ `;
39357
+ depTest += ` ? new ${moduleName}()
39358
+ `;
39359
+ depTest += ` : ${moduleName};
39360
+ `;
39361
+ depTest += ` expect(instance).to.exist;
39362
+ `;
39363
+ depTest += ` });
39364
+ `;
39365
+ }
39366
+ let callerTest = "";
39367
+ if (dependencies && dependencies.importedBy.length > 0) {
39368
+ callerTest += `
39369
+ it('should expose stable API for ${dependencies.importedBy.length} consumers', function() {
39370
+ `;
39371
+ callerTest += ` // KG-informed: used by ${dependencies.importedBy.slice(0, 3).join(", ")}
39372
+ `;
39373
+ callerTest += ` const publicKeys = Object.keys(typeof ${moduleName} === 'function'
39374
+ `;
39375
+ callerTest += ` ? ${moduleName}.prototype || {}
39376
+ `;
39377
+ callerTest += ` : ${moduleName});
39378
+ `;
39379
+ callerTest += ` expect(publicKeys.length).to.be.greaterThan(0);
39380
+ `;
39381
+ callerTest += ` });
39382
+ `;
39383
+ }
39088
39384
  return `${patternComment}import { expect } from 'chai';
39089
- import { ${moduleName} } from '${importPath}';
39385
+ ${sinonImport}import { ${moduleName} } from '${importPath}';
39090
39386
 
39091
39387
  describe('${moduleName}', function() {
39092
39388
  describe('${testType} tests', function() {
39093
- it('should be defined', function() {
39389
+ ${stubSetup}${stubTeardown}${similarityComment} it('should be defined', function() {
39094
39390
  expect(${moduleName}).to.not.be.undefined;
39095
39391
  });
39096
39392
 
@@ -39124,7 +39420,7 @@ describe('${moduleName}', function() {
39124
39420
  : ${moduleName};
39125
39421
  return instance;
39126
39422
  }).to.not.throw();
39127
- });
39423
+ });${depTest}${callerTest}
39128
39424
  });
39129
39425
  });
39130
39426
  `;
@@ -39172,7 +39468,7 @@ var PytestGenerator = class extends BaseTestGenerator {
39172
39468
  * Generate complete test file from analysis
39173
39469
  */
39174
39470
  generateTests(context) {
39175
- const { moduleName, importPath, testType, patterns, analysis } = context;
39471
+ const { moduleName, importPath, testType, patterns, analysis, dependencies } = context;
39176
39472
  if (!analysis || analysis.functions.length === 0 && analysis.classes.length === 0) {
39177
39473
  return this.generateStubTests(context);
39178
39474
  }
@@ -39180,8 +39476,18 @@ var PytestGenerator = class extends BaseTestGenerator {
39180
39476
  const exports = this.extractExports(analysis.functions, analysis.classes);
39181
39477
  const pythonImport = importPath.replace(/\//g, ".").replace(/\.(ts|js)$/, "");
39182
39478
  const importStatement = exports.length > 0 ? `from ${pythonImport} import ${exports.join(", ")}` : `import ${pythonImport} as ${moduleName}`;
39479
+ let mockImport = "";
39480
+ if (dependencies && dependencies.imports.length > 0) {
39481
+ mockImport = `from unittest.mock import patch, MagicMock
39482
+ `;
39483
+ }
39484
+ const depsToMock = dependencies?.imports.slice(0, 5) || [];
39485
+ const patchDecorators = depsToMock.map((dep) => {
39486
+ const depModule = dep.replace(/\//g, ".").replace(/\.py$/, "");
39487
+ return `@patch('${depModule}')`;
39488
+ });
39183
39489
  let code = `${patternComment}import pytest
39184
- ${importStatement}
39490
+ ${mockImport}${importStatement}
39185
39491
 
39186
39492
 
39187
39493
  class Test${this.pascalCase(moduleName)}:
@@ -39189,7 +39495,7 @@ class Test${this.pascalCase(moduleName)}:
39189
39495
 
39190
39496
  `;
39191
39497
  for (const fn of analysis.functions) {
39192
- code += this.generateFunctionTests(fn, testType);
39498
+ code += this.generateFunctionTestsWithPatches(fn, testType, patchDecorators);
39193
39499
  }
39194
39500
  for (const cls of analysis.classes) {
39195
39501
  code += this.generateClassTests(cls, testType);
@@ -39200,8 +39506,18 @@ class Test${this.pascalCase(moduleName)}:
39200
39506
  * Generate tests for a standalone function
39201
39507
  */
39202
39508
  generateFunctionTests(fn, _testType) {
39509
+ return this.generateFunctionTestsWithPatches(fn, _testType, []);
39510
+ }
39511
+ /**
39512
+ * Generate tests for a function with @patch decorators from KG dependencies
39513
+ */
39514
+ generateFunctionTestsWithPatches(fn, _testType, patchDecorators) {
39203
39515
  const validParams = fn.parameters.map((p74) => this.generatePythonTestValue(p74)).join(", ");
39204
- let code = ` def test_${fn.name}_valid_input(self):
39516
+ const mockParams = patchDecorators.map((_56, i58) => `mock_dep_${i58}`).reverse().join(", ");
39517
+ const allParams = mockParams ? `self, ${mockParams}` : "self";
39518
+ const patchPrefix = patchDecorators.map((d74) => ` ${d74}
39519
+ `).join("");
39520
+ let code = `${patchPrefix} def test_${fn.name}_valid_input(${allParams}):
39205
39521
  `;
39206
39522
  code += ` """Test ${fn.name} with valid input"""
39207
39523
  `;
@@ -39212,7 +39528,7 @@ class Test${this.pascalCase(moduleName)}:
39212
39528
  `;
39213
39529
  for (const param of fn.parameters) {
39214
39530
  if (!param.optional && param.type?.includes("str")) {
39215
- code += ` def test_${fn.name}_empty_${param.name}(self):
39531
+ code += `${patchPrefix} def test_${fn.name}_empty_${param.name}(${allParams}):
39216
39532
  `;
39217
39533
  code += ` """Test ${fn.name} with empty ${param.name}"""
39218
39534
  `;
@@ -39267,21 +39583,84 @@ class Test${cls.name}:
39267
39583
  * Generate stub tests when no AST analysis is available
39268
39584
  */
39269
39585
  generateStubTests(context) {
39270
- const { moduleName, importPath, testType, patterns } = context;
39586
+ const { moduleName, importPath, testType, patterns, dependencies, similarCode } = context;
39271
39587
  const patternComment = this.generatePythonPatternComment(patterns);
39272
39588
  const isAsync = patterns.some(
39273
39589
  (p74) => p74.name.toLowerCase().includes("async") || p74.name.toLowerCase().includes("promise")
39274
39590
  );
39275
39591
  const asyncDecorator = isAsync ? "@pytest.mark.asyncio\n " : "";
39276
39592
  const asyncDef = isAsync ? "async def" : "def";
39593
+ let mockImports = "";
39594
+ let mockPatches = "";
39595
+ if (dependencies && dependencies.imports.length > 0) {
39596
+ mockImports = `from unittest.mock import patch, MagicMock
39597
+ `;
39598
+ const depsToMock = dependencies.imports.slice(0, 5);
39599
+ for (const dep of depsToMock) {
39600
+ const depModule = dep.replace(/\//g, ".").replace(/\.py$/, "");
39601
+ mockPatches += ` @patch('${depModule}')
39602
+ `;
39603
+ }
39604
+ }
39605
+ let similarityComment = "";
39606
+ if (similarCode && similarCode.snippets.length > 0) {
39607
+ similarityComment = ` # KG: Similar modules found - consider testing shared patterns:
39608
+ `;
39609
+ for (const s70 of similarCode.snippets.slice(0, 3)) {
39610
+ similarityComment += ` # - ${s70.file} (${(s70.score * 100).toFixed(0)}% similar)
39611
+ `;
39612
+ }
39613
+ similarityComment += `
39614
+ `;
39615
+ }
39616
+ let depTests = "";
39617
+ if (dependencies && dependencies.imports.length > 0) {
39618
+ depTests += `
39619
+ def test_dependencies_importable(self):
39620
+ `;
39621
+ depTests += ` """Verify all dependencies are importable (KG-informed)."""
39622
+ `;
39623
+ for (const dep of dependencies.imports.slice(0, 5)) {
39624
+ const depModule = dep.replace(/\//g, ".").replace(/\.py$/, "");
39625
+ depTests += ` import importlib
39626
+ `;
39627
+ depTests += ` mod = importlib.import_module('${depModule}')
39628
+ `;
39629
+ depTests += ` assert mod is not None
39630
+ `;
39631
+ }
39632
+ depTests += `
39633
+ def test_dependency_interactions(self):
39634
+ `;
39635
+ depTests += ` """Test module interactions with its dependencies (KG-informed)."""
39636
+ `;
39637
+ depTests += ` # Module should handle dependency failures gracefully
39638
+ `;
39639
+ depTests += ` assert ${moduleName} is not None
39640
+ `;
39641
+ depTests += ` assert hasattr(${moduleName}, '__name__') or hasattr(${moduleName}, '__class__')
39642
+ `;
39643
+ }
39644
+ let callerTests = "";
39645
+ if (dependencies && dependencies.importedBy.length > 0) {
39646
+ callerTests += `
39647
+ def test_public_api_surface(self):
39648
+ `;
39649
+ callerTests += ` """Verify public API used by ${dependencies.importedBy.length} consumers (KG-informed)."""
39650
+ `;
39651
+ callerTests += ` public_attrs = [a for a in dir(${moduleName}) if not a.startswith('_')]
39652
+ `;
39653
+ callerTests += ` assert len(public_attrs) > 0, "Module should expose public API"
39654
+ `;
39655
+ }
39277
39656
  return `${patternComment}import pytest
39278
- from ${importPath} import ${moduleName}
39657
+ ${mockImports}from ${importPath} import ${moduleName}
39279
39658
 
39280
39659
 
39281
39660
  class Test${this.pascalCase(moduleName)}:
39282
39661
  """${testType} tests for ${moduleName}"""
39283
39662
 
39284
- def test_is_defined(self):
39663
+ ${similarityComment} def test_is_defined(self):
39285
39664
  """Verify the module is properly exported and defined."""
39286
39665
  assert ${moduleName} is not None
39287
39666
 
@@ -39315,7 +39694,7 @@ class Test${this.pascalCase(moduleName)}:
39315
39694
  except TypeError:
39316
39695
  # Expected if constructor requires arguments
39317
39696
  pass
39318
- `;
39697
+ ${depTests}${callerTests}`;
39319
39698
  }
39320
39699
  /**
39321
39700
  * Generate coverage-focused tests for specific lines
@@ -40333,10 +40712,46 @@ var TestGeneratorService = class {
40333
40712
  * Enhance generated test code using LLM
40334
40713
  * Adds edge cases, improves assertions, and adds documentation
40335
40714
  */
40336
- async enhanceTestWithLLM(testCode, sourceCode, analysis) {
40715
+ async enhanceTestWithLLM(testCode, sourceCode, analysis, context) {
40337
40716
  if (!this.llmRouter) return testCode;
40338
40717
  try {
40339
- const prompt = this.buildTestEnhancementPrompt(testCode, sourceCode, analysis);
40718
+ let prompt = this.buildTestEnhancementPrompt(testCode, sourceCode, analysis);
40719
+ if (context?.dependencies) {
40720
+ prompt += `
40721
+ ## Dependency Context (from Knowledge Graph):
40722
+ `;
40723
+ if (context.dependencies.imports.length > 0) {
40724
+ prompt += `- Imports: ${context.dependencies.imports.join(", ")}
40725
+ `;
40726
+ prompt += ` \u2192 Generate mock declarations for these dependencies
40727
+ `;
40728
+ }
40729
+ if (context.dependencies.importedBy.length > 0) {
40730
+ prompt += `- Imported by: ${context.dependencies.importedBy.join(", ")}
40731
+ `;
40732
+ prompt += ` \u2192 Focus tests on the public API surface these consumers use
40733
+ `;
40734
+ }
40735
+ if (context.dependencies.callers.length > 0) {
40736
+ prompt += `- Called by: ${context.dependencies.callers.join(", ")}
40737
+ `;
40738
+ }
40739
+ if (context.dependencies.callees.length > 0) {
40740
+ prompt += `- Calls: ${context.dependencies.callees.join(", ")}
40741
+ `;
40742
+ }
40743
+ }
40744
+ if (context?.similarCode && context.similarCode.snippets.length > 0) {
40745
+ prompt += `
40746
+ ## Similar Code Patterns (from Knowledge Graph):
40747
+ `;
40748
+ for (const s70 of context.similarCode.snippets.slice(0, 3)) {
40749
+ prompt += `- ${s70.file} (similarity: ${(s70.score * 100).toFixed(0)}%): ${s70.snippet}
40750
+ `;
40751
+ }
40752
+ prompt += ` \u2192 Use similar patterns as templates for assertions
40753
+ `;
40754
+ }
40340
40755
  const modelId = this.getModelForTier(this.config.llmModelTier);
40341
40756
  const response = await this.llmRouter.chat({
40342
40757
  messages: [
@@ -40576,6 +40991,15 @@ ${sourceCode}
40576
40991
  codeAnalysis = this.analyzeSourceCode(sourceContent, sourceFile);
40577
40992
  } catch {
40578
40993
  }
40994
+ let dependencies;
40995
+ let similarCode;
40996
+ if (this.memory && sourceContent) {
40997
+ const hasKGVectors = await this.hasKGVectors();
40998
+ if (hasKGVectors) {
40999
+ dependencies = await this.queryKGDependencies(sourceFile, sourceContent);
41000
+ similarCode = await this.queryKGSimilarCode(sourceContent);
41001
+ }
41002
+ }
40579
41003
  const generator = this.generatorFactory.create(framework);
40580
41004
  const moduleName = this.extractModuleName(sourceFile);
40581
41005
  const importPath = this.getImportPath(sourceFile);
@@ -40584,11 +41008,13 @@ ${sourceCode}
40584
41008
  importPath,
40585
41009
  testType,
40586
41010
  patterns: applicablePatterns,
40587
- analysis: codeAnalysis ?? void 0
41011
+ analysis: codeAnalysis ?? void 0,
41012
+ dependencies,
41013
+ similarCode
40588
41014
  };
40589
41015
  let testCode = generator.generateTests(context);
40590
41016
  if (this.isLLMEnhancementAvailable() && sourceContent) {
40591
- testCode = await this.enhanceTestWithLLM(testCode, sourceContent, codeAnalysis);
41017
+ testCode = await this.enhanceTestWithLLM(testCode, sourceContent, codeAnalysis, context);
40592
41018
  }
40593
41019
  const test = {
40594
41020
  id: v4_default(),
@@ -40783,6 +41209,107 @@ ${sourceCode}
40783
41209
  return complexity;
40784
41210
  }
40785
41211
  // ============================================================================
41212
+ // Private Helper Methods - Knowledge Graph Queries
41213
+ // ============================================================================
41214
+ /**
41215
+ * Check if KG vectors exist by probing a vector search.
41216
+ * Returns true if vectorSearch returns any results (indicating indexed code exists).
41217
+ */
41218
+ async hasKGVectors() {
41219
+ try {
41220
+ const probe = new Array(768).fill(0);
41221
+ probe[0] = 1;
41222
+ const results = await this.memory.vectorSearch(probe, 1);
41223
+ return results.length > 0;
41224
+ } catch {
41225
+ return false;
41226
+ }
41227
+ }
41228
+ /**
41229
+ * Query KG for dependency information about a file.
41230
+ * Extracts imports from source and cross-references with KG vector index
41231
+ * to find which indexed modules this file depends on and which depend on it.
41232
+ */
41233
+ async queryKGDependencies(filePath, sourceContent) {
41234
+ try {
41235
+ const imports = [];
41236
+ const importedBy = [];
41237
+ const callees = [];
41238
+ const callers = [];
41239
+ const tsImports = sourceContent.matchAll(/(?:import|from)\s+['"]([^'"]+)['"]/g);
41240
+ const pyImports = sourceContent.matchAll(/(?:^|\n)\s*(?:from\s+(\S+)\s+import|import\s+(\S+))/g);
41241
+ for (const match of tsImports) {
41242
+ imports.push(match[1]);
41243
+ }
41244
+ for (const match of pyImports) {
41245
+ imports.push(match[1] || match[2]);
41246
+ }
41247
+ const normalizedPath = filePath.replace(/\\/g, "/");
41248
+ const baseName = normalizedPath.split("/").pop()?.replace(/\.(ts|js|tsx|jsx|py)$/, "") || "";
41249
+ const nodeKeys = await this.memory.search(`code-intelligence:kg:node:*${baseName}*`, 50);
41250
+ for (const key of nodeKeys) {
41251
+ if (!key.includes(baseName)) continue;
41252
+ const parts = key.split(":");
41253
+ const nodeType = parts[parts.length - 2];
41254
+ const nodeName = parts[parts.length - 1];
41255
+ if (nodeType === "function") {
41256
+ callees.push(nodeName);
41257
+ }
41258
+ }
41259
+ if (imports.length === 0 && importedBy.length === 0 && callees.length === 0 && callers.length === 0) {
41260
+ return void 0;
41261
+ }
41262
+ return { imports, importedBy, callees, callers };
41263
+ } catch {
41264
+ return void 0;
41265
+ }
41266
+ }
41267
+ /**
41268
+ * Query KG for semantically similar code snippets.
41269
+ * Uses vector search against the persisted vectors table.
41270
+ * KG nodes are stored as vectors with IDs like code-intelligence:kg:node:*
41271
+ */
41272
+ async queryKGSimilarCode(sourceContent) {
41273
+ try {
41274
+ const embedding = this.generatePseudoEmbedding(sourceContent);
41275
+ const results = await this.memory.vectorSearch(embedding, 5);
41276
+ if (results.length === 0) return void 0;
41277
+ const snippets = [];
41278
+ for (const result of results) {
41279
+ if (result.score < 0.1) continue;
41280
+ const metadata = result.metadata;
41281
+ const file = metadata?.file || result.key;
41282
+ const snippet = metadata?.name || metadata?.type || result.key.split(":").pop() || "";
41283
+ snippets.push({ file, snippet, score: result.score });
41284
+ }
41285
+ return snippets.length > 0 ? { snippets } : void 0;
41286
+ } catch {
41287
+ return void 0;
41288
+ }
41289
+ }
41290
+ /**
41291
+ * Generate a simple pseudo-embedding for vector search.
41292
+ * Uses token-based feature extraction similar to semantic-analyzer.
41293
+ */
41294
+ generatePseudoEmbedding(code) {
41295
+ const dimension = 768;
41296
+ const embedding = new Array(dimension).fill(0);
41297
+ const tokens = code.split(/[^a-zA-Z0-9_$]+/).filter((t50) => t50.length > 1);
41298
+ for (let i58 = 0; i58 < tokens.length; i58++) {
41299
+ const token = tokens[i58];
41300
+ for (let j52 = 0; j52 < token.length && j52 < embedding.length; j52++) {
41301
+ embedding[(i58 + j52) % dimension] += token.charCodeAt(j52) / 1e3;
41302
+ }
41303
+ }
41304
+ const magnitude2 = Math.sqrt(embedding.reduce((sum, v62) => sum + v62 * v62, 0));
41305
+ if (magnitude2 > 0) {
41306
+ for (let i58 = 0; i58 < dimension; i58++) {
41307
+ embedding[i58] /= magnitude2;
41308
+ }
41309
+ }
41310
+ return embedding;
41311
+ }
41312
+ // ============================================================================
40786
41313
  // Private Helper Methods - Utility Functions
40787
41314
  // ============================================================================
40788
41315
  async findApplicablePatterns(sourceFile, requestedPatterns) {
@@ -42703,6 +43230,7 @@ var TypeScriptASTParser = class {
42703
43230
  // src/learning/qe-hooks.ts
42704
43231
  init_error_utils();
42705
43232
  init_logging();
43233
+ init_qe_patterns();
42706
43234
  var logger6 = LoggerFactory.create("qe-hooks");
42707
43235
  var QE_HOOK_EVENTS = {
42708
43236
  // Test lifecycle