gsd-pi 2.63.0-dev.d04bbc5 → 2.64.0-dev.9c14bd0

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 (65) hide show
  1. package/dist/resources/extensions/gsd/auto-dashboard.js +5 -5
  2. package/dist/resources/extensions/gsd/auto-post-unit.js +98 -1
  3. package/dist/resources/extensions/gsd/auto-verification.js +138 -1
  4. package/dist/resources/extensions/gsd/auto.js +5 -0
  5. package/dist/resources/extensions/gsd/post-execution-checks.js +407 -0
  6. package/dist/resources/extensions/gsd/pre-execution-checks.js +464 -0
  7. package/dist/resources/extensions/gsd/preferences-types.js +4 -0
  8. package/dist/resources/extensions/gsd/preferences-validation.js +33 -0
  9. package/dist/resources/extensions/gsd/preferences.js +4 -0
  10. package/dist/resources/extensions/gsd/verification-evidence.js +18 -0
  11. package/dist/web/standalone/.next/BUILD_ID +1 -1
  12. package/dist/web/standalone/.next/app-path-routes-manifest.json +15 -15
  13. package/dist/web/standalone/.next/build-manifest.json +2 -2
  14. package/dist/web/standalone/.next/prerender-manifest.json +3 -3
  15. package/dist/web/standalone/.next/required-server-files.json +1 -1
  16. package/dist/web/standalone/.next/server/app/_global-error.html +2 -2
  17. package/dist/web/standalone/.next/server/app/_global-error.rsc +1 -1
  18. package/dist/web/standalone/.next/server/app/_global-error.segments/_full.segment.rsc +1 -1
  19. package/dist/web/standalone/.next/server/app/_global-error.segments/_global-error/__PAGE__.segment.rsc +1 -1
  20. package/dist/web/standalone/.next/server/app/_global-error.segments/_global-error.segment.rsc +1 -1
  21. package/dist/web/standalone/.next/server/app/_global-error.segments/_head.segment.rsc +1 -1
  22. package/dist/web/standalone/.next/server/app/_global-error.segments/_index.segment.rsc +1 -1
  23. package/dist/web/standalone/.next/server/app/_global-error.segments/_tree.segment.rsc +1 -1
  24. package/dist/web/standalone/.next/server/app/_not-found.html +1 -1
  25. package/dist/web/standalone/.next/server/app/_not-found.rsc +1 -1
  26. package/dist/web/standalone/.next/server/app/_not-found.segments/_full.segment.rsc +1 -1
  27. package/dist/web/standalone/.next/server/app/_not-found.segments/_head.segment.rsc +1 -1
  28. package/dist/web/standalone/.next/server/app/_not-found.segments/_index.segment.rsc +1 -1
  29. package/dist/web/standalone/.next/server/app/_not-found.segments/_not-found/__PAGE__.segment.rsc +1 -1
  30. package/dist/web/standalone/.next/server/app/_not-found.segments/_not-found.segment.rsc +1 -1
  31. package/dist/web/standalone/.next/server/app/_not-found.segments/_tree.segment.rsc +1 -1
  32. package/dist/web/standalone/.next/server/app/index.html +1 -1
  33. package/dist/web/standalone/.next/server/app/index.rsc +1 -1
  34. package/dist/web/standalone/.next/server/app/index.segments/__PAGE__.segment.rsc +1 -1
  35. package/dist/web/standalone/.next/server/app/index.segments/_full.segment.rsc +1 -1
  36. package/dist/web/standalone/.next/server/app/index.segments/_head.segment.rsc +1 -1
  37. package/dist/web/standalone/.next/server/app/index.segments/_index.segment.rsc +1 -1
  38. package/dist/web/standalone/.next/server/app/index.segments/_tree.segment.rsc +1 -1
  39. package/dist/web/standalone/.next/server/app-paths-manifest.json +15 -15
  40. package/dist/web/standalone/.next/server/pages/404.html +1 -1
  41. package/dist/web/standalone/.next/server/pages/500.html +2 -2
  42. package/dist/web/standalone/.next/server/server-reference-manifest.json +1 -1
  43. package/dist/web/standalone/server.js +1 -1
  44. package/package.json +1 -1
  45. package/packages/pi-coding-agent/package.json +1 -1
  46. package/pkg/package.json +1 -1
  47. package/src/resources/extensions/gsd/auto-dashboard.ts +5 -4
  48. package/src/resources/extensions/gsd/auto-post-unit.ts +122 -0
  49. package/src/resources/extensions/gsd/auto-verification.ts +190 -2
  50. package/src/resources/extensions/gsd/auto.ts +4 -0
  51. package/src/resources/extensions/gsd/post-execution-checks.ts +539 -0
  52. package/src/resources/extensions/gsd/pre-execution-checks.ts +573 -0
  53. package/src/resources/extensions/gsd/preferences-types.ts +28 -0
  54. package/src/resources/extensions/gsd/preferences-validation.ts +33 -0
  55. package/src/resources/extensions/gsd/preferences.ts +4 -0
  56. package/src/resources/extensions/gsd/tests/auto-start-time-persistence.test.ts +50 -0
  57. package/src/resources/extensions/gsd/tests/enhanced-verification-integration.test.ts +526 -0
  58. package/src/resources/extensions/gsd/tests/post-exec-retry-bypass.test.ts +312 -0
  59. package/src/resources/extensions/gsd/tests/post-execution-checks.test.ts +813 -0
  60. package/src/resources/extensions/gsd/tests/pre-execution-checks.test.ts +999 -0
  61. package/src/resources/extensions/gsd/tests/pre-execution-fail-closed.test.ts +266 -0
  62. package/src/resources/extensions/gsd/tests/pre-execution-pause-wiring.test.ts +457 -0
  63. package/src/resources/extensions/gsd/verification-evidence.ts +68 -0
  64. /package/dist/web/standalone/.next/static/{vIq9fmvRUaFOpguoX5j4W → SoxM61WC_ia7R2gk4VMpJ}/_buildManifest.js +0 -0
  65. /package/dist/web/standalone/.next/static/{vIq9fmvRUaFOpguoX5j4W → SoxM61WC_ia7R2gk4VMpJ}/_ssgManifest.js +0 -0
