@henryqw/pi-subagent 30.1.0 → 31.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CONTEXT.md +2 -2
- package/README.md +18 -22
- package/dist/ephemeral.d.ts +7 -3
- package/dist/ephemeral.js +59 -11
- package/dist/herdr-runtime.js +4 -0
- package/dist/index.d.ts +1 -1
- package/dist/index.js +2 -2
- package/dist/native-host.d.ts +96 -0
- package/dist/native-host.js +243 -0
- package/dist/runner.d.ts +8 -1
- package/dist/runner.js +22 -15
- package/dist/schema.d.ts +71 -2
- package/dist/schema.js +14 -1
- package/dist/workspace-schema.d.ts +11 -0
- package/dist/workspace.d.ts +5 -2
- package/dist/workspace.js +58 -29
- package/docs/measurement.md +12 -1
- package/docs/orchestration-architecture.html +4 -4
- package/docs/orchestration-architecture.svg +2 -2
- package/docs/orchestration.md +69 -258
- package/docs/workspace.md +4 -80
- package/extensions/direct-check-exec.py +91 -0
- package/extensions/direct-check-supervisor.mjs +42 -0
- package/extensions/direct-check-witness.mjs +34 -0
- package/extensions/direct-native.ts +5 -3
- package/extensions/direct-outbox.ts +189 -0
- package/extensions/direct-owner.ts +49 -0
- package/extensions/direct-verification.ts +73 -0
- package/extensions/isolated.ts +25 -301
- package/extensions/prerequisite-evidence.ts +81 -0
- package/extensions/result-transport.ts +6 -4
- package/extensions/subagent-command.ts +12 -7
- package/extensions/subagent.ts +302 -495
- package/extensions/workflow-recovery.ts +359 -0
- package/extensions/workflow.ts +156 -40
- package/extensions/workspace.ts +16 -74
- package/package.json +2 -2
- package/skills/pi-subagent/SKILL.md +15 -37
package/docs/orchestration.md
CHANGED
|
@@ -1,25 +1,6 @@
|
|
|
1
1
|
# Orchestration and package-author API
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
```text
|
|
6
|
-
┌─ direct ─── shared checkout, native Pi or Herdr tab
|
|
7
|
-
request + Role + route ──┤
|
|
8
|
-
└─ isolated ─ Herdr worktree, checked candidate, durable state
|
|
9
|
-
```
|
|
10
|
-
|
|
11
|
-
Both paths resolve Roles and model routes from Pi's effective registries. They share the package's global concurrency, turn/token, timeout, and correction policy. A request cannot supply or refill execution limits.
|
|
12
|
-
|
|
13
|
-
## Choose a delegation mode
|
|
14
|
-
|
|
15
|
-
Main chooses the mode from your request. You do not need to select one. Words such as “direct” and “isolated” can show your intent, but the work sets the route. Main declares the selected mode in each `delegate_task` call. The extension never falls back between modes.
|
|
16
|
-
|
|
17
|
-
| Mode | Request that triggers it | Checkout behavior |
|
|
18
|
-
| --- | --- | --- |
|
|
19
|
-
| `direct` | Bounded research, review, or explicitly authorized writes and commits in the shared checkout | Runs native Pi workers outside Herdr. In Herdr, opens worker tabs without focus. Creates no worktree. |
|
|
20
|
-
| `isolated` | Implementation or a checked task graph | Runs changesets in owned Herdr worktrees. Main selects, validates, and promotes exact candidates. |
|
|
21
|
-
|
|
22
|
-
Keep trivial mechanically verifiable work in Main. Keep tightly coupled changes under one owner. Do not split them by file count.
|
|
3
|
+
Main sends bounded work to native Pi processes in the current checkout. The Pi widget displays each worker.
|
|
23
4
|
|
|
24
5
|
## Direct contract
|
|
25
6
|
|
|
@@ -70,46 +51,76 @@ Each entry has:
|
|
|
70
51
|
| `task` | yes | Non-empty task packet |
|
|
71
52
|
| `access` | yes | `read` or `write`; Main's honest classification, not enforced |
|
|
72
53
|
| `paths` | no | Write tasks only: 1 to 32 repo-relative globs (`path.matchesGlob` syntax, such as `src/**`). The change report flags changed paths outside them. A report only, not enforced |
|
|
54
|
+
| `dependsOn` | no | In `tasks`, names the prerequisites that must succeed before this entry starts. |
|
|
55
|
+
| `verification` | no | For a writer, supplies `criteria` and executable `checks`. |
|
|
73
56
|
| `continueFrom` | no | Direct reference such as `D7.1`; continues that finished worker's Pi session. `role` must equal the recorded Role |
|
|
74
57
|
| `kind` | no | `text` only (default); direct `changeset` is rejected |
|
|
75
58
|
| `modelClass` | no | `fast`, `balanced`, `frontier`, `ultra`, or `fav` route |
|
|
76
59
|
| `model` | no | `provider/modelId`; replaces only the route model |
|
|
77
60
|
|
|
78
|
-
An explicit model must support the route's thinking level. A
|
|
61
|
+
An explicit model must support the route's thinking level. A read can retry one transient operating-system launch failure (`EAGAIN`) when no child started. Both attempts use the original deadline and budget.
|
|
79
62
|
|
|
80
|
-
Direct `changeset` is rejected
|
|
63
|
+
Direct `changeset` is rejected. Use `verification` to attach acceptance checks. Resource validation and recursive-delegation exclusions apply to every task. A request becomes a write request when any task declares `access: "write"`.
|
|
81
64
|
|
|
82
|
-
###
|
|
65
|
+
### Prerequisites and acceptance checks
|
|
66
|
+
|
|
67
|
+
```json
|
|
68
|
+
{
|
|
69
|
+
"mode": "direct",
|
|
70
|
+
"tasks": [
|
|
71
|
+
{
|
|
72
|
+
"role": "implementer", "name": "Repair refresh", "access": "write",
|
|
73
|
+
"task": "Repair refresh handling in the current checkout.",
|
|
74
|
+
"verification": {
|
|
75
|
+
"criteria": "The refresh regression test passes.",
|
|
76
|
+
"checks": [{ "executable": "node", "args": ["--test", "test/refresh.test.js"], "timeoutMs": 10000 }]
|
|
77
|
+
}
|
|
78
|
+
},
|
|
79
|
+
{
|
|
80
|
+
"role": "reviewer", "name": "Review repair", "access": "read",
|
|
81
|
+
"dependsOn": ["Repair refresh"], "task": "Review the repair and its tests."
|
|
82
|
+
}
|
|
83
|
+
]
|
|
84
|
+
}
|
|
85
|
+
```
|
|
86
|
+
|
|
87
|
+
Use unique names in a dependency graph. Unknown prerequisites and cycles fail before launch. A dependent receives up to 4,096 bytes of prerequisite answer excerpts. For each truncated excerpt, the runtime supplies a `fullAnswer` field with the private file path, byte count, and SHA-256 digest. Pi verifies the bytes and gives the dependent a private read-only copy. A missing or changed file blocks that dependent. Short answers need no reference. The result preserves the original task order.
|
|
83
88
|
|
|
84
|
-
|
|
89
|
+
Each writer accepts up to three checks. Each check runs the specified executable and arguments in the writer's checkout, with its process lease. Use only checks authorized for that checkout. Each check stops at the shorter of its requested deadline and the configured worker maximum runtime (`timeout.maxMinutes`). Each check retains up to 8,192 bytes of combined output. A definite nonzero exit permits one correction per writer while the workflow has corrections left. The workflow shares `maxCorrections` across its writers. Set it to zero to return the failed check immediately. After a final acceptance failure, inspect the edits and explicitly close the workflow to release the checkout. A timeout, cancellation or uncertain termination also requires inspection.
|
|
85
90
|
|
|
86
|
-
|
|
91
|
+
Acceptance checks require `/usr/bin/python3`. Linux requires `libseccomp.so.2`. Pi installs an inherited kernel policy before starting the executable. Children must stay in the supervised process group. On macOS, checks can use fork and exec. Programs that require `posix_spawn` receive a permission error because its spawn attributes can create a separate group. For Node test files on macOS, use `node --test --test-isolation=none` on Node versions that provide this option.
|
|
92
|
+
|
|
93
|
+
Saved background requests record step intent before launch. After a same-host restart, Pi starts eligible unstarted reads on the original session branch. It checks their roles, resources, and saved evidence before launch. Recovery requires saved execution limits and applies the stricter of the saved and current limits. Interrupted workers count toward the concurrency limit. Recovery continues the original authorized tool call. Pi checks project trust and tool availability again before launch. For a chain, Pi substitutes the complete preceding answer wherever the task uses `{previous}`. It verifies any saved file before substitution. Live and recovered chains accept up to 16 MiB (16,777,216 bytes) per expanded task, including the template text. Pi rejects a larger task before it starts the worker. Main receives the original workflow result after recovery. A durable claim prevents duplicate dispatch of the same packet. An interrupted writer requires termination evidence and inspection of partial changes. Recovery leaves its work in place.
|
|
94
|
+
|
|
95
|
+
### Dry run
|
|
96
|
+
|
|
97
|
+
Set `"dryRun": true` to preview Role, model, resources, access, and continuation eligibility before dispatch.
|
|
87
98
|
|
|
88
99
|
Read requests skip checkout admission and return plain text. Parallel `tasks` run concurrently up to `maxSubagents`; chains stay ordered. The extension does not enforce `read`. Results stay in request order.
|
|
89
100
|
|
|
90
|
-
|
|
101
|
+
Direct mode uses a native Pi child in every terminal. Before a write starts, Main saves its session and process lease identity in the admission journal. Writers run alone within their request. Ready readers in a named dependency graph can run together. Release requires the observed child exit and two empty scans of the original lease. A definite final acceptance failure can release admission after termination proof. Other rejected writes require explicit cleanup. After a restart, `/subagent` provides journal recovery.
|
|
91
102
|
|
|
92
103
|
Native workers save a private Pi session and process lease. To continue a native worker, Main must have observed its process exit in this Pi process. The Role, checkout and last saved turn must match. Two lease scans must be empty. An interrupted turn can resume after these checks. Continuation after a Pi restart is unavailable. Use `{"mode":"cancel","id":"<exact workflow ID>"}` to stop locally owned work on the current branch. The `/subagent` menu also provides Close. Cancellation does not prove that detached descendants stopped.
|
|
93
104
|
|
|
94
105
|
Direct tasks use the declared tools, extensions, Skills, and MCP servers of the selected Role, including resources that can write. Authorization comes from your request and Main's bounded task packet, not from the capabilities of the Role. Name the permitted paths, actions, and exclusions. Preserve unrelated edits and staged changes. Authorize commits or external actions explicitly.
|
|
95
106
|
|
|
96
|
-
For example, a configured Git operator with `bash` can stage named pending files and commit them on the `fast` route.
|
|
107
|
+
For example, a configured Git operator with `bash` can stage named pending files and commit them on the `fast` route.
|
|
97
108
|
|
|
98
|
-
Direct writes change Main's checkout immediately. They require no clean checkout.
|
|
109
|
+
Direct writes change Main's checkout immediately. They require no clean checkout. Main runs any declared acceptance checks. Edits remain in place after a failure. A write request cannot start while a direct writer owns the checkout. It also cannot start while a Main call that can write is in progress there.
|
|
99
110
|
|
|
100
|
-
A write request runs its tasks in sequence. It holds checkout admission after the initial handle returns. Competing direct writers and Main writes fail until the extension proves that all owned workers stopped.
|
|
111
|
+
A write request without named dependencies runs its tasks in sequence. It holds checkout admission after the initial handle returns. Competing direct writers and Main writes fail until the extension proves that all owned workers stopped. Parallel read requests still run concurrently.
|
|
101
112
|
|
|
102
|
-
A
|
|
113
|
+
A failed prerequisite blocks its descendants. Independent tasks can continue after a read failure. A terminal acceptance failure stops new graph dispatch. Uncertain writer termination stops graph dispatch. Chains replace each literal `{previous}` with the preceding successful answer and stop on failure. Task outcome and worker termination are separate.
|
|
103
114
|
|
|
104
|
-
After settlement, the coordinator
|
|
115
|
+
After settlement, the coordinator releases admission only after observed process exit and two empty private process-lease scans. This proof requires native `lsof`. This automatic step sends no signals, so a background process that the worker started and that holds its lease keeps admission held. The coordinator removes no Git files, commits, or saved sessions. A failure stays a failure even when the coordinator releases admission.
|
|
105
116
|
|
|
106
117
|
Admission stays held if the close fails, identity changes, a leased child survives, or inspection is uncertain. In that case, open `/subagent`. Select the exact direct workflow. Then choose **Close/cancel-and-release ALL owned workers in this workflow** to cancel dispatch and try termination again. This action stops every owned worker of that workflow, not one selected worker.
|
|
107
118
|
|
|
108
|
-
The action checks session, branch, epoch, and live ownership. Recorded-only tasks cannot use local Close. Their separate recovery action cannot stop workers. After it
|
|
119
|
+
The action checks session, branch, epoch, and live ownership. Recorded-only tasks cannot use local Close. Their separate recovery action cannot stop workers. After it observes the owned child exit, it sends `SIGTERM` to each process that holds the exact private lease of an owned worker. Then it sends `SIGKILL` to each process that survives. Before each signal, it scans the lease again for that PID, and it does not signal a PID that no longer holds the lease. If a holder survives, a scan fails, or ownership changes, admission stays held. Resolve the reported blocker, then do the same action again. A restart of Pi is not termination proof.
|
|
109
120
|
|
|
110
121
|
Inspect partial changes before new writes. To recover, never retry a commit or delete work without inspection.
|
|
111
122
|
|
|
112
|
-
|
|
123
|
+
For records from releases before 31.0.0, tab creation could time out or return an incomplete or mismatched identity. In that case, `/subagent` retains the allocation intent. This includes the workspace, checkout, label, private lease and session paths, and any returned tab and pane IDs. No worker starts until the extension verifies the creation identity. These records are evidence, not ownership.
|
|
113
124
|
|
|
114
125
|
Close is not available for an unverified allocation. Admission stays held until you reconcile it manually against Herdr. Do not create the tab again. Do not guess missing IDs or restart to bypass this blocker.
|
|
115
126
|
|
|
@@ -144,7 +155,7 @@ A journal error blocks writes even when Pi reports the `session_start` error and
|
|
|
144
155
|
|
|
145
156
|
Recovered admission is a write barrier, not process-control authority. Replay does not restore worker handles, replay tasks, or stop processes. Continuation and collection of recorded workers wait while admission is unresolved. Reload is not termination proof.
|
|
146
157
|
|
|
147
|
-
The journal saves non-dispatch evidence first. It saves each exact allocation intent before
|
|
158
|
+
The journal saves non-dispatch evidence first. It saves each exact allocation intent before worker launch, and each continuation source before its stop. An interrupted external operation stays unproved. New launches save the private lease and parent filesystem identities before dispatch. Termination checks compare them before and after lease scans. Missing, linked, replaced, or non-private leases block proof.
|
|
148
159
|
|
|
149
160
|
A legacy worker without its original saved lease identity cannot be stopped or continued. The current lease file cannot establish its historical identity. New workers keep their original baseline throughout local execution. Allocation intents are bound to verified tab and pane identities before agent start. Older receipts for allocated workers without that binding require the warned human release, not proof-based release.
|
|
150
161
|
|
|
@@ -170,33 +181,33 @@ Admission coordinates only this Main's Pi calls. Other Pi sessions and external
|
|
|
170
181
|
|
|
171
182
|
### Continue or stop one direct worker
|
|
172
183
|
|
|
173
|
-
Main can continue a finished direct worker, so it does not have to start a new one. It adds `continueFrom` with the reference of the worker, such as `"continueFrom": "D7.1"`, to any single, parallel, or chain task. It uses the same `role` that the worker ran with.
|
|
184
|
+
Main can continue a finished direct worker, so it does not have to start a new one. It adds `continueFrom` with the reference of the worker, such as `"continueFrom": "D7.1"`, to any single, parallel, or chain task. It uses the same `role` that the worker ran with. A native Pi process resumes the saved session after the checks above.
|
|
174
185
|
|
|
175
|
-
The new
|
|
186
|
+
The new worker gets a new reference. Its record points to the same session and private lease file. The launch handle and the result say `continued from D7.1`. Access, admission, write rules, and model routes are the same as for a new task.
|
|
176
187
|
|
|
177
|
-
A request can continue each worker only one time, and only from the checkout
|
|
188
|
+
A request can continue each worker only one time, and only from the checkout where the worker ran. After a continuation, continue the newest reference. The extension refuses an older reference to the same session, because a later turn follows its own turn.
|
|
178
189
|
|
|
179
190
|
Before launch, the request fails if the reference is unknown or matches more than one record on this session branch. It also fails if the Role is different or a locally active task still owns the session of the worker. A missing session file or a session file larger than 16 MiB also causes failure. The last session turn for the recorded prompt must be finished.
|
|
180
191
|
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
An absent old agent still requires two empty lease scans. Continuation and Subagent Collection never send signals to lease holders.
|
|
192
|
+
Continuation requires the original native session and two empty process lease scans. Saved Herdr records remain available for recovery.
|
|
184
193
|
|
|
185
194
|
Records saved before 27.0.0 have no turn identity. The extension cannot continue them. For these records, start a new task.
|
|
186
195
|
|
|
187
|
-
In a running workflow that has only `read` tasks, `/subagent` shows **Stop this worker** for each running worker.
|
|
196
|
+
In a running workflow that has only `read` tasks, `/subagent` shows **Stop this worker** for each running worker. Pi aborts the selected child and waits for it to settle. The result of the worker becomes a failure, `Stopped by user from /subagent`, and keeps any partial output. Other workers continue, but a chain stops its later steps.
|
|
188
197
|
|
|
189
198
|
If the extension cannot prove termination of the stopped worker, the workflow keeps local ownership. So **Close/cancel-and-release** stays available. Main receives one result when the workflow finishes. A workflow with a `write` task offers only **Close/cancel-and-release ALL owned workers in this workflow**. Both actions check session, branch, and epoch, so a stale dialog cannot act.
|
|
190
199
|
|
|
191
200
|
### Direct results and records
|
|
192
201
|
|
|
193
|
-
|
|
202
|
+
Main can receive several completed workflows in one follow-up. A combined follow-up has a 4,096-byte limit, including workflow identifiers and statuses. If previews are clipped, the message points to the saved full results. When the identifiers exceed the limit, one private index lists every status and result file.
|
|
203
|
+
|
|
204
|
+
The extension retrieves each final answer from its exact Pi session file, not its possibly truncated screen. Failed tasks retain the exact saved session path. No whole-run deadline applies.
|
|
194
205
|
|
|
195
206
|
The tasks in a request share a 4 KiB inline answer budget. Each worker prompt states its share. A longer exact answer is still a success. The result shows a UTF-8-safe prefix and a truncation marker. The recovery section links to a private `answer-<turn>.md` file beside the session file, which holds the full answer. For a write task, the budget applies to the `answer` field of the completion object. A chain step receives the full answer of the previous step in `{previous}`; the budget applies only to the result for Main. The result details keep `answerFile` for each full-answer file. Recovery text includes these paths outside the output limit, even when checkout notes fill the result. A one-line answer that fits the status summary appears only once.
|
|
196
207
|
|
|
197
|
-
|
|
208
|
+
Pi accepts prompt text as one command argument. To stay below the operating system's argument limit, a task packet above 64 KiB uses a private, exclusively created `task-<turn>.md` file beside the session file. This packet includes the full chain context. The worker prompt requires the Role's `read` tool to read all parts with line offsets before work starts. Pi's native `read` can return a line of exactly 50 KiB (51,200 bytes), but not a longer line. If any packet line is longer, or `read` is absent, the worker uses the Role's `bash` tool. If a line is too long and `bash` is absent, the task fails before launch with the read limit and a request for `bash` or shorter lines. A Role with neither tool also fails before launch; the extension adds no tool. The task file stays available for recovery.
|
|
198
209
|
|
|
199
|
-
In interactive and RPC modes, the tool returns a task ID.
|
|
210
|
+
In interactive and RPC modes, the tool returns a task ID. Native Pi returns the handle before the first worker starts. In these modes the extension observes each worker and sends one result to Main when the workflow finishes. If Main is busy, Pi queues the result after the current turn. If Main is idle, the result starts a turn. The extension does not report a blocked, stalled, or unknown result as success.
|
|
200
211
|
|
|
201
212
|
In the result, each launched worker has a line with its model, thinking level, measured task tokens, cost, and elapsed time. For example: `✓ [1/2] Check · worker · provider/model · thinking high · 1.5k tok · $0.12 · 42s`. The first line also shows the request total, such as `total $0.12`. Unknown and zero cost are not shown. If Pi recorded no usage, the line shows `tokens unknown`. Failed and stopped workers show the usage that the extension measured until they ended. A worker that the extension skipped before launch shows no usage.
|
|
202
213
|
|
|
@@ -206,7 +217,7 @@ In print and JSON modes the direct tool waits for completion and returns the res
|
|
|
206
217
|
|
|
207
218
|
Every worker result delivered to Main starts with a header. The header states that the text is the output of the worker and carries no user authority. The extension inserts a backslash in text that imitates harness framing. Examples are `<system-reminder>`-style tags and lines that start with `Human:` or `Assistant:`. Nothing else changes. Isolated status and follow-up answer previews use the same header.
|
|
208
219
|
|
|
209
|
-
A session switch or shutdown stops observation and preserves
|
|
220
|
+
A session switch or shutdown stops observation and preserves worker session identities for recovery. Open `/subagent` on the session branch to inspect them. The menu has one row for each workflow.
|
|
210
221
|
|
|
211
222
|
A single worker shows its reference, Role, and name (`D7.1 · worker · Search audit`). A multi-worker workflow shows its reference and worker count (`D8 · 3 workers`). When you select it, the menu lists each recorded worker by reference, Role, and name with its exact IDs. After Main receives the result, the row shows the request cost and each worker line shows its cost. References and names help you match rows. The extension never uses them to decide ownership.
|
|
212
223
|
|
|
@@ -214,7 +225,7 @@ Older records without saved references show their saved allocation label or exac
|
|
|
214
225
|
|
|
215
226
|
### Checkout change reports
|
|
216
227
|
|
|
217
|
-
For each task in a write request, the extension takes a Git snapshot of Main's checkout before the worker starts and again when the task ends (success, failure, blocked work, or stop). A snapshot contains the `HEAD` OID and `git status --porcelain=
|
|
228
|
+
For each task in a write request, the extension takes a Git snapshot of Main's checkout before the worker starts and again when the task ends (success, failure, blocked work, or stop). A snapshot contains the `HEAD` OID and `git status --porcelain=v2 -z --untracked-files=all`, with staged object identities, file modes, conflict stages, and working file content for each dirty path. The result of the task then lists:
|
|
218
229
|
|
|
219
230
|
- New commits from `git rev-list before..after`, as a short OID and subject. If `HEAD` moved to a commit that does not descend from the start `HEAD`, the report says so.
|
|
220
231
|
- Paths with a changed status or content, and the paths that the new commits changed. If the task declares `paths`, each changed path outside them shows `outside declared paths`.
|
|
@@ -223,23 +234,25 @@ The report shows at most 10 commits and 20 paths, and it counts the omitted item
|
|
|
223
234
|
|
|
224
235
|
For a read request, the extension compares the same snapshot at launch and when each task ends. If `HEAD`, status, or dirty content changed, the result of that task shows `checkout changed during task; result may be stale`.
|
|
225
236
|
|
|
237
|
+
Both reports detect changes confined to staged content, even when the working file and status codes stay identical.
|
|
238
|
+
|
|
226
239
|
Outside a Git repository, the extension makes no report and the task continues. If a snapshot fails, the task does not fail; the result shows `change report unavailable: <reason>` (or `stale-read check unavailable: <reason>` for a read request).
|
|
227
240
|
|
|
228
241
|
### Status widgets
|
|
229
242
|
|
|
230
|
-
|
|
243
|
+
Pi shows new workers in its direct status widget. Inspecting a saved isolated request can also display its recorded task rows. Each widget has one row for each visible worker or task. `D` marks direct work, and `I` marks isolated work. Badges such as `[S]` and `[I3]` identify the Role initial. Isolated badges also include the model class: `1` fast, `2` balanced, `3` frontier, `4` ultra, `*` fav.
|
|
231
244
|
|
|
232
|
-
Each direct row starts with a saved direct reference such as `D7.1`. `D7` is the workflow number in this Pi session, and `.1` is the position of the worker in the original request. `/subagent` uses the same reference and name.
|
|
245
|
+
Each direct row starts with a saved direct reference such as `D7.1`. `D7` is the workflow number in this Pi session, and `.1` is the position of the worker in the original request. `/subagent` uses the same reference and name. Numbers continue after reload, and the session never uses a number again.
|
|
233
246
|
|
|
234
|
-
A session switch can move a workflow into a session that already uses its number. In that case, the workflow gets a new number there.
|
|
247
|
+
A session switch can move a workflow into a session that already uses its number. In that case, the workflow gets a new number there.
|
|
235
248
|
|
|
236
249
|
The direct widget shows the launched model, thinking level, elapsed time, measured task tokens (`— tok` until usage is available), and cost next to the tokens (such as `$0.12`; not shown when unknown or zero). Failed rows show before working and completed rows. When rows overflow, `… N more` includes counts by status.
|
|
237
250
|
|
|
238
|
-
The isolated widget shows the recorded task state and any retained workspace.
|
|
251
|
+
The isolated widget shows the recorded task state and any retained workspace. The rows reflect saved task state. Attention shows before ordinary work, and overflow uses `+N more · /subagent`. An aborted request with visible tasks has its own `request aborted` row. This row does not change the recorded statuses of the tasks.
|
|
239
252
|
|
|
240
253
|
A committed worker without a checked candidate can show attention, not readiness. Status glyphs use the active TUI theme. The text also names the status without color.
|
|
241
254
|
|
|
242
|
-
|
|
255
|
+
Direct results and completed widget rows sum `usage.totalTokens` from the worker's completed assistant records, including any correction. The total includes cached tokens when the provider includes them in that field. A continued worker counts only its new task turn. Missing usage stays unknown.
|
|
243
256
|
|
|
244
257
|
The cost is the sum of `usage.cost.total` from the same records, read in the same session read. Pi uses the provider's billed total when available; otherwise, it uses the catalog estimate. The extension does not replace a billed total with the sum of catalog cost fields. Isolated task state records no usage, so isolated rows show no tokens or cost.
|
|
245
258
|
|
|
@@ -255,213 +268,11 @@ Activity uses the existing session sample and file-size cache. The extension ign
|
|
|
255
268
|
|
|
256
269
|
## Explicit workspace selection
|
|
257
270
|
|
|
258
|
-
The optional
|
|
259
|
-
|
|
260
|
-
## Isolated contract
|
|
261
|
-
|
|
262
|
-
An isolated request has one durable ID, one goal, and 1 to 8 typed tasks.
|
|
263
|
-
|
|
264
|
-
New worktrees use `.worktrees/subagent-<name>-<24hex>` and branch `pi-subagent/subagent-<name>-<24hex>`. The name uses the request and task IDs. Text tasks also include `text-<attempt>`. Integration checkouts use the request ID and `integration-<generation>`. Each name component has at most 24 characters; the full readable part has at most 72. Names use lowercase ASCII letters, digits, and hyphens. The 24-hex identity suffix keeps names distinct when readable parts are shortened or normalized.
|
|
265
|
-
|
|
266
|
-
Herdr workspace labels use the worker worktree name. Worker tab labels add the model class. Names never use goals, requirements, or other free-form task text. Saved opaque worktree names and their Herdr labels stay unchanged. Resume and cleanup use the exact saved allocations; the extension does not rename existing resources.
|
|
267
|
-
|
|
268
|
-
For example:
|
|
269
|
-
|
|
270
|
-
```json
|
|
271
|
-
{
|
|
272
|
-
"mode": "isolated",
|
|
273
|
-
"id": "refresh-repair",
|
|
274
|
-
"goal": "Repair token refresh with exact checked evidence.",
|
|
275
|
-
"tasks": [
|
|
276
|
-
{
|
|
277
|
-
"id": "inspect",
|
|
278
|
-
"kind": "text",
|
|
279
|
-
"role": "scout",
|
|
280
|
-
"modelClass": "fast",
|
|
281
|
-
"requirements": "Identify the refresh failure and relevant tests.",
|
|
282
|
-
"deliverable": "A concise evidence report.",
|
|
283
|
-
"dependsOn": [],
|
|
284
|
-
"contextFrom": []
|
|
285
|
-
},
|
|
286
|
-
{
|
|
287
|
-
"id": "repair",
|
|
288
|
-
"kind": "changeset",
|
|
289
|
-
"role": "implementer",
|
|
290
|
-
"modelClass": "balanced",
|
|
291
|
-
"requirements": "Implement the smallest correct repair.",
|
|
292
|
-
"deliverable": "A committed candidate in the owned worktree.",
|
|
293
|
-
"dependsOn": [],
|
|
294
|
-
"contextFrom": ["inspect"],
|
|
295
|
-
"checks": [
|
|
296
|
-
{ "command": "pnpm", "args": ["test", "--", "refresh"] }
|
|
297
|
-
],
|
|
298
|
-
"judgment": {
|
|
299
|
-
"role": "reviewer",
|
|
300
|
-
"modelClass": "balanced",
|
|
301
|
-
"criterion": "The exact candidate fixes refresh and preserves unrelated behavior."
|
|
302
|
-
}
|
|
303
|
-
}
|
|
304
|
-
],
|
|
305
|
-
"finalChecks": [
|
|
306
|
-
{ "command": "pnpm", "args": ["test", "--", "refresh"] }
|
|
307
|
-
]
|
|
308
|
-
}
|
|
309
|
-
```
|
|
310
|
-
|
|
311
|
-
The request also accepts optional `finalJudgment` with `role`, `modelClass`, and `criterion`, using the same shape as task `judgment`.
|
|
312
|
-
|
|
313
|
-
Every task declares `id`, `kind`, `role`, `modelClass`, `requirements`, `deliverable`, `dependsOn`, and `contextFrom`.
|
|
314
|
-
|
|
315
|
-
- A `text` task runs in a disposable child worktree and must leave it unchanged.
|
|
316
|
-
- A `changeset` task requires focused checks and owns one worktree, Herdr workspace, worker tab, and retained worker.
|
|
317
|
-
- `dependsOn` controls ready waves; dependent tasks can run from a selected staged snapshot only after Main explicitly advances it.
|
|
318
|
-
- `contextFrom` may reference completed text tasks only, implies scheduling dependencies, and preserves declaration order. It must not overlap `dependsOn`.
|
|
319
|
-
- A graph containing changesets requires final checks. The repository root must have a `package.json` test script; admission prepends canonical `pnpm test` if absent from final checks. Combined validation rejects a changed root test script.
|
|
320
|
-
|
|
321
|
-
Admission and worker-wave dispatch pin Main's exact committed branch, HEAD, and tree without inspecting or modifying its staged, unstaged, or untracked edits. Worker allocation verifies the same committed identity around worktree creation, including resumed waves; staged-dependent waves verify their clean integration snapshot. A dirty Main can therefore produce a checked retained candidate, but branch/HEAD drift stops new waves. The runner executes ready worker tasks concurrently, inspects clean committed candidates, runs preliminary task checks and optional preliminary judgment, then records ready candidates for Main. **It does not automatically integrate them.**
|
|
322
|
-
|
|
323
|
-
Main selects exact candidates through `subagent_stage` into an owned integration checkout in explicit order. Each stage is a committed merge of the candidate, not a mutation of Main. Conflicts retain the checkout for Main to resolve; `resolve` verifies the exact two-parent merge instead of replaying an uncertain merge. Main can explicitly run dependent tasks from an exact staged tip with `subagent_integrate advance` and stage their results afterward. Independent candidates may be staged without re-running workers.
|
|
324
|
-
|
|
325
|
-
Once all selected work is staged, Main calls `subagent_integrate validate` on the exact clean combined tip. It acknowledges the durably saved validation intent and continues in the session-owned background, independent of later turn cancellation; session replacement/shutdown still cancels it. A follow-up reports completion; status remains authoritative if delivery is missed. This runs every final check, including `pnpm test`, unless [exact check reuse](#validate-and-promote) applies, and optional final judgment in the integration checkout before any Main mutation. A failed check/review can be followed by one Main-authored committed correction in that checkout, recorded with `correct`, then another `validate`.
|
|
326
|
-
|
|
327
|
-
Staging, combined validation, and `promote` require clean Main at the recorded committed identity. Dirty edits block these actions even when the checked candidate stays retained. The extension never replays or merges dirty work automatically. `promote` requires exact passing combined evidence and unchanged Main and uses a guarded update to Main. Only proven promotion leads to selected-worker termination and verified cleanup. A changed candidate, integration tip, or Main identity invalidates prior evidence or blocks promotion; review accepts only exact `PASS`.
|
|
328
|
-
|
|
329
|
-
### Text results and cleanup
|
|
330
|
-
|
|
331
|
-
The extension saves completed text answers independently of cleanup. Status and terminal follow-ups include a bounded preview of the accepted answer and cleanup evidence. Ignored automatic artifacts can retain a checkout, and this does not violate the read-only contract. The extension deletes no ignored files to make cleanup pass.
|
|
332
|
-
|
|
333
|
-
Tracked or untracked changes, a changed checkout identity, or unproved inspection still require attention. The completed answer stays saved. But the extension does not accept it as dependency context or retry it automatically. Retained text checkouts require deliberate manual inspection and cleanup. A retained checkout alone is not evidence that the Role edited source.
|
|
334
|
-
|
|
335
|
-
### Readiness and Main actions
|
|
336
|
-
|
|
337
|
-
The user's request can authorize the declared local graph, checks, review, and Main's later explicit integration actions. After each successful preliminary check batch, the runner drains any follow-up already queued for the same live worker. Each revision must produce a new clean commit and rerun preliminary checks. When the queue is empty, the runner atomically seals the candidate and persists exact readiness evidence without waiting for input.
|
|
338
|
-
|
|
339
|
-
After readiness, use `subagent_stage revise` with the exact candidate, generation, current `expectedTip`, and instruction. A same-worker correction must remain available. Material scope growth, missing authorization, user-owned conflicts, and consequential external actions require a new decision. Pi Subagent never pushes, publishes, deploys, or opens a pull request.
|
|
340
|
-
|
|
341
|
-
### Inspect and revise active work
|
|
342
|
-
|
|
343
|
-
Requires Pi 1.5.0 or later in the 1.x series. To select work by label, open `/subagent` without arguments. The inline selector reports Pi's native blocked status while it waits for user input. Pi clears this status when the selector closes. Key hints use the keybinding manager that Pi supplies.
|
|
344
|
-
|
|
345
|
-
First, a **Current subagent work** report shows the work that local and saved evidence proves is running: locally owned direct workflows with a running worker, and active isolated requests while a live run holds the repository lease. The report lists active requests without a live lease as interrupted, and recorded-only direct work as unverified. A live lease does not identify its request, so several active requests in one checkout all show as working. The menu shows direct records on this session branch and isolated requests in the current canonical Git checkout. This includes requests launched in other sessions. Select an isolated request. Then select **Inspect status and recovery**.
|
|
346
|
-
|
|
347
|
-
The menu also shows requests whose saved parent checkout no longer exists, in their own **Orphaned · parent checkout removed** group. Saved `running` and `pending` states have a `saved` prefix and an `unverified` suffix. The report lists them under **Unverified**, never **Working**, even if the current checkout has a live lease. These labels do not change saved state or prove completion. Orphaned requests with retained resources or `needs_attention` show under **Needs attention**. You can open this view from any checkout of the same repository. The saved worker or integration path identifies the primary repository. Orphaned requests have the same **Close and delete worktrees (discard work)** action, but no inspection or follow-up actions. The extension reads their original state directories; it does not recreate the removed parent checkout. Unreadable files stay preserved and are reported.
|
|
348
|
-
|
|
349
|
-
This launches a Herdr tab without focus, with the configured `scout` Role on the configured `fast` route. The tab runs a read-access task with the resources of the Role. Its prompt contains bounded saved status, including retained paths, but not the raw launch environment or session transcripts. The analysis stays in that tab and does not queue a Main turn. The tab shows in the direct list with its own reference and name, such as `D9.1 · scout · Inspect <request ID>`. The extension records the tab and session file for recovery, even if the launch becomes uncertain.
|
|
350
|
-
|
|
351
|
-
Before any stage or recovery action, the read-only `subagent_status` tool stays Main's authority for exact identities. If Herdr, the `scout` Role, or the fast route is not available, inspection fails and does not change the request. Main can then use `subagent_status`.
|
|
352
|
-
|
|
353
|
-
Both isolated groups hide terminal requests by default: `completed`, `aborted`, `final_failed`, and `superseded`. Requests with retained resources or unresolved recovery stay visible. Select **Completed / history** to see all saved requests; **Refresh** reloads the current view. The filter does not delete records. Without interactive UI, the request list includes history. The extension shows a warning for invalid state IDs and preserves them. Direct recovery still works outside Git or when isolated inventory is not available. The browse action does not resume work or change resources. Direct **Close/cancel-and-release** is an explicit termination action.
|
|
354
|
-
|
|
355
|
-
For a locally active unsealed isolated changeset, choose **Send follow-up instructions** to open a native multiline editor. A submission queues the instruction, not a completed revision. Choose **Edit queued instructions** to withdraw *all still-pending* instructions for that selected task before the editor opens. Their full text shows in FIFO order, with blank lines between them. An explicit submission queues **one replacement** at the end. If you cancel, the withdrawn instructions stay removed.
|
|
356
|
-
|
|
357
|
-
You cannot recall already-claimed instructions, initial prompts, or automatic corrections. A worker can seal while you edit. If the submission fails, the editor opens again with the full submitted text. You can then edit or copy it deliberately. The extension never queues it again automatically.
|
|
358
|
-
|
|
359
|
-
The editor preserves combined text above the single-instruction limit, but rejects it until you make it shorter. A cancel before withdrawal makes no change. Neither action touches Main's editor or Pi's global Option+Up queue shortcut. Sessions without a UI can run `/subagent recover` or use agent tools for individual inspection and recovery.
|
|
360
|
-
|
|
361
|
-
A queued follow-up runs after the current turn settles. It must produce a new clean commit that passes preliminary checks again. When no queued revision remains, the checked candidate seals immediately. There is no guaranteed time to edit after completion. Late follow-ups fail visibly.
|
|
362
|
-
|
|
363
|
-
### Exact integration actions
|
|
364
|
-
|
|
365
|
-
`subagent_status` shows failed review verdicts from each task's latest dispatch, the final gate, and each generation, including while siblings run. Its text uses one shared 32 KiB budget and counts omitted verdicts. Structured output carries each verdict up to 32 KiB and sets `verdictTruncated` when necessary. Follow-ups give short previews and direct Main to status for the full text.
|
|
366
|
-
|
|
367
|
-
Status reports ready candidates with `taskId`, `attempt`, and `tip`. Each generation records its number, stage lineage, combined tip, checks, promotion, and retained worktree. Use these exact identities, including branch, HEAD, index, and tree. Do not guess commits.
|
|
368
|
-
|
|
369
|
-
#### Stage and resolve
|
|
370
|
-
|
|
371
|
-
```text
|
|
372
|
-
{ id, action: "stage" | "resolve" | "reject" | "revise", generation, taskId, attempt, candidate, expectedTip, instruction? }
|
|
373
|
-
```
|
|
374
|
-
|
|
375
|
-
`candidate` is the ready candidate's `tip`. For the first stage, `expectedTip` is Main's recorded identity. Later stages use the previous stage's exact tip. `resolve` checks a pending or conflicted merge, including its exact two-parent identity. It never replays an uncertain merge.
|
|
376
|
-
|
|
377
|
-
Stage and resolve remain available during an active wave; rejection and revision wait until the wave settles. If allocation was uncertain, resolve first proves that the owned checkout remains at its base before starting the selected merge. Otherwise, it retains the intent.
|
|
378
|
-
|
|
379
|
-
Rejection or revision of a staged candidate supersedes that generation and leaves its checkout read-only. Main must explicitly restage selected candidates into a new generation. Each request permits at most two unreleased integration worktrees. Superseded generations and rejected candidates remain until explicit release.
|
|
380
|
-
|
|
381
|
-
Rejection invalidates dependent work. Rejection and revision ignore dependent work that refresh or an earlier rejection already invalidated. If fresh dependent execution exceeds dispatch or lineage limits, start a new request. Do not force promotion.
|
|
382
|
-
|
|
383
|
-
#### Validate and promote
|
|
384
|
-
|
|
385
|
-
```text
|
|
386
|
-
{ id, action: "advance" | "validate" | "correct" | "promote" | "reconcile" | "cleanup", generation, expectedTip }
|
|
387
|
-
```
|
|
388
|
-
|
|
389
|
-
Use the generation's exact `combinedTip` as `expectedTip`. `advance` dispatches ready dependents from that snapshot. `correct` records one clean committed correction after a definitive failed check or review. `reconcile` inspects interrupted validation or promotion without replaying uncertain promotion. `cleanup` finishes proved post-promotion cleanup.
|
|
390
|
-
|
|
391
|
-
Post-promotion cleanup handles each promoted stage separately. A blocked termination or cleanup step records its failure on that step, and cleanup continues with the other stages and then the promoted integration checkout. Clean Main at the promoted identity is a shared precondition; if Main changed, every pending step records the blocker. Dirty, untracked, or ignored files block worktree removal and stay preserved. Until every promoted termination and cleanup step completes, the request stays `needs_attention` with promotion proven, selected tasks `completed`, and not accepted, so `/subagent` lists it. Resolve the recorded blockers, then call `cleanup` again; the request becomes `completed` and accepted only after cleanup completes.
|
|
392
|
-
|
|
393
|
-
Validation acknowledges only after saving the exact generation's validation intent. Checks and final judgment then run in the background. Later turn cancellation does not cancel acknowledged validation; session replacement or shutdown does. Acknowledgement is not passing evidence. Inspect status if the completion follow-up fails.
|
|
394
|
-
|
|
395
|
-
Validation reuses a passed preliminary result for a final check, and does not run that check again, only when all of these conditions are true:
|
|
396
|
-
|
|
397
|
-
- The candidate is staged in this generation.
|
|
398
|
-
- The tree OID of the combined tip is equal to the tree OID of the candidate. This usually occurs when you stage one candidate onto unchanged pinned Main.
|
|
399
|
-
- The saved preliminary checks of the candidate passed, and their `candidate` and `identityAfter` are equal to the candidate tip.
|
|
400
|
-
- The preliminary result has the identical command and argv, exit code 0, and no timeout or signal.
|
|
401
|
-
|
|
402
|
-
Any mismatch runs the check normally. Each reused result records `reusedFrom` with `taskId`, `attempt`, and `candidate`. Status text and the validation follow-up show each reused command. Promotion, reconciliation, and state loading accept a reused result only after they prove these conditions again from saved identities. Final judgment still runs. Reuse assumes that checks use only tracked content. Ignored files, for example `node_modules`, can be different between the worker and integration worktrees.
|
|
403
|
-
|
|
404
|
-
#### Refresh
|
|
405
|
-
|
|
406
|
-
```text
|
|
407
|
-
{ id, action: "refresh", generation, expectedTip, expectedMain, newMain }
|
|
408
|
-
```
|
|
409
|
-
|
|
410
|
-
If Main advances to a clean same-branch descendant, refresh freezes the old generation and allocates a new checkout from `newMain`. Restage selected immutable candidates in order, resolve fresh conflicts, and rerun combined validation. Dirty, divergent, or uncertain Main blocks refresh.
|
|
411
|
-
|
|
412
|
-
After interrupted validation, prove that the old coordinator and check processes stopped. Never take over a live productive lease. Use guarded `reconcile` on the saved generation and `combinedTip`. Missing checks or review never authorize `correct` or `promote`.
|
|
413
|
-
|
|
414
|
-
A reconciled `validation_failed` generation without recorded checks, review, or a prior combined correction permits refresh with identical `expectedMain` and `newMain`. Supply the exact old combined `expectedTip` and next generation number. Main and the retained integration tip must remain exact and clean. This allocates a new checkout; it never resumes uncertain checks.
|
|
415
|
-
|
|
416
|
-
Restage selected candidates and run all final checks and required judgment before promotion. The old generation remains retained, the two-checkout limit still applies, and correction allowances do not reset.
|
|
417
|
-
|
|
418
|
-
#### Release and abort
|
|
419
|
-
|
|
420
|
-
```text
|
|
421
|
-
{ id, action: "release", generation, expectedTip, taskId?, attempt? }
|
|
422
|
-
```
|
|
423
|
-
|
|
424
|
-
Without a task, release a superseded clean checkout using its recorded tip. Use its correction tip, otherwise its last staged tip, otherwise its integration base. Supersession preserves the correction record.
|
|
425
|
-
|
|
426
|
-
With `taskId` and `attempt`, release a rejected candidate, including dependent work invalidated by refresh or rejection. First release every generation that staged it. Supply its candidate tip and the latest generation number, or `1` if none exists.
|
|
427
|
-
|
|
428
|
-
Release proves exact worker termination before cleanup. An absent worker still requires pane absence and two empty lease scans. An observed live worker without saved termination intent can close with the same proof. Uncertain termination never replays automatically.
|
|
429
|
-
|
|
430
|
-
Release saves each host, checkout, and branch step separately. It checks ownership and cleanliness, including ignored files. Branch deletion requires the exact recorded tip. A repeated release proves absence for already-removed resources. Dirty, conflicted, changed, uncertain, or still-needed resources remain for manual inspection. Resolve the blocker, then repeat release; each released checkout frees a slot.
|
|
431
|
-
|
|
432
|
-
Abort cannot discard retained resources. It becomes available after rejection and release of all candidates and owned checkouts. It also removes an empty refreshed generation that remains clean at its base.
|
|
433
|
-
|
|
434
|
-
If you removed resources outside Pi Subagent, abort can reconcile their absence. Each retained candidate or staged integration checkout must be unregistered, its path absent, and its branch absent. Workers must also be proved absent through pane and lease checks. Abort then records candidates as rejected and released and completes cleanup. Any present resource blocks abort without changing the request.
|
|
435
|
-
|
|
436
|
-
### Recovery and state
|
|
437
|
-
|
|
438
|
-
State version 5 lives privately under:
|
|
439
|
-
|
|
440
|
-
```text
|
|
441
|
-
<agent-dir>/config/pi-subagent/state/<repository-hash>/<request-id>.json
|
|
442
|
-
```
|
|
443
|
-
|
|
444
|
-
Parsing rejects unknown properties, malformed evidence, invalid lineage, and v4 or older state without migration. Preserve old files and recover work manually. Writes are atomic. A productive lease prevents concurrent execution or resumption but permits status inspection and abort.
|
|
445
|
-
|
|
446
|
-
`delegate_task`, `subagent_resume`, and `subagent_integrate advance` return a durable request ID after saving the wave. Work continues asynchronously. A saved worker attention state sends a follow-up to the launching session, including while siblings run. The wave also reports its final result.
|
|
447
|
-
|
|
448
|
-
Isolated workers save private exact Pi sessions under their owned process leases. A proved final answer without a changed clean commit requires attention. Missing or mismatched session proof cannot establish completion and never permits prompt replay.
|
|
449
|
-
|
|
450
|
-
When a finished turn leaves tracked or untracked changes in a valid owned worktree, the runner sends one commit reminder per dispatch try. It saves the reminder before delivery. This uses neither a correction nor a dispatch try. The runner never commits, stages, stashes, or discards. A resulting commit follows normal candidate checks; remaining dirty work requires attention.
|
|
451
|
-
|
|
452
|
-
`subagent_status` stays read-only and authoritative if delivery fails. Session replacement or shutdown suppresses stale follow-ups and logs the request ID and reason, not prompts or credentials. Synchronous delivery failures report without automatic replay. Pi reports asynchronous `send_message` failures through its runtime.
|
|
453
|
-
|
|
454
|
-
`subagent_resume` accepts only the reported `retry`, `verify`, or `finalize` continuation. A same-worker correction `retry` permits optional `instruction`: at most 32000 exact characters, with no NUL. The prompt includes this as Main's instruction after the saved failure and saves it before delivery. Other actions reject it.
|
|
455
|
-
|
|
456
|
-
Without retained candidates, abort terminates exact owned workers and removes only owned checkouts that remain clean and unchanged from their pinned base. Cleanup includes ignored-file checks. Productive execution delays cleanup until it settles. Repeat abort to reconcile pending cleanup without replaying uncertain termination. Dirty or committed work and uncertain allocations remain with blockers. `/subagent recover` includes aborted requests with retained resources.
|
|
457
|
-
|
|
458
|
-
### Recover after interruption
|
|
459
|
-
|
|
460
|
-
After a coordinator interruption, run `/subagent recover` one time. It gets the repository productive lease before it changes any interrupted `pending` or `running` state. It preserves unreadable state files and retained candidates. It reports blockers and existing continuations to Main. It does not replay prompts, merges, promotion, or cleanup.
|
|
271
|
+
The optional `repositories` map selects existing checkouts. See [Workspace selection](./workspace.md).
|
|
461
272
|
|
|
462
|
-
|
|
273
|
+
## Saved isolated requests
|
|
463
274
|
|
|
464
|
-
|
|
275
|
+
Use `/subagent` or `subagent_status` to inspect an existing request. Use `subagent_workspace` with `action: "status"` for saved multi-repository requests. A saved candidate stays in its original checkout for manual review.
|
|
465
276
|
|
|
466
277
|
### Close and delete isolated worktrees
|
|
467
278
|
|
|
@@ -481,7 +292,7 @@ The report lists removed, skipped, and failed resources. After complete cleanup,
|
|
|
481
292
|
|
|
482
293
|
### Subagent Collection
|
|
483
294
|
|
|
484
|
-
Subagent Collection closes only verified completed worker tabs. It keeps saved sessions, process leases, worktrees, candidates, and recovery records. It never closes a workspace or its root tab.
|
|
295
|
+
Subagent Collection applies to Herdr tabs saved before version 31.0.0. It closes only verified completed worker tabs. It keeps saved sessions, process leases, worktrees, candidates, and recovery records. It never closes a workspace or its root tab.
|
|
485
296
|
|
|
486
297
|
Automatic collection checks each relevant workspace after direct `delegate_task` launches, after direct or isolated workflows finish, and when Main settles. More than 10 tabs in that workspace triggers collection. Ten is a trigger, not a maximum. Collection can close all eligible tabs, even after the count falls below 10. User tabs count toward the trigger but are never collection targets. There is no timer: changes from other clients wait for the next check.
|
|
487
298
|
|
|
@@ -594,7 +405,7 @@ The extension never modifies the file. Fix the entry or choose another server. T
|
|
|
594
405
|
|
|
595
406
|
The extension still ignores project MCP overrides. A project cannot change the global server allowlist or exposure of the Role. Missing Skills, tools, MCP servers, Roles, or routes fail before productive work starts. The extension excludes Main-only delegation and recovery tools and `ask_question` from children.
|
|
596
407
|
|
|
597
|
-
Isolated
|
|
408
|
+
Isolated native worker launches receive the same turn, token, and child-runtime budget metadata as ephemeral launches. Retained workers therefore keep one non-refilling session budget across follow-ups using the usage in the saved Pi session.
|
|
598
409
|
|
|
599
410
|
### Migrate MCP exposure to 28.0.0
|
|
600
411
|
|
package/docs/workspace.md
CHANGED
|
@@ -1,85 +1,9 @@
|
|
|
1
|
-
#
|
|
1
|
+
# Existing workspace repositories
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
```mermaid
|
|
6
|
-
flowchart LR
|
|
7
|
-
S[Explicit repository set] --> W[One worker, separate owned worktrees]
|
|
8
|
-
W --> C[Check the complete candidate set]
|
|
9
|
-
C --> I[Stage and check the complete integration set]
|
|
10
|
-
I --> P[Preflight every Main target]
|
|
11
|
-
P --> R[Promote serially and save each receipt]
|
|
12
|
-
R --> X[Reconcile a partial result explicitly]
|
|
13
|
-
```
|
|
14
|
-
|
|
15
|
-
## Request
|
|
16
|
-
|
|
17
|
-
```json
|
|
18
|
-
{
|
|
19
|
-
"mode": "isolated",
|
|
20
|
-
"id": "change-contract",
|
|
21
|
-
"goal": "Change the service and client together.",
|
|
22
|
-
"repositories": { "service": "/work/app/service", "client": "/work/app/client" },
|
|
23
|
-
"tasks": [{
|
|
24
|
-
"id": "change", "kind": "changeset", "role": "implementer", "modelClass": "balanced",
|
|
25
|
-
"requirements": "Change and test both sides of the contract.",
|
|
26
|
-
"deliverable": "Clean committed candidates in both selected worktrees.",
|
|
27
|
-
"dependsOn": [], "contextFrom": [],
|
|
28
|
-
"inputs": { "contract": "/work/app/contract.txt" },
|
|
29
|
-
"checks": [
|
|
30
|
-
{ "repository": "service", "command": "pnpm", "args": ["test"] },
|
|
31
|
-
{ "repository": "client", "command": "pnpm", "args": ["test"] }
|
|
32
|
-
]
|
|
33
|
-
}],
|
|
34
|
-
"finalChecks": [
|
|
35
|
-
{ "repository": "service", "command": "pnpm", "args": ["test"] },
|
|
36
|
-
{ "repository": "client", "command": "pnpm", "args": ["test"] }
|
|
37
|
-
]
|
|
38
|
-
}
|
|
39
|
-
```
|
|
40
|
-
|
|
41
|
-
Call from `/work/app`. Each repository must be a canonical direct child with its own `.git` directory. Select 1 to 8 repositories. Aliases, linked worktrees, nested repositories, Git environment overrides, and repositories with Git submodules are not supported.
|
|
42
|
-
|
|
43
|
-
Workspace mode supports exactly one changeset task. It rejects text tasks, dependencies, task judgment, and final judgment. It has no automatic correction, retry, refresh, or restaging. The existing single-repository graph remains unchanged when `repositories` is absent.
|
|
44
|
-
|
|
45
|
-
Every selected repository needs task checks and final checks. Select commands that test that repository. The complete final command list must contain at most 32 entries. Checks must leave the tracked and untracked state clean. If the committed root `package.json` has a test script, that script is pinned from the exact Main base commit. Dirty Main files do not change the pinned script. All task and final checks reject a changed pinned script, regardless of the command name, path, or arguments. Repositories without a root manifest or test script can use their native check commands.
|
|
46
|
-
|
|
47
|
-
`PI_SUBAGENT_REPOSITORIES` contains the absolute repository-to-worktree map as JSON, which is a structured text format. `PI_SUBAGENT_INPUTS` contains the input-name-to-copy map. Check commands receive both environment variables. Task checks use worker worktrees; final checks use integration worktrees. The complete repository set is checked before and after commands, including unchanged members.
|
|
48
|
-
|
|
49
|
-
## Root inputs
|
|
50
|
-
|
|
51
|
-
`inputs` selects up to 8 canonical regular files inside the workspace but outside every Git repository. Each file can contain at most 64 KiB. Directories and symlinks are rejected. Each request stores separate private read-only copies. A later request can select different inputs or new contents.
|
|
52
|
-
|
|
53
|
-
The worker gets copy paths, not permission to edit original inputs. Their content identities are checked with every complete-set inspection. A changed source or copy blocks validation and promotion. Inputs never become Git candidates and are never promoted or restored. This is not a sandbox: an authorized tool can bypass file permissions. A detected input change requires manual inspection.
|
|
54
|
-
|
|
55
|
-
## Integration and recovery
|
|
56
|
-
|
|
57
|
-
Use `subagent_workspace` from the workspace root. Workspace records use their own state version; they do not change existing single-repository records. `/subagent` does not list workspace requests. Existing prune checks protect their retained repository resources.
|
|
58
|
-
|
|
59
|
-
| Action | Required fields | Result |
|
|
60
|
-
| --- | --- | --- |
|
|
61
|
-
| `status` | `id` | Read saved state without mutations. |
|
|
62
|
-
| `stage` | `id`, `expected` | Select the complete checked candidate map from `candidates`. Create an integration worktree in every repository. |
|
|
63
|
-
| `validate` | `id`, `expected` | Check the complete integration map from `tips`. |
|
|
64
|
-
| `promote` | `id`, `expected` | Preflight every target, then promote the exact passing `tips` serially. |
|
|
65
|
-
| `reconcile` | `id` | Inspect interrupted stage or promotion intents without replay. |
|
|
66
|
-
| `abort` | `id` | Stop the exact task-wide worker and retain all Git work. |
|
|
67
|
-
| `cleanup` | `id` | Remove only fully promoted, clean, exactly owned resources. |
|
|
68
|
-
|
|
69
|
-
`expected` must include every repository and its exact branch, commit, index tree, and committed tree. Partial maps are rejected. Status retains per-repository candidates, stages, intents, and promotion receipts.
|
|
70
|
-
|
|
71
|
-
Dirty Main files are preserved. Worker execution can start from the committed Main identities while Main is dirty. Staging and promotion require all Main targets to be clean and unchanged. Each promotion receipt is saved before the next repository can move. All targets are checked again between promotions.
|
|
72
|
-
|
|
73
|
-
**Promotion is not atomic.** A later repository can fail after an earlier repository moved. No rollback is attempted. After an interrupted promotion, call `reconcile`. It compares each uncertain target with its saved endpoints. A target at the promoted endpoint gets a receipt; a target still at its base becomes pending. Then explicitly call `promote` with the complete `tips` to continue. No proven promotion is repeated. Any other Main state requires manual reconciliation.
|
|
74
|
-
|
|
75
|
-
A crash during allocation does not grant ownership. Uncertain allocations and worker prompts are retained and are never adopted or replayed automatically. A completed exact merge can be reconciled after manual conflict resolution. An unstarted merge or incomplete allocation needs manual inspection and a new request. Failed and aborted work is retained; automatic discard is not available.
|
|
76
|
-
|
|
77
|
-
Worker observation uses the request's saved `childMaxMs` maximum runtime and `childIdleMs` idle limit. Only complete Pi session messages renew the idle limit; the maximum runtime does not renew. When a limit expires, the runner saves prompt failure evidence and attempts exact worker termination with a separate safety budget. Unproved termination stays visible for recovery. Every repository worktree is retained, and uncertain prompts are not replayed. These are worker limits, not a deadline for the complete request.
|
|
78
|
-
|
|
79
|
-
An active `abort` can first report a busy lifecycle lock while cancellation settles. Inspect status and repeat `abort` after the active operation ends. Session replacement cancels local observation and suppresses stale delivery, but preserves saved recovery identities.
|
|
80
|
-
|
|
81
|
-
## Direct work
|
|
3
|
+
Select 1 to 8 existing repositories with a `repositories` map from short names to canonical paths. Each selected repository must be a direct child of the workspace.
|
|
82
4
|
|
|
83
5
|
Direct requests can also supply the top-level `repositories` map. Each task uses the same selected set. A write request reserves the workspace and every selected checkout together until all exact owned workers are proved stopped. A conflict in one member refuses the whole reservation. The result labels each repository's change report or stale-read warning.
|
|
84
6
|
|
|
85
7
|
Direct selection rejects `paths` and `continueFrom`. Scope comes from the task packet. Root-file writes are not authorized by repository selection. Direct work has no checked integration, rollback, or sandbox. Other sessions and external processes are outside process-local admission.
|
|
8
|
+
|
|
9
|
+
Use `subagent_workspace` with `action: "status"` to inspect previously saved multi-repository work. Use the explicit `action: "cleanup"` to release resources only after every repository has a promotion receipt. Cleanup requires proved worker termination, unchanged clean Main targets, and exact owned clean resources. It retains failed, aborted, dirty, changed, or uncertain work and reports why. Repeat cleanup to continue after a blocked step. This tool does not start or resume work, allocate resources, stage changes, or promote them.
|