gentle-pi 5.0.0 → 5.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 (234) hide show
  1. package/README.md +1 -1
  2. package/assets/agents/gentle-ai-explore.md +3 -6
  3. package/assets/agents/gentle-ai-verify.md +1 -1
  4. package/assets/agents/gentle-ai-worker.md +9 -9
  5. package/assets/agents/jd-fix-agent.md +1 -1
  6. package/assets/agents/jd-judge-a.md +0 -1
  7. package/assets/agents/jd-judge-b.md +0 -1
  8. package/assets/migrations/agent-body-history.json +6 -0
  9. package/assets/orchestrator-full-delegation.md +1 -1
  10. package/assets/orchestrator-maintenance.md +11 -0
  11. package/assets/orchestrator-quota-recovery.md +1 -1
  12. package/assets/orchestrator-skills.md +10 -0
  13. package/assets/orchestrator-verification.md +9 -7
  14. package/assets/orchestrator.md +1 -1
  15. package/bin/gentle-shell.mjs +67 -15
  16. package/contracts/review-provider-contract-mirror/provider-contract.lock.json +10 -10
  17. package/contracts/review-provider-contract-mirror/{v1.6.0 → v1.7.0}/bundle/manifest.json +5 -5
  18. package/contracts/review-provider-contract-mirror/{v1.6.0 → v1.7.0}/bundle/orchestration/pi.md +5 -3
  19. package/contracts/review-provider-contract-mirror/{v1.6.0 → v1.7.0}/bundle/routing/pi.md +1 -1
  20. package/contracts/review-provider-contract-mirror/{v1.6.0 → v1.7.0}/bundle/schemas/lens.schema.json +3 -3
  21. package/contracts/review-provider-contract-mirror/v1.7.0/bundle/vectors/lens.json +1 -0
  22. package/contracts/review-provider-contract-mirror/{v1.6.0 → v1.7.0}/generated/provider-capabilities.baseline.json +3 -3
  23. package/contracts/review-provider-contract-mirror/{v1.6.0 → v1.7.0}/generated/provider-roles.baseline.json +3 -3
  24. package/docs/bundled-install.md +2 -2
  25. package/docs/delegated-verification.md +8 -4
  26. package/docs/desktop-feed.md +15 -6
  27. package/docs/desktop-rpc.md +44 -20
  28. package/docs/gentle-shell-desktop.md +10 -3
  29. package/docs/gentle-shell.md +17 -13
  30. package/docs/install-wizard.md +2 -2
  31. package/docs/odd-preparation-continuity.md +2 -2
  32. package/docs/permission-modes.md +10 -2
  33. package/docs/readme-reference.md +46 -11
  34. package/docs/session-profile-format.md +33 -7
  35. package/docs/work-continuity.md +7 -7
  36. package/docs/yolo-mode.md +1 -1
  37. package/extensions/child-context.ts +2 -11
  38. package/extensions/gentle-agents.ts +47 -28
  39. package/extensions/gentle-ai.ts +573 -353
  40. package/extensions/gentle-desktop-feed.ts +13 -3
  41. package/extensions/gentle-fast.ts +9 -2
  42. package/extensions/gentle-shell.ts +142 -55
  43. package/extensions/gentle-tps.ts +5 -0
  44. package/extensions/quiet-tools.ts +13 -22
  45. package/extensions/skill-registry.ts +9 -1
  46. package/herdr/mods/gentle-agents/snapshot.js +30 -23
  47. package/herdr/mods/gentle-chat/feed.js +6 -0
  48. package/herdr/mods/gentle-chat/main.js +76 -16
  49. package/herdr/mods/gentle-chat/session.js +13 -5
  50. package/herdr/mods/gentle-chat/snapshot.js +30 -23
  51. package/herdr/mods/gentle-chat/ui.js +7 -1
  52. package/herdr/mods/gentle-inspector/main.js +2 -0
  53. package/herdr/mods/gentle-inspector/snapshot.js +30 -23
  54. package/herdr/mods/gentle-palette/main.js +1 -1
  55. package/herdr/mods/gentle-palette/snapshot.js +30 -23
  56. package/herdr/mods/gentle-pane/snapshot.js +30 -23
  57. package/herdr/mods/gentle-sidebar/snapshot.js +30 -23
  58. package/herdr/mods/gentle-spaces/snapshot.js +30 -23
  59. package/herdr/mods/gentle-status/snapshot.js +30 -23
  60. package/herdr/mods/gentle-tabs/main.js +3 -2
  61. package/herdr/mods/gentle-tabs/new-tab.js +9 -0
  62. package/herdr/mods/gentle-tabs/snapshot.js +30 -23
  63. package/herdr/mods/gentle-tokens/snapshot.js +30 -23
  64. package/lib/agent-profiles.ts +50 -10
  65. package/lib/agents-config.ts +59 -4
  66. package/lib/agents-runner.ts +34 -1
  67. package/lib/auto-permission-runtime.ts +2 -1
  68. package/lib/background-jobs-tools.ts +24 -16
  69. package/lib/claude-bridge-config.ts +41 -0
  70. package/lib/desktop-agent-definitions-service.ts +10 -6
  71. package/lib/desktop-command-rpc.ts +71 -0
  72. package/lib/desktop-feed-sources.ts +44 -1
  73. package/lib/desktop-feed.ts +41 -29
  74. package/lib/desktop-rpc-agent-definitions.ts +7 -3
  75. package/lib/desktop-rpc-changes.ts +13 -4
  76. package/lib/desktop-rpc-config.ts +106 -3
  77. package/lib/exploration-budget.ts +3 -7
  78. package/lib/gentle-design.ts +23 -4
  79. package/lib/gentle-shell-desktop.ts +85 -0
  80. package/lib/gentle-shell-launcher.ts +106 -3
  81. package/lib/mcp-config.ts +214 -0
  82. package/lib/native-review-cli.ts +78 -34
  83. package/lib/odd-phase-inference.ts +1 -1
  84. package/lib/orchestrator-mode-policy.ts +25 -12
  85. package/lib/path-consent-fence.ts +113 -0
  86. package/lib/pi-settings.ts +157 -0
  87. package/lib/review-continuation-registry.ts +7 -20
  88. package/lib/review-coordinator.ts +5 -0
  89. package/lib/review-host-relay.ts +2 -35
  90. package/lib/review-integration-v2.ts +31 -12
  91. package/lib/sensitive-paths.ts +22 -2
  92. package/lib/session-profile-freeze.ts +11 -4
  93. package/lib/session-worktree-registry.ts +11 -5
  94. package/lib/shell-card.ts +27 -1
  95. package/lib/shell-changes-view.ts +6 -2
  96. package/lib/shell-changes.ts +94 -37
  97. package/lib/shell-git-worker.ts +158 -0
  98. package/lib/shell-idle-changes.ts +88 -0
  99. package/lib/shell-untracked-cache.ts +142 -0
  100. package/lib/shell-untracked-lines.ts +178 -0
  101. package/lib/tps-policy.ts +85 -0
  102. package/lib/vim-editor-adapter.ts +3 -2
  103. package/lib/voice-artifacts.ts +8 -1
  104. package/lib/voice-install.ts +7 -3
  105. package/lib/yolo-session-policy.ts +2 -2
  106. package/package.json +1 -1
  107. package/runtime/gentle-shell-desktop.mjs +85 -0
  108. package/runtime/gentle-shell-launcher.mjs +106 -3
  109. package/runtime/native-review-cli.mjs +77 -33
  110. package/runtime/review-integration-v2.mjs +31 -12
  111. package/runtime/sensitive-paths.mjs +22 -2
  112. package/scripts/gentle-ai-installer.mjs +10 -10
  113. package/scripts/main-channel.mjs +27 -7
  114. package/scripts/verify-package-files.mjs +13 -12
  115. package/skills/rdd-defect-workflow/SKILL.md +2 -2
  116. package/tests/agent-profiles-workflow.test.ts +102 -0
  117. package/tests/agents-config.test.ts +1 -2
  118. package/tests/agents-protocol.test.ts +1 -1
  119. package/tests/agents-runner.test.ts +94 -2
  120. package/tests/append-system-prompt-route.test.ts +16 -11
  121. package/tests/auto-permission-runtime.test.ts +4 -4
  122. package/tests/bounded-stop-contract.test.ts +50 -62
  123. package/tests/child-context-files.test.ts +6 -6
  124. package/tests/child-web-package.test.ts +1 -1
  125. package/tests/controlled-engineering-editor.test.ts +192 -0
  126. package/tests/controlled-engineering-launch.test.ts +136 -0
  127. package/tests/controlled-engineering.test.ts +244 -0
  128. package/tests/delivery-b-rendered-surfaces.test.ts +1 -1
  129. package/tests/desktop-feed-tool-summaries.test.ts +1 -1
  130. package/tests/desktop-feed-transcript.test.ts +17 -0
  131. package/tests/desktop-feed.test.ts +141 -7
  132. package/tests/desktop-liveness.test.ts +125 -0
  133. package/tests/desktop-persona.test.ts +17 -0
  134. package/tests/desktop-rpc-agent-definitions.test.ts +23 -2
  135. package/tests/desktop-rpc-changes.test.ts +80 -3
  136. package/tests/desktop-rpc-config-mcp-fidelity.test.ts +106 -0
  137. package/tests/desktop-rpc-config-readonly-stores.test.ts +458 -0
  138. package/tests/desktop-rpc-config.test.ts +5 -2
  139. package/tests/desktop-rpc-design.test.ts +21 -0
  140. package/tests/desktop-rpc-session-snapshot-commands.test.ts +50 -0
  141. package/tests/desktop-session-switch.test.ts +237 -0
  142. package/tests/desktop-target-session.test.ts +104 -0
  143. package/tests/destructive-command-guard.test.ts +187 -0
  144. package/tests/devbinary/pi-host-relay.devtest.ts +73 -9
  145. package/tests/exploration-budget.test.ts +2 -26
  146. package/tests/fixtures/primary-session-prompt/gentleman.golden.md +14 -10
  147. package/tests/full-delegation-closure.test.ts +19 -9
  148. package/tests/generic-agent-tools.test.ts +3 -3
  149. package/tests/gentle-agents.test.ts +214 -9
  150. package/tests/gentle-ai-exploration-budget.test.ts +3 -2
  151. package/tests/gentle-ai-installer.test.ts +52 -51
  152. package/tests/gentle-ai.test.ts +29 -5
  153. package/tests/gentle-chat-read-failure.test.ts +74 -0
  154. package/tests/gentle-chat-session-read.test.ts +127 -0
  155. package/tests/gentle-design.test.ts +39 -0
  156. package/tests/gentle-shell-desktop.test.ts +108 -0
  157. package/tests/gentle-shell-launcher-auto-provision.test.ts +152 -0
  158. package/tests/gentle-shell-launcher-machine-output.test.ts +356 -0
  159. package/tests/gentle-shell.test.ts +93 -12
  160. package/tests/gentle-tps.test.ts +57 -0
  161. package/tests/independent-recovery-delivery.test.ts +15 -13
  162. package/tests/installer-preflight.test.ts +3 -2
  163. package/tests/job-turn-end-texts.test.ts +57 -0
  164. package/tests/lazy-module-contradictions-contract.test.ts +1 -2
  165. package/tests/main-channel.test.ts +12 -1
  166. package/tests/maintainer/desktop-rpc.maintest.ts +2 -2
  167. package/tests/native-review-capability-contract.test.ts +7 -1
  168. package/tests/native-review-cli.test.ts +113 -1
  169. package/tests/no-self-pause-contract.test.ts +8 -7
  170. package/tests/odd-phase-inference.test.ts +2 -2
  171. package/tests/odd-routing-canonical-ratchet.test.ts +1 -1
  172. package/tests/odd-routing-contract.test.ts +1 -1
  173. package/tests/orchestrator-budget.test.ts +7 -2
  174. package/tests/orchestrator-prompt-diet-contract.test.ts +5 -5
  175. package/tests/orchestrator-skills-inline-contract.test.ts +26 -0
  176. package/tests/package-manifest.test.ts +11 -16
  177. package/tests/packaged-agent-codemode.test.ts +79 -0
  178. package/tests/path-consent-fence.test.ts +326 -0
  179. package/tests/pi-update-launcher.test.ts +1 -1
  180. package/tests/primary-session-prompt.test.ts +9 -7
  181. package/tests/profile-fast-tier.test.ts +79 -4
  182. package/tests/progress-rule-contract.test.ts +54 -0
  183. package/tests/rdd-delivery-warning.test.ts +42 -4
  184. package/tests/review-actor-tool-deny.test.ts +1 -2
  185. package/tests/review-continuation-registry.test.ts +17 -17
  186. package/tests/review-controller-native-recovery.test.ts +100 -0
  187. package/tests/review-controller-native-routing.test.ts +129 -24
  188. package/tests/review-coordinator.test.ts +14 -0
  189. package/tests/review-host-relay-restart-parity.test.ts +2 -52
  190. package/tests/review-host-relay-routing.test.ts +57 -297
  191. package/tests/review-host-relay.test.ts +0 -46
  192. package/tests/review-integration-v2-forward.test.ts +39 -2
  193. package/tests/review-json-arguments.test.ts +30 -9
  194. package/tests/review-one-call-findings.test.ts +1 -0
  195. package/tests/review-untracked-inventory-replay.test.ts +181 -0
  196. package/tests/runtime-harness.mjs +27 -1
  197. package/tests/sensitive-path-tools.test.ts +155 -4
  198. package/tests/session-profile-extension.test.ts +90 -11
  199. package/tests/session-profile-freeze.test.ts +49 -2
  200. package/tests/session-profile-v1-compat.test.ts +11 -3
  201. package/tests/session-worktree-registry.test.ts +23 -0
  202. package/tests/shell-changes-idle-start.test.ts +510 -0
  203. package/tests/shell-changes-untracked-bound.test.ts +230 -0
  204. package/tests/shell-changes-view.test.ts +8 -2
  205. package/tests/shell-changes.test.ts +134 -0
  206. package/tests/shell-git-runner-stall.test.ts +74 -0
  207. package/tests/shell-git-worker-fallback.test.ts +140 -0
  208. package/tests/shell-git-worker-lifetime.test.ts +91 -0
  209. package/tests/shell-render-cache-runtime.test.ts +256 -3
  210. package/tests/shell-untracked-cache.test.ts +213 -0
  211. package/tests/short-check-routing-contract.test.ts +11 -7
  212. package/tests/skill-registry.test.ts +3 -3
  213. package/tests/support/chat-ui.ts +39 -0
  214. package/tests/t7-recovery-preservation.test.ts +68 -0
  215. package/tests/tps-policy.test.ts +96 -0
  216. package/tests/turn-end-rule-contract.test.ts +155 -0
  217. package/tests/turn-end-scope.test.ts +39 -0
  218. package/tests/verification-scoped-stop-contract.test.ts +1 -1
  219. package/tests/verification-tiers-contract.test.ts +4 -3
  220. package/tests/verify-first-launch-contract.test.ts +19 -7
  221. package/tests/vim-editor-adapter.test.ts +4 -4
  222. package/tests/voice-install.test.ts +97 -11
  223. package/tests/windows-hidden-processes.test.ts +11 -44
  224. package/tests/work-continuity-contract.test.ts +48 -55
  225. package/tests/yolo-session-policy.test.ts +2 -0
  226. package/contracts/review-provider-contract-mirror/v1.6.0/bundle/vectors/lens.json +0 -1
  227. package/extensions/codegraph-tools.ts +0 -437
  228. package/tests/child-codegraph-bootstrap.test.ts +0 -74
  229. package/tests/codegraph-tools.test.ts +0 -554
  230. /package/contracts/review-provider-contract-mirror/{v1.6.0 → v1.7.0}/bundle/README.md +0 -0
  231. /package/contracts/review-provider-contract-mirror/{v1.6.0 → v1.7.0}/bundle/schemas/refuter.schema.json +0 -0
  232. /package/contracts/review-provider-contract-mirror/{v1.6.0 → v1.7.0}/bundle/schemas/targeted-validator.schema.json +0 -0
  233. /package/contracts/review-provider-contract-mirror/{v1.6.0 → v1.7.0}/bundle/vectors/refuter.json +0 -0
  234. /package/contracts/review-provider-contract-mirror/{v1.6.0 → v1.7.0}/bundle/vectors/targeted-validator.json +0 -0
