@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.
Files changed (116) hide show
  1. package/CHANGELOG.md +77 -0
  2. package/LICENSE +21 -0
  3. package/OPERATIONS.md +57 -0
  4. package/README.md +448 -2
  5. package/ROADMAP.md +158 -0
  6. package/TESTING.md +1061 -0
  7. package/agents.ts +8 -0
  8. package/examples/README.md +114 -0
  9. package/examples/gated.ts +28 -0
  10. package/index.ts +9 -0
  11. package/package.json +93 -4
  12. package/skills/pi-delegates/SKILL.md +147 -0
  13. package/skills/pi-delegates/references/control.md +159 -0
  14. package/skills/pi-delegates/references/definitions.md +163 -0
  15. package/skills/pi-delegates/references/gates.md +175 -0
  16. package/skills/pi-delegates/references/launch.md +156 -0
  17. package/src/domain/definitions.test.ts +41 -0
  18. package/src/domain/definitions.ts +161 -0
  19. package/src/domain/ids.ts +13 -0
  20. package/src/domain/names.ts +35 -0
  21. package/src/domain/orchestration/admission.ts +78 -0
  22. package/src/domain/orchestration/control.test.ts +1298 -0
  23. package/src/domain/orchestration/control.ts +436 -0
  24. package/src/domain/orchestration/fanout.test.ts +419 -0
  25. package/src/domain/orchestration/fanout.ts +334 -0
  26. package/src/domain/orchestration/gates.test.ts +686 -0
  27. package/src/domain/orchestration/gates.ts +360 -0
  28. package/src/domain/orchestration/launch.test.ts +173 -0
  29. package/src/domain/orchestration/launch.ts +581 -0
  30. package/src/domain/orchestration/requests.test.ts +700 -0
  31. package/src/domain/orchestration/requests.ts +769 -0
  32. package/src/domain/orchestration/review.test.ts +214 -0
  33. package/src/domain/orchestration/review.ts +168 -0
  34. package/src/domain/orchestration/run-wait.test.ts +262 -0
  35. package/src/domain/orchestration/run-wait.ts +256 -0
  36. package/src/domain/orchestration/workflow-section.test.ts +62 -0
  37. package/src/domain/orchestration/workflow-section.ts +99 -0
  38. package/src/domain/orchestration/workflow.test.ts +1425 -0
  39. package/src/domain/orchestration/workflow.ts +705 -0
  40. package/src/domain/run-records.test.ts +27 -0
  41. package/src/domain/run-records.ts +527 -0
  42. package/src/domain/shapes.test.ts +165 -0
  43. package/src/domain/skills.test.ts +466 -0
  44. package/src/domain/skills.ts +97 -0
  45. package/src/domain/tool-schema.test.ts +46 -0
  46. package/src/domain/tool-schema.ts +20 -0
  47. package/src/domain/toolkit.test.ts +201 -0
  48. package/src/domain/toolkit.ts +379 -0
  49. package/src/domain/view.test.ts +739 -0
  50. package/src/domain/view.ts +459 -0
  51. package/src/example.test.ts +15 -0
  52. package/src/extension/commands.test.ts +481 -0
  53. package/src/extension/commands.ts +227 -0
  54. package/src/extension/entry.test.ts +1118 -0
  55. package/src/extension/entry.ts +342 -0
  56. package/src/extension/gate-alerts.test.ts +235 -0
  57. package/src/extension/gate-alerts.ts +143 -0
  58. package/src/extension/guard.test.ts +48 -0
  59. package/src/extension/guard.ts +31 -0
  60. package/src/extension/host-signals.test.ts +20 -0
  61. package/src/extension/host-signals.ts +13 -0
  62. package/src/extension/inspector-command.test.ts +1191 -0
  63. package/src/extension/inspector-command.ts +638 -0
  64. package/src/extension/prompt.test.ts +110 -0
  65. package/src/extension/prompt.ts +50 -0
  66. package/src/extension/request-alerts.test.ts +183 -0
  67. package/src/extension/request-alerts.ts +181 -0
  68. package/src/extension/revocation.test.ts +81 -0
  69. package/src/extension/revocation.ts +84 -0
  70. package/src/extension/shortcut.test.ts +64 -0
  71. package/src/extension/shortcut.ts +105 -0
  72. package/src/extension/tools.test.ts +993 -0
  73. package/src/extension/tools.ts +505 -0
  74. package/src/extension/version.test.ts +123 -0
  75. package/src/extension/version.ts +97 -0
  76. package/src/harness-policy.test.ts +74 -0
  77. package/src/package-manifest.test.ts +157 -0
  78. package/src/presentation/actions.test.ts +221 -0
  79. package/src/presentation/actions.ts +85 -0
  80. package/src/presentation/activity.test.ts +387 -0
  81. package/src/presentation/activity.ts +66 -0
  82. package/src/presentation/close.test.ts +361 -0
  83. package/src/presentation/inspector.test.ts +679 -0
  84. package/src/presentation/inspector.ts +440 -0
  85. package/src/presentation/overlay.test.ts +555 -0
  86. package/src/presentation/overlay.ts +229 -0
  87. package/src/presentation/repaint.test.ts +329 -0
  88. package/src/presentation/shortcut.ts +2 -0
  89. package/src/presentation/snapshot.test.ts +530 -0
  90. package/src/presentation/snapshot.ts +306 -0
  91. package/src/presentation/strip.test.ts +196 -0
  92. package/src/presentation/strip.ts +74 -0
  93. package/src/presentation/wording.test.ts +238 -0
  94. package/src/presentation/wording.ts +222 -0
  95. package/src/runtime/bridge.test.ts +131 -0
  96. package/src/runtime/bridge.ts +134 -0
  97. package/src/runtime/config.test.ts +44 -0
  98. package/src/runtime/config.ts +87 -0
  99. package/src/runtime/context.test.ts +19 -0
  100. package/src/runtime/context.ts +9 -0
  101. package/src/runtime/execution-env.test.ts +35 -0
  102. package/src/runtime/execution-env.ts +15 -0
  103. package/src/runtime/extensions.test.ts +86 -0
  104. package/src/runtime/extensions.ts +140 -0
  105. package/src/runtime/log.test.ts +128 -0
  106. package/src/runtime/log.ts +68 -0
  107. package/src/runtime/mcp.test.ts +1453 -0
  108. package/src/runtime/mcp.ts +938 -0
  109. package/src/runtime/models.test.ts +145 -0
  110. package/src/runtime/models.ts +259 -0
  111. package/src/runtime/observe.test.ts +50 -0
  112. package/src/runtime/observe.ts +150 -0
  113. package/src/runtime/session.test.ts +359 -0
  114. package/src/runtime/session.ts +425 -0
  115. package/src/runtime/timers.test.ts +31 -0
  116. package/src/runtime/timers.ts +10 -0
