@osolmaz/pi-workflows 0.13.0 → 0.13.2

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 (84) hide show
  1. package/README.md +11 -9
  2. package/dist/builtins/autodoc.workflow.d.ts +191 -4
  3. package/dist/builtins/autodoc.workflow.js +156 -30
  4. package/dist/builtins/autodoc.workflow.js.map +1 -1
  5. package/dist/builtins/autoimplement-command-batches.d.ts +1 -0
  6. package/dist/builtins/autoimplement-command-batches.js +29 -31
  7. package/dist/builtins/autoimplement-command-batches.js.map +1 -1
  8. package/dist/builtins/autoimplement.workflow.d.ts +1259 -29
  9. package/dist/builtins/autoimplement.workflow.js +416 -153
  10. package/dist/builtins/autoimplement.workflow.js.map +1 -1
  11. package/dist/builtins/autoplan.workflow.d.ts +6 -0
  12. package/dist/builtins/autoplan.workflow.js +68 -32
  13. package/dist/builtins/autoplan.workflow.js.map +1 -1
  14. package/dist/builtins/catalog.js +5 -5
  15. package/dist/builtins/catalog.js.map +1 -1
  16. package/dist/builtins/change-verification.workflow.d.ts +110 -0
  17. package/dist/builtins/change-verification.workflow.js +860 -0
  18. package/dist/builtins/change-verification.workflow.js.map +1 -0
  19. package/dist/builtins/monitor.workflow.js +4 -3
  20. package/dist/builtins/monitor.workflow.js.map +1 -1
  21. package/dist/builtins/plain-summary.workflow.js +35 -24
  22. package/dist/builtins/plain-summary.workflow.js.map +1 -1
  23. package/dist/builtins/plan-change.workflow.d.ts +361 -6
  24. package/dist/builtins/plan-change.workflow.js +26 -0
  25. package/dist/builtins/plan-change.workflow.js.map +1 -1
  26. package/dist/builtins/sanity-check.workflow.js +19 -22
  27. package/dist/builtins/sanity-check.workflow.js.map +1 -1
  28. package/dist/builtins/workspace-preparation.workflow.d.ts +75 -0
  29. package/dist/builtins/workspace-preparation.workflow.js +498 -0
  30. package/dist/builtins/workspace-preparation.workflow.js.map +1 -0
  31. package/dist/controllers/sqlite.js +16 -51
  32. package/dist/controllers/sqlite.js.map +1 -1
  33. package/dist/extension/decision-channels.js +45 -7
  34. package/dist/extension/decision-channels.js.map +1 -1
  35. package/dist/extension/executor.js +1 -4
  36. package/dist/extension/executor.js.map +1 -1
  37. package/dist/extension/index.js +2 -15
  38. package/dist/extension/index.js.map +1 -1
  39. package/dist/extension/recorder.d.ts +1 -1
  40. package/dist/extension/recorder.js +8 -8
  41. package/dist/extension/recorder.js.map +1 -1
  42. package/dist/state/schema.js +22 -3
  43. package/dist/state/schema.js.map +1 -1
  44. package/dist/viewer/session-reducer.d.ts +0 -1
  45. package/dist/viewer/session-reducer.js +2 -24
  46. package/dist/viewer/session-reducer.js.map +1 -1
  47. package/dist/workflows/engine.js +4 -3
  48. package/dist/workflows/engine.js.map +1 -1
  49. package/dist/workflows/store.d.ts +6 -1
  50. package/dist/workflows/store.js +286 -33
  51. package/dist/workflows/store.js.map +1 -1
  52. package/dist/workflows/types.d.ts +1 -1
  53. package/docs/SQLITE_STATE.md +20 -14
  54. package/docs/WORKFLOW_COMPOSITION.md +8 -0
  55. package/docs/plans/2026-08-23-assistant-agent-completion-plan.md +1 -1
  56. package/docs/plans/2026-08-24-change-scoped-verification-plan.md +419 -0
  57. package/docs/plans/2026-08-25-autoplan-user-intent-capture-plan.md +107 -0
  58. package/docs/session-event-journal.md +2 -3
  59. package/docs/workflows.md +43 -21
  60. package/herdr-plugin.toml +1 -1
  61. package/package.json +1 -1
  62. package/skills/autodoc/SKILL.md +7 -0
  63. package/skills/autoimplement/SKILL.md +4 -0
  64. package/src/builtins/autodoc.workflow.ts +184 -33
  65. package/src/builtins/autoimplement-command-batches.ts +39 -33
  66. package/src/builtins/autoimplement.workflow.ts +483 -175
  67. package/src/builtins/autoplan.workflow.ts +80 -32
  68. package/src/builtins/catalog.ts +5 -5
  69. package/src/builtins/change-verification.workflow.ts +1143 -0
  70. package/src/builtins/monitor.workflow.ts +6 -3
  71. package/src/builtins/plain-summary.workflow.ts +38 -40
  72. package/src/builtins/plan-change.workflow.ts +35 -0
  73. package/src/builtins/sanity-check.workflow.ts +19 -22
  74. package/src/builtins/workspace-preparation.workflow.ts +668 -0
  75. package/src/controllers/sqlite.ts +19 -53
  76. package/src/extension/decision-channels.ts +47 -7
  77. package/src/extension/executor.ts +1 -4
  78. package/src/extension/index.ts +2 -15
  79. package/src/extension/recorder.ts +10 -8
  80. package/src/state/schema.ts +22 -3
  81. package/src/viewer/session-reducer.ts +2 -29
  82. package/src/workflows/engine.ts +4 -3
  83. package/src/workflows/store.ts +397 -43
  84. package/src/workflows/types.ts +0 -1
