gentle-pi 4.7.0 → 4.8.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 (365) hide show
  1. package/README.md +55 -44
  2. package/assets/agents/gentle-ai-explore.md +3 -3
  3. package/assets/agents/gentle-ai-verify.md +20 -6
  4. package/assets/agents/gentle-ai-worker.md +6 -6
  5. package/assets/agents/jd-judge-a.md +1 -3
  6. package/assets/agents/jd-judge-b.md +1 -3
  7. package/assets/agents/review-readability.md +1 -5
  8. package/assets/agents/review-reliability.md +1 -5
  9. package/assets/agents/review-resilience.md +1 -5
  10. package/assets/agents/review-risk.md +1 -5
  11. package/assets/design-canvas/canvas-api.js +45 -0
  12. package/assets/design-canvas/canvas-boards.js +456 -0
  13. package/assets/design-canvas/canvas-boot.js +217 -0
  14. package/assets/design-canvas/canvas-checks.js +491 -0
  15. package/assets/design-canvas/canvas-comments.js +315 -0
  16. package/assets/design-canvas/canvas-compare.js +159 -0
  17. package/assets/design-canvas/canvas-events.js +75 -0
  18. package/assets/design-canvas/canvas-export.js +393 -0
  19. package/assets/design-canvas/canvas-focus.js +203 -0
  20. package/assets/design-canvas/canvas-handoffs.js +150 -0
  21. package/assets/design-canvas/canvas-i18n-es.js +392 -0
  22. package/assets/design-canvas/canvas-i18n.js +108 -0
  23. package/assets/design-canvas/canvas-layout.js +526 -0
  24. package/assets/design-canvas/canvas-menu.js +213 -0
  25. package/assets/design-canvas/canvas-messages.js +86 -0
  26. package/assets/design-canvas/canvas-minimap.js +163 -0
  27. package/assets/design-canvas/canvas-parts.js +401 -0
  28. package/assets/design-canvas/canvas-popover.js +234 -0
  29. package/assets/design-canvas/canvas-rail.js +348 -0
  30. package/assets/design-canvas/canvas-sizes.js +524 -0
  31. package/assets/design-canvas/canvas-store.js +164 -0
  32. package/assets/design-canvas/canvas-tokens.js +674 -0
  33. package/assets/design-canvas/canvas-ui.js +24 -0
  34. package/assets/design-canvas/canvas-view.js +184 -0
  35. package/assets/design-canvas/canvas.css +746 -15
  36. package/assets/design-canvas/canvas.js +2 -1506
  37. package/assets/design-canvas/index.html +117 -36
  38. package/assets/design-canvas/inspector.js +546 -16
  39. package/assets/install-wizard/wizard.js +5 -1
  40. package/assets/migrations/agent-body-history.json +24 -0
  41. package/assets/orchestrator-delegation-reference.md +8 -14
  42. package/assets/orchestrator-delegation.md +4 -4
  43. package/assets/orchestrator-full-delegation-card.md +4 -5
  44. package/assets/orchestrator-full-delegation.md +8 -8
  45. package/assets/orchestrator-memory.md +2 -2
  46. package/assets/orchestrator-prompts.md +1 -1
  47. package/assets/orchestrator-quota-recovery.md +5 -0
  48. package/assets/orchestrator-skills.md +13 -12
  49. package/assets/orchestrator-tracking.md +10 -14
  50. package/assets/orchestrator-verification.md +10 -8
  51. package/assets/orchestrator-writer.md +4 -4
  52. package/assets/orchestrator.md +18 -22
  53. package/bin/gentle-shell.mjs +128 -9
  54. package/contracts/review-provider-contract-mirror/provider-contract.lock.json +8 -9
  55. package/contracts/review-provider-contract-mirror/{v1.4.0 → v1.5.0}/bundle/manifest.json +3 -3
  56. package/contracts/review-provider-contract-mirror/{v1.4.0 → v1.5.0}/bundle/orchestration/pi.md +1 -0
  57. package/contracts/review-provider-contract-mirror/{v1.4.0 → v1.5.0}/bundle/routing/pi.md +6 -6
  58. package/contracts/review-provider-contract-mirror/{v1.4.0 → v1.5.0}/generated/provider-capabilities.baseline.json +3 -3
  59. package/contracts/review-provider-contract-mirror/{v1.4.0 → v1.5.0}/generated/provider-roles.baseline.json +1 -1
  60. package/docs/assets/brand/sponsor-banner.svg +60 -0
  61. package/docs/bundled-install.md +14 -6
  62. package/docs/delegated-verification.md +18 -2
  63. package/docs/desktop-rpc.md +1253 -0
  64. package/docs/gentle-agents-activity.md +26 -0
  65. package/docs/gentle-shell.md +39 -16
  66. package/docs/install-wizard.md +30 -21
  67. package/docs/odd-preparation-continuity.md +24 -0
  68. package/docs/permission-modes.md +9 -1
  69. package/docs/prompt-budget.md +12 -0
  70. package/docs/rdd-odd-friction-triage-2026-11-07.md +57 -0
  71. package/docs/readme-reference.md +76 -24
  72. package/docs/review-coordinator.md +29 -9
  73. package/docs/review-delivery-preflight.md +22 -0
  74. package/docs/work-continuity.md +11 -1
  75. package/extensions/ask-user-question.ts +2 -2
  76. package/extensions/child-context.ts +21 -7
  77. package/extensions/gentle-agents.ts +234 -33
  78. package/extensions/gentle-ai.ts +576 -135
  79. package/extensions/gentle-design.ts +69 -3
  80. package/extensions/gentle-desktop-rpc.ts +143 -0
  81. package/extensions/gentle-guide.ts +3 -0
  82. package/extensions/gentle-shell.ts +105 -52
  83. package/extensions/gentle-todo.ts +48 -25
  84. package/extensions/skill-registry.ts +248 -223
  85. package/lib/agent-assets.ts +30 -6
  86. package/lib/agent-tool-overlay.ts +117 -0
  87. package/lib/agents-config.ts +47 -6
  88. package/lib/agents-message-delivery.ts +17 -0
  89. package/lib/agents-messaging.ts +8 -2
  90. package/lib/agents-protocol.ts +15 -0
  91. package/lib/agents-report-cap.ts +115 -0
  92. package/lib/agents-runner.ts +91 -6
  93. package/lib/agents-session-transport.ts +17 -1
  94. package/lib/background-jobs-tools.ts +9 -4
  95. package/lib/bounded-writer-admission.ts +184 -31
  96. package/lib/child-context-files.ts +21 -6
  97. package/lib/codemode-renderer.ts +1 -0
  98. package/lib/delivery-conflict-markers.ts +349 -0
  99. package/lib/design-canvas-assets.ts +36 -0
  100. package/lib/design-canvas-server.ts +241 -23
  101. package/lib/design-comments.ts +94 -4
  102. package/lib/design-handoffs.ts +2 -1
  103. package/lib/design-layout.ts +125 -0
  104. package/lib/design-parts.ts +281 -0
  105. package/lib/design-system-tokens.ts +111 -0
  106. package/lib/desktop-agents-service.ts +294 -0
  107. package/lib/desktop-design-service.ts +233 -0
  108. package/lib/desktop-jobs-service.ts +263 -0
  109. package/lib/desktop-rpc-agents.ts +294 -0
  110. package/lib/desktop-rpc-config.ts +731 -0
  111. package/lib/desktop-rpc-design.ts +138 -0
  112. package/lib/desktop-rpc-jobs.ts +181 -0
  113. package/lib/desktop-rpc-permissions.ts +177 -0
  114. package/lib/desktop-rpc-profiles.ts +196 -0
  115. package/lib/desktop-rpc-usage.ts +229 -0
  116. package/lib/desktop-rpc.ts +225 -0
  117. package/lib/desktop-usage-service.ts +310 -0
  118. package/lib/destructive-command-guard.ts +188 -13
  119. package/lib/gentle-ai-renderer.ts +13 -1
  120. package/lib/gentle-design.ts +201 -14
  121. package/lib/gentle-shell-bundled.ts +100 -9
  122. package/lib/hidden-tools.ts +35 -0
  123. package/lib/inprocess-reviewer.ts +96 -12
  124. package/lib/model-fallback-policy.ts +9 -0
  125. package/lib/model-routing-authority.ts +9 -0
  126. package/lib/nan-provider.ts +42 -28
  127. package/lib/native-review-cli.ts +79 -4
  128. package/lib/orchestrator-discovery.ts +39 -2
  129. package/lib/reply-language-anchor.ts +27 -2
  130. package/lib/request-context-placement.ts +53 -0
  131. package/lib/review-candidate-view.ts +11 -1
  132. package/lib/review-continuation-registry.ts +17 -0
  133. package/lib/review-coordinator.ts +252 -8
  134. package/lib/review-delivery-preflight.ts +85 -0
  135. package/lib/review-host-relay.ts +5 -1
  136. package/lib/review-integration-v2.ts +56 -3
  137. package/lib/reviewer-stream.ts +87 -0
  138. package/lib/shell-prompt.ts +16 -3
  139. package/lib/shell-usage.ts +10 -0
  140. package/lib/vim-editor-adapter.ts +9 -2
  141. package/lib/writer-batch-admission.ts +55 -0
  142. package/lib/yolo-session-policy.ts +6 -1
  143. package/package.json +2 -2
  144. package/prompts/skill-creation.md +1 -10
  145. package/runtime/design-canvas-assets.mjs +37 -0
  146. package/runtime/gentle-shell-bundled.mjs +100 -9
  147. package/runtime/native-review-cli.mjs +79 -4
  148. package/runtime/review-integration-v2.mjs +56 -3
  149. package/scripts/bootstrap.cmd +2 -2
  150. package/scripts/bootstrap.sh +41 -4
  151. package/scripts/build-full-delegation-card.mjs +4 -0
  152. package/scripts/build-runtime-modules.mjs +1 -0
  153. package/scripts/gentle-ai-installer.mjs +10 -10
  154. package/scripts/gentle-ai-proxy.mjs +1 -1
  155. package/scripts/installer-downloads.mjs +34 -8
  156. package/scripts/installer-preflight.mjs +28 -17
  157. package/scripts/installer-probes.mjs +25 -5
  158. package/scripts/installer-server.mjs +38 -9
  159. package/scripts/installer-windows.mjs +2 -2
  160. package/scripts/pi-update.mjs +166 -27
  161. package/scripts/prepare-verifier.mjs +107 -0
  162. package/scripts/update-agent-body-history.mjs +55 -8
  163. package/scripts/verify-package-files.mjs +40 -19
  164. package/skills/branch-pr/SKILL.md +16 -16
  165. package/skills/comment-writer/SKILL.md +1 -1
  166. package/skills/design/SKILL.md +6 -6
  167. package/skills/gentle-ai/SKILL.md +5 -5
  168. package/skills/judgment-day/SKILL.md +2 -2
  169. package/skills/judgment-day/references/prompts-and-formats.md +1 -1
  170. package/skills/rdd-defect-workflow/SKILL.md +6 -6
  171. package/skills/skill-improver/SKILL.md +2 -2
  172. package/skills/skill-registry/SKILL.md +11 -13
  173. package/skills/tui-design/SKILL.md +1 -1
  174. package/skills/work-unit-commits/SKILL.md +5 -5
  175. package/tests/agent-prompt-diet-contract.test.ts +101 -0
  176. package/tests/agent-tool-overlay-acceptance.test.ts +158 -0
  177. package/tests/agent-tool-overlay.test.ts +89 -0
  178. package/tests/agents-config.test.ts +10 -1
  179. package/tests/agents-message-delivery.test.ts +36 -0
  180. package/tests/agents-queries.test.ts +144 -4
  181. package/tests/agents-report-cap.test.ts +126 -0
  182. package/tests/agents-runner.test.ts +37 -1
  183. package/tests/agents-session-transport.test.ts +34 -0
  184. package/tests/always-on-prompt-verdicts-contract.test.ts +188 -0
  185. package/tests/append-system-prompt-route.test.ts +10 -2
  186. package/tests/approved-text-leftovers-contract.test.ts +136 -0
  187. package/tests/artifact-language.test.ts +1 -1
  188. package/tests/ask-user-question.test.ts +2 -1
  189. package/tests/audit-leftovers-contract.test.ts +51 -0
  190. package/tests/bounded-stop-contract.test.ts +9 -1
  191. package/tests/branch-pr-skill.test.ts +10 -1
  192. package/tests/bundled-install.test.ts +1 -1
  193. package/tests/child-context-files.test.ts +64 -8
  194. package/tests/child-skills-catalog.test.ts +56 -0
  195. package/tests/codemode-rendering.test.ts +4 -1
  196. package/tests/delegate-for-reason-contract.test.ts +30 -8
  197. package/tests/delivery-conflict-markers.test.ts +348 -0
  198. package/tests/design-canvas-all-sizes.test.ts +631 -0
  199. package/tests/design-canvas-allowlist.test.ts +32 -0
  200. package/tests/design-canvas-assets.test.ts +11 -878
  201. package/tests/design-canvas-boards.test.ts +77 -0
  202. package/tests/design-canvas-checks.test.ts +655 -0
  203. package/tests/design-canvas-compare.test.ts +79 -0
  204. package/tests/design-canvas-events.test.ts +59 -0
  205. package/tests/design-canvas-export.test.ts +1168 -0
  206. package/tests/design-canvas-focus.test.ts +113 -0
  207. package/tests/design-canvas-handoffs.test.ts +59 -0
  208. package/tests/design-canvas-i18n-review.test.ts +513 -0
  209. package/tests/design-canvas-i18n-views.test.ts +259 -0
  210. package/tests/design-canvas-i18n.test.ts +526 -0
  211. package/tests/design-canvas-inspector.test.ts +937 -0
  212. package/tests/design-canvas-layout.test.ts +1222 -0
  213. package/tests/design-canvas-minimap.test.ts +413 -0
  214. package/tests/design-canvas-modules.test.ts +90 -0
  215. package/tests/design-canvas-parts.test.ts +721 -0
  216. package/tests/design-canvas-rail.test.ts +799 -0
  217. package/tests/design-canvas-server.test.ts +855 -17
  218. package/tests/design-canvas-sizes.test.ts +548 -0
  219. package/tests/design-canvas-store.test.ts +180 -0
  220. package/tests/design-canvas-tokens.test.ts +965 -0
  221. package/tests/design-canvas-view.test.ts +299 -0
  222. package/tests/design-comments.test.ts +201 -1
  223. package/tests/design-handoffs.test.ts +20 -0
  224. package/tests/design-layout.test.ts +100 -0
  225. package/tests/design-parts.test.ts +260 -0
  226. package/tests/design-system-tokens.test.ts +215 -0
  227. package/tests/desktop-rpc-agents.test.ts +893 -0
  228. package/tests/desktop-rpc-config.test.ts +1452 -0
  229. package/tests/desktop-rpc-design.test.ts +662 -0
  230. package/tests/desktop-rpc-jobs.test.ts +796 -0
  231. package/tests/desktop-rpc-permissions.test.ts +311 -0
  232. package/tests/desktop-rpc-profiles.test.ts +140 -0
  233. package/tests/desktop-rpc-safety.test.ts +119 -0
  234. package/tests/desktop-rpc-usage.test.ts +697 -0
  235. package/tests/desktop-rpc.test.ts +252 -0
  236. package/tests/devbinary/pi-host-relay.devtest.ts +149 -80
  237. package/tests/devbinary/review-session-consent.devtest.ts +84 -0
  238. package/tests/engram-safety.test.ts +111 -0
  239. package/tests/fixtures/devbinary/status-v9-escalated-non-blocking.captured.json +92 -0
  240. package/tests/fixtures/devbinary/status-v9-escalated-non-blocking.provenance.md +3 -0
  241. package/tests/fixtures/primary-session-prompt/gentleman.golden.md +20 -29
  242. package/tests/fixtures/refusal-identity.probe.mjs +139 -0
  243. package/tests/full-delegation-closure.test.ts +29 -0
  244. package/tests/gentle-agents.test.ts +329 -4
  245. package/tests/gentle-ai-binary.test.ts +1 -1
  246. package/tests/gentle-ai-child-guards.test.ts +1 -0
  247. package/tests/gentle-ai-installer.test.ts +52 -51
  248. package/tests/gentle-ai-renderer.test.ts +36 -2
  249. package/tests/gentle-ai.test.ts +121 -6
  250. package/tests/gentle-design.test.ts +365 -1
  251. package/tests/gentle-shell-bundled.test.ts +91 -5
  252. package/tests/gentle-shell-launcher.test.ts +1 -1
  253. package/tests/gentle-shell.test.ts +118 -87
  254. package/tests/gentle-todo.test.ts +32 -9
  255. package/tests/hidden-tools.test.ts +188 -0
  256. package/tests/independent-recovery-delivery.test.ts +19 -5
  257. package/tests/inprocess-reviewer.test.ts +73 -0
  258. package/tests/install-wizard.test.ts +27 -1
  259. package/tests/installer-downloads.test.ts +30 -1
  260. package/tests/installer-posix-bootstrap.test.ts +114 -13
  261. package/tests/installer-preflight.test.ts +49 -1
  262. package/tests/installer-probes.test.ts +146 -0
  263. package/tests/installer-server.test.ts +203 -4
  264. package/tests/installer-windows-bootstrap.test.ts +19 -1
  265. package/tests/judgment-day-severity-admission.test.ts +46 -0
  266. package/tests/lazy-module-contradictions-contract.test.ts +158 -0
  267. package/tests/maintainer/desktop-rpc.maintest.ts +632 -0
  268. package/tests/maintainer/pi-update-source.maintest.ts +48 -18
  269. package/tests/model-fallback-policy.test.ts +26 -7
  270. package/tests/nan-provider-runtime.test.ts +17 -3
  271. package/tests/nan-provider.test.ts +111 -56
  272. package/tests/native-review-capability-contract.test.ts +11 -1
  273. package/tests/native-review-cli-nonblocking-findings.test.ts +165 -0
  274. package/tests/native-review-parity.test.ts +24 -5
  275. package/tests/native-review-refusal-identity.test.ts +25 -0
  276. package/tests/no-self-pause-contract.test.ts +11 -3
  277. package/tests/odd-integration.test.ts +11 -3
  278. package/tests/odd-routing-contract.test.ts +80 -28
  279. package/tests/orchestrator-budget.test.ts +30 -5
  280. package/tests/orchestrator-consultation-sdk.test.ts +32 -6
  281. package/tests/orchestrator-delegation-mode.test.ts +2 -1
  282. package/tests/orchestrator-discovery.test.ts +28 -0
  283. package/tests/orchestrator-prompt-budget.test.ts +11 -2
  284. package/tests/orchestrator-prompt-diet-contract.test.ts +221 -0
  285. package/tests/orchestrator-rdd-ownership.test.ts +2 -1
  286. package/tests/orchestrator-work-search.test.ts +4 -2
  287. package/tests/package-files.test.ts +25 -1
  288. package/tests/package-manifest.test.ts +11 -10
  289. package/tests/parallel-reason-contract.test.ts +6 -3
  290. package/tests/permission-allowlist.test.ts +200 -30
  291. package/tests/persona-neutral-voseo.test.ts +4 -4
  292. package/tests/persona-reply-language.test.ts +1 -1
  293. package/tests/persona-single-channel.test.ts +13 -5
  294. package/tests/pi-update-launcher.test.ts +17 -7
  295. package/tests/pi-update-source.test.ts +113 -6
  296. package/tests/pi-update.test.ts +294 -19
  297. package/tests/pnpm-workspace-policy.test.ts +47 -0
  298. package/tests/primary-context-files.test.ts +233 -0
  299. package/tests/primary-context-three-files.test.ts +174 -0
  300. package/tests/provider-defect-handoff.test.ts +9 -2
  301. package/tests/rdd-aware-verification-contract.test.ts +1 -1
  302. package/tests/rdd-status-line.test.ts +94 -1
  303. package/tests/reply-language-anchor-placement.test.ts +184 -0
  304. package/tests/reply-language-anchor.test.ts +17 -1
  305. package/tests/request-context-append-only.test.ts +218 -0
  306. package/tests/request-context-placement.test.ts +148 -0
  307. package/tests/review-agent-end-preflight.test.ts +79 -1
  308. package/tests/review-candidate-view.test.ts +65 -0
  309. package/tests/review-continuation-registry.test.ts +31 -0
  310. package/tests/review-contract-prompt.test.ts +1 -1
  311. package/tests/review-controller.test.ts +2 -1
  312. package/tests/review-coordinator-correction-gate.test.ts +105 -0
  313. package/tests/review-coordinator-findings.test.ts +206 -0
  314. package/tests/review-coordinator-nonblocking-scope.test.ts +169 -0
  315. package/tests/review-coordinator.test.ts +271 -4
  316. package/tests/review-delivery-preflight.test.ts +462 -0
  317. package/tests/review-due-compaction.test.ts +31 -0
  318. package/tests/review-due-public-boundary.test.ts +26 -0
  319. package/tests/review-integration-nonblocking-findings.test.ts +108 -0
  320. package/tests/review-json-arguments.test.ts +41 -2
  321. package/tests/review-ledger-contract.test.ts +19 -40
  322. package/tests/review-loadout-rdd-off-sdk.test.ts +30 -1
  323. package/tests/review-one-call-findings.test.ts +131 -0
  324. package/tests/review-one-call-followups.test.ts +308 -0
  325. package/tests/review-one-call-reviewer-requests.test.ts +207 -0
  326. package/tests/review-one-call.test.ts +452 -0
  327. package/tests/review-relay-transport-agent.test.ts +28 -1
  328. package/tests/review-reviewer-evidence.test.ts +41 -1
  329. package/tests/review-risk-assessment.test.ts +52 -5
  330. package/tests/review-run-statement-guidance-independent.test.ts +54 -0
  331. package/tests/review-session-standing-permission-controller.test.ts +32 -2
  332. package/tests/review-tool-prose-budget.test.ts +1 -0
  333. package/tests/reviewer-stream.test.ts +149 -0
  334. package/tests/session-profile-extension.test.ts +2 -2
  335. package/tests/shell-prompt.test.ts +17 -0
  336. package/tests/shell-usage.test.ts +59 -10
  337. package/tests/skill-contradictions-contract.test.ts +122 -0
  338. package/tests/skill-registry-watcher.test.ts +216 -2
  339. package/tests/skill-registry.test.ts +929 -306
  340. package/tests/support/design-canvas-dom.ts +369 -0
  341. package/tests/support/review-coordinator-runtime.ts +212 -17
  342. package/tests/task-size-routing-contract.test.ts +42 -11
  343. package/tests/test-strength-contract.test.ts +2 -1
  344. package/tests/todo-request-append-only.test.ts +214 -0
  345. package/tests/tool-batching-contract.test.ts +3 -1
  346. package/tests/update-agent-body-history.test.ts +138 -0
  347. package/tests/verification-tiers-contract.test.ts +229 -0
  348. package/tests/verifier-preparation.test.ts +229 -0
  349. package/tests/verify-agent-contract.test.ts +20 -2
  350. package/tests/verify-first-launch-contract.test.ts +87 -11
  351. package/tests/vim-editor-adapter.test.ts +2 -2
  352. package/tests/work-continuity-contract.test.ts +54 -11
  353. package/tests/writer-admission-messages.test.ts +232 -0
  354. package/tests/writer-batch-admission.test.ts +66 -0
  355. package/tests/writer-edit-surface-scope.test.ts +52 -20
  356. package/tests/writer-feature-document-admission.test.ts +184 -0
  357. package/tests/yolo-mode.test.ts +39 -0
  358. package/skills/_shared/review-ledger-contract.md +0 -106
  359. /package/contracts/review-provider-contract-mirror/{v1.4.0 → v1.5.0}/bundle/README.md +0 -0
  360. /package/contracts/review-provider-contract-mirror/{v1.4.0 → v1.5.0}/bundle/schemas/lens.schema.json +0 -0
  361. /package/contracts/review-provider-contract-mirror/{v1.4.0 → v1.5.0}/bundle/schemas/refuter.schema.json +0 -0
  362. /package/contracts/review-provider-contract-mirror/{v1.4.0 → v1.5.0}/bundle/schemas/targeted-validator.schema.json +0 -0
  363. /package/contracts/review-provider-contract-mirror/{v1.4.0 → v1.5.0}/bundle/vectors/lens.json +0 -0
  364. /package/contracts/review-provider-contract-mirror/{v1.4.0 → v1.5.0}/bundle/vectors/refuter.json +0 -0
  365. /package/contracts/review-provider-contract-mirror/{v1.4.0 → v1.5.0}/bundle/vectors/targeted-validator.json +0 -0
