@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
@@ -0,0 +1,318 @@
1
+ ---
2
+ title: Keep large workflow history out of runner resume replies
3
+ author: Onur Solmaz <2453968+osolmaz@users.noreply.github.com>
4
+ date: 2026-09-04
5
+ status: implemented
6
+ ---
7
+
8
+ # Keep large workflow history out of runner resume replies
9
+
10
+ ## Goal
11
+
12
+ A workflow runner must resume, wait, continue, or finish even when its Pi session history is large.
13
+
14
+ The workflow server will send the runner only the execution state it needs. SQLite will keep session messages and tool results. It will also keep activity events and viewer history. If an execution value cannot fit in one runner-server message, the server will send a content reference and the runner will read the exact value in bounded parts.
15
+
16
+ ## Observed failure
17
+
18
+ Monitor run `20260904T050230350Z-monitor-da3951fb` failed while it resumed from a waiting step.
19
+
20
+ The runner called `store.prepareRunResume`. The server returned a complete `LoadedWorkflowRun`, although the engine used only `loaded.state`. The response included all session records and trace history. It also included the workflow snapshot plus all settings and follow-ups.
21
+
22
+ The first oversized response was 1,322,183 bytes. Its session entries alone used 926,764 bytes. Later retries produced responses of 1,974,127 and 1,989,453 bytes. Each response exceeded the 1 MiB runner protocol limit, so the runner crashed. Starting another runner repeated the same failure because it requested the same complete run.
23
+
24
+ This is an interface error. Large history is valid stored data, but it is not input to workflow execution.
25
+
26
+ ## Boundaries
27
+
28
+ This change is limited to the runner-server interface and workflow execution store. It also includes tests and related documentation in this repository.
29
+
30
+ The workflow server remains the only process that opens the writable SQLite database. Workflow runners do not read SQLite directly. The viewer continues to use its existing bounded pages and content references.
31
+
32
+ This change does not:
33
+
34
+ - change Pi core or private Pi interfaces
35
+ - change the SQLite schema or schema version
36
+ - add a service, database, transport, or production runtime
37
+ - truncate or delete workflow history
38
+ - raise the message limit as the primary fix
39
+ - make the complete run record available to workflow execution
40
+
41
+ The component naming hard cut is a separate refactor. It does not change this functional contract, and it is kept in a separate commit.
42
+
43
+ ## Design
44
+
45
+ ### Separate execution reads from inspection reads
46
+
47
+ `LoadedWorkflowRun` is an inspection record. It contains execution state, the saved definition, and all trace or session history. It also contains settings and follow-ups. It is useful inside the server and for inspection code, but it is too broad for the runner interface.
48
+
49
+ The execution store will expose only the two state reads that the engine uses:
50
+
51
+ - `prepareRunResume(runId)` prepares the existing run for resume and returns its committed `WorkflowRunState`.
52
+ - `readRunState(runId)` returns the current `WorkflowRunState` for continuation checks.
53
+
54
+ `WorkflowRunStore.readRun()` remains a server-local inspection method. It is removed from `WorkflowExecutionStore` and from the runner protocol.
55
+
56
+ Resume preparation keeps its current transaction and meaning. It interrupts unfinished node attempts and records `run_resume_prepared`. It then advances the revision and saves the new state. The method returns that committed state. It no longer rebuilds or returns the complete run.
57
+
58
+ Continuation still uses `WorkflowRunState` to check the parent status and waiting node. It also checks the source and input plus any human decision. It does not load session history or viewer data.
59
+
60
+ ### Keep history in the server
61
+
62
+ These values stay in SQLite and never cross to a runner as part of resume or continuation:
63
+
64
+ - session messages and tool results
65
+ - session activity events
66
+ - session capture records and integrity details
67
+ - viewer history and trace pages
68
+ - the full saved definition snapshot
69
+ - settings history
70
+ - follow-up history
71
+
72
+ The server can still read these values for inspection and reconciliation. Recording and viewer requests can also read them. This plan changes only what the execution runner receives.
73
+
74
+ ### Keep viewer reads separate
75
+
76
+ `piw` continues to request bounded run pages. Large viewer values continue to use the existing content-reference and chunked-read behavior.
77
+
78
+ Runner execution reads and viewer reads have different purposes. They must not share a complete-run response or cause one another to load more data.
79
+
80
+ ### Handle a required large execution value
81
+
82
+ A long workflow can make `WorkflowRunState` itself large. Narrowing the response removes unrelated history, but it does not prove that every required state will always fit in one message.
83
+
84
+ The runner protocol will therefore support one bounded content path on its existing connection:
85
+
86
+ 1. The server encodes and measures every response before writing it.
87
+ 2. A response that fits is sent inline.
88
+ 3. If the result is too large, the server stores or reuses its canonical bytes in the existing content-addressed `blobs` table. It sends a small reference with the media type and byte length plus the SHA-256 digest.
89
+ 4. The runner reads that content through the same runner protocol in bounded parts, using the digest and byte offset.
90
+ 5. The runner verifies the final byte length and digest before parsing and using the value.
91
+ 6. Missing content, a changed digest, an invalid range, or a non-JSON state returns a bounded rejected response. It does not crash the runner.
92
+
93
+ This is not a second transport. It is a bounded read on the existing runner-server connection and existing content-addressed storage. It keeps the complete required value available without putting it in one control message.
94
+
95
+ The internal runner protocol gets its own named byte limit instead of importing the external client protocol limit. The fix keeps an explicit bound. It does not depend on making that bound larger.
96
+
97
+ ### Make oversized replies controlled failures
98
+
99
+ The server must never discover an oversized reply only when it writes to the runner process.
100
+
101
+ Response preparation will measure the final canonical message first. Large results will become references. If the server cannot persist or reference a large result, it will return a small rejected response for that request. The supervisor will record the request and reason, but it will not mark the runner as crashed only because a reply was large.
102
+
103
+ Requests keep their existing message IDs, revision checks, claim checks, and accepted, adopted, rejected, or claim-lost outcomes.
104
+
105
+ ## Contract changes
106
+
107
+ This is an in-place alpha change to the version-1 runner contract.
108
+
109
+ - `WorkflowExecutionStore.prepareRunResume()` returns `WorkflowRunState`, not `LoadedWorkflowRun`.
110
+ - `WorkflowExecutionStore.readRun()` is replaced by `readRunState()`.
111
+ - Runner operation `store.readRun` is replaced by `store.readRunState`.
112
+ - `store.prepareRunResume` and `store.readRunState` return state inline or through a verified content reference.
113
+ - `WorkflowRunStore.readRun()` remains available only to server-local inspection code.
114
+ - Runner responses are measured before write and cannot fail with an uncaught size error.
115
+ - The internal runner message limit is owned by the runner protocol, not by the external client protocol.
116
+
117
+ There is no compatibility reader, alternate operation, dual path, feature flag, migration, or version-2 schema. The server and runner change together in one package release.
118
+
119
+ ## Implementation steps
120
+
121
+ ### Add the failing large-history test
122
+
123
+ **Where**
124
+
125
+ - `test/server.test.ts`
126
+ - `test/server-protocol-state.test.ts`
127
+ - `test/workflow-runner-entry.test.ts`
128
+ - Add a focused runner-server integration fixture under `test/fixtures/` only if the existing helpers cannot create the case clearly.
129
+
130
+ **Change**
131
+
132
+ Create a waiting run with more than 2 MB of recorded session entries and events while keeping its workflow state small. Resume it through the real child-runner protocol used in tests.
133
+
134
+ Prove that the old complete-run response crossed the runner message limit and crashed the runner. Keep the fixture deterministic and use temporary directories. Do not call a model.
135
+
136
+ **Verification**
137
+
138
+ The regression fails on the old code with the same oversized runner-response error seen in the saved Monitor run.
139
+
140
+ ### Narrow resume preparation to workflow state
141
+
142
+ **Where**
143
+
144
+ - `src/workflows/store.ts`
145
+ - `src/workflows/engine.ts`
146
+ - `src/server/workflow-runner-store.ts`
147
+ - `src/server/server.ts`
148
+
149
+ **Change**
150
+
151
+ Change `prepareRunResume()` to return the committed `WorkflowRunState` directly. Add a state-only store read that reconstructs the execution state from normalized run rows without loading session, trace, viewer, settings, or follow-up records.
152
+
153
+ Update `WorkflowEngine.resumeRun()` to use the returned state directly. Keep every existing resume validation and interrupted-attempt update. Keep the trace event, revision update, and viewer delta.
154
+
155
+ **Verification**
156
+
157
+ Store and engine tests prove that resume returns the same committed state and revision as before. Instrumented tests prove that resume does not query or serialize session history.
158
+
159
+ ### Replace complete-run continuation reads
160
+
161
+ **Where**
162
+
163
+ - `src/workflows/engine.ts`
164
+ - `src/workflows/store.ts`
165
+ - `src/server/workflow-runner-store.ts`
166
+ - `src/server/workflow-runner-protocol.ts`
167
+ - `src/server/server.ts`
168
+
169
+ **Change**
170
+
171
+ Replace the engine-facing `readRun()` method and `store.readRun` runner operation with `readRunState()` and `store.readRunState`.
172
+
173
+ Update `continueRun()` to read only the parent `WorkflowRunState`. Keep all current waiting-state, source, human-decision, and continuation checks.
174
+
175
+ Remove the broad read from `WorkflowExecutionStore`. Keep `WorkflowRunStore.readRun()` as a concrete server-side inspection API.
176
+
177
+ **Verification**
178
+
179
+ Engine tests cover ordinary continuation plus human-decision continuation. Protocol tests prove that the runner has no operation that returns `LoadedWorkflowRun`.
180
+
181
+ ### Keep history on the server
182
+
183
+ **Where**
184
+
185
+ - `src/workflows/store.ts`
186
+ - `src/server/server.ts`
187
+ - `src/server/view.ts`
188
+ - Existing session recording and viewer tests
189
+
190
+ **Change**
191
+
192
+ Audit the new state-only paths and confirm that they do not load or serialize session entries, session events, capture records, trace pages, settings history, follow-up history, or the full definition snapshot.
193
+
194
+ Do not change their storage, retention, recording, or inspection behavior.
195
+
196
+ **Verification**
197
+
198
+ A run with more than 2 MB of history resumes with a small state response. The same complete history remains readable from server-local inspection and the viewer after the run finishes.
199
+
200
+ ### Preserve bounded viewer reads
201
+
202
+ **Where**
203
+
204
+ - `src/server/view.ts`
205
+ - `src/client/client.ts`
206
+ - `docs/tui-viewer.md`
207
+ - Existing viewer protocol tests
208
+
209
+ **Change**
210
+
211
+ Do not route runner state through viewer projections and do not route viewer history through runner operations. Confirm that `piw` still uses bounded pages and existing content references.
212
+
213
+ No viewer contract change is expected. Update viewer code only if a regression test finds accidental coupling.
214
+
215
+ **Verification**
216
+
217
+ Existing viewer page and content-reference tests pass. Hydration, replay, and large-history tests also pass without larger page limits or complete-run reads.
218
+
219
+ ### Add safe large-result handling to the runner protocol
220
+
221
+ **Where**
222
+
223
+ - `src/server/workflow-runner-protocol.ts`
224
+ - `src/server/child-runner-supervisor.ts`
225
+ - `src/server/workflow-runner-entry.ts`
226
+ - `src/server/workflow-runner-store.ts`
227
+ - `src/workflows/store.ts` or a small server-owned content helper
228
+ - `src/state/prune.ts`
229
+ - Protocol and runner tests
230
+
231
+ **Change**
232
+
233
+ Give the internal runner protocol its own named frame limit. Add a typed version-1 content reference and one bounded content-read operation on the existing runner connection.
234
+
235
+ Before the server writes a response, encode and measure it. Spill only an oversized result to the existing content-addressed blob store. Return its reference so the runner can read and verify bounded parts. Keep message metadata and errors small enough to remain inline. Retain referenced blobs during active runner transfers, including during state pruning.
236
+
237
+ Convert all content persistence and range failures into bounded rejected responses. Do the same for invalid media types, lengths, digests, or parsed values. Do not stop the runner only because a result is too large.
238
+
239
+ **Verification**
240
+
241
+ Protocol tests cover the exact boundary, one byte over it, multiple chunks, and missing content. They also cover invalid offsets, wrong digests, or malformed JSON. A required state larger than one frame resumes successfully after verified reconstruction. An active large-result transfer survives concurrent state pruning. A rejected large-result read fails the workflow request clearly without a runner crash loop.
242
+
243
+ ### Audit all runner-server operations
244
+
245
+ **Where**
246
+
247
+ - `WorkflowRunnerStoreOperation` in `src/server/workflow-runner-protocol.ts`
248
+ - `ServerBackedWorkflowStore` in `src/server/workflow-runner-store.ts`
249
+ - Runner operation dispatch in `src/server/server.ts`
250
+ - `docs/WORKFLOW_SERVER.md`
251
+
252
+ **Change**
253
+
254
+ List every runner request and its response shape. For each operation, return only the value the runner uses. Remove complete-run and other broad response shapes from the runner boundary.
255
+
256
+ Keep content references as the general safe path for a required value that exceeds one frame. Do not add one-off size exceptions for individual operations.
257
+
258
+ **Verification**
259
+
260
+ A contract test exercises every operation with its largest supported result shape. No operation can return a complete run unless workflow execution actually requires every field, and no current operation has that requirement.
261
+
262
+ ### Add full regression coverage and update the contract docs
263
+
264
+ **Where**
265
+
266
+ - `test/store.test.ts`
267
+ - `test/engine.test.ts`
268
+ - `test/engine-more.test.ts`
269
+ - `test/server.test.ts`
270
+ - `test/workflow-runner-entry.test.ts`
271
+ - Existing runner protocol and end-to-end test files
272
+ - `docs/WORKFLOW_SERVER.md`
273
+ - `docs/SQLITE_STATE.md`
274
+ - `docs/workflows.md`
275
+
276
+ **Change**
277
+
278
+ Add one deterministic scenario with more than 2 MB of history that resumes, reaches another wait, continues, then finishes. Assert that no runner generation crashes and history remains complete in SQLite. Also assert that viewer reads remain bounded and every runner frame stays within its protocol limit.
279
+
280
+ Document the execution-only state reads and server-owned history. Also document the content-reference fallback, independent runner frame limit, and controlled large-response failure behavior.
281
+
282
+ **Verification**
283
+
284
+ The regression follows the full saved-run lifecycle. It passes without a real model or extra service. It also requires no schema change, history truncation, or raised limit.
285
+
286
+ ## Tests and checks
287
+
288
+ Run:
289
+
290
+ ```bash
291
+ npm run check
292
+ npm run test:e2e
293
+ npx slophammer-ts@latest dry .
294
+ npx slophammer-ts@latest check . --only ts.dependency-boundaries-required
295
+ npx -y @simpledoc/simpledoc check
296
+ git diff --check
297
+ ```
298
+
299
+ The automated tests must use temporary directories and deterministic providers. They must not call a real model.
300
+
301
+ After the package tests pass, install the built package through the normal local package path and run a manual smoke test. Use a saved run with more than 2 MB of history. Confirm that it resumes, waits, continues, then finishes. Confirm that `piw` can still inspect the complete history.
302
+
303
+ ## Acceptance criteria
304
+
305
+ The change is complete when all of these statements are true:
306
+
307
+ - A run with more than 2 MB of session history can resume, wait, continue, or finish.
308
+ - `prepareRunResume()` returns only the committed workflow state.
309
+ - Continuation uses a state-only read.
310
+ - Session history and viewer history do not enter runner resume or continuation replies.
311
+ - `piw` still reads complete history through bounded pages and content references.
312
+ - Every runner-server response is measured before it is written.
313
+ - A required result larger than one frame is transferred by a verified reference and bounded reads.
314
+ - A large reply cannot cause a runner crash loop.
315
+ - No runner operation returns a complete run when it needs only one small part.
316
+ - The SQLite schema and Pi core do not change, and no installed service changes.
317
+ - The public naming hard cut remains a separate refactor commit.
318
+ - All repository checks pass.
@@ -253,7 +253,7 @@ Add `--list-themes`. A picker Apply writes only the theme selection, preserves
253
253
  unknown config keys and comments, and uses a same-directory temporary file plus
