gentle-pi 4.6.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 (536) hide show
  1. package/README.md +65 -55
  2. package/assets/agents/gentle-ai-explore.md +4 -3
  3. package/assets/agents/gentle-ai-verify.md +23 -6
  4. package/assets/agents/gentle-ai-worker.md +9 -6
  5. package/assets/agents/jd-fix-agent.md +1 -0
  6. package/assets/agents/jd-judge-a.md +2 -3
  7. package/assets/agents/jd-judge-b.md +2 -3
  8. package/assets/agents/review-readability.md +1 -5
  9. package/assets/agents/review-reliability.md +1 -5
  10. package/assets/agents/review-resilience.md +1 -5
  11. package/assets/agents/review-risk.md +1 -5
  12. package/assets/design-canvas/canvas-api.js +45 -0
  13. package/assets/design-canvas/canvas-boards.js +456 -0
  14. package/assets/design-canvas/canvas-boot.js +217 -0
  15. package/assets/design-canvas/canvas-checks.js +491 -0
  16. package/assets/design-canvas/canvas-comments.js +315 -0
  17. package/assets/design-canvas/canvas-compare.js +159 -0
  18. package/assets/design-canvas/canvas-events.js +75 -0
  19. package/assets/design-canvas/canvas-export.js +393 -0
  20. package/assets/design-canvas/canvas-focus.js +203 -0
  21. package/assets/design-canvas/canvas-handoffs.js +150 -0
  22. package/assets/design-canvas/canvas-i18n-es.js +392 -0
  23. package/assets/design-canvas/canvas-i18n.js +108 -0
  24. package/assets/design-canvas/canvas-layout.js +526 -0
  25. package/assets/design-canvas/canvas-menu.js +213 -0
  26. package/assets/design-canvas/canvas-messages.js +86 -0
  27. package/assets/design-canvas/canvas-minimap.js +163 -0
  28. package/assets/design-canvas/canvas-parts.js +401 -0
  29. package/assets/design-canvas/canvas-popover.js +234 -0
  30. package/assets/design-canvas/canvas-rail.js +348 -0
  31. package/assets/design-canvas/canvas-sizes.js +524 -0
  32. package/assets/design-canvas/canvas-store.js +164 -0
  33. package/assets/design-canvas/canvas-tokens.js +674 -0
  34. package/assets/design-canvas/canvas-ui.js +24 -0
  35. package/assets/design-canvas/canvas-view.js +184 -0
  36. package/assets/design-canvas/canvas.css +759 -16
  37. package/assets/design-canvas/canvas.js +2 -1497
  38. package/assets/design-canvas/index.html +117 -36
  39. package/assets/design-canvas/inspector.js +546 -16
  40. package/assets/install-wizard/wizard.js +6 -1
  41. package/assets/migrations/agent-body-history.json +40 -1
  42. package/assets/orchestrator-delegation-reference.md +10 -16
  43. package/assets/orchestrator-delegation.md +5 -5
  44. package/assets/orchestrator-full-delegation-card.md +64 -0
  45. package/assets/orchestrator-full-delegation.md +34 -0
  46. package/assets/orchestrator-memory.md +5 -5
  47. package/assets/orchestrator-prompts.md +2 -2
  48. package/assets/orchestrator-quota-recovery.md +5 -0
  49. package/assets/orchestrator-skills.md +14 -13
  50. package/assets/orchestrator-tracking.md +10 -14
  51. package/assets/orchestrator-verification.md +12 -8
  52. package/assets/orchestrator-writer.md +4 -4
  53. package/assets/orchestrator.md +21 -25
  54. package/bin/gentle-shell.mjs +292 -65
  55. package/contracts/review-provider-contract-mirror/provider-contract.lock.json +8 -9
  56. package/contracts/review-provider-contract-mirror/{v1.4.0 → v1.5.0}/bundle/manifest.json +3 -3
  57. package/contracts/review-provider-contract-mirror/{v1.4.0 → v1.5.0}/bundle/orchestration/pi.md +1 -0
  58. package/contracts/review-provider-contract-mirror/{v1.4.0 → v1.5.0}/bundle/routing/pi.md +6 -6
  59. package/contracts/review-provider-contract-mirror/{v1.4.0 → v1.5.0}/generated/provider-capabilities.baseline.json +3 -3
  60. package/contracts/review-provider-contract-mirror/{v1.4.0 → v1.5.0}/generated/provider-roles.baseline.json +1 -1
  61. package/docs/agent-status.md +61 -0
  62. package/docs/assets/brand/sponsor-banner.svg +60 -0
  63. package/docs/bundled-install.md +20 -10
  64. package/docs/delegated-verification.md +46 -8
  65. package/docs/desktop-rpc.md +1253 -0
  66. package/docs/gentle-agents-activity.md +40 -0
  67. package/docs/gentle-shell.md +91 -30
  68. package/docs/install-wizard.md +30 -21
  69. package/docs/odd-preparation-continuity.md +24 -0
  70. package/docs/permission-modes.md +17 -4
  71. package/docs/prompt-budget.md +12 -0
  72. package/docs/rdd-odd-friction-triage-2026-11-07.md +57 -0
  73. package/docs/readme-reference.md +142 -45
  74. package/docs/render-cache-performance.md +11 -1
  75. package/docs/review-coordinator.md +53 -0
  76. package/docs/review-delivery-preflight.md +22 -0
  77. package/docs/review-request-context.md +19 -0
  78. package/docs/review-windows-acl.md +18 -0
  79. package/docs/voice.md +6 -3
  80. package/docs/work-continuity.md +11 -1
  81. package/docs/yolo-mode.md +5 -5
  82. package/extensions/ask-user-choice.ts +1 -0
  83. package/extensions/ask-user-question.ts +3 -2
  84. package/extensions/child-context.ts +21 -7
  85. package/extensions/child-safety.ts +3 -0
  86. package/extensions/gentle-agent-status.ts +99 -0
  87. package/extensions/gentle-agents.ts +559 -66
  88. package/extensions/gentle-ai.ts +2001 -518
  89. package/extensions/gentle-design.ts +69 -3
  90. package/extensions/gentle-desktop-rpc.ts +143 -0
  91. package/extensions/gentle-guide.ts +3 -0
  92. package/extensions/gentle-shell.ts +398 -115
  93. package/extensions/gentle-todo.ts +66 -27
  94. package/extensions/gentle-tps.ts +48 -0
  95. package/extensions/quiet-tools.ts +38 -8
  96. package/extensions/skill-registry.ts +349 -167
  97. package/extensions/startup-banner.ts +30 -3
  98. package/lib/agent-assets.ts +30 -6
  99. package/lib/agent-profile-pin.ts +3 -3
  100. package/lib/agent-profiles.ts +160 -2
  101. package/lib/agent-status.ts +105 -0
  102. package/lib/agent-tool-overlay.ts +117 -0
  103. package/lib/agents-config.ts +93 -6
  104. package/lib/agents-history.ts +24 -5
  105. package/lib/agents-message-delivery.ts +17 -0
  106. package/lib/agents-messaging.ts +55 -7
  107. package/lib/agents-protocol.ts +15 -0
  108. package/lib/agents-report-cap.ts +115 -0
  109. package/lib/agents-runner.ts +272 -16
  110. package/lib/agents-session-transport.ts +17 -1
  111. package/lib/auto-permission-runtime.ts +1 -1
  112. package/lib/background-jobs-tools.ts +9 -4
  113. package/lib/bounded-writer-admission.ts +197 -32
  114. package/lib/card-content-policy.ts +8 -6
  115. package/lib/child-context-files.ts +21 -6
  116. package/lib/codemode-renderer.ts +1 -0
  117. package/lib/command-palette.ts +133 -17
  118. package/lib/context-backstop.ts +14 -5
  119. package/lib/delivery-conflict-markers.ts +349 -0
  120. package/lib/design-canvas-assets.ts +36 -0
  121. package/lib/design-canvas-server.ts +241 -23
  122. package/lib/design-comments.ts +94 -4
  123. package/lib/design-handoffs.ts +2 -1
  124. package/lib/design-layout.ts +125 -0
  125. package/lib/design-parts.ts +281 -0
  126. package/lib/design-system-tokens.ts +111 -0
  127. package/lib/desktop-agents-service.ts +294 -0
  128. package/lib/desktop-design-service.ts +233 -0
  129. package/lib/desktop-jobs-service.ts +263 -0
  130. package/lib/desktop-rpc-agents.ts +294 -0
  131. package/lib/desktop-rpc-config.ts +731 -0
  132. package/lib/desktop-rpc-design.ts +138 -0
  133. package/lib/desktop-rpc-jobs.ts +181 -0
  134. package/lib/desktop-rpc-permissions.ts +177 -0
  135. package/lib/desktop-rpc-profiles.ts +196 -0
  136. package/lib/desktop-rpc-usage.ts +229 -0
  137. package/lib/desktop-rpc.ts +225 -0
  138. package/lib/desktop-usage-service.ts +310 -0
  139. package/lib/destructive-command-guard.ts +236 -17
  140. package/lib/execution-surface-guard.ts +20 -0
  141. package/lib/exploration-budget.ts +4 -2
  142. package/lib/gentle-ai-binary.ts +1 -1
  143. package/lib/gentle-ai-renderer.ts +13 -1
  144. package/lib/gentle-design.ts +204 -14
  145. package/lib/gentle-shell-bundled.ts +106 -28
  146. package/lib/gentle-shell-launcher.ts +43 -8
  147. package/lib/herdr-activity.ts +14 -2
  148. package/lib/herdr-busy.ts +45 -0
  149. package/lib/hidden-tools.ts +35 -0
  150. package/lib/image-attachments.ts +33 -0
  151. package/lib/image-disk-cache.ts +137 -0
  152. package/lib/inprocess-reviewer.ts +358 -144
  153. package/lib/jobs-view.ts +198 -11
  154. package/lib/model-fallback-policy.ts +9 -0
  155. package/lib/model-routing-authority.ts +31 -4
  156. package/lib/nan-provider.ts +42 -28
  157. package/lib/native-choice-list.ts +20 -2
  158. package/lib/native-review-cli.ts +172 -20
  159. package/lib/orchestrator-discovery.ts +39 -2
  160. package/lib/orchestrator-mode-policy.ts +105 -0
  161. package/lib/questionnaire/questionnaire-view.ts +105 -12
  162. package/lib/rdd-mode-control.ts +32 -0
  163. package/lib/reply-language-anchor.ts +129 -0
  164. package/lib/request-context-placement.ts +53 -0
  165. package/lib/review-blocker.ts +92 -0
  166. package/lib/review-candidate-symlink-scan.ts +136 -0
  167. package/lib/review-candidate-view-owner.ts +81 -44
  168. package/lib/review-candidate-view.ts +11 -1
  169. package/lib/review-continuation-registry.ts +116 -0
  170. package/lib/review-coordinator.ts +407 -0
  171. package/lib/review-delivery-preflight.ts +85 -0
  172. package/lib/review-failure-facts.ts +49 -0
  173. package/lib/review-host-relay.ts +51 -11
  174. package/lib/review-integration-v2.ts +63 -4
  175. package/lib/review-relay-phase-timing.ts +45 -0
  176. package/lib/review-start-context.ts +17 -0
  177. package/lib/reviewer-stream.ts +87 -0
  178. package/lib/session-profile-freeze.ts +4 -2
  179. package/lib/shell-bar.ts +140 -58
  180. package/lib/shell-changes.ts +2 -0
  181. package/lib/shell-panel.ts +17 -3
  182. package/lib/shell-prompt.ts +16 -3
  183. package/lib/shell-sidebar-layout.ts +112 -40
  184. package/lib/shell-sidebar.ts +7 -0
  185. package/lib/shell-todo.ts +10 -3
  186. package/lib/shell-usage.ts +10 -0
  187. package/lib/verifier-admission.ts +1 -1
  188. package/lib/vim-editor-adapter.ts +9 -2
  189. package/lib/visual-customization-policy.ts +36 -16
  190. package/lib/visual-customize-view.ts +216 -21
  191. package/lib/visual-layout-preview.ts +9 -5
  192. package/lib/visual-profiles.ts +2 -2
  193. package/lib/windows-session-transport.ts +53 -2
  194. package/lib/writer-batch-admission.ts +55 -0
  195. package/lib/yolo-session-policy.ts +46 -16
  196. package/package.json +3 -2
  197. package/prompts/skill-creation.md +1 -10
  198. package/runtime/design-canvas-assets.mjs +37 -0
  199. package/runtime/gentle-ai-binary.mjs +1 -1
  200. package/runtime/gentle-shell-bundled.mjs +106 -28
  201. package/runtime/gentle-shell-launcher.mjs +42 -7
  202. package/runtime/native-review-cli.mjs +169 -17
  203. package/runtime/review-integration-v2.mjs +63 -4
  204. package/scripts/bootstrap.cmd +2 -2
  205. package/scripts/bootstrap.sh +41 -4
  206. package/scripts/build-full-delegation-card.mjs +179 -0
  207. package/scripts/build-runtime-modules.mjs +1 -0
  208. package/scripts/bundled-install.mjs +38 -8
  209. package/scripts/download-progress.mjs +68 -0
  210. package/scripts/gentle-ai-installer.mjs +41 -18
  211. package/scripts/gentle-ai-proxy.mjs +294 -0
  212. package/scripts/install-gentle-ai.mjs +14 -1
  213. package/scripts/installer-downloads.mjs +34 -8
  214. package/scripts/installer-preflight.mjs +33 -22
  215. package/scripts/installer-probes.mjs +25 -5
  216. package/scripts/installer-runner.mjs +27 -12
  217. package/scripts/installer-server.mjs +46 -16
  218. package/scripts/installer-windows.mjs +2 -2
  219. package/scripts/pi-update.mjs +166 -27
  220. package/scripts/prepare-verifier.mjs +107 -0
  221. package/scripts/render-cache-host.mjs +72 -0
  222. package/scripts/render-cache-performance-worker.mjs +5 -4
  223. package/scripts/render-cache-performance.mjs +6 -1
  224. package/scripts/run-test-suite.mjs +40 -28
  225. package/scripts/update-agent-body-history.mjs +55 -8
  226. package/scripts/verify-package-files.mjs +50 -19
  227. package/scripts/voice-worker.cjs +32 -6
  228. package/skills/branch-pr/SKILL.md +16 -16
  229. package/skills/comment-writer/SKILL.md +1 -1
  230. package/skills/design/SKILL.md +16 -13
  231. package/skills/gentle-ai/SKILL.md +7 -7
  232. package/skills/gentle-ui-design/SKILL.md +46 -0
  233. package/skills/gentle-ui-design/references/adaptive-interfaces.md +46 -0
  234. package/skills/gentle-ui-design/references/browse-and-compare.md +62 -0
  235. package/skills/gentle-ui-design/references/composition-and-feedback.md +56 -0
  236. package/skills/gentle-ui-design/references/task-and-content.md +60 -0
  237. package/skills/judgment-day/SKILL.md +2 -2
  238. package/skills/judgment-day/references/prompts-and-formats.md +1 -1
  239. package/skills/rdd-defect-workflow/SKILL.md +6 -6
  240. package/skills/skill-improver/SKILL.md +2 -2
  241. package/skills/skill-registry/SKILL.md +11 -11
  242. package/skills/tui-design/SKILL.md +1 -1
  243. package/skills/work-unit-commits/SKILL.md +10 -11
  244. package/tests/agent-home.test.ts +28 -9
  245. package/tests/agent-profiles-workflow.test.ts +163 -0
  246. package/tests/agent-prompt-diet-contract.test.ts +101 -0
  247. package/tests/agent-risk-escalation.test.ts +1 -1
  248. package/tests/agent-status.test.ts +143 -0
  249. package/tests/agent-tool-overlay-acceptance.test.ts +158 -0
  250. package/tests/agent-tool-overlay.test.ts +89 -0
  251. package/tests/agents-config.test.ts +106 -1
  252. package/tests/agents-history.test.ts +31 -0
  253. package/tests/agents-jobs-frames.test.ts +93 -0
  254. package/tests/agents-message-delivery.test.ts +36 -0
  255. package/tests/agents-prompt-lifecycle-runtime.test.ts +376 -0
  256. package/tests/agents-queries.test.ts +144 -4
  257. package/tests/agents-report-cap.test.ts +126 -0
  258. package/tests/agents-runner-drain.test.ts +193 -0
  259. package/tests/agents-runner.test.ts +215 -3
  260. package/tests/agents-session-transport.test.ts +34 -0
  261. package/tests/always-on-prompt-verdicts-contract.test.ts +188 -0
  262. package/tests/append-system-prompt-route.test.ts +12 -1
  263. package/tests/approved-text-leftovers-contract.test.ts +136 -0
  264. package/tests/artifact-language.test.ts +1 -1
  265. package/tests/ask-user-choice.test.ts +4 -3
  266. package/tests/ask-user-question.test.ts +99 -1
  267. package/tests/audit-leftovers-contract.test.ts +51 -0
  268. package/tests/auto-permission-runtime.test.ts +1 -1
  269. package/tests/autonomous-guard.test.ts +346 -10
  270. package/tests/bounded-stop-contract.test.ts +51 -3
  271. package/tests/branch-pr-skill.test.ts +10 -1
  272. package/tests/bridge-cost.test.ts +19 -4
  273. package/tests/bundled-install.test.ts +31 -6
  274. package/tests/card-content-policy.test.ts +3 -3
  275. package/tests/chained-pr-skill.test.ts +8 -6
  276. package/tests/child-context-files.test.ts +64 -8
  277. package/tests/child-safety.test.ts +11 -0
  278. package/tests/child-skills-catalog.test.ts +56 -0
  279. package/tests/codegraph-tools.test.ts +11 -5
  280. package/tests/codemode-rendering.test.ts +4 -1
  281. package/tests/command-palette.test.ts +284 -1
  282. package/tests/delegate-for-reason-contract.test.ts +32 -10
  283. package/tests/delivery-conflict-markers.test.ts +348 -0
  284. package/tests/design-canvas-all-sizes.test.ts +631 -0
  285. package/tests/design-canvas-allowlist.test.ts +32 -0
  286. package/tests/design-canvas-assets.test.ts +11 -695
  287. package/tests/design-canvas-boards.test.ts +77 -0
  288. package/tests/design-canvas-checks.test.ts +655 -0
  289. package/tests/design-canvas-compare.test.ts +79 -0
  290. package/tests/design-canvas-events.test.ts +59 -0
  291. package/tests/design-canvas-export.test.ts +1168 -0
  292. package/tests/design-canvas-focus.test.ts +113 -0
  293. package/tests/design-canvas-handoffs.test.ts +59 -0
  294. package/tests/design-canvas-i18n-review.test.ts +513 -0
  295. package/tests/design-canvas-i18n-views.test.ts +259 -0
  296. package/tests/design-canvas-i18n.test.ts +526 -0
  297. package/tests/design-canvas-inspector.test.ts +937 -0
  298. package/tests/design-canvas-layout.test.ts +1222 -0
  299. package/tests/design-canvas-minimap.test.ts +413 -0
  300. package/tests/design-canvas-modules.test.ts +90 -0
  301. package/tests/design-canvas-parts.test.ts +721 -0
  302. package/tests/design-canvas-rail.test.ts +799 -0
  303. package/tests/design-canvas-server.test.ts +855 -17
  304. package/tests/design-canvas-sizes.test.ts +548 -0
  305. package/tests/design-canvas-store.test.ts +180 -0
  306. package/tests/design-canvas-tokens.test.ts +965 -0
  307. package/tests/design-canvas-view.test.ts +299 -0
  308. package/tests/design-comments.test.ts +201 -1
  309. package/tests/design-handoffs.test.ts +20 -0
  310. package/tests/design-layout.test.ts +100 -0
  311. package/tests/design-parts.test.ts +260 -0
  312. package/tests/design-system-tokens.test.ts +215 -0
  313. package/tests/desktop-rpc-agents.test.ts +893 -0
  314. package/tests/desktop-rpc-config.test.ts +1452 -0
  315. package/tests/desktop-rpc-design.test.ts +662 -0
  316. package/tests/desktop-rpc-jobs.test.ts +796 -0
  317. package/tests/desktop-rpc-permissions.test.ts +311 -0
  318. package/tests/desktop-rpc-profiles.test.ts +140 -0
  319. package/tests/desktop-rpc-safety.test.ts +119 -0
  320. package/tests/desktop-rpc-usage.test.ts +697 -0
  321. package/tests/desktop-rpc.test.ts +252 -0
  322. package/tests/destructive-command-guard.test.ts +52 -0
  323. package/tests/devbinary/pi-host-relay.devtest.ts +149 -80
  324. package/tests/devbinary/review-session-consent.devtest.ts +84 -0
  325. package/tests/download-progress.test.ts +71 -0
  326. package/tests/engram-safety.test.ts +111 -0
  327. package/tests/execution-surface-guard.test.ts +55 -0
  328. package/tests/fixtures/devbinary/status-v9-escalated-non-blocking.captured.json +92 -0
  329. package/tests/fixtures/devbinary/status-v9-escalated-non-blocking.provenance.md +3 -0
  330. package/tests/fixtures/primary-session-prompt/gentleman.golden.md +26 -31
  331. package/tests/fixtures/proxy-tls/proxy.crt +19 -0
  332. package/tests/fixtures/proxy-tls/proxy.key +28 -0
  333. package/tests/fixtures/refusal-identity.probe.mjs +139 -0
  334. package/tests/fixtures/session-profile-v1/gentle-ai-reviewer.ts +89 -0
  335. package/tests/fixtures/session-profile-v1/replay.ts +53 -6
  336. package/tests/full-delegation-closure.test.ts +160 -0
  337. package/tests/full-delegation-notices.test.ts +76 -0
  338. package/tests/generic-agent-tools.test.ts +3 -3
  339. package/tests/gentle-agent-status.test.ts +74 -0
  340. package/tests/gentle-agents-child-jobs.test.ts +237 -0
  341. package/tests/gentle-agents.test.ts +1403 -20
  342. package/tests/gentle-ai-binary.test.ts +3 -1
  343. package/tests/gentle-ai-child-guards.test.ts +1 -0
  344. package/tests/gentle-ai-elapsed-store.test.ts +19 -0
  345. package/tests/gentle-ai-exploration-budget.test.ts +18 -2
  346. package/tests/gentle-ai-installer.test.ts +135 -51
  347. package/tests/gentle-ai-proxy.test.ts +434 -0
  348. package/tests/gentle-ai-renderer.test.ts +36 -2
  349. package/tests/gentle-ai.test.ts +233 -43
  350. package/tests/gentle-design.test.ts +386 -1
  351. package/tests/gentle-herdr-activity.test.ts +9 -6
  352. package/tests/gentle-shell-bin.test.ts +123 -0
  353. package/tests/gentle-shell-bundled.test.ts +293 -31
  354. package/tests/gentle-shell-launcher.test.ts +78 -11
  355. package/tests/gentle-shell.test.ts +1017 -146
  356. package/tests/gentle-todo.test.ts +51 -11
  357. package/tests/gentle-tps.test.ts +123 -0
  358. package/tests/gentle-ui-design-skill.test.ts +59 -0
  359. package/tests/herdr-busy.test.ts +59 -0
  360. package/tests/herdr-task-summary-policy.test.ts +8 -4
  361. package/tests/hidden-tools.test.ts +188 -0
  362. package/tests/image-disk-cache.test.ts +163 -0
  363. package/tests/independent-recovery-delivery.test.ts +97 -0
  364. package/tests/inprocess-reviewer.test.ts +249 -4
  365. package/tests/install-wizard.test.ts +27 -1
  366. package/tests/installer-downloads.test.ts +30 -1
  367. package/tests/installer-posix-bootstrap.test.ts +115 -14
  368. package/tests/installer-preflight.test.ts +54 -5
  369. package/tests/installer-probes.test.ts +146 -0
  370. package/tests/installer-runner.test.ts +79 -44
  371. package/tests/installer-server.test.ts +215 -13
  372. package/tests/installer-windows-bootstrap.test.ts +19 -1
  373. package/tests/jobs-view.test.ts +260 -6
  374. package/tests/judgment-day-severity-admission.test.ts +46 -0
  375. package/tests/lazy-module-contradictions-contract.test.ts +158 -0
  376. package/tests/maintainer/desktop-rpc.maintest.ts +632 -0
  377. package/tests/maintainer/pi-update-source.maintest.ts +48 -18
  378. package/tests/modal-mouse-boundaries.test.ts +136 -0
  379. package/tests/model-fallback-policy.test.ts +26 -7
  380. package/tests/model-routing-authority.test.ts +178 -2
  381. package/tests/nan-provider-runtime.test.ts +17 -3
  382. package/tests/nan-provider.test.ts +111 -56
  383. package/tests/native-choice-list.test.ts +77 -2
  384. package/tests/native-review-capability-contract.test.ts +17 -1
  385. package/tests/native-review-cli-nonblocking-findings.test.ts +165 -0
  386. package/tests/native-review-cli.test.ts +269 -1
  387. package/tests/native-review-parity.test.ts +24 -5
  388. package/tests/native-review-refusal-identity.test.ts +25 -0
  389. package/tests/no-self-pause-contract.test.ts +13 -2
  390. package/tests/odd-integration.test.ts +11 -3
  391. package/tests/odd-routing-canonical-ratchet.test.ts +3 -3
  392. package/tests/odd-routing-contract.test.ts +80 -28
  393. package/tests/orchestrator-budget.test.ts +35 -5
  394. package/tests/orchestrator-consultation-sdk.test.ts +32 -6
  395. package/tests/orchestrator-delegation-mode.test.ts +154 -0
  396. package/tests/orchestrator-discovery.test.ts +28 -0
  397. package/tests/orchestrator-mode-policy.test.ts +175 -0
  398. package/tests/orchestrator-prompt-budget.test.ts +13 -2
  399. package/tests/orchestrator-prompt-diet-contract.test.ts +221 -0
  400. package/tests/orchestrator-rdd-ownership.test.ts +4 -3
  401. package/tests/orchestrator-work-search.test.ts +4 -2
  402. package/tests/package-files.test.ts +25 -1
  403. package/tests/package-manifest.test.ts +16 -13
  404. package/tests/parallel-reason-contract.test.ts +6 -3
  405. package/tests/permission-allowlist.test.ts +372 -0
  406. package/tests/persona-neutral-voseo.test.ts +4 -4
  407. package/tests/persona-reply-language.test.ts +1 -1
  408. package/tests/persona-single-channel.test.ts +13 -5
  409. package/tests/pi-update-launcher.test.ts +25 -7
  410. package/tests/pi-update-source.test.ts +113 -6
  411. package/tests/pi-update.test.ts +294 -19
  412. package/tests/pnpm-workspace-config.test.ts +58 -0
  413. package/tests/pnpm-workspace-policy.test.ts +47 -0
  414. package/tests/primary-context-files.test.ts +233 -0
  415. package/tests/primary-context-three-files.test.ts +174 -0
  416. package/tests/primary-session-prompt.test.ts +13 -0
  417. package/tests/profile-pin.test.ts +29 -2
  418. package/tests/profile-tier-footer.test.ts +5 -0
  419. package/tests/profiles-panel-delegation-mode.test.ts +422 -0
  420. package/tests/provider-defect-handoff.test.ts +9 -2
  421. package/tests/questionnaire-view.test.ts +115 -0
  422. package/tests/quiet-bash-runtime.test.ts +1 -1
  423. package/tests/quiet-tool-rendering.test.ts +48 -0
  424. package/tests/rdd-aware-verification-contract.test.ts +17 -12
  425. package/tests/rdd-customize.test.ts +287 -0
  426. package/tests/rdd-mode-cache.test.ts +450 -0
  427. package/tests/rdd-mode-control.test.ts +407 -0
  428. package/tests/rdd-mode-scope-regression.test.ts +137 -0
  429. package/tests/rdd-off-independent-regression.test.ts +69 -0
  430. package/tests/rdd-status-line.test.ts +112 -1
  431. package/tests/render-cache-performance.test.ts +171 -2
  432. package/tests/reply-language-anchor-placement.test.ts +184 -0
  433. package/tests/reply-language-anchor.test.ts +189 -0
  434. package/tests/request-context-append-only.test.ts +218 -0
  435. package/tests/request-context-placement.test.ts +148 -0
  436. package/tests/review-agent-end-preflight.test.ts +80 -2
  437. package/tests/review-blocker.test.ts +193 -0
  438. package/tests/review-candidate-owner-retry.test.ts +1 -1
  439. package/tests/review-candidate-symlink-scan.test.ts +157 -0
  440. package/tests/review-candidate-view.test.ts +66 -1
  441. package/tests/review-candidate-windows-boundary.test.ts +131 -0
  442. package/tests/review-candidate-windows-probe.test.ts +63 -0
  443. package/tests/review-committed-restart-ack.test.ts +129 -0
  444. package/tests/review-continuation-registry.test.ts +107 -0
  445. package/tests/review-contract-prompt.test.ts +1 -1
  446. package/tests/review-controller-native-routing.test.ts +261 -5
  447. package/tests/review-controller-workspace-root.test.ts +230 -3
  448. package/tests/review-controller.test.ts +98 -12
  449. package/tests/review-coordinator-correction-gate.test.ts +105 -0
  450. package/tests/review-coordinator-findings.test.ts +206 -0
  451. package/tests/review-coordinator-nonblocking-scope.test.ts +169 -0
  452. package/tests/review-coordinator-runtime.test.ts +117 -0
  453. package/tests/review-coordinator.test.ts +462 -0
  454. package/tests/review-delivery-preflight.test.ts +462 -0
  455. package/tests/review-due-compaction.test.ts +31 -0
  456. package/tests/review-due-public-boundary.test.ts +26 -0
  457. package/tests/review-failure-facts.test.ts +87 -0
  458. package/tests/review-host-relay-routing.test.ts +258 -4
  459. package/tests/review-host-relay.test.ts +39 -0
  460. package/tests/review-integration-nonblocking-findings.test.ts +108 -0
  461. package/tests/review-integration-v2.test.ts +46 -3
  462. package/tests/review-json-arguments.test.ts +105 -11
  463. package/tests/review-last-event-closure.test.ts +68 -0
  464. package/tests/review-ledger-contract.test.ts +19 -40
  465. package/tests/review-loadout-rdd-off-sdk.test.ts +95 -32
  466. package/tests/review-one-call-findings.test.ts +131 -0
  467. package/tests/review-one-call-followups.test.ts +308 -0
  468. package/tests/review-one-call-reviewer-requests.test.ts +207 -0
  469. package/tests/review-one-call.test.ts +452 -0
  470. package/tests/review-owner-identity.test.ts +60 -24
  471. package/tests/review-relay-phase-timing.test.ts +128 -0
  472. package/tests/review-relay-transport-agent.test.ts +39 -2
  473. package/tests/review-reviewer-evidence.test.ts +223 -0
  474. package/tests/review-risk-assessment.test.ts +126 -8
  475. package/tests/review-run-statement-guidance-independent.test.ts +54 -0
  476. package/tests/review-session-standing-permission-controller.test.ts +53 -3
  477. package/tests/review-start-context.test.ts +19 -0
  478. package/tests/review-tool-prose-budget.test.ts +122 -0
  479. package/tests/reviewer-stream.test.ts +149 -0
  480. package/tests/run-test-suite.test.ts +122 -1
  481. package/tests/runtime-harness.mjs +4 -1
  482. package/tests/sensitive-path-tools.test.ts +181 -5
  483. package/tests/session-profile-append-controller-pi.test.ts +60 -31
  484. package/tests/session-profile-binding.test.ts +19 -1
  485. package/tests/session-profile-disk-reader-pi.test.ts +58 -16
  486. package/tests/session-profile-extension.test.ts +2 -2
  487. package/tests/session-profile-v1-compat.test.ts +35 -1
  488. package/tests/shell-bar.test.ts +186 -42
  489. package/tests/shell-panel.test.ts +50 -22
  490. package/tests/shell-prompt.test.ts +17 -0
  491. package/tests/shell-sidebar-fullscreen.test.ts +5 -5
  492. package/tests/shell-sidebar-layout.test.ts +294 -23
  493. package/tests/shell-sidebar-scroll-benchmark.test.ts +1 -1
  494. package/tests/shell-surface-transparent.test.ts +89 -0
  495. package/tests/shell-todo.test.ts +12 -0
  496. package/tests/shell-usage.test.ts +59 -10
  497. package/tests/skill-contradictions-contract.test.ts +122 -0
  498. package/tests/skill-registry-watcher.test.ts +216 -2
  499. package/tests/skill-registry.test.ts +1461 -5
  500. package/tests/startup-banner.test.ts +152 -1
  501. package/tests/startup-home-repo.test.ts +2 -0
  502. package/tests/support/design-canvas-dom.ts +369 -0
  503. package/tests/support/review-coordinator-runtime.ts +264 -0
  504. package/tests/task-size-routing-contract.test.ts +45 -12
  505. package/tests/test-strength-contract.test.ts +2 -1
  506. package/tests/todo-request-append-only.test.ts +214 -0
  507. package/tests/tool-batching-contract.test.ts +3 -1
  508. package/tests/update-agent-body-history.test.ts +138 -0
  509. package/tests/verification-tiers-contract.test.ts +229 -0
  510. package/tests/verifier-admission.test.ts +49 -0
  511. package/tests/verifier-preparation.test.ts +229 -0
  512. package/tests/verify-agent-contract.test.ts +20 -2
  513. package/tests/verify-first-launch-contract.test.ts +162 -11
  514. package/tests/vim-editor-adapter.test.ts +2 -2
  515. package/tests/visual-customization-policy.test.ts +39 -6
  516. package/tests/visual-customize-view.test.ts +573 -9
  517. package/tests/visual-layout-preview.test.ts +15 -1
  518. package/tests/visual-profiles.test.ts +11 -0
  519. package/tests/voice-worker.test.ts +73 -2
  520. package/tests/windows-session-transport.test.ts +126 -0
  521. package/tests/work-continuity-contract.test.ts +77 -6
  522. package/tests/writer-admission-messages.test.ts +232 -0
  523. package/tests/writer-batch-admission.test.ts +66 -0
  524. package/tests/writer-edit-surface-scope.test.ts +52 -20
  525. package/tests/writer-feature-document-admission.test.ts +276 -0
  526. package/tests/yolo-customize.test.ts +27 -4
  527. package/tests/yolo-mode.test.ts +62 -18
  528. package/tests/yolo-session-policy.test.ts +270 -1
  529. package/skills/_shared/review-ledger-contract.md +0 -106
  530. /package/contracts/review-provider-contract-mirror/{v1.4.0 → v1.5.0}/bundle/README.md +0 -0
  531. /package/contracts/review-provider-contract-mirror/{v1.4.0 → v1.5.0}/bundle/schemas/lens.schema.json +0 -0
  532. /package/contracts/review-provider-contract-mirror/{v1.4.0 → v1.5.0}/bundle/schemas/refuter.schema.json +0 -0
  533. /package/contracts/review-provider-contract-mirror/{v1.4.0 → v1.5.0}/bundle/schemas/targeted-validator.schema.json +0 -0
  534. /package/contracts/review-provider-contract-mirror/{v1.4.0 → v1.5.0}/bundle/vectors/lens.json +0 -0
  535. /package/contracts/review-provider-contract-mirror/{v1.4.0 → v1.5.0}/bundle/vectors/refuter.json +0 -0
  536. /package/contracts/review-provider-contract-mirror/{v1.4.0 → v1.5.0}/bundle/vectors/targeted-validator.json +0 -0
