@caupulican/pi-adaptative 0.94.1 → 0.96.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (369) hide show
  1. package/CHANGELOG.md +58 -0
  2. package/dist/bundled-resources/extensions/tmux-agent-manager/README.md +32 -13
  3. package/dist/bundled-resources/extensions/tmux-agent-manager/index.d.ts +7 -4
  4. package/dist/bundled-resources/extensions/tmux-agent-manager/index.d.ts.map +1 -1
  5. package/dist/bundled-resources/extensions/tmux-agent-manager/index.js +201 -293
  6. package/dist/bundled-resources/extensions/tmux-agent-manager/index.js.map +1 -1
  7. package/dist/bundled-resources/extensions/tmux-agent-manager/index.ts +272 -392
  8. package/dist/bundled-resources/extensions/tmux-agent-manager/launch-profile.d.ts +52 -0
  9. package/dist/bundled-resources/extensions/tmux-agent-manager/launch-profile.d.ts.map +1 -0
  10. package/dist/bundled-resources/extensions/tmux-agent-manager/launch-profile.js +118 -0
  11. package/dist/bundled-resources/extensions/tmux-agent-manager/launch-profile.js.map +1 -0
  12. package/dist/bundled-resources/extensions/tmux-agent-manager/launch-profile.ts +169 -0
  13. package/dist/bundled-resources/extensions/tmux-agent-manager/templates/builder-validator.json +1 -1
  14. package/dist/bundled-resources/extensions/tmux-agent-manager/templates/provider-prompt-smoke.json +1 -1
  15. package/dist/bundled-resources/extensions/tps/index.d.ts +3 -0
  16. package/dist/bundled-resources/extensions/tps/index.d.ts.map +1 -0
  17. package/dist/bundled-resources/extensions/tps/index.js +44 -0
  18. package/dist/bundled-resources/extensions/tps/index.js.map +1 -0
  19. package/dist/bundled-resources/extensions/tps/index.ts +48 -0
  20. package/dist/bundled-resources/skills/pi-harness-learning/SKILL.md +13 -7
  21. package/dist/bundled-resources/skills/worker-profile-writer/SKILL.md +11 -11
  22. package/dist/core/agent-session-services.d.ts.map +1 -1
  23. package/dist/core/agent-session-services.js +12 -3
  24. package/dist/core/agent-session-services.js.map +1 -1
  25. package/dist/core/agent-session.d.ts +11 -41
  26. package/dist/core/agent-session.d.ts.map +1 -1
  27. package/dist/core/agent-session.js +93 -160
  28. package/dist/core/agent-session.js.map +1 -1
  29. package/dist/core/autonomy/envelope-enforcement.d.ts +6 -1
  30. package/dist/core/autonomy/envelope-enforcement.d.ts.map +1 -1
  31. package/dist/core/autonomy/envelope-enforcement.js +26 -25
  32. package/dist/core/autonomy/envelope-enforcement.js.map +1 -1
  33. package/dist/core/autonomy/lane-private-paths.d.ts.map +1 -1
  34. package/dist/core/autonomy/lane-private-paths.js +2 -1
  35. package/dist/core/autonomy/lane-private-paths.js.map +1 -1
  36. package/dist/core/autonomy/lane-tool-surface.d.ts +8 -8
  37. package/dist/core/autonomy/lane-tool-surface.d.ts.map +1 -1
  38. package/dist/core/autonomy/lane-tool-surface.js +45 -30
  39. package/dist/core/autonomy/lane-tool-surface.js.map +1 -1
  40. package/dist/core/autonomy/worker-session-private-scope.d.ts +12 -0
  41. package/dist/core/autonomy/worker-session-private-scope.d.ts.map +1 -0
  42. package/dist/core/autonomy/worker-session-private-scope.js +42 -0
  43. package/dist/core/autonomy/worker-session-private-scope.js.map +1 -0
  44. package/dist/core/autonomy/worker-tool-adapter-registry.d.ts +65 -0
  45. package/dist/core/autonomy/worker-tool-adapter-registry.d.ts.map +1 -0
  46. package/dist/core/autonomy/worker-tool-adapter-registry.js +145 -0
  47. package/dist/core/autonomy/worker-tool-adapter-registry.js.map +1 -0
  48. package/dist/core/background-lane-controller.d.ts +1 -1
  49. package/dist/core/background-lane-controller.d.ts.map +1 -1
  50. package/dist/core/background-lane-controller.js +1 -1
  51. package/dist/core/background-lane-controller.js.map +1 -1
  52. package/dist/core/background-tool-task-controller.d.ts +8 -2
  53. package/dist/core/background-tool-task-controller.d.ts.map +1 -1
  54. package/dist/core/background-tool-task-controller.js +10 -2
  55. package/dist/core/background-tool-task-controller.js.map +1 -1
  56. package/dist/core/compaction-controller.d.ts +3 -0
  57. package/dist/core/compaction-controller.d.ts.map +1 -1
  58. package/dist/core/compaction-controller.js +12 -1
  59. package/dist/core/compaction-controller.js.map +1 -1
  60. package/dist/core/cost-guard-controller.d.ts +37 -0
  61. package/dist/core/cost-guard-controller.d.ts.map +1 -0
  62. package/dist/core/cost-guard-controller.js +71 -0
  63. package/dist/core/cost-guard-controller.js.map +1 -0
  64. package/dist/core/cost-guard.d.ts +9 -4
  65. package/dist/core/cost-guard.d.ts.map +1 -1
  66. package/dist/core/cost-guard.js +7 -3
  67. package/dist/core/cost-guard.js.map +1 -1
  68. package/dist/core/delegation/worker-attempt-executor.d.ts +1 -1
  69. package/dist/core/delegation/worker-attempt-executor.d.ts.map +1 -1
  70. package/dist/core/delegation/worker-attempt-executor.js +0 -1
  71. package/dist/core/delegation/worker-attempt-executor.js.map +1 -1
  72. package/dist/core/delegation/worker-authority-resolver.d.ts +16 -3
  73. package/dist/core/delegation/worker-authority-resolver.d.ts.map +1 -1
  74. package/dist/core/delegation/worker-authority-resolver.js +114 -55
  75. package/dist/core/delegation/worker-authority-resolver.js.map +1 -1
  76. package/dist/core/delegation/worker-claim.d.ts +1 -2
  77. package/dist/core/delegation/worker-claim.d.ts.map +1 -1
  78. package/dist/core/delegation/worker-claim.js.map +1 -1
  79. package/dist/core/delegation/worker-delegation-controller.d.ts +19 -6
  80. package/dist/core/delegation/worker-delegation-controller.d.ts.map +1 -1
  81. package/dist/core/delegation/worker-delegation-controller.js +125 -40
  82. package/dist/core/delegation/worker-delegation-controller.js.map +1 -1
  83. package/dist/core/delegation/worker-delegation-request.d.ts +3 -3
  84. package/dist/core/delegation/worker-delegation-request.d.ts.map +1 -1
  85. package/dist/core/delegation/worker-delegation-request.js +13 -19
  86. package/dist/core/delegation/worker-delegation-request.js.map +1 -1
  87. package/dist/core/delegation/worker-execution-policy.d.ts +3 -2
  88. package/dist/core/delegation/worker-execution-policy.d.ts.map +1 -1
  89. package/dist/core/delegation/worker-execution-policy.js +54 -39
  90. package/dist/core/delegation/worker-execution-policy.js.map +1 -1
  91. package/dist/core/delegation/worker-fleet-limits.d.ts +3 -3
  92. package/dist/core/delegation/worker-fleet-limits.d.ts.map +1 -1
  93. package/dist/core/delegation/worker-fleet-limits.js +7 -7
  94. package/dist/core/delegation/worker-fleet-limits.js.map +1 -1
  95. package/dist/core/delegation/worker-machine-scope.d.ts +12 -0
  96. package/dist/core/delegation/worker-machine-scope.d.ts.map +1 -0
  97. package/dist/core/delegation/worker-machine-scope.js +38 -0
  98. package/dist/core/delegation/worker-machine-scope.js.map +1 -0
  99. package/dist/core/delegation/worker-recovery-coordinator.d.ts.map +1 -1
  100. package/dist/core/delegation/worker-recovery-coordinator.js +6 -1
  101. package/dist/core/delegation/worker-recovery-coordinator.js.map +1 -1
  102. package/dist/core/delegation/worker-runner.d.ts +5 -7
  103. package/dist/core/delegation/worker-runner.d.ts.map +1 -1
  104. package/dist/core/delegation/worker-runner.js +1 -4
  105. package/dist/core/delegation/worker-runner.js.map +1 -1
  106. package/dist/core/delegation/worker-write-reservation-coordinator.d.ts +3 -2
  107. package/dist/core/delegation/worker-write-reservation-coordinator.d.ts.map +1 -1
  108. package/dist/core/delegation/worker-write-reservation-coordinator.js +50 -25
  109. package/dist/core/delegation/worker-write-reservation-coordinator.js.map +1 -1
  110. package/dist/core/durable-custom-message-turn-controller.d.ts +6 -0
  111. package/dist/core/durable-custom-message-turn-controller.d.ts.map +1 -1
  112. package/dist/core/durable-custom-message-turn-controller.js +38 -15
  113. package/dist/core/durable-custom-message-turn-controller.js.map +1 -1
  114. package/dist/core/extension-binding-controller.d.ts +5 -1
  115. package/dist/core/extension-binding-controller.d.ts.map +1 -1
  116. package/dist/core/extension-binding-controller.js +15 -0
  117. package/dist/core/extension-binding-controller.js.map +1 -1
  118. package/dist/core/extension-import-authority.d.ts +3 -1
  119. package/dist/core/extension-import-authority.d.ts.map +1 -1
  120. package/dist/core/extension-import-authority.js +15 -0
  121. package/dist/core/extension-import-authority.js.map +1 -1
  122. package/dist/core/extensions/factory-runtime.d.ts.map +1 -1
  123. package/dist/core/extensions/factory-runtime.js +5 -0
  124. package/dist/core/extensions/factory-runtime.js.map +1 -1
  125. package/dist/core/extensions/runner.d.ts.map +1 -1
  126. package/dist/core/extensions/runner.js +1 -0
  127. package/dist/core/extensions/runner.js.map +1 -1
  128. package/dist/core/extensions/types.d.ts +8 -4
  129. package/dist/core/extensions/types.d.ts.map +1 -1
  130. package/dist/core/extensions/types.js.map +1 -1
  131. package/dist/core/foreground-terminal-handoff-controller.d.ts +14 -0
  132. package/dist/core/foreground-terminal-handoff-controller.d.ts.map +1 -1
  133. package/dist/core/foreground-terminal-handoff-controller.js +188 -72
  134. package/dist/core/foreground-terminal-handoff-controller.js.map +1 -1
  135. package/dist/core/goals/goal-session-controller.d.ts +2 -0
  136. package/dist/core/goals/goal-session-controller.d.ts.map +1 -1
  137. package/dist/core/goals/goal-session-controller.js +8 -0
  138. package/dist/core/goals/goal-session-controller.js.map +1 -1
  139. package/dist/core/goals/goal-tool-core.d.ts +5 -4
  140. package/dist/core/goals/goal-tool-core.d.ts.map +1 -1
  141. package/dist/core/goals/goal-tool-core.js +23 -19
  142. package/dist/core/goals/goal-tool-core.js.map +1 -1
  143. package/dist/core/keybindings.d.ts +2 -2
  144. package/dist/core/keybindings.d.ts.map +1 -1
  145. package/dist/core/keybindings.js +2 -2
  146. package/dist/core/keybindings.js.map +1 -1
  147. package/dist/core/learning/auto-learn-settings.d.ts +84 -0
  148. package/dist/core/learning/auto-learn-settings.d.ts.map +1 -0
  149. package/dist/core/learning/auto-learn-settings.js +66 -0
  150. package/dist/core/learning/auto-learn-settings.js.map +1 -0
  151. package/dist/core/learning/reflection-engine.d.ts +4 -0
  152. package/dist/core/learning/reflection-engine.d.ts.map +1 -1
  153. package/dist/core/learning/reflection-engine.js +48 -10
  154. package/dist/core/learning/reflection-engine.js.map +1 -1
  155. package/dist/core/local-prefix-warm-controller.d.ts +24 -0
  156. package/dist/core/local-prefix-warm-controller.d.ts.map +1 -0
  157. package/dist/core/local-prefix-warm-controller.js +79 -0
  158. package/dist/core/local-prefix-warm-controller.js.map +1 -0
  159. package/dist/core/memory/providers/file-store.d.ts +2 -0
  160. package/dist/core/memory/providers/file-store.d.ts.map +1 -1
  161. package/dist/core/memory/providers/file-store.js +71 -15
  162. package/dist/core/memory/providers/file-store.js.map +1 -1
  163. package/dist/core/memory/worker-memory-tools.d.ts +5 -0
  164. package/dist/core/memory/worker-memory-tools.d.ts.map +1 -0
  165. package/dist/core/memory/worker-memory-tools.js +5 -0
  166. package/dist/core/memory/worker-memory-tools.js.map +1 -0
  167. package/dist/core/model-capability.d.ts +7 -0
  168. package/dist/core/model-capability.d.ts.map +1 -1
  169. package/dist/core/model-capability.js +12 -0
  170. package/dist/core/model-capability.js.map +1 -1
  171. package/dist/core/model-registry.d.ts.map +1 -1
  172. package/dist/core/model-registry.js +2 -10
  173. package/dist/core/model-registry.js.map +1 -1
  174. package/dist/core/model-router-controller.d.ts +3 -2
  175. package/dist/core/model-router-controller.d.ts.map +1 -1
  176. package/dist/core/model-router-controller.js +3 -2
  177. package/dist/core/model-router-controller.js.map +1 -1
  178. package/dist/core/orchestration/contracts.d.ts +16 -12
  179. package/dist/core/orchestration/contracts.d.ts.map +1 -1
  180. package/dist/core/orchestration/contracts.js +2 -2
  181. package/dist/core/orchestration/contracts.js.map +1 -1
  182. package/dist/core/orchestration/lane-tool-manifests.d.ts +2 -2
  183. package/dist/core/orchestration/lane-tool-manifests.d.ts.map +1 -1
  184. package/dist/core/orchestration/lane-tool-manifests.js +6 -1
  185. package/dist/core/orchestration/lane-tool-manifests.js.map +1 -1
  186. package/dist/core/orchestration/profile-registry.d.ts.map +1 -1
  187. package/dist/core/orchestration/profile-registry.js +14 -0
  188. package/dist/core/orchestration/profile-registry.js.map +1 -1
  189. package/dist/core/orchestration/task-profile-writer.d.ts +7 -4
  190. package/dist/core/orchestration/task-profile-writer.d.ts.map +1 -1
  191. package/dist/core/orchestration/task-profile-writer.js +71 -59
  192. package/dist/core/orchestration/task-profile-writer.js.map +1 -1
  193. package/dist/core/orchestration/thinking-level-schema.d.ts +7 -0
  194. package/dist/core/orchestration/thinking-level-schema.d.ts.map +1 -0
  195. package/dist/core/orchestration/thinking-level-schema.js +19 -0
  196. package/dist/core/orchestration/thinking-level-schema.js.map +1 -0
  197. package/dist/core/orchestration/worker-execution-contract.d.ts.map +1 -1
  198. package/dist/core/orchestration/worker-execution-contract.js +12 -5
  199. package/dist/core/orchestration/worker-execution-contract.js.map +1 -1
  200. package/dist/core/profile-filter-controller.d.ts.map +1 -1
  201. package/dist/core/profile-filter-controller.js +5 -2
  202. package/dist/core/profile-filter-controller.js.map +1 -1
  203. package/dist/core/provider-prompt-contracts.d.ts +6 -5
  204. package/dist/core/provider-prompt-contracts.d.ts.map +1 -1
  205. package/dist/core/provider-prompt-contracts.js +9 -11
  206. package/dist/core/provider-prompt-contracts.js.map +1 -1
  207. package/dist/core/provider-request-context-controller.d.ts +2 -0
  208. package/dist/core/provider-request-context-controller.d.ts.map +1 -1
  209. package/dist/core/provider-request-context-controller.js +10 -3
  210. package/dist/core/provider-request-context-controller.js.map +1 -1
  211. package/dist/core/reflection-controller.d.ts +56 -27
  212. package/dist/core/reflection-controller.d.ts.map +1 -1
  213. package/dist/core/reflection-controller.js +206 -117
  214. package/dist/core/reflection-controller.js.map +1 -1
  215. package/dist/core/resource-loader.d.ts.map +1 -1
  216. package/dist/core/resource-loader.js +6 -2
  217. package/dist/core/resource-loader.js.map +1 -1
  218. package/dist/core/risk-classifier.d.ts.map +1 -1
  219. package/dist/core/risk-classifier.js +22 -2
  220. package/dist/core/risk-classifier.js.map +1 -1
  221. package/dist/core/runtime-builder.d.ts +1 -0
  222. package/dist/core/runtime-builder.d.ts.map +1 -1
  223. package/dist/core/runtime-builder.js +25 -14
  224. package/dist/core/runtime-builder.js.map +1 -1
  225. package/dist/core/secrets/credential-exposure-guard.d.ts.map +1 -1
  226. package/dist/core/secrets/credential-exposure-guard.js +55 -10
  227. package/dist/core/secrets/credential-exposure-guard.js.map +1 -1
  228. package/dist/core/session-role.d.ts +6 -8
  229. package/dist/core/session-role.d.ts.map +1 -1
  230. package/dist/core/session-role.js +8 -18
  231. package/dist/core/session-role.js.map +1 -1
  232. package/dist/core/settings-manager.d.ts +20 -16
  233. package/dist/core/settings-manager.d.ts.map +1 -1
  234. package/dist/core/settings-manager.js +75 -50
  235. package/dist/core/settings-manager.js.map +1 -1
  236. package/dist/core/skill-vault.d.ts +15 -0
  237. package/dist/core/skill-vault.d.ts.map +1 -1
  238. package/dist/core/skill-vault.js +79 -45
  239. package/dist/core/skill-vault.js.map +1 -1
  240. package/dist/core/skills.d.ts +3 -0
  241. package/dist/core/skills.d.ts.map +1 -1
  242. package/dist/core/skills.js +6 -6
  243. package/dist/core/skills.js.map +1 -1
  244. package/dist/core/system-prompt-builder.d.ts +3 -0
  245. package/dist/core/system-prompt-builder.d.ts.map +1 -1
  246. package/dist/core/system-prompt-builder.js +73 -13
  247. package/dist/core/system-prompt-builder.js.map +1 -1
  248. package/dist/core/system-prompt.d.ts.map +1 -1
  249. package/dist/core/system-prompt.js +6 -2
  250. package/dist/core/system-prompt.js.map +1 -1
  251. package/dist/core/tool-capability-policy.d.ts +3 -0
  252. package/dist/core/tool-capability-policy.d.ts.map +1 -1
  253. package/dist/core/tool-capability-policy.js +13 -2
  254. package/dist/core/tool-capability-policy.js.map +1 -1
  255. package/dist/core/toolkit/script-runner.d.ts +2 -1
  256. package/dist/core/toolkit/script-runner.d.ts.map +1 -1
  257. package/dist/core/toolkit/script-runner.js +10 -2
  258. package/dist/core/toolkit/script-runner.js.map +1 -1
  259. package/dist/core/tools/delegate-status.d.ts +1 -1
  260. package/dist/core/tools/delegate-status.d.ts.map +1 -1
  261. package/dist/core/tools/delegate-status.js +1 -1
  262. package/dist/core/tools/delegate-status.js.map +1 -1
  263. package/dist/core/tools/delegate.d.ts +4 -15
  264. package/dist/core/tools/delegate.d.ts.map +1 -1
  265. package/dist/core/tools/delegate.js +111 -73
  266. package/dist/core/tools/delegate.js.map +1 -1
  267. package/dist/core/tools/goal.d.ts +3 -4
  268. package/dist/core/tools/goal.d.ts.map +1 -1
  269. package/dist/core/tools/goal.js +30 -23
  270. package/dist/core/tools/goal.js.map +1 -1
  271. package/dist/core/tools/orchestration-panel.d.ts +7 -0
  272. package/dist/core/tools/orchestration-panel.d.ts.map +1 -1
  273. package/dist/core/tools/orchestration-panel.js +58 -9
  274. package/dist/core/tools/orchestration-panel.js.map +1 -1
  275. package/dist/core/tools/profile-writer.d.ts +2 -8
  276. package/dist/core/tools/profile-writer.d.ts.map +1 -1
  277. package/dist/core/tools/profile-writer.js +6 -18
  278. package/dist/core/tools/profile-writer.js.map +1 -1
  279. package/dist/core/tools/run-toolkit-script.d.ts +1 -1
  280. package/dist/core/tools/run-toolkit-script.d.ts.map +1 -1
  281. package/dist/core/tools/run-toolkit-script.js +2 -2
  282. package/dist/core/tools/run-toolkit-script.js.map +1 -1
  283. package/dist/core/tools/skill-audit.d.ts +28 -1
  284. package/dist/core/tools/skill-audit.d.ts.map +1 -1
  285. package/dist/core/tools/skill-audit.js +56 -12
  286. package/dist/core/tools/skill-audit.js.map +1 -1
  287. package/dist/core/tools/skill.d.ts +12 -1
  288. package/dist/core/tools/skill.d.ts.map +1 -1
  289. package/dist/core/tools/skill.js +52 -0
  290. package/dist/core/tools/skill.js.map +1 -1
  291. package/dist/core/tools/skillify.d.ts.map +1 -1
  292. package/dist/core/tools/skillify.js +16 -7
  293. package/dist/core/tools/skillify.js.map +1 -1
  294. package/dist/core/tools/task-steps.d.ts.map +1 -1
  295. package/dist/core/tools/task-steps.js +2 -1
  296. package/dist/core/tools/task-steps.js.map +1 -1
  297. package/dist/core/tools/tmux-dispatch.d.ts +4 -16
  298. package/dist/core/tools/tmux-dispatch.d.ts.map +1 -1
  299. package/dist/core/tools/tmux-dispatch.js +5 -20
  300. package/dist/core/tools/tmux-dispatch.js.map +1 -1
  301. package/dist/core/worktree-sync/codes.d.ts +1 -2
  302. package/dist/core/worktree-sync/codes.d.ts.map +1 -1
  303. package/dist/core/worktree-sync/codes.js +1 -2
  304. package/dist/core/worktree-sync/codes.js.map +1 -1
  305. package/dist/core/worktree-sync/lane-gate.d.ts +4 -8
  306. package/dist/core/worktree-sync/lane-gate.d.ts.map +1 -1
  307. package/dist/core/worktree-sync/lane-gate.js +5 -51
  308. package/dist/core/worktree-sync/lane-gate.js.map +1 -1
  309. package/dist/index.d.ts +5 -0
  310. package/dist/index.d.ts.map +1 -1
  311. package/dist/index.js +7 -0
  312. package/dist/index.js.map +1 -1
  313. package/dist/modes/interactive/auto-learn-controller.d.ts +6 -7
  314. package/dist/modes/interactive/auto-learn-controller.d.ts.map +1 -1
  315. package/dist/modes/interactive/auto-learn-controller.js +30 -207
  316. package/dist/modes/interactive/auto-learn-controller.js.map +1 -1
  317. package/dist/modes/interactive/autonomy-commands.js +2 -2
  318. package/dist/modes/interactive/autonomy-commands.js.map +1 -1
  319. package/dist/modes/interactive/components/agents-overlay.d.ts +16 -4
  320. package/dist/modes/interactive/components/agents-overlay.d.ts.map +1 -1
  321. package/dist/modes/interactive/components/agents-overlay.js +108 -29
  322. package/dist/modes/interactive/components/agents-overlay.js.map +1 -1
  323. package/dist/modes/interactive/components/custom-message.js +17 -0
  324. package/dist/modes/interactive/components/custom-message.js.map +1 -1
  325. package/dist/modes/interactive/components/fitness-role-selector.d.ts.map +1 -1
  326. package/dist/modes/interactive/components/fitness-role-selector.js +2 -2
  327. package/dist/modes/interactive/components/fitness-role-selector.js.map +1 -1
  328. package/dist/modes/interactive/components/footer.js +1 -1
  329. package/dist/modes/interactive/components/footer.js.map +1 -1
  330. package/dist/modes/interactive/components/settings-selector.d.ts +4 -0
  331. package/dist/modes/interactive/components/settings-selector.d.ts.map +1 -1
  332. package/dist/modes/interactive/components/settings-selector.js +150 -73
  333. package/dist/modes/interactive/components/settings-selector.js.map +1 -1
  334. package/dist/modes/interactive/interactive-mode.d.ts.map +1 -1
  335. package/dist/modes/interactive/interactive-mode.js +5 -4
  336. package/dist/modes/interactive/interactive-mode.js.map +1 -1
  337. package/dist/modes/interactive/report-commands.d.ts.map +1 -1
  338. package/dist/modes/interactive/report-commands.js +8 -4
  339. package/dist/modes/interactive/report-commands.js.map +1 -1
  340. package/dist/modes/interactive/settings-selector-flow.d.ts.map +1 -1
  341. package/dist/modes/interactive/settings-selector-flow.js +10 -0
  342. package/dist/modes/interactive/settings-selector-flow.js.map +1 -1
  343. package/docs/extensions.md +10 -0
  344. package/docs/harness-architecture.md +28 -32
  345. package/docs/index.md +2 -1
  346. package/docs/keybindings.md +2 -0
  347. package/docs/process-matrix.md +8 -6
  348. package/docs/resources.md +1 -1
  349. package/docs/settings.md +61 -51
  350. package/docs/task-steps.md +2 -0
  351. package/docs/tmux-agent-manager.md +48 -41
  352. package/docs/usage.md +1 -1
  353. package/docs/work-lifecycle.md +137 -0
  354. package/docs/worker-profiles.md +8 -6
  355. package/docs/worktree-sync.md +26 -20
  356. package/examples/extensions/custom-provider-anthropic/package-lock.json +2 -2
  357. package/examples/extensions/custom-provider-anthropic/package.json +1 -1
  358. package/examples/extensions/custom-provider-gitlab-duo/package.json +1 -1
  359. package/examples/extensions/sandbox/package-lock.json +2 -2
  360. package/examples/extensions/sandbox/package.json +1 -1
  361. package/examples/extensions/with-deps/package-lock.json +2 -2
  362. package/examples/extensions/with-deps/package.json +1 -1
  363. package/npm-shrinkwrap.json +12 -12
  364. package/package.json +4 -4
  365. package/dist/bundled-resources/extensions/tmux-agent-manager/dispatch-grant.d.ts +0 -133
  366. package/dist/bundled-resources/extensions/tmux-agent-manager/dispatch-grant.d.ts.map +0 -1
  367. package/dist/bundled-resources/extensions/tmux-agent-manager/dispatch-grant.js +0 -199
  368. package/dist/bundled-resources/extensions/tmux-agent-manager/dispatch-grant.js.map +0 -1
  369. package/dist/bundled-resources/extensions/tmux-agent-manager/dispatch-grant.ts +0 -312
