wtf-p 0.8.1 → 0.8.3

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 (464) hide show
  1. package/README.md +33 -18
  2. package/bin/lib/adapter-compiler.js +274 -56
  3. package/package.json +1 -1
  4. package/protocol/actions/advance.json +232 -0
  5. package/protocol/actions/plan-revision.json +8 -3
  6. package/protocol/actions/verify-work.json +6 -2
  7. package/protocol/aliases.lock.json +1 -0
  8. package/protocol/catalog.json +4 -2
  9. package/protocol/project/README.md +2 -0
  10. package/protocol/roles/research-synthesizer.md +1 -1
  11. package/protocol/skills/wtfp-manage-project/SKILL.md +2 -1
  12. package/protocol/skills/wtfp-manage-project/references/actions.md +13 -1
  13. package/protocol/skills/wtfp-plan-section/references/actions.md +1 -1
  14. package/protocol/skills/wtfp-research-literature/references/actions.md +1 -1
  15. package/protocol/skills/wtfp-review-manuscript/references/actions.md +2 -1
  16. package/protocol/workflows/advance.md +38 -0
  17. package/protocol/workflows/discuss-section.md +1 -1
  18. package/protocol/workflows/plan-revision.md +3 -3
  19. package/protocol/workflows/plan-section.md +1 -1
  20. package/protocol/workflows/research-gap.md +3 -3
  21. package/protocol/workflows/review-section.md +2 -2
  22. package/protocol/workflows/verify-work.md +4 -2
  23. package/protocol/workflows/write-section.md +2 -2
  24. package/vendors/antigravity/.wtfp-generated.json +55 -43
  25. package/vendors/antigravity/actions/advance.json +232 -0
  26. package/vendors/antigravity/actions/plan-revision.json +8 -3
  27. package/vendors/antigravity/actions/verify-work.json +6 -2
  28. package/vendors/antigravity/agents/wtfp-research-synthesizer.md +1 -1
  29. package/vendors/antigravity/aliases.lock.json +1 -0
  30. package/vendors/antigravity/catalog.json +4 -2
  31. package/vendors/antigravity/compatibility/action-availability.json +13 -1
  32. package/vendors/antigravity/plugin.json +2 -2
  33. package/vendors/antigravity/project/README.md +2 -0
  34. package/vendors/antigravity/roles/research-synthesizer.md +1 -1
  35. package/vendors/antigravity/rules/wtfp-project-state.md +2 -0
  36. package/vendors/antigravity/skills/wtfp-add-todo/SKILL.md +0 -2
  37. package/vendors/antigravity/skills/wtfp-advance/SKILL.md +18 -0
  38. package/vendors/antigravity/skills/wtfp-checkpoint/SKILL.md +0 -14
  39. package/vendors/antigravity/skills/wtfp-create-outline/SKILL.md +0 -8
  40. package/vendors/antigravity/skills/wtfp-create-poster/SKILL.md +1 -6
  41. package/vendors/antigravity/skills/wtfp-create-slides/SKILL.md +1 -6
  42. package/vendors/antigravity/skills/wtfp-discuss-section/SKILL.md +1 -5
  43. package/vendors/antigravity/skills/wtfp-execute-outline/SKILL.md +0 -10
  44. package/vendors/antigravity/skills/wtfp-help/SKILL.md +1 -1
  45. package/vendors/antigravity/skills/wtfp-list-assumptions/SKILL.md +1 -10
  46. package/vendors/antigravity/skills/wtfp-manage-project/SKILL.md +2 -1
  47. package/vendors/antigravity/skills/wtfp-manage-project/references/actions.md +29 -1
  48. package/vendors/antigravity/skills/wtfp-pause-writing/SKILL.md +0 -6
  49. package/vendors/antigravity/skills/wtfp-plan-milestone-gaps/SKILL.md +0 -6
  50. package/vendors/antigravity/skills/wtfp-plan-revision/SKILL.md +5 -11
  51. package/vendors/antigravity/skills/wtfp-plan-section/references/actions.md +1 -1
  52. package/vendors/antigravity/skills/wtfp-polish-prose/SKILL.md +0 -6
  53. package/vendors/antigravity/skills/wtfp-progress/SKILL.md +1 -22
  54. package/vendors/antigravity/skills/wtfp-quick/SKILL.md +0 -4
  55. package/vendors/antigravity/skills/wtfp-research-literature/references/actions.md +1 -1
  56. package/vendors/antigravity/skills/wtfp-resume-writing/SKILL.md +0 -12
  57. package/vendors/antigravity/skills/wtfp-review-manuscript/references/actions.md +2 -1
  58. package/vendors/antigravity/skills/wtfp-review-section/SKILL.md +2 -10
  59. package/vendors/antigravity/skills/wtfp-submit-milestone/SKILL.md +0 -12
  60. package/vendors/antigravity/skills/wtfp-verify-work/SKILL.md +6 -4
  61. package/vendors/antigravity/tools/README.md +1 -1
  62. package/vendors/antigravity/workflows/advance.md +38 -0
  63. package/vendors/antigravity/workflows/discuss-section.md +1 -1
  64. package/vendors/antigravity/workflows/plan-revision.md +3 -3
  65. package/vendors/antigravity/workflows/plan-section.md +1 -1
  66. package/vendors/antigravity/workflows/research-gap.md +3 -3
  67. package/vendors/antigravity/workflows/review-section.md +2 -2
  68. package/vendors/antigravity/workflows/verify-work.md +4 -2
  69. package/vendors/antigravity/workflows/write-section.md +2 -2
  70. package/vendors/claude/.claude-plugin/marketplace.json +2 -2
  71. package/vendors/claude/.claude-plugin/plugin.json +1 -1
  72. package/vendors/claude/.wtfp-generated.json +109 -93
  73. package/vendors/claude/actions/advance.json +232 -0
  74. package/vendors/claude/actions/plan-revision.json +8 -3
  75. package/vendors/claude/actions/verify-work.json +6 -2
  76. package/vendors/claude/agents/wtfp-research-synthesizer.md +1 -1
  77. package/vendors/claude/ai.iowarp.clio/agents/wtfp-argument-verifier.md +4 -5
  78. package/vendors/claude/ai.iowarp.clio/agents/wtfp-citation-expert.md +5 -5
  79. package/vendors/claude/ai.iowarp.clio/agents/wtfp-citation-formatter.md +3 -3
  80. package/vendors/claude/ai.iowarp.clio/agents/wtfp-coherence-checker.md +6 -7
  81. package/vendors/claude/ai.iowarp.clio/agents/wtfp-outliner.md +3 -3
  82. package/vendors/claude/ai.iowarp.clio/agents/wtfp-plan-checker.md +4 -5
  83. package/vendors/claude/ai.iowarp.clio/agents/wtfp-prose-polisher.md +4 -4
  84. package/vendors/claude/ai.iowarp.clio/agents/wtfp-research-synthesizer.md +6 -6
  85. package/vendors/claude/ai.iowarp.clio/agents/wtfp-section-planner.md +3 -3
  86. package/vendors/claude/ai.iowarp.clio/agents/wtfp-section-reviewer.md +6 -7
  87. package/vendors/claude/ai.iowarp.clio/agents/wtfp-section-writer.md +5 -3
  88. package/vendors/claude/ai.iowarp.clio/prompts/wtfp/add-todo.md +0 -2
  89. package/vendors/claude/ai.iowarp.clio/prompts/wtfp/advance.md +15 -0
  90. package/vendors/claude/ai.iowarp.clio/prompts/wtfp/analyze-bib.md +4 -8
  91. package/vendors/claude/ai.iowarp.clio/prompts/wtfp/audit-milestone.md +2 -16
  92. package/vendors/claude/ai.iowarp.clio/prompts/wtfp/check-refs.md +4 -8
  93. package/vendors/claude/ai.iowarp.clio/prompts/wtfp/check-todos.md +2 -0
  94. package/vendors/claude/ai.iowarp.clio/prompts/wtfp/checkpoint.md +2 -14
  95. package/vendors/claude/ai.iowarp.clio/prompts/wtfp/create-outline.md +4 -10
  96. package/vendors/claude/ai.iowarp.clio/prompts/wtfp/create-poster.md +3 -6
  97. package/vendors/claude/ai.iowarp.clio/prompts/wtfp/create-slides.md +3 -6
  98. package/vendors/claude/ai.iowarp.clio/prompts/wtfp/discuss-section.md +3 -5
  99. package/vendors/claude/ai.iowarp.clio/prompts/wtfp/execute-outline.md +4 -12
  100. package/vendors/claude/ai.iowarp.clio/prompts/wtfp/export-latex.md +2 -8
  101. package/vendors/claude/ai.iowarp.clio/prompts/wtfp/help.md +4 -1
  102. package/vendors/claude/ai.iowarp.clio/prompts/wtfp/insert-section.md +2 -0
  103. package/vendors/claude/ai.iowarp.clio/prompts/wtfp/list-assumptions.md +1 -10
  104. package/vendors/claude/ai.iowarp.clio/prompts/wtfp/new-paper.md +2 -0
  105. package/vendors/claude/ai.iowarp.clio/prompts/wtfp/pause-writing.md +0 -6
  106. package/vendors/claude/ai.iowarp.clio/prompts/wtfp/plan-milestone-gaps.md +2 -6
  107. package/vendors/claude/ai.iowarp.clio/prompts/wtfp/plan-revision.md +7 -11
  108. package/vendors/claude/ai.iowarp.clio/prompts/wtfp/plan-section.md +5 -15
  109. package/vendors/claude/ai.iowarp.clio/prompts/wtfp/polish-prose.md +4 -8
  110. package/vendors/claude/ai.iowarp.clio/prompts/wtfp/progress.md +3 -22
  111. package/vendors/claude/ai.iowarp.clio/prompts/wtfp/quick.md +4 -6
  112. package/vendors/claude/ai.iowarp.clio/prompts/wtfp/research-gap.md +12 -14
  113. package/vendors/claude/ai.iowarp.clio/prompts/wtfp/resume-writing.md +2 -12
  114. package/vendors/claude/ai.iowarp.clio/prompts/wtfp/review-section.md +6 -12
  115. package/vendors/claude/ai.iowarp.clio/prompts/wtfp/settings.md +2 -0
  116. package/vendors/claude/ai.iowarp.clio/prompts/wtfp/submit-milestone.md +2 -12
  117. package/vendors/claude/ai.iowarp.clio/prompts/wtfp/verify-work.md +8 -4
  118. package/vendors/claude/ai.iowarp.clio/prompts/wtfp/write-section.md +6 -14
  119. package/vendors/claude/aliases.lock.json +1 -0
  120. package/vendors/claude/catalog.json +4 -2
  121. package/vendors/claude/commands/add-todo.md +0 -2
  122. package/vendors/claude/commands/advance.md +16 -0
  123. package/vendors/claude/commands/analyze-bib.md +0 -6
  124. package/vendors/claude/commands/audit-milestone.md +0 -16
  125. package/vendors/claude/commands/check-refs.md +0 -6
  126. package/vendors/claude/commands/checkpoint.md +0 -14
  127. package/vendors/claude/commands/create-outline.md +0 -8
  128. package/vendors/claude/commands/create-poster.md +1 -6
  129. package/vendors/claude/commands/create-slides.md +1 -6
  130. package/vendors/claude/commands/discuss-section.md +1 -5
  131. package/vendors/claude/commands/execute-outline.md +0 -10
  132. package/vendors/claude/commands/export-latex.md +0 -8
  133. package/vendors/claude/commands/help.md +1 -1
  134. package/vendors/claude/commands/list-assumptions.md +1 -10
  135. package/vendors/claude/commands/pause-writing.md +0 -6
  136. package/vendors/claude/commands/plan-milestone-gaps.md +0 -6
  137. package/vendors/claude/commands/plan-revision.md +5 -11
  138. package/vendors/claude/commands/plan-section.md +1 -13
  139. package/vendors/claude/commands/polish-prose.md +0 -6
  140. package/vendors/claude/commands/progress.md +1 -22
  141. package/vendors/claude/commands/quick.md +0 -4
  142. package/vendors/claude/commands/research-gap.md +3 -11
  143. package/vendors/claude/commands/resume-writing.md +0 -12
  144. package/vendors/claude/commands/review-section.md +2 -10
  145. package/vendors/claude/commands/submit-milestone.md +0 -12
  146. package/vendors/claude/commands/verify-work.md +6 -4
  147. package/vendors/claude/commands/write-section.md +2 -12
  148. package/vendors/claude/compatibility/action-availability.json +10 -1
  149. package/vendors/claude/output-styles/wtfp-academic-writing.md +2 -2
  150. package/vendors/claude/plugin.json +15 -1
  151. package/vendors/claude/project/README.md +2 -0
  152. package/vendors/claude/roles/research-synthesizer.md +1 -1
  153. package/vendors/claude/skills/wtfp-manage-project/SKILL.md +2 -1
  154. package/vendors/claude/skills/wtfp-manage-project/references/actions.md +29 -1
  155. package/vendors/claude/skills/wtfp-plan-section/references/actions.md +1 -1
  156. package/vendors/claude/skills/wtfp-research-literature/references/actions.md +1 -1
  157. package/vendors/claude/skills/wtfp-review-manuscript/references/actions.md +2 -1
  158. package/vendors/claude/tools/README.md +1 -1
  159. package/vendors/claude/workflows/advance.md +38 -0
  160. package/vendors/claude/workflows/discuss-section.md +1 -1
  161. package/vendors/claude/workflows/plan-revision.md +3 -3
  162. package/vendors/claude/workflows/plan-section.md +1 -1
  163. package/vendors/claude/workflows/research-gap.md +3 -3
  164. package/vendors/claude/workflows/review-section.md +2 -2
  165. package/vendors/claude/workflows/verify-work.md +4 -2
  166. package/vendors/claude/workflows/write-section.md +2 -2
  167. package/vendors/clio-extension/.wtfp-generated.json +56 -8
  168. package/vendors/clio-extension/actions/advance.json +232 -0
  169. package/vendors/clio-extension/actions/plan-revision.json +8 -3
  170. package/vendors/clio-extension/actions/verify-work.json +6 -2
  171. package/vendors/clio-extension/clio-coder-extension.yaml +19 -4
  172. package/vendors/clio-extension/compatibility/action-availability.json +9 -3
  173. package/vendors/clio-extension/project/templates/checkpoint.json +25 -0
  174. package/vendors/clio-extension/project/templates/config.json +31 -0
  175. package/vendors/clio-extension/project/templates/decisions.json +35 -0
  176. package/vendors/clio-extension/project/templates/evidence.json +18 -0
  177. package/vendors/clio-extension/project/templates/interaction.json +16 -0
  178. package/vendors/clio-extension/project/templates/manifest.json +30 -0
  179. package/vendors/clio-extension/project/templates/outline.json +38 -0
  180. package/vendors/clio-extension/project/templates/section.json +32 -0
  181. package/vendors/clio-extension/project/templates/source.json +20 -0
  182. package/vendors/clio-extension/project/templates/state.json +22 -0
  183. package/vendors/clio-extension/project/templates/validation.json +32 -0
  184. package/vendors/clio-extension/runtime/extension.test.ts +724 -6
  185. package/vendors/clio-extension/runtime/extension.ts +1028 -42
  186. package/vendors/clio-extension/runtime/write-guard.json +66 -0
  187. package/vendors/codex/plugins/wtfp/.codex-plugin/plugin.json +1 -1
  188. package/vendors/codex/plugins/wtfp/.wtfp-generated.json +32 -24
  189. package/vendors/codex/plugins/wtfp/actions/advance.json +232 -0
  190. package/vendors/codex/plugins/wtfp/actions/plan-revision.json +8 -3
  191. package/vendors/codex/plugins/wtfp/actions/verify-work.json +6 -2
  192. package/vendors/codex/plugins/wtfp/agents/wtfp-research-synthesizer.toml +1 -1
  193. package/vendors/codex/plugins/wtfp/aliases.lock.json +1 -0
  194. package/vendors/codex/plugins/wtfp/catalog.json +4 -2
  195. package/vendors/codex/plugins/wtfp/compatibility/action-availability.json +13 -1
  196. package/vendors/codex/plugins/wtfp/plugin.json +1 -1
  197. package/vendors/codex/plugins/wtfp/project/README.md +2 -0
  198. package/vendors/codex/plugins/wtfp/roles/research-synthesizer.md +1 -1
  199. package/vendors/codex/plugins/wtfp/skills/wtfp-manage-project/SKILL.md +2 -1
  200. package/vendors/codex/plugins/wtfp/skills/wtfp-manage-project/references/actions.md +29 -1
  201. package/vendors/codex/plugins/wtfp/skills/wtfp-plan-section/references/actions.md +1 -1
  202. package/vendors/codex/plugins/wtfp/skills/wtfp-research-literature/references/actions.md +1 -1
  203. package/vendors/codex/plugins/wtfp/skills/wtfp-review-manuscript/references/actions.md +2 -1
  204. package/vendors/codex/plugins/wtfp/tools/README.md +1 -1
  205. package/vendors/codex/plugins/wtfp/workflows/advance.md +38 -0
  206. package/vendors/codex/plugins/wtfp/workflows/discuss-section.md +1 -1
  207. package/vendors/codex/plugins/wtfp/workflows/plan-revision.md +3 -3
  208. package/vendors/codex/plugins/wtfp/workflows/plan-section.md +1 -1
  209. package/vendors/codex/plugins/wtfp/workflows/research-gap.md +3 -3
  210. package/vendors/codex/plugins/wtfp/workflows/review-section.md +2 -2
  211. package/vendors/codex/plugins/wtfp/workflows/verify-work.md +4 -2
  212. package/vendors/codex/plugins/wtfp/workflows/write-section.md +2 -2
  213. package/vendors/copilot/.wtfp-generated.json +44 -32
  214. package/vendors/copilot/marketplace.json +2 -2
  215. package/vendors/copilot/plugins/wtfp/.claude-plugin/plugin.json +1 -1
  216. package/vendors/copilot/plugins/wtfp/.wtfp-generated.json +56 -44
  217. package/vendors/copilot/plugins/wtfp/actions/advance.json +232 -0
  218. package/vendors/copilot/plugins/wtfp/actions/plan-revision.json +8 -3
  219. package/vendors/copilot/plugins/wtfp/actions/verify-work.json +6 -2
  220. package/vendors/copilot/plugins/wtfp/agents/wtfp-research-synthesizer.md +1 -1
  221. package/vendors/copilot/plugins/wtfp/aliases.lock.json +1 -0
  222. package/vendors/copilot/plugins/wtfp/catalog.json +4 -2
  223. package/vendors/copilot/plugins/wtfp/commands/wtfp-add-todo.md +0 -2
  224. package/vendors/copilot/plugins/wtfp/commands/wtfp-advance.md +17 -0
  225. package/vendors/copilot/plugins/wtfp/commands/wtfp-checkpoint.md +0 -14
  226. package/vendors/copilot/plugins/wtfp/commands/wtfp-create-outline.md +0 -8
  227. package/vendors/copilot/plugins/wtfp/commands/wtfp-create-poster.md +1 -6
  228. package/vendors/copilot/plugins/wtfp/commands/wtfp-create-slides.md +1 -6
  229. package/vendors/copilot/plugins/wtfp/commands/wtfp-discuss-section.md +1 -5
  230. package/vendors/copilot/plugins/wtfp/commands/wtfp-execute-outline.md +0 -10
  231. package/vendors/copilot/plugins/wtfp/commands/wtfp-help.md +1 -1
  232. package/vendors/copilot/plugins/wtfp/commands/wtfp-list-assumptions.md +1 -10
  233. package/vendors/copilot/plugins/wtfp/commands/wtfp-pause-writing.md +0 -6
  234. package/vendors/copilot/plugins/wtfp/commands/wtfp-plan-milestone-gaps.md +0 -6
  235. package/vendors/copilot/plugins/wtfp/commands/wtfp-plan-revision.md +5 -11
  236. package/vendors/copilot/plugins/wtfp/commands/wtfp-plan-section.md +1 -13
  237. package/vendors/copilot/plugins/wtfp/commands/wtfp-polish-prose.md +0 -6
  238. package/vendors/copilot/plugins/wtfp/commands/wtfp-progress.md +1 -22
  239. package/vendors/copilot/plugins/wtfp/commands/wtfp-quick.md +0 -4
  240. package/vendors/copilot/plugins/wtfp/commands/wtfp-resume-writing.md +0 -12
  241. package/vendors/copilot/plugins/wtfp/commands/wtfp-review-section.md +2 -10
  242. package/vendors/copilot/plugins/wtfp/commands/wtfp-submit-milestone.md +0 -12
  243. package/vendors/copilot/plugins/wtfp/commands/wtfp-verify-work.md +6 -4
  244. package/vendors/copilot/plugins/wtfp/commands/wtfp-write-section.md +2 -12
  245. package/vendors/copilot/plugins/wtfp/compatibility/action-availability.json +13 -1
  246. package/vendors/copilot/plugins/wtfp/project/README.md +2 -0
  247. package/vendors/copilot/plugins/wtfp/roles/research-synthesizer.md +1 -1
  248. package/vendors/copilot/plugins/wtfp/skills/wtfp-manage-project/SKILL.md +2 -1
  249. package/vendors/copilot/plugins/wtfp/skills/wtfp-manage-project/references/actions.md +29 -1
  250. package/vendors/copilot/plugins/wtfp/skills/wtfp-plan-section/references/actions.md +1 -1
  251. package/vendors/copilot/plugins/wtfp/skills/wtfp-research-literature/references/actions.md +1 -1
  252. package/vendors/copilot/plugins/wtfp/skills/wtfp-review-manuscript/references/actions.md +2 -1
  253. package/vendors/copilot/plugins/wtfp/tools/README.md +1 -1
  254. package/vendors/copilot/plugins/wtfp/workflows/advance.md +38 -0
  255. package/vendors/copilot/plugins/wtfp/workflows/discuss-section.md +1 -1
  256. package/vendors/copilot/plugins/wtfp/workflows/plan-revision.md +3 -3
  257. package/vendors/copilot/plugins/wtfp/workflows/plan-section.md +1 -1
  258. package/vendors/copilot/plugins/wtfp/workflows/research-gap.md +3 -3
  259. package/vendors/copilot/plugins/wtfp/workflows/review-section.md +2 -2
  260. package/vendors/copilot/plugins/wtfp/workflows/verify-work.md +4 -2
  261. package/vendors/copilot/plugins/wtfp/workflows/write-section.md +2 -2
  262. package/vendors/copilot/project/.github/agents/wtfp-research-synthesizer.agent.md +1 -1
  263. package/vendors/copilot/project/.github/prompts/wtfp-add-todo.prompt.md +0 -2
  264. package/vendors/copilot/project/.github/prompts/wtfp-advance.prompt.md +18 -0
  265. package/vendors/copilot/project/.github/prompts/wtfp-help.prompt.md +1 -1
  266. package/vendors/copilot/project/.github/prompts/wtfp-list-assumptions.prompt.md +1 -10
  267. package/vendors/copilot/project/.github/prompts/wtfp-pause-writing.prompt.md +0 -6
  268. package/vendors/copilot/project/.github/skills/wtfp-manage-project/SKILL.md +2 -1
  269. package/vendors/copilot/project/.github/skills/wtfp-manage-project/references/actions.md +25 -1
  270. package/vendors/copilot/project/.github/skills/wtfp-plan-section/references/actions.md +1 -1
  271. package/vendors/copilot/project/.github/skills/wtfp-research-literature/references/actions.md +1 -1
  272. package/vendors/copilot/project/.github/skills/wtfp-review-manuscript/references/actions.md +2 -1
  273. package/vendors/copilot/project/.github/wtfp/actions/advance.json +232 -0
  274. package/vendors/copilot/project/.github/wtfp/actions/plan-revision.json +8 -3
  275. package/vendors/copilot/project/.github/wtfp/actions/verify-work.json +6 -2
  276. package/vendors/copilot/project/.github/wtfp/aliases.lock.json +1 -0
  277. package/vendors/copilot/project/.github/wtfp/catalog.json +4 -2
  278. package/vendors/copilot/project/.github/wtfp/compatibility/action-availability.json +14 -1
  279. package/vendors/copilot/project/.github/wtfp/project/README.md +2 -0
  280. package/vendors/copilot/project/.github/wtfp/roles/research-synthesizer.md +1 -1
  281. package/vendors/copilot/project/.github/wtfp/skills/wtfp-manage-project/SKILL.md +2 -1
  282. package/vendors/copilot/project/.github/wtfp/skills/wtfp-manage-project/references/actions.md +13 -1
  283. package/vendors/copilot/project/.github/wtfp/skills/wtfp-plan-section/references/actions.md +1 -1
  284. package/vendors/copilot/project/.github/wtfp/skills/wtfp-research-literature/references/actions.md +1 -1
  285. package/vendors/copilot/project/.github/wtfp/skills/wtfp-review-manuscript/references/actions.md +2 -1
  286. package/vendors/copilot/project/.github/wtfp/workflows/advance.md +38 -0
  287. package/vendors/copilot/project/.github/wtfp/workflows/discuss-section.md +1 -1
  288. package/vendors/copilot/project/.github/wtfp/workflows/plan-revision.md +3 -3
  289. package/vendors/copilot/project/.github/wtfp/workflows/plan-section.md +1 -1
  290. package/vendors/copilot/project/.github/wtfp/workflows/research-gap.md +3 -3
  291. package/vendors/copilot/project/.github/wtfp/workflows/review-section.md +2 -2
  292. package/vendors/copilot/project/.github/wtfp/workflows/verify-work.md +4 -2
  293. package/vendors/copilot/project/.github/wtfp/workflows/write-section.md +2 -2
  294. package/vendors/copilot/project/README.md +1 -1
  295. package/vendors/gemini/.wtfp-generated.json +61 -49
  296. package/vendors/gemini/actions/advance.json +232 -0
  297. package/vendors/gemini/actions/plan-revision.json +8 -3
  298. package/vendors/gemini/actions/verify-work.json +6 -2
  299. package/vendors/gemini/agents/wtfp-research-synthesizer.md +1 -1
  300. package/vendors/gemini/aliases.lock.json +1 -0
  301. package/vendors/gemini/catalog.json +4 -2
  302. package/vendors/gemini/commands/wtfp/add-todo.toml +17 -144
  303. package/vendors/gemini/commands/wtfp/advance.toml +14 -0
  304. package/vendors/gemini/commands/wtfp/check-todos.toml +17 -2
  305. package/vendors/gemini/commands/wtfp/checkpoint.toml +17 -735
  306. package/vendors/gemini/commands/wtfp/create-outline.toml +2 -431
  307. package/vendors/gemini/commands/wtfp/create-poster.toml +3 -296
  308. package/vendors/gemini/commands/wtfp/create-slides.toml +3 -296
  309. package/vendors/gemini/commands/wtfp/discuss-section.toml +4 -259
  310. package/vendors/gemini/commands/wtfp/execute-outline.toml +2 -480
  311. package/vendors/gemini/commands/wtfp/help.toml +7 -3
  312. package/vendors/gemini/commands/wtfp/insert-section.toml +3 -1
  313. package/vendors/gemini/commands/wtfp/list-assumptions.toml +4 -510
  314. package/vendors/gemini/commands/wtfp/map-project.toml +2 -0
  315. package/vendors/gemini/commands/wtfp/new-paper.toml +2 -0
  316. package/vendors/gemini/commands/wtfp/pause-writing.toml +17 -309
  317. package/vendors/gemini/commands/wtfp/plan-milestone-gaps.toml +4 -369
  318. package/vendors/gemini/commands/wtfp/plan-revision.toml +76 -423
  319. package/vendors/gemini/commands/wtfp/plan-section.toml +4 -624
  320. package/vendors/gemini/commands/wtfp/polish-prose.toml +4 -329
  321. package/vendors/gemini/commands/wtfp/progress.toml +18 -1143
  322. package/vendors/gemini/commands/wtfp/quick.toml +2 -218
  323. package/vendors/gemini/commands/wtfp/resume-writing.toml +17 -698
  324. package/vendors/gemini/commands/wtfp/review-section.toml +6 -412
  325. package/vendors/gemini/commands/wtfp/settings.toml +17 -2
  326. package/vendors/gemini/commands/wtfp/submit-milestone.toml +2 -617
  327. package/vendors/gemini/commands/wtfp/verify-work.toml +123 -53
  328. package/vendors/gemini/commands/wtfp/write-section.toml +4 -482
  329. package/vendors/gemini/compatibility/action-availability.json +13 -1
  330. package/vendors/gemini/gemini-extension.json +1 -1
  331. package/vendors/gemini/project/README.md +2 -0
  332. package/vendors/gemini/roles/research-synthesizer.md +1 -1
  333. package/vendors/gemini/skills/wtfp-manage-project/SKILL.md +2 -1
  334. package/vendors/gemini/skills/wtfp-manage-project/references/actions.md +29 -1
  335. package/vendors/gemini/skills/wtfp-plan-section/references/actions.md +1 -1
  336. package/vendors/gemini/skills/wtfp-research-literature/references/actions.md +1 -1
  337. package/vendors/gemini/skills/wtfp-review-manuscript/references/actions.md +2 -1
  338. package/vendors/gemini/tools/README.md +1 -1
  339. package/vendors/gemini/workflows/advance.md +38 -0
  340. package/vendors/gemini/workflows/discuss-section.md +1 -1
  341. package/vendors/gemini/workflows/plan-revision.md +3 -3
  342. package/vendors/gemini/workflows/plan-section.md +1 -1
  343. package/vendors/gemini/workflows/research-gap.md +3 -3
  344. package/vendors/gemini/workflows/review-section.md +2 -2
  345. package/vendors/gemini/workflows/verify-work.md +4 -2
  346. package/vendors/gemini/workflows/write-section.md +2 -2
  347. package/vendors/opencode/.wtfp-generated.json +60 -48
  348. package/vendors/opencode/actions/advance.json +232 -0
  349. package/vendors/opencode/actions/plan-revision.json +8 -3
  350. package/vendors/opencode/actions/verify-work.json +6 -2
  351. package/vendors/opencode/agents/wtfp/research-synthesizer.md +1 -1
  352. package/vendors/opencode/aliases.lock.json +1 -0
  353. package/vendors/opencode/catalog.json +4 -2
  354. package/vendors/opencode/commands/wtfp/add-todo.md +17 -144
  355. package/vendors/opencode/commands/wtfp/advance.md +16 -0
  356. package/vendors/opencode/commands/wtfp/check-todos.md +17 -2
  357. package/vendors/opencode/commands/wtfp/checkpoint.md +17 -735
  358. package/vendors/opencode/commands/wtfp/create-outline.md +2 -431
  359. package/vendors/opencode/commands/wtfp/create-poster.md +3 -296
  360. package/vendors/opencode/commands/wtfp/create-slides.md +3 -296
  361. package/vendors/opencode/commands/wtfp/discuss-section.md +4 -259
  362. package/vendors/opencode/commands/wtfp/execute-outline.md +2 -480
  363. package/vendors/opencode/commands/wtfp/help.md +7 -3
  364. package/vendors/opencode/commands/wtfp/insert-section.md +3 -1
  365. package/vendors/opencode/commands/wtfp/list-assumptions.md +4 -510
  366. package/vendors/opencode/commands/wtfp/map-project.md +2 -0
  367. package/vendors/opencode/commands/wtfp/new-paper.md +2 -0
  368. package/vendors/opencode/commands/wtfp/pause-writing.md +17 -309
  369. package/vendors/opencode/commands/wtfp/plan-milestone-gaps.md +4 -369
  370. package/vendors/opencode/commands/wtfp/plan-revision.md +76 -423
  371. package/vendors/opencode/commands/wtfp/plan-section.md +4 -624
  372. package/vendors/opencode/commands/wtfp/polish-prose.md +4 -329
  373. package/vendors/opencode/commands/wtfp/progress.md +18 -1143
  374. package/vendors/opencode/commands/wtfp/quick.md +2 -218
  375. package/vendors/opencode/commands/wtfp/resume-writing.md +17 -698
  376. package/vendors/opencode/commands/wtfp/review-section.md +6 -412
  377. package/vendors/opencode/commands/wtfp/settings.md +17 -2
  378. package/vendors/opencode/commands/wtfp/submit-milestone.md +2 -617
  379. package/vendors/opencode/commands/wtfp/verify-work.md +123 -53
  380. package/vendors/opencode/commands/wtfp/write-section.md +4 -482
  381. package/vendors/opencode/compatibility/action-availability.json +13 -1
  382. package/vendors/opencode/project/README.md +2 -0
  383. package/vendors/opencode/roles/research-synthesizer.md +1 -1
  384. package/vendors/opencode/skills/wtfp-manage-project/SKILL.md +2 -1
  385. package/vendors/opencode/skills/wtfp-manage-project/references/actions.md +29 -1
  386. package/vendors/opencode/skills/wtfp-plan-section/references/actions.md +1 -1
  387. package/vendors/opencode/skills/wtfp-research-literature/references/actions.md +1 -1
  388. package/vendors/opencode/skills/wtfp-review-manuscript/references/actions.md +2 -1
  389. package/vendors/opencode/tools/README.md +1 -1
  390. package/vendors/opencode/workflows/advance.md +38 -0
  391. package/vendors/opencode/workflows/discuss-section.md +1 -1
  392. package/vendors/opencode/workflows/plan-revision.md +3 -3
  393. package/vendors/opencode/workflows/plan-section.md +1 -1
  394. package/vendors/opencode/workflows/research-gap.md +3 -3
  395. package/vendors/opencode/workflows/review-section.md +2 -2
  396. package/vendors/opencode/workflows/verify-work.md +4 -2
  397. package/vendors/opencode/workflows/write-section.md +2 -2
  398. package/vendors/plugin/.wtfp-generated.json +76 -64
  399. package/vendors/plugin/actions/advance.json +232 -0
  400. package/vendors/plugin/actions/plan-revision.json +8 -3
  401. package/vendors/plugin/actions/verify-work.json +6 -2
  402. package/vendors/plugin/ai.iowarp.clio/agents/wtfp-argument-verifier.md +4 -5
  403. package/vendors/plugin/ai.iowarp.clio/agents/wtfp-citation-expert.md +5 -5
  404. package/vendors/plugin/ai.iowarp.clio/agents/wtfp-citation-formatter.md +3 -3
  405. package/vendors/plugin/ai.iowarp.clio/agents/wtfp-coherence-checker.md +6 -7
  406. package/vendors/plugin/ai.iowarp.clio/agents/wtfp-outliner.md +3 -3
  407. package/vendors/plugin/ai.iowarp.clio/agents/wtfp-plan-checker.md +4 -5
  408. package/vendors/plugin/ai.iowarp.clio/agents/wtfp-prose-polisher.md +4 -4
  409. package/vendors/plugin/ai.iowarp.clio/agents/wtfp-research-synthesizer.md +6 -6
  410. package/vendors/plugin/ai.iowarp.clio/agents/wtfp-section-planner.md +3 -3
  411. package/vendors/plugin/ai.iowarp.clio/agents/wtfp-section-reviewer.md +6 -7
  412. package/vendors/plugin/ai.iowarp.clio/agents/wtfp-section-writer.md +5 -3
  413. package/vendors/plugin/ai.iowarp.clio/prompts/wtfp/add-todo.md +7 -3
  414. package/vendors/plugin/ai.iowarp.clio/prompts/wtfp/advance.md +101 -0
  415. package/vendors/plugin/ai.iowarp.clio/prompts/wtfp/analyze-bib.md +11 -19
  416. package/vendors/plugin/ai.iowarp.clio/prompts/wtfp/audit-milestone.md +10 -4
  417. package/vendors/plugin/ai.iowarp.clio/prompts/wtfp/check-refs.md +12 -6
  418. package/vendors/plugin/ai.iowarp.clio/prompts/wtfp/check-todos.md +10 -4
  419. package/vendors/plugin/ai.iowarp.clio/prompts/wtfp/checkpoint.md +10 -4
  420. package/vendors/plugin/ai.iowarp.clio/prompts/wtfp/create-outline.md +11 -19
  421. package/vendors/plugin/ai.iowarp.clio/prompts/wtfp/create-poster.md +18 -13
  422. package/vendors/plugin/ai.iowarp.clio/prompts/wtfp/create-slides.md +18 -13
  423. package/vendors/plugin/ai.iowarp.clio/prompts/wtfp/discuss-section.md +11 -5
  424. package/vendors/plugin/ai.iowarp.clio/prompts/wtfp/execute-outline.md +12 -6
  425. package/vendors/plugin/ai.iowarp.clio/prompts/wtfp/export-latex.md +10 -4
  426. package/vendors/plugin/ai.iowarp.clio/prompts/wtfp/help.md +4 -1
  427. package/vendors/plugin/ai.iowarp.clio/prompts/wtfp/insert-section.md +10 -4
  428. package/vendors/plugin/ai.iowarp.clio/prompts/wtfp/list-assumptions.md +15 -17
  429. package/vendors/plugin/ai.iowarp.clio/prompts/wtfp/map-project.md +7 -3
  430. package/vendors/plugin/ai.iowarp.clio/prompts/wtfp/new-paper.md +10 -4
  431. package/vendors/plugin/ai.iowarp.clio/prompts/wtfp/pause-writing.md +7 -3
  432. package/vendors/plugin/ai.iowarp.clio/prompts/wtfp/plan-milestone-gaps.md +10 -4
  433. package/vendors/plugin/ai.iowarp.clio/prompts/wtfp/plan-revision.md +13 -7
  434. package/vendors/plugin/ai.iowarp.clio/prompts/wtfp/plan-section.md +13 -7
  435. package/vendors/plugin/ai.iowarp.clio/prompts/wtfp/polish-prose.md +12 -6
  436. package/vendors/plugin/ai.iowarp.clio/prompts/wtfp/progress.md +19 -30
  437. package/vendors/plugin/ai.iowarp.clio/prompts/wtfp/quick.md +12 -6
  438. package/vendors/plugin/ai.iowarp.clio/prompts/wtfp/research-gap.md +20 -10
  439. package/vendors/plugin/ai.iowarp.clio/prompts/wtfp/resume-writing.md +10 -4
  440. package/vendors/plugin/ai.iowarp.clio/prompts/wtfp/review-section.md +14 -8
  441. package/vendors/plugin/ai.iowarp.clio/prompts/wtfp/settings.md +10 -4
  442. package/vendors/plugin/ai.iowarp.clio/prompts/wtfp/submit-milestone.md +12 -4
  443. package/vendors/plugin/ai.iowarp.clio/prompts/wtfp/verify-work.md +14 -6
  444. package/vendors/plugin/ai.iowarp.clio/prompts/wtfp/write-section.md +15 -9
  445. package/vendors/plugin/aliases.lock.json +1 -0
  446. package/vendors/plugin/catalog.json +4 -2
  447. package/vendors/plugin/compatibility/action-availability.json +9 -3
  448. package/vendors/plugin/plugin.json +15 -1
  449. package/vendors/plugin/project/README.md +2 -0
  450. package/vendors/plugin/roles/research-synthesizer.md +1 -1
  451. package/vendors/plugin/skills/wtfp-manage-project/SKILL.md +2 -1
  452. package/vendors/plugin/skills/wtfp-manage-project/references/actions.md +13 -1
  453. package/vendors/plugin/skills/wtfp-plan-section/references/actions.md +1 -1
  454. package/vendors/plugin/skills/wtfp-research-literature/references/actions.md +1 -1
  455. package/vendors/plugin/skills/wtfp-review-manuscript/references/actions.md +2 -1
  456. package/vendors/plugin/tools/README.md +1 -1
  457. package/vendors/plugin/workflows/advance.md +38 -0
  458. package/vendors/plugin/workflows/discuss-section.md +1 -1
  459. package/vendors/plugin/workflows/plan-revision.md +3 -3
  460. package/vendors/plugin/workflows/plan-section.md +1 -1
  461. package/vendors/plugin/workflows/research-gap.md +3 -3
  462. package/vendors/plugin/workflows/review-section.md +2 -2
  463. package/vendors/plugin/workflows/verify-work.md +4 -2
  464. package/vendors/plugin/workflows/write-section.md +2 -2
