agentic-qe 3.7.21 → 3.8.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (164) hide show
  1. package/.claude/helpers/brain-checkpoint.cjs +4 -1
  2. package/.claude/helpers/statusline-v3.cjs +3 -1
  3. package/.claude/skills/skills-manifest.json +1 -1
  4. package/CHANGELOG.md +45 -0
  5. package/README.md +2 -14
  6. package/assets/helpers/statusline-v3.cjs +3 -1
  7. package/dist/cli/brain-commands.js +6 -10
  8. package/dist/cli/bundle.js +7441 -4327
  9. package/dist/cli/commands/audit.d.ts +43 -0
  10. package/dist/cli/commands/audit.js +125 -0
  11. package/dist/cli/commands/hooks.js +29 -6
  12. package/dist/cli/commands/init.js +1 -73
  13. package/dist/cli/commands/learning.js +270 -13
  14. package/dist/cli/commands/ruvector-commands.d.ts +15 -0
  15. package/dist/cli/commands/ruvector-commands.js +271 -0
  16. package/dist/cli/handlers/init-handler.d.ts +0 -1
  17. package/dist/cli/handlers/init-handler.js +0 -6
  18. package/dist/cli/index.js +4 -2
  19. package/dist/context/sources/defect-source.js +2 -2
  20. package/dist/context/sources/memory-source.js +2 -2
  21. package/dist/context/sources/requirements-source.js +2 -2
  22. package/dist/coordination/behavior-tree/decorators.d.ts +108 -0
  23. package/dist/coordination/behavior-tree/decorators.js +251 -0
  24. package/dist/coordination/behavior-tree/index.d.ts +12 -0
  25. package/dist/coordination/behavior-tree/index.js +15 -0
  26. package/dist/coordination/behavior-tree/nodes.d.ts +165 -0
  27. package/dist/coordination/behavior-tree/nodes.js +338 -0
  28. package/dist/coordination/behavior-tree/qe-trees.d.ts +105 -0
  29. package/dist/coordination/behavior-tree/qe-trees.js +181 -0
  30. package/dist/coordination/coherence-action-gate.d.ts +284 -0
  31. package/dist/coordination/coherence-action-gate.js +512 -0
  32. package/dist/coordination/index.d.ts +4 -0
  33. package/dist/coordination/index.js +8 -0
  34. package/dist/coordination/reasoning-qec.d.ts +315 -0
  35. package/dist/coordination/reasoning-qec.js +585 -0
  36. package/dist/coordination/task-executor.d.ts +16 -0
  37. package/dist/coordination/task-executor.js +99 -0
  38. package/dist/coordination/workflow-orchestrator.d.ts +29 -0
  39. package/dist/coordination/workflow-orchestrator.js +42 -0
  40. package/dist/domains/visual-accessibility/cnn-visual-regression.d.ts +135 -0
  41. package/dist/domains/visual-accessibility/cnn-visual-regression.js +327 -0
  42. package/dist/domains/visual-accessibility/index.d.ts +1 -0
  43. package/dist/domains/visual-accessibility/index.js +4 -0
  44. package/dist/governance/coherence-validator.d.ts +112 -0
  45. package/dist/governance/coherence-validator.js +180 -0
  46. package/dist/governance/index.d.ts +1 -0
  47. package/dist/governance/index.js +2 -0
  48. package/dist/governance/witness-chain.d.ts +311 -0
  49. package/dist/governance/witness-chain.js +509 -0
  50. package/dist/init/index.d.ts +0 -2
  51. package/dist/init/index.js +0 -1
  52. package/dist/init/init-wizard-steps.d.ts +10 -0
  53. package/dist/init/init-wizard-steps.js +87 -1
  54. package/dist/init/init-wizard.d.ts +1 -9
  55. package/dist/init/init-wizard.js +3 -69
  56. package/dist/init/orchestrator.js +0 -1
  57. package/dist/init/phases/01-detection.js +0 -27
  58. package/dist/init/phases/07-hooks.js +6 -4
  59. package/dist/init/phases/phase-interface.d.ts +0 -1
  60. package/dist/init/settings-merge.js +1 -1
  61. package/dist/integrations/browser/qe-dashboard/clustering.d.ts +48 -0
  62. package/dist/integrations/browser/qe-dashboard/clustering.js +183 -0
  63. package/dist/integrations/browser/qe-dashboard/index.d.ts +12 -0
  64. package/dist/integrations/browser/qe-dashboard/index.js +15 -0
  65. package/dist/integrations/browser/qe-dashboard/pattern-explorer.d.ts +165 -0
  66. package/dist/integrations/browser/qe-dashboard/pattern-explorer.js +260 -0
  67. package/dist/integrations/browser/qe-dashboard/wasm-vector-store.d.ts +144 -0
  68. package/dist/integrations/browser/qe-dashboard/wasm-vector-store.js +277 -0
  69. package/dist/integrations/ruvector/cognitive-container-codec.d.ts +51 -0
  70. package/dist/integrations/ruvector/cognitive-container-codec.js +180 -0
  71. package/dist/integrations/ruvector/cognitive-container.d.ts +125 -0
  72. package/dist/integrations/ruvector/cognitive-container.js +306 -0
  73. package/dist/integrations/ruvector/coherence-gate.d.ts +309 -0
  74. package/dist/integrations/ruvector/coherence-gate.js +631 -0
  75. package/dist/integrations/ruvector/compressed-hnsw-integration.d.ts +176 -0
  76. package/dist/integrations/ruvector/compressed-hnsw-integration.js +301 -0
  77. package/dist/integrations/ruvector/dither-adapter.d.ts +122 -0
  78. package/dist/integrations/ruvector/dither-adapter.js +295 -0
  79. package/dist/integrations/ruvector/domain-transfer.d.ts +129 -0
  80. package/dist/integrations/ruvector/domain-transfer.js +220 -0
  81. package/dist/integrations/ruvector/feature-flags.d.ts +214 -2
  82. package/dist/integrations/ruvector/feature-flags.js +167 -2
  83. package/dist/integrations/ruvector/filter-adapter.d.ts +71 -0
  84. package/dist/integrations/ruvector/filter-adapter.js +285 -0
  85. package/dist/integrations/ruvector/gnn-wrapper.d.ts +20 -0
  86. package/dist/integrations/ruvector/gnn-wrapper.js +40 -0
  87. package/dist/integrations/ruvector/hnsw-health-monitor.d.ts +237 -0
  88. package/dist/integrations/ruvector/hnsw-health-monitor.js +394 -0
  89. package/dist/integrations/ruvector/index.d.ts +8 -2
  90. package/dist/integrations/ruvector/index.js +18 -2
  91. package/dist/integrations/ruvector/interfaces.d.ts +40 -0
  92. package/dist/integrations/ruvector/sona-persistence.d.ts +54 -0
  93. package/dist/integrations/ruvector/sona-persistence.js +162 -0
  94. package/dist/integrations/ruvector/sona-three-loop.d.ts +392 -0
  95. package/dist/integrations/ruvector/sona-three-loop.js +814 -0
  96. package/dist/integrations/ruvector/sona-wrapper.d.ts +97 -0
  97. package/dist/integrations/ruvector/sona-wrapper.js +147 -3
  98. package/dist/integrations/ruvector/spectral-math.d.ts +101 -0
  99. package/dist/integrations/ruvector/spectral-math.js +254 -0
  100. package/dist/integrations/ruvector/temporal-compression.d.ts +163 -0
  101. package/dist/integrations/ruvector/temporal-compression.js +318 -0
  102. package/dist/integrations/ruvector/thompson-sampler.d.ts +61 -0
  103. package/dist/integrations/ruvector/thompson-sampler.js +118 -0
  104. package/dist/integrations/ruvector/transfer-coherence-stub.d.ts +80 -0
  105. package/dist/integrations/ruvector/transfer-coherence-stub.js +63 -0
  106. package/dist/integrations/ruvector/transfer-verification.d.ts +119 -0
  107. package/dist/integrations/ruvector/transfer-verification.js +115 -0
  108. package/dist/kernel/hnsw-adapter.d.ts +52 -1
  109. package/dist/kernel/hnsw-adapter.js +139 -4
  110. package/dist/kernel/hnsw-index-provider.d.ts +5 -0
  111. package/dist/kernel/native-hnsw-backend.d.ts +110 -0
  112. package/dist/kernel/native-hnsw-backend.js +408 -0
  113. package/dist/kernel/unified-memory.js +5 -6
  114. package/dist/learning/aqe-learning-engine.d.ts +2 -0
  115. package/dist/learning/aqe-learning-engine.js +65 -0
  116. package/dist/learning/experience-capture-middleware.js +20 -0
  117. package/dist/learning/experience-capture.d.ts +10 -0
  118. package/dist/learning/experience-capture.js +34 -0
  119. package/dist/learning/index.d.ts +2 -2
  120. package/dist/learning/index.js +4 -4
  121. package/dist/learning/metrics-tracker.d.ts +11 -0
  122. package/dist/learning/metrics-tracker.js +29 -13
  123. package/dist/learning/pattern-lifecycle.d.ts +30 -1
  124. package/dist/learning/pattern-lifecycle.js +92 -20
  125. package/dist/learning/pattern-store.d.ts +8 -0
  126. package/dist/learning/pattern-store.js +8 -2
  127. package/dist/learning/qe-unified-memory.js +1 -28
  128. package/dist/learning/regret-tracker.d.ts +201 -0
  129. package/dist/learning/regret-tracker.js +361 -0
  130. package/dist/mcp/bundle.js +5915 -474
  131. package/dist/routing/index.d.ts +4 -2
  132. package/dist/routing/index.js +3 -1
  133. package/dist/routing/neural-tiny-dancer-router.d.ts +268 -0
  134. package/dist/routing/neural-tiny-dancer-router.js +514 -0
  135. package/dist/routing/queen-integration.js +5 -5
  136. package/dist/routing/routing-config.d.ts +6 -0
  137. package/dist/routing/routing-config.js +1 -0
  138. package/dist/routing/simple-neural-router.d.ts +76 -0
  139. package/dist/routing/simple-neural-router.js +202 -0
  140. package/dist/routing/tiny-dancer-router.d.ts +20 -1
  141. package/dist/routing/tiny-dancer-router.js +21 -2
  142. package/dist/test-scheduling/dag-attention-scheduler.d.ts +81 -0
  143. package/dist/test-scheduling/dag-attention-scheduler.js +358 -0
  144. package/dist/test-scheduling/dag-attention-types.d.ts +81 -0
  145. package/dist/test-scheduling/dag-attention-types.js +10 -0
  146. package/dist/test-scheduling/index.d.ts +1 -0
  147. package/dist/test-scheduling/index.js +4 -0
  148. package/dist/test-scheduling/pipeline.d.ts +8 -0
  149. package/dist/test-scheduling/pipeline.js +28 -0
  150. package/package.json +6 -2
  151. package/dist/cli/commands/migrate.d.ts +0 -9
  152. package/dist/cli/commands/migrate.js +0 -566
  153. package/dist/init/init-wizard-migration.d.ts +0 -52
  154. package/dist/init/init-wizard-migration.js +0 -345
  155. package/dist/init/migration/config-migrator.d.ts +0 -31
  156. package/dist/init/migration/config-migrator.js +0 -149
  157. package/dist/init/migration/data-migrator.d.ts +0 -72
  158. package/dist/init/migration/data-migrator.js +0 -232
  159. package/dist/init/migration/detector.d.ts +0 -44
  160. package/dist/init/migration/detector.js +0 -105
  161. package/dist/init/migration/index.d.ts +0 -8
  162. package/dist/init/migration/index.js +0 -8
  163. package/dist/learning/v2-to-v3-migration.d.ts +0 -86
  164. package/dist/learning/v2-to-v3-migration.js +0 -529