@@ -0,0 +1,50 @@
1
+ // GSD2 — Verify autoStartTime is persisted in paused-session.json and restored on resume
2
+ // Copyright (c) 2026 Jeremy McSpadden <jeremy@fluxlabs.net>
3
+
4
+ /**
5
+ * auto-start-time-persistence.test.ts — Ensures autoStartTime survives
6
+ * cross-session resume via paused-session.json (#3585).
7
+ *
8
+ * Source-code regression guards: verify auto.ts saves and restores
9
+ * autoStartTime so the elapsed timer doesn't vanish after /exit + resume.
10
+ */
11
+
12
+ import test from "node:test";
13
+ import assert from "node:assert/strict";
14
+ import { readFileSync } from "node:fs";
15
+ import { join, dirname } from "node:path";
16
+ import { fileURLToPath } from "node:url";
17
+
18
+ const __dirname = dirname(fileURLToPath(import.meta.url));
19
+ const AUTO_TS_PATH = join(__dirname, "..", "auto.ts");
20
+
21
+ const source = readFileSync(AUTO_TS_PATH, "utf-8");
22
+
23
+ test("pauseAuto persists autoStartTime in paused-session.json (#3585)", () => {
24
+ assert.ok(
25
+ source.includes("autoStartTime: s.autoStartTime"),
26
+ "pausedMeta must include autoStartTime so the timer survives /exit",
27
+ );
28
+ });
29
+
30
+ test("cross-session resume restores autoStartTime from paused-session.json (#3585)", () => {
31
+ const matches = source.match(/s\.autoStartTime\s*=\s*meta\.autoStartTime/g);
32
+ assert.ok(
33
+ matches && matches.length >= 2,
34
+ "both resume paths (custom workflow + milestone) must restore autoStartTime from meta",
35
+ );
36
+ });
37
+
38
+ test("resume path falls back to Date.now() when autoStartTime is missing (#3585)", () => {
39
+ assert.ok(
40
+ source.includes("meta.autoStartTime || Date.now()"),
41
+ "restore should fall back to Date.now() for old paused-session files without autoStartTime",
42
+ );
43
+ });
44
+
45
+ test("resume path guards against zero autoStartTime (#3585)", () => {
46
+ assert.ok(
47
+ source.includes("if (!s.autoStartTime || s.autoStartTime <= 0) s.autoStartTime = Date.now()"),
48
+ "resume path must set autoStartTime to Date.now() if still zero after restore",
49
+ );
50
+ });
@@ -0,0 +1,526 @@
1
+ /**
2
+ * enhanced-verification-integration.test.ts — Integration tests for enhanced verification.
3
+ *
4
+ * Exercises all 7 enhanced verification checks against GSD-2's actual source files.
5
+ * This proves:
6
+ * - R012: No false positives on production code
7
+ * - R013: Speed targets met (<2000ms pre-execution, <1000ms post-execution per task)
8
+ *
9
+ * The test constructs realistic TaskRow fixtures that reference real GSD source files,
10
+ * then runs both pre-execution and post-execution checks against them.
11
+ */
12
+
13
+ import { describe, test } from "node:test";
14
+ import assert from "node:assert/strict";
15
+ import { existsSync } from "node:fs";
16
+ import { join, dirname } from "node:path";
17
+ import { fileURLToPath } from "node:url";
18
+
19
+ import {
20
+ runPreExecutionChecks,
21
+ type PreExecutionResult,
22
+ } from "../pre-execution-checks.ts";
23
+ import {
24
+ runPostExecutionChecks,
25
+ type PostExecutionResult,
26
+ } from "../post-execution-checks.ts";
27
+ import type { TaskRow } from "../gsd-db.ts";
28
+
29
+ // ─── Constants ───────────────────────────────────────────────────────────────
30
+
31
+ const __filename = fileURLToPath(import.meta.url);
32
+ const __dirname = dirname(__filename);
33
+
34
+ // Path to the GSD extension source directory (relative to test file)
35
+ const GSD_SRC_DIR = join(__dirname, "..");
36
+
37
+ // Speed targets from R013
38
+ const PRE_EXECUTION_TIMEOUT_MS = 2000;
39
+ const POST_EXECUTION_TIMEOUT_MS = 1000;
40
+
41
+ // ─── Test Fixtures ───────────────────────────────────────────────────────────
42
+
43
+ /**
44
+ * Create a minimal TaskRow for testing.
45
+ */
46
+ function createTask(overrides: Partial<TaskRow> = {}): TaskRow {
47
+ return {
48
+ milestone_id: "M001",
49
+ slice_id: "S01",
50
+ id: overrides.id ?? "T01",
51
+ title: overrides.title ?? "Test Task",
52
+ status: overrides.status ?? "pending",
53
+ one_liner: "",
54
+ narrative: "",
55
+ verification_result: "",
56
+ duration: "",
57
+ completed_at: overrides.status === "complete" ? new Date().toISOString() : null,
58
+ blocker_discovered: false,
59
+ deviations: "",
60
+ known_issues: "",
61
+ key_files: overrides.key_files ?? [],
62
+ key_decisions: [],
63
+ full_summary_md: "",
64
+ description: overrides.description ?? "",
65
+ estimate: "",
66
+ files: overrides.files ?? [],
67
+ verify: "",
68
+ inputs: overrides.inputs ?? [],
69
+ expected_output: overrides.expected_output ?? [],
70
+ observability_impact: "",
71
+ full_plan_md: "",
72
+ sequence: overrides.sequence ?? 0,
73
+ ...overrides,
74
+ };
75
+ }
76
+
77
+ // ─── Real GSD Source Files for Testing ───────────────────────────────────────
78
+
79
+ // These are actual GSD extension source files that exist in the codebase
80
+ const REAL_GSD_FILES = [
81
+ "gsd-db.ts",
82
+ "auto-verification.ts",
83
+ "pre-execution-checks.ts",
84
+ "post-execution-checks.ts",
85
+ "state.ts",
86
+ "errors.ts",
87
+ "types.ts",
88
+ "cache.ts",
89
+ "atomic-write.ts",
90
+ ];
91
+
92
+ // Verify the test fixture files actually exist
93
+ function verifyTestFixturesExist(): void {
94
+ for (const file of REAL_GSD_FILES) {
95
+ const fullPath = join(GSD_SRC_DIR, file);
96
+ if (!existsSync(fullPath)) {
97
+ throw new Error(`Test fixture file does not exist: ${fullPath}`);
98
+ }
99
+ }
100
+ }
101
+
102
+ // ─── Integration Tests ───────────────────────────────────────────────────────
103
+
104
+ describe("Enhanced Verification Integration Tests", () => {
105
+ // Verify fixtures before running tests
106
+ test("test fixture files exist", () => {
107
+ verifyTestFixturesExist();
108
+ });
109
+
110
+ describe("Pre-Execution Checks on Real GSD Code", () => {
111
+ test("runs pre-execution checks on realistic tasks referencing real files", async () => {
112
+ // Simulate tasks that reference real GSD source files
113
+ const tasks: TaskRow[] = [
114
+ createTask({
115
+ id: "T01",
116
+ sequence: 0,
117
+ title: "Add validation to gsd-db",
118
+ description: `
119
+ ## Steps
120
+ 1. Update src/resources/extensions/gsd/gsd-db.ts to add validation
121
+ 2. Read from src/resources/extensions/gsd/types.ts for type definitions
122
+ 3. Update src/resources/extensions/gsd/errors.ts with new error types
123
+ 4. Run tests to verify changes
124
+ `.trim(),
125
+ files: REAL_GSD_FILES.slice(0, 4).map((f) => join(GSD_SRC_DIR, f)),
126
+ inputs: [
127
+ join(GSD_SRC_DIR, "types.ts"),
128
+ join(GSD_SRC_DIR, "errors.ts"),
129
+ ],
130
+ expected_output: [
131
+ join(GSD_SRC_DIR, "gsd-db.ts"),
132
+ ],
133
+ }),
134
+ ];
135
+
136
+ const start = performance.now();
137
+ const result = await runPreExecutionChecks(tasks, GSD_SRC_DIR);
138
+ const duration = performance.now() - start;
139
+
140
+ // R012: No blocking failures (false positives) on production code
141
+ const blockingFailures = result.checks.filter((c) => !c.passed && c.blocking);
142
+ assert.equal(
143
+ blockingFailures.length,
144
+ 0,
145
+ `Expected zero blocking failures, got: ${JSON.stringify(blockingFailures, null, 2)}`
146
+ );
147
+
148
+ // Overall status should not be fail
149
+ assert.notEqual(result.status, "fail", "Pre-execution checks should not fail on real GSD code");
150
+
151
+ // R013: Speed target met
152
+ assert.ok(
153
+ duration < PRE_EXECUTION_TIMEOUT_MS,
154
+ `Pre-execution checks took ${duration.toFixed(0)}ms, expected <${PRE_EXECUTION_TIMEOUT_MS}ms`
155
+ );
156
+ });
157
+
158
+ test("handles task with code block references to real packages", async () => {
159
+ // Task description with realistic code blocks using actual Node.js built-ins
160
+ const tasks: TaskRow[] = [
161
+ createTask({
162
+ id: "T01",
163
+ sequence: 0,
164
+ title: "Implement file watcher",
165
+ description: `
166
+ ## Implementation
167
+
168
+ \`\`\`typescript
169
+ import { readFileSync, writeFileSync } from "node:fs";
170
+ import { join, dirname } from "node:path";
171
+ import { existsSync } from "node:fs";
172
+
173
+ // Use existing GSD types
174
+ import type { TaskRow } from "./gsd-db.ts";
175
+ \`\`\`
176
+
177
+ Update the file watcher to use these imports.
178
+ `.trim(),
179
+ files: [join(GSD_SRC_DIR, "auto-verification.ts")],
180
+ }),
181
+ ];
182
+
183
+ const start = performance.now();
184
+ const result = await runPreExecutionChecks(tasks, GSD_SRC_DIR);
185
+ const duration = performance.now() - start;
186
+
187
+ // No blocking failures
188
+ const blockingFailures = result.checks.filter((c) => !c.passed && c.blocking);
189
+ assert.equal(
190
+ blockingFailures.length,
191
+ 0,
192
+ `Unexpected blocking failures: ${JSON.stringify(blockingFailures, null, 2)}`
193
+ );
194
+
195
+ // Speed target met
196
+ assert.ok(
197
+ duration < PRE_EXECUTION_TIMEOUT_MS,
198
+ `Pre-execution checks took ${duration.toFixed(0)}ms, expected <${PRE_EXECUTION_TIMEOUT_MS}ms`
199
+ );
200
+ });
201
+
202
+ test("handles multi-task sequence with file dependencies", async () => {
203
+ // Simulate a realistic task sequence where T02 depends on T01's output
204
+ const tasks: TaskRow[] = [
205
+ createTask({
206
+ id: "T01",
207
+ sequence: 0,
208
+ title: "Create types file",
209
+ status: "complete",
210
+ expected_output: [join(GSD_SRC_DIR, "types.ts")],
211
+ }),
212
+ createTask({
213
+ id: "T02",
214
+ sequence: 1,
215
+ title: "Use types in implementation",
216
+ description: `
217
+ Read the types from src/resources/extensions/gsd/types.ts and use them.
218
+ `.trim(),
219
+ inputs: [join(GSD_SRC_DIR, "types.ts")],
220
+ files: [join(GSD_SRC_DIR, "gsd-db.ts")],
221
+ }),
222
+ ];
223
+
224
+ const start = performance.now();
225
+ const result = await runPreExecutionChecks(tasks, GSD_SRC_DIR);
226
+ const duration = performance.now() - start;
227
+
228
+ // No blocking failures
229
+ const blockingFailures = result.checks.filter((c) => !c.passed && c.blocking);
230
+ assert.equal(
231
+ blockingFailures.length,
232
+ 0,
233
+ `Unexpected blocking failures: ${JSON.stringify(blockingFailures, null, 2)}`
234
+ );
235
+
236
+ // Speed target met
237
+ assert.ok(
238
+ duration < PRE_EXECUTION_TIMEOUT_MS,
239
+ `Pre-execution checks took ${duration.toFixed(0)}ms, expected <${PRE_EXECUTION_TIMEOUT_MS}ms`
240
+ );
241
+ });
242
+ });
243
+
244
+ describe("Post-Execution Checks on Real GSD Code", () => {
245
+ test("runs post-execution checks on real GSD source files", () => {
246
+ // Simulate a completed task that modified real files
247
+ const completedTask = createTask({
248
+ id: "T01",
249
+ title: "Update gsd-db validation",
250
+ status: "complete",
251
+ key_files: [
252
+ join(GSD_SRC_DIR, "gsd-db.ts"),
253
+ join(GSD_SRC_DIR, "types.ts"),
254
+ ],
255
+ });
256
+
257
+ const start = performance.now();
258
+ const result = runPostExecutionChecks(completedTask, [], GSD_SRC_DIR);
259
+ const duration = performance.now() - start;
260
+
261
+ // R012: No blocking failures (false positives) on production code
262
+ const blockingFailures = result.checks.filter((c) => !c.passed && c.blocking);
263
+ assert.equal(
264
+ blockingFailures.length,
265
+ 0,
266
+ `Expected zero blocking failures, got: ${JSON.stringify(blockingFailures, null, 2)}`
267
+ );
268
+
269
+ // Overall status should not be fail
270
+ assert.notEqual(result.status, "fail", "Post-execution checks should not fail on real GSD code");
271
+
272
+ // R013: Speed target met
273
+ assert.ok(
274
+ duration < POST_EXECUTION_TIMEOUT_MS,
275
+ `Post-execution checks took ${duration.toFixed(0)}ms, expected <${POST_EXECUTION_TIMEOUT_MS}ms`
276
+ );
277
+ });
278
+
279
+ test("analyzes imports in real TypeScript files", () => {
280
+ // Use auto-verification.ts which imports from multiple other GSD files
281
+ const completedTask = createTask({
282
+ id: "T02",
283
+ title: "Verify auto-verification imports",
284
+ status: "complete",
285
+ key_files: [join(GSD_SRC_DIR, "auto-verification.ts")],
286
+ });
287
+
288
+ const start = performance.now();
289
+ const result = runPostExecutionChecks(completedTask, [], GSD_SRC_DIR);
290
+ const duration = performance.now() - start;
291
+
292
+ // No blocking failures
293
+ const blockingFailures = result.checks.filter((c) => !c.passed && c.blocking);
294
+ assert.equal(
295
+ blockingFailures.length,
296
+ 0,
297
+ `Unexpected blocking failures: ${JSON.stringify(blockingFailures, null, 2)}`
298
+ );
299
+
300
+ // Speed target met
301
+ assert.ok(
302
+ duration < POST_EXECUTION_TIMEOUT_MS,
303
+ `Post-execution checks took ${duration.toFixed(0)}ms, expected <${POST_EXECUTION_TIMEOUT_MS}ms`
304
+ );
305
+ });
306
+
307
+ test("handles multi-file task with cross-file dependencies", () => {
308
+ // Task that touched multiple related files
309
+ const completedTask = createTask({
310
+ id: "T03",
311
+ title: "Refactor state management",
312
+ status: "complete",
313
+ key_files: [
314
+ join(GSD_SRC_DIR, "state.ts"),
315
+ join(GSD_SRC_DIR, "gsd-db.ts"),
316
+ join(GSD_SRC_DIR, "cache.ts"),
317
+ ],
318
+ });
319
+
320
+ const start = performance.now();
321
+ const result = runPostExecutionChecks(completedTask, [], GSD_SRC_DIR);
322
+ const duration = performance.now() - start;
323
+
324
+ // No blocking failures
325
+ const blockingFailures = result.checks.filter((c) => !c.passed && c.blocking);
326
+ assert.equal(
327
+ blockingFailures.length,
328
+ 0,
329
+ `Unexpected blocking failures: ${JSON.stringify(blockingFailures, null, 2)}`
330
+ );
331
+
332
+ // Speed target met
333
+ assert.ok(
334
+ duration < POST_EXECUTION_TIMEOUT_MS,
335
+ `Post-execution checks took ${duration.toFixed(0)}ms, expected <${POST_EXECUTION_TIMEOUT_MS}ms`
336
+ );
337
+ });
338
+
339
+ test("handles task sequence with signature analysis", () => {
340
+ // Simulate checking for signature consistency across tasks
341
+ const priorTasks: TaskRow[] = [
342
+ createTask({
343
+ id: "T01",
344
+ sequence: 0,
345
+ title: "Define TaskRow interface",
346
+ status: "complete",
347
+ key_files: [join(GSD_SRC_DIR, "gsd-db.ts")],
348
+ }),
349
+ ];
350
+
351
+ const completedTask = createTask({
352
+ id: "T02",
353
+ sequence: 1,
354
+ title: "Use TaskRow in state module",
355
+ status: "complete",
356
+ key_files: [join(GSD_SRC_DIR, "state.ts")],
357
+ });
358
+
359
+ const start = performance.now();
360
+ const result = runPostExecutionChecks(completedTask, priorTasks, GSD_SRC_DIR);
361
+ const duration = performance.now() - start;
362
+
363
+ // No blocking failures
364
+ const blockingFailures = result.checks.filter((c) => !c.passed && c.blocking);
365
+ assert.equal(
366
+ blockingFailures.length,
367
+ 0,
368
+ `Unexpected blocking failures: ${JSON.stringify(blockingFailures, null, 2)}`
369
+ );
370
+
371
+ // Speed target met
372
+ assert.ok(
373
+ duration < POST_EXECUTION_TIMEOUT_MS,
374
+ `Post-execution checks took ${duration.toFixed(0)}ms, expected <${POST_EXECUTION_TIMEOUT_MS}ms`
375
+ );
376
+ });
377
+ });
378
+
379
+ describe("Combined Pre and Post Execution Flow", () => {
380
+ test("full verification flow on realistic task lifecycle", async () => {
381
+ // Simulate a complete task lifecycle
382
+ const tasks: TaskRow[] = [
383
+ createTask({
384
+ id: "T01",
385
+ sequence: 0,
386
+ title: "Implement enhanced verification",
387
+ status: "pending",
388
+ description: `
389
+ ## Steps
390
+ 1. Update pre-execution-checks.ts with new validation
391
+ 2. Update post-execution-checks.ts with signature analysis
392
+ 3. Add integration tests
393
+
394
+ \`\`\`typescript
395
+ import { runPreExecutionChecks } from "./pre-execution-checks.ts";
396
+ import { runPostExecutionChecks } from "./post-execution-checks.ts";
397
+ \`\`\`
398
+ `.trim(),
399
+ files: [
400
+ join(GSD_SRC_DIR, "pre-execution-checks.ts"),
401
+ join(GSD_SRC_DIR, "post-execution-checks.ts"),
402
+ ],
403
+ inputs: [
404
+ join(GSD_SRC_DIR, "types.ts"),
405
+ join(GSD_SRC_DIR, "gsd-db.ts"),
406
+ ],
407
+ expected_output: [
408
+ join(GSD_SRC_DIR, "tests/enhanced-verification-integration.test.ts"),
409
+ ],
410
+ }),
411
+ ];
412
+
413
+ // Run pre-execution checks
414
+ const preStart = performance.now();
415
+ const preResult = await runPreExecutionChecks(tasks, GSD_SRC_DIR);
416
+ const preDuration = performance.now() - preStart;
417
+
418
+ // Verify pre-execution results
419
+ const preBlockingFailures = preResult.checks.filter((c) => !c.passed && c.blocking);
420
+ assert.equal(
421
+ preBlockingFailures.length,
422
+ 0,
423
+ `Pre-execution had blocking failures: ${JSON.stringify(preBlockingFailures, null, 2)}`
424
+ );
425
+ assert.ok(
426
+ preDuration < PRE_EXECUTION_TIMEOUT_MS,
427
+ `Pre-execution took ${preDuration.toFixed(0)}ms, expected <${PRE_EXECUTION_TIMEOUT_MS}ms`
428
+ );
429
+
430
+ // Task after execution (simulated completion)
431
+ const completedTask = createTask({
432
+ ...tasks[0],
433
+ status: "complete",
434
+ key_files: tasks[0].files,
435
+ });
436
+
437
+ // Run post-execution checks
438
+ const postStart = performance.now();
439
+ const postResult = runPostExecutionChecks(completedTask, [], GSD_SRC_DIR);
440
+ const postDuration = performance.now() - postStart;
441
+
442
+ // Verify post-execution results
443
+ const postBlockingFailures = postResult.checks.filter((c) => !c.passed && c.blocking);
444
+ assert.equal(
445
+ postBlockingFailures.length,
446
+ 0,
447
+ `Post-execution had blocking failures: ${JSON.stringify(postBlockingFailures, null, 2)}`
448
+ );
449
+ assert.ok(
450
+ postDuration < POST_EXECUTION_TIMEOUT_MS,
451
+ `Post-execution took ${postDuration.toFixed(0)}ms, expected <${POST_EXECUTION_TIMEOUT_MS}ms`
452
+ );
453
+ });
454
+
455
+ test("handles large number of files without timeout", () => {
456
+ // Use all available GSD source files to stress test
457
+ const allGsdFiles = REAL_GSD_FILES.map((f) => join(GSD_SRC_DIR, f));
458
+
459
+ const task = createTask({
460
+ id: "T01",
461
+ title: "Large refactor touching many files",
462
+ status: "complete",
463
+ key_files: allGsdFiles,
464
+ files: allGsdFiles,
465
+ });
466
+
467
+ const start = performance.now();
468
+ const result = runPostExecutionChecks(task, [], GSD_SRC_DIR);
469
+ const duration = performance.now() - start;
470
+
471
+ // No blocking failures
472
+ const blockingFailures = result.checks.filter((c) => !c.passed && c.blocking);
473
+ assert.equal(
474
+ blockingFailures.length,
475
+ 0,
476
+ `Unexpected blocking failures: ${JSON.stringify(blockingFailures, null, 2)}`
477
+ );
478
+
479
+ // Should still be fast even with many files
480
+ // Allow slightly more time for multi-file analysis but still within target
481
+ assert.ok(
482
+ duration < POST_EXECUTION_TIMEOUT_MS * 2, // Allow 2x for stress test
483
+ `Multi-file post-execution took ${duration.toFixed(0)}ms, expected <${POST_EXECUTION_TIMEOUT_MS * 2}ms`
484
+ );
485
+ });
486
+ });
487
+
488
+ describe("Warning Quality", () => {
489
+ test("warnings on real code are actionable, not spurious", () => {
490
+ // Run checks on well-formed production code
491
+ const task = createTask({
492
+ id: "T01",
493
+ title: "Review code quality",
494
+ status: "complete",
495
+ key_files: [
496
+ join(GSD_SRC_DIR, "pre-execution-checks.ts"),
497
+ join(GSD_SRC_DIR, "post-execution-checks.ts"),
498
+ ],
499
+ });
500
+
501
+ const result = runPostExecutionChecks(task, [], GSD_SRC_DIR);
502
+
503
+ // Extract warnings (either non-passed non-blocking, or passed with warning messages)
504
+ const warnings = result.checks.filter(
505
+ (c) => (!c.passed && !c.blocking) || (c.passed && c.message?.startsWith("Warning:"))
506
+ );
507
+
508
+ // Warnings are acceptable but should be few on well-maintained code
509
+ // If we get many warnings, it suggests the checks are too aggressive
510
+ assert.ok(
511
+ warnings.length <= 10,
512
+ `Too many warnings (${warnings.length}) suggests overly aggressive checks: ${JSON.stringify(warnings, null, 2)}`
513
+ );
514
+
515
+ // Each warning should have a clear message
516
+ for (const warning of warnings) {
517
+ assert.ok(warning.category, "Warning missing category");
518
+ assert.ok(warning.message, "Warning missing message");
519
+ assert.ok(
520
+ warning.message.length > 10,
521
+ `Warning message too short to be actionable: "${warning.message}"`
522
+ );
523
+ }
524
+ });
525
+ });
526
+ });