package/docs/resources.md CHANGED
@@ -49,7 +49,7 @@ A profile may also bind a **model**, **thinking level**, **soul**, and **modelRo
49
49
 
50
50
  Pi activates the complete situation as one runtime generation: model/router, thinking, soul, extensions, skills, prompts, agents, themes, and tools are reloaded together. A failed reload restores the prior valid generation instead of persisting a partial selection.
51
51
 
52
- Built-in research lanes still use a fixed read-only profile with `read`, `grep`, `find`, and `ls`. Native worker agents use a different contract: orchestration profiles are optional presets, a profile-free root receives the maximum host-permitted classified core surface, and descendants inherit immutable authority while retaining recursive `delegate`, peer-transcript, messaging, memory, write/edit, and platform-shell capabilities when their parent and live service switches permit them. Lane tool globs expand to exact classified names. Opaque extension tools without orchestration metadata are not guessed into a child surface, and an explicit tool request that cannot be materialized is rejected visibly.
52
+ Built-in research lanes still use a fixed read-only profile with `read`, `grep`, `find`, and `ls`. Native worker agents use a different contract: orchestration profiles are optional presets, a profile-free worker inherits the foreground model, thinking level, every compatible classified core tool, and machine-wide scope permitted by the host. Workers are root-managed leaves: they never receive `delegate`, reflection, or memory-mutation authority and cannot spawn descendants. Top-level `model`, `thinkingLevel`, `path`, and `toolNames` overrides can narrow or focus the inherited worker surface. Lane tool globs expand to exact classified names. Opaque extension tools without orchestration metadata are not guessed into a worker surface, and an explicit tool request that cannot be materialized is rejected visibly.
53
53
 
