gsd-pi 2.79.0-dev.5c910bb05 → 2.79.0-dev.9941c9c24
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/dist/resources/.managed-resources-content-hash +1 -1
- package/dist/resources/extensions/gsd/auto/contracts.js +1 -0
- package/dist/resources/extensions/gsd/auto/orchestrator.js +146 -0
- package/dist/resources/extensions/gsd/auto/phases.js +61 -7
- package/dist/resources/extensions/gsd/auto/session.js +8 -0
- package/dist/resources/extensions/gsd/auto-artifact-paths.js +2 -2
- package/dist/resources/extensions/gsd/auto-dispatch.js +2 -0
- package/dist/resources/extensions/gsd/auto-recovery.js +63 -55
- package/dist/resources/extensions/gsd/auto-runtime-state.js +4 -0
- package/dist/resources/extensions/gsd/auto-start.js +3 -2
- package/dist/resources/extensions/gsd/auto.js +159 -2
- package/dist/resources/extensions/gsd/bootstrap/agent-end-recovery.js +9 -1
- package/dist/resources/extensions/gsd/bootstrap/register-hooks.js +8 -8
- package/dist/resources/extensions/gsd/bootstrap/write-gate.js +8 -8
- package/dist/resources/extensions/gsd/gsd-db.js +34 -1
- package/dist/resources/extensions/gsd/guided-flow.js +40 -0
- package/dist/resources/extensions/gsd/paths.js +5 -1
- package/dist/resources/extensions/gsd/tools/workflow-tool-executors.js +45 -4
- package/dist/resources/extensions/gsd/uok/audit.js +23 -9
- package/dist/resources/extensions/gsd/uok/contracts.js +69 -1
- package/dist/resources/extensions/gsd/uok/dispatch-envelope.js +3 -0
- package/dist/resources/extensions/gsd/uok/loop-adapter.js +48 -33
- package/dist/resources/extensions/gsd/uok/timeline.js +125 -0
- package/dist/resources/extensions/shared/gsd-phase-state.js +45 -3
- package/dist/resources/extensions/shared/interview-ui.js +15 -4
- package/dist/tsconfig.extensions.tsbuildinfo +1 -1
- package/dist/web/standalone/.next/BUILD_ID +1 -1
- package/dist/web/standalone/.next/app-path-routes-manifest.json +14 -14
- package/dist/web/standalone/.next/build-manifest.json +2 -2
- package/dist/web/standalone/.next/prerender-manifest.json +3 -3
- package/dist/web/standalone/.next/server/app/_global-error.html +1 -1
- package/dist/web/standalone/.next/server/app/_global-error.rsc +1 -1
- package/dist/web/standalone/.next/server/app/_global-error.segments/_full.segment.rsc +1 -1
- package/dist/web/standalone/.next/server/app/_global-error.segments/_global-error/__PAGE__.segment.rsc +1 -1
- package/dist/web/standalone/.next/server/app/_global-error.segments/_global-error.segment.rsc +1 -1
- package/dist/web/standalone/.next/server/app/_global-error.segments/_head.segment.rsc +1 -1
- package/dist/web/standalone/.next/server/app/_global-error.segments/_index.segment.rsc +1 -1
- package/dist/web/standalone/.next/server/app/_global-error.segments/_tree.segment.rsc +1 -1
- package/dist/web/standalone/.next/server/app/_not-found.html +1 -1
- package/dist/web/standalone/.next/server/app/_not-found.rsc +1 -1
- package/dist/web/standalone/.next/server/app/_not-found.segments/_full.segment.rsc +1 -1
- package/dist/web/standalone/.next/server/app/_not-found.segments/_head.segment.rsc +1 -1
- package/dist/web/standalone/.next/server/app/_not-found.segments/_index.segment.rsc +1 -1
- package/dist/web/standalone/.next/server/app/_not-found.segments/_not-found/__PAGE__.segment.rsc +1 -1
- package/dist/web/standalone/.next/server/app/_not-found.segments/_not-found.segment.rsc +1 -1
- package/dist/web/standalone/.next/server/app/_not-found.segments/_tree.segment.rsc +1 -1
- package/dist/web/standalone/.next/server/app/index.html +1 -1
- package/dist/web/standalone/.next/server/app/index.rsc +1 -1
- package/dist/web/standalone/.next/server/app/index.segments/__PAGE__.segment.rsc +1 -1
- package/dist/web/standalone/.next/server/app/index.segments/_full.segment.rsc +1 -1
- package/dist/web/standalone/.next/server/app/index.segments/_head.segment.rsc +1 -1
- package/dist/web/standalone/.next/server/app/index.segments/_index.segment.rsc +1 -1
- package/dist/web/standalone/.next/server/app/index.segments/_tree.segment.rsc +1 -1
- package/dist/web/standalone/.next/server/app-paths-manifest.json +14 -14
- package/dist/web/standalone/.next/server/middleware-build-manifest.js +1 -1
- package/dist/web/standalone/.next/server/pages/404.html +1 -1
- package/dist/web/standalone/.next/server/pages/500.html +1 -1
- package/dist/web/standalone/.next/server/server-reference-manifest.json +1 -1
- package/package.json +1 -1
- package/packages/mcp-server/src/workflow-tools.test.ts +13 -2
- package/src/resources/extensions/gsd/auto/contracts.ts +87 -0
- package/src/resources/extensions/gsd/auto/loop-deps.ts +10 -3
- package/src/resources/extensions/gsd/auto/orchestrator.ts +161 -0
- package/src/resources/extensions/gsd/auto/phases.ts +88 -9
- package/src/resources/extensions/gsd/auto/session.ts +11 -0
- package/src/resources/extensions/gsd/auto-artifact-paths.ts +2 -2
- package/src/resources/extensions/gsd/auto-dispatch.ts +1 -0
- package/src/resources/extensions/gsd/auto-recovery.ts +59 -53
- package/src/resources/extensions/gsd/auto-runtime-state.ts +7 -0
- package/src/resources/extensions/gsd/auto-start.ts +3 -2
- package/src/resources/extensions/gsd/auto.ts +167 -1
- package/src/resources/extensions/gsd/bootstrap/agent-end-recovery.ts +14 -1
- package/src/resources/extensions/gsd/bootstrap/register-hooks.ts +11 -8
- package/src/resources/extensions/gsd/bootstrap/tests/write-gate-shouldblock-basepath.test.ts +97 -0
- package/src/resources/extensions/gsd/bootstrap/write-gate.ts +8 -4
- package/src/resources/extensions/gsd/gsd-db.ts +35 -1
- package/src/resources/extensions/gsd/guided-flow.ts +47 -0
- package/src/resources/extensions/gsd/interrupted-session.ts +1 -0
- package/src/resources/extensions/gsd/paths.ts +6 -1
- package/src/resources/extensions/gsd/tests/auto-abort-pause-regression.test.ts +32 -0
- package/src/resources/extensions/gsd/tests/auto-orchestrator.test.ts +353 -0
- package/src/resources/extensions/gsd/tests/auto-recovery.test.ts +108 -1
- package/src/resources/extensions/gsd/tests/auto-runtime-state.test.ts +39 -0
- package/src/resources/extensions/gsd/tests/auto-session-encapsulation.test.ts +3 -0
- package/src/resources/extensions/gsd/tests/check-auto-start-pending-gate.test.ts +203 -0
- package/src/resources/extensions/gsd/tests/check-auto-start-ready-guard.test.ts +148 -0
- package/src/resources/extensions/gsd/tests/deep-planning-mode-dispatch.test.ts +42 -0
- package/src/resources/extensions/gsd/tests/deep-project-auto-loop.test.ts +63 -2
- package/src/resources/extensions/gsd/tests/execute-summary-save-empty-project.test.ts +109 -0
- package/src/resources/extensions/gsd/tests/gsd-db.test.ts +95 -0
- package/src/resources/extensions/gsd/tests/integration/auto-recovery.test.ts +79 -0
- package/src/resources/extensions/gsd/tests/journal-integration.test.ts +134 -0
- package/src/resources/extensions/gsd/tests/paused-session-via-db.test.ts +2 -0
- package/src/resources/extensions/gsd/tests/plan-slice.test.ts +27 -0
- package/src/resources/extensions/gsd/tests/uok-contracts.test.ts +109 -1
- package/src/resources/extensions/gsd/tests/uok-loop-adapter-writer.test.ts +98 -0
- package/src/resources/extensions/gsd/tests/workflow-tool-executors.test.ts +36 -7
- package/src/resources/extensions/gsd/tools/workflow-tool-executors.ts +47 -4
- package/src/resources/extensions/gsd/uok/audit.ts +25 -9
- package/src/resources/extensions/gsd/uok/contracts.ts +105 -0
- package/src/resources/extensions/gsd/uok/dispatch-envelope.ts +4 -0
- package/src/resources/extensions/gsd/uok/loop-adapter.ts +60 -45
- package/src/resources/extensions/gsd/uok/timeline.ts +158 -0
- package/src/resources/extensions/shared/gsd-phase-state.ts +56 -3
- package/src/resources/extensions/shared/interview-ui.ts +18 -5
- package/src/resources/extensions/shared/tests/gsd-phase-state.test.ts +43 -1
- package/src/resources/extensions/shared/tests/interview-notes-loop.test.ts +41 -0
- /package/dist/web/standalone/.next/static/{DSZPSz1kgrF8zPIrV_AMD → zSHLdEn5cpkqivbJZq0Qq}/_buildManifest.js +0 -0
- /package/dist/web/standalone/.next/static/{DSZPSz1kgrF8zPIrV_AMD → zSHLdEn5cpkqivbJZq0Qq}/_ssgManifest.js +0 -0
|
@@ -0,0 +1,353 @@
|
|
|
1
|
+
import test from "node:test";
|
|
2
|
+
import assert from "node:assert/strict";
|
|
3
|
+
|
|
4
|
+
import { createAutoOrchestrator } from "../auto/orchestrator.js";
|
|
5
|
+
import type { AutoOrchestratorDeps } from "../auto/contracts.js";
|
|
6
|
+
|
|
7
|
+
function makeDeps(overrides: Partial<AutoOrchestratorDeps> = {}): { deps: AutoOrchestratorDeps; calls: string[] } {
|
|
8
|
+
const calls: string[] = [];
|
|
9
|
+
|
|
10
|
+
const deps: AutoOrchestratorDeps = {
|
|
11
|
+
dispatch: {
|
|
12
|
+
async decideNextUnit() {
|
|
13
|
+
calls.push("dispatch.decide");
|
|
14
|
+
return { unitType: "execute-task", unitId: "T01", reason: "ready", preconditions: [] };
|
|
15
|
+
},
|
|
16
|
+
},
|
|
17
|
+
recovery: {
|
|
18
|
+
async classifyAndRecover() {
|
|
19
|
+
calls.push("recovery.classify");
|
|
20
|
+
return { action: "stop", reason: "fatal" };
|
|
21
|
+
},
|
|
22
|
+
},
|
|
23
|
+
worktree: {
|
|
24
|
+
async prepareForUnit() { calls.push("worktree.prepare"); },
|
|
25
|
+
async syncAfterUnit() { calls.push("worktree.sync"); },
|
|
26
|
+
async cleanupOnStop() { calls.push("worktree.cleanup"); },
|
|
27
|
+
},
|
|
28
|
+
health: {
|
|
29
|
+
async preAdvanceGate() {
|
|
30
|
+
calls.push("health.pre");
|
|
31
|
+
return { allow: true };
|
|
32
|
+
},
|
|
33
|
+
async postAdvanceRecord() { calls.push("health.post"); },
|
|
34
|
+
},
|
|
35
|
+
runtime: {
|
|
36
|
+
async ensureLockOwnership() { calls.push("runtime.lock"); },
|
|
37
|
+
async journalTransition(event) { calls.push(`journal:${event.name}`); },
|
|
38
|
+
},
|
|
39
|
+
notifications: {
|
|
40
|
+
async notifyLifecycle(event) { calls.push(`notify:${event.name}`); },
|
|
41
|
+
},
|
|
42
|
+
};
|
|
43
|
+
|
|
44
|
+
return { deps: { ...deps, ...overrides }, calls };
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
test("start() advances and records active unit", async () => {
|
|
48
|
+
const { deps, calls } = makeDeps();
|
|
49
|
+
const orchestrator = createAutoOrchestrator(deps);
|
|
50
|
+
|
|
51
|
+
const result = await orchestrator.start({ basePath: "/tmp/project", trigger: "manual" });
|
|
52
|
+
|
|
53
|
+
assert.equal(result.kind, "advanced");
|
|
54
|
+
const status = orchestrator.getStatus();
|
|
55
|
+
assert.equal(status.phase, "running");
|
|
56
|
+
assert.deepEqual(status.activeUnit, { unitType: "execute-task", unitId: "T01" });
|
|
57
|
+
assert.ok(calls.includes("journal:start"));
|
|
58
|
+
assert.ok(calls.includes("journal:advance"));
|
|
59
|
+
});
|
|
60
|
+
|
|
61
|
+
test("advance() returns blocked when health gate denies", async () => {
|
|
62
|
+
const { deps } = makeDeps({
|
|
63
|
+
health: {
|
|
64
|
+
async preAdvanceGate() { return { allow: false, reason: "doctor-block" }; },
|
|
65
|
+
async postAdvanceRecord() {},
|
|
66
|
+
},
|
|
67
|
+
});
|
|
68
|
+
const orchestrator = createAutoOrchestrator(deps);
|
|
69
|
+
|
|
70
|
+
const result = await orchestrator.advance();
|
|
71
|
+
|
|
72
|
+
assert.equal(result.kind, "blocked");
|
|
73
|
+
assert.equal(result.reason, "doctor-block");
|
|
74
|
+
});
|
|
75
|
+
|
|
76
|
+
test("advance() stops when dispatch has no next unit", async () => {
|
|
77
|
+
const { deps } = makeDeps({
|
|
78
|
+
dispatch: {
|
|
79
|
+
async decideNextUnit() { return null; },
|
|
80
|
+
},
|
|
81
|
+
});
|
|
82
|
+
const orchestrator = createAutoOrchestrator(deps);
|
|
83
|
+
|
|
84
|
+
const result = await orchestrator.advance();
|
|
85
|
+
|
|
86
|
+
assert.equal(result.kind, "stopped");
|
|
87
|
+
assert.equal(orchestrator.getStatus().phase, "stopped");
|
|
88
|
+
});
|
|
89
|
+
|
|
90
|
+
test("advance() uses recovery on error", async () => {
|
|
91
|
+
const { deps, calls } = makeDeps({
|
|
92
|
+
runtime: {
|
|
93
|
+
async ensureLockOwnership() { throw new Error("lock lost"); },
|
|
94
|
+
async journalTransition(event) { calls.push(`journal:${event.name}`); },
|
|
95
|
+
},
|
|
96
|
+
recovery: {
|
|
97
|
+
async classifyAndRecover() { return { action: "escalate", reason: "needs manual" }; },
|
|
98
|
+
},
|
|
99
|
+
});
|
|
100
|
+
const orchestrator = createAutoOrchestrator(deps);
|
|
101
|
+
|
|
102
|
+
const result = await orchestrator.advance();
|
|
103
|
+
|
|
104
|
+
assert.equal(result.kind, "error");
|
|
105
|
+
assert.equal(result.reason, "needs manual");
|
|
106
|
+
assert.equal(orchestrator.getStatus().phase, "error");
|
|
107
|
+
assert.ok(calls.includes("journal:advance-error"));
|
|
108
|
+
});
|
|
109
|
+
|
|
110
|
+
test("advance() is idempotent for the same active unit", async () => {
|
|
111
|
+
const { deps, calls } = makeDeps();
|
|
112
|
+
const orchestrator = createAutoOrchestrator(deps);
|
|
113
|
+
|
|
114
|
+
const first = await orchestrator.advance();
|
|
115
|
+
const second = await orchestrator.advance();
|
|
116
|
+
|
|
117
|
+
assert.equal(first.kind, "advanced");
|
|
118
|
+
assert.equal(second.kind, "blocked");
|
|
119
|
+
assert.equal(second.reason, "idempotent advance: unit already active");
|
|
120
|
+
|
|
121
|
+
const prepareCalls = calls.filter((c) => c === "worktree.prepare").length;
|
|
122
|
+
assert.equal(prepareCalls, 1);
|
|
123
|
+
});
|
|
124
|
+
|
|
125
|
+
test("resume() re-enters running flow via advance", async () => {
|
|
126
|
+
const { deps } = makeDeps();
|
|
127
|
+
const orchestrator = createAutoOrchestrator(deps);
|
|
128
|
+
|
|
129
|
+
const result = await orchestrator.resume();
|
|
130
|
+
|
|
131
|
+
assert.equal(result.kind, "advanced");
|
|
132
|
+
assert.equal(orchestrator.getStatus().phase, "running");
|
|
133
|
+
});
|
|
134
|
+
|
|
135
|
+
test("resume() clears idempotent lock and allows re-advance", async () => {
|
|
136
|
+
const { deps } = makeDeps();
|
|
137
|
+
const orchestrator = createAutoOrchestrator(deps);
|
|
138
|
+
|
|
139
|
+
const first = await orchestrator.advance();
|
|
140
|
+
const blocked = await orchestrator.advance();
|
|
141
|
+
const resumed = await orchestrator.resume();
|
|
142
|
+
|
|
143
|
+
assert.equal(first.kind, "advanced");
|
|
144
|
+
assert.equal(blocked.kind, "blocked");
|
|
145
|
+
assert.equal(resumed.kind, "advanced");
|
|
146
|
+
});
|
|
147
|
+
|
|
148
|
+
test("transitionCount increases across lifecycle transitions", async () => {
|
|
149
|
+
const { deps } = makeDeps();
|
|
150
|
+
const orchestrator = createAutoOrchestrator(deps);
|
|
151
|
+
|
|
152
|
+
const before = orchestrator.getStatus().transitionCount;
|
|
153
|
+
await orchestrator.start({ basePath: "/tmp/project", trigger: "manual" });
|
|
154
|
+
const afterStart = orchestrator.getStatus().transitionCount;
|
|
155
|
+
await orchestrator.stop("done");
|
|
156
|
+
const afterStop = orchestrator.getStatus().transitionCount;
|
|
157
|
+
|
|
158
|
+
assert.ok(afterStart > before);
|
|
159
|
+
assert.ok(afterStop > afterStart);
|
|
160
|
+
});
|
|
161
|
+
|
|
162
|
+
test("stop() clears idempotent unit lock so advance can run again", async () => {
|
|
163
|
+
const { deps } = makeDeps();
|
|
164
|
+
const orchestrator = createAutoOrchestrator(deps);
|
|
165
|
+
|
|
166
|
+
const first = await orchestrator.advance();
|
|
167
|
+
const blocked = await orchestrator.advance();
|
|
168
|
+
const stopped = await orchestrator.stop("reset");
|
|
169
|
+
const second = await orchestrator.advance();
|
|
170
|
+
|
|
171
|
+
assert.equal(first.kind, "advanced");
|
|
172
|
+
assert.equal(blocked.kind, "blocked");
|
|
173
|
+
assert.equal(stopped.kind, "stopped");
|
|
174
|
+
assert.equal(second.kind, "advanced");
|
|
175
|
+
});
|
|
176
|
+
|
|
177
|
+
test("advance() stopped clears previous activeUnit", async () => {
|
|
178
|
+
let first = true;
|
|
179
|
+
const { deps } = makeDeps({
|
|
180
|
+
dispatch: {
|
|
181
|
+
async decideNextUnit() {
|
|
182
|
+
if (first) {
|
|
183
|
+
first = false;
|
|
184
|
+
return { unitType: "execute-task", unitId: "T01", reason: "ready", preconditions: [] };
|
|
185
|
+
}
|
|
186
|
+
return null;
|
|
187
|
+
},
|
|
188
|
+
},
|
|
189
|
+
});
|
|
190
|
+
const orchestrator = createAutoOrchestrator(deps);
|
|
191
|
+
|
|
192
|
+
await orchestrator.advance();
|
|
193
|
+
const stopped = await orchestrator.advance();
|
|
194
|
+
|
|
195
|
+
assert.equal(stopped.kind, "stopped");
|
|
196
|
+
assert.equal(orchestrator.getStatus().activeUnit, undefined);
|
|
197
|
+
});
|
|
198
|
+
|
|
199
|
+
test("recovery stop clears activeUnit", async () => {
|
|
200
|
+
const { deps, calls } = makeDeps({
|
|
201
|
+
runtime: {
|
|
202
|
+
async ensureLockOwnership() { throw new Error("boom"); },
|
|
203
|
+
async journalTransition(event) { calls.push(`journal:${event.name}`); },
|
|
204
|
+
},
|
|
205
|
+
recovery: {
|
|
206
|
+
async classifyAndRecover() { return { action: "stop", reason: "fatal" }; },
|
|
207
|
+
},
|
|
208
|
+
});
|
|
209
|
+
const orchestrator = createAutoOrchestrator(deps);
|
|
210
|
+
|
|
211
|
+
const result = await orchestrator.advance();
|
|
212
|
+
|
|
213
|
+
assert.equal(result.kind, "stopped");
|
|
214
|
+
assert.equal(orchestrator.getStatus().activeUnit, undefined);
|
|
215
|
+
assert.ok(calls.includes("journal:advance-stopped"));
|
|
216
|
+
assert.ok(calls.includes("notify:stopped"));
|
|
217
|
+
assert.ok(!calls.includes("notify:error"));
|
|
218
|
+
});
|
|
219
|
+
|
|
220
|
+
test("recovery retry maps to paused result", async () => {
|
|
221
|
+
const { deps, calls } = makeDeps({
|
|
222
|
+
runtime: {
|
|
223
|
+
async ensureLockOwnership() { throw new Error("boom"); },
|
|
224
|
+
async journalTransition(event) { calls.push(`journal:${event.name}`); },
|
|
225
|
+
},
|
|
226
|
+
recovery: {
|
|
227
|
+
async classifyAndRecover() { return { action: "retry", reason: "transient" }; },
|
|
228
|
+
},
|
|
229
|
+
});
|
|
230
|
+
const orchestrator = createAutoOrchestrator(deps);
|
|
231
|
+
|
|
232
|
+
const result = await orchestrator.advance();
|
|
233
|
+
|
|
234
|
+
assert.equal(result.kind, "paused");
|
|
235
|
+
assert.equal(result.reason, "transient");
|
|
236
|
+
assert.equal(orchestrator.getStatus().phase, "paused");
|
|
237
|
+
assert.ok(calls.includes("journal:advance-paused"));
|
|
238
|
+
assert.ok(calls.includes("notify:pause"));
|
|
239
|
+
});
|
|
240
|
+
|
|
241
|
+
test("getStatus() returns defensive copy of activeUnit", async () => {
|
|
242
|
+
const { deps } = makeDeps();
|
|
243
|
+
const orchestrator = createAutoOrchestrator(deps);
|
|
244
|
+
|
|
245
|
+
await orchestrator.advance();
|
|
246
|
+
const snap1 = orchestrator.getStatus();
|
|
247
|
+
if (snap1.activeUnit) snap1.activeUnit.unitId = "MUTATED";
|
|
248
|
+
const snap2 = orchestrator.getStatus();
|
|
249
|
+
|
|
250
|
+
assert.equal(snap2.activeUnit?.unitId, "T01");
|
|
251
|
+
});
|
|
252
|
+
|
|
253
|
+
test("start() clears prior idempotent lock", async () => {
|
|
254
|
+
const { deps } = makeDeps();
|
|
255
|
+
const orchestrator = createAutoOrchestrator(deps);
|
|
256
|
+
|
|
257
|
+
await orchestrator.advance();
|
|
258
|
+
const blocked = await orchestrator.advance();
|
|
259
|
+
const restarted = await orchestrator.start({ basePath: "/tmp/project", trigger: "manual" });
|
|
260
|
+
|
|
261
|
+
assert.equal(blocked.kind, "blocked");
|
|
262
|
+
assert.equal(restarted.kind, "advanced");
|
|
263
|
+
});
|
|
264
|
+
|
|
265
|
+
test("error path emits error notification", async () => {
|
|
266
|
+
const { deps, calls } = makeDeps({
|
|
267
|
+
runtime: {
|
|
268
|
+
async ensureLockOwnership() { throw new Error("boom"); },
|
|
269
|
+
async journalTransition(event) { calls.push(`journal:${event.name}`); },
|
|
270
|
+
},
|
|
271
|
+
recovery: {
|
|
272
|
+
async classifyAndRecover() { return { action: "escalate", reason: "needs manual" }; },
|
|
273
|
+
},
|
|
274
|
+
});
|
|
275
|
+
const orchestrator = createAutoOrchestrator(deps);
|
|
276
|
+
|
|
277
|
+
await orchestrator.advance();
|
|
278
|
+
|
|
279
|
+
assert.ok(calls.includes("notify:error"));
|
|
280
|
+
});
|
|
281
|
+
|
|
282
|
+
test("blocked path journals advance-blocked", async () => {
|
|
283
|
+
const { deps, calls } = makeDeps();
|
|
284
|
+
const orchestrator = createAutoOrchestrator(deps);
|
|
285
|
+
|
|
286
|
+
await orchestrator.advance();
|
|
287
|
+
await orchestrator.advance();
|
|
288
|
+
|
|
289
|
+
assert.ok(calls.includes("journal:advance-blocked"));
|
|
290
|
+
});
|
|
291
|
+
|
|
292
|
+
test("health post hook runs on blocked result", async () => {
|
|
293
|
+
const { deps, calls } = makeDeps();
|
|
294
|
+
const orchestrator = createAutoOrchestrator(deps);
|
|
295
|
+
|
|
296
|
+
await orchestrator.advance();
|
|
297
|
+
await orchestrator.advance();
|
|
298
|
+
|
|
299
|
+
assert.ok(calls.includes("health.post"));
|
|
300
|
+
});
|
|
301
|
+
|
|
302
|
+
test("start() emits start notification", async () => {
|
|
303
|
+
const { deps, calls } = makeDeps();
|
|
304
|
+
const orchestrator = createAutoOrchestrator(deps);
|
|
305
|
+
|
|
306
|
+
await orchestrator.start({ basePath: "/tmp/project", trigger: "manual" });
|
|
307
|
+
|
|
308
|
+
assert.ok(calls.includes("notify:start"));
|
|
309
|
+
});
|
|
310
|
+
|
|
311
|
+
test("resume() emits resume notification", async () => {
|
|
312
|
+
const { deps, calls } = makeDeps();
|
|
313
|
+
const orchestrator = createAutoOrchestrator(deps);
|
|
314
|
+
|
|
315
|
+
await orchestrator.resume();
|
|
316
|
+
|
|
317
|
+
assert.ok(calls.includes("notify:resume"));
|
|
318
|
+
});
|
|
319
|
+
|
|
320
|
+
test("stopped with no remaining units clears idempotent lock for next advance", async () => {
|
|
321
|
+
let callCount = 0;
|
|
322
|
+
const { deps } = makeDeps({
|
|
323
|
+
dispatch: {
|
|
324
|
+
async decideNextUnit() {
|
|
325
|
+
callCount += 1;
|
|
326
|
+
if (callCount === 2) return null;
|
|
327
|
+
return { unitType: "execute-task", unitId: "T01", reason: "ready", preconditions: [] };
|
|
328
|
+
},
|
|
329
|
+
},
|
|
330
|
+
});
|
|
331
|
+
const orchestrator = createAutoOrchestrator(deps);
|
|
332
|
+
|
|
333
|
+
const first = await orchestrator.advance();
|
|
334
|
+
const stopped = await orchestrator.advance();
|
|
335
|
+
const after = await orchestrator.advance();
|
|
336
|
+
|
|
337
|
+
assert.equal(first.kind, "advanced");
|
|
338
|
+
assert.equal(stopped.kind, "stopped");
|
|
339
|
+
assert.equal(after.kind, "advanced");
|
|
340
|
+
});
|
|
341
|
+
|
|
342
|
+
test("stop() cleans up worktree and transitions to stopped", async () => {
|
|
343
|
+
const { deps, calls } = makeDeps();
|
|
344
|
+
const orchestrator = createAutoOrchestrator(deps);
|
|
345
|
+
|
|
346
|
+
const result = await orchestrator.stop("user-request");
|
|
347
|
+
|
|
348
|
+
assert.equal(result.kind, "stopped");
|
|
349
|
+
assert.equal(orchestrator.getStatus().phase, "stopped");
|
|
350
|
+
assert.ok(calls.includes("worktree.cleanup"));
|
|
351
|
+
assert.ok(calls.includes("journal:stop"));
|
|
352
|
+
assert.ok(calls.includes("notify:stop"));
|
|
353
|
+
});
|
|
@@ -7,7 +7,7 @@ import { randomUUID } from "node:crypto";
|
|
|
7
7
|
|
|
8
8
|
import { verifyExpectedArtifact, hasImplementationArtifacts, resolveExpectedArtifactPath, diagnoseExpectedArtifact, buildLoopRemediationSteps, writeBlockerPlaceholder } from "../auto-recovery.ts";
|
|
9
9
|
import { resolveMilestoneFile } from "../paths.ts";
|
|
10
|
-
import { openDatabase, closeDatabase, insertMilestone, insertSlice, insertGateRow } from "../gsd-db.ts";
|
|
10
|
+
import { openDatabase, closeDatabase, insertMilestone, insertSlice, insertGateRow, insertTask } from "../gsd-db.ts";
|
|
11
11
|
import { clearParseCache } from "../files.ts";
|
|
12
12
|
import { parseRoadmap } from "../parsers-legacy.ts";
|
|
13
13
|
import { invalidateAllCaches } from "../cache.ts";
|
|
@@ -90,6 +90,46 @@ test("resolveExpectedArtifactPath returns correct path for plan-slice", () => {
|
|
|
90
90
|
}
|
|
91
91
|
});
|
|
92
92
|
|
|
93
|
+
test("plan-slice artifact resolution handles lowercase unit IDs against uppercase paths", () => {
|
|
94
|
+
const base = makeTmpBase();
|
|
95
|
+
try {
|
|
96
|
+
const sliceDir = join(base, ".gsd", "milestones", "M001", "slices", "S01");
|
|
97
|
+
const tasksDir = join(sliceDir, "tasks");
|
|
98
|
+
writeFileSync(join(sliceDir, "S01-PLAN.md"), [
|
|
99
|
+
"# S01: Test Slice",
|
|
100
|
+
"",
|
|
101
|
+
"## Tasks",
|
|
102
|
+
"",
|
|
103
|
+
"- [ ] **T01: Implement feature** `est:1h`",
|
|
104
|
+
].join("\n"));
|
|
105
|
+
writeFileSync(join(tasksDir, "T01-PLAN.md"), "# T01 Plan");
|
|
106
|
+
|
|
107
|
+
const artifactPath = resolveExpectedArtifactPath("plan-slice", "m001/s01", base);
|
|
108
|
+
assert.ok(
|
|
109
|
+
artifactPath?.endsWith(".gsd/milestones/M001/slices/S01/S01-PLAN.md"),
|
|
110
|
+
"lowercase unit IDs should resolve to the existing uppercase artifact path",
|
|
111
|
+
);
|
|
112
|
+
|
|
113
|
+
const diagnostic = diagnoseExpectedArtifact("plan-slice", "m001/s01", base);
|
|
114
|
+
assert.ok(
|
|
115
|
+
diagnostic?.includes(".gsd/milestones/M001/slices/S01/S01-PLAN.md"),
|
|
116
|
+
"diagnostic should report the existing uppercase artifact path",
|
|
117
|
+
);
|
|
118
|
+
assert.ok(
|
|
119
|
+
diagnostic?.includes("task plans"),
|
|
120
|
+
"diagnostic should mention task plans because slice plan alone is insufficient",
|
|
121
|
+
);
|
|
122
|
+
|
|
123
|
+
assert.equal(
|
|
124
|
+
verifyExpectedArtifact("plan-slice", "m001/s01", base),
|
|
125
|
+
true,
|
|
126
|
+
"verification should pass when the uppercase slice plan and task plans exist",
|
|
127
|
+
);
|
|
128
|
+
} finally {
|
|
129
|
+
cleanup(base);
|
|
130
|
+
}
|
|
131
|
+
});
|
|
132
|
+
|
|
93
133
|
test("resolveExpectedArtifactPath returns null for unknown type", () => {
|
|
94
134
|
const base = makeTmpBase();
|
|
95
135
|
try {
|
|
@@ -764,6 +804,73 @@ test("hasImplementationArtifacts finds implementation commits when .gsd/ is giti
|
|
|
764
804
|
}
|
|
765
805
|
});
|
|
766
806
|
|
|
807
|
+
test("hasImplementationArtifacts binds GSD-Task trailer to milestone via DB state when .gsd/ is gitignored", () => {
|
|
808
|
+
const base = makeGitBase();
|
|
809
|
+
try {
|
|
810
|
+
writeFileSync(join(base, ".git", "info", "exclude"), ".gsd/\n");
|
|
811
|
+
mkdirSync(join(base, ".gsd"), { recursive: true });
|
|
812
|
+
openDatabase(join(base, ".gsd", "gsd.db"));
|
|
813
|
+
insertMilestone({ id: "M001", title: "Milestone One", status: "active" });
|
|
814
|
+
insertSlice({
|
|
815
|
+
id: "S01",
|
|
816
|
+
milestoneId: "M001",
|
|
817
|
+
title: "Slice One",
|
|
818
|
+
status: "complete",
|
|
819
|
+
risk: "low",
|
|
820
|
+
depends: [],
|
|
821
|
+
});
|
|
822
|
+
insertTask({
|
|
823
|
+
id: "T01",
|
|
824
|
+
sliceId: "S01",
|
|
825
|
+
milestoneId: "M001",
|
|
826
|
+
title: "Task One",
|
|
827
|
+
status: "complete",
|
|
828
|
+
});
|
|
829
|
+
|
|
830
|
+
mkdirSync(join(base, "src"), { recursive: true });
|
|
831
|
+
writeFileSync(join(base, "src", "feature.ts"), "export function feature() {}\n");
|
|
832
|
+
execFileSync("git", ["add", "."], { cwd: base, stdio: "ignore" });
|
|
833
|
+
execFileSync(
|
|
834
|
+
"git",
|
|
835
|
+
["commit", "-m", "feat: add feature\n\nGSD-Task: S01/T01"],
|
|
836
|
+
{ cwd: base, stdio: "ignore" },
|
|
837
|
+
);
|
|
838
|
+
|
|
839
|
+
const result = hasImplementationArtifacts(base, "M001");
|
|
840
|
+
assert.equal(
|
|
841
|
+
result,
|
|
842
|
+
"present",
|
|
843
|
+
"DB task ownership should bind S01/T01 implementation commits to M001 without explicit M001 text",
|
|
844
|
+
);
|
|
845
|
+
} finally {
|
|
846
|
+
cleanup(base);
|
|
847
|
+
}
|
|
848
|
+
});
|
|
849
|
+
|
|
850
|
+
test("hasImplementationArtifacts does not bind GSD-Task trailer without milestone ownership evidence", () => {
|
|
851
|
+
const base = makeGitBase();
|
|
852
|
+
try {
|
|
853
|
+
writeFileSync(join(base, ".git", "info", "exclude"), ".gsd/\n");
|
|
854
|
+
mkdirSync(join(base, "src"), { recursive: true });
|
|
855
|
+
writeFileSync(join(base, "src", "feature.ts"), "export function feature() {}\n");
|
|
856
|
+
execFileSync("git", ["add", "."], { cwd: base, stdio: "ignore" });
|
|
857
|
+
execFileSync(
|
|
858
|
+
"git",
|
|
859
|
+
["commit", "-m", "feat: add feature\n\nGSD-Task: S01/T01"],
|
|
860
|
+
{ cwd: base, stdio: "ignore" },
|
|
861
|
+
);
|
|
862
|
+
|
|
863
|
+
const result = hasImplementationArtifacts(base, "M001");
|
|
864
|
+
assert.equal(
|
|
865
|
+
result,
|
|
866
|
+
"absent",
|
|
867
|
+
"S01/T01 shape alone must not bind an implementation commit to M001",
|
|
868
|
+
);
|
|
869
|
+
} finally {
|
|
870
|
+
cleanup(base);
|
|
871
|
+
}
|
|
872
|
+
});
|
|
873
|
+
|
|
767
874
|
test("hasImplementationArtifacts ignores malformed milestone IDs in commit-message fallback", () => {
|
|
768
875
|
const base = makeGitBase();
|
|
769
876
|
try {
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import test from "node:test";
|
|
2
|
+
import assert from "node:assert/strict";
|
|
3
|
+
|
|
4
|
+
import { autoSession, getAutoRuntimeSnapshot } from "../auto-runtime-state.ts";
|
|
5
|
+
|
|
6
|
+
test("getAutoRuntimeSnapshot includes orchestration phase when available", () => {
|
|
7
|
+
autoSession.reset();
|
|
8
|
+
autoSession.active = true;
|
|
9
|
+
autoSession.basePath = "/tmp/project";
|
|
10
|
+
autoSession.orchestration = {
|
|
11
|
+
async start() { return { kind: "advanced" as const }; },
|
|
12
|
+
async advance() { return { kind: "advanced" as const }; },
|
|
13
|
+
async resume() { return { kind: "advanced" as const }; },
|
|
14
|
+
async stop() { return { kind: "stopped" as const }; },
|
|
15
|
+
getStatus() {
|
|
16
|
+
return { phase: "running" as const, transitionCount: 3, lastTransitionAt: 123 };
|
|
17
|
+
},
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
const snap = getAutoRuntimeSnapshot();
|
|
21
|
+
|
|
22
|
+
assert.equal(snap.active, true);
|
|
23
|
+
assert.equal(snap.basePath, "/tmp/project");
|
|
24
|
+
assert.equal(snap.orchestrationPhase, "running");
|
|
25
|
+
assert.equal(snap.orchestrationTransitionCount, 3);
|
|
26
|
+
assert.equal(snap.orchestrationLastTransitionAt, 123);
|
|
27
|
+
|
|
28
|
+
autoSession.reset();
|
|
29
|
+
});
|
|
30
|
+
|
|
31
|
+
test("getAutoRuntimeSnapshot omits orchestration phase when seam not wired", () => {
|
|
32
|
+
autoSession.reset();
|
|
33
|
+
|
|
34
|
+
const snap = getAutoRuntimeSnapshot();
|
|
35
|
+
|
|
36
|
+
assert.equal(snap.orchestrationPhase, undefined);
|
|
37
|
+
assert.equal(snap.orchestrationTransitionCount, undefined);
|
|
38
|
+
assert.equal(snap.orchestrationLastTransitionAt, undefined);
|
|
39
|
+
});
|
|
@@ -201,6 +201,9 @@ test("AutoSession.toJSON() includes key diagnostic properties", () => {
|
|
|
201
201
|
"basePath",
|
|
202
202
|
"currentMilestoneId",
|
|
203
203
|
"currentUnit",
|
|
204
|
+
"orchestrationPhase",
|
|
205
|
+
"orchestrationTransitionCount",
|
|
206
|
+
"orchestrationLastTransitionAt",
|
|
204
207
|
];
|
|
205
208
|
|
|
206
209
|
const missing = requiredDiagnostics.filter(prop => !toJSONBody.includes(prop));
|