@@ -0,0 +1,419 @@
1
+ ---
2
+ title: Make Autoimplement verification change-scoped
3
+ author: Onur Solmaz <2453968+osolmaz@users.noreply.github.com>
4
+ date: 2026-08-24
5
+ ---
6
+
7
+ # Make Autoimplement verification change-scoped
8
+
9
+ Autoimplement and Autodoc must judge the current change, not the complete health of the repository. A check failure that already exists on the base branch must stay visible, but it must not stop unrelated work. A new failure caused by the current change must enter a bounded fix-and-check loop.
10
+
11
+ Known commands and safe mechanical fixes must run as program actions. The model must handle only work that needs judgment, such as proposing a branch name, editing prose, changing code, or classifying evidence that a direct comparison cannot settle.
12
+
13
+ This plan also fixes the related workflow problems found during the failed Autoimplement run on 2026-08-24:
14
+
15
+ - documentation verification returns one Boolean result;
16
+ - a documentation failure stops without a repair loop;
17
+ - an included Autodoc blocker bypasses Autoimplement's blocker challenge;
18
+ - documentation can change before Autoimplement selects a safe workspace;
19
+ - the same model can edit documents and run deterministic checks;
20
+ - repository-wide failures are not compared with the base branch;
21
+ - the final blocked result can lose the original reason and evidence;
22
+ - ordinary node failures can stop without safe recovery;
23
+ - a mistaken missing-plan result can stop without challenge; and
24
+ - documentation failure has no clear handoff back to implementation.
25
+
26
+ The failed SimpleDoc check that exposed these problems was unchanged on the candidate and a clean `origin/main` worktree. It reported the same 30 renames, 32 frontmatter insertions, and 8 reference updates in both places. Formatting, links, privacy, whitespace, and changed-file digests passed. Autoimplement should have reported the SimpleDoc backlog and continued.
27
+
28
+ ## Goal
29
+
30
+ Add two reusable internal workflow compositions:
31
+
32
+ 1. workspace preparation, which selects and confirms where edits will happen; and
33
+ 2. change verification, which runs checks, compares eligible failures with the base branch, repairs current-change failures, and preserves exact evidence.
34
+
35
+ Use them in Autodoc first. Then apply the same result and routing rules to Autoimplement's local checks, review commands, CI inspection, and delivery. Keep each stage's external actions separate. Do not add a general effect runner or a workflow-engine primitive.
36
+
37
+ ## Principles
38
+
39
+ - Prepare the workspace before the first edit.
40
+ - Let the model propose names and make semantic decisions.
41
+ - Let program actions run Git commands, checks, comparisons, and safe mechanical fixes.
42
+ - Judge failures against the current change.
43
+ - Keep all base failures visible.
44
+ - Repair new failures within a fixed limit.
45
+ - Challenge every claimed blocker except explicit cancellation and verified human rejection.
46
+ - Observe a possible partial effect before retrying a mutating step.
47
+ - Keep the graph explicit, durable, bounded, and easy to inspect.
48
+
49
+ ## Workspace selection
50
+
51
+ Autoimplement gains a `workspaceMode` input with these values:
52
+
53
+ - `auto`: select the safest allowed mode from the current repository state and authority;
54
+ - `branch`: work in the current checkout on a task branch;
55
+ - `worktree`: work in a standard sibling worktree on a task branch; and
56
+ - `defaultBranch`: work directly on the repository's real default branch.
57
+
58
+ `auto` is the default. It follows these rules:
59
+
60
+ 1. Keep the current branch when it is already the correct non-default task branch.
61
+ 2. For a clean default branch, ask the workspace-planning model for a clear task branch name, then create or confirm that branch programmatically.
62
+ 3. When unrelated changes must remain in the current checkout, ask for a task branch name and create a standard sibling worktree programmatically.
63
+ 4. Use `defaultBranch` only when the task authority or repository policy explicitly permits direct work on the default branch.
64
+
65
+ For `branch` and `worktree`, the model proposes the branch name. A program action validates and applies the proposal. Validation rejects an empty name, an invalid Git reference, a reserved or conflicting name, the wrong base, a path outside the standard worktree location, and a proposal that would move or overwrite existing work.
66
+
67
+ For `defaultBranch`, no task branch or worktree is created. A program action confirms all of these facts before mutation:
68
+
69
+ - the checked-out branch is the repository's actual default branch;
70
+ - direct default-branch work is authorized by the request or repository policy;
71
+ - the expected base revision is current;
72
+ - existing unrelated changes will not be overwritten or included; and
73
+ - later commit and push actions stay within their separate authority.
74
+
75
+ Working directly on the default branch does not imply commit, push, merge, release, or deployment authority. Delivery must support a direct-default result: commit and push only when authorized, otherwise leave the verified local change and report it. It must not try to open a pull request from the default branch to itself.
76
+
77
+ The workspace result becomes the source of truth for later paths. It records:
78
+
79
+ - mode;
80
+ - repository path;
81
+ - worktree path when applicable;
82
+ - base branch and base revision;
83
+ - work branch;
84
+ - whether direct default-branch work is authorized;
85
+ - pre-existing changed paths;
86
+ - creation or adoption evidence; and
87
+ - the scope that later stages may change.
88
+
89
+ All later prompts and actions use the prepared absolute path. They do not fall back to the Pi process working directory.
90
+
91
+ ## Programmatic checks
92
+
93
+ Known checks run through action or shell nodes. The model does not run them through tools inside an agent step.
94
+
95
+ Each check request records:
96
+
97
+ - a stable ID;
98
+ - executable and argument array;
99
+ - absolute working directory;
100
+ - timeout;
101
+ - output limit;
102
+ - whether the command is read-only;
103
+ - whether it is eligible for base comparison;
104
+ - whether it supports changed-file scope; and
105
+ - the finding format when the tool provides one.
106
+
107
+ A command request cannot use a shell wrapper, hidden environment changes, standard input, or an unbounded timeout. Verification records the exit code, signal, duration, stdout, stderr, truncation state, timeout state, and spawn failure. A truncated or incomplete result cannot pass.
108
+
109
+ Repository guidance remains the first source for command selection. If it gives a complete command list, the workflow uses it without a model turn. If it does not, one model step proposes a structured command plan. Program code validates that plan before execution.
110
+
111
+ ## Candidate and base comparison
112
+
113
+ When a repository-wide read-only check fails and the output does not prove that the current change caused it, change verification runs the same command on a temporary detached worktree at the selected base revision.
114
+
115
+ The base action must:
116
+
117
+ 1. create a temporary worktree outside the candidate checkout;
118
+ 2. run only checks marked read-only and base-eligible;
119
+ 3. use the same executable, arguments, timeout, and output limit;
120
+ 4. record setup and dependency limitations;
121
+ 5. remove the temporary worktree in a bounded cleanup path; and
122
+ 6. preserve cleanup evidence if removal fails.
123
+
124
+ Comparison first uses stable finding IDs when a tool provides them. Otherwise it normalizes only line endings and the temporary worktree path. It does not remove timestamps, counts, file names, or other facts merely to make outputs match.
125
+
126
+ The result separates:
127
+
128
+ - `relatedFailures`: new failures caused by the candidate change;
129
+ - `unrelatedFailures`: matching failures already present on the base;
130
+ - `fixedBaselineFailures`: base failures that the candidate removes;
131
+ - `unknownFailures`: differences that available evidence cannot attribute safely;
132
+ - `untestedChecks`: checks that could not produce complete evidence; and
133
+ - the complete candidate and base command results.
134
+
135
+ Unrelated failures are reported but do not fail the current change. Unknown failures require bounded model judgment or blocker challenge. A `ready` result requires complete candidate checks and no related or unknown failure.
136
+
137
+ ## Repair and recheck
138
+
139
+ A change-related failure enters a bounded repair loop. Start with two repair attempts. Keep the limit explicit in the workflow graph.
140
+
141
+ Mechanical repair is allowed only when the command plan declares:
142
+
143
+ - the direct executable and arguments;
144
+ - the exact changed files it may edit;
145
+ - the check IDs it is expected to fix;
146
+ - its timeout; and
147
+ - the expected type of diff.
148
+
149
+ The action records the diff before and after the fixer. It rejects an edit outside the declared files. It does not infer or run a broad repository migration such as applying all SimpleDoc recommendations to an old repository.
150
+
151
+ When no safe mechanical fix exists, a model repair step receives the approved plan plus related and unknown failures. It does not receive unrelated failures as work to fix. It may make semantic documentation or code changes only inside the prepared workspace and declared scope.
152
+
153
+ After each repair, the same programmatic checks run again. Stop the loop when:
154
+
155
+ - verification succeeds;
156
+ - the repair makes no diff;
157
+ - the failure fingerprint repeats; or
158
+ - the attempt limit is reached.
159
+
160
+ An exhausted repair loop creates a complete blocker claim and goes to blocker challenge. It does not stop directly.
161
+
162
+ ## Shared verification result
163
+
164
+ Replace stage-specific Boolean results with one internal result shape. It uses these routes:
165
+
166
+ - `ready`: all current-change checks passed;
167
+ - `repairable`: a safe repair path exists;
168
+ - `needsJudgment`: evidence is complete but attribution or repair needs model judgment; and
169
+ - `blocked`: a material outside-scope problem remains after safe recovery.
170
+
171
+ The result records:
172
+
173
+ - originating workflow and qualified node;
174
+ - current workspace identity;
175
+ - changed files;
176
+ - candidate commands;
177
+ - base commands;
178
+ - related, unrelated, fixed, unknown, and untested findings;
179
+ - repair attempts and failure fingerprints;
180
+ - output references;
181
+ - reason; and
182
+ - concrete evidence.
183
+
184
+ Keep large command output in the existing action result and refer to it from findings. Do not copy large output into each failure entry.
185
+
186
+ ## Autodoc changes
187
+
188
+ Autodoc keeps model steps for these tasks:
189
+
190
+ - finding or confirming the selected plan;
191
+ - choosing canonical documentation;
192
+ - writing or updating prose; and
193
+ - repairing semantic documentation failures.
194
+
195
+ Autodoc uses program steps for:
196
+
197
+ - workspace preparation when an update is required;
198
+ - documentation checks;
199
+ - base comparison;
200
+ - safe mechanical fixes;
201
+ - result classification when exact comparison is sufficient; and
202
+ - graph routing.
203
+
204
+ Replace `verifyDocumentation` and its `passed` Boolean with the shared change-verification composition. A matching base SimpleDoc failure returns `ready` with visible unrelated failures. A new documentation failure enters repair and recheck.
205
+
206
+ Autodoc's blocked exit must preserve the originating node, exact command evidence, related and unrelated failures, all repair attempts, and the accepted reason. Its blocked reason must not ignore verification output.
207
+
208
+ ## Autoimplement changes
209
+
210
+ Run workspace preparation before the first edit-capable node. Read-only plan discovery may run first. Documentation updates and implementation must use the prepared workspace.
211
+
212
+ Route these blocker sources through one challenge path:
213
+
214
+ - included Autodoc blocked exits;
215
+ - missing-plan claims;
216
+ - implementation classification;
217
+ - local verification;
218
+ - review command failures;
219
+ - review findings that claim an external block;
220
+ - CI inspection and CI command failures;
221
+ - delivery failures;
222
+ - exhausted repair loops; and
223
+ - ordinary node execution failures that safe recovery cannot resolve.
224
+
225
+ Explicit cancellation and verified human rejection remain terminal and bypass challenge.
226
+
227
+ A mistaken missing-plan claim may return to bounded discovery or adopt a plan already proved by the input or canonical documents. The challenge cannot invent an initial plan.
228
+
229
+ The blocker challenge must return the next practical stage, such as plan discovery, documentation, implementation, repair, review, CI inspection, delivery, redesign, or terminal blocked. A stable counter and failure fingerprint prevent loops.
230
+
231
+ ## Ordinary node failures
232
+
233
+ Extend the current timeout fallback into one bounded step-failure recovery path. Classify workflow steps as:
234
+
235
+ - pure;
236
+ - read-only;
237
+ - idempotent mutation; or
238
+ - mutation that needs observation before retry.
239
+
240
+ Pure and read-only failures can retry within the limit. For a mutating step, inspect durable repository or remote state first. Adopt an effect that already completed. Retry only the missing effect. Send an unsupported or ambiguous effect to blocker challenge with exact evidence.
241
+
242
+ This policy applies to both timeouts and ordinary failed outcomes. It never recovers explicit cancellation.
243
+
244
+ Examples:
245
+
246
+ - inspect the current diff before repeating a model edit;
247
+ - inspect commits before repeating a commit;
248
+ - inspect the remote branch after a lost push response;
249
+ - inspect existing comments before posting again;
250
+ - inspect merge state before repeating merge; and
251
+ - inspect recorded action output before rerunning a command batch.
252
+
253
+ ## Later Autoimplement stages
254
+
255
+ Apply the same related, unrelated, unknown, repairable, and blocked meanings to:
256
+
257
+ - local verification;
258
+ - reviewer command execution;
259
+ - CI inspection; and
260
+ - delivery verification.
261
+
262
+ Keep separate adapters for local commands, reviewer output, CI providers, pull-request comments, commits, pushes, and merges. Do not place all effects behind one universal runner.
263
+
264
+ CI failures that predate the candidate or belong to an unrelated target remain visible and do not fail the current change. When local reproduction is not possible, use provider evidence and model judgment. Never classify an unavailable or truncated result as unrelated automatically.
265
+
266
+ ## Blocker evidence
267
+
268
+ Create a durable blocker claim before challenge. It records:
269
+
270
+ - qualified source node;
271
+ - node attempt ID;
272
+ - current route;
273
+ - exact reason;
274
+ - evidence references;
275
+ - failed commands;
276
+ - related and unrelated failures;
277
+ - recovery attempts;
278
+ - alternatives checked; and
279
+ - the authority or external fact that could prevent progress.
280
+
281
+ Parent workflows preserve included child evidence. The final blocked result uses the accepted claim directly. It must not replace available evidence with a generic reason or `null`.
282
+
283
+ ## Implementation order
284
+
285
+ Implement the change in these complete slices:
286
+
287
+ 1. Add the regression for the 2026-08-24 SimpleDoc incident.
288
+ 2. Add shared types, validation, finding comparison, and evidence helpers.
289
+ 3. Add workspace planning and programmatic workspace preparation with all four modes.
290
+ 4. Add candidate checks, base checks, comparison, and temporary worktree cleanup.
291
+ 5. Add mechanical and semantic repair with bounded recheck.
292
+ 6. Migrate Autodoc and remove the Boolean verification route.
293
+ 7. Put workspace preparation before Autoimplement mutation and pass its path to every later stage.
294
+ 8. Route all blocker claims through one challenge and preserve qualified child evidence.
295
+ 9. Extend timeout fallback to safe ordinary-failure recovery.
296
+ 10. Apply the shared verification meanings to local checks, review, CI, and delivery.
297
+ 11. Update skills, workflow documentation, examples, and built-in revision data.
298
+ 12. Run focused, full, persistence, and real-Pi tests before release.
299
+
300
+ Each slice must compile and pass its focused tests. Use a hard replacement during alpha. Do not keep the old Boolean route, duplicate verification path, compatibility alias, or feature flag.
301
+
302
+ ## Tests
303
+
304
+ ### Workspace
305
+
306
+ - A clean default branch in `auto` mode gets an LLM-proposed, programmatically created task branch.
307
+ - An existing correct task branch is adopted without creating another branch.
308
+ - A dirty default checkout gets an LLM-proposed branch in a standard sibling worktree.
309
+ - Explicit `branch` and `worktree` modes use the proposed name only after programmatic validation.
310
+ - `defaultBranch` succeeds only with direct-work authority and the actual default branch checked out.
311
+ - `defaultBranch` does not imply commit or push authority and never opens a pull request to itself.
312
+ - Detached HEAD, wrong base, invalid name, name conflict, hook failure, and worktree cleanup failure preserve evidence and route safely.
313
+ - Existing user changes are never stashed, reset, moved, overwritten, or included.
314
+ - Restart adopts the same prepared workspace instead of creating another one.
315
+
316
+ ### Verification
317
+
318
+ - All candidate checks pass.
319
+ - Candidate and base fail with the same SimpleDoc backlog; the run reports it as unrelated and continues.
320
+ - A candidate-only documentation failure is related.
321
+ - A base-only failure is recorded as fixed by the candidate.
322
+ - Base setup or command failure stays unknown.
323
+ - Timeout, spawn failure, cancellation, and output truncation cannot pass.
324
+ - Finding order and temporary worktree paths do not cause false differences.
325
+ - Only read-only base-eligible checks run on the base.
326
+ - Temporary base worktrees are cleaned after success, failure, restart, and cancellation.
327
+
328
+ ### Repair
329
+
330
+ - An allowlisted formatter changes only declared files and verification then passes.
331
+ - A fixer that changes an undeclared file is rejected with the diff preserved as evidence.
332
+ - A broad repository migration is not run automatically.
333
+ - Semantic repair sees related and unknown failures, not unrelated backlog.
334
+ - No diff, repeated fingerprint, and attempt exhaustion stop the loop and enter blocker challenge.
335
+
336
+ ### Routing and evidence
337
+
338
+ - An included Autodoc blocker reaches the shared challenge.
339
+ - A mistaken missing-plan claim retries discovery or adopts proved input without inventing a plan.
340
+ - Every non-exempt blocker source reaches challenge.
341
+ - Explicit cancellation and verified human rejection stay terminal.
342
+ - Qualified child evidence survives composition, restart, and final presentation.
343
+ - The final blocked result names the source node, commands, reason, evidence, and recovery attempts.
344
+
345
+ ### Failure recovery
346
+
347
+ - Safe read-only and pure steps retry within the limit.
348
+ - A partial local edit is inspected before continuation.
349
+ - A lost push or comment response is adopted when the remote effect exists.
350
+ - An uncertain consequential effect is not replayed blindly.
351
+ - Repeated failures stop at the bounded challenge path.
352
+ - Existing timeout behavior remains covered by the new general path.
353
+
354
+ ### Complete workflow
355
+
356
+ - A real-Pi Autoimplement fixture with a matching base SimpleDoc failure reaches implementation.
357
+ - A change-related documentation failure is repaired and rechecked.
358
+ - A true repository-rule or authority blocker ends with complete evidence.
359
+ - Documentation, local checks, review, CI, and delivery use the same failure meanings.
360
+ - Old terminal run data remains readable.
361
+ - Active runs with an incompatible built-in revision refuse unsafe resume.
362
+
363
+ ## Acceptance criteria
364
+
365
+ - No edit-capable node runs before workspace confirmation.
366
+ - The model proposes every new branch name; program actions validate and create branches and worktrees.
367
+ - `auto`, `branch`, `worktree`, and `defaultBranch` modes work as specified.
368
+ - Known checks and mechanical fixes run programmatically.
369
+ - Candidate and base results are recorded separately.
370
+ - Matching base failures remain visible and do not block the current change.
371
+ - New failures enter a bounded repair and recheck loop.
372
+ - No included blocker bypasses challenge.
373
+ - Missing-plan and ordinary-failure claims have bounded recovery.
374
+ - Final blocked results preserve the original reason and evidence.
375
+ - The same policy applies to documentation, local verification, review, CI, and delivery.
376
+ - The implementation uses existing workflow primitives and adds no Pi core change or engine primitive.
377
+ - Full repository and real-Pi tests pass.
378
+
379
+ ## Rollout
380
+
381
+ This is a hard built-in replacement under the alpha policy.
382
+
383
+ Land the pure contracts and tests first. Then land workspace preparation, Autodoc migration, Autoimplement blocker and failure recovery, and later-stage adapters in that order. Keep each commit complete and reversible.
384
+
385
+ Finish or cancel active runs that use the old built-in definitions before package reload. Old terminal runs remain readable. An active run with an incompatible source revision continues to use the existing revision guard and must restart rather than mixing graphs.
386
+
387
+ After implementation, update [Workflow authoring reference](../workflows.md), [Workflow composition](../WORKFLOW_COMPOSITION.md), the Autoimplement and Autodoc skills, examples, and built-in revision records. Reload or restart Pi and verify discovery through the installed package path.
388
+
389
+ Do not release or deploy this change without separate authority.
390
+
391
+ ## Boundaries
392
+
393
+ - Do not modify Pi core or use a private Pi API.
394
+ - Do not add a workflow-engine primitive, hidden retry, service, database, daemon, or external store.
395
+ - Do not change SimpleDoc, Git, GitHub, CI provider, or target repository behavior.
396
+ - Do not require repositories to add a machine-readable quality manifest.
397
+ - Do not run broad repository migrations automatically.
398
+ - Do not use the model for deterministic command execution, counting, comparison, or routing.
399
+ - Do not hide baseline, nonzero, unknown, or truncated command results.
400
+ - Do not overwrite, stash, reset, or silently move existing user work.
401
+ - Do not merge different remote effects into one universal runner.
402
+ - Do not preserve the superseded alpha behavior through compatibility code.
403
+
404
+ ## Contract impact
405
+
406
+ - **Session state:** normal workflow prompts, action results, model results, and final presentation only.
407
+ - **Other persistent data:** normal node outputs in the existing SQLite state. No new persistence location.
408
+ - **Pi internals:** none.
409
+ - **Public Pi API:** existing documented extension and tool interfaces only.
410
+ - **Autoimplement input:** add optional `workspaceMode` with `auto`, `branch`, `worktree`, and `defaultBranch`. Omission means `auto`.
411
+ - **Autodoc input:** add optional base, scope, workspace mode, and prepared-workspace fields so standalone and included runs use the same safety rules.
412
+ - **Public pi-workflows API:** existing `agent`, `action`, `shell`, `compute`, `includeWorkflow`, named exits, structured outputs, command batches, and edge routing. Shared verification and workspace result contracts remain internal unless later use proves a public need.
413
+
414
+ ## Related plans
415
+
416
+ - [Confirm blockers before autoimplement stops](2026-08-20-autoimplement-blocker-challenge-plan.md)
417
+ - [Run independent commands in bounded batches](2026-08-20-bounded-command-batches-plan.md)
418
+ - [Add Autoimplement timeout fallback](2026-08-21-autoimplement-timeout-fallback-plan.md)
419
+ - [Add shared plan-change approval](2026-08-21-plan-change-approval-policy-plan.md)
@@ -0,0 +1,107 @@
1
+ ---
2
+ title: Capture the user's complete intent in Autoplan
3
+ author: Onur Solmaz <2453968+osolmaz@users.noreply.github.com>
4
+ date: 2026-08-25
5
+ ---
6
+
7
+ # Capture the user's complete intent in Autoplan
8
+
9
+ Autoplan must begin by asking the model to capture the user's instructions from the conversation. The result is one text value named `originalUserInstructions`. This value is the authoritative task text for every later planning step.
10
+
11
+ The capture instruction must tell the model to include everything that the user has instructed for the intended purpose in the given context. This includes relevant earlier messages and queued messages that are present in the model context. When several messages contribute, the model must preserve their wording and order in one text value. It must not summarize, rewrite, explain, label, omit, or add instructions.
12
+
13
+ The model is the authority for the captured text. Validation checks only that the result is a non-empty string. It does not compare the text with Pi session entries. After acceptance, the workflow must preserve the exact string, including its internal whitespace.
14
+
15
+ ## Selected design
16
+
17
+ Add one mandatory `agent` node before Autoplan's existing `frame` node. The node returns this shape:
18
+
19
+ ```json
20
+ {
21
+ "originalUserInstructions": "one text value"
22
+ }
23
+ ```
24
+
25
+ The field is a string. It is not an array of messages or message objects.
26
+
27
+ Every later Autoplan agent prompt must include the accepted string explicitly. The framing, practical candidates, ideal end state, selection, and implementation plan must use it as the authoritative user instructions. The existing structured input remains supplemental:
28
+
29
+ - `problem` can provide a caller-supplied description and can still support the run title;
30
+ - `scope` states the authorized scope;
31
+ - `constraints` carries explicit limits;
32
+ - `previousPlan` carries a plan that may need review; and
33
+ - `newEvidence` carries evidence that can affect the plan.
34
+
35
+ The final ready and blocked outputs must include `originalUserInstructions` for audit and downstream use. The node output and final output remain durable through the existing workflow run store.
36
+
37
+ ## Implementation plan
38
+
39
+ ### 1. Add the intent result contract
40
+
41
+ Add a result type with one `originalUserInstructions` string. Add a validator that rejects a missing, non-string, or whitespace-only value and returns the original string without trimming or normalization.
42
+
43
+ **Where:** `src/builtins/autoplan.workflow.ts` and focused Autoplan tests.
44
+
45
+ **Verify:** Tests accept internal whitespace unchanged and reject empty or whitespace-only text. Type and runtime checks reject arrays and message objects.
46
+
47
+ ### 2. Add the first Autoplan node
48
+
49
+ Add a mandatory intent-capture agent before `frame` and make it the workflow entry node. Its prompt must tell the model to:
50
+
51
+ - inspect the conversation context;
52
+ - include everything the user has instructed for the intended purpose in that context;
53
+ - include relevant earlier or queued user messages that are present in context;
54
+ - preserve the wording and order when several messages contribute;
55
+ - return one `originalUserInstructions` text string; and
56
+ - not summarize, rewrite, explain, label, omit, or add instructions.
57
+
58
+ Route this node directly to `frame` after successful validation.
59
+
60
+ **Where:** `src/builtins/autoplan.workflow.ts`.
61
+
62
+ **Verify:** Graph tests prove that the new node is first and mandatory. Prompt tests check the complete single-string instruction and the direct route to `frame`.
63
+
64
+ ### 3. Use the captured text throughout planning
65
+
66
+ Include `originalUserInstructions` explicitly in every later Autoplan agent prompt: `frame`, `propose`, `ideal`, `choose`, and `plan`. Keep scope, constraints, previous plans, new evidence, and earlier step outputs as supplemental context. Do not let `input.problem` replace the captured instructions.
67
+
68
+ **Where:** `src/builtins/autoplan.workflow.ts` and focused prompt tests.
69
+
70
+ **Verify:** Use a distinct captured string and caller problem in tests. Confirm that every later agent prompt contains the captured string and does not present the caller problem as the authoritative instructions.
71
+
72
+ ### 4. Preserve the text in final results
73
+
74
+ Add `originalUserInstructions` to both ready and blocked result types and final values. Read it from the accepted capture output without changing it.
75
+
76
+ **Where:** `src/builtins/autoplan.workflow.ts` and built-in workflow tests.
77
+
78
+ **Verify:** Ready and blocked runs return the exact captured string. Resume and normal run persistence continue through the existing node-output and final-output records.
79
+
80
+ ### 5. Update the public workflow reference
81
+
82
+ Document the mandatory capture step, the one-string contract, model authority, later prompt use, and final-output field in the built-in Autoplan section.
83
+
84
+ **Where:** `docs/workflows.md`.
85
+
86
+ **Verify:** Documentation checks pass, and the reference agrees with the implementation and tests.
87
+
88
+ ## Boundaries
89
+
90
+ - Use existing `agent`, `compute`, edge, validation, output, and persistence behavior.
91
+ - Do not change Pi core or private Pi APIs.
92
+ - Do not add session-message inference, conversation bindings, an amendment journal, or a workflow-engine primitive.
93
+ - Do not compare the model's text with session history.
94
+ - Do not add aliases, fallback behavior, dual paths, feature flags, a parallel schema version, or compatibility shims.
95
+ - Do not publish a package or update downstream package pins as part of this change.
96
+
97
+ ## Verification
98
+
99
+ Run:
100
+
101
+ ```bash
102
+ npm run check
103
+ npm run test:e2e
104
+ npx slophammer-ts@latest dry .
105
+ npx slophammer-ts@latest check . --only ts.dependency-boundaries-required
106
+ git diff --check
107
+ ```
@@ -45,14 +45,13 @@ The current event types are:
45
45
  - `assistant_event`
