0xray 4.0.34 → 4.0.35
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.
- package/.grok-plugin/plugin.json +1 -1
- package/.xray/codex.json +12 -4
- package/.xray/features.json +1 -1
- package/AGENTS-consumer.md +6 -6
- package/AGENTS.md +5 -5
- package/README.md +2 -2
- package/dist/AGENTS.md +5 -5
- package/dist/CHANGELOG.md +16 -0
- package/dist/README.md +2 -2
- package/dist/cli/index.js +2 -5
- package/dist/governance/governance-service.js +1 -1
- package/dist/integrations/base/README.md +1 -9
- package/dist/integrations/base/index.d.ts +0 -1
- package/dist/integrations/base/index.js +0 -2
- package/dist/integrations/governance/index.js +31 -8
- package/dist/integrations/grok/hooks/grok-hook-utils.js +1 -1
- package/dist/integrations/grok/hooks/session-start.js +12 -0
- package/dist/integrations/hooks/goggles-pipeline.mjs +62 -11
- package/dist/integrations/hooks/host-truth.mjs +74 -0
- package/dist/integrations/hooks/station-hook-runtime.cjs +3 -0
- package/dist/integrations/openclaw/plugin/xray-pre-tool/package.json +1 -1
- package/dist/mcps/knowledge-skills/storyteller.server.js +0 -1
- package/dist/nucleus/delegation-gate.d.ts +2 -2
- package/dist/nucleus/delegation-gate.js +13 -2
- package/dist/nucleus/work-freshness.mjs +189 -0
- package/dist/processors/implementations/agents-md-validation-processor.js +1 -1
- package/docs-site/docs/plates/boot.md +17 -2
- package/docs-site/docs/plates/governance.md +3 -2
- package/docs-site/docs/plates/index.md +3 -1
- package/docs-site/docs/plates/memory-recall.md +26 -35
- package/docs-site/docs/plates/orchestration.md +39 -35
- package/docs-site/docs/plates/processor.md +34 -36
- package/docs-site/docs/plates/reporting.md +3 -8
- package/docs-site/docs/plates/routing.md +22 -11
- package/package.json +2 -2
- package/scripts/foundry/release.mjs +48 -5
- package/scripts/mjs/test-consumer-readiness.mjs +1 -0
- package/scripts/mjs/test-mcp-functionality.mjs +14 -9
- package/scripts/node/basic-security-audit.cjs +0 -1
- package/scripts/node/bridge-mcp-wiring.cjs +66 -3
- package/scripts/node/postinstall.cjs +1 -1
- package/scripts/node/prepare-consumer.cjs +11 -7
- package/scripts/node/setup-dev.cjs +18 -26
- package/scripts/node/validate-mcp-connectivity.js +2 -1
- package/src/integrations/openclaw/plugin/xray-pre-tool/package.json +1 -1
- package/src/mcps/knowledge-skills/storyteller.server.ts +0 -1
- package/xray/agents_template.md +5 -5
- package/xray/codex.json +12 -4
- package/xray/features.json +1 -1
- package/dist/agents/known-names.d.ts +0 -26
- package/dist/agents/known-names.js +0 -72
- package/dist/analytics/consent-manager.d.ts +0 -92
- package/dist/analytics/consent-manager.js +0 -257
- package/dist/benchmark/performance-benchmark.d.ts +0 -103
- package/dist/benchmark/performance-benchmark.js +0 -373
- package/dist/cli/commands/analytics-disable.d.ts +0 -9
- package/dist/cli/commands/analytics-disable.js +0 -72
- package/dist/cli/commands/analytics-enable-action.d.ts +0 -8
- package/dist/cli/commands/analytics-enable-action.js +0 -82
- package/dist/cli/commands/analytics-preview.d.ts +0 -9
- package/dist/cli/commands/analytics-preview.js +0 -106
- package/dist/cli/commands/analytics-status.d.ts +0 -9
- package/dist/cli/commands/analytics-status.js +0 -68
- package/dist/cli/commands/enforce.d.ts +0 -12
- package/dist/cli/commands/enforce.js +0 -78
- package/dist/cli/commands/govern.d.ts +0 -29
- package/dist/cli/commands/govern.js +0 -149
- package/dist/cli/commands/security-audit.d.ts +0 -23
- package/dist/cli/commands/security-audit.js +0 -219
- package/dist/cli/server.d.ts +0 -1
- package/dist/cli/server.js +0 -147
- package/dist/config/routing-mappings.d.ts +0 -26
- package/dist/config/routing-mappings.js +0 -151
- package/dist/core/bridge.mjs +0 -922
- package/dist/core/trace-context.d.ts +0 -12
- package/dist/core/trace-context.js +0 -33
- package/dist/enforcement/index.d.ts +0 -22
- package/dist/enforcement/index.js +0 -40
- package/dist/enforcement/loaders/index.d.ts +0 -36
- package/dist/enforcement/loaders/index.js +0 -39
- package/dist/enforcement/test-auto-healing.d.ts +0 -83
- package/dist/enforcement/test-auto-healing.js +0 -325
- package/dist/inference/index.d.ts +0 -10
- package/dist/inference/index.js +0 -5
- package/dist/infrastructure/iac-validator.d.ts +0 -150
- package/dist/infrastructure/iac-validator.js +0 -465
- package/dist/infrastructure/schemas/cloud-schemas.d.ts +0 -482
- package/dist/infrastructure/schemas/cloud-schemas.js +0 -488
- package/dist/integrations/base/ExampleIntegration.d.ts +0 -46
- package/dist/integrations/base/ExampleIntegration.js +0 -180
- package/dist/integrations/enforcement-gate.d.ts +0 -44
- package/dist/integrations/enforcement-gate.js +0 -348
- package/dist/mcps/connection/connection-manager.d.ts +0 -39
- package/dist/mcps/connection/connection-manager.js +0 -79
- package/dist/mcps/index.d.ts +0 -17
- package/dist/mcps/index.js +0 -65
- package/dist/mcps/orchestrator/index.d.ts +0 -6
- package/dist/mcps/orchestrator/index.js +0 -5
- package/dist/metrics/index.d.ts +0 -6
- package/dist/metrics/index.js +0 -6
- package/dist/orchestrator/self-direction-activation.d.ts +0 -108
- package/dist/orchestrator/self-direction-activation.js +0 -244
- package/dist/orchestrator/universal-registry-bridge.d.ts +0 -84
- package/dist/orchestrator/universal-registry-bridge.js +0 -246
- package/dist/performance/performance-budget-enforcer.d.ts +0 -157
- package/dist/performance/performance-budget-enforcer.js +0 -433
- package/dist/performance/performance-regression-tester.d.ts +0 -107
- package/dist/performance/performance-regression-tester.js +0 -341
- package/dist/postprocessor/analysis/CodeChangeAnalyzer.d.ts +0 -11
- package/dist/postprocessor/analysis/CodeChangeAnalyzer.js +0 -50
- package/dist/postprocessor/config/ProcessorConfigLoader.d.ts +0 -44
- package/dist/postprocessor/config/ProcessorConfigLoader.js +0 -16
- package/dist/postprocessor/integration.d.ts +0 -156
- package/dist/postprocessor/integration.js +0 -194
- package/dist/postprocessor/metamorphosis/index.d.ts +0 -2
- package/dist/postprocessor/metamorphosis/index.js +0 -1
- package/dist/postprocessor/redeploy/RetryHandler.d.ts +0 -49
- package/dist/postprocessor/redeploy/RetryHandler.js +0 -118
- package/dist/processors/implementations/session-capture-processor.d.ts +0 -14
- package/dist/processors/implementations/session-capture-processor.js +0 -37
- package/dist/public/XrayService.d.ts +0 -17
- package/dist/public/XrayService.js +0 -40
- package/dist/public/index.d.ts +0 -4
- package/dist/public/index.js +0 -2
- package/dist/security/comprehensive-security-audit.d.ts +0 -157
- package/dist/security/comprehensive-security-audit.js +0 -1004
- package/dist/security/index.d.ts +0 -13
- package/dist/security/index.js +0 -13
- package/dist/security/security-agent-coordinator.d.ts +0 -71
- package/dist/security/security-agent-coordinator.js +0 -203
- package/dist/security/security-hardening-system.d.ts +0 -238
- package/dist/security/security-hardening-system.js +0 -726
- package/dist/security/security-orchestration-layer.d.ts +0 -118
- package/dist/security/security-orchestration-layer.js +0 -495
- package/dist/testing/memory-regression-suite.d.ts +0 -105
- package/dist/testing/memory-regression-suite.js +0 -258
- package/dist/tools/assess-complexity-tool.d.ts +0 -28
- package/dist/tools/assess-complexity-tool.js +0 -44
- package/dist/tools/query-routing-tool.d.ts +0 -17
- package/dist/tools/query-routing-tool.js +0 -59
- package/dist/utils/batch-operations.d.ts +0 -25
- package/dist/utils/batch-operations.js +0 -292
- package/dist/utils/task-graph.d.ts +0 -29
- package/dist/utils/task-graph.js +0 -106
- package/dist/utils/test-template-generator.d.ts +0 -25
- package/dist/utils/test-template-generator.js +0 -178
- package/dist/utils/token-manager.d.ts +0 -48
- package/dist/utils/token-manager.js +0 -163
- package/dist/validation/agent-config-validator.d.ts +0 -110
- package/dist/validation/agent-config-validator.js +0 -280
- package/dist/validation/orchestration-flow-validator.d.ts +0 -87
- package/dist/validation/orchestration-flow-validator.js +0 -606
- package/src/mcps/connection/connection-manager.ts +0 -91
- package/src/mcps/index.ts +0 -80
- package/src/mcps/orchestrator/index.ts +0 -29
|
@@ -1,341 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Performance Regression Testing
|
|
3
|
-
*
|
|
4
|
-
* Automated testing system that detects performance regressions and
|
|
5
|
-
* enforces performance budget compliance in CI/CD pipelines.
|
|
6
|
-
*
|
|
7
|
-
* @since 2026-01-08
|
|
8
|
-
*/
|
|
9
|
-
import { performance } from "perf_hooks";
|
|
10
|
-
import * as fs from "fs";
|
|
11
|
-
import { frameworkLogger } from "../core/framework-logger.js";
|
|
12
|
-
import { PerformanceBudgetEnforcer, PERFORMANCE_BUDGET, } from "./performance-budget-enforcer.js";
|
|
13
|
-
/**
|
|
14
|
-
* Performance regression testing system
|
|
15
|
-
*/
|
|
16
|
-
export class PerformanceRegressionTester {
|
|
17
|
-
baselines = new Map();
|
|
18
|
-
results = [];
|
|
19
|
-
budgetEnforcer;
|
|
20
|
-
constructor(budgetEnforcer) {
|
|
21
|
-
this.budgetEnforcer = budgetEnforcer || new PerformanceBudgetEnforcer();
|
|
22
|
-
}
|
|
23
|
-
/**
|
|
24
|
-
* Load performance baselines from file
|
|
25
|
-
*/
|
|
26
|
-
loadBaselines(baselineFile) {
|
|
27
|
-
try {
|
|
28
|
-
if (fs.existsSync(baselineFile)) {
|
|
29
|
-
const data = fs.readFileSync(baselineFile, "utf8");
|
|
30
|
-
const baselines = JSON.parse(data);
|
|
31
|
-
this.baselines = new Map(Object.entries(baselines));
|
|
32
|
-
}
|
|
33
|
-
else {
|
|
34
|
-
// No existing baselines found, will use defaults
|
|
35
|
-
}
|
|
36
|
-
}
|
|
37
|
-
catch (error) {
|
|
38
|
-
frameworkLogger.log("performance-regression-tester", "baseline-load-failed", "error", { file: baselineFile, error });
|
|
39
|
-
}
|
|
40
|
-
}
|
|
41
|
-
/**
|
|
42
|
-
* Save performance baselines to file
|
|
43
|
-
*/
|
|
44
|
-
saveBaselines(baselineFile) {
|
|
45
|
-
try {
|
|
46
|
-
const baselines = Object.fromEntries(this.baselines);
|
|
47
|
-
fs.writeFileSync(baselineFile, JSON.stringify(baselines, null, 2));
|
|
48
|
-
}
|
|
49
|
-
catch (error) {
|
|
50
|
-
frameworkLogger.log("performance-regression-tester", "baseline-save-failed", "error", { file: baselineFile, error });
|
|
51
|
-
}
|
|
52
|
-
}
|
|
53
|
-
/**
|
|
54
|
-
* Run a single performance regression test
|
|
55
|
-
*/
|
|
56
|
-
async runRegressionTest(test) {
|
|
57
|
-
const startTime = performance.now();
|
|
58
|
-
try {
|
|
59
|
-
// Set timeout for the test
|
|
60
|
-
const timeoutPromise = new Promise((_, reject) => {
|
|
61
|
-
setTimeout(() => reject(new Error(`Test timeout after ${test.timeout}ms`)), test.timeout);
|
|
62
|
-
});
|
|
63
|
-
const testPromise = Promise.resolve(test.testFunction());
|
|
64
|
-
await Promise.race([testPromise, timeoutPromise]);
|
|
65
|
-
const duration = performance.now() - startTime;
|
|
66
|
-
const baseline = this.baselines.get(test.name);
|
|
67
|
-
let deviation = 0;
|
|
68
|
-
let status = "pass";
|
|
69
|
-
if (baseline) {
|
|
70
|
-
deviation =
|
|
71
|
-
((duration - baseline.averageDuration) / baseline.averageDuration) *
|
|
72
|
-
100;
|
|
73
|
-
if (Math.abs(deviation) > test.tolerance) {
|
|
74
|
-
if (Math.abs(deviation) > test.tolerance * 2) {
|
|
75
|
-
status = "fail";
|
|
76
|
-
}
|
|
77
|
-
else {
|
|
78
|
-
status = "warning";
|
|
79
|
-
}
|
|
80
|
-
}
|
|
81
|
-
}
|
|
82
|
-
else {
|
|
83
|
-
// No baseline, create one
|
|
84
|
-
deviation = 0;
|
|
85
|
-
status = "pass";
|
|
86
|
-
}
|
|
87
|
-
const expectedDuration = baseline
|
|
88
|
-
? baseline.averageDuration
|
|
89
|
-
: test.expectedDuration || duration;
|
|
90
|
-
const result = {
|
|
91
|
-
testName: test.name,
|
|
92
|
-
duration,
|
|
93
|
-
expectedDuration,
|
|
94
|
-
deviation,
|
|
95
|
-
status,
|
|
96
|
-
timestamp: Date.now(),
|
|
97
|
-
};
|
|
98
|
-
this.results.push(result);
|
|
99
|
-
return result;
|
|
100
|
-
}
|
|
101
|
-
catch (error) {
|
|
102
|
-
const duration = performance.now() - startTime;
|
|
103
|
-
const result = {
|
|
104
|
-
testName: test.name,
|
|
105
|
-
duration,
|
|
106
|
-
deviation: 0,
|
|
107
|
-
status: "fail",
|
|
108
|
-
error: error instanceof Error ? error.message : String(error),
|
|
109
|
-
timestamp: Date.now(),
|
|
110
|
-
};
|
|
111
|
-
this.results.push(result);
|
|
112
|
-
return result;
|
|
113
|
-
}
|
|
114
|
-
}
|
|
115
|
-
/**
|
|
116
|
-
* Run a complete regression test suite
|
|
117
|
-
*/
|
|
118
|
-
async runTestSuite(suite) {
|
|
119
|
-
// Load baselines
|
|
120
|
-
this.loadBaselines(suite.baselineFile);
|
|
121
|
-
const suiteStartTime = performance.now();
|
|
122
|
-
const results = [];
|
|
123
|
-
// Run all tests
|
|
124
|
-
for (const test of suite.tests) {
|
|
125
|
-
const result = await this.runRegressionTest(test);
|
|
126
|
-
results.push(result);
|
|
127
|
-
const statusIcon = result.status === "pass"
|
|
128
|
-
? "✅"
|
|
129
|
-
: result.status === "warning"
|
|
130
|
-
? "⚠️"
|
|
131
|
-
: "❌";
|
|
132
|
-
const durationStr = result.duration.toFixed(2);
|
|
133
|
-
const deviationStr = result.deviation.toFixed(2);
|
|
134
|
-
const expectedStr = result.expectedDuration
|
|
135
|
-
? result.expectedDuration.toFixed(2)
|
|
136
|
-
: "N/A";
|
|
137
|
-
if (result.error) {
|
|
138
|
-
frameworkLogger.log("performance-regression-tester", "test-failed", "error", { testName: result.testName, error: result.error });
|
|
139
|
-
}
|
|
140
|
-
}
|
|
141
|
-
// Update baselines with new results
|
|
142
|
-
this.updateBaselines(results);
|
|
143
|
-
// Generate performance budget report
|
|
144
|
-
let budgetReport;
|
|
145
|
-
try {
|
|
146
|
-
budgetReport = await this.budgetEnforcer.generatePerformanceReport();
|
|
147
|
-
}
|
|
148
|
-
catch (error) {
|
|
149
|
-
frameworkLogger.log("performance-regression-tester", "budget-report-failed", "error", { error });
|
|
150
|
-
}
|
|
151
|
-
const suiteDuration = performance.now() - suiteStartTime;
|
|
152
|
-
const summary = this.generateSummary(results, suiteDuration);
|
|
153
|
-
// Display summary
|
|
154
|
-
// Test failure count - kept as console.log for CI visibility
|
|
155
|
-
if (budgetReport) {
|
|
156
|
-
if (budgetReport.violations.length > 0) {
|
|
157
|
-
budgetReport.violations.forEach((v) => { });
|
|
158
|
-
}
|
|
159
|
-
}
|
|
160
|
-
// Save updated baselines
|
|
161
|
-
this.saveBaselines(suite.baselineFile);
|
|
162
|
-
// Check if suite should fail
|
|
163
|
-
const shouldFail = suite.failOnRegression &&
|
|
164
|
-
(summary.failed > 0 ||
|
|
165
|
-
(budgetReport && budgetReport.overallStatus === "fail"));
|
|
166
|
-
if (shouldFail) {
|
|
167
|
-
throw new Error("Performance regression test suite failed");
|
|
168
|
-
}
|
|
169
|
-
else {
|
|
170
|
-
frameworkLogger.log("performance-regression-tester", "suite-passed", "info", { message: "Performance regression test suite passed" });
|
|
171
|
-
}
|
|
172
|
-
const result = {
|
|
173
|
-
results,
|
|
174
|
-
summary,
|
|
175
|
-
success: !shouldFail,
|
|
176
|
-
};
|
|
177
|
-
if (budgetReport) {
|
|
178
|
-
result.budgetReport = budgetReport;
|
|
179
|
-
}
|
|
180
|
-
return result;
|
|
181
|
-
}
|
|
182
|
-
/**
|
|
183
|
-
* Update baselines with new test results
|
|
184
|
-
*/
|
|
185
|
-
updateBaselines(results) {
|
|
186
|
-
for (const result of results) {
|
|
187
|
-
if (result.status === "pass" || result.status === "warning") {
|
|
188
|
-
const existing = this.baselines.get(result.testName);
|
|
189
|
-
if (existing) {
|
|
190
|
-
// Update rolling average
|
|
191
|
-
const newCount = existing.sampleCount + 1;
|
|
192
|
-
const newAverage = (existing.averageDuration * existing.sampleCount +
|
|
193
|
-
result.duration) /
|
|
194
|
-
newCount;
|
|
195
|
-
// Update standard deviation (simplified)
|
|
196
|
-
const variance = Math.pow(result.duration - existing.averageDuration, 2);
|
|
197
|
-
const newStdDev = Math.sqrt((existing.standardDeviation *
|
|
198
|
-
existing.standardDeviation *
|
|
199
|
-
existing.sampleCount +
|
|
200
|
-
variance) /
|
|
201
|
-
newCount);
|
|
202
|
-
this.baselines.set(result.testName, {
|
|
203
|
-
...existing,
|
|
204
|
-
averageDuration: newAverage,
|
|
205
|
-
standardDeviation: newStdDev,
|
|
206
|
-
sampleCount: newCount,
|
|
207
|
-
lastUpdated: Date.now(),
|
|
208
|
-
});
|
|
209
|
-
}
|
|
210
|
-
else {
|
|
211
|
-
// Create new baseline
|
|
212
|
-
this.baselines.set(result.testName, {
|
|
213
|
-
testName: result.testName,
|
|
214
|
-
averageDuration: result.duration,
|
|
215
|
-
standardDeviation: 0,
|
|
216
|
-
sampleCount: 1,
|
|
217
|
-
lastUpdated: Date.now(),
|
|
218
|
-
tolerance: 10, // Default 10% tolerance
|
|
219
|
-
});
|
|
220
|
-
}
|
|
221
|
-
}
|
|
222
|
-
}
|
|
223
|
-
}
|
|
224
|
-
/**
|
|
225
|
-
* Generate test suite summary
|
|
226
|
-
*/
|
|
227
|
-
generateSummary(results, suiteDuration) {
|
|
228
|
-
const passed = results.filter((r) => r.status === "pass").length;
|
|
229
|
-
const warnings = results.filter((r) => r.status === "warning").length;
|
|
230
|
-
const failed = results.filter((r) => r.status === "fail").length;
|
|
231
|
-
const deviations = results.map((r) => Math.abs(r.deviation));
|
|
232
|
-
const averageDeviation = deviations.length > 0
|
|
233
|
-
? deviations.reduce((a, b) => a + b, 0) / deviations.length
|
|
234
|
-
: 0;
|
|
235
|
-
const maxDeviation = deviations.length > 0 ? Math.max(...deviations) : 0;
|
|
236
|
-
return {
|
|
237
|
-
totalTests: results.length,
|
|
238
|
-
passed,
|
|
239
|
-
warnings,
|
|
240
|
-
failed,
|
|
241
|
-
averageDeviation,
|
|
242
|
-
maxDeviation,
|
|
243
|
-
duration: suiteDuration,
|
|
244
|
-
};
|
|
245
|
-
}
|
|
246
|
-
/**
|
|
247
|
-
* Create default performance regression test suite
|
|
248
|
-
*/
|
|
249
|
-
createDefaultTestSuite() {
|
|
250
|
-
const tests = [
|
|
251
|
-
{
|
|
252
|
-
name: "bundle-size-analysis",
|
|
253
|
-
description: "Analyze bundle size against performance budget",
|
|
254
|
-
testFunction: async () => {
|
|
255
|
-
await this.budgetEnforcer.analyzeBundleSize();
|
|
256
|
-
},
|
|
257
|
-
timeout: 10000,
|
|
258
|
-
tolerance: 5,
|
|
259
|
-
},
|
|
260
|
-
{
|
|
261
|
-
name: "module-import-performance",
|
|
262
|
-
description: "Measure core module import performance",
|
|
263
|
-
testFunction: async () => {
|
|
264
|
-
const start = performance.now();
|
|
265
|
-
await import("../core/index");
|
|
266
|
-
const duration = performance.now() - start;
|
|
267
|
-
if (duration > PERFORMANCE_BUDGET.runtime.startupTime) {
|
|
268
|
-
throw new Error(`Import time ${duration.toFixed(2)}ms exceeds budget of ${PERFORMANCE_BUDGET.runtime.startupTime}ms`);
|
|
269
|
-
}
|
|
270
|
-
},
|
|
271
|
-
timeout: 5000,
|
|
272
|
-
tolerance: 10,
|
|
273
|
-
},
|
|
274
|
-
{
|
|
275
|
-
name: "memory-usage-check",
|
|
276
|
-
description: "Verify memory usage stays within budget",
|
|
277
|
-
testFunction: () => {
|
|
278
|
-
const memUsage = process.memoryUsage();
|
|
279
|
-
if (memUsage.heapUsed > PERFORMANCE_BUDGET.runtime.memoryUsage) {
|
|
280
|
-
throw new Error(`Heap usage ${(memUsage.heapUsed / 1024 / 1024).toFixed(2)}MB exceeds budget of ${(PERFORMANCE_BUDGET.runtime.memoryUsage / 1024 / 1024).toFixed(2)}MB`);
|
|
281
|
-
}
|
|
282
|
-
},
|
|
283
|
-
timeout: 1000,
|
|
284
|
-
tolerance: 5,
|
|
285
|
-
},
|
|
286
|
-
{
|
|
287
|
-
name: "test-execution-performance",
|
|
288
|
-
description: "Measure simple test execution time",
|
|
289
|
-
testFunction: async () => {
|
|
290
|
-
const start = performance.now();
|
|
291
|
-
// Simple test operation instead of running npm test
|
|
292
|
-
const testArray = Array.from({ length: 1000 }, (_, i) => i * i);
|
|
293
|
-
const result = testArray.reduce((sum, val) => sum + val, 0);
|
|
294
|
-
if (result < 0)
|
|
295
|
-
throw new Error("Unexpected result"); // Never happens
|
|
296
|
-
const duration = performance.now() - start;
|
|
297
|
-
// Just ensure the operation completes in reasonable time
|
|
298
|
-
if (duration > 100) {
|
|
299
|
-
throw new Error(`Test operation ${duration.toFixed(2)}ms too slow`);
|
|
300
|
-
}
|
|
301
|
-
},
|
|
302
|
-
timeout: 5000,
|
|
303
|
-
tolerance: 20,
|
|
304
|
-
},
|
|
305
|
-
];
|
|
306
|
-
return {
|
|
307
|
-
name: "0xRay Performance Regression Suite",
|
|
308
|
-
description: "Comprehensive performance regression tests for 0xRay Framework",
|
|
309
|
-
tests,
|
|
310
|
-
baselineFile: "./performance-baselines.json",
|
|
311
|
-
failOnRegression: true,
|
|
312
|
-
warningThreshold: 10,
|
|
313
|
-
failureThreshold: 20,
|
|
314
|
-
};
|
|
315
|
-
}
|
|
316
|
-
/**
|
|
317
|
-
* Export test results for analysis
|
|
318
|
-
*/
|
|
319
|
-
exportResults() {
|
|
320
|
-
const summary = {
|
|
321
|
-
totalTests: this.results.length,
|
|
322
|
-
passRate: this.results.length > 0
|
|
323
|
-
? (this.results.filter((r) => r.status === "pass").length /
|
|
324
|
-
this.results.length) *
|
|
325
|
-
100
|
|
326
|
-
: 0,
|
|
327
|
-
averageDeviation: this.results.length > 0
|
|
328
|
-
? this.results.reduce((sum, r) => sum + Math.abs(r.deviation), 0) /
|
|
329
|
-
this.results.length
|
|
330
|
-
: 0,
|
|
331
|
-
regressionDetected: this.results.some((r) => r.status === "fail"),
|
|
332
|
-
};
|
|
333
|
-
return {
|
|
334
|
-
results: this.results,
|
|
335
|
-
baselines: Object.fromEntries(this.baselines),
|
|
336
|
-
summary,
|
|
337
|
-
};
|
|
338
|
-
}
|
|
339
|
-
}
|
|
340
|
-
// Export singleton instance
|
|
341
|
-
export const performanceRegressionTester = new PerformanceRegressionTester();
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import { PostProcessorContext } from "../types.js";
|
|
2
|
-
export declare class CodeChangeAnalyzer {
|
|
3
|
-
analyzeCodeChanges(context: PostProcessorContext): Promise<{
|
|
4
|
-
operation: "commit";
|
|
5
|
-
files: string[];
|
|
6
|
-
newCode: Map<string, string>;
|
|
7
|
-
existingCode: Map<string, string>;
|
|
8
|
-
tests: string[];
|
|
9
|
-
dependencies: string[];
|
|
10
|
-
}>;
|
|
11
|
-
}
|
|
@@ -1,50 +0,0 @@
|
|
|
1
|
-
import { frameworkLogger } from "../../core/framework-logger.js";
|
|
2
|
-
export class CodeChangeAnalyzer {
|
|
3
|
-
async analyzeCodeChanges(context) {
|
|
4
|
-
const fs = await import("fs");
|
|
5
|
-
const path = await import("path");
|
|
6
|
-
const newCode = new Map();
|
|
7
|
-
const existingCode = new Map();
|
|
8
|
-
const tests = [];
|
|
9
|
-
const dependencies = [];
|
|
10
|
-
try {
|
|
11
|
-
// Read new/changed files
|
|
12
|
-
for (const file of context.files || []) {
|
|
13
|
-
try {
|
|
14
|
-
const fullPath = path.join(process.cwd(), file);
|
|
15
|
-
if (fs.existsSync(fullPath)) {
|
|
16
|
-
// Read new code
|
|
17
|
-
const content = fs.readFileSync(fullPath, "utf-8");
|
|
18
|
-
newCode.set(file, content);
|
|
19
|
-
// Check for test files
|
|
20
|
-
if (file.includes(".test.") || file.includes(".spec.")) {
|
|
21
|
-
tests.push(file);
|
|
22
|
-
}
|
|
23
|
-
// Check for package.json or dependency files
|
|
24
|
-
if (file.includes("package.json") || file.includes("requirements.txt") || file.includes("Cargo.toml")) {
|
|
25
|
-
dependencies.push(file);
|
|
26
|
-
}
|
|
27
|
-
}
|
|
28
|
-
}
|
|
29
|
-
catch (error) {
|
|
30
|
-
// Skip files that can't be read
|
|
31
|
-
await frameworkLogger.log("-post-processor", "-code-analysis-file-error", "info", { message: `Could not analyze ${file}: ${error}` });
|
|
32
|
-
}
|
|
33
|
-
}
|
|
34
|
-
await frameworkLogger.log("-post-processor", "-code-analysis-complete", "info", {
|
|
35
|
-
message: `Analyzed ${newCode.size} files, ${tests.length} tests, ${dependencies.length} dependencies`,
|
|
36
|
-
});
|
|
37
|
-
}
|
|
38
|
-
catch (error) {
|
|
39
|
-
await frameworkLogger.log("-post-processor", "-code-analysis-failed", "error", { message: `Code analysis failed: ${error}` });
|
|
40
|
-
}
|
|
41
|
-
return {
|
|
42
|
-
operation: "commit",
|
|
43
|
-
files: context.files || [],
|
|
44
|
-
newCode,
|
|
45
|
-
existingCode,
|
|
46
|
-
tests,
|
|
47
|
-
dependencies,
|
|
48
|
-
};
|
|
49
|
-
}
|
|
50
|
-
}
|
|
@@ -1,44 +0,0 @@
|
|
|
1
|
-
export declare class ProcessorConfigLoader {
|
|
2
|
-
loadProcessorConfig(): Promise<{
|
|
3
|
-
preValidate?: {
|
|
4
|
-
enabled?: boolean;
|
|
5
|
-
};
|
|
6
|
-
codexCompliance?: {
|
|
7
|
-
enabled?: boolean;
|
|
8
|
-
};
|
|
9
|
-
testAutoCreation?: {
|
|
10
|
-
enabled?: boolean;
|
|
11
|
-
};
|
|
12
|
-
versionCompliance?: {
|
|
13
|
-
enabled?: boolean;
|
|
14
|
-
};
|
|
15
|
-
errorBoundary?: {
|
|
16
|
-
enabled?: boolean;
|
|
17
|
-
};
|
|
18
|
-
agentsMdValidation?: {
|
|
19
|
-
enabled?: boolean;
|
|
20
|
-
};
|
|
21
|
-
stateValidation?: {
|
|
22
|
-
enabled?: boolean;
|
|
23
|
-
};
|
|
24
|
-
post_processors?: {
|
|
25
|
-
enabled?: boolean;
|
|
26
|
-
priority_order?: string[];
|
|
27
|
-
};
|
|
28
|
-
storytellingTrigger?: {
|
|
29
|
-
enabled?: boolean;
|
|
30
|
-
};
|
|
31
|
-
sessionSummary?: {
|
|
32
|
-
enabled?: boolean;
|
|
33
|
-
};
|
|
34
|
-
testExecution?: {
|
|
35
|
-
enabled?: boolean;
|
|
36
|
-
};
|
|
37
|
-
regressionTesting?: {
|
|
38
|
-
enabled?: boolean;
|
|
39
|
-
};
|
|
40
|
-
inferenceImprovement?: {
|
|
41
|
-
enabled?: boolean;
|
|
42
|
-
};
|
|
43
|
-
}>;
|
|
44
|
-
}
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
import { featuresConfigLoader } from "../../core/features-config.js";
|
|
2
|
-
import { frameworkLogger } from "../../core/framework-logger.js";
|
|
3
|
-
export class ProcessorConfigLoader {
|
|
4
|
-
async loadProcessorConfig() {
|
|
5
|
-
try {
|
|
6
|
-
const config = featuresConfigLoader.loadConfig();
|
|
7
|
-
return config.processors ?? {};
|
|
8
|
-
}
|
|
9
|
-
catch (error) {
|
|
10
|
-
frameworkLogger.log("postprocessor", "processor-config-load-failed", "info", {
|
|
11
|
-
error: error instanceof Error ? error.message : String(error),
|
|
12
|
-
});
|
|
13
|
-
}
|
|
14
|
-
return {};
|
|
15
|
-
}
|
|
16
|
-
}
|
|
@@ -1,156 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* 0xRay Integration Layer
|
|
3
|
-
*
|
|
4
|
-
* Provides generic connectors for integrating 0xRay's PostProcessor
|
|
5
|
-
* with external applications and frameworks.
|
|
6
|
-
*
|
|
7
|
-
* This is framework-agnostic - works with Express, Fastify, Koa, etc.
|
|
8
|
-
*
|
|
9
|
-
* @since 2026-03-08
|
|
10
|
-
*/
|
|
11
|
-
import express from "express";
|
|
12
|
-
import { PostProcessor } from './PostProcessor.js';
|
|
13
|
-
import type { WebhookConfig } from './triggers/WebhookTrigger.js';
|
|
14
|
-
import type { APIConfig } from './triggers/APITrigger.js';
|
|
15
|
-
export { WebhookTrigger } from './triggers/WebhookTrigger.js';
|
|
16
|
-
export { APITrigger } from './triggers/APITrigger.js';
|
|
17
|
-
export type { WebhookConfig, WebhookEvent } from './triggers/WebhookTrigger.js';
|
|
18
|
-
export type { APIConfig, APIRequest } from './triggers/APITrigger.js';
|
|
19
|
-
/**
|
|
20
|
-
* Generic 0xRay integration for any external application
|
|
21
|
-
*
|
|
22
|
-
* Provides:
|
|
23
|
-
* - Webhook receivers (GitHub, GitLab, Bitbucket, Stripe)
|
|
24
|
-
* - REST API triggers (manual trigger, retry, status)
|
|
25
|
-
* - Framework-agnostic (works with Express, Fastify, Koa, etc.)
|
|
26
|
-
*
|
|
27
|
-
* @example
|
|
28
|
-
* ```typescript
|
|
29
|
-
* import { createXrayIntegration } from '0xray/integration';
|
|
30
|
-
*
|
|
31
|
-
* const postProcessor = new PostProcessor(stateManager);
|
|
32
|
-
* const integration = createXrayIntegration(postProcessor);
|
|
33
|
-
*
|
|
34
|
-
* // Get Express app for mounting
|
|
35
|
-
* app.use('/webhooks', integration.getWebhookApp());
|
|
36
|
-
* app.use('/api/post-process', integration.getAPIApp());
|
|
37
|
-
*
|
|
38
|
-
* // Or get raw routers for Fastify/Koa
|
|
39
|
-
* const webhookRouter = integration.getWebhookRouter();
|
|
40
|
-
* const apiRouter = integration.getAPIRouter();
|
|
41
|
-
* ```
|
|
42
|
-
*/
|
|
43
|
-
export declare class XrayIntegration {
|
|
44
|
-
private postProcessor;
|
|
45
|
-
private webhookTrigger;
|
|
46
|
-
private apiTrigger;
|
|
47
|
-
constructor(postProcessor: PostProcessor);
|
|
48
|
-
/**
|
|
49
|
-
* Initialize all triggers with default configuration
|
|
50
|
-
*
|
|
51
|
-
* @param config - Optional configuration for triggers
|
|
52
|
-
*/
|
|
53
|
-
initialize(config?: {
|
|
54
|
-
webhook?: Partial<WebhookConfig>;
|
|
55
|
-
api?: Partial<APIConfig>;
|
|
56
|
-
}): Promise<void>;
|
|
57
|
-
/**
|
|
58
|
-
* Get webhook app for framework-specific mounting
|
|
59
|
-
*
|
|
60
|
-
* Returns an Express Application. For other frameworks,
|
|
61
|
-
* use getWebhookRouter() to get the router instance.
|
|
62
|
-
*
|
|
63
|
-
* @example
|
|
64
|
-
* ```typescript
|
|
65
|
-
* // Express
|
|
66
|
-
* app.use('/webhooks', integration.getWebhookApp());
|
|
67
|
-
*
|
|
68
|
-
* // Fastify
|
|
69
|
-
* await fastify.register(integration.getWebhookRouter(), { prefix: '/webhooks' });
|
|
70
|
-
*
|
|
71
|
-
* // Koa
|
|
72
|
-
* app.use(integration.getWebhookRouter().routes());
|
|
73
|
-
* ```
|
|
74
|
-
*/
|
|
75
|
-
getWebhookApp(): express.Application | null;
|
|
76
|
-
/**
|
|
77
|
-
* Get webhook router (raw Express router)
|
|
78
|
-
*
|
|
79
|
-
* Useful for frameworks that need the router instance directly
|
|
80
|
-
* rather than the full Express app.
|
|
81
|
-
*/
|
|
82
|
-
getWebhookRouter(): express.Router | null;
|
|
83
|
-
/**
|
|
84
|
-
* Get API trigger app for framework-specific mounting
|
|
85
|
-
*
|
|
86
|
-
* @example
|
|
87
|
-
* ```typescript
|
|
88
|
-
* // Express
|
|
89
|
-
* app.use('/api/post-process', integration.getAPIApp());
|
|
90
|
-
*
|
|
91
|
-
* // Fastify
|
|
92
|
-
* await fastify.register(integration.getAPIRouter(), { prefix: '/api/post-process' });
|
|
93
|
-
* ```
|
|
94
|
-
*/
|
|
95
|
-
getAPIApp(): express.Application | null;
|
|
96
|
-
/**
|
|
97
|
-
* Get API trigger router (raw Express router)
|
|
98
|
-
*
|
|
99
|
-
* Useful for frameworks that need the router instance directly.
|
|
100
|
-
*/
|
|
101
|
-
getAPIRouter(): express.Router | null;
|
|
102
|
-
/**
|
|
103
|
-
* Manually trigger PostProcessor via API
|
|
104
|
-
*
|
|
105
|
-
* Convenience method for programmatic triggering without
|
|
106
|
-
* going through the HTTP endpoint.
|
|
107
|
-
*
|
|
108
|
-
* @example
|
|
109
|
-
* ```typescript
|
|
110
|
-
* await integration.trigger({
|
|
111
|
-
* tool: 'test',
|
|
112
|
-
* operation: 'run',
|
|
113
|
-
* reason: 'Manual test trigger'
|
|
114
|
-
* });
|
|
115
|
-
* ```
|
|
116
|
-
*/
|
|
117
|
-
trigger(options: {
|
|
118
|
-
tool: string;
|
|
119
|
-
operation: string;
|
|
120
|
-
filePath?: string;
|
|
121
|
-
directory?: string;
|
|
122
|
-
reason?: string;
|
|
123
|
-
}): Promise<void>;
|
|
124
|
-
/**
|
|
125
|
-
* Shutdown all triggers
|
|
126
|
-
*/
|
|
127
|
-
shutdown(): Promise<void>;
|
|
128
|
-
}
|
|
129
|
-
/**
|
|
130
|
-
* Factory function for easy integration setup
|
|
131
|
-
*
|
|
132
|
-
* @example
|
|
133
|
-
* ```typescript
|
|
134
|
-
* import { createXrayIntegration } from '0xray/integration';
|
|
135
|
-
*
|
|
136
|
-
* // With default configuration
|
|
137
|
-
* const integration = createXrayIntegration(postProcessor);
|
|
138
|
-
* await integration.initialize();
|
|
139
|
-
*
|
|
140
|
-
* // With custom configuration
|
|
141
|
-
* const integration = createXrayIntegration(postProcessor);
|
|
142
|
-
* await integration.initialize({
|
|
143
|
-
* webhook: {
|
|
144
|
-
* provider: 'gitlab',
|
|
145
|
-
* secret: process.env.GITLAB_WEBHOOK_SECRET,
|
|
146
|
-
* events: ['push', 'merge_request'],
|
|
147
|
-
* path: '/webhooks/gitlab'
|
|
148
|
-
* },
|
|
149
|
-
* api: {
|
|
150
|
-
* path: '/api/stray-trigger',
|
|
151
|
-
* apiKey: process.env.API_KEY
|
|
152
|
-
* }
|
|
153
|
-
* });
|
|
154
|
-
* ```
|
|
155
|
-
*/
|
|
156
|
-
export declare function createXrayIntegration(postProcessor: PostProcessor): XrayIntegration;
|