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
@@ -0,0 +1,165 @@
1
+ import assert from "node:assert/strict";
2
+ import { mkdtempSync, readFileSync, realpathSync, rmSync, writeFileSync } from "node:fs";
3
+ import { tmpdir } from "node:os";
4
+ import { join } from "node:path";
5
+ import test, { after } from "node:test";
6
+ import { NativeReviewCliV216, NativeReviewIntegrationError, type ExecFileAdapter } from "../lib/native-review-cli.ts";
7
+
8
+ // odd/tasks/review-one-call.md T11 (S5), L18: contracted STATUS asks for the
9
+ // non-blocking findings (gentle-ai#6088) only when the caller requests them; a
10
+ // provider that refuses the unknown flag is asked once more without it and is
11
+ // not sent the flag again while it stays the same binary.
12
+
13
+ const scratch = realpathSync(mkdtempSync(join(realpathSync(tmpdir()), "native-nbf-")));
14
+ after(() => rmSync(scratch, { recursive: true, force: true }));
15
+ let binaries = 0;
16
+ /** A package-local executable stand-in; only its path and bytes identify it. */
17
+ function binary(content = `fixture-${binaries}`): string {
18
+ const path = join(scratch, `gentle-ai-${binaries++}`);
19
+ writeFileSync(path, content);
20
+ return path;
21
+ }
22
+
23
+ const statusBody = JSON.parse(readFileSync(join(process.cwd(), "tests", "fixtures", "devbinary", "status-v5.captured.json"), "utf8"));
24
+ const refusal = (cause: string) => ({
25
+ schema: "gentle-ai.review-integration.failure/v2", contract: "gentle-ai.review-integration/v2", operation: "review.status", phase: "preflight",
26
+ code: "invalid_request", message: "The negotiated review request is invalid.", mutation_outcome: "not_started", authority_applicability: "not_evaluated",
27
+ retry_safe: true, replayability: "not_replayable", required_inputs: [], next_action: "correct_request", cause,
28
+ });
29
+ const UNKNOWN_FLAG = refusal("flag provided but not defined: -non-blocking-findings");
30
+ type Reply = { body: unknown; exitCode?: number };
31
+ function adapter(replies: Reply[]): { adapter: ExecFileAdapter; calls: { file: string; arguments: readonly string[] }[] } {
32
+ const calls: { file: string; arguments: readonly string[] }[] = [];
33
+ return { calls, adapter: async (request) => {
34
+ calls.push({ file: request.file, arguments: request.arguments });
35
+ const reply = replies.shift();
36
+ if (reply === undefined) throw new Error("unexpected native invocation");
37
+ const exitCode = reply.exitCode ?? 0;
38
+ return { stdout: JSON.stringify(reply.body), stderr: exitCode === 0 ? "" : "Error: The negotiated review request is invalid. [invalid_request]\n", exitCode, signal: null, timedOut: false, outputLimitExceeded: false };
39
+ } };
40
+ }
41
+ const base = ["review", "status", "--contract", "gentle-ai.review-integration/v2", "--cwd", "/repo", "--projection", "workspace", "--lineage", "review-status-fixture", "--agent", "pi"];
42
+ const request = { cwd: "/repo", lineageId: "review-status-fixture", agent: "pi" as const };
43
+
44
+ test("a contracted STATUS sends --non-blocking-findings only when the caller asks for it", async () => {
45
+ const queue = adapter([{ body: statusBody }, { body: statusBody }]);
46
+ const cli = new NativeReviewCliV216(queue.adapter, binary(), 30_000, 1024 * 1024);
47
+ await cli.targetStatus({ ...request, nonBlockingFindings: true });
48
+ await cli.targetStatus(request);
49
+ assert.deepEqual(queue.calls.map((call) => call.arguments), [[...base, "--non-blocking-findings", "--next-transition"], [...base, "--next-transition"]]);
50
+ });
51
+
52
+ test("a provider that refuses the unknown flag is asked once more without it and is not sent it again while it is the same binary", async () => {
53
+ const executable = binary();
54
+ const queue = adapter([{ body: UNKNOWN_FLAG, exitCode: 1 }, { body: statusBody }, { body: statusBody }]);
55
+ const cli = new NativeReviewCliV216(queue.adapter, () => executable, 30_000, 1024 * 1024);
56
+ const first = await cli.targetStatus({ ...request, nonBlockingFindings: true });
57
+ assert.equal(first.nextTransition?.kind, "collect", "the run ends as today");
58
+ assert.equal(Object.hasOwn(first, "nonBlockingFindings"), false);
59
+ await cli.targetStatus({ ...request, nonBlockingFindings: true });
60
+ assert.deepEqual(queue.calls.map((call) => call.arguments), [
61
+ [...base, "--non-blocking-findings", "--next-transition"],
62
+ [...base, "--next-transition"],
63
+ [...base, "--next-transition"],
64
+ ]);
65
+ // A replaced binary at the same path is a different provider: asked again.
66
+ writeFileSync(executable, "a newer provider");
67
+ const renewed = adapter([{ body: statusBody }]);
68
+ const replaced = new NativeReviewCliV216(renewed.adapter, () => executable, 30_000, 1024 * 1024);
69
+ await replaced.targetStatus({ ...request, nonBlockingFindings: true });
70
+ assert.deepEqual(renewed.calls[0]!.arguments, [...base, "--non-blocking-findings", "--next-transition"]);
71
+ });
72
+
73
+ test("the refusal is remembered per binary: another binary is still sent the flag", async () => {
74
+ const old = binary("old provider");
75
+ const current = binary("current provider");
76
+ let path = old;
77
+ const queue = adapter([{ body: UNKNOWN_FLAG, exitCode: 1 }, { body: statusBody }, { body: statusBody }]);
78
+ const cli = new NativeReviewCliV216(queue.adapter, () => path, 30_000, 1024 * 1024);
79
+ await cli.targetStatus({ ...request, nonBlockingFindings: true });
80
+ path = current;
81
+ await cli.targetStatus({ ...request, nonBlockingFindings: true });
82
+ assert.deepEqual(queue.calls.map((call) => [call.file, call.arguments.includes("--non-blocking-findings")]), [[old, true], [old, false], [current, true]]);
83
+ });
84
+
85
+ test("any other STATUS failure is not retried and keeps its error", async () => {
86
+ for (const body of [refusal("flag provided but not defined: -lenses"), refusal("--non-blocking-findings requires --contract gentle-ai.review-integration/v2"), { ...UNKNOWN_FLAG, code: "authority_unavailable" }]) {
87
+ const queue = adapter([{ body, exitCode: 1 }]);
88
+ const cli = new NativeReviewCliV216(queue.adapter, binary(), 30_000, 1024 * 1024);
89
+ await assert.rejects(cli.targetStatus({ ...request, nonBlockingFindings: true }), (error: unknown) => error instanceof NativeReviewIntegrationError && error.failureEnvelope.cause === body.cause);
90
+ assert.equal(queue.calls.length, 1, String(body.cause));
91
+ }
92
+ });
93
+
94
+ test("the flag rides only Gentle Shell's own contracted STATUS, never a provider-issued selection submission", async () => {
95
+ const queue = adapter([{ body: statusBody }]);
96
+ const cli = new NativeReviewCliV216(queue.adapter, binary(), 30_000, 1024 * 1024);
97
+ await cli.targetStatus({ cwd: "/repo", nonBlockingFindings: true, intendedUntrackedSelection: {
98
+ argumentTokens: ["--contract=gentle-ai.review-integration/v2", "--next-transition=true", "--agent=pi", "--projection=workspace", "--intended-untracked-selection={{value}}"], value: "{}" } } as never);
99
+ assert.equal(queue.calls[0]!.arguments.includes("--non-blocking-findings"), false);
100
+ });
101
+
102
+ // Verifier regressions (odd/tasks/review-one-call.md L19).
103
+ test("two concurrent first STATUS calls each pay the refusal once; later calls never resend the flag", async () => {
104
+ const executable = binary("concurrent provider");
105
+ const calls: boolean[] = [];
106
+ const adapterFn: ExecFileAdapter = async (request) => {
107
+ const flagged = request.arguments.includes("--non-blocking-findings");
108
+ calls.push(flagged);
109
+ await new Promise((resolve) => setTimeout(resolve, 5));
110
+ const refused = flagged;
111
+ return { stdout: JSON.stringify(refused ? UNKNOWN_FLAG : statusBody), stderr: refused ? "Error: The negotiated review request is invalid. [invalid_request]\n" : "", exitCode: refused ? 1 : 0, signal: null, timedOut: false, outputLimitExceeded: false };
112
+ };
113
+ const cli = new NativeReviewCliV216(adapterFn, () => executable, 30_000, 1024 * 1024);
114
+ await Promise.all([cli.targetStatus({ ...request, nonBlockingFindings: true }), cli.targetStatus({ ...request, nonBlockingFindings: true })]);
115
+ await cli.targetStatus({ ...request, nonBlockingFindings: true });
116
+ assert.deepEqual(calls, [true, true, false, false, false]);
117
+ });
118
+
119
+ test("look-alike refusals are not retried", async () => {
120
+ for (const body of [
121
+ refusal("x flag provided but not defined: -non-blocking-findings"),
122
+ refusal("flag provided but not defined: -non-blocking-findings-v2"),
123
+ { ...UNKNOWN_FLAG, mutation_outcome: "unknown" },
124
+ ]) {
125
+ const queue = adapter([{ body, exitCode: 1 }]);
126
+ const cli = new NativeReviewCliV216(queue.adapter, binary(), 30_000, 1024 * 1024);
127
+ await assert.rejects(cli.targetStatus({ ...request, nonBlockingFindings: true }));
128
+ assert.equal(queue.calls.length, 1, JSON.stringify(body).slice(0, 200));
129
+ }
130
+ });
131
+
132
+ test("an in-flight old refusal does not suppress the flag for a replacement executable", async () => {
133
+ const executable = binary("old in-flight provider");
134
+ let enter!: () => void;
135
+ let release!: () => void;
136
+ const entered = new Promise<void>((resolve) => { enter = resolve; });
137
+ const held = new Promise<void>((resolve) => { release = resolve; });
138
+ const queue = adapter([{ body: UNKNOWN_FLAG, exitCode: 1 }, { body: statusBody }, { body: statusBody }]);
139
+ let first = true;
140
+ const cli = new NativeReviewCliV216(async (call) => {
141
+ if (first) { first = false; enter(); await held; }
142
+ return queue.adapter(call);
143
+ }, executable, 30_000, 1024 * 1024);
144
+ const pending = cli.targetStatus({ ...request, nonBlockingFindings: true });
145
+ await entered;
146
+ writeFileSync(executable, "replacement supporting provider");
147
+ release();
148
+ assert.equal((await pending).nextTransition?.kind, "collect");
149
+ assert.equal((await cli.targetStatus({ ...request, nonBlockingFindings: true })).nextTransition?.kind, "collect");
150
+ assert.deepEqual(queue.calls.map((call) => call.arguments), [
151
+ [...base, "--non-blocking-findings", "--next-transition"],
152
+ [...base, "--next-transition"],
153
+ [...base, "--non-blocking-findings", "--next-transition"],
154
+ ]);
155
+ });
156
+
157
+ test("unreadable executable identity preserves STATUS refusal fallback without caching", async () => {
158
+ const executable = join(scratch, "absent-executable");
159
+ const queue = adapter([{ body: UNKNOWN_FLAG, exitCode: 1 }, { body: statusBody }, { body: UNKNOWN_FLAG, exitCode: 1 }, { body: statusBody }]);
160
+ const cli = new NativeReviewCliV216(queue.adapter, executable, 30_000, 1024 * 1024);
161
+ for (let call = 0; call < 2; call++) {
162
+ assert.equal((await cli.targetStatus({ ...request, nonBlockingFindings: true })).nextTransition?.kind, "collect");
163
+ }
164
+ assert.deepEqual(queue.calls.map((call) => call.arguments.includes("--non-blocking-findings")), [true, false, true, false]);
165
+ });
@@ -283,13 +283,21 @@ async function executeController(runtime: ParityRuntime, operation: unknown, cwd
283
283
  return response.details as Record<string, unknown>;
284
284
  }