46
46
  - `message_finished`
47
47
  - `tool_execution_started`
48
- - `tool_execution_updated`
49
48
  - `tool_execution_finished`
50
49
 
51
50
  Unknown future event types remain visible to generic readers.
52
51
 
53
52
  ## Write rules
54
53
 
55
- The recorder queues hot-path Pi events in memory and writes bounded batches. One transaction writes the complete batch, updates the segment count, increments the segment resource revision, and appends its audit event.
54
+ The recorder stores lifecycle boundaries and settled content. It does not store token deltas or incremental tool progress. It queues these bounded records in memory. One transaction writes each complete batch and updates the segment count. The session-event rows are the audit journal; the store does not add one generic event for each flush.
56
55
 
57
56
  The writer checks:
58
57
 
@@ -68,7 +67,7 @@ Workflow execution does not fail because temporal capture failed. The run and th
68
67
 
69
68
  ## Settled entries
70
69
 
71
- A `message_finished` event can refer to the Pi entry ID that settled the message. Replay first shows temporal deltas, then switches to the verbatim entry when that settled link is available.
70
+ A `message_finished` event can refer to the Pi entry ID that settled the message. Replay uses settled assistant content and switches to the verbatim entry when that link is available.
72
71
 
73
72
  Agent workflow steps also store their first and last Pi entry IDs. This makes the conversation slice for each step explicit without changing Pi session data.