package/TESTING.md ADDED
@@ -0,0 +1,1061 @@
1
+ # Testing pi-delegates in a new session
2
+
3
+ This checklist runs a local checkout without publishing the package and covers
4
+ every shipped feature: delegation, fanout, review, gates, control, admission,
5
+ skills, workflows, MCP servers, late revocation and the inspector.
6
+
7
+ Run the checks in order in one session. Each check names the prompt to inject
8
+ and the expected result, so a failure names one feature. Checks that cannot be
9
+ forced by hand are in [Automated-only checks](#automated-only-checks).
10
+
11
+ | Prefix | Feature |
12
+ | ------ | --------------------------------------------- |
13
+ | `C` | Session basics, commands, one launch, restart |
14
+ | `F` | Fanout and review |
15
+ | `G` | Gates, alerts and control |
16
+ | `A` | Admission caps |
17
+ | `T` | Toolkit resolution and pattern grammar |
18
+ | `S` | Skills |
19
+ | `W` | Workflows |
20
+ | `M` | MCP servers |
21
+ | `R` | Late revocation |
22
+ | `L` | Failure log |
23
+ | `Q` | Questions from a delegate |
24
+
25
+ ## Prerequisites
26
+
27
+ - Pi `1.6.0` on `PATH`.
28
+ - Node `22.19.0` or newer.
29
+ - Dependencies installed. Run `bun install` at the repository root.
30
+ - A model and login already configured in `~/.pi/agent`. This checklist keeps
31
+ that configuration and redirects only the session store.
32
+
33
+ Back up the two agent files the checks edit, then restore them in
34
+ [Cleanup](#cleanup). Stop if a copy fails: cleanup deletes a file with no
35
+ backup.
36
+
37
+ ```bash
38
+ if [ -f ~/.pi/agent/mcp.json ]; then cp ~/.pi/agent/mcp.json ~/.pi/agent/mcp.json.bak; fi
39
+ if [ -f ~/.pi/agent/delegates.json ]; then cp ~/.pi/agent/delegates.json ~/.pi/agent/delegates.json.bak; fi
40
+ ```
41
+
42
+ ## 1. Isolate the session
43
+
44
+ Create a scratch working directory and a separate session store:
45
+
46
+ ```bash
47
+ mkdir -p /tmp/pi-delegates-test/repo /tmp/pi-delegates-test/sessions
48
+ cd /tmp/pi-delegates-test/repo
49
+ git init
50
+ ```
51
+
52
+ `git init` gives the child tools a repository to read. Add files for the read
53
+ checks:
54
+
55
+ ```bash
56
+ printf 'hello\n' > note.txt
57
+ printf 'alpha\n' > alpha.txt
58
+ printf 'beta\n' > beta.txt
59
+ printf 'hunter2\n' > vault.txt
60
+ ```
61
+
62
+ ## 2. Fixtures
63
+
64
+ Every fixture lives under `/tmp/pi-delegates-test`, outside the checkout, so a
65
+ check never changes the repository.
66
+
67
+ ### 2.1 The fixture package
68
+
69
+ One local package registers the nine test agents. It depends on the checkout,
70
+ so no build or publish step is needed.
71
+
72
+ Create `/tmp/pi-delegates-test/pi-delegates-local/package.json`:
73
+
74
+ ```json
75
+ {
76
+ "name": "pi-delegates-local",
77
+ "private": true,
78
+ "keywords": ["pi-package"],
79
+ "pi": { "extensions": ["./delegates.ts"] }
80
+ }
81
+ ```
82
+
83
+ Create `/tmp/pi-delegates-test/pi-delegates-local/delegates.ts`:
84
+
85
+ ```ts
86
+ import { createDelegatesExtension } from "@ftrdotdev/pi-delegates";
87
+ import { defineAgent } from "@ftrdotdev/pi-delegates/agents";
88
+
89
+ // G1–G5: a bash call that mentions "vault" parks until a person decides.
90
+ const vaultScout = defineAgent({
91
+ name: "vault-scout",
92
+ role: "Gated vault scout",
93
+ prompt: { role: "You run the shell command you are asked for and report its output." },
94
+ tools: ["read", "bash"],
95
+ extensions: ["coding-tools"],
96
+ approval: { gates: [{ name: "vault-access", tools: ["bash"], match: "vault" }] },
97
+ });
98
+
99
+ // W1–W6: a workflow-only definition; its child gets codemode and the runs namespace.
100
+ const composer = defineAgent({
101
+ name: "composer",
102
+ role: "Workflow composer",
103
+ prompt: { role: "You compose workflows from delegated runs." },
104
+ tools: ["read"],
105
+ extensions: ["coding-tools"],
106
+ approval: { gates: [] },
107
+ codemode: "runs",
108
+ });
109
+
110
+ // S1–S3: declares one skill by name.
111
+ const skilled = defineAgent({
112
+ name: "skilled",
113
+ role: "Skill reader",
114
+ prompt: { role: "You follow the skills declared in your instructions." },
115
+ tools: ["read"],
116
+ extensions: ["coding-tools"],
117
+ approval: { gates: [] },
118
+ skills: ["release-notes"],
119
+ });
120
+
121
+ // M1–M7 and M9: selects the whole demo namespace by pattern.
122
+ const mcpScout = defineAgent({
123
+ name: "mcp-scout",
124
+ role: "MCP caller",
125
+ prompt: { role: "You call the tools you are given and report their text." },
126
+ tools: ["read", "mcp__demo__*"],
127
+ extensions: ["coding-tools"],
128
+ approval: { gates: [] },
129
+ });
130
+
131
+ // T2: names an extension this package does not install.
132
+ const broken = defineAgent({
133
+ name: "broken",
134
+ role: "Broken toolkit",
135
+ prompt: { role: "You are never launched." },
136
+ tools: ["read"],
137
+ extensions: ["missing-extension"],
138
+ approval: { gates: [] },
139
+ });
140
+
141
+ // T3: a pattern that does not name its server.
142
+ const greedy = defineAgent({
143
+ name: "greedy",
144
+ role: "Broad pattern",
145
+ prompt: { role: "You are never launched." },
146
+ tools: ["read", "mcp__*"],
147
+ extensions: ["coding-tools"],
148
+ approval: { gates: [] },
149
+ });
150
+
151
+ // T4: a namespace no server offers.
152
+ const absentScout = defineAgent({
153
+ name: "absent-scout",
154
+ role: "Unknown namespace",
155
+ prompt: { role: "You are never launched." },
156
+ tools: ["read", "mcp__absent__*"],
157
+ extensions: ["coding-tools"],
158
+ approval: { gates: [] },
159
+ });
160
+
161
+ // M8: selects an HTTP server's namespace.
162
+ const docsScout = defineAgent({
163
+ name: "docs-scout",
164
+ role: "HTTP MCP caller",
165
+ prompt: { role: "You call the tools you are given and report their text." },
166
+ tools: ["read", "mcp__docs__*"],
167
+ extensions: ["coding-tools"],
168
+ approval: { gates: [] },
169
+ });
170
+
171
+ // Q1–Q9: asks the user one question and waits for the answer.
172
+ const envScout = defineAgent({
173
+ name: "env-scout",
174
+ role: "Environment scout",
175
+ prompt: { role: "Ask which environment to inspect, then inspect it." },
176
+ tools: ["read", "ask"],
177
+ extensions: ["coding-tools", "questions"],
178
+ approval: { gates: [] },
179
+ });
180
+
181
+ export default createDelegatesExtension({
182
+ definitions: [
183
+ vaultScout,
184
+ composer,
185
+ skilled,
186
+ mcpScout,
187
+ docsScout,
188
+ broken,
189
+ greedy,
190
+ absentScout,
191
+ envScout,
192
+ ],
193
+ });
194
+ ```
195
+
196
+ Install the checkout into that package:
197
+
198
+ ```bash
199
+ cd /tmp/pi-delegates-test/pi-delegates-local
200
+ npm install <checkout>/packages/delegates
201
+ ```
202
+
203
+ ### 2.2 The demo MCP server
204
+
205
+ Create `/tmp/pi-delegates-test/repo/mcp-server.mjs`. It offers `echo`, `add`,
206
+ `big` (25 KiB) and `slow` (never answers).
207
+
208
+ ```js
209
+ import { createInterface } from "node:readline";
210
+
211
+ const send = (message) => process.stdout.write(`${JSON.stringify(message)}\n`);
212
+ const reply = (id, result) => send({ jsonrpc: "2.0", id, result });
213
+
214
+ const tools = [
215
+ {
216
+ name: "echo",
217
+ description: "Echo text",
218
+ inputSchema: { type: "object", properties: { text: { type: "string" } } },
219
+ },
220
+ {
221
+ name: "add",
222
+ description: "Add two numbers",
223
+ inputSchema: {
224
+ type: "object",
225
+ properties: { a: { type: "number" }, b: { type: "number" } },
226
+ },
227
+ },
228
+ { name: "big", description: "Return 25 KiB of text", inputSchema: { type: "object" } },
229
+ { name: "slow", description: "Never answers", inputSchema: { type: "object" } },
230
+ ];
231
+
232
+ createInterface({ input: process.stdin }).on("line", (line) => {
233
+ const message = JSON.parse(line);
234
+ if (message.id === undefined) return;
235
+ if (message.method === "initialize") {
236
+ return reply(message.id, {
237
+ protocolVersion: message.params.protocolVersion,
238
+ capabilities: { tools: {} },
239
+ serverInfo: { name: "demo", version: "0.0.0" },
240
+ });
241
+ }
242
+ if (message.method === "ping") return reply(message.id, {});
243
+ if (message.method === "tools/list") return reply(message.id, { tools });
244
+ if (message.method === "tools/call") {
245
+ const { name, arguments: args = {} } = message.params;
246
+ if (name === "slow") return;
247
+ const text =
248
+ name === "echo"
249
+ ? `echo:${args.text}`
250
+ : name === "add"
251
+ ? String(Number(args.a) + Number(args.b))
252
+ : name === "big"
253
+ ? "x".repeat(25600)
254
+ : null;
255
+ if (text === null) {
256
+ return send({ jsonrpc: "2.0", id: message.id, error: { code: -32601, message: "no tool" } });
257
+ }
258
+ return reply(message.id, { content: [{ type: "text", text }] });
259
+ }
260
+ return send({ jsonrpc: "2.0", id: message.id, error: { code: -32601, message: "no method" } });
261
+ });
262
+ ```
263
+
264
+ Create `/tmp/pi-delegates-test/repo/mcp-http-server.mjs` for `M8`:
265
+
266
+ ```js
267
+ import { createServer } from "node:http";
268
+
269
+ createServer((request, response) => {
270
+ if (request.method !== "POST") return response.writeHead(405).end();
271
+ let body = "";
272
+ request.on("data", (chunk) => (body += chunk));
273
+ request.on("end", () => {
274
+ const message = JSON.parse(body);
275
+ const reply = (result) => {
276
+ response.writeHead(200, { "content-type": "application/json" });
277
+ response.end(JSON.stringify({ jsonrpc: "2.0", id: message.id, result }));
278
+ };
279
+ if (message.id === undefined) return response.writeHead(202).end();
280
+ if (message.method === "ping") return reply({});
281
+ if (message.method === "initialize") {
282
+ return reply({
283
+ protocolVersion: message.params.protocolVersion,
284
+ capabilities: { tools: {} },
285
+ serverInfo: { name: "demo-http", version: "0.0.0" },
286
+ });
287
+ }
288
+ if (message.method === "tools/list") {
289
+ return reply({
290
+ tools: [{ name: "echo", inputSchema: { type: "object" } }],
291
+ });
292
+ }
293
+ if (message.method === "tools/call") {
294
+ return reply({
295
+ content: [{ type: "text", text: `http:${request.headers["x-demo-token"] ?? "none"}` }],
296
+ });
297
+ }
298
+ response.writeHead(200, { "content-type": "application/json" });
299
+ response.end(
300
+ JSON.stringify({ jsonrpc: "2.0", id: message.id, error: { code: -32601, message: "no" } }),
301
+ );
302
+ });
303
+ }).listen(8765, "127.0.0.1");
304
+ ```
305
+
306
+ ### 2.3 The MCP config
307
+
308
+ Create `~/.pi/agent/mcp.json`. `direct` exposure makes `M1` one plain tool call:
309
+
310
+ ```json
311
+ {
312
+ "mcpServers": {
313
+ "demo": {
314
+ "command": "node",
315
+ "args": ["/tmp/pi-delegates-test/repo/mcp-server.mjs"],
316
+ "exposure": "direct"
317
+ }
318
+ }
319
+ }
320
+ ```
321
+
322
+ ### 2.4 The skill
323
+
324
+ Create `/tmp/pi-delegates-test/repo/.pi/skills/release-notes/SKILL.md` only when
325
+ `S2` says so. `S1` runs without it:
326
+
327
+ ```md
328
+ ---
329
+ name: release-notes
330
+ description: Write the release notes for one change.
331
+ ---
332
+
333
+ Read the change's tests first. List what a user sees, not what the code does.
334
+ ```
335
+
336
+ ### 2.5 Start Pi
337
+
338
+ ```bash
339
+ cd /tmp/pi-delegates-test/repo
340
+ pi -ne --session-dir /tmp/pi-delegates-test/sessions \
341
+ -e /tmp/pi-delegates-test/pi-delegates-local \
342
+ -e <checkout>/packages/inquiry \
343
+ --skill <checkout>/packages/delegates/skills/pi-delegates
344
+ ```
345
+
346
+ - `-e` loads the fixture package, which imports the checkout.
347
+ - `-e <checkout>/packages/inquiry` loads the `question` tool the parent model
348
+ uses in `Q2`. `-ne` alone leaves it out, so `Q2` cannot test the dialog path.
349
+ - `-ne` disables other extensions, so a globally installed copy cannot load
350
+ twice and `pi-subagents` cannot block. `R1` removes `-ne` on purpose.
351
+ - `--skill` loads the shipped agent skill. `-e` does not load it.
352
+ - `--session-dir` keeps the test sessions out of your normal store.
353
+
354
+ Do not also pass `-e <checkout>/packages/delegates`: two copies register the
355
+ tools twice.
356
+
357
+ ## 3. Session basics (`C`)
358
+
359
+ Inject each prompt by asking the model to call the named tool. The model may
360
+ wrap a call in prose; the expected text is what the tool returns.
361
+
362
+ **`C1` — the listing.** Run `/delegates:list`. Expect one line per definition:
363
+ the three presets and the eight fixtures, in this order:
364
+
365
+ ```text
366
+ scout — Read-only explorer — tools: read — skills: none — gates: none
367
+ builder — Implementation agent — tools: read, bash, write, edit — skills: none — gates: none
368
+ reviewer — Review agent — tools: read — skills: none — gates: none
369
+ vault-scout — Gated vault scout — tools: read, bash — skills: none — gates: vault-access
370
+ composer — Workflow composer — tools: read — skills: none — gates: none
371
+ skilled — Skill reader — tools: read — skills: release-notes — gates: none
372
+ mcp-scout — MCP caller — tools: read, mcp__demo__* — skills: none — gates: none
373
+ docs-scout — HTTP MCP caller — tools: read, mcp__docs__* — skills: none — gates: none
374
+ broken — Broken toolkit — tools: read — skills: none — gates: none
375
+ greedy — Broad pattern — tools: read, mcp__* — skills: none — gates: none
376
+ absent-scout — Unknown namespace — tools: read, mcp__absent__* — skills: none — gates: none
377
+ ```
378
+
379
+ **`C2` — the empty status.** `delegate_status` with `{}`. Expect
380
+ `No delegation runs in this session.`
381
+
382
+ **`C3` — one launch.** `delegate_launch` with:
383
+
384
+ ```json
385
+ {
386
+ "request": {
387
+ "kind": "single",
388
+ "agent": "scout",
389
+ "task": "read note.txt and reply with its only line"
390
+ }
391
+ }
392
+ ```
393
+
394
+ Expect `hello`. A reply that says `No execution environment is configured`
395
+ means the runtime dropped its `env` option, and every read, write and bash call
396
+ inside a delegate would fail.
397
+
398
+ **`C4` — the run row.** `delegate_status` with `{ "run": "<run id>" }`.
399
+ Expect the run line `<run id> scout · answered: hello` and no lane line.
400
+
401
+ **`C5` — the session listing.** Run `/delegates:list` again. Expect the run row
402
+ and the lane line `default: running 0, queued 0, answered 1`.
403
+
404
+ **`C6` — the inspector.** Press `ctrl+space`. Expect the overlay with the
405
+ agents, the run and the footer
406
+ `enter/i inspect · s stop · a approve · d deny · esc close`. Press `escape`.
407
+ Run `/delegates`; expect the overlay again. Run `/delegates` once more; expect
408
+ it to close.
409
+
410
+ **`C7` — the shipped skill.** Run `/skill:pi-delegates`. Expect the
411
+ when-to-delegate rules, the launch shapes and the note that an MCP pattern must
412
+ name its server.
413
+
414
+ **`C8` — write access.** `delegate_launch` with a builder:
415
+
416
+ ```json
417
+ {
418
+ "request": {
419
+ "kind": "single",
420
+ "agent": "builder",
421
+ "task": "create built.txt in the working directory with the word done in it, then reply with done"
422
+ }
423
+ }
424
+ ```
425
+
426
+ Expect `done` and `/tmp/pi-delegates-test/repo/built.txt` holding `done`.
427
+
428
+ ## 4. Fanout and review (`F`)
429
+
430
+ **`F1` — a fanout.** `delegate_launch` with:
431
+
432
+ ```json
433
+ {
434
+ "request": {
435
+ "kind": "fanout",
436
+ "lane": "audit",
437
+ "agents": [
438
+ { "agent": "scout", "task": "read alpha.txt and reply with its only line" },
439
+ { "agent": "scout", "task": "read beta.txt and reply with its only line" }
440
+ ]
441
+ }
442
+ }
443
+ ```
444
+
445
+ Expect the run id and the answer `2 children answered`.
446
+
447
+ **`F2` — the group row.** `delegate_status` with `{ "run": "<run id>" }`.
448
+ Expect `<run id> fanout · fanout · answered · 2 children` and one `child` line
449
+ per child, each `child <n> <child run id> scout answered: <line>`.
450
+
451
+ **`F3` — the lane.** Run `/delegates:list`. Expect
452
+ `audit: running 0, queued 0, answered 2` after the run rows.
453
+
454
+ **`F4` — a review.** `delegate_launch` with:
455
+
456
+ ```json
457
+ {
458
+ "request": {
459
+ "kind": "review",
460
+ "task": "review the top-level layout of this repository and name the files a new contributor should read first",
461
+ "reviewers": [{ "agent": "reviewer" }, { "agent": "reviewer" }]
462
+ }
463
+ }
464
+ ```
465
+
466
+ Expect the aggregate disposition as the answer, for example `accepted`.
467
+
468
+ **`F5` — the review rows.** `delegate_status` with `{ "run": "<run id>" }`.
469
+ Expect the parent row, then `review <run id> <aggregate>`, then one
470
+ `reviewer <n> <child run id> <disposition>` line per reviewer, with its note.
471
+
472
+ ## 5. Gates and control (`G`)
473
+
474
+ **`G1` — a parked child.** `delegate_launch` with:
475
+
476
+ ```json
477
+ {
478
+ "request": {
479
+ "kind": "fanout",
480
+ "lane": "gate-demo",
481
+ "agents": [
482
+ { "agent": "scout", "task": "read alpha.txt and reply with its only line" },
483
+ { "agent": "scout", "task": "read note.txt and reply with its only line" },
484
+ {
485
+ "agent": "vault-scout",
486
+ "task": "run the shell command cat vault.txt and report the output line"
487
+ }
488
+ ]
489
+ }
490
+ }
491
+ ```
492
+
493
+ Expect `Run <run id> waits for gate vault-access.` and one warning notice that
494
+ names the gate and the waiting child. The secret must not appear.
495
+
496
+ **`G2` — the waiting status.** `delegate_status` with `{ "run": "<run id>" }`.
497
+ Expect `waiting on gate vault-access`, `· 3 children`, two answered child lines
498
+ and one waiting child line, and no lane line.
499
+
500
+ **`G3` — approve.** `delegate_control` with:
501
+
502
+ ```json
503
+ { "action": "approve", "run": "<run id>", "gate": "vault-access" }
504
+ ```
505
+
506
+ Expect `approve <run id>: <status>` and the child finishing. A second approve of
507
+ the same gate is refused.
508
+
509
+ **`G4` — deny.** Repeat `G1`, then call:
510
+
511
+ ```json
512
+ { "action": "deny", "run": "<run id>", "gate": "vault-access" }
513
+ ```
514
+
515
+ Expect the child to end denied and the run to settle without running the
516
+ command.
517
+
518
+ **`G5` — the gate line.** With a gate parked, run `/delegates:list`. Expect
519
+ `gate vault-access pending for <run id>`.
520
+
521
+ **`G6` — steer, stop, resume.** Put a short wait in
522
+ `~/.pi/agent/delegates.json` and restart the session:
523
+
524
+ ```json
525
+ { "defaults": { "launchWaitMs": 1000 } }
526
+ ```
527
+
528
+ Launch a builder that runs `sleep 20`. Expect `running` and a run id:
529
+
530
+ ```json
531
+ {
532
+ "request": {
533
+ "kind": "single",
534
+ "agent": "builder",
535
+ "task": "run the shell command sleep 20, then list the files in the working directory"
536
+ }
537
+ }
538
+ ```
539
+
540
+ Then:
541
+
542
+ ```json
543
+ { "action": "steer", "run": "<run id>", "message": "stop the command and answer now" }
544
+ ```
545
+
546
+ Expect `steer <run id>: <status>`; poll until answered. Start another long run,
547
+ call `{ "action": "stop", "run": "<run id>" }` and expect
548
+ `stop <run id>: stopped`.
549
+ Resume it with `{ "action": "resume", "run": "<run id>" }`; expect the same
550
+ run id and a settled status, not a new run. Resume an answered run and expect a
551
+ refusal that names its status.
552
+
553
+ ## 6. Admission (`A`)
554
+
555
+ Keep `launchWaitMs: 1000`. Add caps:
556
+
557
+ ```json
558
+ { "caps": { "laneCap": 1, "sessionCeiling": 2 }, "defaults": { "launchWaitMs": 1000 } }
559
+ ```
560
+
561
+ **`A1` — one running, one queued.** Launch a fanout of two slow builders in a
562
+ fresh lane `caps`:
563
+
564
+ ```json
565
+ {
566
+ "request": {
567
+ "kind": "fanout",
568
+ "lane": "caps",
569
+ "agents": [
570
+ {
571
+ "agent": "builder",
572
+ "task": "run the shell command sleep 15, then reply with first"
573
+ },
574
+ {
575
+ "agent": "builder",
576
+ "task": "run the shell command sleep 15, then reply with second"
577
+ }
578
+ ]
579
+ }
580
+ }
581
+ ```
582
+
583
+ Expect a run id. `delegate_status` with `{ "run": "<run id>" }` shows one child
584
+ `running` and one `queued`; `/delegates:list` shows
585
+ `caps: running 1, queued 1, answered 0`.
586
+
587
+ **`A2` — the queued child starts.** Wait for the first child to end. Expect the
588
+ second to start and both to answer.
589
+
590
+ ## 7. Toolkit resolution (`T`)
591
+
592
+ Each check must fail before a run exists; `/delegates:list` must show no new run.
593
+
594
+ **`T1` — an inline definition cannot widen tools.** Launch `vault-scout` with an
595
+ inline definition that adds `write`:
596
+
597
+ ```json
598
+ {
599
+ "request": {
600
+ "kind": "single",
601
+ "agent": "vault-scout",
602
+ "task": "deploy the service",
603
+ "definition": {
604
+ "name": "vault-scout",
605
+ "role": "narrowed",
606
+ "prompt": { "role": "narrowed" },
607
+ "tools": ["read", "bash", "write"]
608
+ }
609
+ }
610
+ }
611
+ ```
612
+
613
+ Expect a refusal that names `write` and says the inline tools exceed the
614
+ registered set.
615
+
616
+ **`T2` — a missing extension.** Launch `broken`. Expect an error that names
617
+ `missing-extension` and lists the available extensions.
618
+
619
+ **`T3` — a pattern must name its server.** Launch `greedy`. Expect the grammar
620
+ message `Only "mcp__<server>__*" patterns are allowed: mcp__*.` and the
621
+ available namespaces.
622
+
623
+ **`T4` — an unknown namespace.** Launch `absent-scout`. Expect
624
+ `ToolkitUnresolved` that names `mcp__absent__*` and lists `mcp__demo` as the
625
+ available namespace. When a server is configured but not connected (disabled,
626
+ unreferenced or failing), the same message adds
627
+ `Configured but not connected: <names>.`; `M6` shows the disabled form and `M7`
628
+ the failing one.
629
+
630
+ **`T5` — an inline definition cannot declare a skill or enable code mode.**
631
+ Launch `skilled` with an inline definition that sets `skills: ["release-notes"]`:
632
+
633
+ ```json
634
+ {
635
+ "request": {
636
+ "kind": "single",
637
+ "agent": "skilled",
638
+ "task": "write release notes",
639
+ "definition": {
640
+ "name": "skilled",
641
+ "role": "narrowed",
642
+ "prompt": { "role": "narrowed" },
643
+ "tools": ["read"],
644
+ "skills": ["release-notes"]
645
+ }
646
+ }
647
+ }
648
+ ```
649
+
650
+ Expect a refusal naming `skills`. A second request with `"codemode": "runs"` in
651
+ the inline definition is refused the same way.
652
+
653
+ ## 8. Skills (`S`)
654
+
655
+ **`S1` — a missing skill fails the launch.** With no skill directory yet, launch
656
+ `skilled`:
657
+
658
+ ```json
659
+ {
660
+ "request": { "kind": "single", "agent": "skilled", "task": "write release notes" }
661
+ }
662
+ ```
663
+
664
+ Expect a refusal that names `release-notes` and lists the available skills as
665
+ `(none)`.
666
+
667
+ **`S2` — the prompt lists only the declared skill.** Create the skill from
668
+ [2.4](#24-the-skill), then `/quit` and start the session again with `--continue`.
669
+ Launch `skilled` with the task
670
+ `quote the available-skills block of your instructions verbatim`. Expect
671
+ `<name>release-notes</name>`, its description and the `SKILL.md` path, and the
672
+ line `Use the read tool to load a skill's file`. Ask the child to read that path
673
+ and follow it; expect it to quote the body.
674
+
675
+ **`S3` — a non-invokable skill stays out of the prompt.** Add
676
+ `disable-model-invocation: true` to the frontmatter, restart the session, and
677
+ launch `skilled` again. Expect no `available-skills` block. Ask the child to
678
+ read the file; expect it to succeed, because the body is still on disk.
679
+
680
+ **`S4` — the listing shows the declared name.** `/delegates:list` shows
681
+ `skilled — Skill reader — tools: read — skills: release-notes — gates: none` in
682
+ `S1`, `S2` and `S3`.
683
+
684
+ ## 9. Workflows (`W`)
685
+
686
+ **`W1` — a script answers.** `delegate_launch` with:
687
+
688
+ ```json
689
+ {
690
+ "request": {
691
+ "kind": "workflow",
692
+ "agent": "composer",
693
+ "script": "return 'workflow-ok'"
694
+ }
695
+ }
696
+ ```
697
+
698
+ Expect the answer `workflow-ok`. `delegate_status` with the run id shows the
699
+ row `composer · workflow · answered: workflow-ok` and no lane line.
700
+
701
+ **`W2` — two children from one script.** `delegate_launch` with:
702
+
703
+ ```json
704
+ {
705
+ "request": {
706
+ "kind": "workflow",
707
+ "agent": "composer",
708
+ "script": "const a = await tools.launch({ agent: 'scout', task: 'read alpha.txt and reply with its only line' }); const b = await tools.launch({ agent: 'scout', task: 'read beta.txt and reply with its only line' }); return a.answer + ' | ' + b.answer"
709
+ }
710
+ }
711
+ ```
712
+
713
+ Expect `alpha | beta` (or the file lines, in that order). `delegate_status`
714
+ shows both children nested under the workflow, each with its answer.
715
+
716
+ **`W3` — a workflow definition refuses a single launch.** Launch `composer`
717
+ with `kind: "single"`. Expect a refusal that says it runs workflows only and
718
+ names `kind: "workflow"`. No run appears.
719
+
720
+ **`W4` — a non-workflow definition refuses a workflow launch.** Launch `scout`
721
+ with `kind: "workflow"` and `script: "return 1"`. Expect a refusal that names
722
+ `codemode: "runs"`. No run appears.
723
+
724
+ **`W5` — a workflow cannot resume.** Take the `W1` run id and call
725
+ `{ "action": "resume", "run": "<run id>" }`. Expect a refusal that names the
726
+ workflow mode.
727
+
728
+ **`W6` — a script gate.** `delegate_launch` with:
729
+
730
+ ```json
731
+ {
732
+ "request": {
733
+ "kind": "workflow",
734
+ "agent": "composer",
735
+ "script": "const g = await tools.gate({ name: 'ship' }); return g.decision"
736
+ }
737
+ }
738
+ ```
739
+
740
+ With `launchWaitMs` short, expect `running` and a pending gate `script:ship` in
741
+ `/delegates:list`. Approve with
742
+ `{ "action": "approve", "run": "<run id>", "gate": "script:ship" }`; the script
743
+ answers `approved`. Repeat and deny; expect `denied`.
744
+
745
+ ## 10. MCP servers (`M`)
746
+
747
+ Each check edits `~/.pi/agent/mcp.json` and restarts the session. Keep the run
748
+ ids you need and restore the original file in [Cleanup](#cleanup).
749
+
750
+ **`M1` — a direct tool.** With the config from [2.3](#23-the-mcp-config) and
751
+ `"timeout": 2` beside `demo`, restart. Launch `mcp-scout` with:
752
+
753
+ ```json
754
+ {
755
+ "request": {
756
+ "kind": "single",
757
+ "agent": "mcp-scout",
758
+ "task": "call mcp__demo__echo with text hello, then call mcp__demo__add with a 2 and b 3, and report both results"
759
+ }
760
+ }
761
+ ```
762
+
763
+ Expect both `echo:hello` and `5` in the answer.
764
+
765
+ **`M2` — a bounded result.** Launch `mcp-scout` and ask it to call
766
+ `mcp__demo__big` and report the length and the saved path. Expect a short
767
+ answer with the truncation notice, `mcp.output_saved` in
768
+ `<sessionDir>/delegates.log`, and a file under `<sessionDir>/mcp/` holding 25600
769
+ characters.
770
+
771
+ **`M3` — a call timeout.** Launch `mcp-scout` and ask it to call
772
+ `mcp__demo__slow`. Expect an error naming `demo` after about 2 s and one
773
+ `mcp.call_timeout` line in the log. The child must not hang.
774
+
775
+ **`M4` — deferred exposure.** Set `"exposure": "deferred"` on `demo` and
776
+ restart. Launch `mcp-scout` and ask it to find the echo tool with `tool_search`
777
+ and then call it. Expect `echo:hello`; the child's toolkit holds the
778
+ `tool-search` extension, so the model had to load the tool first.
779
+
780
+ **`M5` — one hidden tool stays hidden.** Set `"exposure": "hidden"` and
781
+ `"toolExposure": { "echo": "direct" }`, then restart. Launch `mcp-scout` with
782
+ the task `call mcp__demo__echo with text hello, then call mcp__demo__add with a 2
783
+ and b 3, and report both results`. Expect `echo:hello`, and the model reporting
784
+ that `add` is not available: no `mcp__demo__add` call appears in the transcript.
785
+
786
+ **`M6` — a project override disables the server.** With a global `demo` entry,
787
+ create `/tmp/pi-delegates-test/repo/.pi/mcp.json`:
788
+
789
+ ```json
790
+ { "mcpServers": { "demo": { "enabled": false } } }
791
+ ```
792
+
793
+ Restart and accept the project-trust prompt. Expect no aggregated warning: a
794
+ disabled server is configuration, not a failure. Launching `mcp-scout` fails with
795
+ `ToolkitUnresolved` that names `demo` as configured but not connected, and the
796
+ log holds no `mcp.connect_failed` line. Then set `"enabled": true` in the
797
+ project file and restart: the global `command` still works, which proves the
798
+ override kept it.
799
+
800
+ **`M7` — a failed server degrades.** Change `demo`'s `command` to
801
+ `/nonexistent/demo` and restart. Expect one aggregated warning naming `demo`,
802
+ the session to load, and `/delegates:list` to work. The log holds one
803
+ `mcp.connect_failed` line. Launching `mcp-scout` fails with `ToolkitUnresolved`
804
+ that names `demo` as configured but not connected.
805
+
806
+ **`M8` — an HTTP server and a `${NAME}` header.** Start the HTTP fixture:
807
+
808
+ ```bash
809
+ node /tmp/pi-delegates-test/repo/mcp-http-server.mjs
810
+ ```
811
+
812
+ Add `docs` and remove the bad `demo` command:
813
+
814
+ ```json
815
+ {
816
+ "mcpServers": {
817
+ "docs": {
818
+ "url": "http://127.0.0.1:8765/mcp",
819
+ "headers": { "X-Demo-Token": "${DEMO_TOKEN}" }
820
+ }
821
+ }
822
+ }
823
+ ```
824
+
825
+ Start Pi with `DEMO_TOKEN=abc` in the environment, restart the session, and
826
+ launch `docs-scout`:
827
+
828
+ ```json
829
+ {
830
+ "request": {
831
+ "kind": "single",
832
+ "agent": "docs-scout",
833
+ "task": "call mcp__docs__echo and report its text"
834
+ }
835
+ }
836
+ ```
837
+
838
+ Expect `http:abc`: the header expanded from the environment. With `DEMO_TOKEN`
839
+ unset, restart and expect one `mcp.env_missing` line in the log and the literal
840
+ `${DEMO_TOKEN}` sent instead.
841
+
842
+ **`M9` — codemode exposure.** Set `"exposure": "codemode"` (the default) on
843
+ the working `demo` entry and restart. Launch `mcp-scout` and ask it to call the
844
+ demo server's `echo` tool from a codemode script, with text `hello`, and return
845
+ the text. Expect `echo:hello`. The child selects `codemode` because a
846
+ codemode-exposed MCP tool is selected, and the script calls the tool by the name
847
+ the codemode section shows.
848
+
849
+ ## 11. Late revocation (`R`)
850
+
851
+ **`R1` — `pi-subagents` blocks the start.** In the scratch project, install it
852
+ locally, then start Pi **without `-ne`** and with **`--session <id>`** on the
853
+ same session store. Use the id of the session that launched the runs, not
854
+ `--continue`: `--continue` picks the newest session file in the store, which in
855
+ a shared store can be another session.
856
+
857
+ ```bash
858
+ cd /tmp/pi-delegates-test/repo
859
+ pi install npm:pi-subagents --local
860
+ pi --session-dir /tmp/pi-delegates-test/sessions --session <id> \
861
+ -e /tmp/pi-delegates-test/pi-delegates-local \
862
+ --skill <checkout>/packages/delegates/skills/pi-delegates
863
+ ```
864
+
865
+ Expect one error notice that starts
866
+ `@ftrdotdev/pi-delegates cannot load while pi-subagents is enabled` and ends with
867
+ `Delegates is shutting down.` No `delegate_launch` tool is offered.
868
+ `/delegates:list` prints the same notice and the runs committed before the
869
+ refusal. The log holds one `coexistence.revoked` line.
870
+
871
+ **`R2` — removing it restores the package.** Run
872
+ `pi remove npm:pi-subagents --local`, then `/reload` in the session. Expect the
873
+ three tools again and the earlier runs still listed by `/delegates:list`.
874
+
875
+ ## 12. Restart (`N`)
876
+
877
+ **`N1` — runs survive.** `/quit`, then start again with `--continue` and the
878
+ same `--session-dir`. `/delegates:list` shows the previous runs and
879
+ `delegate_status` with `{}` is not empty.
880
+
881
+ **`N2` — the store path.** Each session's store sits beside its session file:
882
+
883
+ ```bash
884
+ find /tmp/pi-delegates-test/sessions -name 'delegates-*.sqlite'
885
+ ```
886
+
887
+ A refused session reads this file read-only. No shipped command opens it.
888
+
889
+ ## 13. Failure log (`L`)
890
+
891
+ The log is `<sessionDir>/delegates.log`, one JSON object per line. Each line has
892
+ a stable `code` and a `detail` a person reads. Nothing parses `detail`.
893
+
894
+ **`L1` — a config diagnostic.** Put `{` in `~/.pi/agent/delegates.json`, restart,
895
+ and read the log. Expect one `warn` line with `"code":"config.invalid_json"` and
896
+ the file path in `detail`. Restore the file.
897
+
898
+ **`L2` — a cancelled launch.** Start the `G6` launch and press `ctrl+c` while it
899
+ waits. Expect one `wait.aborted` line and a run that ends `stopped`.
900
+
901
+ **`L3` — one line per failure kind.** Across `M1`–`M9`, the log holds at most
902
+ one line per problem: `mcp.connect_failed`, `mcp.env_missing`,
903
+ `mcp.call_timeout`, `mcp.output_saved`. No line holds a header value or a
904
+ secret.
905
+
906
+ ## 14. Questions from a delegate (`Q`)
907
+
908
+ A launch is content-addressed by session and request: repeating the same task
909
+ text returns the run it already started, not a new one. Give each `Q` case a
910
+ distinct task text.
911
+
912
+ **`Q1` — a child asks.** `delegate_launch` with:
913
+
914
+ ```json
915
+ {
916
+ "request": {
917
+ "kind": "single",
918
+ "agent": "env-scout",
919
+ "task": "ask which environment to inspect, then reply with the chosen label"
920
+ }
921
+ }
922
+ ```
923
+
924
+ Expect `Run <run id> waits for request <request id>.` and a run id, not a
925
+ 600-second block. One warning reads `request <request id> asks: Which
926
+ environment?`. One parent message carries the `questions` JSON. With the
927
+ inquiry extension the model can answer in the same turn (`Q2`); without it the
928
+ turn ends at the request and the parent asks in plain text (`Q3`).
929
+
930
+ **`Q2` — answer with the `question` tool.** Let the model ask with its
931
+ `question` tool (the start block loads the inquiry extension), choose `staging`,
932
+ and let it call `delegate_control` with
933
+ `{ "action": "answer", "run": "<run id>", "request": "<request id>", "answer": "staging" }`.
934
+ Expect `answer <run id>: <status>` and `The user answered: staging` in the
935
+ child's transcript.
936
+
937
+ **`Q3` — answer without the `question` tool.** Turn the `question` tool off,
938
+ repeat `Q1`, and answer in plain text. Expect the same verb to work and the same
939
+ child result. The start block keeps the inquiry extension loaded, so the toggle
940
+ removes only that tool.
941
+
942
+ **`Q4` — the manual command.** With a request waiting, `/delegates:answer` with
943
+ no arguments lists the request, then asks for a label or free text. Answer, and
944
+ expect `answer <run id>: answered`. Repeat and use
945
+ `/delegates:answer <run id> <request id> staging`; expect the same result.
946
+
947
+ **`Q5` — a cancelled dialog declines.** Open `/delegates:answer`, pick a
948
+ request, and press escape. Expect `decline <run id>: cancelled`, the child
949
+ getting an error that names `declined`, and no pending request in
950
+ `/delegates:list`. The run settles `denied`, not `answered`: the row reads
951
+ denied, the lane's answered count does not grow, and the wait text reads
952
+ `Run <run id> was denied: request <request id> was declined.`
953
+
954
+ **`Q6` — a second answer is refused.** Answer a request, then repeat the same
955
+ `delegate_control` call. Expect a refusal naming `answered` and no change.
956
+
957
+ **`Q7` — a reload does not repeat.** While a request waits, run `/reload`.
958
+ Expect no second warning. The session holds one `delegates.request-alert` entry
959
+ for the request. The record still reads `pending`, and the strip and
960
+ `/delegates:list` still name it: a reload closes the inspector, not the parked
961
+ child. A `/quit` leaves it pending too; the store survives. `delegate_control
962
+ stop` is the path that cancels: the record commits `cancelled` with reason
963
+ `stopped`, and the log gains one `request.cancelled` line. With the headless
964
+ default, the log also holds one `request.pending` line with the run and request
965
+ ids and no prompt text.
966
+
967
+ **`Q8` — the surfaces.** While a request waits, `/delegates:list` prints
968
+ `request <request id> pending for <run id>`, the inspector row ends with
969
+ `request <request id>`, and expanding the request shows the prompt, the labels
970
+ and the deadline on wrapped lines inside the box.
971
+
972
+ **`Q9` — the viewer is read-only.** From a refused session (see `R1`),
973
+ `/delegates:list` prints the pending request and posts no message.
974
+
975
+ **`Q10` — a late answer is refused as expired.** Leave a request unanswered past
976
+ its 24-hour deadline (a test build with a short deadline is enough), then answer
977
+ it with `delegate_control` or `/delegates:answer`. Expect a refusal naming
978
+ `expired`, the record committed `expired` with reason `deadline`, and no answer
979
+ in the child's transcript. Use a fresh task text, or the launch returns the
980
+ earlier run and no new request appears.
981
+
982
+ ## Automated-only checks
983
+
984
+ These cases are proven by the suite, not by hand:
985
+
986
+ | Case | Test |
987
+ | ----------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------- |
988
+ | A storage failure logs `report.storage_failed` once and closes the runtime | `src/runtime/session.test.ts` |
989
+ | A stored toolkit name that no longer resolves is refused and written to `RunDoc.diagnostics` | `src/domain/orchestration/control.test.ts` |
990
+ | The session view returns the newest 50 runs and counts the rest | `src/domain/view.test.ts` |
991
+ | A timeout leaves no armed timer; a gate wakes the wait | `src/domain/orchestration/run-wait.test.ts` |
992
+ | A request wait resolves on a commit, a spurious advance re-checks, the backstop catches a lost push | `src/domain/orchestration/run-wait.test.ts` |
993
+ | An answer wakes the child, a second answer and an expired answer are refused, and `stop` cancels | `src/domain/orchestration/control.test.ts` |
994
+ | `stop` cancels the parked request and writes one `request.cancelled` line | `src/domain/orchestration/control.test.ts` |
995
+ | A declined request settles the run denied, names the request, and leaves the lane answered count | `src/domain/orchestration/control.test.ts` |
996
+ | The answer command declines only when the answer dialog is cancelled | `src/extension/commands.test.ts` |
997
+ | The picker hides free text when the request forbids it, and a failed direct answer logs one line | `src/extension/commands.test.ts` |
998
+ | A pending request past its deadline expires; the sweep retires old records, drops stray rows and counts one | `src/domain/orchestration/requests.test.ts` |
999
+ | A request with no options must allow free text, or the tool refuses it | `src/domain/orchestration/requests.test.ts` |
1000
+ | An aborted parked call cancels the record once and writes one `request.cancelled` line | `src/domain/orchestration/requests.test.ts` |
1001
+ | A reload announces nothing twice; the log-only host writes one id-only line | `src/extension/request-alerts.test.ts` |
1002
+ | A headless mode writes the id-only line; `tui` and `rpc` use the toast host | `src/extension/request-alerts.test.ts` |
1003
+ | A request index commit republishes the snapshot with the pending request | `src/presentation/inspector.test.ts` |
1004
+ | A request committed after the inspector attached reaches it without a restart (missing attachments retry) | `src/presentation/inspector.test.ts` |
1005
+ | The inspector and the overlay name a pending request, and an expired one leaves them | `src/presentation/snapshot.test.ts`, `src/presentation/overlay.test.ts` |
1006
+ | The request expansion wraps the prompt, labels and deadline to the box | `src/presentation/wording.test.ts` |
1007
+ | A decided request leaves the fanout child row | `src/presentation/snapshot.test.ts` |
1008
+ | The `failFast` policy aborts the other children | `src/domain/orchestration/fanout.test.ts` |
1009
+ | Every inspector string is exact, including the queued count and a gate's child count | `src/presentation/wording.test.ts` |
1010
+ | The timer adapter fires at the delay and `clearTimeout` cancels it | `src/runtime/timers.test.ts` |
1011
+ | A registered definition overrides its preset and a new name joins the catalogue | `src/domain/definitions.test.ts` |
1012
+ | A version 1 toolkit document opens as version 2 with no skills | `src/domain/skills.test.ts` |
1013
+ | A child's prompt lists only its declared skills, and a dropped skill joins the missing list | `src/domain/skills.test.ts` |
1014
+ | A script over 64 KiB is refused before a run exists | `src/domain/orchestration/workflow.test.ts` |
1015
+ | A restart mid-script reattaches without duplicating or re-claiming children | `src/domain/orchestration/workflow.test.ts` |
1016
+ | A script cannot stop or steer its own run | `src/domain/orchestration/workflow.test.ts` |
1017
+ | A connect timeout, a dropped connection and a bounded result are one line and one file | `src/runtime/mcp.test.ts` |
1018
+ | A viewer builds no MCP layer and reports no MCP name missing | `src/runtime/mcp.test.ts` |
1019
+ | A conflict that appears mid-session withdraws the tools and closes the runtime | `src/extension/entry.test.ts` |
1020
+ | A conflict that registers after the start is refused before the first turn | `src/extension/entry.test.ts` |
1021
+ | A refused `/delegates` reads the store read-only | `src/extension/commands.test.ts` |
1022
+
1023
+ Three modules have no test file of their own. The tests that pin them:
1024
+
1025
+ - `src/domain/names.ts` — `src/domain/orchestration/workflow.test.ts`
1026
+ compares the registered snapshot tools with `RUN_TOOL_NAMES` and asserts
1027
+ that the model is offered none of them.
1028
+ - `src/domain/orchestration/admission.ts` —
1029
+ `src/domain/orchestration/fanout.test.ts` calls `available` and `liveCounts`
1030
+ with inspection records and owned tasks.
1031
+ - `src/presentation/shortcut.ts` — `src/extension/shortcut.test.ts` accepts the
1032
+ default and rejects malformed keys; `src/presentation/wording.test.ts`
1033
+ renders it.
1034
+
1035
+ A standalone read-only CLI and panel belong to a separate plan and are not in
1036
+ this package; the read-only runtime behind a refused `/delegates` is covered by
1037
+ the table above.
1038
+
1039
+ ## Cleanup
1040
+
1041
+ Run `/quit`, then restore the files the checks edited and remove the scratch
1042
+ directory:
1043
+
1044
+ ```bash
1045
+ if [ -f ~/.pi/agent/mcp.json.bak ]; then
1046
+ mv ~/.pi/agent/mcp.json.bak ~/.pi/agent/mcp.json
1047
+ else
1048
+ rm -f ~/.pi/agent/mcp.json
1049
+ fi
1050
+ if [ -f ~/.pi/agent/delegates.json.bak ]; then
1051
+ mv ~/.pi/agent/delegates.json.bak ~/.pi/agent/delegates.json
1052
+ else
1053
+ rm -f ~/.pi/agent/delegates.json
1054
+ fi
1055
+ cd /tmp/pi-delegates-test/repo && pi remove npm:pi-subagents --local 2>/dev/null || true
1056
+ rm -rf /tmp/pi-delegates-test
1057
+ ```
1058
+
1059
+ The checklist adds nothing to `~/.pi/agent/settings.json`, so no other
1060
+ `pi remove` step is needed. Delete `~/.pi/agent/mcp.json` only when it did not
1061
+ exist before the run.