254
254
  atomic rename. Applying a manual theme disables `auto_switch`, matching Herdr.
255
255
 
256
- Host light/dark detection and automatic sibling switching are a final theme
256
+ Server light/dark detection and automatic sibling switching are a final theme
257
257
  phase, not a prerequisite for manual theme selection. When added, query the
258
258
  host terminal background only through standard terminal escape sequences,
259
259
  restore terminal modes on exit, and retain the manually configured theme when
@@ -9,13 +9,13 @@ a recorded Pi conversation, themes, and remote viewing.
9
9
 
10
10
  The viewer uses the [incremental and virtualized viewer design](plans/2026-08-28-piw-incremental-viewer-plan.md).
11
11
 
12
- The run browser subscribes to small host-owned metadata views. It does not load trace, step, session, settings, or follow-up payloads. The host publishes a new bounded view only when its content changes.
12
+ The run browser subscribes to small server-owned metadata views. It does not load trace, step, session, settings, or follow-up payloads. The server publishes a new bounded view only when its content changes.
13
13
 
14
- Each live view keeps the host's `display` value separate from the durable workflow `state`. The run browser, current-run status, timeline, and latest graph use `display` directly. During an origin-session model turn, the latest graph presents the durable `waitingOn` node as running. Replay continues to use durable state and recorded history. `piw` does not calculate another live status.
14
+ Each live view keeps the server's `display` value separate from the durable workflow `state`. The run browser, current-run status, timeline, and latest graph use `display` directly. During an origin-session model turn, the latest graph presents the durable `waitingOn` node as running. Replay continues to use durable state and recorded history. `piw` does not calculate another live status.
15
15
 