@@ -10,7 +10,7 @@
10
10
  import assert from "node:assert/strict";
11
11
  import { createHash, createHmac } from "node:crypto";
12
12
  import { spawnSync } from "node:child_process";
13
- import { existsSync, mkdirSync, mkdtempSync, readdirSync, readFileSync, readlinkSync, realpathSync, rmSync, statSync, symlinkSync, writeFileSync } from "node:fs";
13
+ import { existsSync, mkdirSync, mkdtempSync, readdirSync, readFileSync, readlinkSync, realpathSync, rmSync, statSync, symlinkSync, utimesSync, writeFileSync } from "node:fs";
14
14
  import os, { homedir } from "node:os";
15
15
  import path from "node:path";
16
16
  import { test } from "node:test";
@@ -162,6 +162,8 @@ function project(): string {
162
162
  "paper/introduction.md",
163
163
  "---\ntitle: Introduction\n---\n# Introduction\n\nShared memory changes the cost of logging [@smith2024]. It's a well-known trade-off.\n\n```c\nint flush = 1;\n```\n",
164
164
  );
165
+ // The desk test clock starts at the epoch; the existing draft is a day older than any approval a test gives.
166
+ utimesSync(path.join(workspace, "paper/introduction.md"), new Date(-86_400_000), new Date(-86_400_000));
165
167
  return workspace;