@@ -0,0 +1,338 @@
1
+ /**
2
+ * Behavior Tree Core Nodes
3
+ *
4
+ * Composable behavior tree nodes for agent orchestration.
5
+ * Each node implements a tick-based evaluation model returning
6
+ * SUCCESS, FAILURE, or RUNNING.
7
+ */
8
+ // ============================================================================
9
+ // Abstract Base
10
+ // ============================================================================
11
+ class BaseNode {
12
+ name;
13
+ constructor(name) {
14
+ this.name = name;
15
+ }
16
+ serialize() {
17
+ return { type: this.type, name: this.name };
18
+ }
19
+ }
20
+ class CompositeNode extends BaseNode {
21
+ children;
22
+ constructor(name, children) {
23
+ super(name);
24
+ this.children = children;
25
+ }
26
+ reset() {
27
+ for (const child of this.children) {
28
+ child.reset();
29
+ }
30
+ }
31
+ serialize() {
32
+ return {
33
+ type: this.type,
34
+ name: this.name,
35
+ children: this.children.map((c) => c.serialize()),
36
+ };
37
+ }
38
+ }
39
+ // ============================================================================
40
+ // Composite Nodes
41
+ // ============================================================================
42
+ /**
43
+ * Sequence node - AND logic.
44
+ *
45
+ * Runs children in order from left to right:
46
+ * - Returns FAILURE immediately when any child fails
47
+ * - Returns RUNNING if a child is still running
48
+ * - Returns SUCCESS only when all children succeed
49
+ */
50
+ export class SequenceNode extends CompositeNode {
51
+ type = 'Sequence';
52
+ currentIndex = 0;
53
+ constructor(name, children) {
54
+ super(name, children);
55
+ }
56
+ async tick() {
57
+ while (this.currentIndex < this.children.length) {
58
+ const child = this.children[this.currentIndex];
59
+ const status = await child.tick();
60
+ if (status === 'FAILURE') {
61
+ return 'FAILURE';
62
+ }
63
+ if (status === 'RUNNING') {
64
+ return 'RUNNING';
65
+ }
66
+ // SUCCESS - move to next child
67
+ this.currentIndex++;
68
+ }
69
+ return 'SUCCESS';
70
+ }
71
+ reset() {
72
+ this.currentIndex = 0;
73
+ super.reset();
74
+ }
75
+ }
76
+ /**
77
+ * Selector node - OR logic.
78
+ *
79
+ * Runs children in order from left to right:
80
+ * - Returns SUCCESS immediately when any child succeeds
81
+ * - Returns RUNNING if a child is still running
82
+ * - Returns FAILURE only when all children fail
83
+ */
84
+ export class SelectorNode extends CompositeNode {
85
+ type = 'Selector';
86
+ currentIndex = 0;
87
+ constructor(name, children) {
88
+ super(name, children);
89
+ }
90
+ async tick() {
91
+ while (this.currentIndex < this.children.length) {
92
+ const child = this.children[this.currentIndex];
93
+ const status = await child.tick();
94
+ if (status === 'SUCCESS') {
95
+ return 'SUCCESS';
96
+ }
97
+ if (status === 'RUNNING') {
98
+ return 'RUNNING';
99
+ }
100
+ // FAILURE - try next child
101
+ this.currentIndex++;
102
+ }
103
+ return 'FAILURE';
104
+ }
105
+ reset() {
106
+ this.currentIndex = 0;
107
+ super.reset();
108
+ }
109
+ }
110
+ /**
111
+ * Parallel node - concurrent execution.
112
+ *
113
+ * Runs all children concurrently:
114
+ * - Returns SUCCESS when successThreshold children succeed
115
+ * - Returns FAILURE when it becomes impossible to meet the threshold
116
+ * - Returns RUNNING while children are still executing
117
+ */
118
+ export class ParallelNode extends CompositeNode {
119
+ type = 'Parallel';
120
+ config;
121
+ constructor(name, children, config) {
122
+ super(name, children);
123
+ this.config = {
124
+ successThreshold: config.successThreshold,
125
+ waitForAll: config.waitForAll ?? false,
126
+ };
127
+ }
128
+ async tick() {
129
+ const results = await Promise.all(this.children.map((child) => child.tick()));
130
+ let successCount = 0;
131
+ let failureCount = 0;
132
+ let runningCount = 0;
133
+ for (const status of results) {
134
+ if (status === 'SUCCESS')
135
+ successCount++;
136
+ else if (status === 'FAILURE')
137
+ failureCount++;
138
+ else
139
+ runningCount++;
140
+ }
141
+ // Enough successes to meet threshold
142
+ if (successCount >= this.config.successThreshold) {
143
+ if (this.config.waitForAll && runningCount > 0) {
144
+ return 'RUNNING';
145
+ }
146
+ return 'SUCCESS';
147
+ }
148
+ // Impossible to reach threshold
149
+ const maxPossibleSuccesses = successCount + runningCount;
150
+ if (maxPossibleSuccesses < this.config.successThreshold) {
151
+ return 'FAILURE';
152
+ }
153
+ return 'RUNNING';
154
+ }
155
+ serialize() {
156
+ return {
157
+ type: this.type,
158
+ name: this.name,
159
+ children: this.children.map((c) => c.serialize()),
160
+ config: {
161
+ successThreshold: this.config.successThreshold,
162
+ waitForAll: this.config.waitForAll,
163
+ },
164
+ };
165
+ }
166
+ }
167
+ // ============================================================================
168
+ // Leaf Nodes
169
+ // ============================================================================
170
+ /**
171
+ * Action node - leaf node that executes a function.
172
+ *
173
+ * Wraps an async function that returns a NodeStatus.
174
+ * Use for side-effectful operations like running tests or generating code.
175
+ */
176
+ export class ActionNode extends BaseNode {
177
+ type = 'Action';
178
+ action;
179
+ actionId;
180
+ constructor(name, action, actionId) {
181
+ super(name);
182
+ this.action = action;
183
+ this.actionId = actionId ?? name;
184
+ }
185
+ async tick() {
186
+ try {
187
+ return await this.action();
188
+ }
189
+ catch {
190
+ return 'FAILURE';
191
+ }
192
+ }
193
+ reset() {
194
+ // Leaf nodes have no state to reset
195
+ }
196
+ serialize() {
197
+ return {
198
+ type: this.type,
199
+ name: this.name,
200
+ config: { actionId: this.actionId },
201
+ };
202
+ }
203
+ }
204
+ /**
205
+ * Condition node - leaf node that checks a predicate.
206
+ *
207
+ * Wraps an async predicate that returns boolean.
208
+ * Returns SUCCESS if predicate is true, FAILURE if false.
209
+ * Use for checking preconditions or guard clauses.
210
+ */
211
+ export class ConditionNode extends BaseNode {
212
+ type = 'Condition';
213
+ predicate;
214
+ conditionId;
215
+ constructor(name, predicate, conditionId) {
216
+ super(name);
217
+ this.predicate = predicate;
218
+ this.conditionId = conditionId ?? name;
219
+ }
220
+ async tick() {
221
+ try {
222
+ const result = await this.predicate();
223
+ return result ? 'SUCCESS' : 'FAILURE';
224
+ }
225
+ catch {
226
+ return 'FAILURE';
227
+ }
228
+ }
229
+ reset() {
230
+ // Leaf nodes have no state to reset
231
+ }
232
+ serialize() {
233
+ return {
234
+ type: this.type,
235
+ name: this.name,
236
+ config: { conditionId: this.conditionId },
237
+ };
238
+ }
239
+ }
240
+ /**
241
+ * Deserialize a serialized node tree back into executable BehaviorNodes.
242
+ *
243
+ * Requires a handler registry to reconstruct Action and Condition nodes
244
+ * since functions cannot be serialized directly.
245
+ *
246
+ * Supports both core nodes (Sequence, Selector, Parallel, Action, Condition)
247
+ * and decorator nodes (Inverter, Repeat, UntilFail, Timeout, Retry).
248
+ * Decorator classes must be registered via registerDecoratorTypes() before
249
+ * deserialization of trees containing decorators.
250
+ */
251
+ export function deserializeNode(data, registry) {
252
+ switch (data.type) {
253
+ case 'Sequence': {
254
+ const children = (data.children ?? []).map((c) => deserializeNode(c, registry));
255
+ return new SequenceNode(data.name, children);
256
+ }
257
+ case 'Selector': {
258
+ const children = (data.children ?? []).map((c) => deserializeNode(c, registry));
259
+ return new SelectorNode(data.name, children);
260
+ }
261
+ case 'Parallel': {
262
+ const children = (data.children ?? []).map((c) => deserializeNode(c, registry));
263
+ const config = {
264
+ successThreshold: data.config?.successThreshold ?? children.length,
265
+ waitForAll: data.config?.waitForAll ?? false,
266
+ };
267
+ return new ParallelNode(data.name, children, config);
268
+ }
269
+ case 'Action': {
270
+ const actionId = data.config?.actionId ?? data.name;
271
+ const handler = registry.actions.get(actionId);
272
+ if (!handler) {
273
+ throw new Error(`Action handler not found in registry: '${actionId}'`);
274
+ }
275
+ return new ActionNode(data.name, handler, actionId);
276
+ }
277
+ case 'Condition': {
278
+ const conditionId = data.config?.conditionId ?? data.name;
279
+ const handler = registry.conditions.get(conditionId);
280
+ if (!handler) {
281
+ throw new Error(`Condition handler not found in registry: '${conditionId}'`);
282
+ }
283
+ return new ConditionNode(data.name, handler, conditionId);
284
+ }
285
+ // Decorator types - require exactly one child
286
+ case 'Inverter':
287
+ case 'Repeat':
288
+ case 'UntilFail':
289
+ case 'Timeout':
290
+ case 'Retry': {
291
+ const decoratorFactory = _decoratorFactories.get(data.type);
292
+ if (!decoratorFactory) {
293
+ throw new Error(`Decorator type '${data.type}' not registered. ` +
294
+ `Call registerDecoratorTypes() before deserializing trees with decorators.`);
295
+ }
296
+ const children = data.children ?? [];
297
+ if (children.length !== 1) {
298
+ throw new Error(`Decorator '${data.type}' requires exactly 1 child, got ${children.length}`);
299
+ }
300
+ const child = deserializeNode(children[0], registry);
301
+ return decoratorFactory(data.name, child, data.config ?? {});
302
+ }
303
+ default:
304
+ throw new Error(`Unknown node type: '${data.type}'`);
305
+ }
306
+ }
307
+ const _decoratorFactories = new Map();
308
+ /**
309
+ * Register decorator type factories for deserialization.
310
+ * Called automatically when decorators module is imported via the barrel export.
311
+ */
312
+ export function registerDecoratorFactory(type, factory) {
313
+ _decoratorFactories.set(type, factory);
314
+ }
315
+ // ============================================================================
316
+ // Factory Helpers
317
+ // ============================================================================
318
+ /** Create a Sequence node */
319
+ export function sequence(name, children) {
320
+ return new SequenceNode(name, children);
321
+ }
322
+ /** Create a Selector node */
323
+ export function selector(name, children) {
324
+ return new SelectorNode(name, children);
325
+ }
326
+ /** Create a Parallel node */
327
+ export function parallel(name, children, config) {
328
+ return new ParallelNode(name, children, config);
329
+ }
330
+ /** Create an Action node */
331
+ export function action(name, fn, actionId) {
332
+ return new ActionNode(name, fn, actionId);
333
+ }
334
+ /** Create a Condition node */
335
+ export function condition(name, predicate, conditionId) {
336
+ return new ConditionNode(name, predicate, conditionId);
337
+ }
338
+ //# sourceMappingURL=nodes.js.map
@@ -0,0 +1,105 @@
1
+ /**
2
+ * Pre-built Behavior Trees for Common QE Workflows
3
+ *
4
+ * Provides ready-to-use behavior tree templates for:
5
+ * - Test generation pipeline
6
+ * - Regression suite execution
7
+ * - Security audit workflow
8
+ *
9
+ * Each tree is constructed using the core nodes and decorators,
10
+ * and can be serialized to JSON for persistence/transfer.
11
+ */
12
+ import { type BehaviorNode, type ActionFunction, type ConditionPredicate, type NodeHandlerRegistry } from './nodes.js';
13
+ /** Well-known action IDs for QE behavior trees */
14
+ export declare const QEActionIds: {
15
+ readonly ANALYZE_CODE: "qe.analyze-code";
16
+ readonly GENERATE_TESTS: "qe.generate-tests";
17
+ readonly VALIDATE_TESTS: "qe.validate-tests";
18
+ readonly COMMIT_TESTS: "qe.commit-tests";
19
+ readonly LOAD_TESTS: "qe.load-tests";
20
+ readonly EXECUTE_TESTS: "qe.execute-tests";
21
+ readonly COLLECT_RESULTS: "qe.collect-results";
22
+ readonly GENERATE_REPORT: "qe.generate-report";
23
+ readonly SCAN_VULNERABILITIES: "qe.scan-vulnerabilities";
24
+ readonly CLASSIFY_FINDINGS: "qe.classify-findings";
25
+ readonly GENERATE_SECURITY_REPORT: "qe.generate-security-report";
26
+ readonly REMEDIATE_ISSUES: "qe.remediate-issues";
27
+ };
28
+ /** Well-known condition IDs for QE behavior trees */
29
+ export declare const QEConditionIds: {
30
+ readonly HAS_SOURCE_FILES: "qe.has-source-files";
31
+ readonly TESTS_ARE_VALID: "qe.tests-are-valid";
32
+ readonly HAS_TEST_FILES: "qe.has-test-files";
33
+ readonly ALL_TESTS_PASSED: "qe.all-tests-passed";
34
+ readonly HAS_CRITICAL_FINDINGS: "qe.has-critical-findings";
35
+ readonly SCAN_COMPLETE: "qe.scan-complete";
36
+ };
37
+ /**
38
+ * Context for building QE behavior trees with injectable handlers.
39
+ *
40
+ * When building trees for actual execution, provide real action/condition
41
+ * implementations. For testing or serialization, provide stubs.
42
+ */
43
+ export interface QETreeHandlers {
44
+ actions: Partial<Record<string, ActionFunction>>;
45
+ conditions: Partial<Record<string, ConditionPredicate>>;
46
+ }
47
+ /**
48
+ * Build a test generation pipeline behavior tree.
49
+ *
50
+ * Flow:
51
+ * Sequence("Test Generation Pipeline")
52
+ * Condition("Has Source Files")
53
+ * Retry("Analyze Code with Retry", maxRetries=2)
54
+ * Action("Analyze Code")
55
+ * Action("Generate Tests")
56
+ * Sequence("Validate and Commit")
57
+ * Action("Validate Tests")
58
+ * Condition("Tests Are Valid")
59
+ * Action("Commit Tests")
60
+ */
61
+ export declare function buildTestGenerationPipeline(handlers: QETreeHandlers): BehaviorNode;
62
+ /**
63
+ * Build a regression suite execution behavior tree.
64
+ *
65
+ * Flow:
66
+ * Sequence("Regression Suite")
67
+ * Condition("Has Test Files")
68
+ * Action("Load Tests")
69
+ * Timeout("Execute Tests with Timeout", 300000ms)
70
+ * Parallel("Execute Tests in Parallel", threshold=all)
71
+ * Action("Execute Tests")
72
+ * Action("Collect Results")
73
+ * Action("Generate Report")
74
+ */
75
+ export declare function buildRegressionSuite(handlers: QETreeHandlers, testTimeoutMs?: number): BehaviorNode;
76
+ /**
77
+ * Build a security audit behavior tree.
78
+ *
79
+ * Flow:
80
+ * Sequence("Security Audit")
81
+ * Retry("Scan with Retry", maxRetries=3)
82
+ * Action("Scan Vulnerabilities")
83
+ * Action("Classify Findings")
84
+ * Action("Generate Security Report")
85
+ * Selector("Handle Findings")
86
+ * Sequence("Remediate if Critical")
87
+ * Condition("Has Critical Findings")
88
+ * Action("Remediate Issues")
89
+ * Action("Generate Security Report") // fallback: just report
90
+ */
91
+ export declare function buildSecurityAudit(handlers: QETreeHandlers): BehaviorNode;
92
+ /**
93
+ * Create a NodeHandlerRegistry from QETreeHandlers.
94
+ * Maps QE-specific handler maps to the generic deserialization registry.
95
+ */
96
+ export declare function createQEHandlerRegistry(handlers: QETreeHandlers): NodeHandlerRegistry;
97
+ /**
98
+ * Serialize a QE behavior tree to a JSON string.
99
+ */
100
+ export declare function serializeQETree(tree: BehaviorNode): string;
101
+ /**
102
+ * Deserialize a QE behavior tree from a JSON string.
103
+ */
104
+ export declare function deserializeQETree(json: string, handlers: QETreeHandlers): BehaviorNode;
105
+ //# sourceMappingURL=qe-trees.d.ts.map
@@ -0,0 +1,181 @@
1
+ /**
2
+ * Pre-built Behavior Trees for Common QE Workflows
3
+ *
4
+ * Provides ready-to-use behavior tree templates for:
5
+ * - Test generation pipeline
6
+ * - Regression suite execution
7
+ * - Security audit workflow
8
+ *
9
+ * Each tree is constructed using the core nodes and decorators,
10
+ * and can be serialized to JSON for persistence/transfer.
11
+ */
12
+ import { SequenceNode, SelectorNode, ParallelNode, ActionNode, ConditionNode, deserializeNode, } from './nodes.js';
13
+ import { RetryNode, TimeoutNode } from './decorators.js';
14
+ // ============================================================================
15
+ // QE Action/Condition IDs (used for serialization registry)
16
+ // ============================================================================
17
+ /** Well-known action IDs for QE behavior trees */
18
+ export const QEActionIds = {
19
+ // Test Generation Pipeline
20
+ ANALYZE_CODE: 'qe.analyze-code',
21
+ GENERATE_TESTS: 'qe.generate-tests',
22
+ VALIDATE_TESTS: 'qe.validate-tests',
23
+ COMMIT_TESTS: 'qe.commit-tests',
24
+ // Regression Suite
25
+ LOAD_TESTS: 'qe.load-tests',
26
+ EXECUTE_TESTS: 'qe.execute-tests',
27
+ COLLECT_RESULTS: 'qe.collect-results',
28
+ GENERATE_REPORT: 'qe.generate-report',
29
+ // Security Audit
30
+ SCAN_VULNERABILITIES: 'qe.scan-vulnerabilities',
31
+ CLASSIFY_FINDINGS: 'qe.classify-findings',
32
+ GENERATE_SECURITY_REPORT: 'qe.generate-security-report',
33
+ REMEDIATE_ISSUES: 'qe.remediate-issues',
34
+ };
35
+ /** Well-known condition IDs for QE behavior trees */
36
+ export const QEConditionIds = {
37
+ HAS_SOURCE_FILES: 'qe.has-source-files',
38
+ TESTS_ARE_VALID: 'qe.tests-are-valid',
39
+ HAS_TEST_FILES: 'qe.has-test-files',
40
+ ALL_TESTS_PASSED: 'qe.all-tests-passed',
41
+ HAS_CRITICAL_FINDINGS: 'qe.has-critical-findings',
42
+ SCAN_COMPLETE: 'qe.scan-complete',
43
+ };
44
+ function getAction(handlers, id) {
45
+ const fn = handlers.actions[id];
46
+ if (fn)
47
+ return fn;
48
+ return async () => 'SUCCESS';
49
+ }
50
+ function getCondition(handlers, id) {
51
+ const fn = handlers.conditions[id];
52
+ if (fn)
53
+ return fn;
54
+ return async () => true;
55
+ }
56
+ // ============================================================================
57
+ // Test Generation Pipeline
58
+ // ============================================================================
59
+ /**
60
+ * Build a test generation pipeline behavior tree.
61
+ *
62
+ * Flow:
63
+ * Sequence("Test Generation Pipeline")
64
+ * Condition("Has Source Files")
65
+ * Retry("Analyze Code with Retry", maxRetries=2)
66
+ * Action("Analyze Code")
67
+ * Action("Generate Tests")
68
+ * Sequence("Validate and Commit")
69
+ * Action("Validate Tests")
70
+ * Condition("Tests Are Valid")
71
+ * Action("Commit Tests")
72
+ */
73
+ export function buildTestGenerationPipeline(handlers) {
74
+ return new SequenceNode('Test Generation Pipeline', [
75
+ new ConditionNode('Has Source Files', getCondition(handlers, QEConditionIds.HAS_SOURCE_FILES), QEConditionIds.HAS_SOURCE_FILES),
76
+ new RetryNode('Analyze Code with Retry', new ActionNode('Analyze Code', getAction(handlers, QEActionIds.ANALYZE_CODE), QEActionIds.ANALYZE_CODE), 2),
77
+ new ActionNode('Generate Tests', getAction(handlers, QEActionIds.GENERATE_TESTS), QEActionIds.GENERATE_TESTS),
78
+ new SequenceNode('Validate and Commit', [
79
+ new ActionNode('Validate Tests', getAction(handlers, QEActionIds.VALIDATE_TESTS), QEActionIds.VALIDATE_TESTS),
80
+ new ConditionNode('Tests Are Valid', getCondition(handlers, QEConditionIds.TESTS_ARE_VALID), QEConditionIds.TESTS_ARE_VALID),
81
+ new ActionNode('Commit Tests', getAction(handlers, QEActionIds.COMMIT_TESTS), QEActionIds.COMMIT_TESTS),
82
+ ]),
83
+ ]);
84
+ }
85
+ // ============================================================================
86
+ // Regression Suite
87
+ // ============================================================================
88
+ /**
89
+ * Build a regression suite execution behavior tree.
90
+ *
91
+ * Flow:
92
+ * Sequence("Regression Suite")
93
+ * Condition("Has Test Files")
94
+ * Action("Load Tests")
95
+ * Timeout("Execute Tests with Timeout", 300000ms)
96
+ * Parallel("Execute Tests in Parallel", threshold=all)
97
+ * Action("Execute Tests")
98
+ * Action("Collect Results")
99
+ * Action("Generate Report")
100
+ */
101
+ export function buildRegressionSuite(handlers, testTimeoutMs = 300000) {
102
+ return new SequenceNode('Regression Suite', [
103
+ new ConditionNode('Has Test Files', getCondition(handlers, QEConditionIds.HAS_TEST_FILES), QEConditionIds.HAS_TEST_FILES),
104
+ new ActionNode('Load Tests', getAction(handlers, QEActionIds.LOAD_TESTS), QEActionIds.LOAD_TESTS),
105
+ new TimeoutNode('Execute Tests with Timeout', new ParallelNode('Execute Tests in Parallel', [
106
+ new ActionNode('Execute Tests', getAction(handlers, QEActionIds.EXECUTE_TESTS), QEActionIds.EXECUTE_TESTS),
107
+ ], { successThreshold: 1 }), testTimeoutMs),
108
+ new ActionNode('Collect Results', getAction(handlers, QEActionIds.COLLECT_RESULTS), QEActionIds.COLLECT_RESULTS),
109
+ new ActionNode('Generate Report', getAction(handlers, QEActionIds.GENERATE_REPORT), QEActionIds.GENERATE_REPORT),
110
+ ]);
111
+ }
112
+ // ============================================================================
113
+ // Security Audit
114
+ // ============================================================================
115
+ /**
116
+ * Build a security audit behavior tree.
117
+ *
118
+ * Flow:
119
+ * Sequence("Security Audit")
120
+ * Retry("Scan with Retry", maxRetries=3)
121
+ * Action("Scan Vulnerabilities")
122
+ * Action("Classify Findings")
123
+ * Action("Generate Security Report")
124
+ * Selector("Handle Findings")
125
+ * Sequence("Remediate if Critical")
126
+ * Condition("Has Critical Findings")
127
+ * Action("Remediate Issues")
128
+ * Action("Generate Security Report") // fallback: just report
129
+ */
130
+ export function buildSecurityAudit(handlers) {
131
+ return new SequenceNode('Security Audit', [
132
+ new RetryNode('Scan with Retry', new ActionNode('Scan Vulnerabilities', getAction(handlers, QEActionIds.SCAN_VULNERABILITIES), QEActionIds.SCAN_VULNERABILITIES), 3),
133
+ new ActionNode('Classify Findings', getAction(handlers, QEActionIds.CLASSIFY_FINDINGS), QEActionIds.CLASSIFY_FINDINGS),
134
+ new ActionNode('Generate Security Report', getAction(handlers, QEActionIds.GENERATE_SECURITY_REPORT), QEActionIds.GENERATE_SECURITY_REPORT),
135
+ new SelectorNode('Handle Findings', [
136
+ new SequenceNode('Remediate if Critical', [
137
+ new ConditionNode('Has Critical Findings', getCondition(handlers, QEConditionIds.HAS_CRITICAL_FINDINGS), QEConditionIds.HAS_CRITICAL_FINDINGS),
138
+ new ActionNode('Remediate Issues', getAction(handlers, QEActionIds.REMEDIATE_ISSUES), QEActionIds.REMEDIATE_ISSUES),
139
+ ]),
140
+ // Fallback: always succeed (no critical findings = no remediation needed)
141
+ new ActionNode('No Remediation Needed', async () => 'SUCCESS', 'qe.no-remediation-needed'),
142
+ ]),
143
+ ]);
144
+ }
145
+ // ============================================================================
146
+ // Serialization Utilities
147
+ // ============================================================================
148
+ /**
149
+ * Create a NodeHandlerRegistry from QETreeHandlers.
150
+ * Maps QE-specific handler maps to the generic deserialization registry.
151
+ */
152
+ export function createQEHandlerRegistry(handlers) {
153
+ const actions = new Map();
154
+ const conditions = new Map();
155
+ for (const [id, fn] of Object.entries(handlers.actions)) {
156
+ if (fn)
157
+ actions.set(id, fn);
158
+ }
159
+ for (const [id, fn] of Object.entries(handlers.conditions)) {
160
+ if (fn)
161
+ conditions.set(id, fn);
162
+ }
163
+ // Add the no-remediation-needed fallback
164
+ actions.set('qe.no-remediation-needed', async () => 'SUCCESS');
165
+ return { actions, conditions };
166
+ }
167
+ /**
168
+ * Serialize a QE behavior tree to a JSON string.
169
+ */
170
+ export function serializeQETree(tree) {
171
+ return JSON.stringify(tree.serialize(), null, 2);
172
+ }
173
+ /**
174
+ * Deserialize a QE behavior tree from a JSON string.
175
+ */
176
+ export function deserializeQETree(json, handlers) {
177
+ const data = JSON.parse(json);
178
+ const registry = createQEHandlerRegistry(handlers);
179
+ return deserializeNode(data, registry);
180
+ }
181
+ //# sourceMappingURL=qe-trees.js.map