16
16
  The selected run contains bounded pages. Step, trace, session-entry, session-event, settings, follow-up, and update pages have both a row limit and a byte budget. Replay can jump to any position. The viewer loads the page that contains that position and keeps only the current windows. A session-event page includes the replay checkpoint immediately before its first event. A compact graph projection keeps the latest attempt for each node and the taken transitions up to the replay point.
17
17
 
18
- Large values use host content references. `piw` fetches workflow definitions, graph history, and complete host display reasons before it publishes the related live view. It fetches other large details when the user opens them. It verifies the byte count and SHA-256 digest before it shows the complete text or JSON value. Page and content requests run outside input and drawing through the shared client protocol. A newer page selection replaces the previous request, including when the user returns to an earlier page. A failed first read leaves the run browser usable. A failed refresh keeps the last good view and marks it stale.
18
+ Large values use server content references. `piw` fetches workflow definitions, graph history, and complete server display reasons before it publishes the related live view. It fetches other large details when the user opens them. It verifies the byte count and SHA-256 digest before it shows the complete text or JSON value. Page and content requests run outside input and drawing through the shared client protocol. A newer page selection replaces the previous request, including when the user returns to an earlier page. A failed first read leaves the run browser usable. A failed refresh keeps the last good view and marks it stale.
19
19
 