166
168
  }
167
169
 
@@ -388,7 +390,8 @@ function clioPlan(prepared: Json, workspace: string): Json {
388
390
 
389
391
  /** A before_tool event as Clio 0.6.3 sends it, unless the test sent its own facts. */
390
392
  function withFacts(event: Json, workspace: string): Json {
391
- if (event.point !== "before_tool" || "target" in event || "dispatch" in event) return event;
393
+ // Clio sends the same landing at after_tool as at before_tool.
394
+ if ((event.point !== "before_tool" && event.point !== "after_tool") || "target" in event || "dispatch" in event) return event;
392
395
  const args = (event.args ?? {}) as Json;
393
396
  if (event.tool === "dispatch") {
394
397
  const prepared = clioPrepare(args);
@@ -475,6 +478,9 @@ test("record refuses wrong type, id, project and unknown fields without touching
475
478
  [{ ...section, id: "methods" }, /whose id is introduction/],
476
479
  [{ ...section, project_id: "another-project" }, /belongs to project another-project/],
477
480
  [{ ...section, surprise: true }, /would not validate: .*unknown property surprise|surprise/],
481
+ // A model fixes what it is told; it is told the missing project_id and every schema error at once.
482
+ [(({ project_id: _omitted, ...rest }) => rest)(section), /needs project_id "desk-test"/],
483
+ [{ ...section, surprise: true, other: 1 }, /would not validate: .*surprise.*; .*other/],
478
484
  ];
479
485
  for (const [record, pattern] of cases) {
480
486
  const refused = await host.tool("record", { uri: "project://sections/introduction", record, expect_sha256 });
@@ -482,6 +488,36 @@ test("record refuses wrong type, id, project and unknown fields without touching
482
488
  assert.match(refused.text, pattern);
483
489
  }
484
490
  assert.equal(sha(workspace, ".planning/sections/introduction/section.json"), before);
491
+ // An authored artifact is not a record; the refusal names its file instead of leaving the model to search.
492
+ const artifact = await host.tool("read_record", { uri: "project://sections/introduction/context" });
493
+ assert.match(artifact.text, /authored artifact, not a JSON record; read or write \.planning\/sections\/introduction\/context\.md with the file tools/);
494
+ const plan = await host.tool("read_record", { uri: "project://sections/introduction/plans/initial" });
495
+ assert.match(plan.text, /\.planning\/sections\/introduction\/plans\/initial\.md/);
496
+ // A record that does not exist yet comes with its example, and so does a refused create (live: four calls, one field each).
497
+ const missing = await host.tool("read_record", { uri: "project://sections/methods" });
498
+ assert.match(missing.text, /does not exist yet[\s\S]*A section record looks like this example[\s\S]*"outline_uri"/);
499
+ const bare = await host.tool("record", { uri: "project://sections/methods", record: { schema: "wtfp.project.section/v1", id: "methods", project_id: PROJECT, title: "Methods" } });
500
+ assert.match(bare.text, /would not validate[\s\S]*A section record looks like this example[\s\S]*"word_target"/);
501
+ // A model has no clock: a validation created without executed_at gets the desk's time.
502
+ const unstamped = { schema: "wtfp.project.validation/v1", id: "introduction-stamped", project_id: PROJECT, subject_uri: "project://paper/introduction", validator_role: "section-reviewer", action_id: "review-section", status: "passed", checks: [{ id: "plan-criteria", status: "passed", summary: "Every plan criterion holds.", evidence: ["Stated."] }], issues: [], next_actions: [], effects_applied: [] };
503
+ const stamped = await host.tool("record", { uri: "project://validations/introduction-stamped", record: unstamped });
504
+ assert.equal(stamped.isError, undefined, stamped.text);
505
+ assert.match(String(read(workspace, ".planning/validations/introduction-stamped.json").executed_at), /^\d{4}-\d{2}-\d{2}T/);
506
+ // An invented time, live a few minutes in the future, is replaced too: it ordered a review after the answer it preceded.
507
+ await host.tool("record", { uri: "project://validations/introduction-invented", record: { ...unstamped, id: "introduction-invented", executed_at: "2099-01-01T00:00:00Z" } });
508
+ assert.ok(String(read(workspace, ".planning/validations/introduction-invented.json").executed_at) < "2099", "the desk's time replaces the model's");
509
+ assert.match((await host.tool("read_record", { uri: "project://checkpoints/never-made" })).text, /omit updated_at and created_at, which the desk sets/);
510
+ // Live, a long record closed early and left its last fields beside it; the desk names them.
511
+ const strayFields = await host.tool("record", { uri: "project://validations/stray", record: { schema: "wtfp.project.validation/v1", id: "stray", project_id: PROJECT, subject_uri: "project://paper/introduction", validator_role: "section-reviewer", action_id: "review-section", status: "passed", checks: [{ id: "c", status: "passed", summary: "Holds.", evidence: ["Stated."] }] }, issues: [], next_actions: [], effects_applied: [] });
512
+ assert.equal(strayFields.isError, undefined, strayFields.text);
513
+ assert.match(strayFields.text, /^issues, next_actions, effects_applied arrived beside record and were moved inside it/);
514
+ assert.deepEqual(read(workspace, ".planning/validations/stray.json").next_actions, []);
515
+ const notFields = await host.tool("record", { uri: "project://validations/stray-2", record: { schema: "wtfp.project.validation/v1" }, surprise: 1 });
516
+ assert.match(notFields.text, /surprise is not a record tool argument/);
517
+ const update = await host.tool("record", { uri: "project://sections/introduction", record: { ...section, surprise: true }, expect_sha256 });
518
+ assert.doesNotMatch(update.text, /looks like this example/, "an update is refused without the example");
519
+ const snake = await host.tool("read_record", { uri: "project://checkpoints/confirm_outline" });
520
+ assert.match(snake.text, /invalid id; record ids are lowercase .* such as confirm-outline/);
485
521
  }));
486
522
 
487
523
  test("no record write or file write escapes through a symbolic link", () =>
@@ -781,6 +817,163 @@ test("literature-heavy sections wait for verified evidence behind their required
781
817
  assert.match((await host.command("validate")).text, /manuscript-unread project:\/\/sections\/introduction: project:\/\/materials\/notes could not be checked/);
782
818
  }, SERVED));
