@osolmaz/pi-workflows 0.16.2 → 0.16.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 (315) hide show
  1. package/README.md +41 -41
  2. package/dist/builtins/monitor.workflow.d.ts +1 -1
  3. package/dist/builtins/monitor.workflow.js +8 -8
  4. package/dist/builtins/pi-agent-group.js +3 -3
  5. package/dist/builtins/pi-agent-group.js.map +1 -1
  6. package/dist/channels/adapter-entry.js +14 -14
  7. package/dist/channels/adapter-entry.js.map +1 -1
  8. package/dist/client/client.d.ts +6 -6
  9. package/dist/client/client.js +27 -27
  10. package/dist/client/client.js.map +1 -1
  11. package/dist/client/protocol.d.ts +4 -1
  12. package/dist/client/protocol.js +17 -11
  13. package/dist/client/protocol.js.map +1 -1
  14. package/dist/client/resolver.d.ts +4 -4
  15. package/dist/client/view.d.ts +1 -1
  16. package/dist/extension/index.d.ts +1 -1
  17. package/dist/extension/index.js +32 -32
  18. package/dist/extension/index.js.map +1 -1
  19. package/dist/extension/recorder.d.ts +1 -1
  20. package/dist/extension/recorder.js +1 -1
  21. package/dist/extension/recorder.js.map +1 -1
  22. package/dist/extension/remote-recorder-store.d.ts +1 -1
  23. package/dist/extension/remote-recorder-store.js +2 -2
  24. package/dist/extension/remote-recorder-store.js.map +1 -1
  25. package/dist/extension/{controller-command.d.ts → resource-manager-command.d.ts} +6 -6
  26. package/dist/extension/{controller-command.js → resource-manager-command.js} +7 -7
  27. package/dist/extension/resource-manager-command.js.map +1 -0
  28. package/dist/extension/session-delivery.d.ts +1 -1
  29. package/dist/extension/session-delivery.js +2 -2
  30. package/dist/extension/session-delivery.js.map +1 -1
  31. package/dist/extension/session-view.d.ts +1 -1
  32. package/dist/extension/session-view.js +1 -1
  33. package/dist/extension/session-view.js.map +1 -1
  34. package/dist/extension/workflow-message-coordinator.d.ts +1 -1
  35. package/dist/extension/workflow-message-coordinator.js +6 -6
  36. package/dist/extension/workflow-message-coordinator.js.map +1 -1
  37. package/dist/resource-managers/conditions.d.ts +6 -0
  38. package/dist/{controllers → resource-managers}/conditions.js +3 -3
  39. package/dist/resource-managers/conditions.js.map +1 -0
  40. package/dist/resource-managers/definition.d.ts +6 -0
  41. package/dist/resource-managers/definition.js +45 -0
  42. package/dist/resource-managers/definition.js.map +1 -0
  43. package/dist/resource-managers/effects.d.ts +15 -0
  44. package/dist/{controllers → resource-managers}/effects.js +2 -2
  45. package/dist/resource-managers/effects.js.map +1 -0
  46. package/dist/resource-managers/errors.d.ts +12 -0
  47. package/dist/resource-managers/errors.js +25 -0
  48. package/dist/resource-managers/errors.js.map +1 -0
  49. package/dist/resource-managers/index.d.ts +12 -0
  50. package/dist/resource-managers/index.js +12 -0
  51. package/dist/resource-managers/index.js.map +1 -0
  52. package/dist/resource-managers/json.js.map +1 -0
  53. package/dist/resource-managers/loader.d.ts +23 -0
  54. package/dist/resource-managers/loader.js +75 -0
  55. package/dist/resource-managers/loader.js.map +1 -0
  56. package/dist/resource-managers/results.d.ts +5 -0
  57. package/dist/resource-managers/results.js.map +1 -0
  58. package/dist/resource-managers/runtime.d.ts +59 -0
  59. package/dist/{controllers/manager.js → resource-managers/runtime.js} +57 -57
  60. package/dist/resource-managers/runtime.js.map +1 -0
  61. package/dist/{controllers → resource-managers}/sqlite.d.ts +44 -44
  62. package/dist/{controllers → resource-managers}/sqlite.js +139 -130
  63. package/dist/resource-managers/sqlite.js.map +1 -0
  64. package/dist/{controllers → resource-managers}/store.d.ts +33 -33
  65. package/dist/{controllers → resource-managers}/store.js.map +1 -1
  66. package/dist/{controllers → resource-managers}/types.d.ts +41 -41
  67. package/dist/{controllers → resource-managers}/types.js.map +1 -1
  68. package/dist/resource-managers/workflows.d.ts +34 -0
  69. package/dist/{controllers → resource-managers}/workflows.js +15 -15
  70. package/dist/resource-managers/workflows.js.map +1 -0
  71. package/dist/server/channel-effects.js.map +1 -0
  72. package/dist/{host → server}/channel-supervisor.d.ts +6 -6
  73. package/dist/{host → server}/channel-supervisor.js +3 -3
  74. package/dist/server/channel-supervisor.js.map +1 -0
  75. package/dist/{host/child-worker-supervisor.d.ts → server/child-runner-supervisor.d.ts} +15 -13
  76. package/dist/{host/child-worker-supervisor.js → server/child-runner-supervisor.js} +6 -5
  77. package/dist/server/child-runner-supervisor.js.map +1 -0
  78. package/dist/{host → server}/processes.d.ts +3 -3
  79. package/dist/{host → server}/processes.js +3 -3
  80. package/dist/server/processes.js.map +1 -0
  81. package/dist/{host → server}/resolver-entry.d.ts +6 -6
  82. package/dist/{host → server}/resolver-entry.js +14 -14
  83. package/dist/server/resolver-entry.js.map +1 -0
  84. package/dist/server/resource-runner-entry.d.ts +2 -0
  85. package/dist/{host/controller-worker-entry.js → server/resource-runner-entry.js} +33 -33
  86. package/dist/server/resource-runner-entry.js.map +1 -0
  87. package/dist/server/resource-runner-protocol.d.ts +36 -0
  88. package/dist/server/resource-runner-protocol.js +49 -0
  89. package/dist/server/resource-runner-protocol.js.map +1 -0
  90. package/dist/server/resource-runner-supervisor.d.ts +21 -0
  91. package/dist/{host/worker-supervisor.js → server/resource-runner-supervisor.js} +17 -17
  92. package/dist/server/resource-runner-supervisor.js.map +1 -0
  93. package/dist/{host → server}/rpc-bridge.d.ts +3 -3
  94. package/dist/{host → server}/rpc-bridge.js +3 -3
  95. package/dist/server/rpc-bridge.js.map +1 -0
  96. package/dist/{host → server}/rpc-executor.d.ts +1 -1
  97. package/dist/{host → server}/rpc-executor.js +3 -3
  98. package/dist/server/rpc-executor.js.map +1 -0
  99. package/dist/{host/host-entry.js → server/server-entry.js} +6 -6
  100. package/dist/server/server-entry.js.map +1 -0
  101. package/dist/{host/runner.d.ts → server/server.d.ts} +39 -38
  102. package/dist/{host/runner.js → server/server.js} +408 -374
  103. package/dist/server/server.js.map +1 -0
  104. package/dist/{host → server}/state.d.ts +25 -25
  105. package/dist/{host → server}/state.js +49 -49
  106. package/dist/server/state.js.map +1 -0
  107. package/dist/{host → server}/view.d.ts +7 -7
  108. package/dist/{host → server}/view.js +13 -13
  109. package/dist/server/view.js.map +1 -0
  110. package/dist/server/workflow-runner-content.d.ts +6 -0
  111. package/dist/server/workflow-runner-content.js +96 -0
  112. package/dist/server/workflow-runner-content.js.map +1 -0
  113. package/dist/{host/worker-entry.d.ts → server/workflow-runner-entry.d.ts} +3 -3
  114. package/dist/{host/worker-entry.js → server/workflow-runner-entry.js} +68 -35
  115. package/dist/server/workflow-runner-entry.js.map +1 -0
  116. package/dist/server/workflow-runner-protocol.d.ts +69 -0
  117. package/dist/server/workflow-runner-protocol.js +176 -0
  118. package/dist/server/workflow-runner-protocol.js.map +1 -0
  119. package/dist/{host/worker-store.d.ts → server/workflow-runner-store.d.ts} +11 -11
  120. package/dist/{host/worker-store.js → server/workflow-runner-store.js} +8 -8
  121. package/dist/server/workflow-runner-store.js.map +1 -0
  122. package/dist/server/workflow-runner-supervisor.d.ts +22 -0
  123. package/dist/server/workflow-runner-supervisor.js +56 -0
  124. package/dist/server/workflow-runner-supervisor.js.map +1 -0
  125. package/dist/state/prune.d.ts +1 -1
  126. package/dist/state/prune.js +17 -10
  127. package/dist/state/prune.js.map +1 -1
  128. package/dist/state/schema.js +2 -2
  129. package/dist/state/workflow-messages.d.ts +1 -1
  130. package/dist/state/workflow-messages.js +1 -1
  131. package/dist/state/workflow-messages.js.map +1 -1
  132. package/dist/viewer/backup.js +1 -1
  133. package/dist/viewer/backup.js.map +1 -1
  134. package/dist/viewer/cli.d.ts +2 -2
  135. package/dist/viewer/cli.js +46 -32
  136. package/dist/viewer/cli.js.map +1 -1
  137. package/dist/viewer/tui.d.ts +1 -1
  138. package/dist/viewer/tui.js +1 -1
  139. package/dist/viewer/tui.js.map +1 -1
  140. package/dist/workflows/command-batch.js +2 -2
  141. package/dist/workflows/engine.js +14 -15
  142. package/dist/workflows/engine.js.map +1 -1
  143. package/dist/workflows/store.d.ts +12 -11
  144. package/dist/workflows/store.js +24 -18
  145. package/dist/workflows/store.js.map +1 -1
  146. package/dist/workflows/types.d.ts +2 -2
  147. package/docs/2026-08-20-durable-workflow-launch-plan.md +12 -12
  148. package/docs/2026-08-25-workflow-follow-ups.md +7 -7
  149. package/docs/2026-08-25-workflow-settings.md +3 -3
  150. package/docs/2026-08-30-out-of-process-workflow-host-plan.md +3 -3
  151. package/docs/2026-09-01-restore-session-delivery-controls-plan.md +5 -5
  152. package/docs/2026-09-01-unified-workflow-client-plan.md +6 -6
  153. package/docs/2026-09-02-installed-live-e2e-plan.md +3 -3
  154. package/docs/2026-09-02-unify-workflow-messages-plan.md +8 -8
  155. package/docs/2026-09-04-workflow-run-state-plan.md +6 -6
  156. package/docs/DEFERRED_TURNS.md +7 -7
  157. package/docs/DESIGN_PHILOSOPHY.md +1 -1
  158. package/docs/HUMAN_DECISIONS.md +11 -11
  159. package/docs/HUMAN_DECISION_PRESENTATIONS.md +4 -4
  160. package/docs/MONITOR.md +1 -1
  161. package/docs/RESOURCE_MANAGERS.md +221 -0
  162. package/docs/SQLITE_STATE.md +35 -33
  163. package/docs/WORKFLOW_COMPOSITION.md +1 -1
  164. package/docs/{WORKFLOW_HOST.md → WORKFLOW_SERVER.md} +125 -119
  165. package/docs/WORKFLOW_STEP_MESSAGES.md +18 -18
  166. package/docs/WORKFLOW_UPDATES.md +16 -16
  167. package/docs/development.md +15 -14
  168. package/docs/live-replay-protocol.md +20 -20
  169. package/docs/plans/2026-08-04-controller-runtime-plan.md +25 -25
  170. package/docs/plans/2026-08-05-always-on-workflows-plan.md +8 -8
  171. package/docs/plans/2026-08-10-agent-managed-monitor-workflows-plan.md +2 -2
  172. package/docs/plans/2026-08-13-session-addressed-workflow-notifications-plan.md +1 -1
  173. package/docs/plans/2026-08-16-workflow-updates-plan.md +5 -5
  174. package/docs/plans/2026-08-19-human-decision-gates-plan.md +1 -1
  175. package/docs/plans/2026-08-20-bounded-command-batches-plan.md +1 -1
  176. package/docs/plans/2026-08-21-deferred-turn-intents-plan.md +3 -3
  177. package/docs/plans/2026-08-21-sanity-check-plan.md +2 -2
  178. package/docs/plans/2026-08-23-assistant-agent-completion-plan.md +5 -5
  179. package/docs/plans/2026-08-23-sqlite-state-plan.md +25 -25
  180. package/docs/plans/2026-08-25-live-workflow-settings-plan.md +4 -4
  181. package/docs/plans/2026-08-27-workflow-terminal-restart-plan.md +3 -3
  182. package/docs/plans/2026-09-04-workflow-runner-resume-state-plan.md +318 -0
  183. package/docs/plans/piw-viewer-experience-implementation-plan.md +1 -1
  184. package/docs/tui-viewer.md +9 -9
  185. package/docs/workflows.md +72 -66
  186. package/examples/{controllers/pull-request.controller.ts → resource-managers/pull-request.resource-manager.ts} +12 -12
  187. package/herdr-plugin.toml +1 -1
  188. package/package.json +5 -5
  189. package/protocol/client.v1.schema.json +7 -7
  190. package/protocol/fixtures/client-v1.json +1 -1
  191. package/src/builtins/monitor.workflow.ts +9 -9
  192. package/src/builtins/pi-agent-group.ts +3 -3
  193. package/src/channels/adapter-entry.ts +14 -14
  194. package/src/client/client.ts +33 -32
  195. package/src/client/protocol.ts +16 -11
  196. package/src/client/resolver.ts +4 -4
  197. package/src/client/view.ts +1 -1
  198. package/src/extension/index.ts +44 -34
  199. package/src/extension/recorder.ts +1 -1
  200. package/src/extension/remote-recorder-store.ts +2 -2
  201. package/src/extension/resource-manager-command.ts +45 -0
  202. package/src/extension/session-delivery.ts +2 -2
  203. package/src/extension/session-view.ts +1 -1
  204. package/src/extension/workflow-message-coordinator.ts +6 -6
  205. package/src/{controllers → resource-managers}/conditions.ts +23 -23
  206. package/src/resource-managers/definition.ts +71 -0
  207. package/src/{controllers → resource-managers}/effects.ts +9 -9
  208. package/src/resource-managers/errors.ts +27 -0
  209. package/src/resource-managers/index.ts +88 -0
  210. package/src/resource-managers/loader.ts +111 -0
  211. package/src/{controllers → resource-managers}/results.ts +4 -4
  212. package/src/{controllers/manager.ts → resource-managers/runtime.ts} +95 -92
  213. package/src/{controllers → resource-managers}/sqlite.ts +198 -186
  214. package/src/{controllers → resource-managers}/store.ts +46 -38
  215. package/src/{controllers → resource-managers}/types.ts +50 -41
  216. package/src/{controllers → resource-managers}/workflows.ts +43 -41
  217. package/src/{host → server}/channel-supervisor.ts +8 -8
  218. package/src/{host/child-worker-supervisor.ts → server/child-runner-supervisor.ts} +22 -18
  219. package/src/{host → server}/processes.ts +3 -3
  220. package/src/{host → server}/resolver-entry.ts +28 -25
  221. package/src/{host/controller-worker-entry.ts → server/resource-runner-entry.ts} +67 -65
  222. package/src/server/resource-runner-protocol.ts +103 -0
  223. package/src/server/resource-runner-supervisor.ts +76 -0
  224. package/src/{host → server}/rpc-bridge.ts +3 -3
  225. package/src/{host → server}/rpc-executor.ts +4 -4
  226. package/src/{host/host-entry.ts → server/server-entry.ts} +5 -5
  227. package/src/{host/runner.ts → server/server.ts} +526 -461
  228. package/src/{host → server}/state.ts +78 -67
  229. package/src/{host → server}/view.ts +15 -15
  230. package/src/server/workflow-runner-content.ts +119 -0
  231. package/src/{host/worker-entry.ts → server/workflow-runner-entry.ts} +98 -57
  232. package/src/server/workflow-runner-protocol.ts +241 -0
  233. package/src/{host/worker-store.ts → server/workflow-runner-store.ts} +18 -20
  234. package/src/server/workflow-runner-supervisor.ts +79 -0
  235. package/src/state/prune.ts +27 -9
  236. package/src/state/schema.ts +2 -2
  237. package/src/state/workflow-messages.ts +1 -1
  238. package/src/viewer/backup.ts +1 -1
  239. package/src/viewer/cli.ts +50 -36
  240. package/src/viewer/tui.ts +1 -1
  241. package/src/workflows/command-batch.ts +2 -2
  242. package/src/workflows/engine.ts +14 -15
  243. package/src/workflows/store.ts +31 -28
  244. package/src/workflows/types.ts +2 -2
  245. package/dist/controllers/conditions.d.ts +0 -6
  246. package/dist/controllers/conditions.js.map +0 -1
  247. package/dist/controllers/definition.d.ts +0 -6
  248. package/dist/controllers/definition.js +0 -45
  249. package/dist/controllers/definition.js.map +0 -1
  250. package/dist/controllers/effects.d.ts +0 -15
  251. package/dist/controllers/effects.js.map +0 -1
  252. package/dist/controllers/errors.d.ts +0 -12
  253. package/dist/controllers/errors.js +0 -25
  254. package/dist/controllers/errors.js.map +0 -1
  255. package/dist/controllers/index.d.ts +0 -12
  256. package/dist/controllers/index.js +0 -12
  257. package/dist/controllers/index.js.map +0 -1
  258. package/dist/controllers/json.js.map +0 -1
  259. package/dist/controllers/loader.d.ts +0 -23
  260. package/dist/controllers/loader.js +0 -74
  261. package/dist/controllers/loader.js.map +0 -1
  262. package/dist/controllers/manager.d.ts +0 -59
  263. package/dist/controllers/manager.js.map +0 -1
  264. package/dist/controllers/results.d.ts +0 -5
  265. package/dist/controllers/results.js.map +0 -1
  266. package/dist/controllers/sqlite.js.map +0 -1
  267. package/dist/controllers/workflows.d.ts +0 -34
  268. package/dist/controllers/workflows.js.map +0 -1
  269. package/dist/extension/controller-command.js.map +0 -1
  270. package/dist/host/channel-effects.js.map +0 -1
  271. package/dist/host/channel-supervisor.js.map +0 -1
  272. package/dist/host/child-worker-supervisor.js.map +0 -1
  273. package/dist/host/controller-worker-entry.d.ts +0 -2
  274. package/dist/host/controller-worker-entry.js.map +0 -1
  275. package/dist/host/controller-worker-protocol.d.ts +0 -36
  276. package/dist/host/controller-worker-protocol.js +0 -49
  277. package/dist/host/controller-worker-protocol.js.map +0 -1
  278. package/dist/host/controller-worker-supervisor.d.ts +0 -21
  279. package/dist/host/controller-worker-supervisor.js +0 -54
  280. package/dist/host/controller-worker-supervisor.js.map +0 -1
  281. package/dist/host/host-entry.js.map +0 -1
  282. package/dist/host/processes.js.map +0 -1
  283. package/dist/host/resolver-entry.js.map +0 -1
  284. package/dist/host/rpc-bridge.js.map +0 -1
  285. package/dist/host/rpc-executor.js.map +0 -1
  286. package/dist/host/runner.js.map +0 -1
  287. package/dist/host/state.js.map +0 -1
  288. package/dist/host/view.js.map +0 -1
  289. package/dist/host/worker-entry.js.map +0 -1
  290. package/dist/host/worker-protocol.d.ts +0 -46
  291. package/dist/host/worker-protocol.js +0 -122
  292. package/dist/host/worker-protocol.js.map +0 -1
  293. package/dist/host/worker-store.js.map +0 -1
  294. package/dist/host/worker-supervisor.d.ts +0 -22
  295. package/dist/host/worker-supervisor.js.map +0 -1
  296. package/docs/CONTROLLERS.md +0 -217
  297. package/src/controllers/definition.ts +0 -65
  298. package/src/controllers/errors.ts +0 -27
  299. package/src/controllers/index.ts +0 -88
  300. package/src/controllers/loader.ts +0 -104
  301. package/src/extension/controller-command.ts +0 -45
  302. package/src/host/controller-worker-protocol.ts +0 -104
  303. package/src/host/controller-worker-supervisor.ts +0 -79
  304. package/src/host/worker-protocol.ts +0 -176
  305. package/src/host/worker-supervisor.ts +0 -74
  306. /package/dist/{controllers → resource-managers}/json.d.ts +0 -0
  307. /package/dist/{controllers → resource-managers}/json.js +0 -0
  308. /package/dist/{controllers → resource-managers}/results.js +0 -0
  309. /package/dist/{controllers → resource-managers}/store.js +0 -0
  310. /package/dist/{controllers → resource-managers}/types.js +0 -0
  311. /package/dist/{host → server}/channel-effects.d.ts +0 -0
  312. /package/dist/{host → server}/channel-effects.js +0 -0
  313. /package/dist/{host/host-entry.d.ts → server/server-entry.d.ts} +0 -0
  314. /package/src/{controllers → resource-managers}/json.ts +0 -0
  315. /package/src/{host → server}/channel-effects.ts +0 -0