54
54
  Profiles are stored in settings under `resourceProfiles`, and the active one(s) in `activeResourceProfile`:
55
55
 
package/docs/settings.md CHANGED
@@ -113,7 +113,7 @@ The agent is instructed to edit only that source checkout, preserve unrelated ch
113
113
  | `autonomy.mode` | string | `"off"` | Low-config autonomy preset: `"off"`, `"safe"`, `"balanced"`, or `"full"` |
114
114
  | `autonomy.maxStallTurns` | number | `20` | Maximum provider rounds in one foreground goal loop before Pi stops continuing |
115
115
 
116
- Use `/settings` → **Autonomy** to choose one preset and the foreground goal-loop round budget, or `/autonomy off|safe|balanced|full` to switch the preset while preserving the configured round budget. `full` is the standing-autonomy mode: it schedules post-turn reflection whenever concurrency allows and grants autonomous authority for high-confidence memory writes, user/project skill creation or patching, small user/project extension/tool improvements, autonomy/Auto Learn setting tuning, and edits under the authorized `selfModification.sourcePath` when validation and rollback evidence are recorded.
116
+ Use `/settings` → **Autonomy** to choose one preset and the foreground goal-loop round budget, or `/autonomy off|safe|balanced|full` to switch the preset while preserving the configured round budget. Main-session reflection is enabled in every mode, including `off`; eligible turns queue a durable root-only cue for the orchestrator's next ordinary current-session provider turn. It does not create a separate or background model request, and increasing autonomy never disables learning. `full` additionally grants standing authority for broader user/project skill, extension/tool, autonomy-setting, and authorized self-modification work when validation and rollback evidence are recorded.
117
117
 
118
118
  Hard stops still require explicit foreground approval even in `full`: publishing, npm release, git push, tag creation, credential disclosure or provider-auth changes, destructive user-data deletion, network-exposed services, or authority expansion beyond this policy. An active user-plane `secret_store` grant is the narrow exception: model-blind activation and migration from named accessible sources require no duplicate confirmation. `/autonomy status` shows the active grant and the Auto Learn audit/log directory.
119
119
 
@@ -135,10 +135,10 @@ Hard stops still require explicit foreground approval even in `full`: publishing
135
135
  | `modelRouter.cheapModel` | string | - | Model pattern for read-only, research, explanation, and question turns |
136
136
  | `modelRouter.mediumModel` | string | - | Model pattern for scoped implementation/planning turns |
137
137
  | `modelRouter.expensiveModel` | string | - | Model pattern for high-impact, modify, implementation, and escalated tool-heavy turns |
138
- | `modelRouter.learningModel` | string | `"active"` | Model pattern for background reflection, learn, and skill-creator work; `"active"` uses the current session model |
138
+ | `modelRouter.learningModel` | string | `"active"` | Model pattern for explicit/background Auto Learn, learn, and skill-creator work; automatic reflection uses the orchestrator's current session turn; `"active"` uses the current session model |
139
139
  | `failover.subscriptionHop` | boolean | `true` | Allow subscription/OAuth quota failures to switch once to an authenticated provider default; metered/API-key quota failures always halt for explicit user choice |