@@ -1,11 +1,23 @@
1
1
  import assert from "node:assert/strict";
2
+ import { execFileSync } from "node:child_process";
3
+ import { mkdirSync, mkdtempSync, readFileSync, realpathSync, rmSync } from "node:fs";
4
+ import { tmpdir } from "node:os";
5
+ import { dirname, join } from "node:path";
2
6
  import test from "node:test";
7
+ import { fileURLToPath } from "node:url";
3
8
  import { stream as streamAnthropic } from "@earendil-works/pi-ai/api/anthropic-messages";
4
9
  import { normalizeContext, validateToolArguments, type Model, type ToolCall } from "@earendil-works/pi-ai";
5
10
  import type { ExtensionAPI } from "@earendil-works/pi-coding-agent";
6
11
  import type { NativeReviewCli } from "../lib/native-review-cli.ts";
7
12
  import { __testing, createGentleAiExtension } from "../extensions/gentle-ai.ts";
8
13
 
14
+ const metadata = join(dirname(fileURLToPath(import.meta.resolve("@earendil-works/pi-ai"))), "..", "package.json");
15
+ const version: string = JSON.parse(readFileSync(metadata, "utf8")).version;
16
+ assert.match(version, /^\d+\.\d+\.\d+$/);
17
+ const [major, minor] = version.split(".").map(Number);
18
+ assert.ok(major >= 1, `Pi AI >=1.0.0 required, installed ${version}`);
19
+ const coercesStringNull = major > 1 || (major === 1 && minor >= 5);
20
+
9
21
  function registeredTools(): Map<string, any> {
10
22
  const tools = new Map<string, any>();
11
23
  createGentleAiExtension({ nativeReviewCli: null })({
@@ -53,7 +65,7 @@ test("public Anthropic non-strict adapter preserves the complete review tool dec
53
65
  assert.deepEqual(controller.required, ["operation"]);
54
66
  assert.deepEqual(Object.keys(controller.properties).sort(), ["operation", "lineageId", "selectionBinding", "intendedUntracked", "untrackedScope", "changeName", "idempotencyKey", "transition", "input", "outputPath", "inputPath", "operationId", "lineageIds", "workspaceRoot"].sort());
55
67
  assert.ok(controller.properties.input.anyOf.some((schema: any) => schema.type === "object"));
56
- assert.match(controller.properties.input.description, /START\/ASSESS\/answer-consent/);
68
+ assert.match(controller.properties.input.description, /START\/ASSESS\/answer-consent\/abandon/);
57
69
  assert.deepEqual(controller.properties.operation.enum, tools.get("gentle_review").parameters.properties.operation.enum);
58
70
  for (const name of ["gentle_review_capture", "gentle_review_capture_group"]) {
59
71
  const schema = emitted.get(name);
@@ -77,6 +89,19 @@ test("public Anthropic non-strict adapter preserves the complete review tool dec
77
89
  });
78
90
 
79
91
  const binding = { name: "reviewer_result", arguments: [] };
92
+
93
+ test("STATUS accepts object selectors and rejects malformed input before native access", async () => {
94
+ const input = { baseRef: "HEAD", committedOnly: true };
95
+ assert.equal(__testing.parseReviewControllerParameters(validate("gentle_review", { operation: "status", input })).input, JSON.stringify(input));
96
+ let calls = 0;
97
+ const native = new Proxy({}, { get: () => async () => { calls++; throw new Error("invalid input reached native"); } }) as NativeReviewCli;
98
+ for (const malformed of [null, [], 42]) await assert.rejects(__testing.executeReviewControllerOperation({ operation: "status", input: malformed }, process.cwd(), native), /input|JSON|object/i);
99
+ for (const malformed of [{ baseRef: "HEAD" }, { baseRef: "HEAD", committedOnly: false }, { unexpected: true }]) {
100
+ const result = await __testing.executeReviewControllerOperation({ operation: "status", input: malformed }, process.cwd(), native);
101
+ assert.equal(result.outcome, "native-status-input-invalid");
102
+ }
103
+ assert.equal(calls, 0);
104
+ });
80
105
  test("registered review schemas admit START/ASSESS objects and ordered capture objects", () => {
81
106
  for (const operation of ["start", "assess"]) {
82
107
  const input = operation === "start" ? { mode: "ordinary" } : { committedOnly: true, baseRef: "HEAD" };
@@ -106,17 +131,77 @@ test("answer-consent admits JSON object input and coerces it cleanly (#2375)", a
106
131
  assert.match(String(outcome.outcome), /consent-binding-stale/);
107
132
  });
108
133
 
134
+ test("abandon admits JSON object input and coerces it to a serialized string", () => {
135
+ const input = { actor: "loonbac", reason: "operator_disposition" };
136
+ const args = validate("gentle_review", { operation: "abandon", lineageId: "review-1", input });
137
+ assert.deepEqual(args.input, input);
138
+ assert.equal(__testing.parseReviewControllerParameters(args).input, JSON.stringify(input));
139
+ });
140
+
141
+ test("validated abandon objects reach the mocked native facade and still fail closed", async () => {
142
+ let statusCalls = 0;
143
+ let abandonCalls = 0;
144
+ const native = {
145
+ reviewStatus: async () => { statusCalls++; return { entries: [] }; },
146
+ abandon: async () => { abandonCalls++; },
147
+ } as unknown as NativeReviewCli;
148
+ const bad = await __testing.executeReviewControllerOperation(validate("gentle_review", { operation: "abandon", lineageId: "review-1", input: { actor: "loonbac", reason: "not-a-reason" } }), process.cwd(), native);
149
+ assert.equal(bad.outcome, "native-input-invalid");
150
+ assert.equal(statusCalls, 0);
151
+ const ineligible = await __testing.executeReviewControllerOperation(validate("gentle_review", { operation: "abandon", lineageId: "review-1", input: { actor: "loonbac", reason: "operator_disposition" } }), process.cwd(), native);
152
+ assert.equal(ineligible.outcome, "native-abandon-ineligible");
153
+ assert.equal(statusCalls, 1);
154
+ assert.equal(abandonCalls, 0);
155
+ });
156
+
109
157
  test("validated ASSESS objects reach the mocked native facade with parsed fields", async () => {
110
158
  const requests: unknown[] = [];
159
+ const baseRef = execFileSync("git", ["rev-parse", "HEAD"], { cwd: process.cwd(), encoding: "utf8" }).trim();
111
160
  const native = { assess: async (request: unknown) => { requests.push(request); throw new Error("mock assessment unavailable"); } } as unknown as NativeReviewCli;
112
161
  for (const input of [{ baseRef: "HEAD", committedOnly: true, nativeReviewOutcome: "unknown" }, ' { "baseRef": "HEAD", "committedOnly": true, "nativeReviewOutcome": "unknown" } ']) {
113
162
  await __testing.executeReviewControllerOperation(validate("gentle_review", { operation: "assess", input }), process.cwd(), native);
114
163
  }
115
164
  assert.equal(requests.length, 2);
116
- assert.deepEqual(requests[0], { cwd: process.cwd(), baseRef: "HEAD", committedOnly: true });
165
+ assert.deepEqual(requests[0], { cwd: process.cwd(), baseRef, committedOnly: true });
117
166
  assert.deepEqual(requests[1], requests[0]);
118
167
  });
119
168
 
169
+ test("ASSESS ignores empty top-level selection defaults and targets the selected child repository (#2808)", async (t) => {
170
+ const parent = realpathSync(mkdtempSync(join(tmpdir(), "assess-parent-")));
171
+ t.after(() => rmSync(parent, { recursive: true, force: true }));
172
+ const selected = join(parent, "selected");
173
+ const other = join(parent, "other");
174
+ for (const cwd of [selected, other]) {
175
+ mkdirSync(cwd);
176
+ execFileSync("git", ["init", "--initial-branch=fixture"], { cwd, stdio: "ignore" });
177
+ }
178
+ const requests: unknown[] = [];
179
+ const native = { assess: async (request: unknown) => { requests.push(request); throw new Error("fixture assessment unavailable"); } } as unknown as NativeReviewCli;
180
+ for (const defaults of [{}, { intendedUntracked: [] }, { untrackedScope: "select" }, { untrackedScope: "exclude" }, { intendedUntracked: [], untrackedScope: "select" }, { intendedUntracked: [], untrackedScope: "exclude" }]) {
181
+ const args = validate("gentle_review", { operation: "assess", workspaceRoot: selected, input: "{}", ...defaults });
182
+ const original = structuredClone(args);
183
+ const parsed = __testing.parseReviewControllerParameters(args);
184
+ assert.equal("intendedUntracked" in parsed, false);
185
+ assert.equal("untrackedScope" in parsed, false);
186
+ const result = await __testing.executeReviewControllerOperation(args, parent, native);
187
+ assert.equal(result.operation, "assess");
188
+ assert.deepEqual(args, original, "normalization must not mutate the caller input");
189
+ }
190
+ assert.deepEqual(requests, Array.from({ length: 6 }, () => ({ cwd: selected })), "all equivalent calls reach the selected repository; the fixture deliberately reports native unavailability");
191
+ });
192
+
193
+ test("ASSESS still rejects meaningful or malformed top-level untracked selection (#2808)", () => {
194
+ for (const defaults of [
195
+ { intendedUntracked: ["new.ts"] },
196
+ { intendedUntracked: ["new.ts"], untrackedScope: "select" },
197
+ { intendedUntracked: null }, { intendedUntracked: "" }, { intendedUntracked: undefined },
198
+ { intendedUntracked: [], untrackedScope: "unknown" }, { untrackedScope: null },
199
+ ]) assert.throws(() => __testing.parseReviewControllerParameters({ operation: "assess", ...defaults }), /does not accept/);
200
+ for (const operation of ["status", "start", "answer-consent", "reset"]) {
201
+ assert.throws(() => __testing.parseReviewControllerParameters({ operation, intendedUntracked: [], untrackedScope: "select" }), /does not accept/);
202
+ }
203
+ });
204
+
120
205
  test("serialized inputs remain byte-for-byte unchanged at validation and facade parsing", () => {
121
206
  const input = ' \n{ "mode" : "ordinary" }\t';
122
207
  for (const operation of ["start", "assess", "answer-consent", "reset", "recover"]) {
@@ -126,9 +211,10 @@ test("serialized inputs remain byte-for-byte unchanged at validation and facade
126
211
  assert.equal(__testing.parseReviewCaptureParameters(validate("gentle_review_capture", { lineageId: "l", collectBinding })).collectBinding, collectBinding);
127
212
  });
128
213
 
129
- test("actual validation rejects arrays, null and coerced primitives rather than admitting native calls", async () => {
130
- for (const value of [[], 123, true, "123", "null", "[]"]) {
131
- for (const operation of ["start", "assess", "answer-consent", "inspect", "reset", "recover"]) {
214
+ test("validation and facade keep arrays, primitives and null fail-closed", async () => {
215
+ const operations = ["start", "assess", "answer-consent", "inspect", "reset", "recover"];
216
+ for (const value of [[], 123, true, "123", "[]"]) {
217
+ for (const operation of operations) {
132
218
  assert.throws(() => validate("gentle_review", { operation, input: value }), /Validation failed/);
133
219
  }
134
220
  assert.throws(() => validate("gentle_review_capture", { lineageId: "l", collectBinding: value }), /Validation failed/);
@@ -136,20 +222,28 @@ test("actual validation rejects arrays, null and coerced primitives rather than
136
222
  }
137
223
  let calls = 0;
138
224
  const native = new Proxy({}, { get() { return async () => { calls++; throw new Error("unexpected native execution"); }; } }) as NativeReviewCli;
139
- for (const value of [null, false]) {
140
- for (const operation of ["start", "assess", "answer-consent", "inspect", "reset", "recover"]) {
141
- const validated = validate("gentle_review", { operation, input: value });
142
- assert.equal(validated.input, null, "nullable shell preserves null instead of stripping it to omitted");
143
- await assert.rejects(__testing.executeReviewControllerOperation(validated, process.cwd(), native));
225
+ // SDK coercion admits the nullable shell, not native operation input.
226
+ for (const value of [null, false, "null"]) {
227
+ for (const operation of operations) {
228
+ if (value === "null" && !coercesStringNull) {
229
+ assert.throws(() => validate("gentle_review", { operation, input: value }), /Validation failed/);
230
+ } else {
231
+ const validated = validate("gentle_review", { operation, input: value });
232
+ assert.equal(validated.input, null, "nullable shell preserves null instead of stripping it to omitted");
233
+ await assert.rejects(__testing.executeReviewControllerOperation(validated, process.cwd(), native));
234
+ }
144
235
  }
145
236
  assert.throws(() => validate("gentle_review_capture", { lineageId: "l", collectBinding: value }), /Validation failed/);
146
237
  assert.throws(() => validate("gentle_review_capture_group", { lineageId: "l", collectBindings: [binding, value] }), /Validation failed/);
147
238
  }
239
+ for (const operation of operations) {
240
+ await assert.rejects(__testing.executeReviewControllerOperation({ operation, input: "null" }, process.cwd(), native), /input must be a JSON object/);
241
+ }
148
242
  assert.equal(calls, 0);
149
243
  });
150
244
 
151
245
  test("all other controller operations keep object input fail-closed at the facade boundary (#1698)", async () => {
152
- const operations = (tools.get("gentle_review").parameters.properties.operation.enum as string[]).filter((operation) => operation !== "start" && operation !== "assess" && operation !== "answer-consent" && operation !== "select-intended-untracked");
246
+ const operations = (tools.get("gentle_review").parameters.properties.operation.enum as string[]).filter((operation) => operation !== "start" && operation !== "assess" && operation !== "answer-consent" && operation !== "abandon" && operation !== "status" && operation !== "select-intended-untracked");
153
247
  let calls = 0;
154
248
  const native = new Proxy({}, { get() { return async () => { calls++; throw new Error("unexpected native execution"); }; } }) as NativeReviewCli;
155
249
  for (const operation of operations) {
@@ -6,6 +6,7 @@ import { __testing } from "../extensions/gentle-ai.ts";
6
6
  import { reconcileUnknownReviewLastEventCapture } from "../lib/review-last-event-controller.ts";
7
7
  import * as nativeReviewCliModule from "../lib/native-review-cli.ts";
8
8
  import type { NativeReviewCli } from "../lib/native-review-cli.ts";
9
+ import { ReviewHostRelayError, REVIEW_HOST_RELAY_FAILURE } from "../lib/review-host-relay.ts";
9
10
  import {
10
11
  decodeReviewLastEventClosureV1,
11
12
  decodeReviewStartV3,
@@ -17,6 +18,49 @@ const SHA = `sha256:${"a".repeat(64)}`;
17
18
  const TREE = "b".repeat(40);
18
19
  const CAPTURED_FIXTURES = join(process.cwd(), "tests", "fixtures", "devbinary");
19
20
 
21
+ test("host reviewer facts survive both ordinary capture and terminal closure without changing native output", async t => {
22
+ t.after(() => __testing.setReviewHostRelayRunnerForTesting());
23
+ for (const terminal of [false, true]) {
24
+ const lineageId = `facts-single-${terminal}`, input = materializeInput(lineageId);
25
+ const reviewer = { reviewerModel: "fixture/model", phase: "completion", usage: { input: 10 }, cost: { total: 0.01 } };
26
+ const native = { targetStatus: async () => status(lineageId, [input]) } as unknown as NativeReviewCli;
27
+ __testing.setReviewHostRelayRunnerForTesting(async () => ({ promptByteLength: 30, resultByteLength: 20, reviewerEvidence: reviewer,
28
+ submission: terminal ? JSON.stringify(closure("review/capture-result", lineageId)) : '{"admission_decision":"completed"}' }));
29
+ const result = await __testing.executeReviewCaptureOperation({ lineageId, collectBinding: JSON.stringify(input), reviewerRunAcknowledged: true }, process.cwd(), native);
30
+ assert.equal(result.outcome, terminal ? "native-last-event-closure" : "native-reviewer-result-captured");
31
+ assert.deepEqual((result.host_relay as any)?.reviewer, reviewer);
32
+ const before = structuredClone((result.host_relay as any).reviewer);
33
+ reviewer.usage.input = 999;
34
+ assert.deepEqual((result.host_relay as any).reviewer, before, "host facts are snapshots rather than a runner's mutable object");
35
+ if (terminal) assert.equal((result.closure as any).lineage_id, lineageId);
36
+ }
37
+ });
38
+
39
+ test("group reviewer runs retain every prepared completion after early closure or later admission refusal", async t => {
40
+ t.after(() => __testing.setReviewHostRelayGroupRunnersForTesting());
41
+ for (const terminal of [true, false]) {
42
+ const lineageId = `facts-group-${terminal}`;
43
+ const inputs = Array.from({ length: 4 }, (_, index) => materializeInput(lineageId, String(index), `sha256:${String(index + 1).repeat(64)}`));
44
+ const facts = inputs.map((_, index) => ({ reviewerModel: `fixture/model-${index}`, phase: "completion", ...(index === 1 ? {} : { usage: { input: index + 1 }, cost: { total: 0.01 * (index + 1) } }) }));
45
+ let submitted = 0;
46
+ const native = { targetStatus: async () => ({ ...status(lineageId, inputs.slice(submitted)), repositoryContext: { capability: "review.opaque_repository_context", handle: `rctx1_${"c".repeat(64)}`, revision: SHA, targetIdentity: SHA } }) } as unknown as NativeReviewCli;
47
+ __testing.setReviewHostRelayGroupRunnersForTesting(async requests => requests.map((request, index) => ({ request, promptByteLength: 30, resultByteLength: 20, reviewerEvidence: facts[index] })), async () => {
48
+ if (submitted === 1) throw new ReviewHostRelayError(REVIEW_HOST_RELAY_FAILURE.SUBMISSION_REFUSED, "submit", "fixture refused", { mutationOutcome: "none", reviewerEvidence: facts[1] });
49
+ submitted++;
50
+ return { promptByteLength: 30, resultByteLength: 20, submission: terminal ? JSON.stringify(closure("review/capture-result", lineageId)) : '{"admission_decision":"completed"}' };
51
+ });
52
+ const result = await __testing.executeReviewCaptureGroupOperation({ lineageId, collectBindings: inputs, reviewerRunAcknowledged: true }, process.cwd(), native);
53
+ assert.equal(result.submitted_reviewers, 1, JSON.stringify(result)); assert.equal(result.prepared_reviewers, 4);
54
+ const diagnostics = result.host_relay as any;
55
+ assert.equal(diagnostics.reviewers.length, 1, "legacy reviewer diagnostics remain limited to confirmed submissions");
56
+ assert.equal(diagnostics.reviewer_runs.length, 4, "all prepared completions already spent their reported usage");
57
+ assert.deepEqual(diagnostics.reviewer_runs.map((run: any) => run.reviewer), facts);
58
+ assert.equal(Object.hasOwn(diagnostics.reviewer_runs[1].reviewer, "usage"), false, "missing usage remains unknown");
59
+ assert.equal(Object.hasOwn(diagnostics.reviewers[0], "reviewer"), false, "do not copy cost into both legacy and run diagnostics");
60
+ assert.equal(result.outcome, terminal ? "native-last-event-closure" : "pi-host-relay-transport-failure");
61
+ }
62
+ });
63
+
20
64
  function captured(name: string): unknown {
21
65
  return JSON.parse(readFileSync(join(CAPTURED_FIXTURES, name), "utf8"));
22
66
  }
@@ -492,6 +536,30 @@ test("refuter and validation each execute one self-contained provider vector", a
492
536
  }
493
537
  });
494
538
 
539
+ test("public STATUS retains only the original opaque binding projection", async () => {
540
+ const lineageId = "validation-projection";
541
+ const input = roleInput(lineageId, "review.capture-validation");
542
+ const native = { targetStatus: async () => status(lineageId, [input]),
543
+ reviewMode: async () => ({ operation: "status", scope: "clone", status: { global: "on", cloneLocal: "", effective: "on", source: "global" } }),
544
+ } as unknown as NativeReviewCli;
545
+ const result = await __testing.executeReviewControllerOperation({ operation: "status", lineageId }, process.cwd(), native);
546
+ const entries = result.collectBindings as Array<{ collectBinding: string }>;
547
+ assert.equal(entries.length, 1);
548
+ assert.deepEqual(Object.keys(entries[0]), ["collectBinding"]);
549
+ assert.deepEqual(JSON.parse(entries[0].collectBinding), input);
550
+ assert.equal((entries[0] as Record<string, unknown>).forecast, undefined, "legacy execute vectors keep their existing route");
551
+ });
552
+
553
+ test("public correction STATUS adds no inferred input metadata", async () => {
554
+ const lineageId = "authored-plan-metadata";
555
+ const input = correctionPlanInput(lineageId);
556
+ const native = { targetStatus: async () => status(lineageId, [input]) } as unknown as NativeReviewCli;
557
+ const result = await __testing.executeReviewControllerOperation({ operation: "status", lineageId }, process.cwd(), native);
558
+ const entries = result.collectBindings as Array<{ collectBinding: string }>;
559
+ assert.deepEqual(Object.keys(entries[0]), ["collectBinding"]);
560
+ assert.deepEqual(JSON.parse(entries[0].collectBinding), input);
561
+ });
562
+
495
563
  test("terminal capture closes directly, nonterminal capture does not auto-follow, and unknown mutation reconciles once", async (t) => {
496
564
  t.after(() => __testing.setReviewHostRelayRunnerForTesting());
497
565
  const lineageId = "closure-behavior";
@@ -4,9 +4,9 @@ import { dirname, join, relative, resolve, sep } from "node:path";
4
4
  import test from "node:test";
5
5
  import { REVIEW_LENS_PARITY_PATTERNS } from "./support/review-lens-parity.ts";
6
6
  import { readDelegationDetail } from "./support/orchestrator-modules.ts";
7
+ import { FROZEN_SEVERITY } from "../lib/review-transaction.ts";
7
8
 
8
9
  const ROOT = join(import.meta.dirname, "..");
9
- const CANONICAL = "skills/_shared/review-ledger-contract.md";
10
10
  const ORCHESTRATOR = ["assets/orchestrator.md", "assets/orchestrator-delegation.md", "assets/orchestrator-writer.md"];
11
11
  const REVIEW_LENSES = [
12
12
  "assets/agents/review-risk.md",
@@ -23,6 +23,7 @@ const README = "README.md";
23
23
  const TECHNICAL_REFERENCE = "docs/readme-reference.md";
24
24
  const CHAIN = "assets/chains/4r-review.chain.md";
25
25
  const WORKER = "assets/agents/gentle-ai-worker.md";
26
+ const RDD_DEFECT_SKILL = "skills/rdd-defect-workflow/SKILL.md";
26
27
 
27
28
  function read(path: string): string {
28
29
  return readFileSync(join(ROOT, path), "utf8");
@@ -71,7 +72,6 @@ const OBSOLETE_JUDGMENT_DAY_REPLACEMENT =
71
72
  /Judgment Day starts only when explicitly requested and replaces ordinary review for that lineage\./;
72
73
 
73
74
  const JUDGMENT_DAY_SEMANTIC_SURFACES = [
74
- CANONICAL,
75
75
  JD_SKILL,
76
76
  JD_PROMPTS,
77
77
  ...JUDGES,
@@ -91,39 +91,25 @@ const FIX_PATTERNS = [
91
91
  /Do not add findings, alter frozen claims, authorize transitions, deliver, publish, or start another actor\./,
92
92
  ] as const;
93
93
 
94
- test("canonical contract defines compact risk, causal admission, correction, CAS, compatibility, and the delivery boundary", () => {
95
- const content = read(CANONICAL);
96
- assertMatches(CANONICAL, content, [
97
- /start -> finalize -> validate/,
98
- /`low`[\s\S]*`medium`[\s\S]*`high`/,
94
+ test("technical reference and README keep the review budget, compact states, trust boundary, and the delivery boundary", () => {
95
+ // The retired skills/_shared/review-ledger-contract.md carried these rules too; the
96
+ // technical reference is where they still live (cost-speed-painpoints P15).
97
+ const reference = read(TECHNICAL_REFERENCE);
98
+ assertMatches(TECHNICAL_REFERENCE, reference, [
99
+ /`low \| medium \| high` tier/,
99
100
  /min\(200, ceil\(original_changed_lines \/ 2\)\)/,
100
101
  /testdata\/golden\/\*\*/,
101
102
  /`reviewing`, `correction_required`, `validating`, `approved`, and `escalated`/,
102
- /`evidence_class`, `causal_disposition`, and concrete proof/,
103
- /`changed-hunk`[\s\S]*`candidate-created-path`[\s\S]*`differential-test`[\s\S]*`before-after`/,
104
- /Only severe `introduced`, `behavior-activated`, or `worsened` findings with valid proof can enter `correction_ids`/,
105
- /`pre-existing` and `base-only` findings become non-blocking follow-ups/,
106
- /one correction transaction/i,
107
- /original budget/i,
108
- /frozen findings and genesis scope/i,
109
- /content-derived revisions, compare-and-swap replacement, exact retry idempotency/i,
110
- /graph-v1 ordinary lineages remain readable for compatibility but reject new mutation/i,
111
- /Legacy graph bundle export\/import is retired/i,
103
+ /Ordinary permits one correction transaction within the original budget\./,
104
+ /frozen findings and genesis scope remain unchanged/,
105
+ /legacy graph bundle export\/import is retired/i,
112
106
  /Judgment Day remains mutable on graph-v1/i,
113
- /--agent=pi --materialize=true/,
114
- /provider-owned submission form/i,
115
- /self-contained authority-advancing vectors/i,
116
- /Commit, push, pull-request creation, and release creation are not RDD gates/i,
117
- /Review outcomes and receipt state are informational and never authorize, consume, rewrite, or block a Bash delivery command/i,
118
- /Pi does not inspect RDD mode or native authority for those commands/i,
119
- /Review transactions, validation, and SDD never perform delivery commands themselves/i,
120
107
  /local orchestrator and same-user process are trusted/i,
121
- /reviewer and validator outputs remain semantically untrusted/i,
122
- /do not report.*trusted local orchestrator.*security finding/i,
123
- /untrusted repository content.*malformed inputs.*stale authority.*path drift.*external callers/i,
124
108
  ...JUDGMENT_DAY_DISCOVERY_PATTERNS,
125
109
  ]);
126
- assert.match(read(TECHNICAL_REFERENCE), /Review outcomes and receipt state are informational; commit, push, pull-request, and release delivery follow ordinary repository policy\./);
110
+ assert.doesNotMatch(reference, /up to three failed targeted attempts|third failed attempt/i);
111
+ assert.match(read(RDD_DEFECT_SKILL), /Keep bounded review defects in one correction transaction/);
112
+ assert.match(reference, /Review outcomes never authorize delivery; commit, push, pull-request and release actions follow ordinary repository policy\./);
127
113
  assert.match(read(README), /\]\(docs\/readme-reference\.md(?:#[^)]+)?\)/);
128
114
  assert.doesNotMatch(read(README), /one one-shot authorization for the exact command/i);
129
115
  assert.doesNotMatch(read(README), /review-publication-gate/i);
@@ -231,16 +217,6 @@ test("ordinary lens prompts contain the literal compact-v2 native result envelop
231
217
  }
232
218
  });
233
219
 
234
- test("retained provider review contract preserves bounded correction without declaring approval", () => {
235
- const content = read(CANONICAL);
236
- assert.match(content, /one correction transaction/i);
237
- assert.match(content, /original budget/i);
238
- assert.match(content, /`correction_required`/);
239
- assert.doesNotMatch(content, /up to three failed targeted attempts|third failed attempt/i);
240
- assert.match(content, /`reviewing`, `correction_required`, `validating`, `approved`, and `escalated`/);
241
- assert.match(content, /Only severe `introduced`, `behavior-activated`, or `worsened` findings with valid proof can enter `correction_ids`/);
242
- });
243
-
244
220
  test("risk lens distinguishes trusted orchestration from concrete boundary bypasses", () => {
245
221
  const content = read("assets/agents/review-risk.md");
246
222
  assert.match(content, /local orchestrator and same-user process are trusted/i);
@@ -314,6 +290,9 @@ test("Judgment Day skill and prompts preserve bounded fix and re-judgment author
314
290
  assertMatches(JD_PROMPTS, judgePrompt, JUDGMENT_DAY_DISCOVERY_PATTERNS);
315
291
  assertMatches(JD_PROMPTS, fencedBlock(JD_PROMPTS, "## Fix Agent Prompt"), FIX_PATTERNS);
316
292
  assertMatches(FIX_AGENT, read(FIX_AGENT), FIX_PATTERNS);
293
+ for (const content of [skill, judgePrompt, ...JUDGES.map(read)]) {
294
+ for (const severity of Object.values(FROZEN_SEVERITY)) assert.match(content, new RegExp(`\\b${severity}\\b`), "judge vocabulary must cover the canonical ledger enum");
295
+ }
317
296
  });
318
297
 
319
298
  test("Judgment Day fix routing has one canonical shape and never falls back to generic roles", () => {
@@ -330,7 +309,6 @@ test("Judgment Day fix routing has one canonical shape and never falls back to g
330
309
  "## Allowed edit surfaces",
331
310
  ].join("\n");
332
311
  for (const [path, content] of [
333
- [CANONICAL, read(CANONICAL)],
334
312
  [FIX_AGENT, read(FIX_AGENT)],
335
313
  [JD_SKILL, read(JD_SKILL)],
336
314
  [JD_PROMPTS, fencedBlock(JD_PROMPTS, "## Fix Agent Prompt")],
@@ -345,7 +323,8 @@ test("Judgment Day fix routing has one canonical shape and never falls back to g
345
323
  });
346
324
 
347
325
  test("orchestrator, injected skill, and technical reference defer RDD lifecycle ownership to Gentle AI", () => {
348
- const boundary = "This package injects the mirrored provider-bundle review execution contract into this session's system prompt at start; Gentle AI writes nothing into the Pi system prompt, and this package owns everything else here. Absent that mirrored contract, this package invents no lifecycle instructions.";
326
+ // cost-speed-painpoints S15 P5a (verdict X1): the contract is injected only while RDD is not off.
327
+ const boundary = "While RDD is not off, this package injects the mirrored provider-bundle review execution contract; Gentle AI writes nothing into this prompt. Absent that mirrored contract, this package invents no lifecycle instructions.";
349
328
  const orchestrator = union(ORCHESTRATOR);
350
329
  assert.ok(orchestrator.includes(boundary), "orchestrator must carry the sole static ownership boundary");
351
330
 
@@ -7,9 +7,8 @@ import test from "node:test";
7
7
  import type { AssistantMessage, JsonObject, Tool, ToolCall } from "@earendil-works/pi-ai";
8
8
  import type { NativeReviewCli } from "../lib/native-review-cli.ts";
9
9
 
10
- // gentle-pi S11 T1: with receipt-driven development off, the orchestrator only
11
- // ever calls gentle_review ASSESS, so the parent request carries a short ASSESS
12
- // guideline and leaves the capture, capture-group, and scope declarations out.
10
+ // With receipt-driven development off, the parent request does not require
11
+ // ASSESS and leaves the capture, capture-group, and scope declarations out.
13
12
  // With RDD on, the request is exactly what the registered tools declare. Both
14
13
  // paths run through a real Pi SDK session and inspect the provider request.
15
14
 
@@ -20,6 +19,7 @@ interface SessionRun {
20
19
  requests: RecordedRequest[];
21
20
  registered: Map<string, { description: string; promptGuidelines?: readonly string[] }>;
22
21
  assessResults: Array<{ isError: boolean; details: unknown }>;
22
+ nativeCalls: { mode: number; assess: number; target: number };
23
23
  errors: string[];
24
24
  }
25
25
 
@@ -31,24 +31,29 @@ const NATIVE_CONTINUATION = {
31
31
  arguments: [{ name: "--agent", value: "pi" }, { name: "--next-transition" }],
32
32
  };
33
33
 
34
- function nativeCli(mode: () => RddMode): NativeReviewCli {
34
+ function nativeCli(mode: () => RddMode, calls: SessionRun["nativeCalls"]): NativeReviewCli {
35
35
  return {
36
36
  reviewMode: async () => {
37
+ calls.mode++;
37
38
  const effective = mode();
38
39
  if (effective === "throws") throw new Error("native review mode is unavailable");
39
40
  return { operation: "status", scope: "clone", status: { global: effective, cloneLocal: "", effective, source: "global" } };
40
41
  },
41
- assess: async () => ({
42
- schema: "gentle-ai.review-assessment/v1",
43
- risk: "high",
44
- reviewDue: true,
45
- reviewDueReason: "high_risk",
46
- nextTransition: NATIVE_CONTINUATION,
47
- reasons: [],
48
- changedPaths: 1,
49
- changedLines: 3,
50
- candidate: { kind: "current-changes", baseRef: undefined },
51
- }),
42
+ assess: async () => {
43
+ calls.assess++;
44
+ return {
45
+ schema: "gentle-ai.review-assessment/v1",
46
+ risk: "high",
47
+ reviewDue: true,
48
+ reviewDueReason: "high_risk",
49
+ nextTransition: NATIVE_CONTINUATION,
50
+ reasons: [],
51
+ changedPaths: 1,
52
+ changedLines: 3,
53
+ candidate: { kind: "current-changes", baseRef: undefined },
54
+ };
55
+ },
56
+ targetStatus: async () => { calls.target++; return { applicability: "current_target", targetIdentity: "fixture" }; },
52
57
  } as unknown as NativeReviewCli;
53
58
  }
54
59
 
@@ -58,6 +63,7 @@ async function runSession(
58
63
  bindings: Record<string, string>,
59
64
  mode: () => RddMode,
60
65
  beforeSecondPrompt: () => void = () => {},
66
+ extra?: { tools: string[]; install: (pi: import("@earendil-works/pi-coding-agent").ExtensionAPI) => void },
61
67
  ): Promise<SessionRun> {
62
68
  const sdk = await import("@earendil-works/pi-coding-agent");
63
69
  const ai = await import("@earendil-works/pi-ai");
@@ -66,9 +72,9 @@ async function runSession(
66
72
  mkdirSync(cwd);
67
73
  const gitEnv = { PATH: process.env.PATH, HOME: root, GIT_CONFIG_NOSYSTEM: "1", GIT_CONFIG_GLOBAL: join(root, "gitconfig") };
68
74
  writeFileSync(gitEnv.GIT_CONFIG_GLOBAL, "");
75
+ // The stubbed review client needs a repository root, not a committed candidate.
69
76
  execFileSync("git", ["init", "--initial-branch=fixture"], { cwd, env: gitEnv, stdio: "ignore" });
70
- execFileSync("git", ["-c", "user.name=SDK Fixture", "-c", "user.email=fixture@example.invalid", "commit", "--allow-empty", "-m", "fixture"], { cwd, env: gitEnv, stdio: "ignore" });
71
- const run: SessionRun = { requests: [], registered: new Map(), assessResults: [], errors: [] };
77
+ const run: SessionRun = { requests: [], registered: new Map(), assessResults: [], nativeCalls: { mode: 0, assess: 0, target: 0 }, errors: [] };
72
78
  let next: { name: string; arguments: JsonObject } | undefined;
73
79
  let calls = 0;
74
80
  const model = { id: "driver", name: "Local driver", provider: "loadout-fixture", api: "loadout-fixture", baseUrl: "http://invalid.local", reasoning: false, input: ["text"], contextWindow: 1_000_000, maxTokens: 1024, cost: { input: 0, output: 0, cacheRead: 0, cacheWrite: 0 } } as const;
@@ -85,11 +91,12 @@ async function runSession(
85
91
  return registerTool(definition as never);
86
92
  }) as typeof pi.registerTool;
87
93
  createGentleAiExtension({
88
- nativeReviewCli: nativeCli(mode),
94
+ nativeReviewCli: nativeCli(mode, run.nativeCalls),
89
95
  candidateViews: null,
90
96
  processEnv: { ...bindings, GENTLE_AI_TELEMETRY: "0" },
91
97
  resolveTelemetryTriggerBinary: () => { throw new Error("fixture"); },
92
98
  })(pi);
99
+ extra?.install(pi);
93
100
  pi.on("tool_result", (event) => {
94
101
  if (event.toolName === "gentle_review") run.assessResults.push({ isError: event.isError, details: event.details });
95
102
  });
@@ -125,7 +132,7 @@ async function runSession(
125
132
  assert.deepEqual(loader.getExtensions().errors, []);
126
133
  const { session } = await sdk.createAgentSession({
127
134
  cwd, agentDir: bindings.PI_CODING_AGENT_DIR, modelRuntime: runtime, model: model as never, thinkingLevel: "off", resourceLoader: loader,
128
- tools: ["read", "gentle_review", ...HIDDEN_WHEN_OFF], sessionManager: manager, settingsManager: settings,
135
+ tools: ["read", "gentle_review", ...HIDDEN_WHEN_OFF, ...(extra?.tools ?? [])], sessionManager: manager, settingsManager: settings,
129
136
  });
130
137
  try {
131
138
  await session.bindExtensions({ mode: "json", onError: (error) => run.errors.push(error.error) });
@@ -140,7 +147,7 @@ async function runSession(
140
147
  return run;
141
148
  }
142
149
 
143
- const LEAN_GUIDELINE = /gentle_review only for \{"operation":"assess"\}/;
150
+ const LEAN_GUIDELINE = /RDD off does not require an assessment/;
144
151
 
145
152
  function fixture(t: { after: (fn: () => void) => void }): { root: string; bindings: Record<string, string> } {
146
153
  const root = realpathSync(mkdtempSync(join(tmpdir(), "gentle-review-loadout-")));
@@ -171,10 +178,8 @@ function registeredGuidelines(run: SessionRun): string[] {
171
178
  function assertLeanRequest(request: RecordedRequest, run: SessionRun): void {
172
179
  assert.match(request.systemPrompt, /Receipt-driven development: off /);
173
180
  assert.match(request.systemPrompt, LEAN_GUIDELINE);
174
- assert.match(request.systemPrompt, /relay it unchanged but do not execute it while RDD is off/);
175
- assert.match(request.systemPrompt, /assessment metadata does not authorize STATUS, another review lifecycle operation, or enabling RDD/);
176
- assert.doesNotMatch(request.systemPrompt, /relay it unchanged and follow it/);
177
- assert.match(request.systemPrompt, /Continue the returned verification plan/);
181
+ assert.doesNotMatch(request.systemPrompt, /after an authorized implementation, delegated or inline, call it over the diff/);
182
+ assert.match(request.systemPrompt, /named Task Size high-risk item still requires one independent verifier/);
178
183
  assert.match(request.systemPrompt, /tests, builds, and functional checks still run/);
179
184
  for (const guideline of registeredGuidelines(run)) assert.equal(request.systemPrompt.includes(guideline), false, `RDD off must leave out: ${guideline.slice(0, 80)}`);
180
185
  const names = request.tools.map((tool) => tool.name);
@@ -193,7 +198,7 @@ function assertRegisteredRequest(request: RecordedRequest, run: SessionRun): voi
193
198
  }
194
199
  }
195
200
 
196
- test("RDD off: the parent request carries only the lean ASSESS loadout; RDD on: the registered review loadout", { timeout: 30_000 }, async (t) => {
201
+ test("RDD off: the parent request does not mandate ASSESS; RDD on keeps the registered review loadout", { timeout: 30_000 }, async (t) => {
197
202
  const { root, bindings } = fixture(t);
198
203
  const off = await runSession(root, "off", bindings, () => "off");
199
204
  const on = await runSession(root, "on", bindings, () => "on");
@@ -211,9 +216,11 @@ test("RDD off: the parent request carries only the lean ASSESS loadout; RDD on:
211
216
  assert.equal((off.assessResults[0].details as { schema?: string }).schema, "gentle-pi.review-assessment-plan/v1");
212
217
  const plan = off.assessResults[0].details as Record<string, unknown>;
213
218
  assert.equal(plan.rddLine, "off");
214
- assert.equal(plan.reviewDue, true);
215
- assert.equal(plan.reviewDueReason, "high_risk");
216
- assert.deepEqual(plan.nextTransition, NATIVE_CONTINUATION);
219
+ assert.equal(plan.nativeRisk, "unassessable");
220
+ assert.equal(plan.candidate, null);
221
+ for (const field of ["reviewDue", "reviewDueReason", "nextTransition"]) assert.equal(Object.hasOwn(plan, field), false);
222
+ assert.equal(off.nativeCalls.assess, 0);
223
+ assert.equal(off.nativeCalls.target, 0);
217
224
  assert.equal((plan.plan as Record<string, unknown>).writerSelfVerification, true);
218
225
  assert.equal((plan.plan as Record<string, unknown>).independentVerifier, true);
219
226
 
@@ -223,6 +230,9 @@ test("RDD off: the parent request carries only the lean ASSESS loadout; RDD on:
223
230
  }
224
231
  assert.equal(on.assessResults.length, 1);
225
232
  assert.equal(on.assessResults[0].isError, false);
233
+ assert.equal(on.nativeCalls.assess, 1);
234
+ assert.equal(on.nativeCalls.target, 1);
235
+ assert.deepEqual((on.assessResults[0].details as Record<string, unknown>).nextTransition, NATIVE_CONTINUATION);
226
236
 
227
237
  const bytes = (request: RecordedRequest) => ({
228
238
  systemPrompt: Buffer.byteLength(request.systemPrompt),
@@ -244,15 +254,68 @@ test("an unknown RDD line keeps the registered loadout; turning RDD on mid-sessi
244
254
  assert.match(request.systemPrompt, /Receipt-driven development: unknown/);
245
255
  assertRegisteredRequest(request, unknown);
246
256
  }
257
+ assert.equal(unknown.nativeCalls.assess, 1);
258
+ assert.equal(unknown.nativeCalls.target, 1);
247
259
 
248
260
  let mode: RddMode = "off";
249
- const flipped = await runSession(root, "flip", bindings, () => mode, () => {
250
- mode = "on";
251
- __testing.clearRddStatusMemoForTesting();
252
- });
261
+ const flipped = await runSession(root, "flip", bindings, () => mode, () => { mode = "on"; });
253
262
  assert.deepEqual(flipped.errors, []);
254
263
  const last = flipped.requests.at(-1)!;
255
264
  for (const request of flipped.requests.slice(0, -1)) assertLeanRequest(request, flipped);
256
265
  assert.match(last.systemPrompt, /Receipt-driven development: on /);
257
266
  assertRegisteredRequest(last, flipped);
267
+
268
+ mode = "off";
269
+ const failed = await runSession(root, "failed-after-off", bindings, () => mode, () => { mode = "throws"; });
270
+ assert.deepEqual(failed.errors, []);
271
+ assert.match(failed.requests.at(-1)!.systemPrompt, /Receipt-driven development: unknown/);
272
+ assertRegisteredRequest(failed.requests.at(-1)!, failed);
273
+ });
274
+
275
+ test("malformed fresh reads restore guidance while on and unknown preserve pinning", { timeout: 30_000 }, async (t) => {
276
+ const { root, bindings } = fixture(t);
277
+ for (const [initial, next, expected] of [["off", "malformed", "unknown"], ["on", "throws", "on"], ["throws", "on", "unknown"]] as const) {
278
+ let mode: RddMode = initial;
279
+ const run = await runSession(root, `independent-${initial}`, bindings, () => mode, () => { mode = next as RddMode; });
280
+ assert.deepEqual(run.errors, []);
281
+ assert.match(run.requests.at(-1)!.systemPrompt, new RegExp(`Receipt-driven development: ${expected}`));
282
+ assertRegisteredRequest(run.requests.at(-1)!, run);
283
+ if (initial === "off") {
284
+ assertLeanRequest(run.requests[0], run);
285
+ assert.equal(run.nativeCalls.assess, 0);
286
+ assert.equal(run.nativeCalls.target, 0);
287
+ } else {
288
+ assert.equal(run.nativeCalls.assess, 1);
289
+ assert.equal(run.nativeCalls.target, 1);
290
+ assert.equal(new Set(run.requests.map((request) => request.systemPrompt)).size, 1);
291
+ }
292
+ t.diagnostic(JSON.stringify({ initial, next, expected, requests: run.requests.length, calls: run.nativeCalls, errors: run.errors }));
293
+ }
294
+ });
295
+
296
+ // P3 (tools by mode): another tool hidden behind codemode joins the RDD-off
297
+ // projection; it never replaces it, and the request stays stable across turns.
298
+ test("RDD off: the review capture tools stay hidden beside a tool hidden behind codemode", { timeout: 30_000 }, async (t) => {
299
+ const { root, bindings } = fixture(t);
300
+ const { default: gentleGuide } = await import("../extensions/gentle-guide.ts");
301
+ const { registerCompactCodemode } = await import("../lib/codemode-renderer.ts");
302
+ const extra = { tools: ["gentle_guide", "codemode"], install: (pi: import("@earendil-works/pi-coding-agent").ExtensionAPI) => { gentleGuide(pi, {}); registerCompactCodemode(pi); } };
303
+ const off = await runSession(root, "off-codemode", bindings, () => "off", () => {}, extra);
304
+ assert.deepEqual(off.errors, []);
305
+ for (const request of off.requests) {
306
+ assertLeanRequest(request, off);
307
+ assert.match(request.systemPrompt, /gentle_review\* tools are model-only: use direct tool calls, never tools\.gentle_review\(\.\.\.\) in codemode/);
308
+ assert.match(request.systemPrompt, /ALL_TOOLS lists only callable tools; absence there does not mean the direct tool is unavailable/);
309
+ assert.match(request.tools.find(tool => tool.name === "gentle_review")!.description, /Call directly, never through codemode/);
310
+ const names = request.tools.map((tool) => tool.name);
311
+ assert.deepEqual(names, ["read", "gentle_review", "codemode"], "review capture tools and the guide are all left out");
312
+ }
313
+ assert.equal(new Set(off.requests.map((request) => JSON.stringify(request.tools.map((tool) => tool.name)))).size, 1);
314
+ const on = await runSession(root, "on-codemode", bindings, () => "on", () => {}, extra);
315
+ assert.deepEqual(on.errors, []);
316
+ for (const request of on.requests) {
317
+ assert.deepEqual(request.tools.map((tool) => tool.name), ["read", "gentle_review", ...HIDDEN_WHEN_OFF, "codemode"], "RDD on declares the review family; the guide stays behind codemode");
318
+ assert.match(request.systemPrompt, /gentle_review\* tools are model-only: use direct tool calls/);
319
+ assert.match(request.tools.find(tool => tool.name === "gentle_review")!.description, /Call directly, never through codemode/);
320
+ }
258
321
  });