@@ -78,7 +78,7 @@ export type WorkflowProgressData = {
78
78
  export type WorkflowNodeCommon = {
79
79
  /**
80
80
  * Per-node active-execution timeout or a callback that derives it from the run context.
81
- * Waiting, paused, disconnected, and host-down origin-session time does not count.
81
+ * Waiting, paused, disconnected, and server-down origin-session time does not count.
82
82
  * Null disables the deadline. Omission falls back to the engine default (15 minutes).
83
83
  */
84
84
  timeoutMs?: number | null | ((context: WorkflowNodeContext) => MaybePromise<number | null>);
@@ -808,7 +808,7 @@ export type WorkflowEngineOptions = {
808
808
  notificationSink?: WorkflowNotificationSink;
809
809
  /** Canonical SQLite database. Defaults to `~/.pi/agent/workflows/state.sqlite`. */
810
810
  databasePath?: string;
811
- /** Durable execution store. Workers use a host-backed implementation. */
811
+ /** Durable execution store. Runners use a server-backed implementation. */
812
812
  store?: import("./store.js").WorkflowExecutionStore;
813
813
  /**
814
814
  * Awaited after `run_started` is persisted, before any node executes.
@@ -18,7 +18,7 @@ If startup then fails, pi-workflows must save the failure and start one new mode
18
18
  actionable error. The model can correct the request and call `workflow start` again. A failed launch
19
19
  must release the session reservation so the corrected run can start.
20
20
 
21
- This change stays inside pi-workflows. It uses the existing project-scoped SQLite controller store
21
+ This change stays inside pi-workflows. It uses the existing project-scoped SQLite resource manager store
22
22
  and documented Pi extension APIs. It does not change Pi, add a service, or add another database.
23
23
 
24
24
  ## Current failure
@@ -81,12 +81,12 @@ pi-workflows is in alpha. Change the current storage and tool contracts in place
81
81
  - Change the SQLite table definitions and TypeScript types directly.
82
82
  - Remove the superseded status values and launch path in the same change.
83
83
 
84
- An existing controller store with the old alpha table layout is incompatible. On open, pi-workflows
84
+ An existing resource manager store with the old alpha table layout is incompatible. On open, pi-workflows
85
85
  must verify the required table columns and status contract. If the layout is old, it must stop with a
86
- clear instruction to preserve any needed run evidence and reset the project-scoped controller store.
86
+ clear instruction to preserve any needed run evidence and reset the project-scoped resource manager store.
87
87
  It must not silently reinterpret or delete old state.
88
88
 
89
- Run bundles remain separate evidence. Resetting an incompatible controller queue must not delete run
89
+ Run bundles remain separate evidence. Resetting an incompatible resource manager queue must not delete run
90
90
  bundle directories.
91
91
 
92
92
  ## Public behavior
@@ -118,7 +118,7 @@ includes:
118
118
  - Workflow resolution and definition validation.
119
119
  - Declared input validation.
120
120
  - Parent checkpoint and source checks for continuations.
121
- - Controller-store access.
121
+ - ResourceManager-store access.
122
122
  - Existing active or queued session reservation.
123
123
  - Pending final presentation conflicts.
124
124
 
@@ -217,7 +217,7 @@ bundle owns input after the engine starts.
217
217
 
218
218
  Keep `workflow_notifications` limited to passive `progress` and `final` reports. A launch failure creates an eligible row in `workflow_turn_intents`; it does not add a run-level notification kind.
219
219
 
220
- The project-scoped controller store remains private local state. Tests must verify restrictive file
220
+ The project-scoped resource manager store remains private local state. Tests must verify restrictive file
221
221
  and directory permissions.
222
222
 
223
223
  ## State transitions
@@ -273,9 +273,9 @@ can correct it without including secret values.
273
273
 
274
274
  ## Implementation plan
275
275
 
276
- ### 1. Replace the alpha controller-store layout
276
+ ### 1. Replace the alpha resource manager store layout
277
277
 
278
- Update `src/controllers/sqlite.ts` and its exported queue and notification types.
278
+ Update `src/resource-managers/sqlite.ts` and its exported queue and notification types.
279
279
 
280
280
  - Keep `CONTROLLER_STORE_SCHEMA` at `pi-workflows.controller-store.v1`.
281
281
  - Change `SCHEMA_SQL` directly.
@@ -316,8 +316,8 @@ Preparation owns resolution, validation, run ID allocation, immutable source ide
316
316
  digest, and reservation. Activation owns claims, engine construction, recorder setup, `activeRun`,
317
317
  running state, and executor release.
318
318
 
319
- Controller child workflows remain on their controller scheduler path. Share pure workflow-resolution
320
- helpers where useful, but do not make controller children wait for an interactive agent boundary.
319
+ Resource manager child workflows remain on their resource manager scheduler path. Share pure workflow-resolution
320
+ helpers where useful, but do not make resource manager children wait for an interactive agent boundary.
321
321
 
322
322
  ### 4. Change the start tool
323
323
 
@@ -361,7 +361,7 @@ surface.
361
361
  ### 8. Update documentation
362
362
 
363
363
  Update `docs/workflows.md` with the queued start contract, run ID, status, cancellation, failure
364
- follow-up, and model retry behavior. Update controller-store documentation with the alpha reset rule.
364
+ follow-up, and model retry behavior. Update resource manager store documentation with the alpha reset rule.
365
365
  Do not document a v2 schema or migration path.
366
366
 
367
367
  ## Tests
@@ -438,7 +438,7 @@ copy as the implementation source.
438
438
 
439
439
  - Do not change Pi or propose a new Pi API.
440
440
  - Do not add a service, daemon, remote queue, telemetry endpoint, or second database.
441
- - Do not preserve old alpha controller-store layouts.
441
+ - Do not preserve old alpha resource manager store layouts.
442
442
  - Do not add a migration or v2 schema.
443
443
  - Do not add blind automatic workflow retries.
444
444
  - Do not change built-in workflow behavior except for test fixtures needed to verify startup.
@@ -32,7 +32,7 @@ Remove an unsent prompt with:
32
32
  }
33
33
  ```
34
34
 
35
- A model can remove only a prompt added by the same session tool source. A controller can remove only its own prompt. A verified human can remove any unsent prompt in the owned run.
35
+ A model can remove only a prompt added by the same session tool source. A resource manager can remove only its own prompt. A verified human can remove any unsent prompt in the owned run.
36
36
 
37
37
  Direct commands are also available:
38
38
 
@@ -57,7 +57,7 @@ await ctx.workflows.removeFollowUp({
57
57
  });
58
58
  ```
59
59
 
60
- The host creates the actor and stable request identity. Prompt data cannot claim human or controller authority.
60
+ The server creates the actor and stable request identity. Prompt data cannot claim human or resource manager authority.
61
61
 
62
62
  ## Ordering and run states
63
63
 
@@ -65,25 +65,25 @@ Prompts keep database acceptance order. Several requests can add several prompts
65
65
 
66
66
  - Running, paused, parked, and waiting workflows accept new prompts.
67
67
  - Pause and park keep prompts queued.
68
- - A checkpoint continuation keeps queued prompt rows attached to the chain member that accepted them. The host walks the continuation chain to determine their final source outcome; it does not rewrite the rows.
68
+ - A checkpoint continuation keeps queued prompt rows attached to the chain member that accepted them. The server walks the continuation chain to determine their final source outcome; it does not rewrite the rows.
69
69
  - Successful completion records the terminal run and terminal workflow message before a follow-up can send.
70
70
  - Failed, timed-out, and cancelled workflows cancel every unsent prompt.
71
71
  - A terminal workflow rejects new prompts. Repeating an earlier request ID can still return its first result.
72
72
 
73
73
  A repeated request ID with the same prompt returns the first result. Reusing that ID with different content fails.
74
74
 
75
- Each accepted prompt creates its `workflow_follow_ups` source record and one `followUp` workflow message in one transaction. The message points to its source through `sourceId`; the source row stores no message pointer. The host derives eligibility from saved domain facts. A follow-up is eligible only after the source continuation chain completes successfully, its terminal message turn ends, every earlier accepted follow-up is settled or cancelled, and no nonterminal run, including one waiting for a checkpoint or protected decision, reserves the origin session.
75
+ Each accepted prompt creates its `workflow_follow_ups` source record and one `followUp` workflow message in one transaction. The message points to its source through `sourceId`; the source row stores no message pointer. The server derives eligibility from saved domain facts. A follow-up is eligible only after the source continuation chain completes successfully, its terminal message turn ends, every earlier accepted follow-up is settled or cancelled, and no nonterminal run, including one waiting for a checkpoint or protected decision, reserves the origin session.
76
76
 
77
77
  ## One message path
78
78
 
79
79
  The shared `WorkflowMessageCoordinator` handles follow-ups. There is no follow-up sender.
80
80
 
81
81
  1. Wait for the terminal outcome, sent terminal workflow message, and matching model-turn end.
82
- 2. After every host connection, wait for the complete origin-session view and report the active branch.
83
- 3. Wait until the host view names this `followUp` as the next eligible pending message, Pi is idle, and no earlier workflow message is active.
82
+ 2. After every server connection, wait for the complete origin-session view and report the active branch.
83
+ 3. Wait until the server view names this `followUp` as the next eligible pending message, Pi is idle, and no earlier workflow message is active.
84
84
  4. Keep its ID in the coordinator's in-memory queued map and report a matching active-branch entry when one already exists.
85
85
  5. Otherwise, recheck synchronously that Pi is idle, has no pending input, the message is absent, and the connection still owns the active coordinator epoch. Call documented `pi.sendMessage()` with the follow-up prompt and `triggerTurn: true` without an `await` between the check and call.
86
- 6. Report the active branch so the host saves the observed Pi entry ID and marks the message `sent`.
86
+ 6. Report the active branch so the server saves the observed Pi entry ID and marks the message `sent`.
87
87
  7. Wait for that turn and any workflow it starts to finish before the next follow-up becomes eligible.
88
88
 
89
89
  The follow-up custom message starts normal conversation work and can use a user-style renderer. Its internal workflow message ID stays in custom details and does not enter provider-facing content. It can ask the model to start another workflow, but it cannot resume or reactivate the completed workflow. Text that starts with `/` remains plain model input; a custom message cannot dispatch a Pi slash command or expand a prompt template. A `restart` chosen from the terminal turn creates a separate immutable workflow run.
@@ -108,7 +108,7 @@ await ctx.workflows.changeSettings({
108
108
  });
109
109
  ```
110
110
 
111
- Each request has a stable host-issued ID. Repeating the same ID and content returns the first result. Reusing an ID with different content fails. When one model response emits several workflow tool calls, the extension applies them in source order so a settings change cannot race past a later step submission.
111
+ Each request has a stable server-issued ID. Repeating the same ID and content returns the first result. Reusing an ID with different content fails. When one model response emits several workflow tool calls, the extension applies them in source order so a settings change cannot race past a later step submission.
112
112
 
113
113
  `expectedChangeNumber` protects the complete settings value. A JSON Patch `test` operation can protect one field. When no expected number is supplied, the patch applies to the latest saved value in database acceptance order.
114
114
 
@@ -127,11 +127,11 @@ The permissions mean:
127
127
 
128
128
  `read` is not a privacy filter. Workflow code in that scope receives the complete typed settings value.
129
129
 
130
- The host records the actor outside the patch:
130
+ The server records the actor outside the patch:
131
131
 
132
132
  - `session` for a model workflow-tool call;
133
133
  - `human` for a direct command or verified human decision;
134
- - `controller` for a controller request;
134
+ - `controller` for a resource manager request; this internal version-1 actor value is retained;
135
135
  - `policy` only for existing saved policy code.
136
136
 
137
137
  Patch data cannot claim another actor type.
@@ -12,7 +12,7 @@ A live workflow lost its lease while it was still working. The workflow engine k
12
12
 
13
13
  This plan fixes that failure first, then removes its root architectural cause. One user-level host will own workflow state. Each active run will execute in a supervised child process. Pi will become a client that starts work, presents interactive requests, and submits answers through documented extension APIs.
14
14
 
15
- [Workflow host](WORKFLOW_HOST.md) defines the complete target process, protocol, state, recovery, and Pi integration contracts. This plan gives the implementation order and acceptance checks.
15
+ [Workflow server](WORKFLOW_SERVER.md) defines the complete target process, protocol, state, recovery, and Pi integration contracts. This plan gives the implementation order and acceptance checks.
16
16
 
17
17
  ## Goals
18
18
 
@@ -273,7 +273,7 @@ The host protocol and worker runtime may exist under tests before the final swit
273
273
  - Recover a resumable expired run.
274
274
  - Stop an uncertain effect for manual review.
275
275
 
276
- ### Host and child isolation
276
+ ### Server and child isolation
277
277
 
278
278
  - Block a child event loop longer than the run lease and prove the host keeps ownership.
279
279
  - Kill Pi while a run computes.
@@ -333,7 +333,7 @@ Run Pi Reviewer against `main` until no P0 or P1 findings remain. Check pull-req
333
333
  - Expired running rows can be resumed or cancelled safely.
334
334
  - Pi restart does not lose or falsely fail pending work.
335
335
  - An unanswered interactive request keeps its original node deadline, follows its timeout route, and cannot hold a stale session reservation forever.
336
- - Host restart recovers durable work without duplicate transitions.
336
+ - Server restart recovers durable work without duplicate transitions.
337
337
  - Interactive steps still use the origin Pi session.
338
338
  - Duplicate commands and submissions return stored receipts.
339
339
  - A submission is not accepted until supervised workflow validation succeeds.
@@ -10,9 +10,9 @@ date: 2026-09-01
10
10
 
11
11
  This repair restored the widget, Escape pause, and the first shared sender. Version 0.16.0 still has a model-turn status bug and did not preserve all earlier session features. The approved [workflow-message restoration plan](2026-09-02-unify-workflow-messages-plan.md) replaces separate send records with one workflow-message contract and restores the remaining behavior.
12
12
 
13
- The out-of-process workflow host removed the Pi workflow widget and Escape-to-pause behavior. A later delivery safety fix also caused normal polling to report `Interactive request presentation claim conflict`. This plan restores those features and fixes delivery without bringing back the embedded workflow runtime.
13
+ The out-of-process workflow server removed the Pi workflow widget and Escape-to-pause behavior. A later delivery safety fix also caused normal polling to report `Interactive request presentation claim conflict`. This plan restores those features and fixes delivery without bringing back the embedded workflow runtime.
14
14
 
15
- [Workflow host](WORKFLOW_HOST.md) remains the process and state specification. [Workflow step messages](WORKFLOW_STEP_MESSAGES.md) remains the session message specification. This plan records the cause, scope, implementation order, and acceptance checks for the repair.
15
+ [Workflow server](WORKFLOW_SERVER.md) remains the process and state specification. [Workflow step messages](WORKFLOW_STEP_MESSAGES.md) remains the session message specification. This plan records the cause, scope, implementation order, and acceptance checks for the repair.
16
16
 
17
17
  ## Observed problems
18
18
 
@@ -34,7 +34,7 @@ The coordinator also removes its local queued guard before durable settlement fi
34
34
  ## Requirements
35
35
 
36
36
  - Keep one global host as the normal workflow state writer.
37
- - Keep workflow and controller code in supervised child processes.
37
+ - Keep workflow and resource manager code in supervised child processes.
38
38
  - Use documented Pi extension APIs only.
39
39
  - Preserve one ordered session delivery path for steps, decisions, notifications, and final results.
40
40
  - Never send through an expired claim.
@@ -92,7 +92,7 @@ The change may update:
92
92
  - host pause and resume handling for parked interactions;
93
93
  - existing version-1 interaction response fields;
94
94
  - focused unit, integration, and live Pi tests;
95
- - the workflow host and authoring documentation.
95
+ - the workflow server and authoring documentation.
96
96
 
97
97
  ## Non-goals
98
98
 
@@ -125,7 +125,7 @@ The change may update:
125
125
  - A paused interaction rejects `update` and `submit`.
126
126
  - Resume keeps the same request and allows submission without another prompt.
127
127
  - Non-aborted turns and unrelated sessions do not pause the workflow.
128
- - The extension and host execute no workflow or controller code in their own event loops.
128
+ - The extension and host execute no workflow or resource manager code in their own event loops.
129
129
 
130
130
  ## Verification
131
131
 
@@ -37,7 +37,7 @@ These are not independent display defects. The extension, Herdr integration, and
37
37
 
38
38
  ## Root cause
39
39
 
40
- `WorkflowHostClient` is the authority for commands, but it is not the authority for live views.
40
+ `WorkflowClient` is the authority for commands, but it is not the authority for live views.
41
41
 
42
42
  The Pi extension opens SQLite twice during one refresh. It first finds the origin session reservation and then loads the run from a second database snapshot. It maps durable workflow state directly to a widget label. The host cannot add exact origin-session model activity to that result.
43
43
 
@@ -200,7 +200,7 @@ The widget shows the Herdr hint only when the documented Herdr capability check
200
200
 
201
201
  ### One live `piw` source
202
202
 
203
- Local `piw` connects to the package-owned host, subscribes to run views, and fetches pages through `pi-workflows.client.v1`. When the socket is absent, Rust may start the host only by executing the installed `pi-workflows host start` command. Rust does not reimplement host launch, locking, epochs, or readiness. If that command is unavailable or fails, `piw` stops with the direct install or startup instruction.
203
+ Local `piw` connects to the package-owned host, subscribes to run views, and fetches pages through `pi-workflows.client.v1`. When the socket is absent, Rust may start the host only by executing the installed `pi-workflows server start` command. Rust does not reimplement host launch, locking, epochs, or readiness. If that command is unavailable or fails, `piw` stops with the direct install or startup instruction.
204
204
 
205
205
  `piw serve` stops reading SQLite. It becomes a loopback-only WebSocket relay for the same logical protocol. Remote clients continue to use an SSH tunnel. The relay opens one host socket connection for each WebSocket connection and couples their lifecycles one to one. It carries frames only. It does not multiplex clients, translate run state, keep another projection, or retain activity after either side closes.
206
206
 
@@ -237,7 +237,7 @@ No migration, compatibility reader, dual protocol, bridge period, or feature fla
237
237
 
238
238
  ### 2. Make the host the only live database reader
239
239
 
240
- **Location:** `src/host/`, `src/state/`, controller stores, and state maintenance commands.
240
+ **Location:** `src/server/`, `src/state/`, resource manager stores, and state maintenance commands.
241
241
 
242
242
  **Change:** Add host handlers for atomic origin-session view lookup, run-list and run-view snapshots, revision subscriptions, bounded pages, and active database maintenance. Keep projection reads and writes in the host. A view read must resolve the session reservation, run, durable display facts, and presentation revision from one consistent read boundary. Persist generated large view values in the run-scoped content table under their digest and media type before advertising their references. Do not reuse general state blobs or allow another run to read the content. Store the complete original workflow definition, not its escaped projection. Externalize large replay checkpoints and make both clients resolve them. Route state-changing Pi extension commands through the durable retry path. Give the CLI one stable client identity and one fresh key for each backup or applied prune invocation. Reuse that key only for the invocation's automatic reconnect retry, with a new request ID. Keep an in-flight maintenance operation alive after disconnect, store its accepted or rejected command receipt before response, wait for it during host shutdown, and adopt an exact retry. Wait for socket drain before sending another snapshot, and remove every subscription kind explicitly when its client unsubscribes.
243
243
 
@@ -245,7 +245,7 @@ No migration, compatibility reader, dual protocol, bridge period, or feature fla
245
245
 
246
246
  ### 3. Add the host status reducer and activity overlay
247
247
 
248
- **Location:** a host-owned view module under `src/host/` or `src/viewer/`, with no Pi import.
248
+ **Location:** a host-owned view module under `src/server/` or `src/viewer/`, with no Pi import.
249
249
 
250
250
  **Change:** Build the `display` object from durable facts and the validated activity overlay. Add connection-scoped activity leases and monotonic sequences. Apply the documented status precedence and allowed-control rules in one function.
251
251
 
@@ -255,7 +255,7 @@ No migration, compatibility reader, dual protocol, bridge period, or feature fla
255
255
 
256
256
  **Location:** `src/extension/session-view.ts`, `src/extension/index.ts`, and the delivery coordinator.
257
257
 
258
- **Change:** Remove all extension imports and construction of `HostStateStore`, `SqliteControllerStore`, `WorkflowRunStore`, and the active state path. Replace `waitForInteractionSubmission`, `pendingInteractionForSession`, `pendingDecision`, `interactionPresentationClaimIsLive`, `hasClaimableNotification`, `hasClaimableTurn`, `terminalRunState`, `sessionRun`, and the widget's two-read refresh with `WorkflowClient` requests or the one origin-session subscription. The `interaction.submit` response supplies the final validation outcome. Report exact delivery activity from documented Pi events and the coordinator's delivery map. Render only the host `display` object. Keep Escape pause tied to the exact active workflow delivery.
258
+ **Change:** Remove all extension imports and construction of `ServerStateStore`, `SqliteResourceManagerStore`, `WorkflowRunStore`, and the active state path. Replace `waitForInteractionSubmission`, `pendingInteractionForSession`, `pendingDecision`, `interactionPresentationClaimIsLive`, `hasClaimableNotification`, `hasClaimableTurn`, `terminalRunState`, `sessionRun`, and the widget's two-read refresh with `WorkflowClient` requests or the one origin-session subscription. The `interaction.submit` response supplies the final validation outcome. Report exact delivery activity from documented Pi events and the coordinator's delivery map. Render only the host `display` object. Keep Escape pause tied to the exact active workflow delivery.
259
259
 
260
260
  **Verification:** Hold Pi busy longer than both the poll interval and activity lease. The widget stays `running` while refreshed exact activity is live, falls back to `waiting` after activity ends without submission, and shows `paused` only after the host accepts pause. The controlled run produces one visible delivery and one model turn without claiming a universal exactly-once guarantee.
261
261
 
@@ -277,7 +277,7 @@ No migration, compatibility reader, dual protocol, bridge period, or feature fla
277
277
 
278
278
  ### 7. Remove split paths and update documentation
279
279
 
280
- **Location:** old host/replay protocol code, obsolete viewer readers, `docs/WORKFLOW_HOST.md`, `docs/SQLITE_STATE.md`, `docs/live-replay-protocol.md`, README usage, and package contents.
280
+ **Location:** old host/replay protocol code, obsolete viewer readers, `docs/WORKFLOW_SERVER.md`, `docs/SQLITE_STATE.md`, `docs/live-replay-protocol.md`, README usage, and package contents.
281
281
 
282
282
  **Change:** Delete the superseded request/response and replay contracts, direct live readers, duplicated status reducers, and fallback flags. Update all user commands and architecture diagrams to show the one client stack. Keep inactive backup verification explicitly separate.
283
283
 
@@ -46,7 +46,7 @@ Each run will use:
46
46
 
47
47
  Pi will start with `--no-skills`, `--no-themes`, `--no-prompt-templates`, `--no-context-files`, and `--no-builtin-tools`. The runner must not use `--no-extensions`, because that would also disable Pi Workflows.
48
48
 
49
- After startup, the runner will call RPC `get_commands`. The `workflow`, `controller`, and `piw` commands must come from the packed Pi Workflows package. Any other user or project extension is a failure. Base Pi's own inline commands are allowed.
49
+ After startup, the runner will call RPC `get_commands`. The `workflow`, `resource-manager`, and `piw` commands must come from the packed Pi Workflows package. Any other user or project extension is a failure. Base Pi's own inline commands are allowed.
50
50
 
51
51
  ## Installed package test
52
52
 
@@ -96,7 +96,7 @@ The runner will start it through Pi RPC and check the following sequence:
96
96
  2. RPC emits `setWidget` and `setStatus` for the `pi-workflows` key with `running` state.
97
97
  3. `/workflow pause` is accepted.
98
98
  4. The widget and status change to `paused`.
99
- 5. Host status reports one parked run and no active workflow worker.
99
+ 5. Server status reports one parked run and no active workflow runner.
100
100
  6. `/workflow resume` is accepted.
101
101
  7. The widget and status return to `running`.
102
102
  8. The workflow completes with the fixed output.
@@ -170,7 +170,7 @@ A real-model run requires explicit provider and model arguments. `--runtime-only
170
170
  The standalone runner will own one temporary root and remove it in a `finally` path. It will:
171
171
 
172
172
  - close the Pi RPC process;
173
- - stop the workflow host through the installed client;
173
+ - stop the workflow server through the installed client;
174
174
  - wait for the host endpoint to disappear;
175
175
  - stop child workers started for the smoke workflows;
176
176
  - remove the npm consumer installation, sessions, workflow state, and fixture project.
@@ -15,7 +15,7 @@ This change gives the host one saved list of workflow messages that Pi must add
15
15
 
16
16
  The same change restores the user features removed during the host cut. It keeps one global host, one client protocol, one database, and one production runtime.
17
17
 
18
- [Workflow host](WORKFLOW_HOST.md) remains the process and state specification. [Workflow messages in Pi](WORKFLOW_STEP_MESSAGES.md) remains the Pi message specification. This plan changes both contracts in place.
18
+ [Workflow server](WORKFLOW_SERVER.md) remains the process and state specification. [Workflow messages in Pi](WORKFLOW_STEP_MESSAGES.md) remains the Pi message specification. This plan changes both contracts in place.
19
19
 
20
20
  ## Current problems
21
21
 
@@ -70,9 +70,9 @@ Several reference pages still describe reminders, follow-ups, live settings cont
70
70
 
71
71
  - Do not restore the embedded workflow executor.
72
72
  - Do not let the extension, CLI, or `piw` open live SQLite state.
73
- - Do not restore per-project hosts or `/controller start` and `/controller stop`.
73
+ - Do not restore per-project hosts or `/resource-manager start` and `/resource-manager stop`.
74
74
  - Do not send a workflow prompt into an active model turn.
75
- - Do not run workflow or controller code in the host event loop.
75
+ - Do not run workflow or resource manager code in the host event loop.
76
76
  - Do not change Pi core, private Pi APIs, Pi session files, or Pi session schemas.
77
77
  - Do not add another database, service, runtime, compatibility reader, fallback, or feature flag.
78
78
  - Do not claim exactly-once model execution.
@@ -227,7 +227,7 @@ The host applies the end and its workflow consequence in one transaction:
227
227
 
228
228
  The transaction stores one immutable end event, updates activity, and creates or cancels messages together. Repeating the same report adopts that result. A stale or different turn ID cannot end newer activity.
229
229
 
230
- The host clears process-local activity when the client disconnects. Host startup does not close a Pi turn because the host cannot know whether Pi is still working. On `session_start`, the extension reports the active branch before new sends. If Pi is still busy, it reports `started` again with the retained turn ID. Only an idle-session branch report can close an open sent message with synthetic `stopReason: "lost"`. A lost step follows the normal unproductive-turn rule. A lost terminal or follow-up closes without reopening the completed workflow.
230
+ The host clears process-local activity when the client disconnects. Server startup does not close a Pi turn because the host cannot know whether Pi is still working. On `session_start`, the extension reports the active branch before new sends. If Pi is still busy, it reports `started` again with the retained turn ID. Only an idle-session branch report can close an open sent message with synthetic `stopReason: "lost"`. A lost step follows the normal unproductive-turn rule. A lost terminal or follow-up closes without reopening the completed workflow.
231
231
 
232
232
  ### Display rule
233
233
 
@@ -270,7 +270,7 @@ This applies to:
270
270
  - cancelled runs;
271
271
  - launch failures;
272
272
  - claim loss when safe handoff is impossible and the host commits a terminal result;
273
- - controller interruption.
273
+ - resource manager interruption.
274
274
 
275
275
  An ordinary claim transfer remains a handoff and creates no terminal message. A stale owner cannot create one.
276
276
 
@@ -391,7 +391,7 @@ Restore TypeScript viewer step scrubbing and its one-second elapsed-time redraw.
391
391
  - Escape pauses only the exact matching workflow turn.
392
392
  - Pause, cancel, answer, update, and submit remain durable host commands.
393
393
  - A pending interaction on a paused run rejects update and submit until resume.
394
- - Workflow and controller code remain in supervised children.
394
+ - Workflow and resource manager code remain in supervised children.
395
395
  - Side effects remain idempotent or explicitly ambiguous.
396
396
  - `/piw`, `Ctrl+Shift+R`, Herdr placement, and widget scrolling remain available.
397
397
  - Local and remote `piw` use the same client protocol and exact run view.
@@ -455,7 +455,7 @@ The later status work binds only to `workflow_messages`. Do not implement a temp
455
455
 
456
456
  ### Update reference documentation
457
457
 
458
- Update [Workflow host](WORKFLOW_HOST.md), [Workflow messages in Pi](WORKFLOW_STEP_MESSAGES.md), [SQLite state](SQLITE_STATE.md), [Live client protocol](live-replay-protocol.md), [Deferred workflow turns](DEFERRED_TURNS.md), [workflow follow-ups](2026-08-25-workflow-follow-ups.md), [workflow settings](2026-08-25-workflow-settings.md), [Human decisions](HUMAN_DECISIONS.md), [Human decision presentations](HUMAN_DECISION_PRESENTATIONS.md), [Session event journal](session-event-journal.md), [Rust TUI viewer](tui-viewer.md), the earlier host plans, the authoring reference, and README to match the implementation.
458
+ Update [Workflow server](WORKFLOW_SERVER.md), [Workflow messages in Pi](WORKFLOW_STEP_MESSAGES.md), [SQLite state](SQLITE_STATE.md), [Live client protocol](live-replay-protocol.md), [Deferred workflow turns](DEFERRED_TURNS.md), [workflow follow-ups](2026-08-25-workflow-follow-ups.md), [workflow settings](2026-08-25-workflow-settings.md), [Human decisions](HUMAN_DECISIONS.md), [Human decision presentations](HUMAN_DECISION_PRESENTATIONS.md), [Session event journal](session-event-journal.md), [Rust TUI viewer](tui-viewer.md), the earlier host plans, the authoring reference, and README to match the implementation.
459
459
 
460
460
  Remove temporary current-version warnings only after live checks pass.
461
461
 
@@ -498,7 +498,7 @@ Remove temporary current-version warnings only after live checks pass.
498
498
  - Pause and resume a presented step and receive one step message with reason `resumed`.
499
499
  - Prove initial, reminder, and resumed prompts use the same message kind, contract, attempt identity, eligibility, and recovery path.
500
500
  - Prove the partial unique index allows at most one pending step message per request for every reason.
501
- - Complete, fail, time out, cancel, fail launch without recoverable handoff, and interrupt through a controller; receive one terminal turn in each case.
501
+ - Complete, fail, time out, cancel, fail launch without recoverable handoff, and interrupt through a resource manager; receive one terminal turn in each case.
502
502
  - Settle a checkpoint parent through a continuation and prove only the final chain leaf gets a terminal turn.
503
503
  - Restart safely, reject a fourth restart, and reject a repeated terminal fingerprint.
504
504
  - Queue and remove follow-ups, then send remaining prompts once in order without pointer deadlock.
@@ -63,7 +63,7 @@ Cancellation and terminal-message creation currently share a transaction path. I
63
63
 
64
64
  The compiler assigns complete node paths. The engine uses those paths to identify logical work. Child workflows can receive a local view of inputs and outputs, but that local view cannot replace the compiled identity.
65
65
 
66
- The host state store owns every durable transition. Host orchestration code asks the store to start, pause, finish, cancel, or recover work. It does not update lifecycle tables directly.
66
+ The host state store owns every durable transition. Server orchestration code asks the store to start, pause, finish, cancel, or recover work. It does not update lifecycle tables directly.
67
67
 
68
68
  The worker receives one explicit command and executes it. It does not infer the command from nullable fields.
69
69
 
@@ -210,13 +210,13 @@ Update authoring docs and all built-in workflows in the same change. Keep no ali
210
210
 
211
211
  ### Make worker commands explicit
212
212
 
213
- Add the tagged run command to `src/host/worker-protocol.ts`, the host bootstrap response, and `src/host/worker-entry.ts`.
213
+ Add the tagged run command to `src/server/workflow-runner-protocol.ts`, the host bootstrap response, and `src/server/workflow-runner-entry.ts`.
214
214
 
215
215
  Replace the `initialized` and `parentRunId` dispatch heuristic with an exhaustive command switch. Add the engine path for a fresh restart and keep checkpoint continuation separate. Remove the superseded dispatch code.
216
216
 
217
217
  ### Centralize durable transitions
218
218
 
219
- Move direct lifecycle SQL from `src/host/runner.ts` into typed store operations in the state and workflow-store modules. Replace ambiguous boolean returns used by run failure and cancellation with typed results.
219
+ Move direct lifecycle SQL from `src/server/runner.ts` into typed store operations in the state and workflow-store modules. Replace ambiguous boolean returns used by run failure and cancellation with typed results.
220
220
 
221
221
  Keep claim fencing and revision checks in each state transaction. The runner handles process supervision and protocol routing only.
222
222
 
@@ -256,7 +256,7 @@ Do not keep feature flags or fallback behavior.
256
256
 
257
257
  ### Update documentation
258
258
 
259
- Update `WORKFLOW_HOST.md`, `SQLITE_STATE.md`, and `workflows.md` after implementation so they describe the shipped interfaces and recovery behavior. Keep this plan as the decision and implementation record.
259
+ Update `WORKFLOW_SERVER.md`, `SQLITE_STATE.md`, and `workflows.md` after implementation so they describe the shipped interfaces and recovery behavior. Keep this plan as the decision and implementation record.
260
260
 
261
261
  ## Tests
262
262
 
@@ -284,7 +284,7 @@ Update `WORKFLOW_HOST.md`, `SQLITE_STATE.md`, and `workflows.md` after implement
284
284
  - A later reconciliation creates the missing terminal message once.
285
285
  - Terminalization ends open turns and pending interactions in the same state transaction.
286
286
 
287
- ### Worker recovery
287
+ ### Runner recovery
288
288
 
289
289
  - A worker crash after a newer durable revision resumes safely.
290
290
  - A worker crash at the same revision parks once and does not relaunch.
@@ -316,7 +316,7 @@ Automated tests use temporary directories and deterministic providers. They do n
316
316
  - A terminal run has no open workflow turn.
317
317
  - Later ordinary Pi turns cannot attach to terminal workflow work.
318
318
  - No raw SQLite uniqueness or media-type error reaches normal recovery paths.
319
- - Host, extension, widget, CLI, Herdr, and `piw` agree on run activity.
319
+ - Server, extension, widget, CLI, Herdr, and `piw` agree on run activity.
320
320
  - Pi core and private Pi APIs remain unchanged. Pi session schemas also remain unchanged.
321
321
  - One host and one database remain. The system keeps one client protocol and one production runtime.
322
322
 
@@ -1,6 +1,6 @@
1
1
  # Terminal workflow messages
2
2
 
3
- This specification defines the final Pi message for an interactive workflow. It replaces the separate deferred-turn and `workflow_turn_intents` design. Terminal messages use the same host state, client operations, and extension coordinator as all other [workflow messages](WORKFLOW_STEP_MESSAGES.md).
3
+ This specification defines the final Pi message for an interactive workflow. It replaces the separate deferred-turn and `workflow_turn_intents` design. Terminal messages use the same server state, client operations, and extension coordinator as all other [workflow messages](WORKFLOW_STEP_MESSAGES.md).
4
4
 
5
5
  The earlier [deferred-turn plan](plans/2026-08-21-deferred-turn-intents-plan.md) and [terminal restart plan](plans/2026-08-27-workflow-terminal-restart-plan.md) remain historical design records. This document is the current contract.
6
6
 
@@ -14,7 +14,7 @@ The earlier [deferred-turn plan](plans/2026-08-21-deferred-turn-intents-plan.md)
14
14
 
15
15
  ## Core rule
16
16
 
17
- The host creates one `terminal` workflow message in the same transaction that records the final terminal outcome. Only the final run in a continuation chain creates this message. A parent settled by a continuation does not create one.
17
+ The server creates one `terminal` workflow message in the same transaction that records the final terminal outcome. Only the final run in a continuation chain creates this message. A parent settled by a continuation does not create one.
18
18
 
19
19
  The terminal message uses the same `workflow_messages` table and `WorkflowMessageCoordinator` as steps, decisions, notifications, and follow-ups. Initial, reminder, and resumed prompts are one step-message kind. There is no `workflow_turn_intents` table, deferred-turn sender, terminal sender, or second send path.
20
20
 
@@ -28,9 +28,9 @@ A terminal message can report:
28
28
  - workflow failure;
29
29
  - timeout with no recovery edge;
30
30
  - cancellation;
31
- - launch or worker failure that became the final run outcome.
31
+ - launch or runner failure that became the final run outcome.
32
32
 
33
- Pause, Escape, a waiting checkpoint, a nonfinal continuation parent, user hold, and normal host shutdown do not create a terminal message.
33
+ Pause, Escape, a waiting checkpoint, a nonfinal continuation parent, user hold, and normal server shutdown do not create a terminal message.
34
34
 
35
35
  A claim loss is a handoff. It creates no terminal outcome or terminal message unless later recovery proves that the run itself failed.
36
36
 
@@ -48,15 +48,15 @@ A terminal workflow message is open only until its first model turn ends. The ex
48
48
 
49
49
  The end report includes `stopReason: "completed"`, `"aborted"`, or `"error"`. Response-entry evidence comes from `ctx.sessionManager.getBranch()` after `agent_end` and can be null. A repeated report adopts the stored result. A stale turn ID cannot end a newer turn.
50
50
 
51
- If Pi restarts after a terminal message was sent but before its end was reported, the extension's idle-session active-branch report records a synthetic end with `stopReason: "lost"`. Host restart alone does not close the turn. The terminal result remains durable and visible, but the host does not pretend that the model turn completed.
51
+ If Pi restarts after a terminal message was sent but before its end was reported, the extension's idle-session active-branch report records a synthetic end with `stopReason: "lost"`. Server restart alone does not close the turn. The terminal result remains durable and visible, but the server does not pretend that the model turn completed.
52
52
 
53
53
  ## Sending and recovery
54
54
 
55
- After every host connection, the coordinator waits for the complete origin-session view and reports the active branch before it sends a workflow message or reports a model turn. The host gives the next eligible pending message only to the active coordinator epoch for that session. A replacement connection fences the old one.
55
+ After every server connection, the coordinator waits for the complete origin-session view and reports the active branch before it sends a workflow message or reports a model turn. The server gives the next eligible pending message only to the active coordinator epoch for that session. A replacement connection fences the old one.
56
56
 
57
57
  The coordinator waits until Pi is idle and has no pending messages. It keeps the terminal workflow message ID in its in-memory queued map, checks the active branch, and reports a matching entry before any send. Otherwise, it performs one final synchronous check that Pi is idle, has no pending input, the message is absent, and its connection still owns the active epoch. It calls documented `pi.sendMessage()` without an `await` between that check and the call.
58
58
 
59
- A matching hidden workflow message ID in the active branch proves that Pi accepted the message. The host records the matching Pi entry ID and changes the message to `sent`, even if its source cancelled it after the send. If the extension reloads, it reports the active branch and adopts that entry before another send.
59
+ A matching hidden workflow message ID in the active branch proves that Pi accepted the message. The server records the matching Pi entry ID and changes the message to `sent`, even if its source cancelled it after the send. If the extension reloads, it reports the active branch and adopts that entry before another send.
60
60
 
61
61
  Absence is usable only when all three facts are true:
62
62
 
@@ -38,7 +38,7 @@ Reading shared state never gives mutation authority. Every durable write checks
38
38
 
39
39
  ## Boundaries
40
40
 
41
- The workflow engine stays independent of Pi. The Pi extension hosts the engine and connects it to a conversation. Controllers manage durable external resources. Viewers read recorded state without changing it.
41
+ The workflow engine stays independent of Pi. The Pi extension servers the engine and connects it to a conversation. Controllers manage durable external resources. Viewers read recorded state without changing it.
42
42
 
43
43
  Keep these layers separate and connect them through small public interfaces.
44
44
 
@@ -168,7 +168,7 @@ The accepted human sources are:
168
168
  - the Pi interactive decision view; and
169
169
  - a configured external decision channel such as Telegram.
170
170
 
171
- The host assigns the source. A workflow or model cannot claim that an answer came from a person. Pi non-interactive modes can wait for Telegram, but they cannot manufacture a Pi UI answer.
171
+ The server assigns the source. A workflow or model cannot claim that an answer came from a person. Pi non-interactive modes can wait for Telegram, but they cannot manufacture a Pi UI answer.
172
172
 
173
173
  ## Audiences and channel profiles
174
174
 
@@ -199,7 +199,7 @@ Private configuration maps the audience to channels:
199
199
  }
200
200
  ```
201
201
 
202
- The workflow never receives a bot token, user ID, chat ID, Telegram message ID, or Pi session detail. Channel profiles are private host configuration and are excluded from run presentation.
202
+ The workflow never receives a bot token, user ID, chat ID, Telegram message ID, or Pi session detail. Channel profiles are private server configuration and are excluded from run presentation.
203
203
 
204
204
  pi-workflows keeps credential references in a separate private file. A Telegram credential points to an existing absolute mode-`0600` token file:
205
205
 
@@ -222,7 +222,7 @@ The same Unix account can read a local credential file. This design prevents acc
222
222
 
223
223
  ## Channel interface
224
224
 
225
- The host owns decision state and launches each external channel adapter as a supervised child process. The private child protocol has these message kinds:
225
+ The server owns decision state and launches each external channel adapter as a supervised child process. The private child protocol has these message kinds:
226
226
 
227
227
  - `channel.ready`;
228
228
  - `channel.present`;
@@ -230,15 +230,15 @@ The host owns decision state and launches each external channel adapter as a sup
230
230
  - `channel.settle`; and
231
231
  - `channel.exiting`.
232
232
 
233
- Each message names the adapter epoch, channel profile, saved request or settlement record, expected revision, and stable attempt ID. The host validates and saves every state change. The child never opens SQLite, loads workflow code, changes a run directly, receives the canonical decision subject, or receives another channel's credentials.
233
+ Each message names the adapter epoch, channel profile, saved request or settlement record, expected revision, and stable attempt ID. The server validates and saves every state change. The child never opens SQLite, loads workflow code, changes a run directly, receives the canonical decision subject, or receives another channel's credentials.
234
234
 
235
235
  Channel handling is independent from workflow routing. A failed Telegram send leaves the decision available in Pi. Audience policy decides whether one successful channel is enough or whether all configured channels must receive the request.
236
236
 
237
237
  ### Pi channel
238
238
 
239
- The host creates one `decision` workflow message for the origin session. The shared extension coordinator shows it through documented `pi.sendMessage()` with no model turn. The message lists the request ID, choices, input rule, and deadline. It uses no blocking Pi dialog and no private Pi API.
239
+ The server creates one `decision` workflow message for the origin session. The shared extension coordinator shows it through documented `pi.sendMessage()` with no model turn. The message lists the request ID, choices, input rule, and deadline. It uses no blocking Pi dialog and no private Pi API.
240
240
 
241
- A verified operator answers with `/workflow answer` or the matching `piw` control. The host validates the choice and optional text, records the Pi channel as the source, and accepts only the first valid winner. Closing or reloading Pi cannot lose the request. On `session_start` or `session_tree`, the extension adopts an existing decision message or creates one new `decision` message when the pending request has no entry on the active branch.
241
+ A verified operator answers with `/workflow answer` or the matching `piw` control. The server validates the choice and optional text, records the Pi channel as the source, and accepts only the first valid winner. Closing or reloading Pi cannot lose the request. On `session_start` or `session_tree`, the extension adopts an existing decision message or creates one new `decision` message when the pending request has no entry on the active branch.
242
242
 
243
243
  ### Telegram channel
244
244
 
@@ -252,11 +252,11 @@ A choice without input submits from its button. A text choice such as `replan` w
252
252
  4. the adapter verifies the numeric user ID, chat ID, reply message ID, decision ID, and request digest; and
253
253
  5. the exact received text becomes `input.instructions`.
254
254
 
255
- The adapter does not infer a choice from ordinary chat text. Callback payloads contain short opaque IDs because Telegram limits callback data. The host's channel records map each opaque ID to the validated decision request. Credentials remain outside the database and reach only the matching supervised adapter child.
255
+ The adapter does not infer a choice from ordinary chat text. Callback payloads contain short opaque IDs because Telegram limits callback data. The server's channel records map each opaque ID to the validated decision request. Credentials remain outside the database and reach only the matching supervised adapter child.
256
256
 
257
- Telegram permits one long-polling consumer for a bot profile. The global host starts at most one adapter child for that profile and keeps the package-owned on-demand host process alive while an external decision is pending. No Pi process or adapter child owns a SQLite lease. If the host stops, the next Pi, CLI, or `piw` client starts it and the host recovers the saved channel state before it starts another adapter child. This design installs no operating-system service.
257
+ Telegram permits one long-polling consumer for a bot profile. The global server starts at most one adapter child for that profile and keeps the package-owned on-demand server process alive while an external decision is pending. No Pi process or adapter child owns a SQLite lease. If the server stops, the next Pi, CLI, or `piw` client starts it and the server recovers the saved channel state before it starts another adapter child. This design installs no operating-system service.
258
258
 
259
- The Bot API does not provide an idempotency key for `sendMessage`. Before it tells the adapter to send or settle a message, the host records the exact attempt in `effects` and `effect_attempts`. A confirmed Telegram message ID settles the effect and remains in its result. A timed-out, disconnected, or interrupted exact attempt with no proof becomes `ambiguous` and is not retried automatically. Pi remains available while the operator checks Telegram and explicitly confirms or retries the operation. This prevents blind duplicate sends without claiming exactly-once Telegram behavior.
259
+ The Bot API does not provide an idempotency key for `sendMessage`. Before it tells the adapter to send or settle a message, the server records the exact attempt in `effects` and `effect_attempts`. A confirmed Telegram message ID settles the effect and remains in its result. A timed-out, disconnected, or interrupted exact attempt with no proof becomes `ambiguous` and is not retried automatically. Pi remains available while the operator checks Telegram and explicitly confirms or retries the operation. This prevents blind duplicate sends without claiming exactly-once Telegram behavior.
260
260
 
261
261
  ## Durable decision records
262
262
 
@@ -328,7 +328,7 @@ Adoption does not change the lease, claim generation, queue state, timestamps, o
328
328
 
329
329
  This alpha change updates the current request, accepted-result, receipt, resolution, continuation, and snapshot contracts in place. Old active runs refuse resume through normal source and definition identity checks. There is no compatibility reader, migration, dual path, or new schema generation. The continuation startup fix uses existing queue and lease records. It adds no field, table, migration, or schema version. Existing compatible prepared or initialized continuations are adopted. Updated viewers label a human decision as a checkpoint, show its deadline and automatic action when present, and keep the canonical subject separate. Private channel configuration and transport identifiers remain hidden.
330
330
 
331
- The engine remains independent from Pi and Telegram. Core code owns decision contracts and validation. The host owns durable acceptance, continuation, workflow messages, and channel-child supervision. The Pi extension owns documented session presentation and controls. The Telegram adapter child owns Bot API translation. Workflow definitions own only the question, choices, audience, and routes.
331
+ The engine remains independent from Pi and Telegram. Core code owns decision contracts and validation. The server owns durable acceptance, continuation, workflow messages, and channel-child supervision. The Pi extension owns documented session presentation and controls. The Telegram adapter child owns Bot API translation. Workflow definitions own only the question, choices, audience, and routes.
332
332
 
333
333
  ## Contract impact
334
334
 
@@ -360,7 +360,7 @@ The implementation must test:
360
360
  - identical and conflicting retries;
361
361
  - crashes before and after answer acceptance and continuation creation;
362
362
  - ambiguous Telegram sends;
363
- - one supervised long-poll adapter per profile and host-restart recovery;
363
+ - one supervised long-poll adapter per profile and server-restart recovery;
364
364
  - decision cancellation and expiry;
365
365
  - included `plan-approval` routes and bounded replan loops;
366
366
  - viewer redaction; and