140
140
 
141
- Use `/settings` → **Model Router** to configure these fields globally or for the current project's `.pi/settings.json`. `/session` and `/usage` show the active router state, diagnostics, and per-tier fitness when the gate is enabled. Profile files can also include a `modelRouter` block so a situation can carry its own cheap, medium, expensive, and learning/reflection models together with its model, thinking level, soul, and resource filters.
141
+ Use `/settings` → **Model Router** to configure these fields globally or for the current project's `.pi/settings.json`. `/session` and `/usage` show the active router state, diagnostics, and per-tier fitness when the gate is enabled. Profile files can also include a `modelRouter` block so a situation can carry its own cheap, medium, expensive, and learning model together with its model, thinking level, soul, and resource filters. Automatic reflection does not select a separate reflection model.
142
142
 
143
143
  Fitness applicability is intentionally split by autonomy level:
144
144
 
@@ -162,17 +162,17 @@ Fitness applicability is intentionally split by autonomy level:
162
162
 
163
163
  ### Worker Delegation
164
164
 
165
- Pi's native delegation runtime is a durable recursive agent tree. A profile is not required. A profile-free root agent starts from the foreground model and the maximum classified core worker surface the host can materialize: `read`, `grep`, `find`, `ls`, `write`, `edit`, `memory`, the platform shell, and `delegate`. Live service switches can revoke memory, writes, or delegation. Every descendant inherits its parent's immutable execution grant and the tree's remaining budget by default.
165
+ Pi's native delegation runtime manages durable, persistent leaf workers. A profile is not required. A fresh worker inherits the foreground model, live thinking level, and every active classified tool the native lane can materialize. It receives machine-wide read/write/process/network authority by default while raw Pi auth, session, settings, and memory state remain denied. Workers never receive `delegate`, descendant spawning, reflection, or memory mutation.
166
166
 
167
- Whenever `delegate` is active, root and worker prompts use the same provider-neutral decision rule: delegate useful independent research, implementation, tests, or specialist review early; keep dependent or trivial work local. Reasoning level, provider identity, and model identity do not enable or suppress that policy; the model-capability profile may still narrow tools for very small context windows.
167
+ Whenever `delegate` is active, the root prompt uses a provider-neutral decision rule: delegate useful independent research, implementation, tests, or specialist review early; keep dependent or trivial work local. Reasoning level, provider identity, and model identity do not enable or suppress that policy; the model-capability profile may still narrow tools for very small context windows.
168
168
 
169
- An agent may set `authority` on `delegate` to choose its child's role label, authenticated model, supported reasoning level, and classified tool names. Omitted fields inherit from the parent or selected preset. The model-facing start schema has no per-dispatch budget field: ordinary starts inherit the unbounded baseline, host settings, or an owner-authored profile ceiling. The host validates the request, resolves the concrete model and tools, intersects execution authority with the immutable parent grant and live global switches, then persists the exact result before the child starts. A descendant can specialize or narrow authority but cannot add an execution capability, tool, path, or budget that the parent did not hold. Profile selection also cannot add context: every child resource pointer must fully match an ancestral pointer (ID alone is insufficient), soul text must match exactly, and a verifier stays within its previously admitted ancestral verifier or worker boundary. Roles are descriptive routing and audit labels; the built-in compiler does not impose hidden role ceilings, though an embedding may supply an explicit host ceiling.
169
+ For a fresh `delegate start`, the orchestrator may optionally set `model`, `thinkingLevel`, one `path`, and `toolNames`. Omitted fields inherit. `path` changes the worker's real working directory and narrows direct read/write authority to that workspace; omitting it keeps the parent working directory for process execution without narrowing machine scope. Tool overrides may only narrow the compatible inherited surface and an unavailable or root-only requested tool fails admission instead of being silently ignored. The host derives capabilities and paths, applies global kill switches and private-state denials, and persists the exact immutable grant before execution. Reusing an `agentId` keeps its admitted grant and transcript, so overrides are rejected on reuse.
170
170
 
171
- `workerDelegation.modelPins` optionally lets the owner fix the provider, model, and thinking level used by each fresh worker role. With no pins, delegation keeps the adaptive behavior above exactly. An applicable pin overrides model/thinking chosen by `authority` or a preset, while role, tools, resources, paths, and budgets still follow normal admission. This applies to fresh top-level workers, fresh nested workers, and mandatory verifiers. The admitted binding is persisted and reported by `delegate start`; queued work, retries, resumes, recovery, and later tasks on a reused `agentId` keep that immutable contract even if settings change.
171
+ `workerDelegation.modelPins` optionally lets the owner fix the provider, model, and thinking level used by each fresh worker role. With no pins, delegation keeps the adaptive behavior above exactly. An applicable pin is a hard ceiling: a conflicting explicit `model` or `thinkingLevel` override fails closed with `worker_model_pin_conflict:<role>` instead of silently running a different model, while an omitted override uses the pin. Owner-authored preset bindings are still narrowed to the pin. Tools, resources, workspace, and budgets follow normal admission. This applies to fresh workers and mandatory verifiers. The admitted binding is persisted and reported by `delegate start`; queued work, retries, resumes, recovery, and later tasks on a reused `agentId` keep that immutable contract even if settings change.
172
172
 
173
173
  Pin precedence is deliberately different from ordinary deep-merged settings: global role, global default, trusted local role, trusted local default, then adaptive routing. A global default therefore wins over every project role. Within trusted local settings, the user-level directory overlay wins over the project file at the same role/default tier. Untrusted project settings are ignored. Every binding must contain an exact `provider`, `modelId`, and supported `thinkingLevel`. Malformed pin configuration blocks fresh worker admission with `worker_model_pins_invalid`; an unavailable applicable pin blocks with `worker_model_pin_unavailable:<role>`. Neither condition falls back to another model. Configure pins directly in JSON; `/settings` does not edit them.
174
174
 
175
- A `roles`-only configuration (no `default` in any scope) leaves every role not listed under `roles` entirely unpinned: a delegation using an unlisted role plus an explicit `authority.model` is not blocked, since there is no applicable pin to enforce, and it uses the caller-requested model exactly as ordinary adaptive routing would. This is expected, not an admission bug, but it is easy to configure by accident. The host surfaces it two ways so it stays observable: a settings diagnostic lists the unpinned roles whenever a `roles`-only policy compiles with no `default`, and a delegation that hits this gap (an active pin policy, no pin for the effective role, and an explicit requested model) reports `modelPinBypass: <role>` on its `delegate start` result. Add a `default` to close the gap for every role, or pin every role explicitly under `roles` if adaptive routing is never intended.
175
+ A `roles`-only configuration (no `default` in any scope) leaves every role not listed under `roles` unpinned. This is valid but easy to configure by accident, so settings diagnostics list unpinned roles. Add a `default` to close the gap for every role, or pin every role explicitly under `roles` if adaptive routing is never intended.
176
176
 
177
177
  ```json
178
178
  {
@@ -207,36 +207,22 @@ For a new logical agent, `forkTurns` chooses immutable sanitized birth context:
207
207
  "action": "start",
208
208
  "instructions": "Implement and verify the scheduler change.",
209
209
  "forkTurns": "3",
210
- "authority": {
211
- "role": "implementer",
212
- "model": { "provider": "openai-codex", "modelId": "gpt-5.5" },
213
- "thinkingLevel": "high",
214
- "capabilities": [
215
- "filesystem.read",
216
- "filesystem.write",
217
- "worktree.read",
218
- "worktree.mutate",
219
- "process.exec",
220
- "memory.query",
221
- "workflow.delegate"
222
- ],
223
- "toolNames": ["read", "grep", "find", "ls", "write", "edit", "memory", "bash", "delegate"],
224
- "readPaths": ["."],
225
- "writePaths": ["packages/coding-agent"],
226
- "budget": { "maxTokens": 32000, "maxCostUsd": 2, "maxToolCalls": 80 }
227
- }
210
+ "model": { "provider": "openai-codex", "modelId": "gpt-5.5" },
211
+ "thinkingLevel": "high",
212
+ "path": "/home/me/GitHub/project",
213
+ "toolNames": ["read", "grep", "find", "ls", "write", "edit", "python", "bash"]
228
214
  }
229
215
  ```
230
216
 
231
- Fleet creation is bounded before Pi creates a durable task, conversation, agent, or queue entry: depth is at most 8, one parent may own at most 64 direct children, one session may retain at most 256 logical agents, and the scheduler may retain at most 256 queued dispatches. The profile-free baseline is deliberately lean: the session may retain one nested identity at depth one, and that child is a leaf; additional root workers remain available and can reuse the retained specialists. An owner-authored profile may set `delegationLimits.maxDepth`, `delegationLimits.maxChildrenPerAgent`, and `delegationLimits.maxNestedAgentsPerSession` up to the host ceilings; omitted authored limits retain the host ceilings. Descendant profile selection intersects these limits with the ancestor's immutable contract and cannot widen them. Admission dynamically preserves queue and durable-projection headroom for every implementation whose mandatory verifier has not yet materialized, plus a newly admitted contract's verifier. A verifier dispatch that encounters saturation remains represented by its durable subject and replays on a queue-capacity event. The shared durable projection independently caps agents, tasks, and attempts at 256 each. `workerDelegation.maxConcurrent` remains the global running-agent limit; excess admitted work enters the bounded durable queue. The kernel also rejects an exact recursive cycle when a child repeats the same normalized instructions and effective profile already present in its ancestor chain. Root budgets are cumulative across every descendant and attempt: token, cost, tool-call, active-wall-clock, and attempt usage are reconstructed from durable checkpoints and checked before more work is admitted. The default delegation baseline adds no cost or active-time ceiling; positive global settings, profile budgets, and inherited foreground ceilings remain authoritative when explicitly configured.
217
+ Fleet creation is bounded before Pi creates a durable task, conversation, agent, or queue entry: one session may retain at most 256 logical agents, and the scheduler may retain at most 256 queued dispatches. Every compiled worker profile has zero descendant depth and fan-out even if a legacy profile contains recursive limits. Admission preserves queue and durable-projection headroom for mandatory verifiers. A verifier dispatch that encounters saturation remains represented by its durable subject and replays on a queue-capacity event. `workerDelegation.maxConcurrent` is the global running-agent limit; excess admitted work enters the bounded durable queue. Worker token, cost, tool-call, active-wall-clock, and attempt usage are reconstructed from durable checkpoints and checked before more work is admitted. The default delegation baseline adds no cost or active-time ceiling; positive global settings, profile budgets, and inherited foreground ceilings remain authoritative when explicitly configured.
232
218
 
