@ftrdotdev/pi-delegates 0.0.0-stage → 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +77 -0
- package/LICENSE +21 -0
- package/OPERATIONS.md +57 -0
- package/README.md +448 -2
- package/ROADMAP.md +158 -0
- package/TESTING.md +1061 -0
- package/agents.ts +8 -0
- package/examples/README.md +114 -0
- package/examples/gated.ts +28 -0
- package/index.ts +9 -0
- package/package.json +93 -4
- package/skills/pi-delegates/SKILL.md +147 -0
- package/skills/pi-delegates/references/control.md +159 -0
- package/skills/pi-delegates/references/definitions.md +163 -0
- package/skills/pi-delegates/references/gates.md +175 -0
- package/skills/pi-delegates/references/launch.md +156 -0
- package/src/domain/definitions.test.ts +41 -0
- package/src/domain/definitions.ts +161 -0
- package/src/domain/ids.ts +13 -0
- package/src/domain/names.ts +35 -0
- package/src/domain/orchestration/admission.ts +78 -0
- package/src/domain/orchestration/control.test.ts +1298 -0
- package/src/domain/orchestration/control.ts +436 -0
- package/src/domain/orchestration/fanout.test.ts +419 -0
- package/src/domain/orchestration/fanout.ts +334 -0
- package/src/domain/orchestration/gates.test.ts +686 -0
- package/src/domain/orchestration/gates.ts +360 -0
- package/src/domain/orchestration/launch.test.ts +173 -0
- package/src/domain/orchestration/launch.ts +581 -0
- package/src/domain/orchestration/requests.test.ts +700 -0
- package/src/domain/orchestration/requests.ts +769 -0
- package/src/domain/orchestration/review.test.ts +214 -0
- package/src/domain/orchestration/review.ts +168 -0
- package/src/domain/orchestration/run-wait.test.ts +262 -0
- package/src/domain/orchestration/run-wait.ts +256 -0
- package/src/domain/orchestration/workflow-section.test.ts +62 -0
- package/src/domain/orchestration/workflow-section.ts +99 -0
- package/src/domain/orchestration/workflow.test.ts +1425 -0
- package/src/domain/orchestration/workflow.ts +705 -0
- package/src/domain/run-records.test.ts +27 -0
- package/src/domain/run-records.ts +527 -0
- package/src/domain/shapes.test.ts +165 -0
- package/src/domain/skills.test.ts +466 -0
- package/src/domain/skills.ts +97 -0
- package/src/domain/tool-schema.test.ts +46 -0
- package/src/domain/tool-schema.ts +20 -0
- package/src/domain/toolkit.test.ts +201 -0
- package/src/domain/toolkit.ts +379 -0
- package/src/domain/view.test.ts +739 -0
- package/src/domain/view.ts +459 -0
- package/src/example.test.ts +15 -0
- package/src/extension/commands.test.ts +481 -0
- package/src/extension/commands.ts +227 -0
- package/src/extension/entry.test.ts +1118 -0
- package/src/extension/entry.ts +342 -0
- package/src/extension/gate-alerts.test.ts +235 -0
- package/src/extension/gate-alerts.ts +143 -0
- package/src/extension/guard.test.ts +48 -0
- package/src/extension/guard.ts +31 -0
- package/src/extension/host-signals.test.ts +20 -0
- package/src/extension/host-signals.ts +13 -0
- package/src/extension/inspector-command.test.ts +1191 -0
- package/src/extension/inspector-command.ts +638 -0
- package/src/extension/prompt.test.ts +110 -0
- package/src/extension/prompt.ts +50 -0
- package/src/extension/request-alerts.test.ts +183 -0
- package/src/extension/request-alerts.ts +181 -0
- package/src/extension/revocation.test.ts +81 -0
- package/src/extension/revocation.ts +84 -0
- package/src/extension/shortcut.test.ts +64 -0
- package/src/extension/shortcut.ts +105 -0
- package/src/extension/tools.test.ts +993 -0
- package/src/extension/tools.ts +505 -0
- package/src/extension/version.test.ts +123 -0
- package/src/extension/version.ts +97 -0
- package/src/harness-policy.test.ts +74 -0
- package/src/package-manifest.test.ts +157 -0
- package/src/presentation/actions.test.ts +221 -0
- package/src/presentation/actions.ts +85 -0
- package/src/presentation/activity.test.ts +387 -0
- package/src/presentation/activity.ts +66 -0
- package/src/presentation/close.test.ts +361 -0
- package/src/presentation/inspector.test.ts +679 -0
- package/src/presentation/inspector.ts +440 -0
- package/src/presentation/overlay.test.ts +555 -0
- package/src/presentation/overlay.ts +229 -0
- package/src/presentation/repaint.test.ts +329 -0
- package/src/presentation/shortcut.ts +2 -0
- package/src/presentation/snapshot.test.ts +530 -0
- package/src/presentation/snapshot.ts +306 -0
- package/src/presentation/strip.test.ts +196 -0
- package/src/presentation/strip.ts +74 -0
- package/src/presentation/wording.test.ts +238 -0
- package/src/presentation/wording.ts +222 -0
- package/src/runtime/bridge.test.ts +131 -0
- package/src/runtime/bridge.ts +134 -0
- package/src/runtime/config.test.ts +44 -0
- package/src/runtime/config.ts +87 -0
- package/src/runtime/context.test.ts +19 -0
- package/src/runtime/context.ts +9 -0
- package/src/runtime/execution-env.test.ts +35 -0
- package/src/runtime/execution-env.ts +15 -0
- package/src/runtime/extensions.test.ts +86 -0
- package/src/runtime/extensions.ts +140 -0
- package/src/runtime/log.test.ts +128 -0
- package/src/runtime/log.ts +68 -0
- package/src/runtime/mcp.test.ts +1453 -0
- package/src/runtime/mcp.ts +938 -0
- package/src/runtime/models.test.ts +145 -0
- package/src/runtime/models.ts +259 -0
- package/src/runtime/observe.test.ts +50 -0
- package/src/runtime/observe.ts +150 -0
- package/src/runtime/session.test.ts +359 -0
- package/src/runtime/session.ts +425 -0
- package/src/runtime/timers.test.ts +31 -0
- package/src/runtime/timers.ts +10 -0
|
@@ -0,0 +1,530 @@
|
|
|
1
|
+
import { assert, it } from "@effect/vitest";
|
|
2
|
+
import type { GateRecord } from "../domain/orchestration/gates.ts";
|
|
3
|
+
import type { RequestRecord } from "../domain/orchestration/requests.ts";
|
|
4
|
+
import {
|
|
5
|
+
laneViews,
|
|
6
|
+
STATUS_RUN_LIMIT,
|
|
7
|
+
type ChildView,
|
|
8
|
+
type RunStatus,
|
|
9
|
+
type RunView,
|
|
10
|
+
type SessionView,
|
|
11
|
+
} from "../domain/view.ts";
|
|
12
|
+
import type { RunActivity } from "./activity.ts";
|
|
13
|
+
import { InspectorSnapshotEquivalence, projectSnapshot } from "./snapshot.ts";
|
|
14
|
+
|
|
15
|
+
const runView = (
|
|
16
|
+
input: Partial<RunView> & { readonly runId: string; readonly status: RunStatus },
|
|
17
|
+
): RunView => ({
|
|
18
|
+
definition: "scout",
|
|
19
|
+
mode: "single",
|
|
20
|
+
lane: "default",
|
|
21
|
+
conversationId: null,
|
|
22
|
+
taskId: null,
|
|
23
|
+
answer: null,
|
|
24
|
+
durationMs: null,
|
|
25
|
+
children: [],
|
|
26
|
+
missing: [],
|
|
27
|
+
gates: [],
|
|
28
|
+
requests: [],
|
|
29
|
+
diagnostic: null,
|
|
30
|
+
...input,
|
|
31
|
+
});
|
|
32
|
+
|
|
33
|
+
const childView = (
|
|
34
|
+
input: Partial<ChildView> & { readonly child: number; readonly runId: string },
|
|
35
|
+
): ChildView => ({
|
|
36
|
+
conversationId: null,
|
|
37
|
+
taskId: null,
|
|
38
|
+
agent: "scout",
|
|
39
|
+
status: "running",
|
|
40
|
+
answer: null,
|
|
41
|
+
durationMs: null,
|
|
42
|
+
...input,
|
|
43
|
+
});
|
|
44
|
+
|
|
45
|
+
const gateRecord = (input: Partial<GateRecord> & { readonly gate: string }): GateRecord => ({
|
|
46
|
+
runId: "run:one",
|
|
47
|
+
status: "pending",
|
|
48
|
+
tool: "bash",
|
|
49
|
+
taskId: null,
|
|
50
|
+
taskIds: [],
|
|
51
|
+
childRunIds: [],
|
|
52
|
+
requestedAt: 1_000,
|
|
53
|
+
deadline: 0,
|
|
54
|
+
decision: null,
|
|
55
|
+
decidedBy: null,
|
|
56
|
+
reason: null,
|
|
57
|
+
...input,
|
|
58
|
+
});
|
|
59
|
+
|
|
60
|
+
const view = (
|
|
61
|
+
runs: readonly RunView[],
|
|
62
|
+
gates: readonly GateRecord[] = [],
|
|
63
|
+
requests: readonly RequestRecord[] = [],
|
|
64
|
+
): SessionView => ({
|
|
65
|
+
runs,
|
|
66
|
+
lanes: laneViews(runs),
|
|
67
|
+
gates,
|
|
68
|
+
requests,
|
|
69
|
+
reviews: [],
|
|
70
|
+
});
|
|
71
|
+
|
|
72
|
+
const noActivity = new Map<string, RunActivity>();
|
|
73
|
+
|
|
74
|
+
it("the projection lists one parent row and its children, newest run first", () => {
|
|
75
|
+
const fanout = runView({
|
|
76
|
+
runId: "run:fanout",
|
|
77
|
+
definition: "fanout",
|
|
78
|
+
status: "running",
|
|
79
|
+
children: [
|
|
80
|
+
childView({ child: 0, runId: "run:fanout:child:0" }),
|
|
81
|
+
childView({ child: 1, runId: "run:fanout:child:1" }),
|
|
82
|
+
],
|
|
83
|
+
});
|
|
84
|
+
const single = runView({ runId: "run:single", status: "answered" });
|
|
85
|
+
|
|
86
|
+
const snapshot = projectSnapshot({
|
|
87
|
+
view: view([single, fanout]),
|
|
88
|
+
activity: noActivity,
|
|
89
|
+
now: 4_000,
|
|
90
|
+
revision: 1,
|
|
91
|
+
});
|
|
92
|
+
|
|
93
|
+
assert.deepStrictEqual(
|
|
94
|
+
snapshot.rows.map((row) => row.id),
|
|
95
|
+
["run:run:fanout", "child:run:fanout:child:1", "child:run:fanout:child:0", "run:run:single"],
|
|
96
|
+
);
|
|
97
|
+
assert.deepStrictEqual(snapshot.rows[0], {
|
|
98
|
+
id: "run:run:fanout",
|
|
99
|
+
runId: "run:fanout",
|
|
100
|
+
parentId: null,
|
|
101
|
+
childCount: 2,
|
|
102
|
+
label: "fanout",
|
|
103
|
+
lane: "default",
|
|
104
|
+
status: "running",
|
|
105
|
+
conversationId: null,
|
|
106
|
+
taskId: null,
|
|
107
|
+
gates: [],
|
|
108
|
+
requests: [],
|
|
109
|
+
tool: null,
|
|
110
|
+
slot: null,
|
|
111
|
+
idleMs: null,
|
|
112
|
+
durationMs: null,
|
|
113
|
+
diagnostic: null,
|
|
114
|
+
});
|
|
115
|
+
assert.strictEqual(snapshot.rows[1]?.parentId, "run:run:fanout");
|
|
116
|
+
assert.strictEqual(snapshot.rows[1]?.childCount, 0);
|
|
117
|
+
assert.strictEqual(snapshot.rows[3]?.childCount, 0);
|
|
118
|
+
});
|
|
119
|
+
|
|
120
|
+
it("a single run whose definition is named fanout stays one row", () => {
|
|
121
|
+
const named = runView({
|
|
122
|
+
runId: "run:named",
|
|
123
|
+
definition: "fanout",
|
|
124
|
+
status: "running",
|
|
125
|
+
children: [childView({ child: 0, runId: "run:named" })],
|
|
126
|
+
});
|
|
127
|
+
const snapshot = projectSnapshot({
|
|
128
|
+
view: view([named]),
|
|
129
|
+
activity: noActivity,
|
|
130
|
+
now: 4_000,
|
|
131
|
+
revision: 1,
|
|
132
|
+
});
|
|
133
|
+
assert.deepStrictEqual(
|
|
134
|
+
snapshot.rows.map((row) => row.id),
|
|
135
|
+
["run:run:named"],
|
|
136
|
+
);
|
|
137
|
+
assert.strictEqual(snapshot.rows[0]?.childCount, 0);
|
|
138
|
+
assert.strictEqual(snapshot.rows[0]?.parentId, null);
|
|
139
|
+
});
|
|
140
|
+
|
|
141
|
+
it("a projected row carries the committed status, not a live busy marker", () => {
|
|
142
|
+
const snapshot = projectSnapshot({
|
|
143
|
+
view: view([runView({ runId: "run:one", status: "waiting" })]),
|
|
144
|
+
activity: noActivity,
|
|
145
|
+
now: 4_000,
|
|
146
|
+
revision: 1,
|
|
147
|
+
});
|
|
148
|
+
assert.strictEqual(snapshot.rows[0]?.status, "waiting");
|
|
149
|
+
assert.ok(!("busy" in snapshot));
|
|
150
|
+
});
|
|
151
|
+
|
|
152
|
+
it("a projected row carries tool activity and an age", () => {
|
|
153
|
+
const running = runView({ runId: "run:one", status: "running" });
|
|
154
|
+
const snapshot = projectSnapshot({
|
|
155
|
+
view: view([running]),
|
|
156
|
+
activity: new Map<string, RunActivity>([
|
|
157
|
+
["run:one", { tool: "bash", slot: "running", turns: 2, at: 1_000 }],
|
|
158
|
+
]),
|
|
159
|
+
now: 4_000,
|
|
160
|
+
revision: 1,
|
|
161
|
+
});
|
|
162
|
+
const row = snapshot.rows[0];
|
|
163
|
+
assert.strictEqual(row?.tool, "bash");
|
|
164
|
+
assert.strictEqual(row?.slot, "running");
|
|
165
|
+
assert.strictEqual(row?.idleMs, 3_000);
|
|
166
|
+
});
|
|
167
|
+
|
|
168
|
+
it("a projected row without activity is explicit", () => {
|
|
169
|
+
const snapshot = projectSnapshot({
|
|
170
|
+
view: view([runView({ runId: "run:one", status: "running" })]),
|
|
171
|
+
activity: noActivity,
|
|
172
|
+
now: 4_000,
|
|
173
|
+
revision: 1,
|
|
174
|
+
});
|
|
175
|
+
const row = snapshot.rows[0];
|
|
176
|
+
assert.strictEqual(row?.tool, null);
|
|
177
|
+
assert.strictEqual(row?.slot, null);
|
|
178
|
+
assert.strictEqual(row?.idleMs, null);
|
|
179
|
+
});
|
|
180
|
+
|
|
181
|
+
it("a finished row carries a fixed duration and drops stale activity", () => {
|
|
182
|
+
const snapshot = projectSnapshot({
|
|
183
|
+
view: view([runView({ runId: "run:one", status: "stopped", durationMs: 12_000 })]),
|
|
184
|
+
activity: new Map<string, RunActivity>([
|
|
185
|
+
["run:one", { tool: "bash", slot: "running", turns: 2, at: 1_000 }],
|
|
186
|
+
]),
|
|
187
|
+
now: 4_000,
|
|
188
|
+
revision: 1,
|
|
189
|
+
});
|
|
190
|
+
const row = snapshot.rows[0];
|
|
191
|
+
assert.strictEqual(row?.durationMs, 12_000);
|
|
192
|
+
assert.strictEqual(row?.tool, null);
|
|
193
|
+
assert.strictEqual(row?.slot, null);
|
|
194
|
+
assert.strictEqual(row?.idleMs, null);
|
|
195
|
+
});
|
|
196
|
+
|
|
197
|
+
it("a projected row carries the detail the expansion block reads", () => {
|
|
198
|
+
const snapshot = projectSnapshot({
|
|
199
|
+
view: view([
|
|
200
|
+
runView({
|
|
201
|
+
runId: "run:one",
|
|
202
|
+
definition: "deployer",
|
|
203
|
+
lane: "coding",
|
|
204
|
+
status: "waiting",
|
|
205
|
+
conversationId: 7,
|
|
206
|
+
taskId: 12,
|
|
207
|
+
gates: ["deploy"],
|
|
208
|
+
diagnostic: "missing deployer",
|
|
209
|
+
}),
|
|
210
|
+
]),
|
|
211
|
+
activity: noActivity,
|
|
212
|
+
now: 4_000,
|
|
213
|
+
revision: 1,
|
|
214
|
+
});
|
|
215
|
+
const row = snapshot.rows[0];
|
|
216
|
+
assert.deepStrictEqual(row?.gates, ["deploy"]);
|
|
217
|
+
assert.strictEqual(row?.diagnostic, "missing deployer");
|
|
218
|
+
assert.strictEqual(row?.conversationId, 7);
|
|
219
|
+
assert.strictEqual(row?.taskId, 12);
|
|
220
|
+
assert.strictEqual(row?.label, "deployer");
|
|
221
|
+
assert.strictEqual(row?.lane, "coding");
|
|
222
|
+
});
|
|
223
|
+
|
|
224
|
+
it("a projection carries no answer text", () => {
|
|
225
|
+
const snapshot = projectSnapshot({
|
|
226
|
+
view: view([
|
|
227
|
+
runView({
|
|
228
|
+
runId: "run:one",
|
|
229
|
+
status: "answered",
|
|
230
|
+
answer: "deployed",
|
|
231
|
+
children: [
|
|
232
|
+
childView({ child: 0, runId: "run:one", status: "answered", answer: "deployed" }),
|
|
233
|
+
],
|
|
234
|
+
}),
|
|
235
|
+
]),
|
|
236
|
+
activity: noActivity,
|
|
237
|
+
now: 4_000,
|
|
238
|
+
revision: 1,
|
|
239
|
+
});
|
|
240
|
+
for (const row of snapshot.rows) assert.ok(!("answer" in row));
|
|
241
|
+
assert.ok(!JSON.stringify(snapshot).includes("deployed"));
|
|
242
|
+
});
|
|
243
|
+
|
|
244
|
+
it("lane counters in the snapshot equal the existing lane derivation", () => {
|
|
245
|
+
const runs = [
|
|
246
|
+
runView({
|
|
247
|
+
runId: "run:coding",
|
|
248
|
+
lane: "coding",
|
|
249
|
+
status: "running",
|
|
250
|
+
children: [childView({ child: 0, runId: "run:coding", status: "running" })],
|
|
251
|
+
}),
|
|
252
|
+
runView({ runId: "run:review", lane: "review", status: "answered" }),
|
|
253
|
+
];
|
|
254
|
+
const snapshot = projectSnapshot({
|
|
255
|
+
view: view(runs),
|
|
256
|
+
activity: noActivity,
|
|
257
|
+
now: 4_000,
|
|
258
|
+
revision: 1,
|
|
259
|
+
});
|
|
260
|
+
assert.deepStrictEqual(snapshot.lanes, laneViews(runs));
|
|
261
|
+
});
|
|
262
|
+
|
|
263
|
+
it("counters name running, queued, waiting and pending gates", () => {
|
|
264
|
+
const runs = [
|
|
265
|
+
runView({
|
|
266
|
+
runId: "run:fanout",
|
|
267
|
+
definition: "fanout",
|
|
268
|
+
status: "running",
|
|
269
|
+
children: [
|
|
270
|
+
childView({ child: 0, runId: "run:fanout:0", status: "running" }),
|
|
271
|
+
childView({ child: 1, runId: "run:fanout:1", status: "queued" }),
|
|
272
|
+
childView({ child: 2, runId: "run:fanout:2", status: "waiting" }),
|
|
273
|
+
],
|
|
274
|
+
}),
|
|
275
|
+
];
|
|
276
|
+
const gates = [
|
|
277
|
+
gateRecord({ runId: "run:fanout", gate: "deploy", requestedAt: 1_000 }),
|
|
278
|
+
gateRecord({ runId: "run:fanout", gate: "smoke", requestedAt: 2_000 }),
|
|
279
|
+
];
|
|
280
|
+
const snapshot = projectSnapshot({
|
|
281
|
+
view: view(runs, gates),
|
|
282
|
+
activity: noActivity,
|
|
283
|
+
now: 4_000,
|
|
284
|
+
revision: 1,
|
|
285
|
+
});
|
|
286
|
+
assert.deepStrictEqual(snapshot.counts, {
|
|
287
|
+
running: 1,
|
|
288
|
+
queued: 1,
|
|
289
|
+
waiting: 1,
|
|
290
|
+
gates: 2,
|
|
291
|
+
requests: 0,
|
|
292
|
+
});
|
|
293
|
+
const visible = (counts: typeof snapshot.counts): boolean =>
|
|
294
|
+
counts.running + counts.queued + counts.waiting + counts.gates > 0;
|
|
295
|
+
assert.strictEqual(visible(snapshot.counts), true);
|
|
296
|
+
});
|
|
297
|
+
|
|
298
|
+
it("a terminal run stays a row and stops keeping the strip visible", () => {
|
|
299
|
+
const snapshot = projectSnapshot({
|
|
300
|
+
view: view([runView({ runId: "run:one", status: "answered" })]),
|
|
301
|
+
activity: noActivity,
|
|
302
|
+
now: 4_000,
|
|
303
|
+
revision: 1,
|
|
304
|
+
});
|
|
305
|
+
assert.strictEqual(snapshot.rows.length, 1);
|
|
306
|
+
assert.deepStrictEqual(snapshot.counts, {
|
|
307
|
+
running: 0,
|
|
308
|
+
queued: 0,
|
|
309
|
+
waiting: 0,
|
|
310
|
+
gates: 0,
|
|
311
|
+
requests: 0,
|
|
312
|
+
});
|
|
313
|
+
const visible =
|
|
314
|
+
snapshot.counts.running +
|
|
315
|
+
snapshot.counts.queued +
|
|
316
|
+
snapshot.counts.waiting +
|
|
317
|
+
snapshot.counts.gates >
|
|
318
|
+
0;
|
|
319
|
+
assert.strictEqual(visible, false);
|
|
320
|
+
});
|
|
321
|
+
|
|
322
|
+
it("a pending gate carries the fields the expansion block reads", () => {
|
|
323
|
+
const runs = [runView({ runId: "run:one", lane: "coding", status: "waiting" })];
|
|
324
|
+
const snapshot = projectSnapshot({
|
|
325
|
+
view: view(runs, [
|
|
326
|
+
gateRecord({
|
|
327
|
+
runId: "run:one",
|
|
328
|
+
gate: "deploy",
|
|
329
|
+
tool: "bash",
|
|
330
|
+
requestedAt: 1_000,
|
|
331
|
+
childRunIds: ["run:child"],
|
|
332
|
+
}),
|
|
333
|
+
]),
|
|
334
|
+
activity: noActivity,
|
|
335
|
+
now: 4_000,
|
|
336
|
+
revision: 1,
|
|
337
|
+
});
|
|
338
|
+
const gate = snapshot.gates[0];
|
|
339
|
+
assert.strictEqual(gate?.id, "gate:run:one:deploy");
|
|
340
|
+
assert.strictEqual(gate?.runId, "run:one");
|
|
341
|
+
assert.strictEqual(gate?.gate, "deploy");
|
|
342
|
+
assert.strictEqual(gate?.lane, "coding");
|
|
343
|
+
assert.strictEqual(gate?.tool, "bash");
|
|
344
|
+
assert.deepStrictEqual(gate?.childRunIds, ["run:child"]);
|
|
345
|
+
assert.strictEqual(gate?.idleMs, 3_000);
|
|
346
|
+
for (const key of ["decision", "decidedBy", "reason"]) {
|
|
347
|
+
assert.ok(!(key in (gate as object)), `gate row owns ${key}`);
|
|
348
|
+
}
|
|
349
|
+
});
|
|
350
|
+
|
|
351
|
+
it("a child row carries only the gates whose record names that child", () => {
|
|
352
|
+
const runs = [
|
|
353
|
+
runView({
|
|
354
|
+
runId: "run:fanout",
|
|
355
|
+
definition: "fanout",
|
|
356
|
+
lane: "coding",
|
|
357
|
+
status: "waiting",
|
|
358
|
+
gates: ["deploy"],
|
|
359
|
+
children: [
|
|
360
|
+
childView({ child: 0, runId: "run:fanout:child:0", status: "waiting" }),
|
|
361
|
+
childView({ child: 1, runId: "run:fanout:child:1", status: "running" }),
|
|
362
|
+
],
|
|
363
|
+
}),
|
|
364
|
+
];
|
|
365
|
+
const snapshot = projectSnapshot({
|
|
366
|
+
view: view(runs, [
|
|
367
|
+
gateRecord({
|
|
368
|
+
runId: "run:fanout",
|
|
369
|
+
gate: "deploy",
|
|
370
|
+
childRunIds: ["run:fanout:child:0"],
|
|
371
|
+
}),
|
|
372
|
+
]),
|
|
373
|
+
activity: noActivity,
|
|
374
|
+
now: 4_000,
|
|
375
|
+
revision: 1,
|
|
376
|
+
});
|
|
377
|
+
const waitingChild = snapshot.rows.find((row) => row.runId === "run:fanout:child:0");
|
|
378
|
+
const runningChild = snapshot.rows.find((row) => row.runId === "run:fanout:child:1");
|
|
379
|
+
assert.deepStrictEqual(waitingChild?.gates, ["deploy"]);
|
|
380
|
+
assert.deepStrictEqual(runningChild?.gates, []);
|
|
381
|
+
});
|
|
382
|
+
|
|
383
|
+
it("a view larger than the live window keeps the newest rows and reports the omitted count", () => {
|
|
384
|
+
const runs = Array.from({ length: STATUS_RUN_LIMIT }, (_, index) =>
|
|
385
|
+
runView({ runId: `run:${index}`, status: "answered" }),
|
|
386
|
+
);
|
|
387
|
+
const snapshot = projectSnapshot({
|
|
388
|
+
view: { ...view(runs), omitted: 5 },
|
|
389
|
+
activity: noActivity,
|
|
390
|
+
now: 4_000,
|
|
391
|
+
revision: 1,
|
|
392
|
+
});
|
|
393
|
+
assert.strictEqual(snapshot.rows.length, STATUS_RUN_LIMIT);
|
|
394
|
+
assert.strictEqual(snapshot.omitted, 5);
|
|
395
|
+
});
|
|
396
|
+
|
|
397
|
+
it("two projections of the same state are equivalent", () => {
|
|
398
|
+
const runs = [runView({ runId: "run:one", status: "running" })];
|
|
399
|
+
const input = {
|
|
400
|
+
view: view(runs),
|
|
401
|
+
activity: new Map<string, RunActivity>([
|
|
402
|
+
["run:one", { tool: "bash", slot: "running", turns: 1, at: 1_000 }],
|
|
403
|
+
]),
|
|
404
|
+
now: 4_000,
|
|
405
|
+
revision: 1,
|
|
406
|
+
};
|
|
407
|
+
assert.strictEqual(
|
|
408
|
+
InspectorSnapshotEquivalence(projectSnapshot(input), projectSnapshot(input)),
|
|
409
|
+
true,
|
|
410
|
+
);
|
|
411
|
+
});
|
|
412
|
+
|
|
413
|
+
it("one changed age is not equivalent", () => {
|
|
414
|
+
const input = {
|
|
415
|
+
view: view([runView({ runId: "run:one", status: "running" })]),
|
|
416
|
+
activity: new Map<string, RunActivity>([
|
|
417
|
+
["run:one", { tool: "bash", slot: "running", turns: 1, at: 1_000 }],
|
|
418
|
+
]),
|
|
419
|
+
revision: 1,
|
|
420
|
+
};
|
|
421
|
+
assert.strictEqual(
|
|
422
|
+
InspectorSnapshotEquivalence(
|
|
423
|
+
projectSnapshot({ ...input, now: 4_000 }),
|
|
424
|
+
projectSnapshot({ ...input, now: 5_000 }),
|
|
425
|
+
),
|
|
426
|
+
false,
|
|
427
|
+
);
|
|
428
|
+
});
|
|
429
|
+
|
|
430
|
+
it("a revision alone is not a change", () => {
|
|
431
|
+
const input = {
|
|
432
|
+
view: view([runView({ runId: "run:one", status: "running" })]),
|
|
433
|
+
activity: noActivity,
|
|
434
|
+
now: 4_000,
|
|
435
|
+
};
|
|
436
|
+
assert.strictEqual(
|
|
437
|
+
InspectorSnapshotEquivalence(
|
|
438
|
+
projectSnapshot({ ...input, revision: 1 }),
|
|
439
|
+
projectSnapshot({ ...input, revision: 2 }),
|
|
440
|
+
),
|
|
441
|
+
true,
|
|
442
|
+
);
|
|
443
|
+
});
|
|
444
|
+
|
|
445
|
+
const requestRecord = (
|
|
446
|
+
input: Partial<RequestRecord> & { readonly requestId: string },
|
|
447
|
+
): RequestRecord => ({
|
|
448
|
+
runId: "run:one",
|
|
449
|
+
childRunId: "run:one",
|
|
450
|
+
conversationId: 12,
|
|
451
|
+
prompt: "Which environment?",
|
|
452
|
+
options: [
|
|
453
|
+
{ label: "staging", description: null, recommended: false },
|
|
454
|
+
{ label: "production", description: null, recommended: false },
|
|
455
|
+
],
|
|
456
|
+
allowOther: true,
|
|
457
|
+
status: "pending",
|
|
458
|
+
taskIds: [7],
|
|
459
|
+
requestedAt: 1_000,
|
|
460
|
+
deadline: 9_000,
|
|
461
|
+
answer: null,
|
|
462
|
+
answeredBy: null,
|
|
463
|
+
reason: null,
|
|
464
|
+
...input,
|
|
465
|
+
});
|
|
466
|
+
|
|
467
|
+
it("the inspector lists a pending request", () => {
|
|
468
|
+
const record = requestRecord({ requestId: "12:c1" });
|
|
469
|
+
const snapshot = projectSnapshot({
|
|
470
|
+
view: view(
|
|
471
|
+
[runView({ runId: "run:one", status: "waiting", requests: ["12:c1"] })],
|
|
472
|
+
[],
|
|
473
|
+
[record],
|
|
474
|
+
),
|
|
475
|
+
activity: noActivity,
|
|
476
|
+
now: 4_000,
|
|
477
|
+
revision: 1,
|
|
478
|
+
});
|
|
479
|
+
|
|
480
|
+
assert.deepStrictEqual(snapshot.rows[0]?.requests, ["12:c1"]);
|
|
481
|
+
assert.strictEqual(snapshot.requests.length, 1);
|
|
482
|
+
assert.strictEqual(snapshot.requests[0]?.prompt, "Which environment?");
|
|
483
|
+
assert.strictEqual(snapshot.requests[0]?.deadline, 9_000);
|
|
484
|
+
assert.deepStrictEqual(snapshot.requests[0]?.options, ["staging", "production"]);
|
|
485
|
+
assert.strictEqual(snapshot.counts.requests, 1);
|
|
486
|
+
});
|
|
487
|
+
|
|
488
|
+
it("a decided request leaves the fanout child row", () => {
|
|
489
|
+
const record = requestRecord({
|
|
490
|
+
requestId: "12:c1",
|
|
491
|
+
childRunId: "run:fanout:0",
|
|
492
|
+
status: "answered",
|
|
493
|
+
answer: "staging",
|
|
494
|
+
});
|
|
495
|
+
const snapshot = projectSnapshot({
|
|
496
|
+
view: view(
|
|
497
|
+
[
|
|
498
|
+
runView({
|
|
499
|
+
runId: "run:fanout",
|
|
500
|
+
definition: "fanout",
|
|
501
|
+
status: "running",
|
|
502
|
+
children: [childView({ child: 0, runId: "run:fanout:0", status: "running" })],
|
|
503
|
+
}),
|
|
504
|
+
],
|
|
505
|
+
[],
|
|
506
|
+
[record],
|
|
507
|
+
),
|
|
508
|
+
activity: noActivity,
|
|
509
|
+
now: 4_000,
|
|
510
|
+
revision: 1,
|
|
511
|
+
});
|
|
512
|
+
|
|
513
|
+
const child = snapshot.rows.find((row) => row.id === "child:run:fanout:0");
|
|
514
|
+
assert.deepStrictEqual(child?.requests, []);
|
|
515
|
+
assert.strictEqual(snapshot.requests.length, 0);
|
|
516
|
+
});
|
|
517
|
+
|
|
518
|
+
it("an expired request leaves the surfaces", () => {
|
|
519
|
+
const record = requestRecord({ requestId: "12:c1", deadline: 3_000 });
|
|
520
|
+
const snapshot = projectSnapshot({
|
|
521
|
+
view: view([runView({ runId: "run:one", status: "waiting" })], [], [record]),
|
|
522
|
+
activity: noActivity,
|
|
523
|
+
now: 4_000,
|
|
524
|
+
revision: 1,
|
|
525
|
+
});
|
|
526
|
+
|
|
527
|
+
assert.deepStrictEqual(snapshot.rows[0]?.requests, []);
|
|
528
|
+
assert.strictEqual(snapshot.requests.length, 0);
|
|
529
|
+
assert.strictEqual(snapshot.counts.requests, 0);
|
|
530
|
+
});
|