@@ -0,0 +1,57 @@
1
+ import assert from "node:assert/strict";
2
+ import { readFileSync } from "node:fs";
3
+ import test from "node:test";
4
+ import { jobNoticeText, monitorStoppedText } from "../lib/background-jobs-tools.ts";
5
+ import type { JobRecord } from "../lib/background-jobs.ts";
6
+
7
+ const agents = readFileSync(new URL("../extensions/gentle-agents.ts", import.meta.url), "utf8");
8
+
9
+ const job = (overrides: Partial<JobRecord>): JobRecord => ({
10
+ id: "job-1", kind: "command", label: "export", command: "make export", status: "exited", exitCode: 0,
11
+ cwd: "/tmp", ownerSessionId: "s", startedAt: 0, endedAt: 1000, tail: [], outputPath: "/tmp/job-1.log", ...overrides,
12
+ });
13
+ const lastLine = (record: JobRecord) => jobNoticeText(record).split("\n").at(-1);
14
+
15
+ // TypeScript checks the fixture's fields; this structural check guards against bypassing that check.
16
+ test("the notice fixture does not bypass JobRecord checking with an assertion", () => {
17
+ const fixture = readFileSync(import.meta.filename, "utf8").split(/^const job = |^const lastLine = /m)[1];
18
+ assert.ok(fixture, "the JobRecord fixture is present");
19
+ assert.doesNotMatch(fixture, /\bas\s+(?:unknown|JobRecord)\b/);
20
+ });
21
+
22
+ // turn-end-coherence S1: each job outcome is an obstacle, a limit or a plain result, never the same instruction.
23
+ test("a job the user stopped is reported as a limit: no restart, only independent work continues", () => {
24
+ const line = lastLine(job({ status: "stopped", exitCode: null }));
25
+ assert.equal(line, "The user stopped this job: that is an explicit limit on it. Do not restart it; continue only independent authorized work.");
26
+ assert.match(jobNoticeText(job({ status: "stopped", exitCode: null })), /was stopped by the user/);
27
+ });
28
+
29
+ test("a failed job stays an obstacle and a successful one a result to continue from", () => {
30
+ assert.match(lastLine(job({ exitCode: 7 }))!, /^This failure is an obstacle, not the end of the task:/);
31
+ assert.match(lastLine(job({ status: "failed", exitCode: null, error: "spawn failed" }))!, /^This failure is an obstacle/);
32
+ assert.equal(lastLine(job({})), "This result does not end the task: read it and continue the authorized work that depended on this job.");
33
+ });
34
+
35
+ test("a monitor deadline notice reports the configured limit and allows only necessary authorized watching", () => {
36
+ const monitor = job({ kind: "monitor", label: "checks", status: "stopped", exitCode: null, timeoutSeconds: 30, events: 3 });
37
+ assert.equal(monitorStoppedText(monitor, "timeout"),
38
+ 'Monitor job-1 ("checks") reached its 30s timeout after 3 events and ended. This is the limit you set with timeout_seconds, not a failure or a user stop. Start a new monitor only if watching is still needed for authorized work and other limits allow it.\nFull output: /tmp/job-1.log');
39
+ });
40
+
41
+ test("ordinary monitor exit and explicit user stop keep their distinct notices", () => {
42
+ const monitor = job({ kind: "monitor", label: "checks", timeoutSeconds: 30, events: 1 });
43
+ assert.match(jobNoticeText(monitor), /^Monitor job-1 \("checks"\) exited with code 0 after 1s, 1 event\./);
44
+ assert.equal(lastLine(monitor), "This result does not end the task: read it and continue the authorized work that depended on this job.");
45
+ const stopped = { ...monitor, status: "stopped" } as const;
46
+ assert.match(jobNoticeText(stopped), /^Monitor job-1 \("checks"\) was stopped by the user/);
47
+ assert.equal(lastLine(stopped), "The user stopped this job: that is an explicit limit on it. Do not restart it; continue only independent authorized work.");
48
+ });
49
+
50
+ // turn-end-coherence S4: a blocked standalone sleep is not an instruction to end the turn.
51
+ test("the standalone-sleep rejection sends the agent to independent work before waiting", () => {
52
+ const reason = agents.match(/Standalone sleep is blocked while background work is active[^`]*/)?.[0];
53
+ assert.ok(reason, "the rejection reason is present");
54
+ assert.ok(!reason.includes("End the turn now"), "ending the turn is not the first instruction");
55
+ assert.ok(reason.includes("Continue independent in-scope work; end the turn to wait only when none remains."));
56
+ assert.ok(reason.includes("Each completion arrives automatically as a session message and starts a new turn."));
57
+ });
@@ -113,14 +113,13 @@ test("Duplicates: tracking keeps no restatement of step 3 or of the Phase report
113
113
  }
114
114
  });
115
115
 
116
- test("C4: the explorer may get web and MCP work its declared tools do, never shell work", () => {
116
+ test("C4: web and MCP routing follows declared tools and never assigns shell work to the explorer", () => {
117
117
  for (const text of [delegation, card]) {
118
118
  assert.ok(!text.includes("shell, HTTP or MCP work"), "the card still forbids HTTP or MCP work to the explorer");
119
119
  assert.ok(text.includes("never give a read-only explorer shell work"), "the shell restriction must stay");
120
120
  assert.ok(text.includes("Check the agent's declared `tools` in `subagent_list_agents` before launching"));
121
121
  }
122
122
  assert.match(explorer, /^ {2}- web_search$/m, "the explorer declares web tools");
123
- assert.match(explorer, /^ {2}- mcp__codegraph__codegraph_explore$/m, "the explorer declares an MCP tool");
124
123
  assert.doesNotMatch(explorer, /^ {2}- bash$/m, "the explorer declares no shell");
125
124
  });
126
125
 
@@ -458,12 +458,23 @@ async function upgradeWorld({ userGo = null as string | null, pinned = false, ac
458
458
  if (acquireFails) throw new Error("Go verified acquisition failed; nothing was published", { cause: new Error("Conflicting Go destination: /x") });
459
459
  return { goPath: pinnedGo, version: "1.25.14", acquired: true };
460
460
  };
461
- const upgrade = () => runUpgrade({ args: ["--channel", "main"], ctx: s.ctx, platform: "darwin", arch: "arm64", packageRoot: join(s.root, "pkg"),
461
+ const upgrade = (progressStream?: { write: (chunk: string) => void }) => runUpgrade({ progressStream, args: ["--channel", "main"], ctx: s.ctx, platform: "darwin", arch: "arm64", packageRoot: join(s.root, "pkg"),
462
462
  currentVersion: "4.0.0-main.6e7e3a18f794", adapters: { fetch, run, fs: fsPromises, which, acquireGo }, out: () => {} });
463
463
  const builtWith = () => calls.find((call) => call.argv[0] === "install")?.command;
464
464
  return { ...s, calls, pinnedGo, upgrade, builtWith, acquired };
465
465
  }
466
466
 
467
+ test("main upgrade shows active stages and clears progress before a build error", posixOnly, async () => {
468
+ const w = await upgradeWorld({ acquireFails: true });
469
+ const frames: string[] = [];
470
+ try {
471
+ await assert.rejects(w.upgrade({ write: chunk => frames.push(chunk) }), /getting the pinned Go/);
472
+ assert.match(frames.join(""), /Checking main revisions/);
473
+ assert.match(frames.join(""), /Building Gentle AI/);
474
+ assert.equal(frames.at(-1), "\r\x1b[2K");
475
+ } finally { w.cleanup(); }
476
+ });
477
+
467
478
  test("upgrading main uses the installer's pinned Go when the user's Go is missing, older or cannot be checked, and leaves the user's Go as it is", posixOnly, async () => {
468
479
  for (const userGo of [null, "1.24.0", "devel"]) {
469
480
  const w = await upgradeWorld({ userGo, pinned: true });
@@ -248,10 +248,10 @@ test("installed Pi serves Desktop config reads from the existing stores", () =>
248
248
  assert.deepEqual(models.data.value, { worker: { model: "openai/gpt-probe" } });
249
249
 
250
250
  const snapshot = byRequest("config-3").data;
251
- assert.equal(snapshot.state.config.stores.length, 9);
251
+ assert.equal(snapshot.state.config.stores.length, 12);
252
252
  assert.deepEqual(
253
253
  snapshot.state.config.stores.map((entry: any) => entry.store),
254
- ["profiles", "models", "profile_fallbacks", "subagents", "pins", "managed_assets", "persona", "banner", "notifications"],
254
+ ["profiles", "models", "profile_fallbacks", "subagents", "pins", "managed_assets", "persona", "banner", "notifications", "mcp", "pi_settings", "claude_bridge"],
255
255
  );
256
256
  assert.equal(snapshot.state.config.stores[0].status, "ok");
257
257
  assert.equal(JSON.stringify(snapshot).includes("claude-probe"), false, "snapshots stay bounded");
@@ -422,11 +422,17 @@ test("5.0.0 retains the compact-v2 CLI contract for the runtime pin", () => {
422
422
  assert.deepEqual(contract, NATIVE_CLI_CONTRACTS["4.6.0"] as Record<string, boolean>);
423
423
  });
424
424
 
425
+ test("5.1.0 retains the 5.0.0 compact-v2 CLI contract for the runtime pin", () => {
426
+ const contract = NATIVE_CLI_CONTRACTS["5.1.0"] as Record<string, boolean>;
427
+ assert.ok(contract, "the published v5.1.0 runtime must have an explicit capability row");
428
+ assert.deepEqual(contract, NATIVE_CLI_CONTRACTS["5.0.0"] as Record<string, boolean>);
429
+ });
430
+
425
431
  test("no shipped version key was added beyond the pin bump", () => {
426
432
  // Rows are promises to consumers, so a new key only ever appears in a
427
433
  // dedicated commit alongside a pin bump, never as a side effect. v2.2.4 and
428
434
  // v2.3.0 shipped upstream while Pi stayed on 2.2.3 and were never pinned,
429
435
  // so they get no row: a row asserts ground truth measured against a binary
430
436
  // Pi actually ran, and the table only has to be ascending, not gapless.
431
- assert.deepEqual(Object.keys(NATIVE_CLI_CONTRACTS), [...DARK_VERSIONS, "2.2.0", "2.2.1", "2.2.2", "2.2.3", "2.4.0", "2.5.0-rc.3", "2.5.0", "2.6.0", "2.7.0", "2.8.0", "2.8.1", "2.8.2", "2.9.0", "2.9.1", "3.0.0", "3.0.1", "3.1.0", "3.2.1", "3.4.0", "3.5.0", "3.6.0", "3.6.1", "3.7.0", "4.0.0", "4.1.1", "4.2.0", "4.3.1", "4.4.0", "4.5.0", "4.6.0", "5.0.0"]);
437
+ assert.deepEqual(Object.keys(NATIVE_CLI_CONTRACTS), [...DARK_VERSIONS, "2.2.0", "2.2.1", "2.2.2", "2.2.3", "2.4.0", "2.5.0-rc.3", "2.5.0", "2.6.0", "2.7.0", "2.8.0", "2.8.1", "2.8.2", "2.9.0", "2.9.1", "3.0.0", "3.0.1", "3.1.0", "3.2.1", "3.4.0", "3.5.0", "3.6.0", "3.6.1", "3.7.0", "4.0.0", "4.1.1", "4.2.0", "4.3.1", "4.4.0", "4.5.0", "4.6.0", "5.0.0", "5.1.0"]);
432
438
  });
@@ -1,9 +1,12 @@
1
1
  import assert from "node:assert/strict";
2
+ import { execFileSync } from "node:child_process";
2
3
  import { createHash } from "node:crypto";
3
- import { mkdtempSync, readFileSync, realpathSync, rmSync, symlinkSync, writeFileSync } from "node:fs";
4
+ import { existsSync, mkdtempSync, readFileSync, realpathSync, rmSync, symlinkSync, writeFileSync } from "node:fs";
4
5
  import { tmpdir } from "node:os";
5
6
  import { join } from "node:path";
6
7
  import test from "node:test";
8
+ import { setTimeout as delay } from "node:timers/promises";
9
+ import { createGentleAiExtension } from "../extensions/gentle-ai.ts";
7
10
  import {
8
11
  decodeReviewConsentV3,
9
12
  } from "../lib/review-integration-v2.ts";
@@ -1097,6 +1100,115 @@ test("node execFile adapter passes AbortSignal to child_process", async () => {
1097
1100
  await assert.rejects(pending, (error: unknown) => error instanceof Error && error.name === "AbortError");
1098
1101
  });
1099
1102
 
1103
+ test("POSIX review STATUS settles as timed out when the native child ignores SIGTERM", { skip: process.platform === "win32" }, async (t) => {
1104
+ const cwd = realpathSync(mkdtempSync(join(tmpdir(), "gentle-pi-native-status-")));
1105
+ const invocation = join(cwd, "invocation.json");
1106
+ const binary = join(cwd, "gentle-ai.cjs");
1107
+ t.after(() => {
1108
+ try { process.kill(JSON.parse(readFileSync(invocation, "utf8")).pid, "SIGKILL"); } catch { /* Not started, or already reaped. */ }
1109
+ rmSync(cwd, { recursive: true, force: true });
1110
+ });
1111
+ execFileSync("git", ["init", "-q"], { cwd });
1112
+ const status = negotiatedStartStatus(TARGET, ["--contract=gentle-ai.review-integration/v2"]);
1113
+ writeFileSync(binary, `#!${process.execPath}
1114
+ if (!process.argv.includes("--lineage")) {
1115
+ process.stdout.write(${JSON.stringify(JSON.stringify(status))});
1116
+ } else {
1117
+ process.on("SIGTERM", () => {});
1118
+ require("node:fs").writeFileSync(${JSON.stringify(invocation)}, JSON.stringify({ argv: process.argv.slice(2), pid: process.pid }));
1119
+ setTimeout(() => {}, 10_000);
1120
+ }
1121
+ `, { mode: 0o700 });
1122
+ let review: { execute(id: string, parameters: Record<string, unknown>, signal: undefined, onUpdate: undefined, context: unknown): Promise<{ details: Record<string, unknown>; content: unknown }> };
1123
+ createGentleAiExtension({ nativeReviewCli: new NativeReviewCliV216(createNodeExecFileAdapter(), binary, 300), candidateViews: null, processEnv: { GENTLE_AI_TELEMETRY: "0" } })(
1124
+ { on() {}, registerCommand() {}, registerTool(tool: typeof review & { name: string }) { if (tool.name === "gentle_review") review = tool; } } as never);
1125
+ const context = { cwd, hasUI: false, sessionManager: { getSessionId: () => cwd } };
1126
+ const normal = await review!.execute("status-complete", { operation: "status" }, undefined, undefined, context);
1127
+ assert.deepEqual(normal.details, { operation: "status", status: "ready", result: status });
1128
+
1129
+ const lineageId = "stalled-native-status";
1130
+ const pending = review!.execute("status-timeout", { operation: "status", lineageId }, undefined, undefined, context);
1131
+ const result = await Promise.race([pending, delay(1_500, "still pending", { ref: false })]);
1132
+ const { argv, pid } = JSON.parse(readFileSync(invocation, "utf8"));
1133
+ assert.deepEqual(argv, ["review", "status", "--contract", "gentle-ai.review-integration/v2", "--cwd", cwd, "--projection", "workspace", "--lineage", lineageId, "--agent", "pi", "--next-transition"]);
1134
+ assert.notEqual(result, "still pending", "STATUS was still pending 1,500 ms after invocation (native deadline 300 ms)");
1135
+ if (typeof result === "string") return;
1136
+ assert.deepEqual(result.content, [{ type: "text", text: JSON.stringify(result.details) }]);
1137
+ assert.deepEqual({
1138
+ status: result.details.status,
1139
+ outcome: result.details.outcome,
1140
+ mutationPerformed: result.details.mutation_performed,
1141
+ mutationOutcome: result.details.mutation_outcome,
1142
+ nextAction: result.details.next_action,
1143
+ diagnostics: result.details.diagnostics,
1144
+ }, {
1145
+ status: "blocked", outcome: "native-status-timed-out", mutationPerformed: false, mutationOutcome: "none", nextAction: "rerun-native-status",
1146
+ diagnostics: { operation: "review/status", error_code: "timeout", exit_code: 1, timed_out: true, output_limit_exceeded: false },
1147
+ });
1148
+ // Settlement doesn't wait for libuv to reap the signalled child.
1149
+ const reapingDeadline = Date.now() + 1_000;
1150
+ while (Date.now() < reapingDeadline) {
1151
+ try { process.kill(pid, 0); } catch (error) { if ((error as NodeJS.ErrnoException).code === "ESRCH") return; throw error; }
1152
+ await delay(10);
1153
+ }
1154
+ assert.throws(() => process.kill(pid, 0), { code: "ESRCH" }, "timed-out child must not be left running");
1155
+ });
1156
+
1157
+ test("POSIX review STATUS settles as timed out after the native child exits with inherited pipes open", { skip: process.platform === "win32" }, async (t) => {
1158
+ const cwd = realpathSync(mkdtempSync(join(tmpdir(), "gentle-pi-native-status-pipes-")));
1159
+ const invocation = join(cwd, "invocation.json");
1160
+ const binary = join(cwd, "gentle-ai.cjs");
1161
+ const readInvocation = (): { pid: number; descendantPid: number; argv: string[] } => JSON.parse(readFileSync(invocation, "utf8"));
1162
+ t.after(() => {
1163
+ try { process.kill(readInvocation().descendantPid, "SIGKILL"); } catch { /* Not started, or already gone. */ }
1164
+ rmSync(cwd, { recursive: true, force: true });
1165
+ });
1166
+ execFileSync("git", ["init", "-q"], { cwd });
1167
+ writeFileSync(binary, `#!${process.execPath}
1168
+ const { spawn } = require("node:child_process");
1169
+ const { renameSync, writeFileSync } = require("node:fs");
1170
+ const descendant = spawn(process.execPath, ["-e", "setTimeout(() => {}, 30_000)"], { detached: true, stdio: "inherit" });
1171
+ const invocation = ${JSON.stringify(invocation)};
1172
+ writeFileSync(invocation + ".tmp", JSON.stringify({ pid: process.pid, descendantPid: descendant.pid, argv: process.argv.slice(2) }));
1173
+ renameSync(invocation + ".tmp", invocation);
1174
+ process.exit(0);
1175
+ `, { mode: 0o700 });
1176
+ let review: { execute(id: string, parameters: Record<string, unknown>, signal: undefined, onUpdate: undefined, context: unknown): Promise<{ details: Record<string, unknown> }> };
1177
+ createGentleAiExtension({ nativeReviewCli: new NativeReviewCliV216(createNodeExecFileAdapter(), binary, 500), candidateViews: null, processEnv: { GENTLE_AI_TELEMETRY: "0" } })(
1178
+ { on() {}, registerCommand() {}, registerTool(tool: typeof review & { name: string }) { if (tool.name === "gentle_review") review = tool; } } as never);
1179
+ const lineageId = "exited-native-status";
1180
+ const pending = review!.execute("status-open-pipes", { operation: "status", lineageId }, undefined, undefined, { cwd, hasUI: false, sessionManager: { getSessionId: () => cwd } });
1181
+ const limit = delay(1_500, "still pending", { ref: false });
1182
+ const reaped = async () => {
1183
+ while (!existsSync(invocation)) await delay(10, undefined, { ref: false, signal: t.signal });
1184
+ const record = readInvocation();
1185
+ for (;;) {
1186
+ try { process.kill(record.pid, 0); } catch (error) { if ((error as NodeJS.ErrnoException).code === "ESRCH") return record; throw error; }
1187
+ await delay(10, undefined, { ref: false, signal: t.signal });
1188
+ }
1189
+ };
1190
+ const first = await Promise.race([reaped(), pending, limit]);
1191
+ assert.ok(typeof first === "object" && "descendantPid" in first, "the native child must exit before STATUS settles");
1192
+ assert.deepEqual(first.argv, ["review", "status", "--contract", "gentle-ai.review-integration/v2", "--cwd", cwd, "--projection", "workspace", "--lineage", lineageId, "--agent", "pi", "--next-transition"]);
1193
+
1194
+ const result = await Promise.race([pending, limit]);
1195
+ assert.ok(typeof result !== "string", "STATUS must settle without waiting for the descendant to close the pipes");
1196
+ assert.equal(result.details.status, "blocked");
1197
+ assert.equal(result.details.outcome, "native-status-timed-out");
1198
+ assert.equal(result.details.mutation_performed, false);
1199
+ assert.equal(result.details.mutation_outcome, "none");
1200
+ assert.deepEqual(result.details.diagnostics, { operation: "review/status", error_code: "timeout", exit_code: 1, timed_out: true, output_limit_exceeded: false });
1201
+ assert.doesNotThrow(() => process.kill(first.descendantPid, 0), "the descendant is still alive when STATUS settles");
1202
+ });
1203
+
1204
+ test("POSIX non-STATUS adapter calls retain Node's ordinary timeout handling", { skip: process.platform === "win32" }, async () => {
1205
+ const result = await createNodeExecFileAdapter()({
1206
+ file: process.execPath, arguments: ["-e", "setTimeout(() => {}, 10_000)"],
1207
+ cwd: process.cwd(), maxBufferBytes: 1024, timeoutMs: 100,
1208
+ });
1209
+ assert.deepEqual(result, { stdout: "", stderr: "", exitCode: 1, signal: "SIGTERM", timedOut: true, outputLimitExceeded: false });
1210
+ });
1211
+
1100
1212
  // On Windows, killing gentle-ai alone leaves its git children running against
1101
1213
  // the repository index; abort and timeout must take the whole tree down.
1102
1214
  test("node execFile adapter kills the whole process tree on Windows abort and timeout", async () => {
@@ -8,7 +8,7 @@ import { __testing } from "../extensions/gentle-ai.ts";
8
8
  // stop you between the two and pick the second part up later"; every Gentle
9
9
  // cell delivered only the first part and paused by itself. Hedged delivery
10
10
  // wording asks for resumable notes and separate commits, never a stop, and
11
- // the close step must not leave tracked tasks pending without a user stop.
11
+ // the Close step must not leave runnable authorized tasks pending.
12
12
 
13
13
  const REPO_ROOT = join(import.meta.dirname, "..");
14
14
  const read = (relative: string): string => readFileSync(join(REPO_ROOT, relative), "utf8");
@@ -16,7 +16,7 @@ const read = (relative: string): string => readFileSync(join(REPO_ROOT, relative
16
16
  const tracking = read("assets/orchestrator-tracking.md");
17
17
  const core = read("assets/orchestrator.md");
18
18
 
19
- const contextualApproval = 'Interpret short replies such as "yes", "go ahead", or "eso mismo" against the immediately preceding proposal. When the human unambiguously accepts a concrete implementation action they already understand, execute that action within its agreed scope without asking again. Confirming a preference alone does not authorize implementation; genuinely unclear change intent still requires one focused question. Contextual approval never substitutes for provider-owned consent, exact-token authorization, or separate publishing and destructive-action permission.';
19
+ const contextualApproval = 'Read short replies ("yes", "go ahead", "eso mismo") against the preceding proposal. Act within scope on clear, informed approval of a concrete change without asking again. Preference alone is not approval. Ask one focused question if change intent is unclear. Contextual approval never substitutes for provider-owned consent, exact-token authorization, or separate publishing and destructive-action permission.';
20
20
  const informedClarification = 'Clarify scope, constraints, acceptance criteria, and non-goals when needed for the human to understand the action or to resolve consequential uncertainty. Reuse what is already established; after informed approval, proceed without repeating the clarification unless new consequential uncertainty appears.';
21
21
 
22
22
  test("contextual approval continues the agreed action without weakening consent boundaries", () => {
@@ -30,10 +30,11 @@ test("clarification preserves understanding without reopening informed approval"
30
30
 
31
31
  test("resolved subdecisions retain the original authorized objective", () => {
32
32
  const prompt = __testing.buildGentlePrompt("gentleman");
33
- assert.ok(prompt.includes("Resolving an incident or subdecision does not complete or cancel the original authorized objective; resume safe, necessary in-scope steps automatically, using judgment for proportionate recovery and respecting explicit user dispositions."));
33
+ assert.ok(prompt.includes("After resolving an incident or subdecision, automatically resume safe, necessary in-scope work on the original authorized objective. Recover proportionately and respect explicit user dispositions."));
34
34
  assert.ok(!prompt.includes("Investigate pending technical uncertainty"), "the canonical real-human-decision boundary owns that clause");
35
- assert.ok(prompt.includes("only a real human decision, the user's explicit stop, a denial, missing consent, or an exhausted limit stops the work it applies to, never independent authorized work"));
36
- assert.ok(prompt.includes("Missing, partial, unavailable, or declined proof forbids claiming completion of the affected work, never an independently authorized next step"));
35
+ assert.ok(prompt.includes("Only a real human decision, explicit user stop, denial, missing consent, exhausted limit, or failure without a permitted route stops only affected work."));
36
+ assert.ok(prompt.includes("Continue independent authorized work; never abandon runnable work or present an unverified outcome as final."));
37
+ assert.ok(prompt.includes("Missing, partial, unavailable, or declined proof bars claiming completion of affected work, not independent authorized work or required authorized checks in budget."));
37
38
  // cost-speed-painpoints S15 P4: the verifier-setup rules load with the Verification rule, not on every turn.
38
39
  const verification = read("assets/orchestrator-verification.md");
39
40
  for (const sentence of [
@@ -43,7 +44,7 @@ test("resolved subdecisions retain the original authorized objective", () => {
43
44
  assert.ok(verification.includes(sentence), `verification module keeps: ${sentence}`);
44
45
  assert.ok(!prompt.includes(sentence), `always-on prompt no longer carries: ${sentence}`);
45
46
  }
46
- assert.ok(prompt.includes("Do not infer permission for publishing, destructive actions, unrelated scope or native consent from this continuity rule."));
47
+ assert.ok(prompt.includes("Do not infer permission for publishing, destructive actions, unrelated scope or native consent."));
47
48
  });
48
49
 
49
50
  function authorizationSection(): string {
@@ -121,7 +122,7 @@ test("T13: the always-on harness narrows conditional intent and gates Close on p
121
122
  "harness must say hedged delivery wording is not a stop",
122
123
  );
123
124
  assert.ok(
124
- harness.includes("A tracked task ends the turn pending only while it waits on already-launched work, for the affected work a denial, missing consent, the user's explicit stop, or an exhausted limit applies to, or for a genuine human decision still outstanding"),
125
+ harness.includes("A tracked task ends the turn pending only for launched work still running, a real human decision, denial, missing consent, explicit stop, or exhausted limit."),
125
126
  "harness Close step must keep a legitimate pending child or scoped human decision",
126
127
  );
127
128
  assert.ok(harness.includes("Hedged wording is not a stop."), "harness Close step must keep hedged wording out of stops");
@@ -6,7 +6,7 @@ import { inferOddPhase } from "../lib/odd-phase-inference.ts";
6
6
  // working label. Unknown tools and ambiguous shell commands never change it.
7
7
 
8
8
  test("read-only file tools infer exploring", () => {
9
- for (const tool of ["read", "grep", "find", "ls", "codegraph"]) {
9
+ for (const tool of ["read", "grep", "find", "ls"]) {
10
10
  assert.equal(inferOddPhase(tool, { path: "src/index.ts" }), "exploring", tool);
11
11
  }
12
12
  });
@@ -110,7 +110,7 @@ test("a checking segment wins over an exploring segment in the same command", ()
110
110
  // read-only inspection must still read as exploring.
111
111
  test("real compound read-only shell commands infer exploring", () => {
112
112
  for (const command of [
113
- `cd /repo && git rev-parse --show-toplevel && ls -d .codegraph 2>/dev/null; git log -1 --oneline; grep -rniI "bridge" --include=*.ts -l . 2>/dev/null | grep -v node_modules | head -30`,
113
+ `cd /repo && git rev-parse --show-toplevel && ls -d lib 2>/dev/null; git log -1 --oneline; grep -rniI "bridge" --include=*.ts -l . 2>/dev/null | grep -v node_modules | head -30`,
114
114
  `ls ~/work | grep -i -E "shell|pi"; for d in ~/work/a ~/dev/b; do [ -d $d ] && echo "== $d" && cd $d && git log -1 --oneline && grep -rniI "bridge" -l . 2>/dev/null | grep -v node_modules | head -20; done`,
115
115
  `cd ~/w && grep -rniI "bridge" src | grep -v test | head -15; echo ===; cat ~/.config/settings.json 2>/dev/null | head -40; cd ~/repo && git branch -a --contains 6776520be 2>/dev/null | head`,
116
116
  `f=~/.local/bin/tool; ls -la $f; file -h $f; readlink -f $f; head -c 1500 "$(readlink -f $f)" | strings | head -40`,
@@ -216,7 +216,7 @@ const ANCHORS: readonly RoutingAnchor[] = [
216
216
  // wait event, not a human decision. Pi's continuity scopes an explicit stop
217
217
  // to the work it names without restating the boundary.
218
218
  label: "authorized work continues across a pending child",
219
- canonical: "a pending child is a wait event whose completion resumes the turn without asking the human",
219
+ canonical: "A pending child is a wait: completion resumes the turn without asking.",
220
220
  mirrors: [
221
221
  { surface: EXTENSION, includes: "An explicit user stop applies only to the work it names." },
222
222
  ],
@@ -491,7 +491,7 @@ test("ODD protocol is always-on in the rendered system prompt and runs by defaul
491
491
  const orderedClauses = [
492
492
  "Default workflow: Organic Driven Development (MANDATORY)",
493
493
  "predefined workflow of this orchestrator",
494
- "Never describe this workflow only when asked about it: run it.",
494
+ "Every request enters it unasked. Apply it, don't just describe it. Run these steps in this order on every request:",
495
495
  "1. **Authorize.**",
496
496
  "2. **Explore.**",
497
497
  "3. **Resolve uncertainty.**",
@@ -45,7 +45,12 @@ const FIXTURE_PATH = join(import.meta.dirname, "fixtures", "orchestrator.pre-die
45
45
  // cost-speed P14 (PD-81): the Evidence-budget lookup number matches the runtime notice; measured 9,189 -> 9,177 B.
46
46
  // fix/temp-dir-exemption (user decision 2026-11-16): the confinement clause exempts the OS temp directory
47
47
  // (read/write, deleting only what the session or its tools created); approved up to 9,352 B, measured 9,177 -> 9,347 B at the 128-char root.
48
- const BUDGET_BYTES = 9347;
48
+ // gentle-shell#348 rebase (2026-11-16): the parent-inline skill-read duty clause (+49 B over its
49
+ // original base) rides on the current 9,347 B baseline; measured below at the 128-char root.
50
+ // review follow-up (2026-11-16): 9,396 B is the new pin for this candidate — the clause was
51
+ // re-approved with the rebase in issues/348 (budget note, 2026-10-30); the previous 9,352 B cap
52
+ // recorded above predates this candidate's clause and is superseded by this pin.
53
+ const BUDGET_BYTES = 9396;
49
54
  const MIN_CONTROLLED_LONG_ASSETS_ROOT_CHARS = 93;
50
55
 
51
56
  const LAZY_ASSET_NAMES = [
@@ -138,7 +143,7 @@ function measureOrchestratorPromptBytes(assetsDir: string): number {
138
143
  // measuring a shorter render again.
139
144
  const RDD_WORST_CASE_LINE = "Receipt-driven development: unknown (native status unavailable)";
140
145
 
141
- test("getOrchestratorPrompt return value stays within the canonical 9,197 B budget at a short assets root", () => {
146
+ test("getOrchestratorPrompt return value stays within the canonical 9,396 B budget at a short assets root", () => {
142
147
  const rendered = __testing.renderOrchestratorPrompt(representativeProductionAssetsDir);
143
148
  assert.ok(
144
149
  rendered.includes(RDD_WORST_CASE_LINE),
@@ -166,11 +166,11 @@ test("S5 change 5: gentle_odd_phase does not restate the Phase reporting cadence
166
166
  // --- harness-continuity S3: the authorized-work boundary is mode- and RDD-stable ---
167
167
 
168
168
  const CANONICAL_CLOSE = [
169
- "Authorized work continues: runnable in-scope steps run, a pending child is a wait event whose completion resumes the turn without asking the human",
170
- "A tracked task ends the turn pending only while it waits on already-launched work, for the affected work a denial, missing consent, the user's explicit stop, or an exhausted limit applies to, or for a genuine human decision still outstanding",
171
- "only a real human decision, the user's explicit stop, a denial, missing consent, or an exhausted limit stops the work it applies to, never independent authorized work",
172
- "Missing, partial, unavailable, or declined proof forbids claiming completion of the affected work, never an independently authorized next step",
173
- "while a required authorized check the existing budget still allows keeps running",
169
+ "Run authorized in-scope steps. Work through failures with a permitted route. A pending child is a wait: completion resumes the turn without asking.",
170
+ "A tracked task ends the turn pending only for launched work still running, a real human decision, denial, missing consent, explicit stop, or exhausted limit.",
171
+ "Only a real human decision, explicit user stop, denial, missing consent, exhausted limit, or failure without a permitted route stops only affected work.",
172
+ "Continue independent authorized work; never abandon runnable work or present an unverified outcome as final.",
173
+ "Missing, partial, unavailable, or declined proof bars claiming completion of affected work, not independent authorized work or required authorized checks in budget.",
174
174
  "Never turn a report into a blind self-reprompt loop.",
175
175
  ] as const;
176
176
 
@@ -0,0 +1,26 @@
1
+ import assert from "node:assert/strict";
2
+ import { readFileSync } from "node:fs";
3
+ import { join } from "node:path";
4
+ import test from "node:test";
5
+
6
+ const readAsset = (name: string) => readFileSync(join(import.meta.dirname, "..", "assets", name), "utf8");
7
+ const skills = readAsset("orchestrator-skills.md");
8
+ const parentExecution = (skills.split(/^### Parent execution\s*$/m)[1] ?? "")
9
+ .split(/^#{1,6} /m)[0].replace(/\s+/g, " ");
10
+
11
+ // Pin the instructions the parent receives, not the output of a scripted model.
12
+ test("the parent is routed to read the exact indexed skill before acting", () => {
13
+ assert.match(readAsset("orchestrator.md"), /inline\/fallbacks: `orchestrator-skills\.md`/);
14
+ assert.match(parentExecution, /read the exact indexed `SKILL\.md` in this session before acting/);
15
+ });
16
+
17
+ test("the parent follows the skill's output contract only after reading it", () => {
18
+ assert.match(parentExecution, /let the skill's declared `## Output Contract` shape the result, so the reply carries the same contract markers applying the skill directly would produce/);
19
+ assert.match(parentExecution, /Never present contract markers without the in-session read/);
20
+ });
21
+
22
+ test("the parent proceeds unskilled on an unreadable path and adds no attribution line", () => {
23
+ assert.match(parentExecution, /If the indexed path is unreadable, proceed unskilled/);
24
+ assert.doesNotMatch(skills, /Skill (applied|unavailable) \(parent\)/);
25
+ assert.doesNotMatch(parentExecution, /attribution/i);
26
+ });
@@ -61,7 +61,7 @@ const V014_MANAGED_ASSETS = join(
61
61
  // gentle-ai-explore.md as their exemplar (packaged, absent from the v0.13
62
62
  // manifest) after review-refuter.md was retired together with every
63
63
  // Pi-authored adversarial review verdict.
64
- const MANAGED_EXEMPLAR_TOOLS = ["read", "grep", "find", "codegraph", "web_enable", "web_search", "source_check", "fetch_content", "get_search_content", "mcp__codegraph__codegraph_explore"];
64
+ const MANAGED_EXEMPLAR_TOOLS = ["read", "grep", "find", "web_enable", "web_search", "source_check", "fetch_content", "get_search_content", "codemode"];
65
65
  const RETIRED_ADVERSARIAL_AGENTS = ["review-refuter.md", "review-validator.md"];
66
66
 
67
67
  interface ManagedAssetsManifest {
@@ -431,14 +431,14 @@ test("package manifest installs pi-pretty through a wrapper without bundling nat
431
431
  );
432
432
  });
433
433
 
434
- test("package verification binds the published Gentle AI v5.0.0 runtime pin", () => {
434
+ test("package verification binds the published Gentle AI v5.1.0 runtime pin", () => {
435
435
  const installer = readFileSync(join(PACKAGE_ROOT, "scripts", "gentle-ai-installer.mjs"), "utf8");
436
436
  const binary = readFileSync(join(PACKAGE_ROOT, "lib", "gentle-ai-binary.ts"), "utf8");
437
437
  const verifier = readFileSync(join(PACKAGE_ROOT, "scripts", "verify-package-files.mjs"), "utf8");
438
438
 
439
- assert.match(installer, /INSTALLER_VERSION = "5\.0\.0"/);
439
+ assert.match(installer, /INSTALLER_VERSION = "5\.1\.0"/);
440
440
  assert.match(installer, /GENTLE_AI_WINDOWS_SOURCE_PACKAGE.*GENTLE_AI_WINDOWS_SOURCE_MODULE/);
441
- assert.match(installer, /GENTLE_AI_WINDOWS_SOURCE_MODULE_CHECKSUM = "h1:8NBGfEMu\/LsR\/lJxALGNAsvK9\+5SA2htPNueWKXIW24="/);
441
+ assert.match(installer, /GENTLE_AI_WINDOWS_SOURCE_MODULE_CHECKSUM = "h1:SrWjhJn\+hvtGM\+N7O3k5JM3x\+MPxOVDsH4B5QODlYjQ="/);
442
442
  assert.match(installer, /GOTOOLCHAIN: "local"/);
443
443
  assert.match(installer, /GOSUMDB: "sum\.golang\.org"/);
444
444
  assert.match(binary, /GENTLE_AI_VERSION = INSTALLER_VERSION/);
@@ -1583,8 +1583,8 @@ test("gentle-ai-worker packages the exact scoped writer contract", () => {
1583
1583
  "edit",
1584
1584
  "write",
1585
1585
  "bash",
1586
+ "codemode",
1586
1587
  "mem_save",
1587
- "mcp__codegraph__codegraph_explore",
1588
1588
  ]);
1589
1589
  assert.ok(
1590
1590
  tools.every((tool) => !tool.startsWith("subagent_")),
@@ -1703,8 +1703,8 @@ test("package installation gives gentle-ai-worker a loader-compatible scoped ide
1703
1703
  "edit",
1704
1704
  "write",
1705
1705
  "bash",
1706
+ "codemode",
1706
1707
  "mem_save",
1707
- "mcp__codegraph__codegraph_explore",
1708
1708
  ]);
1709
1709
  assert.doesNotMatch(
1710
1710
  readAgentFrontmatter(installedAgentPath),
@@ -1828,8 +1828,8 @@ test("global model routing uses PI_CODING_AGENT_DIR for package-installed agents
1828
1828
  test("normal and forced installation copy generic agents with complete role contracts", () => {
1829
1829
  const previousAgentHome = process.env.GENTLE_PI_AGENT_HOME;
1830
1830
  const expectedTools = {
1831
- "gentle-ai-explore": ["read", "grep", "find", "codegraph", "web_enable", "web_search", "source_check", "fetch_content", "get_search_content", "mcp__codegraph__codegraph_explore"],
1832
- "gentle-ai-verify": ["read", "grep", "find", "bash", "mcp__codegraph__codegraph_explore"],
1831
+ "gentle-ai-explore": ["read", "grep", "find", "web_enable", "web_search", "source_check", "fetch_content", "get_search_content", "codemode"],
1832
+ "gentle-ai-verify": ["read", "grep", "find", "bash", "codemode"],
1833
1833
  } as const;
1834
1834
 
1835
1835
  try {
@@ -1849,12 +1849,7 @@ test("normal and forced installation copy generic agents with complete role cont
1849
1849
  assert.match(source, /generic ODD work/);
1850
1850
  assert.match(source, /Do not (?:fix findings, delegate to child agents|delegate to child agents, commit)/);
1851
1851
  if (name === "gentle-ai-explore") {
1852
- assert.match(source, /cwd-scoped `codegraph` tool/);
1853
- assert.match(source, /never ask it to target another path/);
1854
- assert.match(source, /sole permitted mutation/);
1855
- assert.match(source, /all tracked files, source files, and other project content remain read-only/);
1856
- assert.match(source, /CodeGraph reports that it is unavailable or fails/);
1857
- assert.match(source, /Do not use that fallback before CodeGraph is unavailable or fails/);
1852
+ assert.match(source, /Read and search only\. Do not edit, write, run commands, or mutate project state\./);
1858
1853
  }
1859
1854
  assert.match(source, /Do not (?:edit, write|edit, write, or fix findings)/);
1860
1855
  // Cost/speed S4: reports are compact and never restate the task.
@@ -1949,9 +1944,9 @@ test("pi-pretty wrapper uses cached ESM loading for compiled and pnpm symlink in
1949
1944
  assert.match(wrapper, /quietToolsEnabled/);
1950
1945
  });
1951
1946
 
1952
- test("Gentle Shell v5.0.0 package manifest declares the release version", () => {
1947
+ test("Gentle Shell v5.1.0 package manifest declares the release version", () => {
1953
1948
  const packageJson = readPackageJson();
1954
- assert.equal(packageJson.version, "5.0.0", "the release manifest must be explicitly pinned to v5.0.0");
1949
+ assert.equal(packageJson.version, "5.1.0", "the release manifest must be explicitly pinned to v5.1.0");
1955
1950
  assert.equal(packageJson.scripts?.test, "node scripts/run-test-suite.mjs");
1956
1951
  assert.ok(packageJson.files?.includes("assets/"));
1957
1952
  assert.ok(packageJson.files?.includes("contracts/"));
@@ -0,0 +1,79 @@
1
+ import assert from "node:assert/strict";
2
+ import { readdirSync, readFileSync } from "node:fs";
3
+ import { join } from "node:path";
4
+ import test from "node:test";
5
+
6
+ // `codemode` is the only route that lets a child batch independent tool calls in
7
+ // one model turn and filter their output before it reaches its context, so every
8
+ // packaged agent that discovers, verifies, or implements declares it. The
9
+ // read-only review actors keep their narrow, deny-all allowlist: a script there
10
+ // would widen the sandbox of the lane whose job is to judge, not to act.
11
+ const ROOT = join(import.meta.dirname, "..");
12
+ const AGENTS_DIR = join(ROOT, "assets", "agents");
13
+
14
+ /** Agents whose unit of work is discovery, verification, or implementation. */
15
+ const CODEMODE_AGENTS = [
16
+ "gentle-ai-explore.md",
17
+ "gentle-ai-verify.md",
18
+ "gentle-ai-worker.md",
19
+ "jd-fix-agent.md",
20
+ ] as const;
21
+
22
+ /** Adversarial read-only reviewers: they report findings and never act. */
23
+ const REVIEW_ACTOR_AGENTS = [
24
+ "jd-judge-a.md",
25
+ "jd-judge-b.md",
26
+ "review-risk.md",
27
+ "review-reliability.md",
28
+ "review-resilience.md",
29
+ "review-readability.md",
30
+ ] as const;
31
+
32
+ const CODEMODE_TOOL = "codemode";
33
+
34
+ function readDeclaredTools(file: string): string[] {
35
+ const text = readFileSync(join(AGENTS_DIR, file), "utf8");
36
+ const frontmatter = text.match(/^---\n([\s\S]*?)\n---/)?.[1];
37
+ assert.ok(frontmatter, `${file} must have YAML frontmatter`);
38
+ const lines = frontmatter.split("\n");
39
+ const toolsIndex = lines.findIndex((line) => line === "tools:");
40
+ assert.notEqual(toolsIndex, -1, `${file} must declare tools as a YAML list`);
41
+ const tools: string[] = [];
42
+ for (const line of lines.slice(toolsIndex + 1)) {
43
+ if (!line.startsWith(" - ")) break;
44
+ tools.push(line.slice(4).trim().replace(/^['"]|['"]$/g, ""));
45
+ }
46
+ return tools;
47
+ }
48
+
49
+ test("packaged discovery, verification, and implementation agents declare codemode", () => {
50
+ for (const file of CODEMODE_AGENTS) {
51
+ const tools = readDeclaredTools(file);
52
+ assert.ok(
53
+ tools.includes(CODEMODE_TOOL),
54
+ `${file} must declare ${CODEMODE_TOOL} so its child can batch tool calls in one turn`,
55
+ );
56
+ }
57
+ });
58
+
59
+ test("packaged read-only review actors keep a codemode-free allowlist", () => {
60
+ for (const file of REVIEW_ACTOR_AGENTS) {
61
+ const tools = readDeclaredTools(file);
62
+ assert.ok(
63
+ !tools.includes(CODEMODE_TOOL),
64
+ `${file} is a read-only review actor: ${CODEMODE_TOOL} must not widen its deny-all allowlist`,
65
+ );
66
+ }
67
+ });
68
+
69
+ test("every packaged agent is classified for codemode", () => {
70
+ const classified = new Set<string>([...CODEMODE_AGENTS, ...REVIEW_ACTOR_AGENTS]);
71
+ const packaged = readdirSync(AGENTS_DIR).filter((entry) => entry.endsWith(".md"));
72
+ assert.ok(packaged.length > 0, "gentle-pi must ship packaged agents");
73
+ for (const file of packaged) {
74
+ assert.ok(
75
+ classified.has(file),
76
+ `${file} is not classified for ${CODEMODE_TOOL}: add it to CODEMODE_AGENTS or REVIEW_ACTOR_AGENTS`,
77
+ );
78
+ }
79
+ });