opencode-swarm-plugin 0.38.0 → 0.39.1

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 (69) hide show
  1. package/.env +2 -0
  2. package/.hive/eval-results.json +26 -0
  3. package/.hive/issues.jsonl +11 -0
  4. package/.hive/memories.jsonl +23 -1
  5. package/.opencode/eval-history.jsonl +12 -0
  6. package/CHANGELOG.md +130 -0
  7. package/README.md +29 -12
  8. package/bin/swarm.test.ts +475 -0
  9. package/bin/swarm.ts +383 -0
  10. package/dist/compaction-hook.d.ts +1 -1
  11. package/dist/compaction-hook.d.ts.map +1 -1
  12. package/dist/compaction-prompt-scoring.d.ts +124 -0
  13. package/dist/compaction-prompt-scoring.d.ts.map +1 -0
  14. package/dist/eval-capture.d.ts +81 -1
  15. package/dist/eval-capture.d.ts.map +1 -1
  16. package/dist/eval-gates.d.ts +84 -0
  17. package/dist/eval-gates.d.ts.map +1 -0
  18. package/dist/eval-history.d.ts +117 -0
  19. package/dist/eval-history.d.ts.map +1 -0
  20. package/dist/eval-learning.d.ts +216 -0
  21. package/dist/eval-learning.d.ts.map +1 -0
  22. package/dist/index.d.ts +44 -0
  23. package/dist/index.d.ts.map +1 -1
  24. package/dist/index.js +370 -13
  25. package/dist/plugin.js +203 -13
  26. package/dist/post-compaction-tracker.d.ts +133 -0
  27. package/dist/post-compaction-tracker.d.ts.map +1 -0
  28. package/dist/swarm-orchestrate.d.ts +23 -0
  29. package/dist/swarm-orchestrate.d.ts.map +1 -1
  30. package/dist/swarm-prompts.d.ts +25 -1
  31. package/dist/swarm-prompts.d.ts.map +1 -1
  32. package/dist/swarm.d.ts +4 -0
  33. package/dist/swarm.d.ts.map +1 -1
  34. package/evals/README.md +589 -105
  35. package/evals/compaction-prompt.eval.ts +149 -0
  36. package/evals/coordinator-behavior.eval.ts +8 -8
  37. package/evals/fixtures/compaction-prompt-cases.ts +305 -0
  38. package/evals/lib/compaction-loader.test.ts +248 -0
  39. package/evals/lib/compaction-loader.ts +320 -0
  40. package/evals/lib/data-loader.test.ts +345 -0
  41. package/evals/lib/data-loader.ts +107 -6
  42. package/evals/scorers/compaction-prompt-scorers.ts +145 -0
  43. package/evals/scorers/compaction-scorers.ts +13 -13
  44. package/evals/scorers/coordinator-discipline.evalite-test.ts +3 -2
  45. package/evals/scorers/coordinator-discipline.ts +13 -13
  46. package/examples/plugin-wrapper-template.ts +117 -0
  47. package/package.json +7 -5
  48. package/scripts/migrate-unknown-sessions.ts +349 -0
  49. package/src/compaction-capture.integration.test.ts +257 -0
  50. package/src/compaction-hook.test.ts +42 -0
  51. package/src/compaction-hook.ts +81 -0
  52. package/src/compaction-prompt-scorers.test.ts +299 -0
  53. package/src/compaction-prompt-scoring.ts +298 -0
  54. package/src/eval-capture.test.ts +422 -0
  55. package/src/eval-capture.ts +94 -2
  56. package/src/eval-gates.test.ts +306 -0
  57. package/src/eval-gates.ts +218 -0
  58. package/src/eval-history.test.ts +508 -0
  59. package/src/eval-history.ts +214 -0
  60. package/src/eval-learning.test.ts +378 -0
  61. package/src/eval-learning.ts +360 -0
  62. package/src/index.ts +61 -1
  63. package/src/post-compaction-tracker.test.ts +251 -0
  64. package/src/post-compaction-tracker.ts +237 -0
  65. package/src/swarm-decompose.ts +2 -2
  66. package/src/swarm-orchestrate.ts +2 -2
  67. package/src/swarm-prompts.ts +2 -2
  68. package/src/swarm-review.ts +3 -3
  69. /package/evals/{evalite.config.ts → evalite.config.ts.bak} +0 -0