@@ -27,7 +27,7 @@ import {
27
27
  trustedSystemExtractor,
28
28
  } from "../scripts/gentle-ai-installer.mjs";
29
29
 
30
- // v4.4.0 archive digests independently match the minisign-signed release
30
+ // v4.5.0 archive digests independently match the minisign-signed release
31
31
  // checksums; binary digests were computed from the extracted executables.
32
32
  function releaseAssets(): Record<string, { name: string; sha256: string; binarySha256: string; url: string }> {
33
33
  const assets: Record<string, { name: string; sha256: string; binarySha256: string; url: string }> = {};
@@ -43,17 +43,18 @@ function releaseAssets(): Record<string, { name: string; sha256: string; binaryS
43
43
  }
44
44
 
45
45
  const EXPECTED_ASSETS = {
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" },
46
+ "darwin/amd64": { name: "gentle-ai_4.5.0_darwin_amd64.tar.gz", sha256: "45c65d04fb429f8065682360d9a3c650d988842fe62f843b36598953c8acc0a1", binarySha256: "4b89ffad9ee7fb1ed70058bd6f73914dc6256aea6c79998838ca2d2c363f24b4" },
47
+ "darwin/arm64": { name: "gentle-ai_4.5.0_darwin_arm64.tar.gz", sha256: "b8522090394d93aa5dd8d3f5c80982e6163c4d5d2e7952c3c1917da8a150ae31", binarySha256: "699a44555e544447f5db342b918aa8558b5e0e3213bb9404b66863319b1f58d4" },
48
+ "linux/amd64": { name: "gentle-ai_4.5.0_linux_amd64.tar.gz", sha256: "6dfd0a6fc27122541d20da4b65ec449763e672051daf2069611ca33134270c5b", binarySha256: "76295de0b0abae140f0356d2da5a9955f8770f54c9d7a9b7ac768821126d5fe3" },
49
+ "linux/arm64": { name: "gentle-ai_4.5.0_linux_arm64.tar.gz", sha256: "a0a8bf642abbdcb8b93013ab3f2ff90d01c9087a27927c93d980ddb57de74378", binarySha256: "7820589547c4dddcc130532643aa5ba001667525d2a0fbec1189a8398ceacfa6" },
50
50
  } as const;
51
51
 
52
- test("published Gentle AI v4.4.0 is the installer pin", () => {
53
- assert.equal(INSTALLER_VERSION, "4.4.0");
52
+ test("published Gentle AI v4.5.0 is the installer pin", () => {
53
+ assert.equal(INSTALLER_VERSION, "4.5.0");
54
54
  // v4.0.0 moved the Go module path to the /v4 major-version suffix.
55
55
  assert.equal(GENTLE_AI_WINDOWS_SOURCE_MODULE, "github.com/gentleman-programming/gentle-ai/v4");
56
- assert.equal(GENTLE_AI_WINDOWS_SOURCE_MODULE_CHECKSUM, "h1:cAQAzIsbocYcQfOzA1CmgGpGgiCivUNcPjdfJE8RJ6g=");
56
+ assert.equal(GENTLE_AI_WINDOWS_SOURCE_MODULE_CHECKSUM, "h1:81Hsy+cboAbUse1ORVJuwji6V9sRIGlFwC73EtMdw0c=");
57
+ assert.equal(GENTLE_AI_WINDOWS_SOURCE_TAG, "v4.5.0");
57
58
  });
58
59
 
59
60
  test("default installer package root is the package containing scripts, not its parent", () => {
@@ -64,15 +65,15 @@ test("default installer package root is the package containing scripts, not its
64
65
  assert.notEqual(resolveGentleAiInstallerPackageRoot(), dirname(expectedPackageRoot));
65
66
  });
66
67
 
67
- test("release mapping selects only the supported official v4.4.0 assets and pinned digests", () => {
68
+ test("release mapping selects only the supported official v4.5.0 assets and pinned digests", () => {
68
69
  assert.deepEqual(
69
70
  Object.fromEntries(Object.entries(releaseAssets()).map(([key, asset]) => [key, { name: asset.name, sha256: asset.sha256, binarySha256: asset.binarySha256 }])),
70
71
  EXPECTED_ASSETS,
71
72
  );
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");
73
+ assert.equal(resolveGentleAiReleaseAsset("linux", "x64").name, "gentle-ai_4.5.0_linux_amd64.tar.gz");
74
+ assert.equal(resolveGentleAiReleaseAsset("darwin", "arm64").name, "gentle-ai_4.5.0_darwin_arm64.tar.gz");
74
75
  for (const asset of Object.values(releaseAssets())) {
75
- assert.match(asset.url, /^https:\/\/github\.com\/Gentleman-Programming\/gentle-ai\/releases\/download\/v4\.4\.0\//);
76
+ assert.match(asset.url, /^https:\/\/github\.com\/Gentleman-Programming\/gentle-ai\/releases\/download\/v4\.5\.0\//);
76
77
  }
77
78
  });
78
79
 
@@ -82,7 +83,7 @@ test("raw release assets are admitted only under a prerelease pin", () => {
82
83
  assert.equal(gentleAiAssetForm("gentle-ai_2.5.0-rc.3_windows_amd64.exe", "2.5.0-rc.3"), "raw-binary");
83
84
  // A raw binary under a stable pin means the pin itself is wrong: stable
84
85
  // releases publish signed archives only, so this fails closed pre-download.
85
- assert.throws(() => gentleAiAssetForm("gentle-ai_4.4.0_linux_amd64", "4.4.0"), /only admitted for a prerelease pin/);
86
+ assert.throws(() => gentleAiAssetForm("gentle-ai_4.5.0_linux_amd64", "4.5.0"), /only admitted for a prerelease pin/);
86
87
  assert.throws(() => gentleAiAssetForm("gentle-ai.dmg", "2.5.0-rc.3"), /unsupported Gentle AI release asset form/);
87
88
  // The current stable pin admits every pinned asset row through the same
88
89
  // gate the installer uses at download time (default installerVersion
@@ -109,7 +110,7 @@ test("release digests are all-or-none and install fails closed while any digest
109
110
  }),
110
111
  /checksum mismatch/,
111
112
  );
112
- assert.equal(existsSync(join(packageRoot, ".gentle-ai", "v4.4.0", "gentle-ai")), false);
113
+ assert.equal(existsSync(join(packageRoot, ".gentle-ai", "v4.5.0", "gentle-ai")), false);
113
114
  }
114
115
  });
115
116
 
@@ -139,7 +140,7 @@ function windowsGoFixture(fixtureOptions: WindowsGoFixtureOptions = {}) {
139
140
  const metadata = [
140
141
  "gentle-ai.exe: go1.25.10",
141
142
  "\tpath\tgithub.com/gentleman-programming/gentle-ai/v4/cmd/gentle-ai",
142
- `\tmod\tgithub.com/gentleman-programming/gentle-ai/v4\tv4.4.0\t${GENTLE_AI_WINDOWS_SOURCE_MODULE_CHECKSUM}`,
143
+ `\tmod\tgithub.com/gentleman-programming/gentle-ai/v4\tv4.5.0\t${GENTLE_AI_WINDOWS_SOURCE_MODULE_CHECKSUM}`,
143
144
  "\tbuild\t-buildmode=exe", "\tbuild\t-compiler=gc", "\tbuild\tCGO_ENABLED=0", `\tbuild\tGOARCH=${fixtureOptions.goArchitecture ?? "amd64"}`, "\tbuild\tGOOS=windows",
144
145
  ].join("\n");
145
146
  const run = async (file: string, arguments_: string[], options: WindowsGoCall["options"]) => {
@@ -157,7 +158,7 @@ function windowsGoFixture(fixtureOptions: WindowsGoFixtureOptions = {}) {
157
158
  return { stdout: "", stderr: "" };
158
159
  }
159
160
  if (file === goExecutable && arguments_[0] === "version" && arguments_[1] === "-m") return { stdout: metadata, stderr: "" };
160
- if (arguments_.length === 1 && arguments_[0] === "version") return { stdout: fixtureOptions.reportedVersion ?? "gentle-ai 4.4.0\n", stderr: "" };
161
+ if (arguments_.length === 1 && arguments_[0] === "version") return { stdout: fixtureOptions.reportedVersion ?? "gentle-ai 4.5.0\n", stderr: "" };
161
162
  throw new Error(`unexpected command: ${file} ${arguments_.join(" ")}`);
162
163
  };
163
164
  return { calls, run, setGoExecutable: (path: string) => { goExecutable = path; } };
@@ -173,7 +174,7 @@ test("win32 x64 and arm64 install the exact Go SumDB source tag without archive
173
174
  const result = await installGentleAi({ packageRoot, platform: "win32", arch, execFile: fixture.run, resolveGoExecutable: async () => goPath });
174
175
  assert.equal(result.installed, true);
175
176
  assert.deepEqual(fixture.calls.filter((call) => call.file === goPath).map((call) => call.arguments_.slice(0, 2)), [
176
- ["version"], ["install", "github.com/gentleman-programming/gentle-ai/v4/cmd/gentle-ai@v4.4.0"], ["version", "-m"],
177
+ ["version"], ["install", "github.com/gentleman-programming/gentle-ai/v4/cmd/gentle-ai@v4.5.0"], ["version", "-m"],
177
178
  ]);
178
179
  }
179
180
  });
@@ -244,7 +245,7 @@ test("Windows source install reports missing or too-old Go without publishing a
244
245
  () => installGentleAi({ packageRoot, platform: "win32", arch: "x64", execFile: fixture.run, resolveGoExecutable: async () => goPath }),
245
246
  (error: unknown) => error instanceof Error && "code" in error && error.code === fixtureOptions.expectedCode,
246
247
  );
247
- assert.equal(existsSync(join(packageRoot, ".gentle-ai", "v4.4.0", "gentle-ai.exe")), false);
248
+ assert.equal(existsSync(join(packageRoot, ".gentle-ai", "v4.5.0", "gentle-ai.exe")), false);
248
249
  assert.deepEqual((await readdir(packageRoot)).filter((entry) => entry.includes("install-")), []);
249
250
  }
250
251
  });
@@ -290,7 +291,7 @@ test("Windows source install builds in a short private directory under the temp
290
291
  }
291
292
  for (const call of fixture.calls.filter((entry) => entry.file === goPath)) assert.ok(call.options.cwd?.startsWith(buildDirectory), call.arguments_.join(" "));
292
293
  assert.deepEqual(await readdir(temporaryDirectory), [], "the build directory is removed");
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");
294
+ if (!installError) assert.equal(existsSync(join(packageRoot, ".gentle-ai", "v4.5.0", "gentle-ai.exe")), true, "the verified binary is published into the package");
294
295
  } finally {
295
296
  await rm(packageRoot, { recursive: true, force: true });
296
297
  await rm(temporaryDirectory, { recursive: true, force: true });
@@ -312,7 +313,7 @@ test("Windows source install cleans staging after Go failure or wrong built vers
312
313
  () => installGentleAi({ packageRoot, platform: "win32", arch: "x64", execFile: fixture.run, resolveGoExecutable: async () => goPath }),
313
314
  (error: unknown) => error instanceof Error && "code" in error && error.code === fixtureOptions.expectedCode,
314
315
  );
315
- const runtimeDirectory = join(packageRoot, ".gentle-ai", "v4.4.0");
316
+ const runtimeDirectory = join(packageRoot, ".gentle-ai", "v4.5.0");
316
317
  assert.ok(fixture.calls.some((call) => call.arguments_[0] === "install"));
317
318
  assert.equal(existsSync(join(runtimeDirectory, "gentle-ai.exe")), false);
318
319
  assert.equal(existsSync(runtimeDirectory) && (await readdir(runtimeDirectory)).some((entry) => entry.startsWith(".go-install-") || entry.endsWith(".tmp")), false);
@@ -333,7 +334,7 @@ test("Windows source installs reuse only a fully verified package-local binary",
333
334
  assert.equal(reused.installed, false);
334
335
  assert.ok(reuse.calls.every((call) => call.file !== "gentle-ai"), "the installer must never fall back to ambient gentle-ai on PATH");
335
336
 
336
- await writeFile(join(packageRoot, ".gentle-ai", "v4.4.0", "integrity.json"), "{}\n");
337
+ await writeFile(join(packageRoot, ".gentle-ai", "v4.5.0", "integrity.json"), "{}\n");
337
338
  const repaired = windowsGoFixture();
338
339
  repaired.setGoExecutable(goPath);
339
340
  assert.equal((await installGentleAi({ packageRoot, platform: "win32", arch: "x64", execFile: repaired.run, resolveGoExecutable: async () => goPath })).installed, true);
@@ -375,7 +376,7 @@ async function hardenedWindowsGoFixture(packageRoot: string, fixtureOptions: Har
375
376
  const metadata = fixtureOptions.metadataOverride ?? [
376
377
  "gentle-ai.exe: go1.25.10",
377
378
  "\tpath\tgithub.com/gentleman-programming/gentle-ai/v4/cmd/gentle-ai",
378
- `\tmod\tgithub.com/gentleman-programming/gentle-ai/v4\tv4.4.0\t${GENTLE_AI_WINDOWS_SOURCE_MODULE_CHECKSUM}`,
379
+ `\tmod\tgithub.com/gentleman-programming/gentle-ai/v4\tv4.5.0\t${GENTLE_AI_WINDOWS_SOURCE_MODULE_CHECKSUM}`,
379
380
  "\tbuild\t-buildmode=exe",
380
381
  "\tbuild\t-compiler=gc",
381
382
  "\tbuild\tCGO_ENABLED=0",
@@ -395,7 +396,7 @@ async function hardenedWindowsGoFixture(packageRoot: string, fixtureOptions: Har
395
396
  return { stdout: "", stderr: "" };
396
397
  }
397
398
  if (file === goPath && arguments_[0] === "version" && arguments_[1] === "-m") return { stdout: metadata, stderr: "" };
398
- if (arguments_.length === 1 && arguments_[0] === "version") return { stdout: "gentle-ai 4.4.0\n", stderr: "" };
399
+ if (arguments_.length === 1 && arguments_[0] === "version") return { stdout: "gentle-ai 4.5.0\n", stderr: "" };
399
400
  throw new Error(`unexpected command: ${file} ${arguments_.join(" ")}`);
400
401
  };
401
402
  return {
@@ -437,7 +438,7 @@ test("Windows source installation resolves one validated Go executable and seals
437
438
  const goCalls = fixture.calls.filter((call) => call.file === fixture.goPath);
438
439
  assert.deepEqual(goCalls.map((call) => call.arguments_.slice(0, 2)), [
439
440
  ["version"],
440
- ["install", "github.com/gentleman-programming/gentle-ai/v4/cmd/gentle-ai@v4.4.0"],
441
+ ["install", "github.com/gentleman-programming/gentle-ai/v4/cmd/gentle-ai@v4.5.0"],
441
442
  ["version", "-m"],
442
443
  ]);
443
444
  for (const call of goCalls) {
@@ -463,14 +464,14 @@ test("Windows source manifest binds verified Go metadata and architecture", asyn
463
464
  const packageRoot = await mkdtemp(join(tmpdir(), "gentle-pi-installer-provenance-"));
464
465
  const fixture = await hardenedWindowsGoFixture(packageRoot, { architecture: "arm64" });
465
466
  const result = await installGentleAi({ packageRoot, platform: "win32", arch: "arm64", execFile: fixture.run, resolveGoExecutable: fixture.resolveGoExecutable });
466
- const manifest = JSON.parse(await readFile(join(packageRoot, ".gentle-ai", "v4.4.0", "integrity.json"), "utf8")) as Record<string, string>;
467
+ const manifest = JSON.parse(await readFile(join(packageRoot, ".gentle-ai", "v4.5.0", "integrity.json"), "utf8")) as Record<string, string>;
467
468
  assert.equal(result.installed, true);
468
469
  assert.deepEqual(manifest, {
469
- version: "4.4.0",
470
+ version: "4.5.0",
470
471
  method: "go-sumdb-source-build",
471
472
  package: "github.com/gentleman-programming/gentle-ai/v4/cmd/gentle-ai",
472
473
  module: "github.com/gentleman-programming/gentle-ai/v4",
473
- tag: "v4.4.0",
474
+ tag: "v4.5.0",
474
475
  architecture: "arm64",
475
476
  binarySha256: createHash("sha256").update("trusted Windows source build").digest("hex"),
476
477
  moduleChecksum: GENTLE_AI_WINDOWS_SOURCE_MODULE_CHECKSUM,
@@ -490,12 +491,12 @@ test("Windows source installation rejects Go metadata for a different architectu
490
491
  () => installGentleAi({ packageRoot, platform: "win32", arch: "x64", execFile: fixture.run, resolveGoExecutable: fixture.resolveGoExecutable }),
491
492
  (error: unknown) => error instanceof Error && "code" in error && error.code === "GENTLE_AI_GO_INSTALL_FAILED",
492
493
  );
493
- assert.equal(existsSync(join(packageRoot, ".gentle-ai", "v4.4.0", "gentle-ai.exe")), false);
494
+ assert.equal(existsSync(join(packageRoot, ".gentle-ai", "v4.5.0", "gentle-ai.exe")), false);
494
495
  });
495
496
 
496
497
  test("Windows source installation treats a fresh ownerless lock as active", async () => {
497
498
  const packageRoot = await mkdtemp(join(tmpdir(), "gentle-pi-installer-ownerless-lock-"));
498
- const lockPath = join(packageRoot, ".gentle-ai", ".v4.4.0.install.lock");
499
+ const lockPath = join(packageRoot, ".gentle-ai", ".v4.5.0.install.lock");
499
500
  await mkdir(lockPath, { recursive: true });
500
501
  const fixture = await hardenedWindowsGoFixture(packageRoot);
501
502
  await assertManualLockRecoveryRequired(packageRoot, fixture);
@@ -503,7 +504,7 @@ test("Windows source installation treats a fresh ownerless lock as active", asyn
503
504
 
504
505
  test("Windows source installation preserves a lock whose owner nonce changed before release", async () => {
505
506
  const packageRoot = await mkdtemp(join(tmpdir(), "gentle-pi-installer-owner-lock-"));
506
- const lockOwnerPath = join(packageRoot, ".gentle-ai", ".v4.4.0.install.lock", "owner.json");
507
+ const lockOwnerPath = join(packageRoot, ".gentle-ai", ".v4.5.0.install.lock", "owner.json");
507
508
  const fixture = await hardenedWindowsGoFixture(packageRoot);
508
509
  let replacedOwner = false;
509
510
  const run = async (...arguments_: Parameters<typeof fixture.run>) => {
@@ -520,7 +521,7 @@ test("Windows source installation preserves a lock whose owner nonce changed bef
520
521
  });
521
522
 
522
523
  async function assertManualLockRecoveryRequired(packageRoot: string, fixture: Awaited<ReturnType<typeof hardenedWindowsGoFixture>>, options: Record<string, unknown> = {}) {
523
- const lockPath = join(packageRoot, ".gentle-ai", ".v4.4.0.install.lock");
524
+ const lockPath = join(packageRoot, ".gentle-ai", ".v4.5.0.install.lock");
524
525
  await assert.rejects(
525
526
  () => installGentleAi({ packageRoot, platform: "win32", arch: "x64", execFile: fixture.run, resolveGoExecutable: fixture.resolveGoExecutable, ...options }),
526
527
  (error: unknown) => error instanceof Error && error.message.includes(lockPath) && /confirm no installer is active.*remove.*manually/i.test(error.message),
@@ -530,18 +531,18 @@ async function assertManualLockRecoveryRequired(packageRoot: string, fixture: Aw
530
531
  }
531
532
 
532
533
  function tombstonePath(packageRoot: string, nonce: string): string {
533
- return join(packageRoot, ".gentle-ai", `.v4.4.0.install.tombstone-${nonce}`);
534
+ return join(packageRoot, ".gentle-ai", `.v4.5.0.install.tombstone-${nonce}`);
534
535
  }
535
536
 
536
537
  async function tombstones(packageRoot: string): Promise<string[]> {
537
538
  const runtimeRoot = join(packageRoot, ".gentle-ai");
538
539
  return existsSync(runtimeRoot)
539
- ? (await readdir(runtimeRoot)).filter((entry) => entry.startsWith(".v4.4.0.install.tombstone-"))
540
+ ? (await readdir(runtimeRoot)).filter((entry) => entry.startsWith(".v4.5.0.install.tombstone-"))
540
541
  : [];
541
542
  }
542
543
 
543
544
  function backupBundlePath(packageRoot: string, nonce: string): string {
544
- return join(packageRoot, ".gentle-ai", `.v4.4.0.backup-${nonce}`);
545
+ return join(packageRoot, ".gentle-ai", `.v4.5.0.backup-${nonce}`);
545
546
  }
546
547
 
547
548
  async function copyWindowsBundle(source: string, destination: string): Promise<void> {
@@ -552,7 +553,7 @@ async function copyWindowsBundle(source: string, destination: string): Promise<v
552
553
 
553
554
  test("Windows source installation fails closed for an ownerless lock even after the stale threshold", async () => {
554
555
  const packageRoot = await mkdtemp(join(tmpdir(), "gentle-pi-installer-ownerless-stale-lock-"));
555
- const lockPath = join(packageRoot, ".gentle-ai", ".v4.4.0.install.lock");
556
+ const lockPath = join(packageRoot, ".gentle-ai", ".v4.5.0.install.lock");
556
557
  await mkdir(lockPath, { recursive: true });
557
558
  const fixture = await hardenedWindowsGoFixture(packageRoot);
558
559
  await assertManualLockRecoveryRequired(packageRoot, fixture, { now: () => Date.now() + 10 * 60_000 });
@@ -560,7 +561,7 @@ test("Windows source installation fails closed for an ownerless lock even after
560
561
 
561
562
  test("Windows source installation fails closed for a stale owner lock", async () => {
562
563
  const packageRoot = await mkdtemp(join(tmpdir(), "gentle-pi-installer-stale-lock-"));
563
- const lockPath = join(packageRoot, ".gentle-ai", ".v4.4.0.install.lock");
564
+ const lockPath = join(packageRoot, ".gentle-ai", ".v4.5.0.install.lock");
564
565
  await mkdir(lockPath, { recursive: true });
565
566
  await writeFile(join(lockPath, "owner.json"), `${JSON.stringify({ createdAt: 0, nonce: "0".repeat(64) })}\n`);
566
567
  const fixture = await hardenedWindowsGoFixture(packageRoot);
@@ -612,7 +613,7 @@ test("Windows source acquisition fails closed when a tombstone appears after its
612
613
  (error: unknown) => error instanceof Error && error.message.includes(foreignTombstone),
613
614
  );
614
615
  assert.equal(existsSync(foreignTombstone), true);
615
- assert.equal(existsSync(join(packageRoot, ".gentle-ai", ".v4.4.0.install.lock")), false);
616
+ assert.equal(existsSync(join(packageRoot, ".gentle-ai", ".v4.5.0.install.lock")), false);
616
617
  assert.equal(fixture.calls.some((call) => call.arguments_[0] === "install"), false);
617
618
  });
618
619
 
@@ -620,7 +621,7 @@ test("Windows source release deletes its matching tombstone and allows reuse", a
620
621
  const packageRoot = await mkdtemp(join(tmpdir(), "gentle-pi-installer-owned-lock-release-"));
621
622
  const fixture = await hardenedWindowsGoFixture(packageRoot);
622
623
  await installGentleAi({ packageRoot, platform: "win32", arch: "x64", execFile: fixture.run, resolveGoExecutable: fixture.resolveGoExecutable });
623
- assert.equal(existsSync(join(packageRoot, ".gentle-ai", ".v4.4.0.install.lock")), false);
624
+ assert.equal(existsSync(join(packageRoot, ".gentle-ai", ".v4.5.0.install.lock")), false);
624
625
  assert.deepEqual(await tombstones(packageRoot), []);
625
626
  const reuse = await hardenedWindowsGoFixture(packageRoot);
626
627
  assert.equal((await installGentleAi({ packageRoot, platform: "win32", arch: "x64", execFile: reuse.run, resolveGoExecutable: reuse.resolveGoExecutable })).installed, false);
@@ -630,7 +631,7 @@ test("Windows source recovers a valid backup after a crash between publication r
630
631
  const packageRoot = await mkdtemp(join(tmpdir(), "gentle-pi-installer-backup-crash-"));
631
632
  const initial = await hardenedWindowsGoFixture(packageRoot);
632
633
  await installGentleAi({ packageRoot, platform: "win32", arch: "x64", execFile: initial.run, resolveGoExecutable: initial.resolveGoExecutable });
633
- const live = join(packageRoot, ".gentle-ai", "v4.4.0");
634
+ const live = join(packageRoot, ".gentle-ai", "v4.5.0");
634
635
  const backup = backupBundlePath(packageRoot, "crash");
635
636
  await rename(live, backup);
636
637
  const recovery = await hardenedWindowsGoFixture(packageRoot);
@@ -666,7 +667,7 @@ test("Windows source cleans one validated backup only when the live bundle is va
666
667
  const packageRoot = await mkdtemp(join(tmpdir(), "gentle-pi-installer-backup-valid-live-"));
667
668
  const initial = await hardenedWindowsGoFixture(packageRoot);
668
669
  await installGentleAi({ packageRoot, platform: "win32", arch: "x64", execFile: initial.run, resolveGoExecutable: initial.resolveGoExecutable });
669
- const live = join(packageRoot, ".gentle-ai", "v4.4.0");
670
+ const live = join(packageRoot, ".gentle-ai", "v4.5.0");
670
671
  const backup = backupBundlePath(packageRoot, "valid");
671
672
  await copyWindowsBundle(live, backup);
672
673
  const reuse = await hardenedWindowsGoFixture(packageRoot);
@@ -679,7 +680,7 @@ test("Windows source preserves a valid backup when the live bundle is invalid",
679
680
  const packageRoot = await mkdtemp(join(tmpdir(), "gentle-pi-installer-backup-invalid-live-"));
680
681
  const initial = await hardenedWindowsGoFixture(packageRoot);
681
682
  await installGentleAi({ packageRoot, platform: "win32", arch: "x64", execFile: initial.run, resolveGoExecutable: initial.resolveGoExecutable });
682
- const live = join(packageRoot, ".gentle-ai", "v4.4.0");
683
+ const live = join(packageRoot, ".gentle-ai", "v4.5.0");
683
684
  const backup = backupBundlePath(packageRoot, "valid");
684
685
  await copyWindowsBundle(live, backup);
685
686
  await writeFile(join(live, "integrity.json"), "{}\n");
@@ -697,7 +698,7 @@ test("Windows concurrent installs fail closed until normal release, then reuse t
697
698
  const fixture = await hardenedWindowsGoFixture(packageRoot, { blockInstall: true });
698
699
  const first = installGentleAi({ packageRoot, platform: "win32", arch: "x64", execFile: fixture.run, resolveGoExecutable: fixture.resolveGoExecutable });
699
700
  await fixture.waitForInstall();
700
- const lockPath = join(packageRoot, ".gentle-ai", ".v4.4.0.install.lock");
701
+ const lockPath = join(packageRoot, ".gentle-ai", ".v4.5.0.install.lock");
701
702
  await assert.rejects(
702
703
  () => installGentleAi({ packageRoot, platform: "win32", arch: "x64", execFile: fixture.run, resolveGoExecutable: fixture.resolveGoExecutable }),
703
704
  (error: unknown) => error instanceof Error && error.message.includes(lockPath),
@@ -711,7 +712,7 @@ test("Windows concurrent installs fail closed until normal release, then reuse t
711
712
 
712
713
  test("Windows source publication rolls back a prior bundle when final directory swap fails", async () => {
713
714
  const packageRoot = await mkdtemp(join(tmpdir(), "gentle-pi-installer-rollback-"));
714
- const versionDirectory = join(packageRoot, ".gentle-ai", "v4.4.0");
715
+ const versionDirectory = join(packageRoot, ".gentle-ai", "v4.5.0");
715
716
  await mkdir(versionDirectory, { recursive: true });
716
717
  await writeFile(join(versionDirectory, "old.txt"), "previous bundle");
717
718
  const fixture = await hardenedWindowsGoFixture(packageRoot);
@@ -1147,7 +1148,7 @@ test("Darwin/Linux signed bundles retain their four-field manifest and reusable
1147
1148
  },
1148
1149
  };
1149
1150
  await installGentleAi(options);
1150
- const manifestPath = join(packageRoot, ".gentle-ai", "v4.4.0", "integrity.json");
1151
+ const manifestPath = join(packageRoot, ".gentle-ai", "v4.5.0", "integrity.json");
1151
1152
  const manifest = JSON.parse(await readFile(manifestPath, "utf8")) as Record<string, string>;
1152
1153
  assert.deepEqual(Object.keys(manifest), ["version", "asset", "assetSha256", "binarySha256"]);
1153
1154
  assert.equal((await installGentleAi({ ...options, download: async () => { throw new Error("signed bundle must be reused"); } })).installed, false);
@@ -1160,7 +1161,7 @@ test("a pinned asset falls back to its gentle-pi mirror only on download failure
1160
1161
  // under the current stable pin, whose form gate refuses raw binaries.
1161
1162
  const payload = Buffer.from("signed archive fixture");
1162
1163
  const binary = "mirrored binary";
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" };
1164
+ const baseAsset = { name: "gentle-ai_4.5.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" };
1164
1165
  const extractArchive = async (_archive: string, destination: string) => {
1165
1166
  await mkdir(destination, { recursive: true });
1166
1167
  await writeFile(join(destination, "gentle-ai"), binary);
@@ -1304,7 +1305,7 @@ test("checksum mismatch cleans temporary state without promoting a binary", asyn
1304
1305
  }),
1305
1306
  /checksum mismatch/,
1306
1307
  );
1307
- assert.equal(existsSync(join(packageRoot, ".gentle-ai", "v4.4.0", "gentle-ai")), false);
1308
+ assert.equal(existsSync(join(packageRoot, ".gentle-ai", "v4.5.0", "gentle-ai")), false);
1308
1309
  assert.deepEqual((await readdir(packageRoot)).filter((entry) => entry.startsWith(".gentle-ai-install-")), []);
1309
1310
  });
1310
1311
 
@@ -1326,7 +1327,7 @@ test("installer promotes only the expected regular executable with executable PO
1326
1327
  await chmod(extracted, 0o700);
1327
1328
  },
1328
1329
  });
1329
- const binary = join(packageRoot, ".gentle-ai", "v4.4.0", "gentle-ai");
1330
+ const binary = join(packageRoot, ".gentle-ai", "v4.5.0", "gentle-ai");
1330
1331
  assert.equal(existsSync(binary), true);
1331
1332
  assert.equal(await readFile(binary, "utf8"), "native executable");
1332
1333
  assert.ok(((await stat(binary)).mode & 0o111) !== 0);
@@ -1357,7 +1358,7 @@ test("installer rejects an extracted binary that differs from its pinned digest"
1357
1358
  }),
1358
1359
  /binary checksum mismatch/,
1359
1360
  );
1360
- assert.equal(existsSync(join(packageRoot, ".gentle-ai", "v4.4.0", "gentle-ai")), false);
1361
+ assert.equal(existsSync(join(packageRoot, ".gentle-ai", "v4.5.0", "gentle-ai")), false);
1361
1362
  });
1362
1363
 
1363
1364
  test("installer repairs a valid non-executable POSIX binary instead of reusing it", async (t) => {
@@ -1380,7 +1381,7 @@ test("installer repairs a valid non-executable POSIX binary instead of reusing i
1380
1381
  },
1381
1382
  };
1382
1383
  await installGentleAi(options);
1383
- const binary = join(packageRoot, ".gentle-ai", "v4.4.0", "gentle-ai");
1384
+ const binary = join(packageRoot, ".gentle-ai", "v4.5.0", "gentle-ai");
1384
1385
  await chmod(binary, 0o600);
1385
1386
  const repaired = await installGentleAi(options);
1386
1387
  assert.equal(repaired.installed, true);
@@ -1417,7 +1418,7 @@ test("installer rejects archives with multiple expected executable entries", asy
1417
1418
  }),
1418
1419
  /exactly one regular gentle-ai/,
1419
1420
  );
1420
- assert.equal(existsSync(join(packageRoot, ".gentle-ai", "v4.4.0", "gentle-ai")), false);
1421
+ assert.equal(existsSync(join(packageRoot, ".gentle-ai", "v4.5.0", "gentle-ai")), false);
1421
1422
  });
1422
1423
 
1423
1424
  test("installer rejects an archive without the expected regular executable", async () => {
@@ -1435,7 +1436,7 @@ test("installer rejects an archive without the expected regular executable", asy
1435
1436
  }),
1436
1437
  /non-regular gentle-ai/,
1437
1438
  );
1438
- assert.equal(existsSync(join(packageRoot, ".gentle-ai", "v4.4.0", "gentle-ai")), false);
1439
+ assert.equal(existsSync(join(packageRoot, ".gentle-ai", "v4.5.0", "gentle-ai")), false);
1439
1440
  });
1440
1441
 
1441
1442
  test("safeRemoveDirectory passes Windows-safe retry options to recursive rm cleanup", async () => {
@@ -48,11 +48,13 @@ test("completed review cards fit Pi's default Box at terminal width 57", () => {
48
48
 
49
49
  test("review registrations own their shell", () => {
50
50
  const tools: ToolDefinition[] = [];
51
- createGentleAiExtension({ nativeReviewCli: null } as never)({
51
+ // An explicit empty environment: an inherited GENTLE_PI_AGENTS_CHILD=1 or
52
+ // GENTLE_PI_EXPERIMENTAL_REVIEW_COORDINATOR=0 would drop gentle_review_run.
53
+ createGentleAiExtension({ nativeReviewCli: null, processEnv: {} } as never)({
52
54
  on() {}, registerCommand() {}, registerTool(tool: ToolDefinition) { tools.push(tool); },
53
55
  } as unknown as ExtensionAPI);
54
56
  const review = tools.filter((tool) => tool.name.startsWith("gentle_review"));
55
- assert.equal(review.length, 4);
57
+ assert.equal(review.length, 5);
56
58
  for (const tool of review) assert.equal(tool.renderShell, "self", tool.name);
57
59
  });
58
60
 
@@ -471,6 +473,38 @@ test("JSON summaries stay bounded at every width", () => {
471
473
  assert.match(narrow[0], /^unassessable · native.*…$/);
472
474
  });
473
475
 
476
+ // T9: with a UI the run shows each reviewer-run forecast as a partial update
477
+ // right before the reviewers run; its collapsed line says what will run.
478
+ const groupForecast = { tool: "gentle_review_capture_group", status: "blocked", outcome: "reviewer-model-run-forecast",
479
+ cost_forecast: { transport: "pi_host_relay", model_runs: 2, lenses: ["review-risk", "review-reliability"] }, mutation_performed: false, mutation_outcome: "none" };
480
+ const refuterForecast = { tool: "gentle_review_capture", status: "blocked", outcome: "reviewer-model-run-forecast",
481
+ cost_forecast: { transport: "pi_host_relay", model_runs: 1, roles: ["review-refuter"] }, mutation_performed: false, mutation_outcome: "none" };
482
+
483
+ test("a collapsed reviewer-run forecast shows the model-run count and the lenses or roles", () => {
484
+ for (const isPartial of [true, false]) {
485
+ const render = (envelope: unknown, width: number) => bodyRows(renderGentleAiResult(jsonResult(envelope), { expanded: false, isPartial }, plainTheme).render(width));
486
+ assert.deepEqual(render(groupForecast, 120), ["2 model runs · review-risk, review-reliability · blocked · reviewer-model-run-forecast"]);
487
+ assert.deepEqual(render(refuterForecast, 120), ["1 model run · review-refuter · blocked · reviewer-model-run-forecast"]);
488
+ const at80 = render(groupForecast, 80);
489
+ assert.equal(at80.length, 1);
490
+ assert.match(at80[0], /^2 model runs · review-risk, review-reliability · .*…$/, "the count and lenses survive the cut");
491
+ assert.match(render(groupForecast, 40)[0], /^2 model runs · review-risk, revie.*…$/);
492
+ }
493
+ for (const width of [0, 1, 2, 3, 4, 5, 6, 7, 8, 24, 40, 80]) {
494
+ const rows = renderGentleAiResult(jsonResult(groupForecast), { expanded: false }, plainTheme).render(width);
495
+ if (width === 0) { assert.deepEqual(rows, []); continue; }
496
+ assert.ok(rows.length <= 3, `width ${width}: ${rows.length} rows`);
497
+ assert.ok(rows.every((row) => visibleWidth(row) <= width), `width ${width}`);
498
+ }
499
+ });
500
+
501
+ test("envelopes that are not a reviewer-run forecast keep their ordinary collapsed line", () => {
502
+ const render = (envelope: unknown) => bodyRows(renderGentleAiResult(jsonResult(envelope), { expanded: false }, plainTheme).render(120));
503
+ // Same cost_forecast shape under another outcome: unchanged.
504
+ assert.deepEqual(render({ ...groupForecast, outcome: "native-reviewer-result-captured" }), ["blocked · native-reviewer-result-captured"]);
505
+ assert.deepEqual(render(inspectEnvelope), ["blocked · start · fresh_target_ready"]);
506
+ });
507
+
474
508
  // The rose call card reads like the quiet read card: glyph, a short name and
475
509
  // the operation as its argument, in one title span without a muted subtitle.
476
510
 
@@ -34,6 +34,7 @@ import type { ReviewCollectInputV3, ReviewStatusV3 } from "../lib/review-integra
34
34
  import { stripAnsi } from "../lib/terminal-theme.ts";
35
35
  import { cardBody, cardTitle, cardTone } from "./gentle-card-text.ts";
36
36
  import { readDelegationDetail } from "./support/orchestrator-modules.ts";
37
+ import { beginDesktopProfileApply, endDesktopProfileApply } from "../lib/desktop-rpc-profiles.ts";
37
38
 
38
39
  initTheme("dark");
39
40
 
@@ -80,7 +81,7 @@ function renderComponent(component: { render(width: number): string[] }): string
80
81
  return component.render(120).map((line) => line.replace(/[ \t]+$/g, "")).join("\n");
81
82
  }
82
83
 
83
- function registeredGentleTools(): Map<string, any> {
84
+ function registeredGentleTools(processEnv?: NodeJS.ProcessEnv): Map<string, any> {
84
85
  const tools = new Map<string, any>();
85
86
  const pi = {
86
87
  on() {},
@@ -89,7 +90,7 @@ function registeredGentleTools(): Map<string, any> {
89
90
  tools.set(tool.name, tool);
90
91
  },
91
92
  } as unknown as ExtensionAPI;
92
- createGentleAiExtension({ nativeReviewCli: null })(pi);
93
+ createGentleAiExtension({ nativeReviewCli: null, ...(processEnv === undefined ? {} : { processEnv }) })(pi);
93
94
  return tools;
94
95
  }
95
96
 
@@ -244,12 +245,15 @@ test("missing package-local binaries give a direct recovery without attributing
244
245
  });
245
246
 
246
247
  test("registered Gentle Review tools render reusable rose lifecycle call rows", () => {
247
- const tools = registeredGentleTools();
248
+ // An explicit empty environment, so an inherited child or opt-out variable
249
+ // cannot drop gentle_review_run from the registered family this test lists.
250
+ const tools = registeredGentleTools({});
248
251
  const cases = [
249
252
  ["gentle_review", { operation: "status" }, "status"],
250
253
  ["gentle_review", { operation: "future-operation", secret: "/private" }, ""],
251
254
  ["gentle_review_scope", {}, "scope"],
252
255
  ["gentle_review_capture_group", {}, "capture group"],
256
+ ["gentle_review_run", { lineageId: "lineage-id" }, "run"],
253
257
  [
254
258
  "gentle_review_capture",
255
259
  {
@@ -1568,7 +1572,7 @@ test("models screen lists configuration problems under the profile name without
1568
1572
  assert.ok(!plain.some((line) => line.includes("…")));
1569
1573
  });
1570
1574
 
1571
- test("delivery commands bypass RDD under every mode outcome while command safety remains independent", async () => {
1575
+ test("#2997: due-review workflow preflight precedes delivery while commits and ordinary command safety remain independent", async () => {
1572
1576
  type ToolCallHandler = (
1573
1577
  event: { toolName: string; input: unknown },
1574
1578
  ctx: ExtensionContext,
@@ -1611,7 +1615,12 @@ test("delivery commands bypass RDD under every mode outcome while command safety
1611
1615
 
1612
1616
  for (const command of commands) {
1613
1617
  const result = await toolCall!({ toolName: "bash", input: { command } }, ctx);
1614
- assert.equal(result, undefined, `${mode.label}: ${command}`);
1618
+ const deliveryCommands: readonly string[] = [commands[1], commands[2], commands[5], commands[6]];
1619
+ const delivery = deliveryCommands.includes(command);
1620
+ if (delivery && (mode.label === "RDD on" || mode.label === "mode failure")) {
1621
+ assert.equal(result?.block, true, `${mode.label}: ${command}`);
1622
+ assert.match(result?.reason ?? "", /RDD pre-delivery/);
1623
+ } else assert.equal(result, undefined, `${mode.label}: ${command}`);
1615
1624
  }
1616
1625
  }
1617
1626
  });
@@ -1883,7 +1892,7 @@ test(`${channel} emits only a private, balanced Herdr projection`, () => {
1883
1892
  registerTool() {},
1884
1893
  } as unknown as ExtensionAPI;
1885
1894
  createGentleAiExtension({ nativeReviewCli: null })(pi);
1886
- const privateHostDiscovery = new Set(["gentle:yolo:host-ui", "gentle:rdd:host-ui"]);
1895
+ const privateHostDiscovery = new Set(["gentle:yolo:host-ui", "gentle:rdd:host-ui", "gentle:desktop:profiles-service"]);
1887
1896
  for (const channel of privateHostDiscovery) assert.equal(eventHandlers.has(channel), true);
1888
1897
  assert.deepEqual([...eventHandlers.keys()].filter(name => !privateHostDiscovery.has(name)).sort(), [
1889
1898
  "gentle-pi:ask-user-choice:blocked", "gentle-pi:ask-user-question:blocked", "rpiv:ask-user:blocked",
@@ -5089,6 +5098,112 @@ test("a keeps the legacy global apply semantics", async (t) => {
5089
5098
  assert.ok(existsSync(fixture.globalPath), "the global routing is materialized");
5090
5099
  });
5091
5100
 
5101
+ function desktopApplyHarness(t: test.TestContext) {
5102
+ const store = profilesStoreFixture(t);
5103
+ const ctx = {
5104
+ cwd: store.fixture.root,
5105
+ hasUI: true,
5106
+ ui: { notify() { throw new Error("the screen UI is never used by a Desktop apply"); }, confirm: async () => { throw new Error("the screen UI is never used by a Desktop apply"); } },
5107
+ sessionManager: { getSessionId: () => "session-desktop" },
5108
+ } as unknown as ExtensionContext;
5109
+ const live = { setModel: async () => true, setThinkingLevel() {}, getThinkingLevel(): ThinkingLevel { return "medium"; } };
5110
+ return { ...store, ctx, live };
5111
+ }
5112
+
5113
+ test("Desktop apply_profile default asks the screen's own confirmation and writes nothing without its token", async (t) => {
5114
+ const h = desktopApplyHarness(t);
5115
+ h.writeStore({ team: { worker: { model: "openai/alpha" } }, old: {} }, "old");
5116
+ // A readable, empty global routing makes the screen list the concrete diff.
5117
+ writeFileSync(h.fixture.globalPath, "{}\n");
5118
+ const storeBefore = readFileSync(h.storePath, "utf8");
5119
+ const asked = await __testing.applyDesktopProfile(h.ctx, h.live, { profile: "team", mode: "default" });
5120
+ assert.equal(asked.status, "confirmation_required");
5121
+ assert.ok(asked.status === "confirmation_required");
5122
+ assert.equal(asked.title, 'Apply profile "team"?');
5123
+ assert.match(asked.message, /worker: openai\/alpha \(added\)/);
5124
+ assert.match(asked.confirmation, /^[0-9a-f]{64}$/);
5125
+ assert.equal(readFileSync(h.storePath, "utf8"), storeBefore, "asking writes nothing");
5126
+ assert.equal(readFileSync(h.fixture.globalPath, "utf8"), "{}\n", "asking writes no routing");
5127
+
5128
+ const wrong = await __testing.applyDesktopProfile(h.ctx, h.live, { profile: "team", mode: "default", confirmation: "0".repeat(64) });
5129
+ assert.deepEqual(wrong, asked, "a wrong token asks again with the same text");
5130
+ assert.equal(readFileSync(h.storePath, "utf8"), storeBefore);
5131
+ assert.equal(readFileSync(h.fixture.globalPath, "utf8"), "{}\n");
5132
+
5133
+ const applied = await __testing.applyDesktopProfile(h.ctx, h.live, { profile: "team", mode: "default", confirmation: asked.confirmation });
5134
+ assert.equal(applied.status, "applied");
5135
+ assert.ok(applied.status === "applied");
5136
+ assert.match(applied.notes.at(-1)?.text ?? "", /applied profile "team"/);
5137
+ assert.equal(applied.notes.at(-1)?.level, "info");
5138
+ assert.equal(JSON.parse(readFileSync(h.storePath, "utf8")).active, "team", "the store claims the profile");
5139
+ assert.match(readFileSync(h.fixture.globalPath, "utf8"), /openai\/alpha/, "the global routing is materialized");
5140
+ });
5141
+
5142
+ test("Desktop apply_profile refuses a token for a diff that changed since it was shown", async (t) => {
5143
+ const h = desktopApplyHarness(t);
5144
+ h.writeStore({ team: { worker: { model: "openai/alpha" } }, old: {} }, "old");
5145
+ const asked = await __testing.applyDesktopProfile(h.ctx, h.live, { profile: "team", mode: "default" });
5146
+ assert.ok(asked.status === "confirmation_required");
5147
+ h.writeStore({ team: { worker: { model: "openai/beta" } }, old: {} }, "old");
5148
+ const storeBefore = readFileSync(h.storePath, "utf8");
5149
+ const stale = await __testing.applyDesktopProfile(h.ctx, h.live, { profile: "team", mode: "default", confirmation: asked.confirmation });
5150
+ assert.ok(stale.status === "confirmation_required", "the changed diff is shown again");
5151
+ // Without a readable routing the screen's text does not list routes, so the
5152
+ // token must also bind the profile itself for an edit to ask again.
5153
+ assert.notEqual(stale.confirmation, asked.confirmation);
5154
+ assert.equal(readFileSync(h.storePath, "utf8"), storeBefore, "a stale token writes nothing");
5155
+ assert.equal(existsSync(h.fixture.globalPath), false);
5156
+ });
5157
+
5158
+ test("Desktop apply_profile names an unknown profile and writes nothing", async (t) => {
5159
+ const h = desktopApplyHarness(t);
5160
+ h.writeStore({ team: { worker: { model: "openai/alpha" } } }, undefined);
5161
+ const storeBefore = readFileSync(h.storePath, "utf8");
5162
+ assert.deepEqual(await __testing.applyDesktopProfile(h.ctx, h.live, { profile: "missing", mode: "default" }), { status: "unknown_profile" });
5163
+ assert.deepEqual(await __testing.applyDesktopProfile(h.ctx, h.live, { profile: "missing", mode: "session" }), { status: "unknown_profile" });
5164
+ assert.equal(readFileSync(h.storePath, "utf8"), storeBefore);
5165
+ assert.equal(existsSync(h.fixture.globalPath), false);
5166
+ });
5167
+
5168
+ test("Desktop apply_profile session binds through the screen's path and writes nothing shared", async (t) => {
5169
+ const h = desktopApplyHarness(t);
5170
+ h.writeStore({ team: { worker: { model: "openai/alpha" } }, old: {} }, "old");
5171
+ const storeBefore = readFileSync(h.storePath, "utf8");
5172
+ const manager = profileActionManager(h.fixture.root);
5173
+ const ctx = { cwd: h.fixture.root, hasUI: true, ui: {}, sessionManager: manager } as unknown as ExtensionContext;
5174
+ const bound = await __testing.applyDesktopProfile(ctx, h.live, { profile: "team", mode: "session" });
5175
+ assert.equal(bound.status, "applied");
5176
+ assert.equal(readSessionProfileBinding(manager.getSessionId())?.name, "team");
5177
+ assert.equal(readFileSync(h.storePath, "utf8"), storeBefore, "the store is untouched");
5178
+ assert.equal(existsSync(h.fixture.globalPath), false, "no global routing is written");
5179
+ });
5180
+
5181
+ test("the screen's Make default waits for a running Desktop apply instead of racing it", async (t) => {
5182
+ const { fixture, storePath, writeStore } = profilesStoreFixture(t);
5183
+ writeStore({ team: { worker: { model: "openai/alpha" } }, old: {} }, "old");
5184
+ const storeBefore = readFileSync(storePath, "utf8");
5185
+ assert.equal(beginDesktopProfileApply(), true);
5186
+ t.after(() => endDesktopProfileApply());
5187
+ let asked = false;
5188
+ fixture.onConfirm(async () => { asked = true; return true; });
5189
+ applyOnce(fixture, "team");
5190
+ await fixture.run("gentle:profiles");
5191
+ assert.equal(asked, false, "nothing is asked while another apply runs");
5192
+ assert.equal(readFileSync(storePath, "utf8"), storeBefore, "the store is untouched");
5193
+ assert.equal(existsSync(fixture.globalPath), false, "no routing is written");
5194
+ assert.equal(beginDesktopProfileApply(), false, "the screen never releases a gate it did not take");
5195
+ });
5196
+
5197
+ test("Desktop apply_profile runs one apply at a time", async (t) => {
5198
+ const h = desktopApplyHarness(t);
5199
+ h.writeStore({ team: { worker: { model: "openai/alpha" } }, old: {} }, "old");
5200
+ const first = __testing.applyDesktopProfile(h.ctx, h.live, { profile: "team", mode: "default" });
5201
+ const second = __testing.applyDesktopProfile(h.ctx, h.live, { profile: "team", mode: "default" });
5202
+ assert.deepEqual(await second, { status: "busy" });
5203
+ assert.equal((await first).status, "confirmation_required");
5204
+ assert.equal((await __testing.applyDesktopProfile(h.ctx, h.live, { profile: "team", mode: "default" })).status, "confirmation_required", "the gate reopens");
5205
+ });
5206
+
5092
5207
  test("Enter with a winning pin binds the session and never touches the pin layers", async (t) => {
5093
5208
  const { fixture, storePath, writeStore, writePin, localPinPath } = profilesStoreFixture(t);
5094
5209
  writeStore({ team: { worker: { model: "openai/alpha" } }, old: {} }, undefined);