gentle-pi 4.6.0 → 4.7.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 (290) hide show
  1. package/README.md +10 -11
  2. package/assets/agents/gentle-ai-explore.md +1 -0
  3. package/assets/agents/gentle-ai-verify.md +5 -2
  4. package/assets/agents/gentle-ai-worker.md +3 -0
  5. package/assets/agents/jd-fix-agent.md +1 -0
  6. package/assets/agents/jd-judge-a.md +1 -0
  7. package/assets/agents/jd-judge-b.md +1 -0
  8. package/assets/design-canvas/canvas.css +13 -1
  9. package/assets/design-canvas/canvas.js +11 -2
  10. package/assets/install-wizard/wizard.js +1 -0
  11. package/assets/migrations/agent-body-history.json +16 -1
  12. package/assets/orchestrator-delegation-reference.md +4 -4
  13. package/assets/orchestrator-delegation.md +1 -1
  14. package/assets/orchestrator-full-delegation-card.md +65 -0
  15. package/assets/orchestrator-full-delegation.md +34 -0
  16. package/assets/orchestrator-memory.md +3 -3
  17. package/assets/orchestrator-prompts.md +1 -1
  18. package/assets/orchestrator-skills.md +1 -1
  19. package/assets/orchestrator-verification.md +7 -5
  20. package/assets/orchestrator.md +3 -3
  21. package/bin/gentle-shell.mjs +164 -56
  22. package/docs/agent-status.md +61 -0
  23. package/docs/bundled-install.md +7 -5
  24. package/docs/delegated-verification.md +29 -7
  25. package/docs/gentle-agents-activity.md +14 -0
  26. package/docs/gentle-shell.md +54 -16
  27. package/docs/install-wizard.md +1 -1
  28. package/docs/permission-modes.md +9 -4
  29. package/docs/readme-reference.md +75 -30
  30. package/docs/render-cache-performance.md +11 -1
  31. package/docs/review-coordinator.md +33 -0
  32. package/docs/review-request-context.md +19 -0
  33. package/docs/review-windows-acl.md +18 -0
  34. package/docs/voice.md +6 -3
  35. package/docs/yolo-mode.md +5 -5
  36. package/extensions/ask-user-choice.ts +1 -0
  37. package/extensions/ask-user-question.ts +1 -0
  38. package/extensions/child-safety.ts +3 -0
  39. package/extensions/gentle-agent-status.ts +99 -0
  40. package/extensions/gentle-agents.ts +326 -34
  41. package/extensions/gentle-ai.ts +1496 -454
  42. package/extensions/gentle-shell.ts +293 -63
  43. package/extensions/gentle-todo.ts +18 -2
  44. package/extensions/gentle-tps.ts +48 -0
  45. package/extensions/quiet-tools.ts +38 -8
  46. package/extensions/skill-registry.ts +175 -18
  47. package/extensions/startup-banner.ts +30 -3
  48. package/lib/agent-profile-pin.ts +3 -3
  49. package/lib/agent-profiles.ts +160 -2
  50. package/lib/agent-status.ts +105 -0
  51. package/lib/agents-config.ts +46 -0
  52. package/lib/agents-history.ts +24 -5
  53. package/lib/agents-messaging.ts +47 -5
  54. package/lib/agents-runner.ts +183 -12
  55. package/lib/auto-permission-runtime.ts +1 -1
  56. package/lib/bounded-writer-admission.ts +13 -1
  57. package/lib/card-content-policy.ts +8 -6
  58. package/lib/command-palette.ts +133 -17
  59. package/lib/context-backstop.ts +14 -5
  60. package/lib/destructive-command-guard.ts +48 -4
  61. package/lib/execution-surface-guard.ts +20 -0
  62. package/lib/exploration-budget.ts +4 -2
  63. package/lib/gentle-ai-binary.ts +1 -1
  64. package/lib/gentle-design.ts +3 -0
  65. package/lib/gentle-shell-bundled.ts +6 -19
  66. package/lib/gentle-shell-launcher.ts +43 -8
  67. package/lib/herdr-activity.ts +14 -2
  68. package/lib/herdr-busy.ts +45 -0
  69. package/lib/image-attachments.ts +33 -0
  70. package/lib/image-disk-cache.ts +137 -0
  71. package/lib/inprocess-reviewer.ts +270 -140
  72. package/lib/jobs-view.ts +198 -11
  73. package/lib/model-routing-authority.ts +22 -4
  74. package/lib/native-choice-list.ts +20 -2
  75. package/lib/native-review-cli.ts +96 -19
  76. package/lib/orchestrator-mode-policy.ts +105 -0
  77. package/lib/questionnaire/questionnaire-view.ts +105 -12
  78. package/lib/rdd-mode-control.ts +32 -0
  79. package/lib/reply-language-anchor.ts +104 -0
  80. package/lib/review-blocker.ts +92 -0
  81. package/lib/review-candidate-symlink-scan.ts +136 -0
  82. package/lib/review-candidate-view-owner.ts +81 -44
  83. package/lib/review-continuation-registry.ts +99 -0
  84. package/lib/review-coordinator.ts +163 -0
  85. package/lib/review-failure-facts.ts +49 -0
  86. package/lib/review-host-relay.ts +46 -10
  87. package/lib/review-integration-v2.ts +7 -1
  88. package/lib/review-relay-phase-timing.ts +45 -0
  89. package/lib/review-start-context.ts +17 -0
  90. package/lib/session-profile-freeze.ts +4 -2
  91. package/lib/shell-bar.ts +140 -58
  92. package/lib/shell-changes.ts +2 -0
  93. package/lib/shell-panel.ts +17 -3
  94. package/lib/shell-sidebar-layout.ts +112 -40
  95. package/lib/shell-sidebar.ts +7 -0
  96. package/lib/shell-todo.ts +10 -3
  97. package/lib/verifier-admission.ts +1 -1
  98. package/lib/visual-customization-policy.ts +36 -16
  99. package/lib/visual-customize-view.ts +216 -21
  100. package/lib/visual-layout-preview.ts +9 -5
  101. package/lib/visual-profiles.ts +2 -2
  102. package/lib/windows-session-transport.ts +53 -2
  103. package/lib/yolo-session-policy.ts +40 -15
  104. package/package.json +2 -1
  105. package/runtime/gentle-ai-binary.mjs +1 -1
  106. package/runtime/gentle-shell-bundled.mjs +6 -19
  107. package/runtime/gentle-shell-launcher.mjs +42 -7
  108. package/runtime/native-review-cli.mjs +93 -16
  109. package/runtime/review-integration-v2.mjs +7 -1
  110. package/scripts/build-full-delegation-card.mjs +175 -0
  111. package/scripts/bundled-install.mjs +38 -8
  112. package/scripts/download-progress.mjs +68 -0
  113. package/scripts/gentle-ai-installer.mjs +41 -18
  114. package/scripts/gentle-ai-proxy.mjs +294 -0
  115. package/scripts/install-gentle-ai.mjs +14 -1
  116. package/scripts/installer-preflight.mjs +5 -5
  117. package/scripts/installer-runner.mjs +27 -12
  118. package/scripts/installer-server.mjs +8 -7
  119. package/scripts/render-cache-host.mjs +72 -0
  120. package/scripts/render-cache-performance-worker.mjs +5 -4
  121. package/scripts/render-cache-performance.mjs +6 -1
  122. package/scripts/run-test-suite.mjs +40 -28
  123. package/scripts/verify-package-files.mjs +12 -2
  124. package/scripts/voice-worker.cjs +32 -6
  125. package/skills/design/SKILL.md +11 -8
  126. package/skills/gentle-ai/SKILL.md +2 -2
  127. package/skills/gentle-ui-design/SKILL.md +46 -0
  128. package/skills/gentle-ui-design/references/adaptive-interfaces.md +46 -0
  129. package/skills/gentle-ui-design/references/browse-and-compare.md +62 -0
  130. package/skills/gentle-ui-design/references/composition-and-feedback.md +56 -0
  131. package/skills/gentle-ui-design/references/task-and-content.md +60 -0
  132. package/skills/skill-registry/SKILL.md +4 -2
  133. package/skills/work-unit-commits/SKILL.md +6 -7
  134. package/tests/agent-home.test.ts +28 -9
  135. package/tests/agent-profiles-workflow.test.ts +163 -0
  136. package/tests/agent-risk-escalation.test.ts +1 -1
  137. package/tests/agent-status.test.ts +143 -0
  138. package/tests/agents-config.test.ts +96 -0
  139. package/tests/agents-history.test.ts +31 -0
  140. package/tests/agents-jobs-frames.test.ts +93 -0
  141. package/tests/agents-prompt-lifecycle-runtime.test.ts +376 -0
  142. package/tests/agents-runner-drain.test.ts +193 -0
  143. package/tests/agents-runner.test.ts +178 -2
  144. package/tests/append-system-prompt-route.test.ts +4 -1
  145. package/tests/ask-user-choice.test.ts +4 -3
  146. package/tests/ask-user-question.test.ts +97 -0
  147. package/tests/auto-permission-runtime.test.ts +1 -1
  148. package/tests/autonomous-guard.test.ts +346 -10
  149. package/tests/bounded-stop-contract.test.ts +43 -3
  150. package/tests/bridge-cost.test.ts +19 -4
  151. package/tests/bundled-install.test.ts +30 -5
  152. package/tests/card-content-policy.test.ts +3 -3
  153. package/tests/chained-pr-skill.test.ts +8 -6
  154. package/tests/child-safety.test.ts +11 -0
  155. package/tests/codegraph-tools.test.ts +11 -5
  156. package/tests/command-palette.test.ts +284 -1
  157. package/tests/delegate-for-reason-contract.test.ts +3 -3
  158. package/tests/design-canvas-assets.test.ts +185 -2
  159. package/tests/destructive-command-guard.test.ts +52 -0
  160. package/tests/download-progress.test.ts +71 -0
  161. package/tests/execution-surface-guard.test.ts +55 -0
  162. package/tests/fixtures/primary-session-prompt/gentleman.golden.md +9 -5
  163. package/tests/fixtures/proxy-tls/proxy.crt +19 -0
  164. package/tests/fixtures/proxy-tls/proxy.key +28 -0
  165. package/tests/fixtures/session-profile-v1/gentle-ai-reviewer.ts +89 -0
  166. package/tests/fixtures/session-profile-v1/replay.ts +53 -6
  167. package/tests/full-delegation-closure.test.ts +131 -0
  168. package/tests/full-delegation-notices.test.ts +76 -0
  169. package/tests/generic-agent-tools.test.ts +3 -3
  170. package/tests/gentle-agent-status.test.ts +74 -0
  171. package/tests/gentle-agents-child-jobs.test.ts +237 -0
  172. package/tests/gentle-agents.test.ts +1070 -12
  173. package/tests/gentle-ai-binary.test.ts +3 -1
  174. package/tests/gentle-ai-elapsed-store.test.ts +19 -0
  175. package/tests/gentle-ai-exploration-budget.test.ts +18 -2
  176. package/tests/gentle-ai-installer.test.ts +134 -51
  177. package/tests/gentle-ai-proxy.test.ts +434 -0
  178. package/tests/gentle-ai.test.ts +113 -38
  179. package/tests/gentle-design.test.ts +21 -0
  180. package/tests/gentle-herdr-activity.test.ts +9 -6
  181. package/tests/gentle-shell-bin.test.ts +123 -0
  182. package/tests/gentle-shell-bundled.test.ts +207 -31
  183. package/tests/gentle-shell-launcher.test.ts +77 -10
  184. package/tests/gentle-shell.test.ts +899 -59
  185. package/tests/gentle-todo.test.ts +19 -2
  186. package/tests/gentle-tps.test.ts +123 -0
  187. package/tests/gentle-ui-design-skill.test.ts +59 -0
  188. package/tests/herdr-busy.test.ts +59 -0
  189. package/tests/herdr-task-summary-policy.test.ts +8 -4
  190. package/tests/image-disk-cache.test.ts +163 -0
  191. package/tests/independent-recovery-delivery.test.ts +83 -0
  192. package/tests/inprocess-reviewer.test.ts +176 -4
  193. package/tests/installer-posix-bootstrap.test.ts +1 -1
  194. package/tests/installer-preflight.test.ts +5 -4
  195. package/tests/installer-runner.test.ts +79 -44
  196. package/tests/installer-server.test.ts +14 -11
  197. package/tests/jobs-view.test.ts +260 -6
  198. package/tests/modal-mouse-boundaries.test.ts +136 -0
  199. package/tests/model-routing-authority.test.ts +178 -2
  200. package/tests/native-choice-list.test.ts +77 -2
  201. package/tests/native-review-capability-contract.test.ts +7 -1
  202. package/tests/native-review-cli.test.ts +269 -1
  203. package/tests/no-self-pause-contract.test.ts +4 -1
  204. package/tests/odd-routing-canonical-ratchet.test.ts +3 -3
  205. package/tests/orchestrator-budget.test.ts +7 -2
  206. package/tests/orchestrator-delegation-mode.test.ts +153 -0
  207. package/tests/orchestrator-mode-policy.test.ts +175 -0
  208. package/tests/orchestrator-prompt-budget.test.ts +3 -1
  209. package/tests/orchestrator-rdd-ownership.test.ts +2 -2
  210. package/tests/package-manifest.test.ts +11 -9
  211. package/tests/permission-allowlist.test.ts +202 -0
  212. package/tests/pi-update-launcher.test.ts +8 -0
  213. package/tests/pnpm-workspace-config.test.ts +58 -0
  214. package/tests/primary-session-prompt.test.ts +13 -0
  215. package/tests/profile-pin.test.ts +29 -2
  216. package/tests/profile-tier-footer.test.ts +5 -0
  217. package/tests/profiles-panel-delegation-mode.test.ts +422 -0
  218. package/tests/questionnaire-view.test.ts +115 -0
  219. package/tests/quiet-bash-runtime.test.ts +1 -1
  220. package/tests/quiet-tool-rendering.test.ts +48 -0
  221. package/tests/rdd-aware-verification-contract.test.ts +16 -11
  222. package/tests/rdd-customize.test.ts +287 -0
  223. package/tests/rdd-mode-cache.test.ts +450 -0
  224. package/tests/rdd-mode-control.test.ts +407 -0
  225. package/tests/rdd-mode-scope-regression.test.ts +137 -0
  226. package/tests/rdd-off-independent-regression.test.ts +69 -0
  227. package/tests/rdd-status-line.test.ts +18 -0
  228. package/tests/render-cache-performance.test.ts +171 -2
  229. package/tests/reply-language-anchor.test.ts +173 -0
  230. package/tests/review-agent-end-preflight.test.ts +1 -1
  231. package/tests/review-blocker.test.ts +193 -0
  232. package/tests/review-candidate-owner-retry.test.ts +1 -1
  233. package/tests/review-candidate-symlink-scan.test.ts +157 -0
  234. package/tests/review-candidate-view.test.ts +1 -1
  235. package/tests/review-candidate-windows-boundary.test.ts +131 -0
  236. package/tests/review-candidate-windows-probe.test.ts +63 -0
  237. package/tests/review-committed-restart-ack.test.ts +129 -0
  238. package/tests/review-continuation-registry.test.ts +76 -0
  239. package/tests/review-controller-native-routing.test.ts +261 -5
  240. package/tests/review-controller-workspace-root.test.ts +230 -3
  241. package/tests/review-controller.test.ts +96 -11
  242. package/tests/review-coordinator-runtime.test.ts +117 -0
  243. package/tests/review-coordinator.test.ts +195 -0
  244. package/tests/review-failure-facts.test.ts +87 -0
  245. package/tests/review-host-relay-routing.test.ts +258 -4
  246. package/tests/review-host-relay.test.ts +39 -0
  247. package/tests/review-integration-v2.test.ts +46 -3
  248. package/tests/review-json-arguments.test.ts +65 -10
  249. package/tests/review-last-event-closure.test.ts +68 -0
  250. package/tests/review-loadout-rdd-off-sdk.test.ts +65 -31
  251. package/tests/review-owner-identity.test.ts +60 -24
  252. package/tests/review-relay-phase-timing.test.ts +128 -0
  253. package/tests/review-relay-transport-agent.test.ts +12 -2
  254. package/tests/review-reviewer-evidence.test.ts +183 -0
  255. package/tests/review-risk-assessment.test.ts +74 -3
  256. package/tests/review-session-standing-permission-controller.test.ts +21 -1
  257. package/tests/review-start-context.test.ts +19 -0
  258. package/tests/review-tool-prose-budget.test.ts +121 -0
  259. package/tests/run-test-suite.test.ts +122 -1
  260. package/tests/runtime-harness.mjs +4 -1
  261. package/tests/sensitive-path-tools.test.ts +181 -5
  262. package/tests/session-profile-append-controller-pi.test.ts +60 -31
  263. package/tests/session-profile-binding.test.ts +19 -1
  264. package/tests/session-profile-disk-reader-pi.test.ts +58 -16
  265. package/tests/session-profile-v1-compat.test.ts +35 -1
  266. package/tests/shell-bar.test.ts +186 -42
  267. package/tests/shell-panel.test.ts +50 -22
  268. package/tests/shell-sidebar-fullscreen.test.ts +5 -5
  269. package/tests/shell-sidebar-layout.test.ts +294 -23
  270. package/tests/shell-sidebar-scroll-benchmark.test.ts +1 -1
  271. package/tests/shell-surface-transparent.test.ts +89 -0
  272. package/tests/shell-todo.test.ts +12 -0
  273. package/tests/skill-registry.test.ts +838 -5
  274. package/tests/startup-banner.test.ts +152 -1
  275. package/tests/startup-home-repo.test.ts +2 -0
  276. package/tests/support/review-coordinator-runtime.ts +69 -0
  277. package/tests/task-size-routing-contract.test.ts +5 -3
  278. package/tests/verifier-admission.test.ts +49 -0
  279. package/tests/verify-first-launch-contract.test.ts +78 -3
  280. package/tests/visual-customization-policy.test.ts +39 -6
  281. package/tests/visual-customize-view.test.ts +573 -9
  282. package/tests/visual-layout-preview.test.ts +15 -1
  283. package/tests/visual-profiles.test.ts +11 -0
  284. package/tests/voice-worker.test.ts +73 -2
  285. package/tests/windows-session-transport.test.ts +126 -0
  286. package/tests/work-continuity-contract.test.ts +28 -0
  287. package/tests/writer-feature-document-admission.test.ts +92 -0
  288. package/tests/yolo-customize.test.ts +27 -4
  289. package/tests/yolo-mode.test.ts +23 -18
  290. package/tests/yolo-session-policy.test.ts +270 -1