@@ -0,0 +1,306 @@
1
+ /**
2
+ * Tests for progressive eval gates
3
+ *
4
+ * TDD approach:
5
+ * RED: Tests written first, all failing
6
+ * GREEN: Minimal implementation to pass
7
+ * REFACTOR: Clean up while keeping tests green
8
+ */
9
+ import { afterEach, beforeEach, describe, expect, test } from "bun:test";
10
+ import * as fs from "node:fs";
11
+ import { checkGate } from "./eval-gates.js";
12
+ import { recordEvalRun } from "./eval-history.js";
13
+
14
+ const TEST_PROJECT = "/tmp/eval-gates-test";
15
+
16
+ beforeEach(() => {
17
+ // Clean slate for each test
18
+ if (fs.existsSync(TEST_PROJECT)) {
19
+ fs.rmSync(TEST_PROJECT, { recursive: true });
20
+ }
21
+ fs.mkdirSync(TEST_PROJECT, { recursive: true });
22
+ });
23
+
24
+ afterEach(() => {
25
+ // Cleanup
26
+ if (fs.existsSync(TEST_PROJECT)) {
27
+ fs.rmSync(TEST_PROJECT, { recursive: true });
28
+ }
29
+ });
30
+
31
+ /**
32
+ * Helper to create run history
33
+ */
34
+ function seedHistory(evalName: string, scores: number[]): void {
35
+ for (let i = 0; i < scores.length; i++) {
36
+ recordEvalRun(TEST_PROJECT, {
37
+ timestamp: new Date(Date.now() + i * 1000).toISOString(),
38
+ eval_name: evalName,
39
+ score: scores[i],
40
+ run_count: i + 1,
41
+ });
42
+ }
43
+ }
44
+
45
+ describe("checkGate - Bootstrap Phase (<10 runs)", () => {
46
+ test("always passes with 0 runs", () => {
47
+ const result = checkGate(TEST_PROJECT, "my-eval", 0.5);
48
+
49
+ expect(result.passed).toBe(true);
50
+ expect(result.phase).toBe("bootstrap");
51
+ expect(result.message).toContain("Bootstrap phase");
52
+ });
53
+
54
+ test("always passes with 9 runs, even with score drop", () => {
55
+ seedHistory("my-eval", [0.9, 0.88, 0.87, 0.86, 0.85, 0.84, 0.83, 0.82, 0.81]);
56
+
57
+ const result = checkGate(TEST_PROJECT, "my-eval", 0.5); // 50% drop
58
+
59
+ expect(result.passed).toBe(true);
60
+ expect(result.phase).toBe("bootstrap");
61
+ expect(result.message).toContain("Bootstrap phase");
62
+ });
63
+
64
+ test("provides run count in message", () => {
65
+ seedHistory("my-eval", [0.8, 0.8, 0.8]);
66
+
67
+ const result = checkGate(TEST_PROJECT, "my-eval", 0.75);
68
+
69
+ expect(result.message).toContain("3/10");
70
+ });
71
+ });
72
+
73
+ describe("checkGate - Stabilization Phase (10-50 runs)", () => {
74
+ test("exactly 10 runs enters stabilization", () => {
75
+ seedHistory("my-eval", Array(10).fill(0.85));
76
+
77
+ const result = checkGate(TEST_PROJECT, "my-eval", 0.84);
78
+
79
+ expect(result.phase).toBe("stabilization");
80
+ });
81
+
82
+ test("passes with <10% regression", () => {
83
+ seedHistory("my-eval", Array(15).fill(0.9));
84
+
85
+ const result = checkGate(TEST_PROJECT, "my-eval", 0.82); // 8.8% drop
86
+
87
+ expect(result.passed).toBe(true);
88
+ expect(result.phase).toBe("stabilization");
89
+ expect(result.message).toContain("acceptable");
90
+ });
91
+
92
+ test("WARNS on >10% regression but still passes", () => {
93
+ seedHistory("my-eval", Array(15).fill(0.9));
94
+
95
+ const result = checkGate(TEST_PROJECT, "my-eval", 0.8); // 11.1% drop
96
+
97
+ expect(result.passed).toBe(true); // Still passes in stabilization
98
+ expect(result.phase).toBe("stabilization");
99
+ expect(result.message).toContain("regression");
100
+ expect(result.message).toMatch(/10%|11%/); // Should mention threshold
101
+ });
102
+
103
+ test("edge case: exactly 10% regression", () => {
104
+ seedHistory("my-eval", Array(20).fill(0.9));
105
+
106
+ const result = checkGate(TEST_PROJECT, "my-eval", 0.81); // Exactly 10% drop
107
+
108
+ expect(result.passed).toBe(true);
109
+ expect(result.phase).toBe("stabilization");
110
+ });
111
+
112
+ test("passes with score improvement", () => {
113
+ seedHistory("my-eval", Array(25).fill(0.8));
114
+
115
+ const result = checkGate(TEST_PROJECT, "my-eval", 0.95);
116
+
117
+ expect(result.passed).toBe(true);
118
+ expect(result.message).toContain("acceptable");
119
+ });
120
+
121
+ test("exactly 50 runs still in stabilization", () => {
122
+ seedHistory("my-eval", Array(50).fill(0.85));
123
+
124
+ const result = checkGate(TEST_PROJECT, "my-eval", 0.84);
125
+
126
+ expect(result.phase).toBe("stabilization");
127
+ });
128
+ });
129
+
130
+ describe("checkGate - Production Phase (>50 runs + variance <0.1)", () => {
131
+ test("enters production with 51 stable runs", () => {
132
+ seedHistory("my-eval", Array(51).fill(0.85));
133
+
134
+ const result = checkGate(TEST_PROJECT, "my-eval", 0.84);
135
+
136
+ expect(result.phase).toBe("production");
137
+ });
138
+
139
+ test("FAILS on >5% regression in production", () => {
140
+ seedHistory("my-eval", Array(60).fill(0.9));
141
+
142
+ const result = checkGate(TEST_PROJECT, "my-eval", 0.84); // 6.7% drop
143
+
144
+ expect(result.passed).toBe(false);
145
+ expect(result.phase).toBe("production");
146
+ expect(result.message).toContain("FAIL");
147
+ expect(result.message).toMatch(/5%|6%/);
148
+ });
149
+
150
+ test("passes with <5% regression in production", () => {
151
+ seedHistory("my-eval", Array(60).fill(0.9));
152
+
153
+ const result = checkGate(TEST_PROJECT, "my-eval", 0.86); // 4.4% drop
154
+
155
+ expect(result.passed).toBe(true);
156
+ expect(result.phase).toBe("production");
157
+ expect(result.message).toContain("acceptable");
158
+ });
159
+
160
+ test("edge case: exactly 5% regression", () => {
161
+ seedHistory("my-eval", Array(60).fill(0.9));
162
+
163
+ const result = checkGate(TEST_PROJECT, "my-eval", 0.855); // Exactly 5% drop
164
+
165
+ expect(result.passed).toBe(true);
166
+ expect(result.phase).toBe("production");
167
+ });
168
+
169
+ test("stays in stabilization if variance too high (>0.1) despite >50 runs", () => {
170
+ // Need significant wild variance to push above 0.1
171
+ // From memory: 60 stable + 50 alternating wild = variance ~0.103
172
+ const stableRuns = Array(60).fill(0.85);
173
+ const wildRuns = Array(50)
174
+ .fill(0)
175
+ .map((_, i) => (i % 2 === 0 ? 0.1 : 0.9));
176
+ seedHistory("my-eval", [...stableRuns, ...wildRuns]);
177
+
178
+ const result = checkGate(TEST_PROJECT, "my-eval", 0.84);
179
+
180
+ expect(result.phase).toBe("stabilization");
181
+ expect(result.message).toContain("variance");
182
+ });
183
+
184
+ test("passes with score improvement in production", () => {
185
+ seedHistory("my-eval", Array(60).fill(0.8));
186
+
187
+ const result = checkGate(TEST_PROJECT, "my-eval", 0.95);
188
+
189
+ expect(result.passed).toBe(true);
190
+ expect(result.phase).toBe("production");
191
+ });
192
+ });
193
+
194
+ describe("checkGate - Baseline Calculation", () => {
195
+ test("uses mean of all historical scores as baseline", () => {
196
+ // Need 10+ runs to exit bootstrap and see baseline in message
197
+ seedHistory("my-eval", [0.8, 0.85, 0.9, 0.95, 1.0, 0.9, 0.9, 0.9, 0.9, 0.9]); // mean = 0.9
198
+
199
+ const result = checkGate(TEST_PROJECT, "my-eval", 0.88);
200
+
201
+ // 0.88 is ~2.2% drop from 0.9 mean (within stabilization tolerance)
202
+ expect(result.passed).toBe(true);
203
+ expect(result.message).toContain("0.90"); // Should show baseline
204
+ });
205
+
206
+ test("handles different eval names independently", () => {
207
+ seedHistory("eval-a", Array(15).fill(0.9));
208
+ seedHistory("eval-b", Array(15).fill(0.5));
209
+
210
+ const resultA = checkGate(TEST_PROJECT, "eval-a", 0.88);
211
+ const resultB = checkGate(TEST_PROJECT, "eval-b", 0.48);
212
+
213
+ expect(resultA.passed).toBe(true);
214
+ expect(resultB.passed).toBe(true);
215
+ });
216
+ });
217
+
218
+ describe("checkGate - Edge Cases", () => {
219
+ test("handles score of 0", () => {
220
+ seedHistory("my-eval", Array(15).fill(0.8));
221
+
222
+ const result = checkGate(TEST_PROJECT, "my-eval", 0);
223
+
224
+ expect(result.passed).toBe(true); // Still passes in stabilization with warning
225
+ expect(result.message).toContain("regression");
226
+ });
227
+
228
+ test("handles perfect score of 1.0", () => {
229
+ seedHistory("my-eval", Array(15).fill(0.9));
230
+
231
+ const result = checkGate(TEST_PROJECT, "my-eval", 1.0);
232
+
233
+ expect(result.passed).toBe(true);
234
+ });
235
+
236
+ test("handles no history file (first run)", () => {
237
+ // No seedHistory call - empty project
238
+
239
+ const result = checkGate(TEST_PROJECT, "my-eval", 0.75);
240
+
241
+ expect(result.passed).toBe(true);
242
+ expect(result.phase).toBe("bootstrap");
243
+ });
244
+
245
+ test("handles baseline of 0 (avoid division by zero)", () => {
246
+ seedHistory("my-eval", Array(15).fill(0));
247
+
248
+ const result = checkGate(TEST_PROJECT, "my-eval", 0.5);
249
+
250
+ expect(result.passed).toBe(true);
251
+ expect(result.message).not.toContain("NaN");
252
+ expect(result.message).not.toContain("Infinity");
253
+ });
254
+ });
255
+
256
+ describe("checkGate - Configurable Thresholds", () => {
257
+ test("accepts custom stabilization threshold", () => {
258
+ seedHistory("my-eval", Array(15).fill(0.9));
259
+
260
+ // 15% regression with custom 20% threshold - should pass
261
+ const result = checkGate(TEST_PROJECT, "my-eval", 0.765, {
262
+ stabilizationThreshold: 0.2, // 20% instead of default 10%
263
+ });
264
+
265
+ expect(result.passed).toBe(true);
266
+ expect(result.phase).toBe("stabilization");
267
+ expect(result.message).toContain("acceptable");
268
+ });
269
+
270
+ test("accepts custom production threshold", () => {
271
+ seedHistory("my-eval", Array(60).fill(0.9));
272
+
273
+ // 7% regression with custom 10% threshold - should pass
274
+ const result = checkGate(TEST_PROJECT, "my-eval", 0.837, {
275
+ productionThreshold: 0.1, // 10% instead of default 5%
276
+ });
277
+
278
+ expect(result.passed).toBe(true);
279
+ expect(result.phase).toBe("production");
280
+ });
281
+
282
+ test("custom threshold makes test fail when exceeded", () => {
283
+ seedHistory("my-eval", Array(60).fill(0.9));
284
+
285
+ // 7% regression with custom 3% threshold - should fail
286
+ const result = checkGate(TEST_PROJECT, "my-eval", 0.837, {
287
+ productionThreshold: 0.03, // 3% instead of default 5%
288
+ });
289
+
290
+ expect(result.passed).toBe(false);
291
+ expect(result.phase).toBe("production");
292
+ expect(result.message).toContain("FAIL");
293
+ });
294
+
295
+ test("partial config uses defaults for unspecified thresholds", () => {
296
+ seedHistory("my-eval", Array(15).fill(0.9));
297
+
298
+ // Only override production threshold
299
+ const result = checkGate(TEST_PROJECT, "my-eval", 0.88, {
300
+ productionThreshold: 0.01,
301
+ // stabilizationThreshold not specified - uses default 0.1
302
+ });
303
+
304
+ expect(result.passed).toBe(true); // 2.2% regression < 10% stabilization default
305
+ });
306
+ });
@@ -0,0 +1,218 @@
1
+ /**
2
+ * Progressive Eval Gates
3
+ *
4
+ * Enforces quality gates based on eval history and current phase:
5
+ * - Bootstrap (<10 runs): Always pass, collect data
6
+ * - Stabilization (10-50 runs): Pass but warn on >10% regression
7
+ * - Production (>50 runs + variance <0.1): Fail on >5% regression
8
+ *
9
+ * @module eval-gates
10
+ */
11
+ import { calculateVariance, getPhase, getScoreHistory } from "./eval-history.js";
12
+
13
+ /**
14
+ * Result from a gate check
15
+ */
16
+ export interface GateResult {
17
+ /** Whether the gate passed */
18
+ passed: boolean;
19
+ /** Current phase */
20
+ phase: "bootstrap" | "stabilization" | "production";
21
+ /** Human-readable message */
22
+ message: string;
23
+ /** Baseline score (mean of history) */
24
+ baseline?: number;
25
+ /** Current score */
26
+ currentScore: number;
27
+ /** Regression percentage (negative = improvement) */
28
+ regressionPercent?: number;
29
+ }
30
+
31
+ /**
32
+ * Configuration for gate thresholds
33
+ */
34
+ export interface GateConfig {
35
+ /** Regression threshold for stabilization phase (default: 0.1 = 10%) */
36
+ stabilizationThreshold?: number;
37
+ /** Regression threshold for production phase (default: 0.05 = 5%) */
38
+ productionThreshold?: number;
39
+ }
40
+
41
+ /**
42
+ * Default regression thresholds by phase
43
+ */
44
+ export const DEFAULT_THRESHOLDS = {
45
+ stabilization: 0.1, // 10% regression warning
46
+ production: 0.05, // 5% regression failure
47
+ } as const;
48
+
49
+ /**
50
+ * Calculate baseline score (mean of all historical scores)
51
+ */
52
+ function calculateBaseline(history: ReturnType<typeof getScoreHistory>, currentScore: number): number {
53
+ if (history.length === 0) {
54
+ return currentScore;
55
+ }
56
+ return history.reduce((sum, run) => sum + run.score, 0) / history.length;
57
+ }
58
+
59
+ /**
60
+ * Calculate regression percentage from baseline
61
+ *
62
+ * Returns 0 if baseline is 0 to avoid division by zero.
63
+ * Positive = regression (score dropped), negative = improvement
64
+ */
65
+ function calculateRegression(baseline: number, currentScore: number): number {
66
+ if (baseline === 0) {
67
+ return 0;
68
+ }
69
+ return (baseline - currentScore) / baseline;
70
+ }
71
+
72
+ /**
73
+ * Format regression message with scores
74
+ */
75
+ function formatRegressionMessage(
76
+ regressionPercent: number,
77
+ baseline: number,
78
+ currentScore: number,
79
+ ): string {
80
+ return `${(regressionPercent * 100).toFixed(1)}% regression (baseline: ${baseline.toFixed(2)}, current: ${currentScore.toFixed(2)})`;
81
+ }
82
+
83
+ /**
84
+ * Check if the current eval score passes the quality gate
85
+ *
86
+ * Progressive gates adapt based on data maturity:
87
+ * - **Bootstrap (<10 runs)**: Always pass, focus on collecting baseline data
88
+ * - **Stabilization (10-50 runs)**: Warn on >10% regression (default), but pass
89
+ * - **Production (>50 runs + variance <0.1)**: Fail on >5% regression (default)
90
+ *
91
+ * **Baseline calculation**: Mean of all historical scores for this eval (not just last run).
92
+ *
93
+ * **Regression formula**: `(baseline - current) / baseline`
94
+ * - Positive = regression (score dropped)
95
+ * - Negative = improvement
96
+ * - Returns 0 if baseline is 0 (avoids division by zero)
97
+ *
98
+ * **Variance threshold (0.1)**: High variance keeps eval in stabilization phase even with >50 runs.
99
+ * This prevents premature production gates when scores are still unstable.
100
+ *
101
+ * **CI Integration**: Production gates can fail PRs. Use `swarm eval status` to check phase before merging.
102
+ *
103
+ * @param projectPath - Absolute path to project root (contains `.opencode/eval-history.jsonl`)
104
+ * @param evalName - Name of the eval (e.g., "swarm-decomposition", "coordinator-behavior")
105
+ * @param currentScore - Current score to check (typically 0-1 range)
106
+ * @param config - Optional threshold configuration (defaults: stabilization=0.1, production=0.05)
107
+ * @returns Gate check result with pass/fail, phase, baseline, regression details
108
+ *
109
+ * @example
110
+ * ```typescript
111
+ * import { checkGate } from "./eval-gates.js";
112
+ *
113
+ * const result = checkGate("/path/to/project", "swarm-decomposition", 0.89);
114
+ *
115
+ * if (!result.passed) {
116
+ * console.error(`❌ Gate FAILED: ${result.message}`);
117
+ * process.exit(1); // Fail CI
118
+ * }
119
+ *
120
+ * console.log(`✅ ${result.phase} phase: ${result.message}`);
121
+ * ```
122
+ *
123
+ * @example
124
+ * ```typescript
125
+ * // Custom thresholds for sensitive eval
126
+ * const result = checkGate("/path", "critical-eval", 0.92, {
127
+ * stabilizationThreshold: 0.05, // 5% threshold in stabilization
128
+ * productionThreshold: 0.02, // 2% threshold in production
129
+ * });
130
+ * ```
131
+ */
132
+ export function checkGate(
133
+ projectPath: string,
134
+ evalName: string,
135
+ currentScore: number,
136
+ config?: GateConfig,
137
+ ): GateResult {
138
+ const thresholds = {
139
+ stabilization: config?.stabilizationThreshold ?? DEFAULT_THRESHOLDS.stabilization,
140
+ production: config?.productionThreshold ?? DEFAULT_THRESHOLDS.production,
141
+ };
142
+
143
+ const phase = getPhase(projectPath, evalName);
144
+ const history = getScoreHistory(projectPath, evalName);
145
+
146
+ // Bootstrap phase - always pass
147
+ if (phase === "bootstrap") {
148
+ return {
149
+ passed: true,
150
+ phase: "bootstrap",
151
+ message: `Bootstrap phase (${history.length}/10 runs) - collecting data`,
152
+ currentScore,
153
+ };
154
+ }
155
+
156
+ // Calculate baseline and regression
157
+ const baseline = calculateBaseline(history, currentScore);
158
+ const regressionPercent = calculateRegression(baseline, currentScore);
159
+ const regressionMsg = formatRegressionMessage(regressionPercent, baseline, currentScore);
160
+
161
+ // Stabilization phase - warn on regression but pass
162
+ if (phase === "stabilization") {
163
+ if (regressionPercent > thresholds.stabilization) {
164
+ return {
165
+ passed: true,
166
+ phase: "stabilization",
167
+ message: `Stabilization phase: ${regressionMsg} - exceeds ${(thresholds.stabilization * 100).toFixed(0)}% threshold but still passing`,
168
+ baseline,
169
+ currentScore,
170
+ regressionPercent,
171
+ };
172
+ }
173
+
174
+ // Check if we have high variance (>50 runs but can't enter production)
175
+ if (history.length > 50) {
176
+ const scores = history.map((run) => run.score);
177
+ const variance = calculateVariance(scores);
178
+ return {
179
+ passed: true,
180
+ phase: "stabilization",
181
+ message: `Stabilization phase: ${regressionMsg} - acceptable. High variance (${variance.toFixed(3)}) prevents production phase.`,
182
+ baseline,
183
+ currentScore,
184
+ regressionPercent,
185
+ };
186
+ }
187
+
188
+ return {
189
+ passed: true,
190
+ phase: "stabilization",
191
+ message: `Stabilization phase: ${regressionMsg} - acceptable`,
192
+ baseline,
193
+ currentScore,
194
+ regressionPercent,
195
+ };
196
+ }
197
+
198
+ // Production phase - fail on regression exceeding threshold
199
+ if (regressionPercent > thresholds.production) {
200
+ return {
201
+ passed: false,
202
+ phase: "production",
203
+ message: `Production phase FAIL: ${regressionMsg} - exceeds ${(thresholds.production * 100).toFixed(0)}% threshold`,
204
+ baseline,
205
+ currentScore,
206
+ regressionPercent,
207
+ };
208
+ }
209
+
210
+ return {
211
+ passed: true,
212
+ phase: "production",
213
+ message: `Production phase: ${regressionMsg} - acceptable`,
214
+ baseline,
215
+ currentScore,
216
+ regressionPercent,
217
+ };
218
+ }