233
- `delegate` exposes the shared durable task/tree state through distinct authority boundaries:
219
+ `delegate` exposes the shared durable worker state to the owning root through distinct control actions:
234
220
 
235
221
  - `tasks` returns a bounded view of durable DAG tasks, dependencies, status, latest attempt/agent dispatch, verifier state, terminal reason, and persisted retry eligibility. `start.dependsOn` accepts only existing same-objective task IDs; forward, cross-objective, self, and cyclic edges fail before dispatch.
236
- - `list` returns safe metadata for session agents, including lineage, depth, state, and reusable activity; it does not grant transcript or control authority.
237
- - `transcript` pages bounded messages only for the session root or the caller's own agent/control subtree, with an opaque raw-entry cursor and page size of 1-64. A page may be empty and still provide `nextCursor` after visiting non-message entries; an individually oversized message is omitted and counted rather than partially returned. Sibling and unrelated peer transcripts are not readable by workers.
222
+ - `list` returns safe metadata for session agents, including state and reusable activity; it does not expose private resume state.
223
+ - `transcript` pages bounded messages for the session root with an opaque raw-entry cursor and page size of 1-64. A page may be empty and still provide `nextCursor` after visiting non-message entries; an individually oversized message is omitted and counted rather than partially returned.
238
224
  - `send` and `broadcast` queue bounded, non-waking, threaded peer evidence; broadcast canonicalizes a bounded target set and reports acceptance per target. Peer content is untrusted data, never authority.
239
- - `follow_up`, `interrupt`, `resume`, and `cancel` may wake or mutate only within the caller's control subtree. `resume` keeps the admitted model, transcript, resources, and grant; a paused objective retains its suspended attempt without starting or cancelling it until objective resume drains the scheduler. `cancel` terminates only the selected current task.
225
+ - `follow_up`, `interrupt`, `resume`, and `cancel` let the owning root steer worker lifecycle. `resume` keeps the admitted model, transcript, resources, and grant; a paused objective retains its suspended attempt without starting or cancelling it until objective resume drains the scheduler. `cancel` terminates only the selected current task.
240
226
  - `reply` answers one exact reply-expected request. The session root consumes replies through the acknowledged `inbox`, event-driven `inbox_wait`, and `inbox_ack` flow instead of unsolicited transcript injection.
241
227
  - `wait` and `wait_many` are event-driven; `wait_many` accepts a bounded canonical target set and completes in `any` or `all` mode. `retire` replay-safely closes only an idle leaf after its mailbox and reply obligations clear, preserving its binding and transcript.
242
228
 
@@ -244,7 +230,7 @@ Transient attempt retries are evidence-gated. A classified provider or transport
244
230
 
245
231
  `delegate` returns a stable agent/lane identity immediately. A fresh `start` does not accept `laneId`; omit it, retain the returned `agentId`, and pass that `agentId` to a later `start` to reuse the persistent worker. Completion persists a bounded terminal handoff before waking the parent; late output stays in the worker transcript instead of racing into the active foreground transcript. Review-pending results remain `partial` and project blockers remain `blocked` in lane status and terminal handoffs instead of either being collapsed into harness failures. A scheduled transient retry is reported as nonterminal with its durable state retained. A full parent mailbox retains the attempt-keyed handoff until an explicit terminal, mailbox-capacity, state-change, or recovery event drains it—there is no retry polling loop. Exact replays are inert, conflicts fail closed, and delivery errors remain retained. Use `delegate { action: "status", laneId }` for bounded lane-result retrieval.
246
232
 
247
- Global profiles live at `~/.pi/agent/profiles/orchestration/<id>.json`; project profiles live at `.pi/profiles/orchestration/<id>.json`. They are optional presets for model, reasoning, tools, resources, budget, verification, prompt defaults, and recursive `delegationLimits`. Select one with `profileId` on a call or configure `workerDelegation.orchestrationProfile`. `dispatchProfileIds` is preset-routing metadata, not an admission allowlist. Profile `maxConcurrent` is retained in the authored schema but does not override the global scheduler. `delegate` actions `profile_inspect` and `profile_create` manage optional immutable session-scoped narrowings; task profiles inherit the owner-authored base budget unchanged, and direct authority selection does not require a profile.
233
+ Global profiles live at `~/.pi/agent/profiles/orchestration/<id>.json`; project profiles live at `.pi/profiles/orchestration/<id>.json`. They are optional presets for model, reasoning, tools, resources, workspace, budget, verification, and prompt defaults. Select one with `profileId` on a call or configure `workerDelegation.orchestrationProfile`. Profile `maxConcurrent` is retained in the authored schema but does not override the global scheduler. `delegate` actions `profile_inspect` and `profile_create` manage immutable session-scoped narrowings. `profile_create` can omit `baseProfileId`; Pi then derives the foreground model, live thinking, compatible tools, and machine scope before applying optional `model`, `thinkingLevel`, `path`, and `toolNames` narrowing.
248
234
 
249
235
  A preset with `requireIndependentVerification: true` still names an owner-authored `verificationProfileId`. The runtime creates a separate durable verifier task and accepts the implementation only after a typed verifier decision. A profile using `run_process` must declare `executionPolicy`; that tool launches only listed executables as direct argv. The platform shell is different: it is a real persistent per-agent shell and is not OS/container isolation. Shell commands can exercise the host process, filesystem, network, and credentials available to Pi; direct `write`/`edit` path scopes do not sandbox shell side effects.
250
236
 
@@ -252,13 +238,12 @@ Direct `write`/`edit` calls use review-after-apply semantics. The compiled grant
252
238
 
253
239
  | Setting | Type | Default | Description |
254
240
  |---------|------|---------|-------------|
255
- | `workerDelegation.enabled` | boolean | `true` | Enable autonomous recursive agent trees; explicit `false` is a hard off-switch |
241
+ | `workerDelegation.enabled` | boolean | `true` | Enable autonomous persistent leaf workers; explicit `false` is a hard off-switch |
256
242
  | `workerDelegation.orchestrationProfile` | string | - | Optional default execution preset; agents may replace its defaults within inherited authority |
257
- | `workerDelegation.maxUsd` | number | `0` | Cumulative USD ceiling for one root tree; `0` is unbounded and a positive value explicitly enables the ceiling |
258
- | `workerDelegation.maxWallClockMs` | number | `0` | Cumulative active wall-clock ceiling for one root tree; `0` is unbounded and a positive value explicitly enables the ceiling |
243
+ | `workerDelegation.maxUsd` | number | `0` | USD ceiling for one worker task; `0` is unbounded and a positive value explicitly enables the ceiling |
244
+ | `workerDelegation.maxWallClockMs` | number | `0` | Active wall-clock ceiling for one worker task; `0` is unbounded and a positive value explicitly enables the ceiling |
259
245
  | `workerDelegation.maxConcurrent` | number | `20` | Global running-agent concurrency inside the fixed fleet and queue bounds |
260
246
  | `workerDelegation.writeEnabled` | boolean | `true` | Expose direct `write`/`edit`; explicit `false` revokes them for newly admitted work and narrows resumed grants |
261
- | `workerDelegation.writePaths` | string[] | `["."]` | Global envelope for direct child writes; an explicit empty array revokes direct `write`/`edit` |
262
247
  | `workerDelegation.modelPins` | object | - | Optional exact `default` and per-role provider/model/thinking bindings for fresh workers; malformed or unavailable applicable pins fail closed |
263
248
 
264
249
  ### Tool Repair