@@ -9,6 +9,7 @@ import {
9
9
  GENTLE_AI_BINARY_MISSING_CODE,
10
10
  GENTLE_AI_DEV_BINARY_ENV,
11
11
  GENTLE_AI_VERSION,
12
+ binaryDigest,
12
13
  gentleAiDevBinaryRegistrationPath,
13
14
  PackageLocalGentleAiBinaryMissingError,
14
15
  registerGentleAiDevBinary,
@@ -98,7 +99,7 @@ async function writeWindowsSourceBinary(packageRoot: string): Promise<{ binaryPa
98
99
  method: "go-sumdb-source-build",
99
100
  package: "github.com/gentleman-programming/gentle-ai/v4/cmd/gentle-ai",
100
101
  module: "github.com/gentleman-programming/gentle-ai/v4",
101
- tag: "v4.3.1",
102
+ tag: "v4.4.0",
102
103
  architecture: process.arch === "x64" ? "x64" : "arm64",
103
104
  binarySha256: createHash("sha256").update(binary).digest("hex"),
104
105
  moduleChecksum: GENTLE_AI_WINDOWS_SOURCE_MODULE_CHECKSUM,
@@ -185,6 +186,7 @@ test("runtime reuses the binary digest while the file is unchanged and re-hashes
185
186
  const countingRead = (path: string) => { reads++; return readFileSync(path); };
186
187
  assert.equal(resolveGentleAiBinary(packageRoot, "win32", countingRead), binaryPath);
187
188
  assert.equal(resolveGentleAiBinary(packageRoot, "win32", countingRead), binaryPath);
189
+ assert.equal(binaryDigest(binaryPath, countingRead), createHash("sha256").update(readFileSync(binaryPath)).digest("hex"));
188
190
  assert.equal(reads, 1, "an unchanged binary is hashed once");
189
191
  await writeFile(binaryPath, "tampered Windows source build");
190
192
  assert.throws(() => resolveGentleAiBinary(packageRoot, "win32", countingRead), /package-local-binary-missing/);
@@ -66,3 +66,22 @@ test("a fresh ledger restores timings recorded by a previous one", () => {
66
66
  const second = new GentleAiElapsedTimingLedger({ getEntries: () => stored });
67
67
  assert.deepEqual(second.lookup("call-1"), { toolCallId: "call-1", startedAt: 1_000 });
68
68
  });
69
+
70
+ test("extension events persist the coordinator outer call timing and ignore foreign tools", async () => {
71
+ const { createGentleAiExtension } = await import("../extensions/gentle-ai.ts");
72
+ const entries: Array<{ type: string; customType: string; data: unknown }> = [];
73
+ const handlers = new Map<string, Array<(event: any, ctx: any) => unknown>>();
74
+ const pi = { registerCommand() {}, registerTool() {}, appendEntry: (customType: string, data: unknown) => entries.push({ type: "custom", customType, data }),
75
+ on(name: string, handler: (event: any, ctx: any) => unknown) { handlers.set(name, [...(handlers.get(name) ?? []), handler]); } };
76
+ const manager = { getSessionId: () => "coordinator-timing-fixture", getCwd: () => process.cwd(), getEntries: () => entries, getBranch: () => [], getSessionFile: () => undefined };
77
+ const ctx = { cwd: process.cwd(), hasUI: false, sessionManager: manager, ui: { notify() {}, setStatus() {}, setWidget() {} } };
78
+ createGentleAiExtension({ nativeReviewCli: null, candidateViews: null, processEnv: { GENTLE_PI_AGENTS_CHILD: "1", GENTLE_AI_TELEMETRY: "0" } })(pi as never);
79
+ for (const handler of handlers.get("session_start") ?? []) await handler({ reason: "new" }, ctx);
80
+ for (const [stage, name, id] of [["tool_execution_start", "gentle_review_run", "outer"], ["tool_execution_end", "gentle_review_run", "outer"], ["tool_execution_start", "foreign", "foreign"], ["tool_execution_end", "foreign", "foreign"]]) {
81
+ for (const handler of handlers.get(stage) ?? []) await handler({ toolName: name, toolCallId: id }, ctx);
82
+ }
83
+ const timing = readGentleAiTimings(entries).get("outer");
84
+ assert.ok(timing); assert.ok(typeof timing.endedAt === "number" && timing.endedAt >= timing.startedAt);
85
+ assert.equal(readGentleAiTimings(entries).has("foreign"), false);
86
+ for (const handler of handlers.get("session_shutdown") ?? []) await handler({}, ctx);
87
+ });
@@ -7,7 +7,7 @@ import type { ExtensionAPI, ExtensionContext } from "@earendil-works/pi-coding-a
7
7
  import { createGentleAiExtension } from "../extensions/gentle-ai.ts";
8
8
 
9
9
  type Handler = (event: any, ctx: ExtensionContext) => any;
10
- function fixture(t: TestContext, child = false) {
10
+ function fixture(t: TestContext, child = false, extraEnv: Record<string, string> = {}) {
11
11
  const cwd = mkdtempSync(join(tmpdir(), "exploration-budget-"));
12
12
  t.after(() => rmSync(cwd, { recursive: true, force: true }));
13
13
  const handlers = new Map<string, Handler>();
@@ -22,7 +22,7 @@ function fixture(t: TestContext, child = false) {
22
22
  createGentleAiExtension({
23
23
  nativeReviewCli: null,
24
24
  contextBackstopMeasure: { minIntervalMs: 0 },
25
- processEnv: { GENTLE_PI_CONFIG_HOME: join(cwd, "config"), GENTLE_PI_AGENTS_CHILD: child ? "1" : "0" },
25
+ processEnv: { GENTLE_PI_CONFIG_HOME: join(cwd, "config"), GENTLE_PI_AGENTS_CHILD: child ? "1" : "0", ...extraEnv },
26
26
  resolveTelemetryTriggerBinary: () => "/usr/bin/true", telemetryTriggerSpawn: (() => undefined) as never,
27
27
  })(pi);
28
28
  const ctx = { cwd, hasUI: false, mode: "interactive", ui: { notify() {} },
@@ -133,3 +133,19 @@ test("child sessions and stale calls cannot contribute to a new primary request"
133
133
  assert.equal(await f.result("new"), undefined);
134
134
  assert.match(f.messages[0].message.content, /Exploration budget:/);
135
135
  });
136
+
137
+ // full-delegation-mode-conflicts S5: the hook hands both notices the session's mode, so a full delegation session is
138
+ // never told to keep a write inline. The organic texts are pinned by the tests above.
139
+ test("S5: in full delegation mode both notices drop their inline wording through the real hook", async (t) => {
140
+ const f = fixture(t, false, { GENTLE_PI_ORCHESTRATOR_MODE: "full-delegation" });
141
+ await f.start();
142
+ for (let i = 0; i < 3; i++) { await f.call(String(i)); await f.result(String(i)); }
143
+ (f.ctx as any).getContextUsage = () => ({ tokens: 160_000, contextWindow: 1_000_000 });
144
+ await f.call("3");
145
+ const patch = await f.result("3");
146
+ assert.match(patch.content[1].text, /Context backstop:.*keep only state checks in this context\./);
147
+ assert.doesNotMatch(patch.content[1].text, /stays? inline/);
148
+ assert.match(f.messages[0].message.content, /Reading that prepares a writer belongs in that writer's prompt\./);
149
+ assert.doesNotMatch(f.messages[0].message.content, /inline write/);
150
+ });
151
+
@@ -1,6 +1,9 @@
1
1
  import assert from "node:assert/strict";
2
2
  import { createHash } from "node:crypto";
3
3
  import { existsSync } from "node:fs";
4
+ import fsPromises from "node:fs/promises";
5
+ import pathModule from "node:path";
6
+ import { syncBuiltinESMExports } from "node:module";
4
7
  import { EventEmitter } from "node:events";
5
8
  import { PassThrough } from "node:stream";
6
9
  import { chmod, copyFile, mkdtemp, mkdir, readFile, readdir, rename, rm, stat, symlink, writeFile } from "node:fs/promises";
@@ -24,7 +27,7 @@ import {
24
27
  trustedSystemExtractor,
25
28
  } from "../scripts/gentle-ai-installer.mjs";
26
29
 
27
- // v4.3.1 archive digests independently match the minisign-signed release
30
+ // v4.4.0 archive digests independently match the minisign-signed release
28
31
  // checksums; binary digests were computed from the extracted executables.
29
32
  function releaseAssets(): Record<string, { name: string; sha256: string; binarySha256: string; url: string }> {
30
33
  const assets: Record<string, { name: string; sha256: string; binarySha256: string; url: string }> = {};
@@ -40,17 +43,17 @@ function releaseAssets(): Record<string, { name: string; sha256: string; binaryS
40
43
  }
41
44
 
42
45
  const EXPECTED_ASSETS = {
43
- "darwin/amd64": { name: "gentle-ai_4.3.1_darwin_amd64.tar.gz", sha256: "6cf57fee0574daef2abed07f54a355fec3b93ac8f01733dc6c4d3674f1746112", binarySha256: "ca44c3fce186b63a7e7ad455c338133ba1982f4a13485301ce4d66edb73d2928" },
44
- "darwin/arm64": { name: "gentle-ai_4.3.1_darwin_arm64.tar.gz", sha256: "13e8828447f9081465ee0c35a61b24fb49296d51a310c6999227e2aed178956b", binarySha256: "749d08062b0dec13681678a1a1c018613d223ddcca47b5f27681b1d8ab5d14c2" },
45
- "linux/amd64": { name: "gentle-ai_4.3.1_linux_amd64.tar.gz", sha256: "04ec685c56b42c29dff6db10fc7dc2c730217dc9c96736e53ad2acf3226dafb7", binarySha256: "86248792bde3fe5e9ca93b128c07e7caa6a5b31fac0f9fc84b5b3011b123cb90" },
46
- "linux/arm64": { name: "gentle-ai_4.3.1_linux_arm64.tar.gz", sha256: "99e7d313a2ff85eaf23a6415e9b3aae67bf74c2fa169b21b93070ada7613f6a0", binarySha256: "df3580506bb5ea63cc4ef5ccebe8b68cfedf66b72f3b51f84ff393183d8cea2b" },
46
+ "darwin/amd64": { name: "gentle-ai_4.4.0_darwin_amd64.tar.gz", sha256: "95686ea30615516aa29ebb6257227b1cdd4c67649dff63ec7adb576ca26a678d", binarySha256: "634189866db1db635aed6257716969e87e7cde6830c26627795becbd2969e104" },
47
+ "darwin/arm64": { name: "gentle-ai_4.4.0_darwin_arm64.tar.gz", sha256: "b6e00957eb81115f18e33197ae2035f75812a624c6d53e72826ecf7b4a635539", binarySha256: "5bb53e7e32da585f08b668444209bde7a9b5c9c26489e2052bf180b05a2aab81" },
48
+ "linux/amd64": { name: "gentle-ai_4.4.0_linux_amd64.tar.gz", sha256: "1f72ca13b32e87cb7f65b29e7fae6df4490b53d69d4763cdf23e944165880cd6", binarySha256: "9f39a94cef0b9882be4cd519fac3ef3602e602e3bf437df7db55c8cbd42f358d" },
49
+ "linux/arm64": { name: "gentle-ai_4.4.0_linux_arm64.tar.gz", sha256: "2d8874464cbe54b66a77d7c9fe66ce577933de00936ed1a035c81de6406a95fc", binarySha256: "b9913af83cbeff2719e33d4b6c09e6ed568a000c4d6b885b4806ec5ce796f2b7" },
47
50
  } as const;
48
51
 
49
- test("published Gentle AI v4.3.1 is the installer pin", () => {
50
- assert.equal(INSTALLER_VERSION, "4.3.1");
52
+ test("published Gentle AI v4.4.0 is the installer pin", () => {
53
+ assert.equal(INSTALLER_VERSION, "4.4.0");
51
54
  // v4.0.0 moved the Go module path to the /v4 major-version suffix.
52
55
  assert.equal(GENTLE_AI_WINDOWS_SOURCE_MODULE, "github.com/gentleman-programming/gentle-ai/v4");
53
- assert.equal(GENTLE_AI_WINDOWS_SOURCE_MODULE_CHECKSUM, "h1:00p8dnjJrhYFq1Qikk2oY6K/UXIty9A/IBUUOUiX9XA=");
56
+ assert.equal(GENTLE_AI_WINDOWS_SOURCE_MODULE_CHECKSUM, "h1:cAQAzIsbocYcQfOzA1CmgGpGgiCivUNcPjdfJE8RJ6g=");
54
57
  });
55
58
 
56
59
  test("default installer package root is the package containing scripts, not its parent", () => {
@@ -61,15 +64,15 @@ test("default installer package root is the package containing scripts, not its
61
64
  assert.notEqual(resolveGentleAiInstallerPackageRoot(), dirname(expectedPackageRoot));
62
65
  });
63
66
 
64
- test("release mapping selects only the supported official v4.3.1 assets and pinned digests", () => {
67
+ test("release mapping selects only the supported official v4.4.0 assets and pinned digests", () => {
65
68
  assert.deepEqual(
66
69
  Object.fromEntries(Object.entries(releaseAssets()).map(([key, asset]) => [key, { name: asset.name, sha256: asset.sha256, binarySha256: asset.binarySha256 }])),
67
70
  EXPECTED_ASSETS,
68
71
  );
69
- assert.equal(resolveGentleAiReleaseAsset("linux", "x64").name, "gentle-ai_4.3.1_linux_amd64.tar.gz");
70
- assert.equal(resolveGentleAiReleaseAsset("darwin", "arm64").name, "gentle-ai_4.3.1_darwin_arm64.tar.gz");
72
+ assert.equal(resolveGentleAiReleaseAsset("linux", "x64").name, "gentle-ai_4.4.0_linux_amd64.tar.gz");
73
+ assert.equal(resolveGentleAiReleaseAsset("darwin", "arm64").name, "gentle-ai_4.4.0_darwin_arm64.tar.gz");
71
74
  for (const asset of Object.values(releaseAssets())) {
72
- assert.match(asset.url, /^https:\/\/github\.com\/Gentleman-Programming\/gentle-ai\/releases\/download\/v4\.3\.1\//);
75
+ assert.match(asset.url, /^https:\/\/github\.com\/Gentleman-Programming\/gentle-ai\/releases\/download\/v4\.4\.0\//);
73
76
  }
74
77
  });
75
78
 
@@ -79,7 +82,7 @@ test("raw release assets are admitted only under a prerelease pin", () => {
79
82
  assert.equal(gentleAiAssetForm("gentle-ai_2.5.0-rc.3_windows_amd64.exe", "2.5.0-rc.3"), "raw-binary");
80
83
  // A raw binary under a stable pin means the pin itself is wrong: stable
81
84
  // releases publish signed archives only, so this fails closed pre-download.
82
- assert.throws(() => gentleAiAssetForm("gentle-ai_4.3.1_linux_amd64", "4.3.1"), /only admitted for a prerelease pin/);
85
+ assert.throws(() => gentleAiAssetForm("gentle-ai_4.4.0_linux_amd64", "4.4.0"), /only admitted for a prerelease pin/);
83
86
  assert.throws(() => gentleAiAssetForm("gentle-ai.dmg", "2.5.0-rc.3"), /unsupported Gentle AI release asset form/);
84
87
  // The current stable pin admits every pinned asset row through the same
85
88
  // gate the installer uses at download time (default installerVersion
@@ -106,7 +109,7 @@ test("release digests are all-or-none and install fails closed while any digest
106
109
  }),
107
110
  /checksum mismatch/,
108
111
  );
109
- assert.equal(existsSync(join(packageRoot, ".gentle-ai", "v4.3.1", "gentle-ai")), false);
112
+ assert.equal(existsSync(join(packageRoot, ".gentle-ai", "v4.4.0", "gentle-ai")), false);
110
113
  }
111
114
  });
112
115
 
@@ -136,7 +139,7 @@ function windowsGoFixture(fixtureOptions: WindowsGoFixtureOptions = {}) {
136
139
  const metadata = [
137
140
  "gentle-ai.exe: go1.25.10",
138
141
  "\tpath\tgithub.com/gentleman-programming/gentle-ai/v4/cmd/gentle-ai",
139
- `\tmod\tgithub.com/gentleman-programming/gentle-ai/v4\tv4.3.1\t${GENTLE_AI_WINDOWS_SOURCE_MODULE_CHECKSUM}`,
142
+ `\tmod\tgithub.com/gentleman-programming/gentle-ai/v4\tv4.4.0\t${GENTLE_AI_WINDOWS_SOURCE_MODULE_CHECKSUM}`,
140
143
  "\tbuild\t-buildmode=exe", "\tbuild\t-compiler=gc", "\tbuild\tCGO_ENABLED=0", `\tbuild\tGOARCH=${fixtureOptions.goArchitecture ?? "amd64"}`, "\tbuild\tGOOS=windows",
141
144
  ].join("\n");
142
145
  const run = async (file: string, arguments_: string[], options: WindowsGoCall["options"]) => {
@@ -154,7 +157,7 @@ function windowsGoFixture(fixtureOptions: WindowsGoFixtureOptions = {}) {
154
157
  return { stdout: "", stderr: "" };
155
158
  }
156
159
  if (file === goExecutable && arguments_[0] === "version" && arguments_[1] === "-m") return { stdout: metadata, stderr: "" };
157
- if (arguments_.length === 1 && arguments_[0] === "version") return { stdout: fixtureOptions.reportedVersion ?? "gentle-ai 4.3.1\n", stderr: "" };
160
+ if (arguments_.length === 1 && arguments_[0] === "version") return { stdout: fixtureOptions.reportedVersion ?? "gentle-ai 4.4.0\n", stderr: "" };
158
161
  throw new Error(`unexpected command: ${file} ${arguments_.join(" ")}`);
159
162
  };
160
163
  return { calls, run, setGoExecutable: (path: string) => { goExecutable = path; } };
@@ -170,11 +173,63 @@ test("win32 x64 and arm64 install the exact Go SumDB source tag without archive
170
173
  const result = await installGentleAi({ packageRoot, platform: "win32", arch, execFile: fixture.run, resolveGoExecutable: async () => goPath });
171
174
  assert.equal(result.installed, true);
172
175
  assert.deepEqual(fixture.calls.filter((call) => call.file === goPath).map((call) => call.arguments_.slice(0, 2)), [
173
- ["version"], ["install", "github.com/gentleman-programming/gentle-ai/v4/cmd/gentle-ai@v4.3.1"], ["version", "-m"],
176
+ ["version"], ["install", "github.com/gentleman-programming/gentle-ai/v4/cmd/gentle-ai@v4.4.0"], ["version", "-m"],
174
177
  ]);
175
178
  }
176
179
  });
177
180
 
181
+ test("long Windows staging prefixes publish and reuse a verified package-local bundle", async () => {
182
+ const root = await mkdtemp(join(tmpdir(), "gentle-pi-long-staging-"));
183
+ const temporaryDirectory = await mkdtemp(join(tmpdir(), "gentle-pi-long-staging-temp-"));
184
+ let packageRoot = root;
185
+ const stagingSuffix = join(".gentle-ai", `.v${INSTALLER_VERSION}.staging-`);
186
+ while (join(packageRoot, stagingSuffix).length + 6 <= 260) packageRoot = join(packageRoot, "deep".repeat(12));
187
+ assert.ok(join(packageRoot, stagingSuffix).length + 6 > 260, "the final mkdtemp path must exceed the legacy Windows bound");
188
+ const goPath = join(root, "go.exe");
189
+ const originalMkdtemp = fsPromises.mkdtemp;
190
+ const originalNamespace = pathModule.toNamespacedPath;
191
+ let longStagingCalls = 0;
192
+ try {
193
+ await writeFile(goPath, "trusted local Go executable");
194
+ // POSIX uses // as a filesystem-equivalent marker for the simulated
195
+ // Windows namespace. Native Windows uses its real path and filesystem APIs.
196
+ if (process.platform !== "win32") {
197
+ pathModule.toNamespacedPath = (value: string) => value.startsWith("/") ? `/${value}` : value;
198
+ fsPromises.mkdtemp = ((prefix: string, options?: Parameters<typeof originalMkdtemp>[1]) => {
199
+ if (prefix.includes(`.v${INSTALLER_VERSION}.staging-`) && prefix.length + 6 > 260) {
200
+ longStagingCalls += 1;
201
+ if (!prefix.startsWith("//")) return Promise.reject(Object.assign(new Error("long Windows mkdtemp prefix"), { code: "ENOENT" }));
202
+ }
203
+ return originalMkdtemp(prefix, options);
204
+ }) as typeof fsPromises.mkdtemp;
205
+ syncBuiltinESMExports();
206
+ }
207
+ const fixture = windowsGoFixture();
208
+ fixture.setGoExecutable(goPath);
209
+ const options = { packageRoot, platform: "win32", arch: "x64", execFile: fixture.run, resolveGoExecutable: async () => goPath, temporaryDirectory };
210
+ const runtimeRoot = join(packageRoot, ".gentle-ai");
211
+ const failing = windowsGoFixture({ installError: new Error("fake Go failed") });
212
+ failing.setGoExecutable(goPath);
213
+ await assert.rejects(() => installGentleAi({ ...options, execFile: failing.run }), { code: "GENTLE_AI_GO_INSTALL_FAILED" });
214
+ assert.deepEqual(await readdir(runtimeRoot), [], "failed installs remove staging and their owned lock");
215
+ const installed = await installGentleAi(options);
216
+ assert.equal(installed.installed, true);
217
+ assert.equal(await readFile(join(runtimeRoot, `v${INSTALLER_VERSION}`, "gentle-ai.exe"), "utf8"), "trusted Windows source build");
218
+ const manifest = JSON.parse(await readFile(join(runtimeRoot, `v${INSTALLER_VERSION}`, "integrity.json"), "utf8"));
219
+ assert.equal(manifest.moduleChecksum, GENTLE_AI_WINDOWS_SOURCE_MODULE_CHECKSUM);
220
+ assert.equal(manifest.binarySha256, createHash("sha256").update("trusted Windows source build").digest("hex"));
221
+ assert.equal((await installGentleAi(options)).installed, false);
222
+ assert.deepEqual(await readdir(runtimeRoot), [`v${INSTALLER_VERSION}`]);
223
+ if (process.platform !== "win32") assert.ok(longStagingCalls >= 2, "the simulated long-path boundary must be exercised");
224
+ } finally {
225
+ fsPromises.mkdtemp = originalMkdtemp;
226
+ pathModule.toNamespacedPath = originalNamespace;
227
+ syncBuiltinESMExports();
228
+ await rm(root, { recursive: true, force: true });
229
+ await rm(temporaryDirectory, { recursive: true, force: true });
230
+ }
231
+ });
232
+
178
233
  test("Windows source install reports missing or too-old Go without publishing a binary", async () => {
179
234
  for (const fixtureOptions of [
180
235
  { goVersion: "go version go1.25.9 windows/amd64\n", expectedCode: "GENTLE_AI_GO_TOOLCHAIN_TOO_OLD" },
@@ -189,7 +244,7 @@ test("Windows source install reports missing or too-old Go without publishing a
189
244
  () => installGentleAi({ packageRoot, platform: "win32", arch: "x64", execFile: fixture.run, resolveGoExecutable: async () => goPath }),
190
245
  (error: unknown) => error instanceof Error && "code" in error && error.code === fixtureOptions.expectedCode,
191
246
  );
192
- assert.equal(existsSync(join(packageRoot, ".gentle-ai", "v4.3.1", "gentle-ai.exe")), false);
247
+ assert.equal(existsSync(join(packageRoot, ".gentle-ai", "v4.4.0", "gentle-ai.exe")), false);
193
248
  assert.deepEqual((await readdir(packageRoot)).filter((entry) => entry.includes("install-")), []);
194
249
  }
195
250
  });
@@ -235,7 +290,7 @@ test("Windows source install builds in a short private directory under the temp
235
290
  }
236
291
  for (const call of fixture.calls.filter((entry) => entry.file === goPath)) assert.ok(call.options.cwd?.startsWith(buildDirectory), call.arguments_.join(" "));
237
292
  assert.deepEqual(await readdir(temporaryDirectory), [], "the build directory is removed");
238
- if (!installError) assert.equal(existsSync(join(packageRoot, ".gentle-ai", "v4.3.1", "gentle-ai.exe")), true, "the verified binary is published into the package");
293
+ if (!installError) assert.equal(existsSync(join(packageRoot, ".gentle-ai", "v4.4.0", "gentle-ai.exe")), true, "the verified binary is published into the package");
239
294
  } finally {
240
295
  await rm(packageRoot, { recursive: true, force: true });
241
296
  await rm(temporaryDirectory, { recursive: true, force: true });
@@ -257,7 +312,7 @@ test("Windows source install cleans staging after Go failure or wrong built vers
257
312
  () => installGentleAi({ packageRoot, platform: "win32", arch: "x64", execFile: fixture.run, resolveGoExecutable: async () => goPath }),
258
313
  (error: unknown) => error instanceof Error && "code" in error && error.code === fixtureOptions.expectedCode,
259
314
  );
260
- const runtimeDirectory = join(packageRoot, ".gentle-ai", "v4.3.1");
315
+ const runtimeDirectory = join(packageRoot, ".gentle-ai", "v4.4.0");
261
316
  assert.ok(fixture.calls.some((call) => call.arguments_[0] === "install"));
262
317
  assert.equal(existsSync(join(runtimeDirectory, "gentle-ai.exe")), false);
263
318
  assert.equal(existsSync(runtimeDirectory) && (await readdir(runtimeDirectory)).some((entry) => entry.startsWith(".go-install-") || entry.endsWith(".tmp")), false);
@@ -278,7 +333,7 @@ test("Windows source installs reuse only a fully verified package-local binary",
278
333
  assert.equal(reused.installed, false);
279
334
  assert.ok(reuse.calls.every((call) => call.file !== "gentle-ai"), "the installer must never fall back to ambient gentle-ai on PATH");
280
335
 
281
- await writeFile(join(packageRoot, ".gentle-ai", "v4.3.1", "integrity.json"), "{}\n");
336
+ await writeFile(join(packageRoot, ".gentle-ai", "v4.4.0", "integrity.json"), "{}\n");
282
337
  const repaired = windowsGoFixture();
283
338
  repaired.setGoExecutable(goPath);
284
339
  assert.equal((await installGentleAi({ packageRoot, platform: "win32", arch: "x64", execFile: repaired.run, resolveGoExecutable: async () => goPath })).installed, true);
@@ -320,7 +375,7 @@ async function hardenedWindowsGoFixture(packageRoot: string, fixtureOptions: Har
320
375
  const metadata = fixtureOptions.metadataOverride ?? [
321
376
  "gentle-ai.exe: go1.25.10",
322
377
  "\tpath\tgithub.com/gentleman-programming/gentle-ai/v4/cmd/gentle-ai",
323
- `\tmod\tgithub.com/gentleman-programming/gentle-ai/v4\tv4.3.1\t${GENTLE_AI_WINDOWS_SOURCE_MODULE_CHECKSUM}`,
378
+ `\tmod\tgithub.com/gentleman-programming/gentle-ai/v4\tv4.4.0\t${GENTLE_AI_WINDOWS_SOURCE_MODULE_CHECKSUM}`,
324
379
  "\tbuild\t-buildmode=exe",
325
380
  "\tbuild\t-compiler=gc",
326
381
  "\tbuild\tCGO_ENABLED=0",
@@ -340,7 +395,7 @@ async function hardenedWindowsGoFixture(packageRoot: string, fixtureOptions: Har
340
395
  return { stdout: "", stderr: "" };
341
396
  }
342
397
  if (file === goPath && arguments_[0] === "version" && arguments_[1] === "-m") return { stdout: metadata, stderr: "" };
343
- if (arguments_.length === 1 && arguments_[0] === "version") return { stdout: "gentle-ai 4.3.1\n", stderr: "" };
398
+ if (arguments_.length === 1 && arguments_[0] === "version") return { stdout: "gentle-ai 4.4.0\n", stderr: "" };
344
399
  throw new Error(`unexpected command: ${file} ${arguments_.join(" ")}`);
345
400
  };
346
401
  return {
@@ -382,7 +437,7 @@ test("Windows source installation resolves one validated Go executable and seals
382
437
  const goCalls = fixture.calls.filter((call) => call.file === fixture.goPath);
383
438
  assert.deepEqual(goCalls.map((call) => call.arguments_.slice(0, 2)), [
384
439
  ["version"],
385
- ["install", "github.com/gentleman-programming/gentle-ai/v4/cmd/gentle-ai@v4.3.1"],
440
+ ["install", "github.com/gentleman-programming/gentle-ai/v4/cmd/gentle-ai@v4.4.0"],
386
441
  ["version", "-m"],
387
442
  ]);
388
443
  for (const call of goCalls) {
@@ -408,14 +463,14 @@ test("Windows source manifest binds verified Go metadata and architecture", asyn
408
463
  const packageRoot = await mkdtemp(join(tmpdir(), "gentle-pi-installer-provenance-"));
409
464
  const fixture = await hardenedWindowsGoFixture(packageRoot, { architecture: "arm64" });
410
465
  const result = await installGentleAi({ packageRoot, platform: "win32", arch: "arm64", execFile: fixture.run, resolveGoExecutable: fixture.resolveGoExecutable });
411
- const manifest = JSON.parse(await readFile(join(packageRoot, ".gentle-ai", "v4.3.1", "integrity.json"), "utf8")) as Record<string, string>;
466
+ const manifest = JSON.parse(await readFile(join(packageRoot, ".gentle-ai", "v4.4.0", "integrity.json"), "utf8")) as Record<string, string>;
412
467
  assert.equal(result.installed, true);
413
468
  assert.deepEqual(manifest, {
414
- version: "4.3.1",
469
+ version: "4.4.0",
415
470
  method: "go-sumdb-source-build",
416
471
  package: "github.com/gentleman-programming/gentle-ai/v4/cmd/gentle-ai",
417
472
  module: "github.com/gentleman-programming/gentle-ai/v4",
418
- tag: "v4.3.1",
473
+ tag: "v4.4.0",
419
474
  architecture: "arm64",
420
475
  binarySha256: createHash("sha256").update("trusted Windows source build").digest("hex"),
421
476
  moduleChecksum: GENTLE_AI_WINDOWS_SOURCE_MODULE_CHECKSUM,
@@ -435,12 +490,12 @@ test("Windows source installation rejects Go metadata for a different architectu
435
490
  () => installGentleAi({ packageRoot, platform: "win32", arch: "x64", execFile: fixture.run, resolveGoExecutable: fixture.resolveGoExecutable }),
436
491
  (error: unknown) => error instanceof Error && "code" in error && error.code === "GENTLE_AI_GO_INSTALL_FAILED",
437
492
  );
438
- assert.equal(existsSync(join(packageRoot, ".gentle-ai", "v4.3.1", "gentle-ai.exe")), false);
493
+ assert.equal(existsSync(join(packageRoot, ".gentle-ai", "v4.4.0", "gentle-ai.exe")), false);
439
494
  });
440
495
 
441
496
  test("Windows source installation treats a fresh ownerless lock as active", async () => {
442
497
  const packageRoot = await mkdtemp(join(tmpdir(), "gentle-pi-installer-ownerless-lock-"));
443
- const lockPath = join(packageRoot, ".gentle-ai", ".v4.3.1.install.lock");
498
+ const lockPath = join(packageRoot, ".gentle-ai", ".v4.4.0.install.lock");
444
499
  await mkdir(lockPath, { recursive: true });
445
500
  const fixture = await hardenedWindowsGoFixture(packageRoot);
446
501
  await assertManualLockRecoveryRequired(packageRoot, fixture);
@@ -448,7 +503,7 @@ test("Windows source installation treats a fresh ownerless lock as active", asyn
448
503
 
449
504
  test("Windows source installation preserves a lock whose owner nonce changed before release", async () => {
450
505
  const packageRoot = await mkdtemp(join(tmpdir(), "gentle-pi-installer-owner-lock-"));
451
- const lockOwnerPath = join(packageRoot, ".gentle-ai", ".v4.3.1.install.lock", "owner.json");
506
+ const lockOwnerPath = join(packageRoot, ".gentle-ai", ".v4.4.0.install.lock", "owner.json");
452
507
  const fixture = await hardenedWindowsGoFixture(packageRoot);
453
508
  let replacedOwner = false;
454
509
  const run = async (...arguments_: Parameters<typeof fixture.run>) => {
@@ -465,7 +520,7 @@ test("Windows source installation preserves a lock whose owner nonce changed bef
465
520
  });
466
521
 
467
522
  async function assertManualLockRecoveryRequired(packageRoot: string, fixture: Awaited<ReturnType<typeof hardenedWindowsGoFixture>>, options: Record<string, unknown> = {}) {
468
- const lockPath = join(packageRoot, ".gentle-ai", ".v4.3.1.install.lock");
523
+ const lockPath = join(packageRoot, ".gentle-ai", ".v4.4.0.install.lock");
469
524
  await assert.rejects(
470
525
  () => installGentleAi({ packageRoot, platform: "win32", arch: "x64", execFile: fixture.run, resolveGoExecutable: fixture.resolveGoExecutable, ...options }),
471
526
  (error: unknown) => error instanceof Error && error.message.includes(lockPath) && /confirm no installer is active.*remove.*manually/i.test(error.message),
@@ -475,18 +530,18 @@ async function assertManualLockRecoveryRequired(packageRoot: string, fixture: Aw
475
530
  }
476
531
 
477
532
  function tombstonePath(packageRoot: string, nonce: string): string {
478
- return join(packageRoot, ".gentle-ai", `.v4.3.1.install.tombstone-${nonce}`);
533
+ return join(packageRoot, ".gentle-ai", `.v4.4.0.install.tombstone-${nonce}`);
479
534
  }
480
535
 
481
536
  async function tombstones(packageRoot: string): Promise<string[]> {
482
537
  const runtimeRoot = join(packageRoot, ".gentle-ai");
483
538
  return existsSync(runtimeRoot)
484
- ? (await readdir(runtimeRoot)).filter((entry) => entry.startsWith(".v4.3.1.install.tombstone-"))
539
+ ? (await readdir(runtimeRoot)).filter((entry) => entry.startsWith(".v4.4.0.install.tombstone-"))
485
540
  : [];
486
541
  }
487
542
 
488
543
  function backupBundlePath(packageRoot: string, nonce: string): string {
489
- return join(packageRoot, ".gentle-ai", `.v4.3.1.backup-${nonce}`);
544
+ return join(packageRoot, ".gentle-ai", `.v4.4.0.backup-${nonce}`);
490
545
  }
491
546
 
492
547
  async function copyWindowsBundle(source: string, destination: string): Promise<void> {
@@ -497,7 +552,7 @@ async function copyWindowsBundle(source: string, destination: string): Promise<v
497
552
 
498
553
  test("Windows source installation fails closed for an ownerless lock even after the stale threshold", async () => {
499
554
  const packageRoot = await mkdtemp(join(tmpdir(), "gentle-pi-installer-ownerless-stale-lock-"));
500
- const lockPath = join(packageRoot, ".gentle-ai", ".v4.3.1.install.lock");
555
+ const lockPath = join(packageRoot, ".gentle-ai", ".v4.4.0.install.lock");
501
556
  await mkdir(lockPath, { recursive: true });
502
557
  const fixture = await hardenedWindowsGoFixture(packageRoot);
503
558
  await assertManualLockRecoveryRequired(packageRoot, fixture, { now: () => Date.now() + 10 * 60_000 });
@@ -505,7 +560,7 @@ test("Windows source installation fails closed for an ownerless lock even after
505
560
 
506
561
  test("Windows source installation fails closed for a stale owner lock", async () => {
507
562
  const packageRoot = await mkdtemp(join(tmpdir(), "gentle-pi-installer-stale-lock-"));
508
- const lockPath = join(packageRoot, ".gentle-ai", ".v4.3.1.install.lock");
563
+ const lockPath = join(packageRoot, ".gentle-ai", ".v4.4.0.install.lock");
509
564
  await mkdir(lockPath, { recursive: true });
510
565
  await writeFile(join(lockPath, "owner.json"), `${JSON.stringify({ createdAt: 0, nonce: "0".repeat(64) })}\n`);
511
566
  const fixture = await hardenedWindowsGoFixture(packageRoot);
@@ -557,7 +612,7 @@ test("Windows source acquisition fails closed when a tombstone appears after its
557
612
  (error: unknown) => error instanceof Error && error.message.includes(foreignTombstone),
558
613
  );
559
614
  assert.equal(existsSync(foreignTombstone), true);
560
- assert.equal(existsSync(join(packageRoot, ".gentle-ai", ".v4.3.1.install.lock")), false);
615
+ assert.equal(existsSync(join(packageRoot, ".gentle-ai", ".v4.4.0.install.lock")), false);
561
616
  assert.equal(fixture.calls.some((call) => call.arguments_[0] === "install"), false);
562
617
  });
563
618
 
@@ -565,7 +620,7 @@ test("Windows source release deletes its matching tombstone and allows reuse", a
565
620
  const packageRoot = await mkdtemp(join(tmpdir(), "gentle-pi-installer-owned-lock-release-"));
566
621
  const fixture = await hardenedWindowsGoFixture(packageRoot);
567
622
  await installGentleAi({ packageRoot, platform: "win32", arch: "x64", execFile: fixture.run, resolveGoExecutable: fixture.resolveGoExecutable });
568
- assert.equal(existsSync(join(packageRoot, ".gentle-ai", ".v4.3.1.install.lock")), false);
623
+ assert.equal(existsSync(join(packageRoot, ".gentle-ai", ".v4.4.0.install.lock")), false);
569
624
  assert.deepEqual(await tombstones(packageRoot), []);
570
625
  const reuse = await hardenedWindowsGoFixture(packageRoot);
571
626
  assert.equal((await installGentleAi({ packageRoot, platform: "win32", arch: "x64", execFile: reuse.run, resolveGoExecutable: reuse.resolveGoExecutable })).installed, false);
@@ -575,7 +630,7 @@ test("Windows source recovers a valid backup after a crash between publication r
575
630
  const packageRoot = await mkdtemp(join(tmpdir(), "gentle-pi-installer-backup-crash-"));
576
631
  const initial = await hardenedWindowsGoFixture(packageRoot);
577
632
  await installGentleAi({ packageRoot, platform: "win32", arch: "x64", execFile: initial.run, resolveGoExecutable: initial.resolveGoExecutable });
578
- const live = join(packageRoot, ".gentle-ai", "v4.3.1");
633
+ const live = join(packageRoot, ".gentle-ai", "v4.4.0");
579
634
  const backup = backupBundlePath(packageRoot, "crash");
580
635
  await rename(live, backup);
581
636
  const recovery = await hardenedWindowsGoFixture(packageRoot);
@@ -611,7 +666,7 @@ test("Windows source cleans one validated backup only when the live bundle is va
611
666
  const packageRoot = await mkdtemp(join(tmpdir(), "gentle-pi-installer-backup-valid-live-"));
612
667
  const initial = await hardenedWindowsGoFixture(packageRoot);
613
668
  await installGentleAi({ packageRoot, platform: "win32", arch: "x64", execFile: initial.run, resolveGoExecutable: initial.resolveGoExecutable });
614
- const live = join(packageRoot, ".gentle-ai", "v4.3.1");
669
+ const live = join(packageRoot, ".gentle-ai", "v4.4.0");
615
670
  const backup = backupBundlePath(packageRoot, "valid");
616
671
  await copyWindowsBundle(live, backup);
617
672
  const reuse = await hardenedWindowsGoFixture(packageRoot);
@@ -624,7 +679,7 @@ test("Windows source preserves a valid backup when the live bundle is invalid",
624
679
  const packageRoot = await mkdtemp(join(tmpdir(), "gentle-pi-installer-backup-invalid-live-"));
625
680
  const initial = await hardenedWindowsGoFixture(packageRoot);
626
681
  await installGentleAi({ packageRoot, platform: "win32", arch: "x64", execFile: initial.run, resolveGoExecutable: initial.resolveGoExecutable });
627
- const live = join(packageRoot, ".gentle-ai", "v4.3.1");
682
+ const live = join(packageRoot, ".gentle-ai", "v4.4.0");
628
683
  const backup = backupBundlePath(packageRoot, "valid");
629
684
  await copyWindowsBundle(live, backup);
630
685
  await writeFile(join(live, "integrity.json"), "{}\n");
@@ -642,7 +697,7 @@ test("Windows concurrent installs fail closed until normal release, then reuse t
642
697
  const fixture = await hardenedWindowsGoFixture(packageRoot, { blockInstall: true });
643
698
  const first = installGentleAi({ packageRoot, platform: "win32", arch: "x64", execFile: fixture.run, resolveGoExecutable: fixture.resolveGoExecutable });
644
699
  await fixture.waitForInstall();
645
- const lockPath = join(packageRoot, ".gentle-ai", ".v4.3.1.install.lock");
700
+ const lockPath = join(packageRoot, ".gentle-ai", ".v4.4.0.install.lock");
646
701
  await assert.rejects(
647
702
  () => installGentleAi({ packageRoot, platform: "win32", arch: "x64", execFile: fixture.run, resolveGoExecutable: fixture.resolveGoExecutable }),
648
703
  (error: unknown) => error instanceof Error && error.message.includes(lockPath),
@@ -656,7 +711,7 @@ test("Windows concurrent installs fail closed until normal release, then reuse t
656
711
 
657
712
  test("Windows source publication rolls back a prior bundle when final directory swap fails", async () => {
658
713
  const packageRoot = await mkdtemp(join(tmpdir(), "gentle-pi-installer-rollback-"));
659
- const versionDirectory = join(packageRoot, ".gentle-ai", "v4.3.1");
714
+ const versionDirectory = join(packageRoot, ".gentle-ai", "v4.4.0");
660
715
  await mkdir(versionDirectory, { recursive: true });
661
716
  await writeFile(join(versionDirectory, "old.txt"), "previous bundle");
662
717
  const fixture = await hardenedWindowsGoFixture(packageRoot);
@@ -1092,7 +1147,7 @@ test("Darwin/Linux signed bundles retain their four-field manifest and reusable
1092
1147
  },
1093
1148
  };
1094
1149
  await installGentleAi(options);
1095
- const manifestPath = join(packageRoot, ".gentle-ai", "v4.3.1", "integrity.json");
1150
+ const manifestPath = join(packageRoot, ".gentle-ai", "v4.4.0", "integrity.json");
1096
1151
  const manifest = JSON.parse(await readFile(manifestPath, "utf8")) as Record<string, string>;
1097
1152
  assert.deepEqual(Object.keys(manifest), ["version", "asset", "assetSha256", "binarySha256"]);
1098
1153
  assert.equal((await installGentleAi({ ...options, download: async () => { throw new Error("signed bundle must be reused"); } })).installed, false);
@@ -1105,7 +1160,7 @@ test("a pinned asset falls back to its gentle-pi mirror only on download failure
1105
1160
  // under the current stable pin, whose form gate refuses raw binaries.
1106
1161
  const payload = Buffer.from("signed archive fixture");
1107
1162
  const binary = "mirrored binary";
1108
- const baseAsset = { name: "gentle-ai_4.3.1_linux_amd64.tar.gz", sha256: createHash("sha256").update(payload).digest("hex"), binarySha256: createHash("sha256").update(binary).digest("hex"), url: "https://example.invalid/upstream", mirrorUrl: "https://example.invalid/mirror", executable: "gentle-ai" };
1163
+ const baseAsset = { name: "gentle-ai_4.4.0_linux_amd64.tar.gz", sha256: createHash("sha256").update(payload).digest("hex"), binarySha256: createHash("sha256").update(binary).digest("hex"), url: "https://example.invalid/upstream", mirrorUrl: "https://example.invalid/mirror", executable: "gentle-ai" };
1109
1164
  const extractArchive = async (_archive: string, destination: string) => {
1110
1165
  await mkdir(destination, { recursive: true });
1111
1166
  await writeFile(join(destination, "gentle-ai"), binary);
@@ -1249,7 +1304,7 @@ test("checksum mismatch cleans temporary state without promoting a binary", asyn
1249
1304
  }),
1250
1305
  /checksum mismatch/,
1251
1306
  );
1252
- assert.equal(existsSync(join(packageRoot, ".gentle-ai", "v4.3.1", "gentle-ai")), false);
1307
+ assert.equal(existsSync(join(packageRoot, ".gentle-ai", "v4.4.0", "gentle-ai")), false);
1253
1308
  assert.deepEqual((await readdir(packageRoot)).filter((entry) => entry.startsWith(".gentle-ai-install-")), []);
1254
1309
  });
1255
1310
 
@@ -1271,7 +1326,7 @@ test("installer promotes only the expected regular executable with executable PO
1271
1326
  await chmod(extracted, 0o700);
1272
1327
  },
1273
1328
  });
1274
- const binary = join(packageRoot, ".gentle-ai", "v4.3.1", "gentle-ai");
1329
+ const binary = join(packageRoot, ".gentle-ai", "v4.4.0", "gentle-ai");
1275
1330
  assert.equal(existsSync(binary), true);
1276
1331
  assert.equal(await readFile(binary, "utf8"), "native executable");
1277
1332
  assert.ok(((await stat(binary)).mode & 0o111) !== 0);
@@ -1302,7 +1357,7 @@ test("installer rejects an extracted binary that differs from its pinned digest"
1302
1357
  }),
1303
1358
  /binary checksum mismatch/,
1304
1359
  );
1305
- assert.equal(existsSync(join(packageRoot, ".gentle-ai", "v4.3.1", "gentle-ai")), false);
1360
+ assert.equal(existsSync(join(packageRoot, ".gentle-ai", "v4.4.0", "gentle-ai")), false);
1306
1361
  });
1307
1362
 
1308
1363
  test("installer repairs a valid non-executable POSIX binary instead of reusing it", async (t) => {
@@ -1325,7 +1380,7 @@ test("installer repairs a valid non-executable POSIX binary instead of reusing i
1325
1380
  },
1326
1381
  };
1327
1382
  await installGentleAi(options);
1328
- const binary = join(packageRoot, ".gentle-ai", "v4.3.1", "gentle-ai");
1383
+ const binary = join(packageRoot, ".gentle-ai", "v4.4.0", "gentle-ai");
1329
1384
  await chmod(binary, 0o600);
1330
1385
  const repaired = await installGentleAi(options);
1331
1386
  assert.equal(repaired.installed, true);
@@ -1362,7 +1417,7 @@ test("installer rejects archives with multiple expected executable entries", asy
1362
1417
  }),
1363
1418
  /exactly one regular gentle-ai/,
1364
1419
  );
1365
- assert.equal(existsSync(join(packageRoot, ".gentle-ai", "v4.3.1", "gentle-ai")), false);
1420
+ assert.equal(existsSync(join(packageRoot, ".gentle-ai", "v4.4.0", "gentle-ai")), false);
1366
1421
  });
1367
1422
 
1368
1423
  test("installer rejects an archive without the expected regular executable", async () => {
@@ -1380,7 +1435,7 @@ test("installer rejects an archive without the expected regular executable", asy
1380
1435
  }),
1381
1436
  /non-regular gentle-ai/,
1382
1437
  );
1383
- assert.equal(existsSync(join(packageRoot, ".gentle-ai", "v4.3.1", "gentle-ai")), false);
1438
+ assert.equal(existsSync(join(packageRoot, ".gentle-ai", "v4.4.0", "gentle-ai")), false);
1384
1439
  });
1385
1440
 
1386
1441
  test("safeRemoveDirectory passes Windows-safe retry options to recursive rm cleanup", async () => {
@@ -1412,3 +1467,31 @@ test("Windows source build bounds go install separately from the Go toolchain pr
1412
1467
  assert.ok(probes.length >= 2, "go version probes must run");
1413
1468
  for (const probe of probes) assert.equal(probe.options.timeout, 120_000, `go ${probe.arguments_.join(" ")} keeps the probe bound`);
1414
1469
  });
1470
+
1471
+ test("download reports progress per chunk with the declared total", async (t) => {
1472
+ const directory = await mkdtemp(join(tmpdir(), "gentle-pi-progress-"));
1473
+ t.after(() => rm(directory, { recursive: true, force: true }));
1474
+ const request = (_url: URL, _options: unknown, callback: (response: PassThrough & { statusCode?: number; headers: Record<string, string> }) => void) => {
1475
+ const response = Object.assign(new PassThrough(), { statusCode: 200, headers: { "content-length": "6" } });
1476
+ queueMicrotask(() => { callback(response); response.write("abc"); response.end("def"); });
1477
+ return pendingRequest();
1478
+ };
1479
+ const seen: Array<{ received: number; total: number | undefined }> = [];
1480
+ await downloadGentleAiAsset("https://example.invalid/archive", join(directory, "archive"), 1024, 0, { request, maxAttempts: 1, retryDelayMs: 0, onProgress: (progress: { received: number; total: number | undefined }) => seen.push(progress) });
1481
+ assert.deepEqual(seen, [{ received: 3, total: 6 }, { received: 6, total: 6 }]);
1482
+ assert.equal(await readFile(join(directory, "archive"), "utf8"), "abcdef");
1483
+ });
1484
+
1485
+ test("download reports an unknown total as undefined and a throwing reporter never breaks it", async (t) => {
1486
+ const directory = await mkdtemp(join(tmpdir(), "gentle-pi-progress-"));
1487
+ t.after(() => rm(directory, { recursive: true, force: true }));
1488
+ const request = (_url: URL, _options: unknown, callback: (response: PassThrough & { statusCode?: number; headers: Record<string, string> }) => void) => {
1489
+ const response = Object.assign(new PassThrough(), { statusCode: 200, headers: {} });
1490
+ queueMicrotask(() => { callback(response); response.end("xy"); });
1491
+ return pendingRequest();
1492
+ };
1493
+ const totals: Array<number | undefined> = [];
1494
+ await downloadGentleAiAsset("https://example.invalid/archive", join(directory, "archive"), 1024, 0, { request, maxAttempts: 1, retryDelayMs: 0, onProgress: ({ total }: { total: number | undefined }) => { totals.push(total); throw new Error("reporter bug"); } });
1495
+ assert.deepEqual(totals, [undefined]);
1496
+ assert.equal(await readFile(join(directory, "archive"), "utf8"), "xy");
1497
+ });