20
20
  ## Install
21
21
 
@@ -28,10 +28,10 @@ cargo install pi-workflows
28
28
 
29
29
  ## Modes
30
30
 
31
- - `piw` connects to the local package-owned workflow host. If the socket is absent, it runs the installed `pi-workflows host start` command.
32
- - `piw <runId>` opens one host-owned run view.
33
- - `piw <runId> --once` waits for that run, renders one complete 120 × 40 plain-text frame, and exits. It returns a nonzero status for host, protocol, missing-run, or snapshot-timeout failures.
34
- - `piw serve [--bind 127.0.0.1:9377]` relays each WebSocket connection to one host socket over the [live client protocol](live-replay-protocol.md). Only loopback addresses are accepted; use an SSH tunnel for remote viewing.
31
+ - `piw` connects to the local package-owned workflow server. If the socket is absent, it runs the installed `pi-workflows server start` command.
32
+ - `piw <runId>` opens one server-owned run view.
33
+ - `piw <runId> --once` waits for that run, renders one complete 120 × 40 plain-text frame, and exits. It returns a nonzero status for server, protocol, missing-run, or snapshot-timeout failures.
34
+ - `piw serve [--bind 127.0.0.1:9377]` relays each WebSocket connection to one server socket over the [live client protocol](live-replay-protocol.md). Only loopback addresses are accepted; use an SSH tunnel for remote viewing.
35
35
  - `piw --connect ws://…` reads from another `piw serve` process.