@@ -287,21 +272,35 @@ Environment kill switches override their diagnostic layers: `PI_TOOL_REPAIR_DISA
287
272
 
288
273
  ### Auto Learn Advanced
289
274
 
275
+ Native reflection belongs only to the main/orchestrator session. Eligible turns append a durable cue to the orchestrator's next ordinary current-session provider turn; reflection never starts a separate/background model request. Workers cannot run reflection or mutate durable memory; they return evidence to the parent, which decides what should be retained. A fresh main session uses this audited learning policy:
276
+
290
277
  | Setting | Type | Default | Description |
291
278
  |---------|------|---------|-------------|
292
- | `autoLearn.enabled` | boolean | derived from `autonomy.mode` (`false` when off) | Autonomously trigger background history scavenging for long sessions |
279
+ | `learningPolicy.enabled` | boolean | `true` | Route reflection writes through the decision/audit/rollback policy |
280
+ | `learningPolicy.autoApplyEnabled` | boolean | `true` | Apply eligible additive or organizational learning without asking the user to babysit it |
281
+ | `learningPolicy.confidenceThreshold` | number | `50` | Minimum confidence for automatic application |
282
+ | `learningPolicy.minObservations` | number | `1` | Minimum repeated observations for automatic application |
283
+ | `learningPolicy.allowedAutoApplyLayers` | string[] | `["memory", "skill"]` | Layers eligible for automatic application; other layers remain proposals |
284
+ | `learningPolicy.requireRollbackPlan` | boolean | `true` | Require an inverse plan before an automatic durable write |
285
+ | `learningPolicy.autoApplySupersessions` | boolean | `false` | Keep memory replacement/removal approval-gated unless explicitly enabled |
286
+
287
+ Safe `memory_add`, `okf_add`, and `okf_organize` writes can therefore land autonomously, including moving an exact hot-memory fact from `MEMORY.md` into structured OKF storage. Clean skill promotion is also eligible after overlap checks. `memory_replace` and `memory_remove` remain proposals by default because they supersede existing knowledge. Every applied write records its decision, outcome, and rollback data.
288
+
289
+ | Setting | Type | Default | Description |
290
+ |---------|------|---------|-------------|
291
+ | `autoLearn.enabled` | boolean | `true` in every autonomy mode | Enable root-session current-turn reflection. Disabling it immediately dismisses any pending cue and removes the standing reflection contract; re-enabling does not resurrect dismissed evidence. Automatic reflection never schedules a separate or background model request. |
293
292
  | `autoLearn.model` | string | `modelRouter.learningModel`, otherwise `"active"` | Legacy/direct override for the background learner; `"active"` uses the current session model, otherwise use a `pi --model` pattern |
294
- | `autoLearn.longSessionMessages` | number | `32` | Trigger after this many message entries in the active branch |
295
- | `autoLearn.longSessionContextPercent` | number | `70` | Trigger when current context usage reaches this percent |
296
- | `autoLearn.cooldownMinutes` | number | `120` | Per-session-tenant cooldown between learner launches |
293
+ | `autoLearn.longSessionMessages` | number | `32` | Readiness threshold after this many message entries in the active branch for an eligible learner run |
294
+ | `autoLearn.longSessionContextPercent` | number | `70` | Readiness threshold when current context usage reaches this percent |
295
+ | `autoLearn.cooldownMinutes` | number | `1440` | Per-session-tenant cooldown between learner launches |
297
296
  | `autoLearn.leaseMinutes` | number | `90` | Shared-state lease duration for a running background learner |
298
- | `autoLearn.maxConcurrentLearners` | number | `2` | Maximum running Auto Learn background learners per session tenant |
297
+ | `autoLearn.maxConcurrentLearners` | number | `1` | Maximum running Auto Learn background learners per session tenant |
299
298
  | `autoLearn.applyHighConfidence` | boolean | `false` | Allow the learner to apply high-confidence memory candidates; broader write authority is controlled by `autonomy.mode` |
300
- | `autoLearn.reflectionReview` | boolean | `true` | When Auto Learn is enabled, also run bounded post-turn reflection after corrective or complex turns |
301
- | `autoLearn.reflectionMinToolCalls` | number | `5` | Trigger reflection review after this many tool calls in one completed turn |
302
- | `autoLearn.reflectionCooldownMinutes` | number | `60` | Per-session-tenant cooldown between reflection-review learners |
299
+ | `autoLearn.reflectionReview` | boolean | `true` | When enabled, allow root-only automatic reflection cues after eligible corrective or complex turns; the cue is consumed by the next ordinary current-session turn |
300
+ | `autoLearn.reflectionMinToolCalls` | number | `12` | Queue a root-session reflection cue after this many tool calls in one completed turn |
301
+ | `autoLearn.reflectionCooldownMinutes` | number | `1440` | Per-session-tenant cooldown between automatic root-session reflection cues; corrective and complex-task signals can bypass it |
303
302
 
304
- Use `/settings` → **Model Router** for the preferred place to choose the scavenger/reflection/skill-creator model. Use `/settings` → **Auto Learn Advanced** for trigger/cooldown/concurrency overrides and the legacy direct `autoLearn.model` override. Use `/autonomy status` for the compact preset dashboard, `/auto-learn status` to inspect trigger state, reflection cooldown, and running leases, or `/auto-learn run` to start one learner immediately.
303
+ Use `/settings` → **Model Router** for the preferred place to choose the learner/skill-creator model. Automatic reflection uses the orchestrator's current session turn rather than a separate or background model request. Use `/settings` → **Auto Learn Advanced** for readiness/cooldown/concurrency overrides and the legacy direct `autoLearn.model` override. Use `/autonomy status` for the compact preset dashboard, `/auto-learn status` to inspect readiness and running leases, or `/auto-learn run` to explicitly start one bounded background learner immediately. Workers never receive reflection or durable-memory mutation authority; they return evidence to the root orchestrator.
305
304
 
306
305
  When enabled, Auto Learn keeps a small shared state file for visibility/cooldowns, but prompt/log/session artifacts are isolated under per-session-tenant directories so one session's learner does not consume another session's concurrency budget. Learners must confront available user/project memory first, using existing rules, preferences, corrections, and project facts to decide whether each candidate is useful, unique versus merge/upgrade-worthy, and agent-improving. Candidate validation is chunked/vectorized instead of one memory query per candidate. Successful Auto Learn workers purge their internal prompt/log/session artifacts after exit; the 7-day retention pruner is a fallback for unfinished or failed artifacts, and active leases are skipped so running learners are not raced. Provider/user history pruning is delegated to the continuous-learning tool after it records a learning outcome: only files older than 7 days whose current fingerprint still matches a successfully extracted index entry are deleted, and active/current sessions are protected.
307
306
 
@@ -312,13 +311,13 @@ When enabled, Auto Learn keeps a small shared state file for visibility/cooldown
312
311
  "model": "active",
313
312
  "longSessionMessages": 32,
314
313
  "longSessionContextPercent": 70,
315
- "cooldownMinutes": 120,
314
+ "cooldownMinutes": 1440,
316
315
  "leaseMinutes": 90,
317
- "maxConcurrentLearners": 2,
316
+ "maxConcurrentLearners": 1,
318
317
  "applyHighConfidence": false,
319
318
  "reflectionReview": true,
320
- "reflectionMinToolCalls": 5,
321
- "reflectionCooldownMinutes": 60
319
+ "reflectionMinToolCalls": 12,
320
+ "reflectionCooldownMinutes": 1440
322
321
  }
323
322
  }
324
323
  ```
@@ -349,10 +348,21 @@ The checkpoint owns user intent mechanically: `## Active Task` copies the latest
349
348
 
350
349
  | Setting | Type | Default | Description |
351
350
  |---------|------|---------|-------------|
352
- | `costGuard.maxTurnUsd` | number | `0` | Projected per-turn USD warning ceiling; disabled by default, positive values explicitly enable it |
351
+ | `costGuard.enabled` | boolean | `false` | Explicitly enable foreground per-turn cost projections and enforcement |
352
+ | `costGuard.maxTurnUsd` | number | `0` | Projected per-turn USD ceiling; a positive legacy value remains dormant until `enabled` is `true` |
353
353
  | `costGuard.action` | string | `"warn"` | `"warn"` only reports the estimate; `"downgrade"` also lowers reasoning one rung for that request without changing saved/profile state |
354
354
 
355
- The projection uses the session response reserve, cached-input rates, and model-declared long-context tiers. ChatGPT subscription usage is marked `(sub)` and does not enter the USD guard.
355
+ The projection uses the session response reserve, cached-input rates, and model-declared long-context tiers. ChatGPT subscription usage is marked `(sub)` and does not enter the USD guard. Enable it explicitly through `/settings` → **Foreground cost guard**, or in JSON:
356
+
357
+ ```json
358
+ {
359
+ "costGuard": {
360
+ "enabled": true,
361
+ "maxTurnUsd": 0.5,
362
+ "action": "warn"
363
+ }
364
+ }
365
+ ```
356
366
 
357
367
  ### Context GC
358
368
 
@@ -8,6 +8,8 @@ Task steps complement the native goal and delegation systems:
8
8
  - `goal` records durable outcome requirements and evidence.
9
9
  - `delegate` starts worker lanes, retrieves status, reviews claims, and coordinates them.
10
10
 
11
+ For the canonical Survey → Contract → Plan/Route → Execute → Prove/Deliver flow and the ownership boundary between these systems, see [Five-step work lifecycle](work-lifecycle.md).
12
+
11
13
  ## Statuses
12
14
 
13
15
  Each step has one of these statuses:
@@ -31,13 +31,18 @@ Run `/tmux-agents` or call `tmux_agent_manager` with `action: "status"` to check
31
31
 
32
32
  ## Completion contract
33
33
 
34
- `fire_task` creates panes, injects prompts, and arms one event-driven `tmux pipe-pane` watcher per worker before returning. Each watcher:
34
+ `fire_task` creates idle panes and arms one event-driven `tmux pipe-pane` watcher per worker. It then
35
+ starts every provider with the initial prompt file as part of the same CLI command
36
+ (`--prompt-interactive` for Agy), so task delivery cannot race TUI startup. Each watcher:
35
37
 
36
38
  1. consumes pane output as it arrives;
37
39
  2. writes one atomic terminal result when it sees the worker's `DONE` or `BLOCKED` marker, the pane closes, or its one-shot deadline expires;
38
40
  3. updates tmux status metadata and emits a display notification.
39
41
 
40
- The parent Pi session watches result-file events. Once a turn's worker is terminal, it records a per-agent notification marker (`notifiedTurn`) and sends a bounded, source-labelled untrusted handoff with `triggerTurn: true`. Startup performs one reconciliation pass for terminal events produced while Pi was offline, and also reconciles tmux **sessions**: see [Persistence](#persistence-follow-ups-reconcile-dismiss) below.
42
+ On deadline, the watcher persists `timeout` first and then terminates its owned pane. A timed-out
43
+ provider process therefore cannot remain live and continue spending resources.
44
+
45
+ The parent Pi session watches result-file events. Once a turn's worker is terminal, it records a per-agent notification marker (`notifiedTurn`) and sends a bounded, source-labelled untrusted handoff with `triggerTurn: true`. Startup reconciles every persisted terminal turn into host lane state, including turns whose user-facing handoff was already delivered, so a rehydrated running projection cannot outlive the worker. It also reconciles tmux **sessions**: see [Persistence](#persistence-follow-ups-reconcile-dismiss) below.
41
46
 
42
47
  Do not poll pane state, capture pane output, or inspect logs merely to detect completion. Use `job_status` or terminal artifacts after the handoff only when its bounded evidence is insufficient.
43
48
 
@@ -53,13 +58,14 @@ actions manage that persistence:
53
58
  (relaunch with `fire_task` instead) or if the job was `dismiss`ed.
54
59
  - **`dismiss`** — stops tracking a job (no more re-arming, no more handoffs) without killing its tmux
55
60
  session; the pane keeps running and can still be attached to (`tmux attach -t <session>`) or stopped
56
- later with `stop_job`/`stop_session`.
61
+ later with `stop_job`/`stop_session`. Dismiss detaches the completion watcher, so its old deadline no
62
+ longer owns that pane.
57
63
  - **Session reconcile** — on session start, Pi diffs live tmux sessions against its own job records for
58
64
  jobs it started. A session that has disappeared while its job was not yet terminal is marked orphaned