285
285
 
286
- function consentNative(cwd: string): { native: NativeReviewCli; starts: { count: number }; answers: string[] } {
287
- const consent = decodeReviewConsentV3(captured("consent-v3.captured.json"));
286
+ function consentNative(cwd: string, agent: "claude-code" | "pi" = "claude-code"): { native: NativeReviewCli; starts: { count: number }; answers: string[]; consent: ReturnType<typeof decodeReviewConsentV3> } {
287
+ const raw = captured("consent-v3.captured.json") as Record<string, unknown>;
288
+ if (agent === "pi") {
289
+ raw.agent = agent;
290
+ for (const choice of raw.choices as Array<Record<string, unknown>>) {
291
+ choice.invocation = String(choice.invocation).replace(" --consent ", " --agent pi --consent ");
292
+ }
293
+ }
294
+ const consent = decodeReviewConsentV3(raw, agent);
288
295
  const starts = { count: 0 };
289
296
  const answers: string[] = [];
290
297
  return {
291
298
  starts,
292
299
  answers,
300
+ consent,
293
301
  native: {
294
302
  targetStatus: async () => startStatus(cwd),
295
303
  start: async () => {
@@ -336,6 +344,12 @@ async function beginConsent(runtime: ParityRuntime, cwd: string, sessionId = "pa
336
344
  const blocked = await executeController(runtime, { operation: "start", input: JSON.stringify({ mode: "ordinary" }) }, cwd, sessionId);
337
345
  assert.equal(blocked.outcome, "native-review-consent-required");
338
346
  assert.equal(typeof blocked.consent_binding, "string");
347
+ const consent = blocked.consent as Record<string, unknown>;
348
+ if (consent.schema === "gentle-ai.review-integration.consent/v3" && consent.agent === "pi") {
349
+ assert.equal(consent.consentBinding, blocked.consent_binding);
350
+ } else {
351
+ assert.equal(Object.hasOwn(consent, "consentBinding"), false, "other native envelopes remain exact");
352
+ }
339
353
  return blocked;
340
354
  }
341
355
 
@@ -439,7 +453,7 @@ test("public gentle:review-mode handler reports current operations, global-off w
439
453
  test("public consent relay allows any active session to resolve a live binding, is one-shot, and is candidate-scoped", async (t) => {
440
454
  const cwd = repository(t);
441
455
  const sharedRegistry = new PendingReviewConsentRegistry();
442
- const fixture = consentNative(cwd);
456
+ const fixture = consentNative(cwd, "pi");
443
457
  const first = parityRuntime(fixture.native, { pendingReviewConsentRegistry: sharedRegistry });
444
458
  const second = parityRuntime(fixture.native, { pendingReviewConsentRegistry: sharedRegistry });
445
459
  const sameSession = await beginConsent(first, cwd, "same-session");
@@ -449,8 +463,13 @@ test("public consent relay allows any active session to resolve a live binding,
449
463
  // gentle-pi#455: a binding is answerable by whichever active Pi session
450
464
  // presents it, not only the session whose START created it.
451
465
  const blockedA = await beginConsent(first, cwd, "session-a");
452
- assert.deepEqual(blockedA.consent, decodeReviewConsentV3(captured("consent-v3.captured.json")).raw);
453
- const declinedFromOtherSession = await answerConsent(second, cwd, blockedA.consent_binding, "declined", "session-b");
466
+ const { consentBinding, ...nativeEnvelope } = blockedA.consent as Record<string, unknown>;
467
+ assert.deepEqual(nativeEnvelope, fixture.consent.raw, "the public copy preserves every native field");
468
+ assert.notEqual(blockedA.consent, fixture.consent.raw, "the Pi annotation must not mutate the native object");
469
+ assert.equal(Object.hasOwn(fixture.consent.raw, "consentBinding"), false);
470
+ assert.doesNotThrow(() => decodeReviewConsentV3(fixture.consent.raw));
471
+ assert.throws(() => decodeReviewConsentV3(blockedA.consent), /consentBinding/, "the annotated copy is not a native envelope");
472
+ const declinedFromOtherSession = await answerConsent(second, cwd, consentBinding, "declined", "session-b");
454
473
  assert.equal(declinedFromOtherSession.operation, "answer-consent");
455
474
  assert.equal(declinedFromOtherSession.outcome, "consent-declined-this-candidate");
456
475
  assert.deepEqual(fixture.answers, ["declined", "declined"]);
@@ -0,0 +1,25 @@
1
+ // Independent T3 refusal-identity regressions (S1/S3).
2
+ import assert from "node:assert/strict";
3
+ import { spawnSync } from "node:child_process";
4
+ import { mkdtempSync, rmSync } from "node:fs";
5
+ import { tmpdir } from "node:os";
6
+ import { join } from "node:path";
7
+ import test from "node:test";
8
+
9
+ for (const flavor of ["runtime", "typescript"]) {
10
+ test(`refusal identity public probes: ${flavor}`, () => {
11
+ const scratch = mkdtempSync(join(tmpdir(), "identity-regression-"));
12
+ try {
13
+ const run = spawnSync(process.execPath, ["--experimental-strip-types", "--test", "tests/fixtures/refusal-identity.probe.mjs"], {
14
+ cwd: process.cwd(), encoding: "utf8", timeout: 30_000,
15
+ env: { PATH: process.env.PATH, HOME: scratch, USERPROFILE: scratch,
16
+ TMPDIR: scratch, TMP: scratch, TEMP: scratch,
17
+ NODE_COMPILE_CACHE: join(scratch, "cache"), NO_UPDATE_NOTIFIER: "1",
18
+ PROBE_ROOT: process.cwd(), PROBE_FLAVOR: flavor },
19
+ });
20
+ assert.equal(run.status, 0, `${run.error ?? ""}\n${run.stdout}\n${run.stderr}`);
21
+ } finally {
22
+ rmSync(scratch, { recursive: true, force: true });
23
+ }
24
+ });
25
+ }
@@ -33,8 +33,15 @@ test("resolved subdecisions retain the original authorized objective", () => {
33
33
  assert.ok(prompt.includes("Resolving an incident or subdecision does not complete or cancel the original authorized objective; resume safe, necessary in-scope steps automatically, using judgment for proportionate recovery and respecting explicit user dispositions. Investigate pending technical uncertainty rather than treating it alone as a new human decision."));
34
34
  assert.ok(prompt.includes("Stop for an unresolved consequential scope/product decision, required explicit consent, a denied action, or the human's explicit stop."));
35
35
  assert.ok(prompt.includes("Unavailable required proof blocks completion and delivery; it does not alone prohibit specifically authorized in-scope implementation where actual native authority and other limits permit it."));
36
- assert.ok(prompt.includes("After a setup prerequisite is repaired, the human may explicitly request one new bounded verification attempt."));
37
- assert.ok(prompt.includes("Never bypass consent, a denial, explicit one-run or no-retry limits, terminal native outcomes, or exhausted native budgets."));
36
+ // cost-speed-painpoints S15 P4: the verifier-setup rules load with the Verification rule, not on every turn.
37
+ const verification = read("assets/orchestrator-verification.md");
38
+ for (const sentence of [
39
+ "After a setup prerequisite is repaired, the human may explicitly request one new bounded verification attempt.",
40
+ "Never bypass consent, a denial, explicit one-run or no-retry limits, terminal native outcomes, or exhausted native budgets",
41
+ ]) {
42
+ assert.ok(verification.includes(sentence), `verification module keeps: ${sentence}`);
43
+ assert.ok(!prompt.includes(sentence), `always-on prompt no longer carries: ${sentence}`);
44
+ }
38
45
  assert.ok(prompt.includes("Do not infer permission for publishing, destructive actions, unrelated scope or native consent from this continuity rule."));
39
46
  });
40
47
 
@@ -86,7 +93,8 @@ test("T13: the Close gate requires continuing or quoting the user's explicit sto
86
93
  test("T13: budgets hold and the pinned human-control line is untouched", () => {
87
94
  const bytes = Buffer.byteLength(tracking, "utf8");
88
95
  // S14: close the open slice before a high-risk commit; outcomes per commit (12,600 -> 12,850 B), same as MODULE_BUDGETS.
89
- assert.ok(bytes <= 12_850, `orchestrator-tracking.md is ${bytes} B, over its 12,850 B budget`);
96
+ // P5b: contradictions and step 3 / Phase reporting restatements removed; 1.4.0 commit-boundary rules kept (12,850 -> 10,324 B).
97
+ assert.ok(bytes <= 10_324, `orchestrator-tracking.md is ${bytes} B, over its 10,324 B budget`);
90
98
  assert.ok(core.includes("- Preserve human control: user decisions beat agent momentum."), "core human-control line must stay verbatim");
91
99
  assert.ok(core.includes("4. **Track**") && core.includes("`orchestrator-tracking.md`"), "Track must still load the tracking module");
92
100
  });
@@ -1,6 +1,7 @@
1
1
  import assert from "node:assert/strict";
2
2
  import { existsSync, readFileSync } from "node:fs";
3
3
  import test from "node:test";
4
+ import { __testing } from "../extensions/gentle-ai.ts";
4
5
  import { readDelegationDetail } from "./support/orchestrator-modules.ts";
5
6
 
6
7
  const read = (path: string) => readFileSync(new URL(`../${path}`, import.meta.url), "utf8");
@@ -11,7 +12,10 @@ test("ODD continuity persists the task file and complete Engram mirror across re
11
12
  assert.match(memory, /odd\/tasks\/<feature-name>\.md/);
12
13
  assert.match(memory, /odd\/<feature-name>\/tasks/);
13
14
  assert.match(memory, /Mirror the full current document and repository-relative file locator/);
14
- assert.match(memory, /Read back both writes; they are not atomic/);
15
+ assert.match(memory, /After a successful local update and an explicit, complete save acknowledgement/);
16
+ assert.match(memory, /do not routinely reread both full copies/);
17
+ assert.match(memory, /These writes are not atomic/);
18
+ assert.match(memory, /uncertain acknowledgement requires checking which writes already applied before any retry; never replay an applied write/);
15
19
  assert.match(memory, /mirror pending/);
16
20
  assert.match(memory, /On resume, use `mem_context`, then project\/feature-scoped `mem_search`, and `mem_get_observation`/);
17
21
  assert.match(memory, /read the actual task file/);
@@ -19,7 +23,9 @@ test("ODD continuity persists the task file and complete Engram mirror across re
19
23
 
20
24
  test("optional research stays output-only and delegates to a general worker", () => {
21
25
  const delegation = readDelegationDetail();
22
- assert.match(delegation, /Recommend optional research only for a named uncertainty/);
26
+ // P5b: the named-uncertainty rule is stated once, in always-on step 3.
27
+ assert.match(__testing.buildGentlePrompt("gentleman"), /Recommend optional research only for a named uncertainty/);
28
+ assert.doesNotMatch(delegation, /Recommend optional research only for a named uncertainty/);
23
29
  assert.match(delegation, /Forward these research instructions to an existing fresh general exploration\/research worker/);
24
30
  assert.match(delegation, /Research remains read-only and requires no new persistence or readiness machinery/);
25
31
  assert.match(delegation, /If tools are unavailable, disclose limitations without inventing access or evidence/);
@@ -32,7 +38,9 @@ test("applicability, fallback and honest evidence flow through ODD actors", () =
32
38
  const worker = read("assets/agents/gentle-ai-worker.md");
33
39
  const verifier = read("assets/agents/gentle-ai-verify.md");
34
40
  assert.match(wrapper, /behavior changes with applicable runnable deterministic tests and a clear expected outcome/);
35
- assert.match(delegation, /Test or framework presence alone does not establish applicability/);
41
+ // P5b (C3): the applicability rule lives in the always-on principle; the lazy modules forward it.
42
+ assert.match(wrapper, /Test presence alone does not establish applicability/);
43
+ assert.match(delegation, /forward this policy, the applicable exact runner and commands/);
36
44
  for (const [actor, text] of [["implementation support", support], ["worker", worker], ["verifier", verifier]] as const) {
37
45
  assert.match(text, /behavior changes with applicable runnable deterministic tests and a clear expected outcome/i, `${actor} must assess behavior-level applicability`);
38
46
  assert.match(text, /passive documentation/i, `${actor} must handle passive docs`);
@@ -82,7 +82,9 @@ test("organic progress preserves both complete feature copies and reconciles act
82
82
  "preserve valid completed and unrelated work",
83
83
  "reopen invalidated items",
84
84
  "Check off only observed outcomes",
85
- "Read back both writes",
85
+ "explicit, complete save acknowledgement",
86
+ "inspect the changed local task/log lines as needed",
87
+ "do not routinely reread both full copies",
86
88
  "not atomic",
87
89
  "mirror pending",
88
90
  "Preserve both versions",
@@ -98,21 +100,41 @@ test("organic progress preserves both complete feature copies and reconciles act
98
100
  assert.doesNotMatch(memory, /`todo` tool is an optional session\/UI projection/);
99
101
  });
100
102
 
103
+ // gentle-shell#1494 field follow-up: tracking must not grow its own reconciliation
104
+ // scripts, invented size gates, or repeated malformed writer launches.
105
+ test("tracking sync recovers from partial writes without custom reconciliation gates", () => {
106
+ containsAll(memory, [
107
+ "These writes are not atomic",
108
+ "never author comparison or reconciliation scripts or gates for them",
109
+ "A missing, partial, truncated, failed, or uncertain acknowledgement requires checking which writes already applied before any retry; never replay an applied write",
110
+ "If the tool reports a payload it cannot preserve, keep the file and mark its mirror pending rather than repeatedly resending the same payload",
111
+ "a mirror that differs from the file just written is refreshed from the file, never a blocker",
112
+ "Preserve both versions on irreconcilable edits",
113
+ ]);
114
+ containsAll(delegation, [
115
+ "A user's line limit is a ceiling, never an exact-count gate; never invent acceptance gates the user did not ask for",
116
+ ]);
117
+ const writerClause = "Every new writer launch carries the section (a continuation inherits it); after an admission rejection, repair what it names once, never relaunch the same prompt unchanged";
118
+ containsAll(delegation, [writerClause]);
119
+ containsAll(read("assets/orchestrator-full-delegation-card.md"), [writerClause]);
120
+ });
121
+
101
122
  test("assumption challenge and task checks do not activate or duplicate native review", () => {
123
+ // P5b: the step 3 limit lives in the always-on steps; tracking keeps only what step 3 does not carry.
124
+ containsAll(wrapper, ["at most one scoped read-only assumption challenge for a high-consequence unproven premise"]);
102
125
  containsAll(delegation, [
103
- "at most one scoped independent read-only assumption challenge",
104
- "high-consequence unproven premise",
126
+ "The step 3 assumption challenge is independent",
105
127
  "Deterministic failures need fixes",
106
128
  "native RDD refuter",
107
129
  "functional checks per task",
108
130
  "native review runs at that work-unit commit or PR slice boundary",
109
- "native candidate risk assessment",
110
- "gentle_review` with `{\"operation\":\"assess\"}",
111
- "Passive/low",
112
- "no reviewer or consent ceremony",
113
- "only on grant",
114
- "decline continues under ordinary policy",
115
- "never infer low risk from a failed assessment",
131
+ "Never replace assessment with model judgment, task size or defect severity",
132
+ "`gentle_review` `{\"operation\":\"assess\"}`",
133
+ // P5b (C5): the injected contract governs how a review starts, runs, and gets consent; tracking keeps the
134
+ // commit-boundary rules mirrored from routing/pi.md, which the rendered prompt carries nowhere else.
135
+ "When RDD is enabled, the injected Gentle AI contract governs native review start, execution and consent; this module adds only assessment and commit boundaries.",
136
+ "A not-due `passive` commit needs no review and the boundary advances; `under_budget` stays pending in the slice until a later commit reaches the budget.",
137
+ "lower the tier or infer low risk",
116
138
  "When RDD is disabled, do not start or prompt for RDD",
117
139
  ]);
118
140
  });
@@ -157,14 +179,10 @@ test("ODD commits work units in reviewable slices and reviews the commit or PR s
157
179
  );
158
180
  assert.ok(!core.includes("- Never commit unless the user explicitly asks."), "core Safety contradicts ODD step 6 work-unit commits");
159
181
  containsAll(delegation, [
160
- 'after each work-unit commit, assess it with that same call and `{"baseRef":"<last reviewed boundary>","committedOnly":true}`',
161
- "Passive/low: silent structural checks, no reviewer or consent ceremony, and the boundary advances",
162
- 'start native review on it right away at that base with `gentle_review` `{"operation":"start"}`',
163
- "Medium: defer to the PR slice",
164
- "bounded by the delivery budget of about 400 authored changed lines",
165
- "The first boundary is the branch point, and every reviewed boundary becomes the next base",
182
+ 'After each work-unit commit, assess it with `gentle_review` `{"operation":"assess"}` and `{"baseRef":"<last reviewed boundary>","committedOnly":true}`',
183
+ "start at the branch point; each reviewed boundary is the next base",
166
184
  // S14: commit per reviewable slice; one commit may hold several tasks, so outcomes are recorded per commit.
167
- "Record per commit the assessed tier and outcome: granted, declined, passive, deferred to slice, or unavailable",
185
+ "Record each commit's assessed tier, outcome (not due, granted, declined, unavailable) and `reviewDueReason`",
168
186
  "Delivery follows work units",
169
187
  "forecast authored changed lines (additions plus deletions, generated files excluded) from the task list",
170
188
  "keep a running count from work-unit commits",
@@ -253,7 +271,10 @@ test("one feature document carries intent, accepted rationale and worker context
253
271
  "automatically update affected intent and TODOs",
254
272
  "add genuinely new tasks or reopen invalidated items with a reason",
255
273
  "Findings alone never authorize scope expansion or automatic acceptance",
256
- "Before implementation or resume, the parent reads both the actual file and full observation",
274
+ "At initial implementation or recovery after interruption or context loss, the parent reads both the actual file and full observation",
275
+ "Within an intact continuation, reuse the established specs, next task, route, and applicable proof",
276
+ "A progress question does not restart preparation",
277
+ "New scope, external edits, stale proof, or missing context require inspecting the affected state before editing",
257
278
  "passes the locator, task IDs, and linked `S#`; workers read the document until `## Log` before edits",
258
279
  ]);
259
280
  containsAll(read("assets/agents/gentle-ai-worker.md"), [
@@ -322,19 +343,23 @@ test("ODD defaults to applicable test-first without chat or TUI activation", ()
322
343
  // rendered parent prompt (harness + core) now carries that policy exactly
323
344
  // once, from the harness, instead of the core carrying its own copy.
324
345
  const rendered = __testing.buildGentlePrompt("gentleman");
325
- for (const text of [rendered, delegation, worker, verify, support, skill, wrapper]) {
346
+ // P5b (C3): the delegation modules forward the policy instead of restating its cycle.
347
+ for (const text of [rendered, worker, verify, support, skill, wrapper]) {
326
348
  containsAll(text, ["applicable", "RED", "GREEN"]);
327
349
  assert.doesNotMatch(text, /(?:configured TDD mode|Strict TDD Mode is enabled|explicit user choice|test presence does not enable it|tests existing does not activate it)/i);
328
350
  }
329
351
  assert.equal(rendered.split("use test-first by default").length - 1, 1, "the parent prompt states the test-first policy once");
330
352
  assert.ok(!core.includes("GREEN"), "core restates the harness test-first policy");
331
- for (const [actor, text] of [["delegation", delegation], ["extension", wrapper], ["skill", skill]] as const) {
353
+ // P5b (C3): the lazy modules no longer restate the policy; they forward it (below).
354
+ for (const [actor, text] of [["extension", wrapper], ["skill", skill]] as const) {
332
355
  assert.match(text, /behavior changes with applicable runnable deterministic tests and a clear expected outcome/i, `${actor} must require applicability, not test presence`);
333
356
  assert.match(text, /passive documentation/i, `${actor} must handle passive docs`);
334
357
  assert.match(text, /unavailable runner/i, `${actor} must handle unavailable runners`);
335
358
  assert.match(text, /ordinary functional or structural verification/i, `${actor} must specify fallback checks`);
336
359
  }
337
- containsAll(delegation, ["by default", "Forward this policy"]);
360
+ // P5b (C3): the "use test-first by default" policy lives once, in the rendered always-on principle
361
+ // (asserted above); tracking alone forwards it to writers.
362
+ containsAll(read("assets/orchestrator-tracking.md"), ["Test-first is the always-on harness principle", "forward this policy"]);
338
363
  containsAll(worker, ["before implementation", "ordinary functional or structural verification", "no meaningful RED"]);
339
364
  containsAll(verify, ["observed RED", "observed GREEN", "exception"]);
340
365
  assert.doesNotMatch(skill, /SDD|OpenSpec/i, "the ODD-only skill must not prime SDD");
@@ -491,15 +516,42 @@ test("ODD protocol is always-on in the rendered system prompt and runs by defaul
491
516
  assert.doesNotMatch(core + delegation + memory, /SDD|sdd-|OpenSpec|openspec/i);
492
517
  });
493
518
 
494
- // S14: commit per reviewable slice. Mirrors gentle-ai 06ad2776: a high-risk unit that follows pending medium commits
495
- // closes the open slice first, so native review takes the high-risk commit alone; outcomes are recorded per commit,
496
- // since one commit may hold several tasks.
497
- test("S14: RDD tracking closes the open slice before a high-risk commit and records outcomes per commit", () => {
519
+ // S14: commit per reviewable slice; outcomes are recorded per commit, since one commit may hold several tasks.
520
+ // Mirrors gentle-ai#6110: a high-risk unit following pending `under_budget`
521
+ // commits assesses that slice first without forcing review. The rendered prompt carries
522
+ // only steps 1-7 of routing/pi.md and the injected orchestration contract has no slice rule, so tracking states it;
523
+ // P5b removed only the sentences that restated the injected contract (start, consent, Medium deferral).
524
+ test("S14: RDD tracking assesses the open slice before a high-risk commit and records outcomes per commit", () => {
498
525
  const tracking = readFileSync(join(import.meta.dirname, "..", "assets", "orchestrator-tracking.md"), "utf8");
499
526
  assert.ok(
500
- tracking.includes("When a high-risk unit follows pending medium commits still under the slice budget, close the open slice first, assessing and reviewing it as the slice, so the high-risk commit is then reviewed alone against the new boundary."),
501
- "tracking must close the open slice before a high-risk commit",
527
+ tracking.includes("Before a high-risk unit, assess any pending `under_budget` slice."),
528
+ "tracking must assess the open slice before a high-risk commit",
529
+ );
530
+ assert.ok(
531
+ wrapper.includes("a unit whose Risk line names a high-risk item gets its own commit so native review can take it alone"),
532
+ "step 6 must keep a high-risk unit in its own commit",
502
533
  );
503
- assert.ok(tracking.includes("Record per commit the assessed tier and outcome"), "tracking must record outcomes per commit");
534
+ assert.ok(tracking.includes("Record each commit's assessed tier, outcome"), "tracking must record outcomes per commit");
504
535
  assert.ok(!tracking.includes("Record per task the assessed tier and outcome"), "tracking must not record outcomes per task");
505
536
  });
537
+
538
+ test("pending slice review follows provider due or explicit request without inventing a boundary", () => {
539
+ const tracking = read("assets/orchestrator-tracking.md");
540
+ containsAll(tracking, [
541
+ "Before a high-risk unit, assess any pending `under_budget` slice.",
542
+ "Review the pending slice only when `reviewDue` is true or the user explicitly asks",
543
+ "otherwise preserve the pending boundary and proceed without review",
544
+ "A task boundary neither authorizes review nor advances a reviewed boundary.",
545
+ ]);
546
+ assert.doesNotMatch(tracking, /close the open slice first, assessing and reviewing it as the slice/);
547
+ });
548
+
549
+ test("failed assessment reports missing proof without inventing due or preflight", () => {
550
+ const tracking = read("assets/orchestrator-tracking.md");
551
+ containsAll(tracking, [
552
+ "report missing assessment proof",
553
+ "never infer `reviewDue`, construct a preflight transition",
554
+ "lower the tier or infer low risk",
555
+ ]);
556
+ assert.doesNotMatch(tracking, /treat the commit as due/);
557
+ });
@@ -39,7 +39,11 @@ const FIXTURE_PATH = join(import.meta.dirname, "fixtures", "orchestrator.pre-die
39
39
  // Issue #2935 (user decision 2026-11-06): 9,250 -> 9,350 B so the confinement clause keeps its full wording
40
40
  // (registered same-clone worktrees, never-blanket grants) while adding the resolved-skill-read exception; the
41
41
  // controlled 128-char assets root needs the headroom for platform-independent rendering.
42
- const BUDGET_BYTES = 9350;
42
+ // cost-speed-painpoints S5 (T4): the duplicate `## Identity Contract` pointer left the core (the Language Boundary
43
+ // intro carries the same pointer); measured 9,347 -> 9,197 B at the 128-char root: 9,350 -> 9,197 B.
44
+ // cost-speed-painpoints S15 P5a: verdicts C7, C9, C12, X1, X3 and C8 (L41); measured 9,197 -> 9,189 B at the 128-char root.
45
+ // cost-speed P14 (PD-81): the Evidence-budget lookup number matches the runtime notice; measured 9,189 -> 9,177 B.
46
+ const BUDGET_BYTES = 9177;
43
47
  const MIN_CONTROLLED_LONG_ASSETS_ROOT_CHARS = 93;
44
48
 
45
49
  const LAZY_ASSET_NAMES = [
@@ -132,7 +136,7 @@ function measureOrchestratorPromptBytes(assetsDir: string): number {
132
136
  // measuring a shorter render again.
133
137
  const RDD_WORST_CASE_LINE = "Receipt-driven development: unknown (native status unavailable)";
134
138
 
135
- test("getOrchestratorPrompt return value stays within the canonical 9,350 B budget at a short assets root", () => {
139
+ test("getOrchestratorPrompt return value stays within the canonical 9,197 B budget at a short assets root", () => {
136
140
  const rendered = __testing.renderOrchestratorPrompt(representativeProductionAssetsDir);
137
141
  assert.ok(
138
142
  rendered.includes(RDD_WORST_CASE_LINE),
@@ -203,7 +207,7 @@ const TARGET_FILE: Record<Target, string> = {
203
207
  // (frozen byte-identical copy of assets/orchestrator.md at 23,047 B / 312 lines).
204
208
  const DISPOSITION_MAP: DispositionRange[] = [
205
209
  { lines: [1, 4], target: "replaced", label: "Header + bind: retired phase qualification" },
206
- { lines: [5, 8], target: "core", label: "Identity Contract" },
210
+ { lines: [5, 8], target: "replaced", label: "Identity Contract pointer: dropped as a duplicate of the Language Boundary intro pointer (cost-speed-painpoints S5)" },
207
211
  { lines: [9, 13], target: "core", label: "Core Role" },
208
212
  { lines: [15, 15], target: "core", label: "Language Boundary heading" },
209
213
  { lines: [17, 17], target: "core", label: "Language Boundary LB1 pointer" },
@@ -277,7 +281,9 @@ const DISPOSITION_MAP: DispositionRange[] = [
277
281
  { lines: [232, 232], target: "core", label: "Skill Registry Protocol heading" },
278
282
  { lines: [234, 253], target: "replaced", label: "Skill resolution retained without phase roles" },
279
283
  { lines: [255, 255], target: "core", label: "Intent-Driven Skill Discovery heading" },
280
- { lines: [257, 276], target: "skills", label: "Intent-Driven Skill Discovery detail" },
284
+ { lines: [257, 260], target: "skills", label: "Intent-Driven Skill Discovery introduction" },
285
+ { lines: [261, 264], target: "replaced", label: "Disk-first discovery replaced by the S7 effective session view" },
286
+ { lines: [265, 276], target: "skills", label: "Intent-Driven Skill Discovery fallback and intent hints" },
281
287
  { lines: [278, 283], target: "core", label: "Safety" },
282
288
  { lines: [285, 312], target: "obsolete", label: "Superseded pre-transaction review contract" },
283
289
  ];
@@ -336,6 +342,8 @@ for (const range of DISPOSITION_MAP) {
336
342
  const trimmed = raw.trim();
337
343
  const expected =
338
344
  // Preserve the synthesis rule while reserving core bytes for the RDD scope condition.
345
+ // cost-speed-painpoints S15 P5a (verdict C7): organic is inline by default; delegation only by a Mechanism trigger.
346
+ ln === 11 ? "You are a COORDINATOR who executes understood work inline. Maintain one thin conversation thread, delegate only when a Mechanism trigger fires, and synthesize results for the user." :
339
347
  ln === 13 ? "Default to concise synthesis: decision, outcome, next action. Expand on request or when detail is needed." :
340
348
  ln === 36 ? "- Substantial authorized work: use ODD; track feature progress automatically." :
341
349
  trimmed;
@@ -362,6 +370,22 @@ for (const range of DISPOSITION_MAP) {
362
370
  );
363
371
  }
364
372
 
373
+ test("lazy skill discovery selects and delegates from the effective view with a disclosed disk-only fallback", () => {
374
+ const skills = readRealAsset("orchestrator-skills.md");
375
+ for (const required of [
376
+ "Match task context and target files against the effective view's `Trigger / description` column.",
377
+ "Pass only matching exact `Path` values to subagents under `## Skills to load before work`.",
378
+ "Tell subagents to read those exact `SKILL.md` files before reading, writing, reviewing, testing, or creating artifacts.",
379
+ "The effective view is `<available_skills>` plus the on-disk rows of the `Effective session skills` system-prompt block",
380
+ "Consult `<available_skills>` and the `Effective session skills` block, when present, before acting or delegating.",
381
+ "Read the matching exact `SKILL.md` path when acting; pass it to the subagent when delegating.",
382
+ "If the view is unavailable, disclose the limitation; `.atl/skill-registry.md` is a disk-only fallback, not a complete Pi view.",
383
+ "If an expected workflow is absent, search configured skill roots only as a fallback. Prefer the most specific project skill over a global skill with the same intent.",
384
+ "If no matching skill exists, continue with the smallest safe fallback and say which expected skill was unavailable.",
385
+ ]) assert.ok(skills.includes(required), `missing skill-discovery rule: ${required}`);
386
+ assert.doesNotMatch(skills, /1\. Read `\.atl\/skill-registry\.md` when present\./);
387
+ });
388
+
365
389
  // ---------------------------------------------------------------------------
366
390
  // 2.4 — Core-alone load-bearing tokens (JD-007) — assert on the raw core
367
391
  // string alone, no lazy union.
@@ -394,7 +418,8 @@ test("lazy coordination detail retains subject guidance without inflating the co
394
418
 
395
419
  test("core-alone: dynamic Gentle AI ownership replaces package lifecycle instructions", () => {
396
420
  const core = readRealAsset("orchestrator.md");
397
- assert.match(core, /injects the mirrored provider-bundle review execution contract into this session's system prompt at start/);
421
+ // cost-speed-painpoints S15 P5a (verdict X1): the contract is injected only while RDD is not off.
422
+ assert.match(core, /While RDD is not off, this package injects the mirrored provider-bundle review execution contract;/);
398
423
  assert.match(core, /Absent that mirrored contract, this package invents no lifecycle instructions/);
399
424
  assert.doesNotMatch(core, /start -> finalize -> validate/i);
400
425
  assert.doesNotMatch(core, /receipt validation/i);