783
819
 
820
+ test("an author's note on a gate answer reaches the next step, and typed text asks again instead of answering", () =>
821
+ withDesk(async (host, workspace) => {
822
+ await answer(host, GATE, "protocol-first");
823
+ // Free text names no option: the same gate comes back with how to attach the text, and nothing is recorded.
824
+ const key = await ask(host, PLAN_GATE);
825
+ const typed = await host.interview({ id: "gate-one", step: key, nav: "next", answers: { choice: "Split the claim in two." }, other: { choice: true } } as never);
826
+ assert.ok(!("done" in typed), "the gate is asked again");
827
+ assert.match(JSON.stringify(typed.step.intro), /attach your text to it with \[n\] note/);
828
+ assert.equal((read(workspace, `.planning/checkpoints/${PLAN_GATE}.json`) as Json).status, "pending");
829
+ // An option with a note records both; the note is the author's own, inside the sealed answer's checkpoint.
830
+ const done = await host.interview({ id: "gate-one", step: typed.step.key, nav: "next", answers: { choice: "revise" }, notes: { choice: "Split the claim\nin two." } } as never);
831
+ assert.ok("done" in done, JSON.stringify(done));
832
+ const resolved = read(workspace, `.planning/checkpoints/${PLAN_GATE}.json`);
833
+ assert.equal((resolved.resolution as Json).selected_option, "revise");
834
+ assert.match(String((resolved.resolution as Json).summary), /The author's note: Split the claim in two\.$/);
835
+ const ready = await host.tool("readiness", { section: "introduction" });
836
+ assert.match(ready.text, /not approve, with this note for the next plan: Split the claim in two\./);
837
+ }, SERVED));
838
+
839
+ test("a complete draft goes to submit-milestone on a fresh audit with no errors, and back to audit after any later write", () =>
840
+ withDesk(async (host, workspace) => {
841
+ await answer(host, GATE, "protocol-first");
842
+ await answer(host, PLAN_GATE, "approve");
843
+ put(workspace, ".planning/sections/introduction/section.json", { ...read(workspace, ".planning/sections/introduction/section.json"), status: "complete" });
844
+ const nextOf = async () => (((await host.tool("status", {})).data as Json).next as Json).action;
845
+ assert.equal(await nextOf(), "audit-milestone");
846
+ const audit = { schema: "wtfp.project.validation/v1", id: "milestone-audit-01", project_id: PROJECT, subject_uri: "project://state", validator_role: "coherence-checker", action_id: "audit-milestone", status: "issues-found", checks: [{ id: "readiness", status: "passed", summary: "Every section is complete.", evidence: ["Stated."] }], issues: [{ severity: "warning", summary: "One source is metadata-only." }], next_actions: [], effects_applied: [], executed_at: AT };
847
+ put(workspace, ".planning/validations/milestone-audit-01.json", audit);
848
+ assert.equal(await nextOf(), "submit-milestone", "warnings alone do not hold delivery");
849
+ put(workspace, ".planning/validations/milestone-audit-01.json", { ...audit, issues: [{ severity: "error", summary: "A citation does not resolve." }] });
850
+ assert.equal(await nextOf(), "plan-milestone-gaps");
851
+ put(workspace, ".planning/validations/milestone-audit-01.json", audit);
852
+ // A passed submission delivers the draft; an audit after it keeps it delivered.
853
+ put(workspace, ".planning/validations/milestone-01.json", { ...audit, id: "milestone-01", action_id: "submit-milestone", status: "passed", issues: [] });
854
+ put(workspace, ".planning/validations/milestone-audit-02.json", { ...audit, id: "milestone-audit-02" });
855
+ assert.equal(await nextOf(), null, "delivered");
856
+ assert.match(String(((((await host.tool("status", {})).data as Json).next as Json).reason)), /^Delivered/);
857
+ const later = Date.now() / 1000 + 60;
858
+ utimesSync(path.join(workspace, "paper/introduction.md"), later, later);
859
+ assert.equal(await nextOf(), "audit-milestone", "an audit of an earlier draft does not stand for this one");
860
+ }, SERVED));
861
+
862
+ test("submit-milestone archives the whole project once, by digest, and nothing else may", () =>
863
+ withDesk(async (host, workspace) => {
864
+ const refused = await host.tool("archive", { archive: "draft-01" });
865
+ assert.match(refused.text, /nothing armed does not declare archiving project:\/\/archives\/draft-01/);
866
+ await host.hook({ point: "prompt_submit", text: "/wtfp:submit-milestone" });
867
+ const made = await host.tool("archive", { archive: "draft-01" });
868
+ assert.equal(made.isError, undefined, made.text);
869
+ const manifest = read(workspace, ".planning/archives/draft-01/manifest.json");
870
+ const files = manifest.files as Array<{ path: string; sha256: string }>;
871
+ assert.ok(files.some((file) => file.path === ".planning/project.json") && files.some((file) => file.path === "paper/introduction.md"));
872
+ for (const file of files) assert.equal(sha(workspace, `.planning/archives/draft-01/${file.path}`), file.sha256, file.path);
873
+ assert.match((await host.tool("archive", { archive: "draft-01" })).text, /already exists, and an archive is immutable/);
874
+ const again = await host.tool("archive", { archive: "draft-02" });
875
+ assert.ok(!(read(workspace, ".planning/archives/draft-02/manifest.json").files as Array<{ path: string }>).some((file) => file.path.startsWith(".planning/archives/")), again.text);
876
+ }, { id: "wtfp", prompts: [...SERVED.prompts, "wtfp:submit-milestone"] }));
877
+
878
+ test("the author's approval links the plan it approves, in the same commit", () =>
879
+ withDesk(async (host, workspace) => {
880
+ const section = read(workspace, ".planning/sections/introduction/section.json");
881
+ put(workspace, ".planning/sections/introduction/section.json", { ...section, status: "not-started", artifacts: { ...(section.artifacts as Json), plans: [] } });
882
+ await answer(host, GATE, "protocol-first");
883
+ assert.match(await answer(host, PLAN_GATE, "approve"), /The desk linked project:\/\/sections\/introduction\/plans\/initial in project:\/\/sections\/introduction with this answer; do not link it again\. The desk wrote project:\/\/checkpoints\/approve-initial, project:\/\/state, project:\/\/sections\/introduction; read any of them again before writing it/);
884
+ const linked = read(workspace, ".planning/sections/introduction/section.json");
885
+ assert.deepEqual((linked.artifacts as Json).plans, [PLAN_URI]);
886
+ assert.equal(linked.status, "planned");
887
+ assert.equal(((await host.tool("readiness", { section: "introduction" })).data as Json).ready, true);
888
+ }, SERVED));
889
+
890
+ test("a family URI reads every record of that family in one call, and names what it leaves out", () =>
891
+ withDesk(async (host, workspace) => {
892
+ const source = (id: string, title: string) => ({
893
+ schema: "wtfp.project.source/v1", id, project_id: PROJECT, kind: "journal-article", title, creators: ["A. Author"], year: 2025,
894
+ identifiers: { doi: `10.1234/${id}` }, citation_key: id.replace(/-/gu, ""), status: "verified",
895
+ provenance: { discovered_via: "scholarly-index", inspection_depth: "full-text", verified_at: AT },
896
+ });
897
+ const empty = await host.tool("read_record", { uri: "project://sources" });
898
+ assert.match(empty.text, /project:\/\/sources holds no records yet/);
899
+ put(workspace, ".planning/sources/source-a.json", source("source-a", "A"));
900
+ put(workspace, ".planning/sources/source-b.json", source("source-b", "B"));
901
+ const both = await host.tool("read_record", { uri: "project://sources/*" });
902
+ assert.match(both.text, /holds 2 records; 2 returned in full/);
903
+ const records = (both.data as Json).records as Json[];
904
+ assert.deepEqual(records.map((entry) => (entry.record as Json).id), ["source-a", "source-b"]);
905
+ assert.equal(records[0]?.sha256, (await host.tool("read_record", { uri: "project://sources/source-a" }) as { data: Json }).data.sha256);
906
+ // A family too large to return in full lists one digest row per record, with the version to write it back.
907
+ put(workspace, ".planning/sources/source-c.json", source("source-c", "C".repeat(20 * 1024)));
908
+ const listed = await host.tool("read_record", { uri: "project://sources" });
909
+ assert.equal((listed.data as Json).form, "digest");
910
+ assert.match(listed.text, /holds 3 records, 2\d KB in full, so this read lists 3 as one digest row each.*Read a record at its uri for every field, or keep one section's records with \?section=<section id>/);
911
+ const rows = (listed.data as Json).records as Json[];
912
+ assert.deepEqual(rows.map((row) => row.citation_key), ["sourcea", "sourceb", "sourcec"]);
913
+ assert.equal(rows[0]?.sha256, records[0]?.sha256);
914
+ assert.equal(rows[0]?.record, undefined, "a digest row carries no record body");
915
+ assert.ok(String(rows[2]?.title).length <= 160, "a digest row bounds its text");
916
+ // Past the page budget, the rest is named for the next page.
917
+ for (const id of ["source-d", "source-e", "source-f", "source-g"]) put(workspace, `.planning/sources/${id}.json`, source(id, "x".repeat(20 * 1024)));
918
+ const many = Array.from({ length: 300 }, (_, index) => `source-z${index}`);
919
+ for (const id of many) put(workspace, `.planning/sources/${id}.json`, source(id, "Z"));
920
+ const capped = await host.tool("read_record", { uri: "project://sources" });
921
+ const omitted = (capped.data as Json).omitted as string[];
922
+ assert.ok(omitted.length > 0);
923
+ const last = String((((capped.data as Json).records as Json[]).at(-1) as Json).uri).split("/").pop();
924
+ assert.match(capped.text, new RegExp(`${omitted.length} more not returned, to keep this read small; read the next page with project://sources\\?after=${last}`));
925
+ const next = await host.tool("read_record", { uri: `project://sources?after=${last}` });
926
+ assert.equal(((next.data as Json).records as Json[])[0]?.uri, `project://sources/${omitted[0]}`);
927
+ assert.match((await host.tool("read_record", { uri: "project://sources?sort=year" })).text, /^Not read: .*takes section=<section id> and after=<record id>/);
928
+ // Sections are a family too, read from each section's own directory.
929
+ const sections = await host.tool("read_record", { uri: "project://sections" });
930
+ assert.deepEqual(((sections.data as Json).records as Json[]).map((entry) => entry.uri), ["project://sections/introduction"]);
931
+ }, SERVED));
932
+
933
+ test("a family read narrowed to one section keeps only the records about it", () =>
934
+ withDesk(async (host, workspace) => {
935
+ const validation = (id: string, subject: string) => ({
936
+ schema: "wtfp.project.validation/v1", id, project_id: PROJECT, subject_uri: subject, validator_role: "argument-verifier", action_id: "verify-work",
937
+ status: "issues-found", checks: [{ id: "claims", status: "failed", summary: "A claim is unsupported.", evidence: ["paragraph 2"] }], issues: ["unsupported claim"], next_actions: [], effects_applied: [], executed_at: AT,
938
+ });
939
+ put(workspace, ".planning/validations/introduction-verified.json", validation("introduction-verified", "project://sections/introduction"));
940
+ put(workspace, ".planning/validations/introduction-plan-checked.json", validation("introduction-plan-checked", "project://sections/introduction/plans/initial"));
941
+ put(workspace, ".planning/validations/methods-verified.json", validation("methods-verified", "project://sections/methods"));
942
+ const narrowed = await host.tool("read_record", { uri: "project://validations?section=introduction" });
943
+ assert.deepEqual(((narrowed.data as Json).records as Json[]).map((entry) => entry.uri), ["project://validations/introduction-plan-checked", "project://validations/introduction-verified"]);
944
+ assert.match(narrowed.text, /holds 2 records about section introduction; 2 returned in full/);
945
+ assert.equal((narrowed.data as Json).uri, "project://validations?section=introduction");
946
+ // Past the full budget the narrowed family is listed by digest, each row naming its failed checks.
947
+ for (let index = 0; index < 12; index++) put(workspace, `.planning/validations/introduction-review-${index}.json`, { ...validation(`introduction-review-${index}`, "project://sections/introduction"), issues: ["x".repeat(2048)] });
948
+ const digest = await host.tool("read_record", { uri: "project://validations?section=introduction" });
949
+ assert.equal((digest.data as Json).form, "digest");
950
+ const row = ((digest.data as Json).records as Json[])[0] as Json;
951
+ assert.deepEqual([row.action_id, row.status, row.failed_checks, row.issues], ["verify-work", "issues-found", ["claims"], 1]);
952
+ assert.ok(((digest.data as Json).records as Json[]).every((entry) => String(entry.uri).includes("introduction")));
953
+ assert.match((await host.tool("read_record", { uri: "project://validations?section=nowhere" })).text, /^Not read: there is no section nowhere/);
954
+ }, SERVED));
955
+
956
+ test("a literature-heavy section that records no claim needing evidence is not covered", () =>
957
+ withDesk(async (host, workspace) => {
958
+ const outline = read(workspace, ".planning/structure/outline.json");
959
+ const [entry] = outline.sections as Json[];
960
+ put(workspace, ".planning/structure/outline.json", { ...outline, sections: [{ ...entry, research: { required: true, topics: ["logging"] } }] });
961
+ await answer(host, GATE, "protocol-first");
962
+ await answer(host, PLAN_GATE, "approve");
963
+ const ready = await host.tool("readiness", { section: "introduction" });
964
+ assert.equal((ready.data as Json).ready, false, "no claims means nothing shows the sources cover it");
965
+ assert.match(ready.text, /records no claim that needs evidence.*run research-gap first/);
966
+ assert.match(blocked(await write(host, "paper/introduction.md")) ?? "", /research-gap/);
967
+ // A rejected claim, or one that needs no evidence, covers nothing either.
968
+ const section = read(workspace, ".planning/sections/introduction/section.json");
969
+ const claim = { id: "claim-flush", statement: "Flushes dominate logging cost.", status: "rejected", evidence_required: true, evidence_uris: [] };
970
+ put(workspace, ".planning/sections/introduction/section.json", { ...section, claims: [claim, { ...claim, id: "claim-scope", status: "planned", evidence_required: false }] });
971
+ assert.equal(((await host.tool("readiness", { section: "introduction" })).data as Json).ready, false);
972
+ // Turning research off is the author's way to draft without it.
973
+ put(workspace, ".planning/structure/outline.json", { ...outline, sections: [{ ...entry, research: { required: false, topics: [] } }] });
974
+ assert.equal(((await host.tool("readiness", { section: "introduction" })).data as Json).ready, true);
975
+ }, SERVED));
976
+
784
977
  test("a section file counts only for the section whose id names its directory", () =>
785
978
  withDesk(async (host, workspace) => {
786
979
  const outline = read(workspace, ".planning/structure/outline.json");
@@ -848,6 +1041,500 @@ test("an armed action writes only what its contract declares, for the section it
848
1041
  assert.match(blocked(await write(host, ".planning/sections/introduction/notes.md")) ?? "", /declares no file outputs/);
849
1042
  }, SERVED));
850
1043
 
1044
+ // --- the advance driver ------------------------------------------------------------
1045
+ // `/wtfp:advance` runs one long turn. The desk, never the model, picks each step
1046
+ // by the progress ladder and arms the write guard for that action alone; a gate
1047
+ // stops the run until the author answers it at the desk.
1048
+
1049
+ const DRIVEN_PLUGIN = {
1050
+ id: "wtfp",
1051
+ prompts: [...SERVED.prompts, "wtfp:advance", "wtfp:review-section", "wtfp:discuss-section", "wtfp:create-outline", "wtfp:verify-work", "wtfp:plan-revision"],
1052
+ };
1053
+ /** Stamps the manuscript as written `offsetMs` from the desk's clock, after or before the plan's approval. */
1054
+ /** The writer saves the manuscript at this offset without finishing write-section. */
1055
+ const saved = (host: Host, workspace: string, offsetMs: number): void => {
1056
+ const at = new Date(host.now + offsetMs);
1057
+ utimesSync(path.join(workspace, "paper/introduction.md"), at, at);
1058
+ };
1059
+ /** write-section drafts the manuscript at this offset and records its validation. */
1060
+ const drafted = (host: Host, workspace: string, offsetMs: number): void => {
1061
+ saved(host, workspace, offsetMs);
1062
+ put(workspace, ".planning/validations/introduction-written.json", {
1063
+ schema: "wtfp.project.validation/v1",
1064
+ id: "introduction-written",
1065
+ project_id: PROJECT,
1066
+ subject_uri: "project://paper/introduction",
1067
+ validator_role: "section-writer",
1068
+ action_id: "write-section",
1069
+ status: "passed",
1070
+ checks: [{ id: "plan-criteria", status: "passed", summary: "The draft satisfies its plan.", evidence: ["paper/introduction.md"] }],
1071
+ issues: [],
1072
+ next_actions: [],
1073
+ effects_applied: [],
1074
+ executed_at: new Date(host.now + offsetMs).toISOString().replace(/\.\d{3}Z$/u, "Z"),
1075
+ });
1076
+ };
1077
+ const nextStep = async (host: Host): Promise<{ text: string; data: Json; isError?: boolean }> => {
1078
+ const result = await host.tool("next_step", {});
1079
+ return { text: result.text, data: (result.data ?? {}) as Json, ...(result.isError ? { isError: true } : {}) };
1080
+ };
1081
+
1082
+ test("only an advance turn may ask the desk for a step, and the turn's end ends the run", () =>
1083
+ withDesk(async (host) => {
1084
+ assert.equal((await nextStep(host)).isError, true, "no drive outside an advance turn");
1085
+ await host.hook({ point: "prompt_submit", text: "/wtfp:write-section introduction" });
1086
+ assert.equal((await nextStep(host)).isError, true, "an ordinary action cannot drive");
1087
+ const armed = await host.hook({ point: "prompt_submit", text: "/wtfp:advance" });
1088
+ assert.match(JSON.stringify(armed.effects), /WTF-P driver armed/);
1089
+ assert.match(blocked(await write(host, "paper/introduction.md")) ?? "", /nothing is armed between \/wtfp:advance steps.*Call extension_wtfp__next_step/, "nothing is writable before the desk arms a step, and the refusal says how to get one");
1090
+ assert.equal((await nextStep(host)).data.kind, "gate");
1091
+ await host.observe({ event: "turn_end", turnId: "t1", outcome: "completed", usage: null });
1092
+ assert.equal((await nextStep(host)).isError, true, "the drive ends with its turn");
1093
+ await host.hook({ point: "prompt_submit", text: "/wtfp:advance" });
1094
+ // Clio continuing the turn after its tool budget or loop guard resumes the drive the turn had.
1095
+ assert.equal((await nextStep(host)).data.kind, "gate");
1096
+ await host.observe({ event: "turn_end", turnId: "t2", outcome: "completed", usage: null });
1097
+ assert.equal((await nextStep(host)).isError, true, "between turns nothing drives");
1098
+ await host.hook({ point: "prompt_submit", text: "Continue.", origin: "continuation", continuation: { index: 1, cap: 3 } } as never);
1099
+ const resumed = await nextStep(host);
1100
+ assert.notEqual(resumed.isError, true, resumed.text);
1101
+ await host.hook({ point: "prompt_submit", text: "/wtfp:progress" });
1102
+ assert.equal((await nextStep(host)).isError, true, "any other prompt ends the drive");
1103
+ await host.observe({ event: "turn_end", turnId: "t3", outcome: "completed", usage: null });
1104
+ await host.hook({ point: "prompt_submit", text: "Continue.", origin: "continuation", continuation: { index: 1, cap: 3 } } as never);
1105
+ assert.equal((await nextStep(host)).isError, true, "a continuation resumes only the drive its own turn had");
1106
+ }, DRIVEN_PLUGIN));
1107
+
1108
+ test("advance puts each gate to the author, then arms exactly the step the ladder names", () =>
1109
+ withDesk(async (host, workspace) => {
1110
+ await host.hook({ point: "prompt_submit", text: "/wtfp:advance" });
1111
+ // The desk names the gates in its own order; each is answered as the author would.
1112
+ const choices: Record<string, string> = { [GATE]: "protocol-first", [PLAN_GATE]: "approve" };
1113
+ const asked: string[] = [];
1114
+ for (let round = 0; round < 2; round += 1) {
1115
+ const gate = await nextStep(host);
1116
+ assert.equal(gate.data.kind, "gate", gate.text);
1117
+ asked.push(gate.data.checkpoint as string);
1118
+ assert.match(blocked(await write(host, "paper/introduction.md")) ?? "", /nothing is armed between \/wtfp:advance steps/, "a gate leaves nothing armed");
1119
+ await answer(host, gate.data.checkpoint as string, choices[gate.data.checkpoint as string] as string);
1120
+ }
1121
+ assert.deepEqual(asked.sort(), [GATE, PLAN_GATE].sort());
1122
+ const step = await nextStep(host);
1123
+ assert.deepEqual([step.data.kind, step.data.action, step.data.section, step.data.prompt], ["step", "write-section", "introduction", "ai.iowarp.clio/prompts/wtfp/write-section.md"]);
1124
+ assert.match(step.text, /armed for write-section introduction only/);
1125
+ assert.equal(blocked(await write(host, "paper/introduction.md")), null, "the armed step may write its manuscript");
1126
+ assert.ok(blocked(await write(host, ".planning/sections/introduction/plans/second.md")), "but nothing write-section does not declare");
1127
+ const outline = read(workspace, ".planning/structure/outline.json");
1128
+ const undeclared = await host.tool("record", { uri: "project://structure/outline", record: { ...outline, thesis: "Changed." }, expect_revision: 1 });
1129
+ assert.match(undeclared.text, /write-section does not declare updating project:\/\/structure\/outline/);
1130
+ // The drafted section moves to review, and the desk arms the review next, not the draft.
1131
+ drafted(host, workspace, 60_000);
1132
+ put(workspace, ".planning/sections/introduction/section.json", { ...read(workspace, ".planning/sections/introduction/section.json"), status: "reviewing" });
1133
+ const review = await nextStep(host);
1134
+ assert.deepEqual([review.data.kind, review.data.action, review.data.section], ["step", "review-section", "introduction"]);
1135
+ assert.ok(blocked(await write(host, "paper/introduction.md")), "the review step may not touch the manuscript the draft step could");
1136
+ // A step that changed nothing the ladder reads is handed back once to record its outputs, then not run again.
1137
+ const finish = await nextStep(host);
1138
+ assert.deepEqual([finish.data.kind, finish.data.action, finish.data.finish], ["step", "review-section", true]);
1139
+ assert.match(finish.text, /Continue \/wtfp:review-section introduction; it has not failed\. It recorded nothing.*project:\/\/sections\/introduction\/reviews\/\{review\}/);
1140
+ const again = await nextStep(host);
1141
+ assert.equal(again.data.kind, "stop");
1142
+ assert.match(again.text, /changed nothing/);
1143
+ assert.match(blocked(await write(host, "paper/introduction.md")) ?? "", /nothing is armed between \/wtfp:advance steps/, "a stop disarms the last step");
1144
+ }, DRIVEN_PLUGIN));
1145
+
1146
+ test("every next_step result restates the driver rule, so a compacted turn can continue from the last result alone", () =>
1147
+ withDesk(async (host) => {
1148
+ await host.hook({ point: "prompt_submit", text: "/wtfp:advance" });
1149
+ const ruleOf = (text: string): string => /Driver rule for this \/wtfp:advance run: .*$/u.exec(text)?.[0] ?? "";
1150
+ const gate = await nextStep(host);
1151
+ assert.equal(gate.data.kind, "gate");
1152
+ assert.match(gate.text, new RegExp(`Call extension_wtfp__gate with checkpoint ${gate.data.checkpoint as string}\\.`));
1153
+ const rule = ruleOf(gate.text);
1154
+ assert.match(rule, /the desk, not you, picks every step/);
1155
+ assert.match(rule, /call extension_wtfp__next_step/);
1156
+ assert.match(rule, /call extension_wtfp__gate with the checkpoint it names and then extension_wtfp__next_step/);
1157
+ assert.match(rule, /on a stop, a failed step or a refused call report the steps taken and end the turn/);
1158
+ await answer(host, GATE, "protocol-first");
1159
+ await answer(host, PLAN_GATE, "approve");
1160
+ const step = await nextStep(host);
1161
+ assert.equal(step.data.kind, "step");
1162
+ assert.match(step.text, /^Step 1: \/wtfp:write-section introduction\./);
1163
+ assert.match(step.text, /Read and follow <plugin root>\/ai\.iowarp\.clio\/prompts\/wtfp\/write-section\.md, where <plugin root> is the WTF-P plugin root \(two directories above the base_dir of the loaded wtfp-manage-project skill/);
1164
+ // Live on Clio 0.8.3, the model looked for a tool named audit-milestone and stopped the drive.
1165
+ assert.match(step.text, /A step is a procedure, not a capability: there is no tool named after its action/);
1166
+ assert.match(step.text, /invocation input introduction/);
1167
+ assert.equal(ruleOf(step.text), rule);
1168
+ const finish = await nextStep(host);
1169
+ assert.equal(finish.data.finish, true);
1170
+ assert.equal(ruleOf(finish.text), rule);
1171
+ const stop = await nextStep(host);
1172
+ assert.equal(stop.data.kind, "stop");
1173
+ assert.equal(ruleOf(stop.text), rule);
1174
+ }, DRIVEN_PLUGIN));
1175
+
1176
+ test("a gate the author keeps pending, or that no author can answer, stops the run with the gate open", () =>
1177
+ withDesk(async (host, workspace) => {
1178
+ await host.hook({ point: "prompt_submit", text: "/wtfp:advance" });
1179
+ const first = (await nextStep(host)).data.checkpoint as string;
1180
+ assert.ok([GATE, PLAN_GATE].includes(first));
1181
+ await answer(host, first, "__keep");
1182
+ const kept = await nextStep(host);
1183
+ assert.equal(kept.data.kind, "stop");
1184
+ assert.match(kept.text, new RegExp(`${first} is still waiting on you`));
1185
+ assert.equal((read(workspace, `.planning/checkpoints/${first}.json`) as Json).status, "pending");
1186
+ await host.observe({ event: "turn_end", turnId: "t1", outcome: "completed", usage: null });
1187
+ await host.hook({ point: "prompt_submit", text: "/wtfp:advance" });
1188
+ assert.equal((await nextStep(host)).data.checkpoint, first, "a new run asks the kept gate again");
1189
+ const recorded = interactions(workspace).length;
1190
+ const key = await ask(host, first);
1191
+ await host.interview({ id: "gate-one", step: key, nav: "cancel", answers: {}, reason: "headless" });
1192
+ const headless = await nextStep(host);
1193
+ assert.equal(headless.data.kind, "stop");
1194
+ assert.equal((read(workspace, `.planning/checkpoints/${first}.json`) as Json).status, "pending");
1195
+ assert.equal(interactions(workspace).length, recorded, "no answer was recorded for an author who was never asked");
1196
+ }, DRIVEN_PLUGIN));
1197
+
1198
+ test("advance never starts a project and never runs an action the plugin does not serve", () =>
1199
+ withDesk(async (host, workspace) => {
1200
+ await host.hook({ point: "prompt_submit", text: "/wtfp:advance" });
1201
+ await answer(host, GATE, "protocol-first");
1202
+ await answer(host, PLAN_GATE, "approve");
1203
+ // write-section is next, but this plugin serves only advance.
1204
+ const unserved = await nextStep(host);
1205
+ assert.equal(unserved.data.kind, "stop");
1206
+ assert.match(unserved.text, /needs the WTF-P plugin/);
1207
+ rmSync(path.join(workspace, ".planning"), { recursive: true, force: true });
1208
+ const empty = await nextStep(host);
1209
+ assert.equal(empty.data.kind, "stop");
1210
+ assert.match(empty.text, /never starts one/);
1211
+ }, { id: "wtfp", prompts: ["wtfp:advance"] }));
1212
+
1213
+ test("advance creates the section records an outline lists before any section step", () =>
1214
+ withDesk(async (host, workspace) => {
1215
+ await host.hook({ point: "prompt_submit", text: "/wtfp:advance" });
1216
+ await answer(host, GATE, "protocol-first");
1217
+ await answer(host, PLAN_GATE, "approve");
1218
+ // new-paper leaves an outline with no section records; only create-outline may create one.
1219
+ rmSync(path.join(workspace, ".planning/sections/introduction/section.json"));
1220
+ const step = await nextStep(host);
1221
+ assert.deepEqual([step.data.kind, step.data.action, step.data.section], ["step", "create-outline", null], step.text);
1222
+ assert.match(step.text, /lists introduction without a section record/);
1223
+ }, DRIVEN_PLUGIN));
1224
+
1225
+ test("after review the author accepts a section or sends it back, and advance follows the sealed answer", () =>
1226
+ withDesk(async (host, workspace) => {
1227
+ await host.hook({ point: "prompt_submit", text: "/wtfp:advance" });
1228
+ await answer(host, GATE, "protocol-first");
1229
+ await answer(host, PLAN_GATE, "approve");
1230
+ drafted(host, workspace, 60_000);
1231
+ const sectionFile = ".planning/sections/introduction/section.json";
1232
+ const validation = (id: string, action: string, at: string): Json => ({
1233
+ schema: "wtfp.project.validation/v1",
1234
+ id,
1235
+ project_id: PROJECT,
1236
+ subject_uri: "project://paper/introduction",
1237
+ validator_role: action === "review-section" ? "section-reviewer" : "author",
1238
+ action_id: action,
1239
+ status: "passed",
1240
+ checks: [{ id: "plan-criteria", status: "passed", summary: "Every plan criterion holds.", evidence: ["The bottleneck and contribution are stated."] }],
1241
+ issues: [],
1242
+ next_actions: [],
1243
+ effects_applied: [],
1244
+ executed_at: at,
1245
+ });
1246
+ put(workspace, sectionFile, { ...read(workspace, sectionFile), status: "reviewing" });
1247
+ put(workspace, ".planning/validations/introduction-review.json", validation("introduction-review", "review-section", "2026-09-01T10:00:00Z"));
1248
+ // Review is critique only; the author's acceptance is verify-work's.
1249
+ const verify = await nextStep(host);
1250
+ assert.deepEqual([verify.data.kind, verify.data.action, verify.data.section], ["step", "verify-work", "introduction"], verify.text);
1251
+ assert.match(verify.text, /is reviewed; the author checks it against its plan/);
1252
+ put(workspace, ".planning/validations/introduction-verified.json", validation("introduction-verified", "verify-work", "2026-09-01T11:00:00Z"));
1253
+ put(workspace, ".planning/checkpoints/accept-introduction.json", {
1254
+ schema: "wtfp.project.checkpoint/v1",
1255
+ id: "accept-introduction",
1256
+ project_id: PROJECT,
1257
+ kind: "decision",
1258
+ status: "pending",
1259
+ blocking: true,
1260
+ scope_uri: "project://validations/introduction-verified",
1261
+ request: "Accept the introduction as written?",
1262
+ options: [
1263
+ { id: "accept", label: "Revise", implication: "A checkpoint may label its options as it likes." },
1264
+ { id: "revise", label: "Accept", implication: "The desk's own words decide what reads as acceptance." },
1265
+ ],
1266
+ resume_action: "verify-work",
1267
+ created_at: "2026-09-01T11:00:00Z",
1268
+ });
1269
+ const gate = await nextStep(host);
1270
+ assert.deepEqual([gate.data.kind, gate.data.checkpoint], ["gate", "accept-introduction"], gate.text);
1271
+ const asked = await host.tool("gate", { checkpoint: "accept-introduction" });
1272
+ const options = asked.interview?.step.questions[0]?.options ?? [];
1273
+ assert.match(options.find((option) => option.value === "accept")?.label ?? "", /^Accept this section as written/);
1274
+ assert.ok(!options.some((option) => option.value !== "accept" && /^accept/iu.test(option.label)), "no other option may read as acceptance");
1275
+ await host.interview({ id: "gate-one", step: asked.interview?.step.key as string, nav: "next", answers: { choice: "revise" } });
1276
+ const revise = await nextStep(host);
1277
+ assert.deepEqual([revise.data.kind, revise.data.action, revise.data.section], ["step", "plan-revision", "introduction"], revise.text);
1278
+ // A later review supersedes that verification, so the author is asked again.
1279
+ put(workspace, ".planning/validations/introduction-review-2.json", validation("introduction-review-2", "review-section", "2026-09-01T12:00:00Z"));
1280
+ const again = await nextStep(host);
1281
+ assert.deepEqual([again.data.action, again.data.section], ["verify-work", "introduction"], again.text);
1282
+ assert.match(again.text, /is reviewed; the author checks it against its plan/);
1283
+ }, DRIVEN_PLUGIN));
1284
+
1285
+ test("a reviewed section whose approved revision plan no draft has applied goes back to write-section", () =>
1286
+ withDesk(async (host, workspace) => {
1287
+ await host.hook({ point: "prompt_submit", text: "/wtfp:advance" });
1288
+ await answer(host, GATE, "protocol-first");
1289
+ // The draft predates the plan the author approves now: live, plan-02 was approved and advance armed review again.
1290
+ await host.advance(7_200_000);
1291
+ drafted(host, workspace, -3_600_000);
1292
+ await answer(host, PLAN_GATE, "approve");
1293
+ const sectionFile = ".planning/sections/introduction/section.json";
1294
+ put(workspace, sectionFile, { ...read(workspace, sectionFile), status: "reviewing", artifacts: { ...(read(workspace, sectionFile).artifacts as Json), reviews: ["project://sections/introduction/reviews/review-01"] } });
1295
+ const rewrite = await nextStep(host);
1296
+ assert.deepEqual([rewrite.data.kind, rewrite.data.action, rewrite.data.section], ["step", "write-section", "introduction"], rewrite.text);
1297
+ assert.match(rewrite.text, /approved revision plan that no draft has applied yet/);
1298
+ // A manuscript saved after the approval without write-section's validation is not drafted yet: live, a writer
1299
+ // saved the revision, could not count it, and the desk sent the section to review with a stale count and summary.
1300
+ saved(host, workspace, 30_000);
1301
+ put(workspace, sectionFile, { ...read(workspace, sectionFile), word_count: 286 });
1302
+ const unfinished = await nextStep(host);
1303
+ assert.deepEqual([unfinished.data.action, unfinished.data.section], ["write-section", "introduction"], unfinished.text);
1304
+ assert.match(unfinished.text, /draft for its approved plan is saved, but write-section has not finished it/);
1305
+ // The same step armed again after progress says so, instead of reading like the first arming.
1306
+ assert.match(unfinished.text, /Continue \/wtfp:write-section introduction: it made progress but has not finished, so the desk arms it again on purpose; this is not a loop/);
1307
+ // Once the draft is written after the approval, it is reviewed again: the earlier review read the earlier draft.
1308
+ drafted(host, workspace, 60_000);
1309
+ const review = await nextStep(host);
1310
+ assert.deepEqual([review.data.action, review.data.section], ["review-section", "introduction"], review.text);
1311
+ }, DRIVEN_PLUGIN));
1312
+
1313
+ test("a section drafted from its approved plan goes to review even if its record still says writing", () =>
1314
+ withDesk(async (host, workspace) => {
1315
+ await host.hook({ point: "prompt_submit", text: "/wtfp:advance" });
1316
+ await answer(host, GATE, "protocol-first");
1317
+ await answer(host, PLAN_GATE, "approve");
1318
+ // Live, write-section drafted method-admission but left status writing, and the desk re-armed the draft.
1319
+ drafted(host, workspace, 60_000);
1320
+ const sectionFile = ".planning/sections/introduction/section.json";
1321
+ put(workspace, sectionFile, { ...read(workspace, sectionFile), status: "writing" });
1322
+ const review = await nextStep(host);
1323
+ assert.deepEqual([review.data.kind, review.data.action, review.data.section], ["step", "review-section", "introduction"], review.text);
1324
+ assert.match(review.text, /is drafted and waits for review/);
1325
+ // Live, the review was recorded but the status stayed writing, and the desk named the review again.
1326
+ const reviewFile = ".planning/validations/introduction-review.json";
1327
+ put(workspace, reviewFile, {
1328
+ schema: "wtfp.project.validation/v1", id: "introduction-review", project_id: PROJECT, subject_uri: "project://paper/introduction",
1329
+ validator_role: "section-reviewer", action_id: "review-section", status: "passed",
1330
+ checks: [{ id: "plan-criteria", status: "passed", summary: "Every plan criterion holds.", evidence: ["Stated."] }],
1331
+ issues: [], next_actions: [], effects_applied: [], executed_at: "2026-09-01T10:00:00Z",
1332
+ });
1333
+ const after = new Date(host.now + 120_000);
1334
+ utimesSync(path.join(workspace, reviewFile), after, after);
1335
+ const verify = await nextStep(host);
1336
+ assert.deepEqual([verify.data.action, verify.data.section], ["verify-work", "introduction"], verify.text);
1337
+ }, DRIVEN_PLUGIN));
1338
+
1339
+ test("a review counts only for the draft it read", () =>
1340
+ withDesk(async (host, workspace) => {
1341
+ await host.hook({ point: "prompt_submit", text: "/wtfp:advance" });
1342
+ await answer(host, GATE, "protocol-first");
1343
+ await answer(host, PLAN_GATE, "approve");
1344
+ drafted(host, workspace, 60_000);
1345
+ const sectionFile = ".planning/sections/introduction/section.json";
1346
+ put(workspace, sectionFile, { ...read(workspace, sectionFile), status: "reviewing" });
1347
+ const reviewFile = ".planning/validations/introduction-review.json";
1348
+ put(workspace, reviewFile, {
1349
+ schema: "wtfp.project.validation/v1", id: "introduction-review", project_id: PROJECT, subject_uri: "project://paper/introduction",
1350
+ validator_role: "section-reviewer", action_id: "review-section", status: "passed",
1351
+ checks: [{ id: "plan-criteria", status: "passed", summary: "Every plan criterion holds.", evidence: ["Stated."] }],
1352
+ issues: [], next_actions: [], effects_applied: [], executed_at: "2026-09-01T10:00:00Z",
1353
+ });
1354
+ // The desk recorded the review after the draft, so it covers it: the author checks it next.
1355
+ const after = new Date(host.now + 120_000);
1356
+ utimesSync(path.join(workspace, reviewFile), after, after);
1357
+ assert.equal((await nextStep(host)).data.action, "verify-work");
1358
+ // A revision written after that review waits for a new one, whatever the review claims as its time.
1359
+ drafted(host, workspace, 180_000);
1360
+ const again = await nextStep(host);
1361
+ assert.deepEqual([again.data.action, again.data.section], ["review-section", "introduction"], again.text);
1362
+ }, DRIVEN_PLUGIN));
1363
+
1364
+ test("an accepted section is handed back to verify-work, which marks it complete", () =>
1365
+ withDesk(async (host, workspace) => {
1366
+ await host.hook({ point: "prompt_submit", text: "/wtfp:advance" });
1367
+ await answer(host, GATE, "protocol-first");
1368
+ await answer(host, PLAN_GATE, "approve");
1369
+ drafted(host, workspace, 60_000);
1370
+ const sectionFile = ".planning/sections/introduction/section.json";
1371
+ put(workspace, sectionFile, { ...read(workspace, sectionFile), status: "reviewing" });
1372
+ for (const [id, action, at] of [["introduction-review", "review-section", "2026-09-01T10:00:00Z"], ["introduction-verified", "verify-work", "2026-09-01T11:00:00Z"]])
1373
+ put(workspace, `.planning/validations/${id}.json`, {
1374
+ schema: "wtfp.project.validation/v1",
1375
+ id,
1376
+ project_id: PROJECT,
1377
+ subject_uri: "project://sections/introduction",
1378
+ validator_role: "author",
1379
+ action_id: action,
1380
+ status: "passed",
1381
+ checks: [],
1382
+ issues: [],
1383
+ next_actions: [],
1384
+ effects_applied: [],
1385
+ executed_at: at,
1386
+ });
1387
+ put(workspace, ".planning/checkpoints/accept-introduction.json", {
1388
+ schema: "wtfp.project.checkpoint/v1",
1389
+ id: "accept-introduction",
1390
+ project_id: PROJECT,
1391
+ kind: "decision",
1392
+ status: "pending",
1393
+ blocking: true,
1394
+ scope_uri: "project://validations/introduction-verified",
1395
+ request: "Accept the introduction as written?",
1396
+ options: [
1397
+ { id: "accept", label: "Accept", implication: "Mark it complete." },
1398
+ { id: "revise", label: "Revise", implication: "Plan a revision." },
1399
+ ],
1400
+ resume_action: "verify-work",
1401
+ created_at: "2026-09-01T11:00:00Z",
1402
+ });
1403
+ assert.equal((await nextStep(host)).data.kind, "gate");
1404
+ await answer(host, "accept-introduction", "accept");
1405
+ const apply = await nextStep(host);
1406
+ assert.deepEqual([apply.data.kind, apply.data.action, apply.data.section], ["step", "verify-work", "introduction"], apply.text);
1407
+ assert.match(apply.text, /accepted Introduction; verify-work marks it complete/);
1408
+ }, DRIVEN_PLUGIN));
1409
+
1410
+ test("the desk's advance key fills the advance prompt only while the plugin serves it", () =>
1411
+ withDesk(async (host) => {
1412
+ const filled = await host.action("advance");
1413
+ assert.equal(filled.text, "/wtfp:advance");
1414
+ }, DRIVEN_PLUGIN));
1415
+
1416
+ test("status gives an agent the whole project in one read, matching what the desk draws", () =>
1417
+ withDesk(async (host, workspace) => {
1418
+ const status = await host.tool("status", {});
1419
+ const data = status.data as Json;
1420
+ assert.equal(data.present, true);
1421
+ assert.equal(data.phase, "writing");
1422
+ const [section] = data.sections as Json[];
1423
+ assert.equal(section?.id, "introduction");
1424
+ assert.equal((section?.plan as Json).state, "awaiting");
1425
+ assert.ok((section?.blockers as string[]).length > 0, "a gated section reports why it cannot be drafted");
1426
+ assert.deepEqual((data.open_gates as Json[]).map((gate) => gate.id).sort(), [GATE, PLAN_GATE].sort());
1427
+ assert.ok(((data.next as Json).gate as string) !== null);
1428
+ assert.match(status.text, /introduction: planned/);
1429
+ rmSync(path.join(workspace, ".planning"), { recursive: true, force: true });
1430
+ assert.equal(((await host.tool("status", {})).data as Json).present, false);
1431
+ }, SERVED));
1432
+
1433
+ // --- the turn_start status reminder ------------------------------------------------
1434
+ // Clio fires turn_start once per operator prompt; the desk answers with its status
1435
+ // only when that prompt armed a WTF-P action or advance in a project.
1436
+
1437
+ const turnStart = (host: Host) => host.hook({ point: "turn_start", turnId: "t1" });
1438
+ const reminderOf = (result: { effects?: Array<{ kind: string }> }): string | null =>
1439
+ (result.effects?.find((effect) => effect.kind === "inject_reminder") as { message?: string } | undefined)?.message ?? null;
1440
+
1441
+ test("a WTF-P turn starts from the desk's status, and no other turn does", () =>
1442
+ withDesk(async (host, workspace) => {
1443
+ assert.equal(reminderOf(await turnStart(host)), null, "nothing armed, nothing injected");
1444
+ await host.hook({ point: "prompt_submit", text: "explain the flush bottleneck" });
1445
+ assert.equal(reminderOf(await turnStart(host)), null, "an ordinary prompt gets no reminder");
1446
+ await host.hook({ point: "prompt_submit", text: "/wtfp:plan-section introduction" });
1447
+ const armed = await turnStart(host);
1448
+ const message = reminderOf(armed) ?? "";
1449
+ assert.match(message, /^WTF-P desk status at the start of this turn/);
1450
+ assert.match(message, /introduction: planned/);
1451
+ assert.match(message, new RegExp(`Open gates: .*${GATE}`));
1452
+ assert.ok(message.length <= 2000);
1453
+ assert.equal((armed.effects as Array<{ kind: string; audience?: string }>)[0]?.audience, "model");
1454
+ await host.observe({ event: "turn_end", turnId: "t1", outcome: "completed", usage: null });
1455
+ assert.equal(reminderOf(await turnStart(host)), null, "the turn's end disarms the reminder");
1456
+ await host.hook({ point: "prompt_submit", text: "/wtfp:advance" });
1457
+ assert.match(reminderOf(await turnStart(host)) ?? "", /WTF-P desk status/, "an advance run starts from the status too");
1458
+ rmSync(path.join(workspace, ".planning"), { recursive: true, force: true });
1459
+ await host.hook({ point: "prompt_submit", text: "/wtfp:advance" });
1460
+ assert.equal(reminderOf(await turnStart(host)), null, "no project, no reminder");
1461
+ }, DRIVEN_PLUGIN));
1462
+
1463
+ test("a status too long for one Clio effect is cut to 2,000 characters and points at the status tool", () =>
1464
+ withDesk(async (host, workspace) => {
1465
+ const outline = read(workspace, ".planning/structure/outline.json");
1466
+ const extra = Array.from({ length: 60 }, (_, index) => ({
1467
+ ...((outline.sections as Json[])[0] as Json),
1468
+ id: `appendix-measurement-detail-${String(index).padStart(2, "0")}`,
1469
+ title: `Appendix ${index}`,
1470
+ wave: 2,
1471
+ depends_on: ["introduction"],
1472
+ }));
1473
+ put(workspace, ".planning/structure/outline.json", { ...outline, sections: [...(outline.sections as Json[]), ...extra] });
1474
+ await host.hook({ point: "prompt_submit", text: "/wtfp:progress" });
1475
+ const message = reminderOf(await turnStart(host)) ?? "";
1476
+ assert.ok(message.length > 1990 && message.length <= 2000, `length ${message.length}`);
1477
+ assert.match(message, /… \(truncated; call extension_wtfp__status\)$/);
1478
+ assert.equal(((await host.tool("status", {})).data as { sections: Json[] }).sections.length, 61, "the full status stays one call away");
1479
+ }, SERVED));
1480
+
1481
+ // --- the manuscript write note ------------------------------------------------------
1482
+ // A write that changes a manuscript the armed action may measure gets one note on
1483
+ // its result naming the measure_section call. It spends none of the turn's shared
1484
+ // continuation budget, and the desk declares no turn_end hook at all.
1485
+
1486
+ const wrote = (host: Host, target: string, outcome: "ok" | "error" = "ok") =>
1487
+ host.hook({ point: "after_tool", tool: "write", turnId: "t1", outcome, durationMs: 1, args: { path: target } } as never);
1488
+ const noteOf = (result: { effects?: Array<{ kind: string }> }): string | null =>
1489
+ (result.effects?.find((effect) => effect.kind === "annotate_tool_result") as { message?: string } | undefined)?.message ?? null;
1490
+
1491
+ test("a manuscript write inside an action that may measure it is noted once with the exact measure_section call", () =>
1492
+ withDesk(async (host) => {
1493
+ assert.equal(noteOf(await wrote(host, "paper/introduction.md")), null, "nothing armed, no note");
1494
+ await host.hook({ point: "prompt_submit", text: "/wtfp:progress" });
1495
+ assert.equal(noteOf(await wrote(host, "paper/introduction.md")), null, "an action that declares no manuscript gets no note");
1496
+ await host.hook({ point: "prompt_submit", text: "/wtfp:write-section introduction" });
1497
+ assert.equal(noteOf(await wrote(host, "paper/introduction.md", "error")), null, "a failed write changed nothing");
1498
+ assert.equal(noteOf(await wrote(host, ".planning/sections/introduction/summary.md")), null, "only a manuscript is measured");
1499
+ const note = noteOf(await wrote(host, "paper/introduction.md")) ?? "";
1500
+ assert.match(note, /^WTF-P: paper\/introduction\.md is the manuscript of introduction/);
1501
+ assert.match(note, /gateway\(op="call", capability="extension_wtfp__measure_section", args=\{section: "introduction"\}\)/);
1502
+ assert.match(note, /A dispatched worker leaves this call to the action that dispatched it/);
1503
+ assert.equal(noteOf(await wrote(host, "paper/introduction.md")), null, "noted once per section");
1504
+ assert.match((await host.tool("measure_section", { section: "introduction" })).text, /has 11 body words/);
1505
+ assert.ok(noteOf(await wrote(host, "paper/introduction.md")), "a write after measuring is noted again");
1506
+ await host.observe({ event: "turn_end", turnId: "t1", outcome: "completed", usage: null });
1507
+ assert.equal(noteOf(await wrote(host, "paper/introduction.md")), null, "the turn's end disarms the note");
1508
+ }, SERVED));
1509
+
1510
+ test("inside an advance run only the armed step's manuscript writes are noted", () =>
1511
+ withDesk(async (host) => {
1512
+ await host.hook({ point: "prompt_submit", text: "/wtfp:advance" });
1513
+ assert.equal(noteOf(await wrote(host, "paper/introduction.md")), null, "an idle run measures nothing");
1514
+ await answer(host, GATE, "protocol-first");
1515
+ await answer(host, PLAN_GATE, "approve");
1516
+ assert.equal((await nextStep(host)).data.action, "write-section");
1517
+ assert.match(noteOf(await wrote(host, "paper/introduction.md")) ?? "", /args=\{section: "introduction"\}/);
1518
+ assert.equal((await nextStep(host)).data.finish, true, "an unchanged step is handed back once");
1519
+ assert.equal((await nextStep(host)).data.kind, "stop");
1520
+ assert.equal(noteOf(await wrote(host, "paper/introduction.md")), null, "after a stop nothing is armed to measure");
1521
+ }, DRIVEN_PLUGIN));
1522
+
1523
+ test("inside a WTF-P action every question goes to the author as one only the author may answer", () =>
1524
+ withDesk(async (host) => {
1525
+ const ask = (args: Json) => host.hook({ point: "before_tool", tool: "ask_user", turnId: "t1", args });
1526
+ const question = { question: "Lead with the protocol?", options: [{ label: "Yes" }, { label: "No" }] };
1527
+ assert.equal(rewriteOf(await ask({ action: "ask", questions: [question] })), null, "outside an action the desk leaves questions alone");
1528
+ await host.hook({ point: "prompt_submit", text: "/wtfp:discuss-section introduction" });
1529
+ const marked = rewriteOf(await ask({ action: "ask", questions: [question] }));
1530
+ assert.deepEqual((marked?.questions as Json[] | undefined)?.[0], { ...question, operator_only: true });
1531
+ assert.match(blocked(await ask({ action: "ask", questions: [question, { question: "And the venue?" }] })) ?? "", /one call at a time, each with operator_only: true and its own options/);
1532
+ assert.equal(rewriteOf(await ask({ action: "ask", questions: [{ ...question, operator_only: true }] })), null, "a question already marked passes unchanged");
1533
+ assert.equal(blocked(await ask({ action: "complete", decisions: [] })), null);
1534
+ await host.hook({ point: "prompt_submit", text: "/wtfp:advance" });
1535
+ assert.ok(rewriteOf(await ask({ action: "ask", questions: [question] })), "an advance turn marks them too");
1536
+ }, DRIVEN_PLUGIN));
1537
+
851
1538
  test("WTF-P workers are dispatched only inside their action and only to manuscripts that are ready (W3)", () =>
852
1539
  withDesk(async (host, workspace) => {
853
1540
  const dispatch = (args: Json) => host.hook({ point: "before_tool", tool: "dispatch", turnId: "t1", args });
@@ -863,11 +1550,16 @@ test("WTF-P workers are dispatched only inside their action and only to manuscri
863
1550
  assert.deepEqual(rootsOf(rewriteOf(narrowed)), [".planning/sections/introduction/summary.md", "paper/introduction.md", "paper/introduction/"]);
864
1551
  // Roots that already are the confinement, in any order, need no rewrite.
865
1552
  assert.equal(rewriteOf(await dispatch({ agent: "wtfp-section-writer", task: "Draft.", intent: { write_roots: ["paper/introduction/", "paper/introduction.md", ".planning/sections/introduction/summary.md"] } })), null);
1553
+ // Live, a local model named project:// URIs and a .planning/paper path; the refusal names the workspace roots it would accept.
1554
+ assert.match(
1555
+ blocked(await dispatch({ agent: "wtfp-section-writer", task: "Draft.", intent: { write_roots: ["project://paper/introduction", ".planning/paper/introduction.md"] } })) ?? "",
1556
+ /names write_roots .*\.planning\/paper\/introduction\.md.*project:.*which reach no manuscript .* give it intent\.write_roots .*paper\/introduction\.md.* \(workspace paths, not project:\/\/ URIs\)/,
1557
+ );
866
1558
  assert.match(
867
1559
  blocked(await dispatch({ tasks: [{ agent: "wtfp-section-writer", task: "a" }, { agent: "wtfp-section-writer", task: "b" }] })) ?? "",
868
1560
  /Clio: parallel writers need disjoint intent\.write_roots/,
869
1561
  );
870
- assert.match(blocked(await dispatch({ agent: "coder", task: "x", intent: { write_roots: ["src"] } })) ?? "", /lie outside what write-section may write/);
1562
+ assert.match(blocked(await dispatch({ agent: "coder", task: "x", intent: { write_roots: ["src"] } })) ?? "", /delegates only to wtfp-argument-verifier, wtfp-section-writer, and this call would start coder/);
871
1563
  assert.ok(existsSync(path.join(workspace, "paper/introduction.md")));
872
1564
  // A root the action itself grants is refused when a link makes it lead somewhere else.
873
1565
  symlinkSync(path.join(workspace, ".planning/sections"), path.join(workspace, "paper/introduction"));
@@ -957,8 +1649,21 @@ test("where Clio resolves a call's landing and dispatch plan, the desk judges wh
957
1649
  const reader = await dispatch({ agent: "auto", tasks: [{ task: "Review the introduction." }] }, plan(task("scout", { readOnly: true })));
958
1650
  assert.equal(blocked(reader), null);
959
1651
  assert.equal(rewriteOf(reader), null);
960
- // The desk takes that from Clio: a reviewer Clio does not report read-only is confined like any writer.
961
- assert.deepEqual(rootsOf(rewriteOf(await dispatch({ agent: "wtfp-section-reviewer", tasks: [{ task: "Review." }] }, plan(task("wtfp-section-reviewer"))))), roots);
1652
+ // The desk takes that from Clio: a verifier Clio does not report read-only is confined like any writer.
1653
+ assert.deepEqual(rootsOf(rewriteOf(await dispatch({ agent: "wtfp-argument-verifier", tasks: [{ task: "Verify." }] }, plan(task("wtfp-argument-verifier"))))), roots);
1654
+ // A writer the action does not delegate to is refused by name, as is Clio's default worker when the call names no agent.
1655
+ assert.match(blocked(await dispatch({ agent: "wtfp-section-reviewer", tasks: [{ task: "Review." }] }, plan(task("wtfp-section-reviewer")))) ?? "", /delegates only to wtfp-argument-verifier, wtfp-section-writer, and this call would start wtfp-section-reviewer/);
1656
+ assert.match(blocked(await dispatch({ tasks: [{ task: "Draft." }] }, plan(task("coder")))) ?? "", /would start coder; name the role with agent \(for example agent: "wtfp-section-writer"\)/);
1657
+ assert.match(
1658
+ blocked(await dispatch({ agent: "wtfp-argument-verifier", task: "x", intent: { write_roots: ["src"] } }, plan(task("wtfp-argument-verifier", { writeRoots: ["src"], writeBoundaries: [path.join(real, "src")] })))) ?? "",
1659
+ /src lie outside what write-section may write/,
1660
+ );
1661
+ // A declared empty write_roots is no boundary to the worker, and Clio refuses a rewrite that fills it, so the desk names the roots.
1662
+ assert.match(
1663
+ blocked(await dispatch({ agent: "wtfp-section-writer", task: "Draft.", intent: { read_roots: [".planning"], write_roots: [] } }, plan(task("wtfp-section-writer")))) ?? "",
1664
+ /intent without write_roots bounds nothing.*Send intent\.write_roots \.planning\/sections\/introduction\/summary\.md, paper\/introduction\.md, paper\/introduction\//,
1665
+ );
1666
+ assert.match(blocked(await dispatch({ agent: "wtfp-section-writer", task: "Draft.", intent: { read_roots: [".planning"] } }, plan(task("wtfp-section-writer")))) ?? "", /intent without write_roots/);
962
1667
  // A task Clio keeps as a string is confined as a task object, and Clio's private keys are left for Clio to recompute.
963
1668
  const spelled = await dispatch({ agent: "wtfp-section-writer", tasks: ["Draft."], __clio_resolved_dispatch_plan: { resolvedBy: "clio" } }, plan(task("wtfp-section-writer")));
964
1669
  assert.deepEqual(rewriteOf(spelled), { agent: "wtfp-section-writer", tasks: [{ task: "Draft.", intent: { write_roots: roots } }] });
@@ -1305,12 +2010,25 @@ test("measure_section counts body words by the desk's one method and commits the
1305
2010
  withDesk(async (host, workspace) => {
1306
2011
  const measured = await host.tool("measure_section", { section: "introduction" });
1307
2012
  assert.equal(measured.isError, undefined, measured.text);
1308
- assert.deepEqual(measured.data, { words: 11, target: 100, file: "paper/introduction.md", total: 11 });
2013
+ assert.deepEqual(measured.data, { words: 11, target: 100, file: "paper/introduction.md", total: 11, recorded: true });
1309
2014
  assert.equal(read(workspace, ".planning/sections/introduction/section.json").word_count, 11);
1310
2015
  assert.equal((read(workspace, ".planning/state.json").progress as Json).word_count, 11);
1311
2016
  assert.equal(read(workspace, ".planning/state.json").revision, 4);
1312
2017
  }));
1313
2018
 
2019
+ test("an action that may not record a count still gets the desk's count instead of counting by hand", () =>
2020
+ withDesk(async (host, workspace) => {
2021
+ // Live, review-section was refused measure_section and the model counted words with a script.
2022
+ await host.hook({ point: "prompt_submit", text: "/wtfp:review-section introduction" });
2023
+ const before = read(workspace, ".planning/state.json").revision;
2024
+ const measured = await host.tool("measure_section", { section: "introduction" });
2025
+ assert.equal(measured.isError, undefined, measured.text);
2026
+ assert.equal((measured.data as Json).words, 11);
2027
+ assert.equal((measured.data as Json).recorded, false);
2028
+ assert.match(measured.text, /Not recorded: .*review-section does not update the section's word count; use this count instead of counting by hand/);
2029
+ assert.equal(read(workspace, ".planning/state.json").revision, before, "nothing was written");
2030
+ }, DRIVEN_PLUGIN));
2031
+
1314
2032
  test("a failure between paired writes leaves a journal the next write completes; one before the commit point leaves nothing (R2)", () =>
1315
2033
  withDesk(async (host, workspace) => {
1316
2034
  process.env.WTFP_DESK_TEST_FAULT = "between-renames";