36
36
  - `piw --theme <name>` selects a theme for this invocation.
37
37
  - `piw --list-themes` prints the built-in theme names.
@@ -169,7 +169,7 @@ light_name = "catppuccin-latte"
169
169
  colors accept `#rrggbb`, `#rgb`, `rgb(r,g,b)`, named terminal colors, and
170
170
  `reset`. Invalid fields are reported without discarding valid fields.
171
171
 
172
- When `auto_switch` is enabled, `PIW_THEME_APPEARANCE=dark|light` or the host's
172
+ When `auto_switch` is enabled, `PIW_THEME_APPEARANCE=dark|light` or the server's
173
173
  `COLORFGBG` value selects `dark_name` or `light_name` at startup. A manual
174
174
  selection in the picker disables automatic switching.
175
175
 
@@ -213,7 +213,7 @@ Revision gaps force a bounded snapshot.
213
213
 
214
214
  `piw serve` is a frame relay. It keeps no run projection or client activity after either side closes. Clients keep separate revision and page cursors, so one client's replay jump does not move another client. A lagged client gets a bounded snapshot instead of an unbounded patch backlog.
215
215
 
216
- The host resolves expanded prompt and output fields from durable content. Local and remote snapshots carry the same bounded semantic view and do not expose a database path.
216
+ The server resolves expanded prompt and output fields from durable content. Local and remote snapshots carry the same bounded semantic view and do not expose a database path.
217
217
 
218
218
  ## Interaction
219
219