74
73
 
package/docs/workflows.md CHANGED
@@ -437,11 +437,11 @@ runs.
437
437
  ### Built-in plain summary
438
438
 
439
439
  The built-in `plain-summary` workflow turns supplied structured data into one
440
- short normal assistant message. Its input has `source`, `purpose`, optional
440
+ normal assistant message. Its input has `source`, `purpose`, optional
441
441
  `mustInclude`, optional `maxChars`, optional `maxSentences`, and `format` set to
442
- `paragraphs`, `bullets`, or `mixed`. The workflow defaults to 2,000 characters,
443
- five sentences, and mixed format. These are workflow-specific limits;
444
- `assistantMessage()` itself has no default limit.
442
+ `paragraphs`, `bullets`, or `mixed`. The workflow applies no character or
443
+ sentence limit by default. A caller can request either limit with a positive
444
+ integer. `assistantMessage()` itself also has no default limit.
445
445
 
446
446
  The summarizer uses only the supplied source, treats instructions inside that
447
447
  source as data, keeps required points, and returns the same text as its
@@ -452,11 +452,38 @@ before the parent continues.
452
452
 
453
453
  ### Built-in planning and implementation
454
454
 
455
- The built-in `autoplan` workflow records two through four practical candidates,
456
- describes the ideal separately, chooses one option, records a rejection reason
457
- for every other explicit option, and writes a detailed plan. It then includes
458
- `plain-summary` to show the chosen plan, its main steps, and the rejected options
459
- in one short assistant message. The detailed records remain in the run bundle. The standalone `autodoc` workflow finds an already selected plan, records it in canonical documentation, verifies those documents, and never devises or implements. The built-in `autoimplement` workflow finds a clear existing plan from explicit input, conversation context, or referenced canonical documents. It blocks when no clear plan exists. An explicit plan bypasses autodoc only when a current-document receipt carries its matching plan digest; otherwise autodoc inspects and adopts or updates the canonical documents. Later invalidating evidence returns to `autoplan` followed by `autodoc`.
455
+ The built-in `autoplan` workflow first asks the model to capture everything the
456
+ user has instructed for the intended purpose in the available conversation
457
+ context. Relevant earlier and queued user messages must keep their wording and
458
+ order. The model returns one `originalUserInstructions` string and must not
459
+ summarize, rewrite, explain, label, omit, or add instructions. Validation checks
460
+ only that the string is not empty and preserves the accepted text without
461
+ normalization. Every later Autoplan agent prompt includes this string as the
462
+ authoritative user instructions. Structured run input such as scope,
463
+ constraints, a previous plan, and new evidence remains supplemental. Ready and
464
+ blocked final outputs include the same string for audit and downstream use.
465
+
466
+ Autoplan then records two through four practical candidates, describes the ideal
467
+ separately, chooses one option, records a rejection reason for every other
468
+ explicit option, and writes a detailed plan. It includes `plain-summary` to show
469
+ the chosen plan, its main steps, and the rejected options in one assistant
470
+ message without a character or sentence limit. The detailed records remain in
471
+ the run bundle. See
472
+ [Capture the user's complete intent in Autoplan](plans/2026-08-25-autoplan-user-intent-capture-plan.md)
473
+ for the selected design and implementation plan.
474
+
475
+ The standalone `autodoc` workflow finds an already selected plan, records it in
476
+ canonical documentation, and never devises or implements. It prepares a safe
477
+ workspace only when documentation must change. Program actions run candidate
478
+ checks, compare eligible failures with the base revision in a temporary
479
+ detached worktree, and keep matching baseline failures visible without blocking
480
+ the current change. The built-in `autoimplement` workflow finds a clear existing
481
+ plan from explicit input, conversation context, or referenced canonical
482
+ documents. A missing-plan claim and every other non-exempt blocker enter one
483
+ bounded challenge path. An explicit plan bypasses autodoc only when a
484
+ current-document receipt carries its matching plan digest; otherwise autodoc
485
+ inspects and adopts or updates the canonical documents. Later invalidating
486
+ evidence returns to `autoplan` followed by `autodoc`.
460
487
 
461
488
  The built-in `plan-approval` workflow offers `continue`, `stop`, and exact-text `replan` exits. Its shared policy uses `auto`, `required`, or `skip` mode. Omitted policy defaults to `auto`: ask audience `operator`, then continue with the exact plan after 10 minutes without an answer. Required mode waits for a human. Skip mode creates no decision. Stop and replan always require a human answer.
462
489
 
@@ -464,18 +491,13 @@ The internal plan-change workflow composes Autoplan, Autodoc, plan approval, and
464
491
 
465
492
  Autoimplement runs independent commands through bounded command batches. A batch is an ordinary function action that calls the public `runCommandBatch` helper. Each command has a stable ID, executable, arguments, absolute working directory, timeout, and output limit. Results stay separate and return in input order. One command uses the same path with concurrency one.
466
493
 
467
- Autoimplement gives `implement` an eight-hour deadline. When a supported
468
- long-running agent node times out, one shared read-only fallback inspects the
469
- current repository, accepted workflow outputs, and relevant pull-request state.
470
- It then retries the timed-out stage or routes to verification, review, CI,
471
- delivery, the existing redesign workflow, or blocked. The fallback can run at
472
- most three times in one Autoimplement run. Its own failure or timeout is
473
- terminal. Cancellation remains immediate and never enters fallback. A repeated
474
- effect step first checks what already exists and performs only missing work.
475
- This graph fallback starts after the timed-out turn ends and is separate from
476
- successor-turn delivery.
494
+ Autoimplement prepares the workspace before its first edit-capable node. `workspaceMode` accepts `auto`, `branch`, `worktree`, or `defaultBranch`. Auto mode adopts a current task branch, creates a model-named branch from a clean default branch, or creates a model-named standard sibling worktree when the default checkout has existing work. Program actions validate and apply names. Direct default-branch work requires explicit authority and does not imply commit, push, merge, or release authority. Every later stage uses the prepared absolute path.
477
495
 
478
- Autoimplement uses batches for pi-reviewer, pending CI watches, and local verification commands from independent repositories. It keeps model turns, fixes, pushes, comment changes, merges, and releases in their existing order. Reviewer commands are tied to the repository, base branch, pushed head, and relevant dependency fingerprint. A later review round includes only repositories whose head or dependency fingerprint changed. P0 or P1 work still requires another review. P2-only work can be addressed and verified without another reviewer run only because of that P2 work.
496
+ Autoimplement gives `implement` an eight-hour deadline. When a supported step fails or times out, one shared bounded recovery step inspects accepted outputs and durable repository or pull-request state. It adopts a completed effect or retries only a missing effect. Cancellation remains immediate and never enters recovery. Unsupported or uncertain effects create a qualified blocker claim before challenge.
497
+
498
+ Local verification uses the shared change-verification composition. Direct program actions run candidate checks and read-only base-eligible checks with the same command, arguments, timeout, and output limit. Results separate related, unrelated, fixed-baseline, unknown, and untested findings. Matching base failures do not block the candidate. Related failures enter a two-attempt mechanical or semantic repair loop. Unknown or incomplete evidence needs bounded judgment, and truncated, timed-out, cancelled, or spawn-failed output cannot pass.
499
+
500
+ Autoimplement uses batches for pi-reviewer and pending CI watches. It keeps model turns, fixes, pushes, comment changes, merges, and releases in their existing order. Reviewer commands are tied to the repository, base branch, pushed head, and relevant dependency fingerprint. A later review round includes only repositories whose head or dependency fingerprint changed. P0 or P1 work still requires another review. P2-only work can be addressed and verified without another reviewer run only because of that P2 work.
479
501
 
480
502
  Autoimplement inspects every pull request before it waits for CI. It accepts only supported pending `gh pr checks --watch` or `gh run watch` descriptors and binds each one to the validated pull request as `gh pr checks <PR URL> --watch`. Repository and pull-request overrides are rejected. One watch lasts at most five minutes. A failed or timed-out watch affects only its pull request. When checks remain pending, the model runs more useful local tests before checking CI again. Autoimplement does not invent an ETA.
481
503
 
@@ -684,7 +706,7 @@ possible. Defaults worth knowing:
684
706
  is explicit user control. When no run is live but the widget still shows a parked or finished run,
685
707
  the command clears the widget.
686
708
  - One workflow runs per session at a time.
687
- - After the workflow tool accepts an agent-step submission, the extension removes any assistant tail text from the rest of that agent run. The next workflow message is the visible continuation. A deferred intent makes a workflow prompt, presentation, and factual fallback compete to provide one successor turn, so an abort cannot produce two continuation turns.
709
+ - After the workflow tool accepts an agent-step submission, any assistant text that follows remains visible. The next workflow message continues the graph. A deferred intent makes a workflow prompt, presentation, and factual fallback compete to provide one successor turn, so an abort cannot produce two continuation turns.
688
710
  - Agent nudges: if the model ends its turn without submitting the pending
689
711
  step, it gets a reminder, twice by default, then the step fails.
690
712