59
- (informational only — nothing is ever killed to produce this state, and the job directory is never
65
+ (informational only — reconciliation never kills it to produce this state, and the job directory is never
60
66
  deleted automatically). A session that is still alive with a pending turn has its watcher re-armed so
61
- the job can still complete normally. Killing a session always stays behind the explicit
62
- `stop_job`/`stop_session` confirm path.
67
+ the job can still complete normally. Manual early termination stays behind the explicit
68
+ `stop_job`/`stop_session` confirm path; a managed deadline terminates only its owned pane.
63
69
 
64
70
  An idle worker (no turn currently dispatched) does not hold this session's reload-quiesce; `/reload` is
65
71
  never blocked merely because a persistent tmux worker exists between turns.
@@ -68,33 +74,36 @@ Running managed lanes are checkpointed at dispatch and rehydrated with the same
68
74
  `/reload`. A later terminal event therefore completes the existing goal binding instead of minting a
69
75
  replacement lane or risking a duplicate dispatch.
70
76
 
71
- ## Approval-gated dispatch: the standing grant
72
-
73
- A real (non-dry-run) `fire_task` or `send_followup` launch requires either a **standing grant** or a
74
- one-shot interactive approval — never a silent launch:
75
-
76
- - **`grant_dispatch`** authorizes repeated unattended dispatch. Set `agent` (required), `maxLaunches`
77
- (required), and optionally `goalId` (an unscoped grant covers any goal), `allowedTools`,
78
- `resourceProfile`, `writePaths`, and `expiresInMinutes`. Requires interactive confirmation when a UI is
79
- attached; in print/rpc/non-interactive mode, requires the `--allow-tmux-dispatch` CLI flag instead.
80
- Once granted, matching launches proceed unattended. Team launches validate every child against the
81
- grant and consume one unit of `maxLaunches` for each child process launched; a single-provider grant
82
- cannot authorize a mixed-provider team.
83
- - **`revoke_grant`** ends a standing grant early (defaults to whichever grant is currently active).
84
- - With **no covering grant**: an interactive session is prompted for a one-shot approval; a
85
- non-interactive session (no UI, no grant) is **refused** with a clear error — never launched silently.
86
-
87
- A grant-covered (or one-shot-approved) `pi` child is launched with a **restricted profile**: `--tools`
88
- (or a read-biased default), `--resource-profile` (or `--no-extensions --no-skills`), and a scoped
89
- `--append-system-prompt` naming the grant and a fixed hard-stop list (publish/push/tag/credential
90
- changes/destructive deletion must come back BLOCKED, never self-approved). This pushes the envelope into
91
- the **child's own** launch configuration — it is not an in-process sandbox, and non-`pi` agents
92
- (`agy`/`claude`/`codex`/`opencode`/custom) are bounded only at the launch layer; their internal tool-loop
93
- behavior is that CLI's own responsibility.
94
-
95
- Grant budget (`maxLaunches`, `expiresInMinutes`) is real and enforced. `maxUsdAdvisory` and any
96
- self-reported worker usage are **advisory** — a claim to review, never a hard cap across the process
97
- boundary (the child bills under its own authentication).
77
+ ## Autonomous dispatch profiles
78
+
79
+ A real `fire_task` or `send_followup` runs autonomously without a UI prompt or CLI allow flag. Tmux
80
+ availability detection happens inside every action; `guard` is diagnostic only and is never a required
81
+ handshake.
82
+
83
+ Before `fire_task` creates any pane, watcher, prompt, or job artifact, it derives one immutable internal
84
+ execution profile per worker and durably reserves that worker's managed lane. Omitted tool and thinking
85
+ fields inherit the orchestrator's eligible worker surface. Omitted `path` uses the normal process cwd
86
+ while inheriting the host-derived full-machine scope except private harness paths. An explicit `path`
87
+ sets the process cwd and passes an immutable child-scope channel that enforces that workspace for Pi's
88
+ structured filesystem tools. Follow-up turns reuse the persisted profile and may change instructions,
89
+ never authority.
90
+
91
+ For `pi` workers, `tools`, `resourceProfile`, `thinkingLevel`, and `worktreeLane` become Pi CLI flags. The shared worker
92
+ ceiling removes memory, root-owned durable state, and agent-launching controls while retaining ordinary
93
+ inherited capabilities such as Python. When `resourceProfile` is omitted, the host compiles the
94
+ orchestrator's effective extension/skill/prompt/theme/agent/tool filters into a one-shot child profile;
95
+ an explicit value overrides that inheritance. The structured read/write/edit/search tools hard-deny
96
+ Pi's private auth, session, memory, settings, state, and work roots, and an explicit `path` further
97
+ restricts those structural calls to that workspace. Arbitrary process tools such as bash and
98
+ Python remain deliberate host-trust boundaries and can reach OS-visible files; this profile is not
99
+ misrepresented as process sandboxing. These fields are rejected for non-Pi providers because arbitrary
100
+ external CLIs own their own tool, thinking, and workspace controls; put native provider options in
101
+ `command` instead. A non-Pi `path` changes its cwd only. Its durable profile records one machine-wide,
102
+ host-trusted process (`bash` capability) rather than projecting the parent's Pi tool names or claiming
103
+ CLI/OS sandbox enforcement.
104
+
105
+ Any cooperative self-reported worker usage is **advisory** — a claim to review, never a hard cap across
106
+ the process boundary (the child bills under its own authentication).
98
107
 
99
108
  Dispatched tmux workers appear as `tmux-worker` lanes alongside in-process worker lanes in `/autonomy`
100
109
  and `delegate { action: "status" }`; a worker's self-reported changed files are re-checked against the session's active
@@ -105,16 +114,14 @@ write scope and flagged for parent review when out of scope, exactly like an in-
105
114
  The `goal` tool's `dispatch_worker` action can bind a single open requirement to a persistent tmux worker
106
115
  instead of the default in-process one: pass `dispatchTarget: "tmux"`. Core invokes `fire_task` itself (the
107
116
  same call the model would make) with exactly one `pi` agent, so the dispatch maps 1:1 to the
108
- requirement's bound lane; the launch still goes through the standing-grant authorization above unchanged
109
- — an unattended goal/idle loop with no covering grant is honestly refused, never silently launched. The
110
- requirement's binding is recorded either way; a successful tmux dispatch waits and resumes through the
111
- same lane machinery as an in-process worker.
117
+ requirement's bound lane. The same autonomous profile derivation and pre-launch durable reservation
118
+ apply. A successful tmux dispatch waits and resumes through the same lane machinery as an in-process
119
+ worker.
112
120
 
113
121
  When no worker was dispatched, the tool response's `dispatchSkipReason` explains why:
114
122
 
115
- - `no_standing_grant` — no covering grant, and this call had no UI to prompt (run `grant_dispatch` first).
116
123
  - `tmux_extension_not_loaded` — `tmux_agent_manager` is not loaded in this session (see Enable above).
117
- - `tmux_dispatch_failed` — the `fire_task` launch threw for a reason other than the grant (a bad jobId, a
124
+ - `tmux_dispatch_failed` — the `fire_task` launch threw (an invalid `launchKey`, a
118
125
  live session-name collision, an environment failure).
119
126
  - `tmux_dispatch_incomplete` — the launch call returned without the job/agent details needed to identify
120
127
  the new lane.
@@ -130,8 +137,8 @@ When no worker was dispatched, the tool response's `dispatchSkipReason` explains
130
137
 
131
138
  ## Safety
132
139
 
133
- Launch actions run directly unless `dryRun: true` is requested, and are approval-gated per the standing
134
- grant above. Stop actions can discard active pane work, so they remain previews by default and require
140
+ Launch actions run directly unless `dryRun: true` is requested. Stop actions can discard active pane
141
+ work, so they remain previews by default and require
135
142
  `confirm: "yes-tmux-stop"` for execution. Existing sessions are never replaced silently; `force: true`
136
143
  archives an old job directory but does not kill a live tmux session.
137
144
 
package/docs/usage.md CHANGED
@@ -316,6 +316,6 @@ pi --exclude-tools ask_question
316
316
 
317
317
  ## Design Principles
318
318
 
319
- Pi keeps the core focused and pushes project-specific workflows into extensions, skills, prompt templates, and packages. Core includes the cross-project lifecycle primitives it depends on itself: native goals, task steps, durable recursive agent orchestration, and a platform-selected shell. Broader integrations such as MCP and external-provider teams remain extension/package territory.
319
+ Pi keeps the core focused and pushes project-specific workflows into extensions, skills, prompt templates, and packages. Core includes the cross-project lifecycle primitives it depends on itself: native goals, task steps, durable root-managed leaf-worker orchestration, and a platform-selected shell. Broader integrations such as MCP and external-provider teams remain extension/package territory.
320
320
 
321
321
  For the full rationale, read the [blog post](https://mariozechner.at/posts/2025-11-30-pi-coding-agent/).
@@ -0,0 +1,137 @@
1
+ # Five-step work lifecycle
2
+
3
+ This document is the canonical design for how Pi carries a request from first inspection to verified delivery. It defines five phases only, then maps each phase onto existing `goal`, `task_steps`, delegation, evidence, and approval owners. For tool syntax, read [Task steps](task-steps.md) and [Task worker presets](worker-profiles.md); this document does not duplicate those references.
4
+
5
+ ## Confidence and scope
6
+
7
+ **Confirmed:** current Pi claims were checked against the source paths cited below. **External comparison:** Codex observations were checked against the adjacent `external/codex` checkout and are not claims about Pi. **Not checked:** provider-specific compliance beyond the deterministic prompt and gate tests, stochastic routing quality, and runtime performance under a large worker fleet.
8
+
9
+ ## Core invariant
10
+
11
+ Pi uses this one five-phase spine:
12
+
13
+ 1. **Survey**
14
+ 2. **Contract**
15
+ 3. **Plan/Route**
16
+ 4. **Execute**
17
+ 5. **Prove/Deliver**
18
+
19
+ The phase list is source-owned by `WORK_LIFECYCLE_PHASES`. Every root prompt receives the phase contract; the owner-specific line appears only when a goal or planning tool is active, and child workers keep their narrower contract (`packages/coding-agent/src/core/provider-prompt-contracts.ts`; `packages/coding-agent/src/core/system-prompt-builder.ts`). Chat and minimal-class models receive the same five phases in a 56-character compact form so their stable prompts remain inside their 2,048- and 4,096-character capability envelopes; larger root profiles retain the full contract (`packages/coding-agent/src/core/model-capability.ts`). Short or read-only work may collapse phases, but it must not invent a sixth phase or another workflow state machine.
20
+
21
+ State ownership stays singular:
22
+
23
+ - `goal` owns the desired outcome, acceptance requirements, and trusted evidence.
24
+ - `task_steps` owns the foreground execution plan.
25
+ - `delegate` and the orchestration runtime own worker identity, attempts, grants, results, and independent verifier lanes.
26
+ - the risk and policy gates own authorization decisions.
27
+ - the root session owns integration and the final acceptance decision.
28
+
29
+ The runtime already joins these owners through a read-only projection; it does not cross-write their stores (`packages/coding-agent/src/core/orchestration/work-state-projection.ts:111-167`; `packages/coding-agent/src/core/goals/goal-runtime-snapshot.ts:18-87,136-151`).
30
+
31
+ ## 1. Survey
32
+
33
+ Start project work with bounded, read-only discovery. Read the relevant project instructions, entry points, nearby tests, affected contracts, and existing implementation owners. Stop discovery when the evidence is sufficient to state a delivery contract and its uncertainty; do not scan the whole repository by default.
34
+
35
+ Survey happens before project mutation and before final delivery classification. Pi's existing model router is intentionally not the delivery classifier: routing receives the expanded original prompt during request preparation, before request-model validation and tool execution (`packages/coding-agent/src/core/agent-session.ts:2602-2624`; `packages/coding-agent/src/core/model-router-controller.ts:438-464`; `packages/coding-agent/src/core/risk-classifier.ts:87-179`). Reusing that prompt-only classifier for project scope would make POC-versus-complete decisions without source evidence.
36
+
37
+ **Exit condition:** relevant project facts, affected surfaces, uncertainty, and consequential owner choices are known. Routine implementation choices remain with Pi.
38
+
39
+ ## 2. Contract
40
+
41
+ Translate the request and Survey evidence into a project-relative outcome contract. Record that contract in the goal objective and requirements, not in task titles. Goal state already owns requirement status and evidence bindings (`packages/coding-agent/src/core/goals/goal-state.ts:34-128`), and the goal tool now tells the root to make delivery depth explicit after Survey (`packages/coding-agent/src/core/tools/goal.ts:428-442`).
42
+
43
+ Use these delivery meanings:
44
+
45
+ - **POC:** a bounded executable proof that establishes whether the requested capability works. Production integration is intentionally outside the contract unless explicitly named.
46
+ - **MVP:** the smallest usable project slice that proves the requested feature in its real context. Deliberately omitted integrations must be explicit.
47
+ - **Complete feature:** a production-ready feature integrated across every affected project surface. A demo, isolated helper, or passing happy-path test is not complete.
48
+
49
+ For a complete feature, inspect and include every applicable surface: public entry points and callers; types and wire contracts; configuration and defaults; persistence, migration, and compatibility; cancellation, failure, retry, and resume behavior; UI or CLI exposure; tests and production-shaped verification; documentation and changelog; obsolete-path cleanup. “Applicable” matters: the contract must not manufacture irrelevant work merely to fill a checklist.
50
+
51
+ **Exit condition:** acceptance criteria distinguish requested outcome from implementation method, name the delivery depth, cover applicable project integration, preserve authority boundaries, and identify what evidence can prove each criterion.
52
+
53
+ ## 3. Plan/Route
54
+
55
+ Create the mutation plan in `task_steps`, link steps to goal requirements, and keep one step active. `task_steps` already enforces one active item and preserves notes/evidence (`packages/coding-agent/src/core/tasks/task-state.ts:358-400,431-488`); its tool contract now makes Plan/Route precede project mutation and forbids a second outcome state (`packages/coding-agent/src/core/tools/task-steps.ts:316-332`). Detailed plans may contain more than five checklist items—the five-item limit applies to lifecycle phases, not implementation decomposition.
56
+
57
+ Choose solo versus team execution adaptively. Long duration alone never mandates a team. Evaluate:
58
+
59
+ - risk and invariant sensitivity;
60
+ - uncertainty and missing expertise;
61
+ - urgency and available parallelism;
62
+ - reversibility and blast radius;
63
+ - test strength and verification cost;
64
+ - cognitive load and integration coupling.
65
+
66
+ Keep dependent, trivial, context-heavy, or interactive work local. Delegate separable discovery, implementation, tests, or specialist review when doing so improves speed or confidence. Require a different reviewer identity when the factors make implementation self-review insufficient. Worker profiles already support mandatory independent verification and resolve a dedicated verifier shipment (`packages/coding-agent/src/core/delegation/worker-delegation-controller.ts:710-734`).
67
+
68
+ **Exit condition:** ordered work, stable owners, dependencies, acceptance evidence, verification depth, and solo/team route are explicit before mutation.
69
+
70
+ ## 4. Execute
71
+
72
+ Work the first open plan item. The root remains integration owner; a worker result is evidence, not accepted truth. Workers receive immutable authority and result contracts through the existing orchestration runtime rather than a lifecycle-specific executor (`packages/coding-agent/src/core/orchestration/contracts.ts:367-509`; `packages/coding-agent/src/core/orchestration/policy-gate.ts:10-30`).
73
+
74
+ Record changed files, focused tests, rejected hypotheses, and blockers on the relevant task and goal requirement. Wait event-driven at true dependencies. Worker terminals already pass through one durable notification coordinator and one foreground handoff path; matching active-goal completions wake the parent (`packages/coding-agent/src/core/background-lane-controller.ts:174-200`; `packages/coding-agent/src/core/foreground-terminal-handoff-controller.ts:197-205,341-429`). The goal continuation decision waits on bound in-flight workers and resumes once work can advance (`packages/coding-agent/src/core/goals/goal-continuation-controller.ts:284-353`).
75
+
76
+ A failed implementation or review does not create a new phase. Update Contract only if the requested outcome changed; otherwise return to Plan/Route or continue Execute with the new evidence.
77
+
78
+ **Exit condition:** planned mutations are integrated, no required work is silently deferred, and evidence is ready for independent acceptance.
79
+
80
+ ## 5. Prove/Deliver
81
+
82
+ Verify from narrow to broad in proportion to risk: focused reproduction and negative control, adjacent tests, type/build/static gates, then production-shaped checks when the contract requires them. Independent review must inspect the integrated result, not only worker claims or exit codes. Goal completion already distinguishes proven requirements from open work, waits for cited background tasks, and requires an explicit completion transition (`packages/coding-agent/src/core/goals/goal-continuation-controller.ts:198-237`; `packages/coding-agent/src/core/goal-loop-controller.ts:88-199`).
83
+
84
+ When checks are green and the owner requested or authorized a checkpoint, create a local commit inside Prove/Deliver. Commit is not a sixth lifecycle state. The risk classifier now admits one plain local `git commit` as a reversible scoped write, while composed shell commands, history-rewriting commits, push, reset, clean, stash, rebase, release, deploy, and publish operations stay approval-gated (`packages/coding-agent/src/core/risk-classifier.ts:220-265`; `packages/coding-agent/src/core/autonomy/gates.ts:189-219`). A commit message containing words such as “release” does not turn a local checkpoint into publication.
85
+
86
+ `git push`, tags, releases, package publication, deployment, destructive operations, credential/authentication changes, settings/authority expansion, and other external side effects remain owner-gated. Approval produces authority for the requested operation; it is not proof that the feature is correct (`packages/coding-agent/src/core/orchestration/contracts.ts:486-509`; `packages/coding-agent/src/core/orchestration/policy-compiler.ts:161-186`).
87
+
88
+ **Exit condition:** every required criterion has trusted evidence, integrated review is clean, no active work remains, authorized local checkpointing is complete, and either delivery is complete or Pi is explicitly waiting at an external authorization boundary. Any failed criterion loops to Contract, Plan/Route, or Execute.
89
+
90
+ ## Current-code audit
91
+
92
+ ### Retained as authoritative
93
+
94
+ **Confirmed:** goal state, task state, delegated task runtime, worker lifecycle, foreground handoff, continuation, risk assessment, and approval compilation are live owners with focused tests. The goal/task/worker read model already links stable IDs without merging their mutation paths (`packages/coding-agent/src/core/orchestration/work-state-projection.ts:89-167`). Historical hardening of these owners is documented in [Goal/Task-Steps/Subagent Fix Cycle](goal-task-subagent-cycle-2026-07-19.md); this document links rather than restating that dated fix ledger.
95
+
96
+ ### Rewired in this feature
97
+
98
+ **Confirmed:**
99
+
100
+ - one root-only lifecycle contract is always assembled, with goal/task/delegate ownership wording added only when the corresponding planning surface is available;
101
+ - goal and task tool guidance directs Contract and Plan/Route into their existing owners;
102
+ - delegation guidance makes team use adaptive rather than duration-triggered;
103
+ - plain local commits no longer hit the publication/destructive approval path;
104
+ - focused tests lock the five exact phases, root/child/tool-surface prompt gating, project-relative delivery wording, adaptive factors, and local-commit negative controls.
105
+
106
+ No lifecycle database, controller, event type, planner store, or delivery enum was added. Delivery completeness is contextual and belongs in acceptance requirements; a global enum could not determine which project surfaces are applicable after discovery.
107
+
108
+ ### Deliberately not reused as delivery classification
109
+
110
+ **Confirmed:** `classifyModelRouterRoute(prompt)` and its `intent-classifier.ts` re-export remain model-cost/risk routing mechanisms. They run on prompt text before Survey and cannot safely decide project delivery depth. The orchestration event store remains the delegated execution owner; mirroring root lifecycle phases into it would duplicate goal/task state.
111
+
112
+ ### Residual limits
113
+
114
+ **Confirmed limitation:** adaptive routing and the decision to request an independent reviewer are semantic decisions made by the root under the lifecycle contract. The host deterministically enforces worker authority and a profile's required verifier once selected, but it does not infer project risk after Survey or auto-spawn reviewers for solo work.
115
+
116
+ **Confirmed limitation:** automatic local checkpointing means the root invokes a plain `git commit` after green evidence. Pi does not run an ambient auto-commit daemon, because that could capture unrelated owner changes without a proven patch boundary.
117
+
118
+ **Not checked:** prompt conformance cannot prove every provider follows the lifecycle under all context-pressure conditions. Deterministic prompt-shape tests and completion gates reduce that risk; evidence-gated review remains necessary.
119
+
120
+ ## Codex mechanisms considered
121
+
122
+ **External comparison, confirmed against the adjacent checkout:** Codex's Thread Store exposes one raw history append API, one metadata update API, and a preferred `LiveThread` path for active persistence (`../../external/codex/codex-rs/thread-store/README.md:3-30`). That supports Pi's one-owner-per-invariant decision; it does not justify copying Codex's storage types.
123
+
124
+ Codex review launches a one-shot subagent with an explicit review prompt, disables collaboration features inside that reviewer, and marks it as `SubAgentSource::Review` (`../../external/codex/codex-rs/core/src/tasks/review.rs:103-140`). Pi retains the same useful separation—implementation evidence is reviewed by a distinct identity when warranted—through its existing verifier shipment instead of adding a second review subsystem.
125
+
126
+ Codex approval handling is tool/operation scoped rather than a generic “commit phase”: the tool orchestrator computes an execution approval requirement, requests approval when needed, then attempts the tool under the selected sandbox (`../../external/codex/codex-rs/core/src/tools/orchestrator.rs:154-233`). Pi follows the same separation: lifecycle acceptance and execution authority remain different decisions. No Codex rollout or thread-store code is copied.
127
+
128
+ ## Verification map
129
+
130
+ - Prompt lifecycle and tool-surface gating: `packages/coding-agent/test/system-prompt-builder-tool-selection.test.ts`.
131
+ - Stable compact base prompt: `packages/coding-agent/test/system-prompt.test.ts`.
132
+ - Local commit and approval negative controls: `packages/coding-agent/test/autonomy-risk-assessment.test.ts`.
133
+ - Existing goal/task/delegate behavior: the focused suites referenced by [Task steps](task-steps.md) and [Goal/Task-Steps/Subagent Fix Cycle](goal-task-subagent-cycle-2026-07-19.md).
134
+
135
+ ## Documentation scope note
136
+
137
+ Covered in depth: lifecycle semantics, delivery-depth contract, ownership, current wiring, local checkpoint authorization, and the directly compared Codex mechanisms. Structurally checked: goal continuation, worker verifier admission, terminal handoff, work-state projection, and approval compilation. Not checked in depth: every provider adapter, every worker profile, UI rendering, pipeline internals, release automation, and performance under fleet load.