pi-herdr-agents 0.0.1
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/AGENTS.md +116 -0
- package/CONTEXT.md +159 -0
- package/LICENSE +21 -0
- package/README.md +874 -0
- package/RELEASING.md +139 -0
- package/agents/adversarial-reviewer.md +80 -0
- package/agents/claude-reviewer.md +23 -0
- package/agents/planner.md +539 -0
- package/agents/poteto.md +32 -0
- package/agents/reviewer.md +164 -0
- package/agents/scout.md +106 -0
- package/agents/visual-tester.md +224 -0
- package/agents/worker.md +132 -0
- package/config.json.example +8 -0
- package/docs/README.md +42 -0
- package/docs/adr/0001-btw-ephemeral-side-questions.md +142 -0
- package/docs/adr/0002-agent-workflow-skill-runtime-taxonomy.md +265 -0
- package/docs/adr/0003-installable-role-packs.md +135 -0
- package/docs/adr/0004-require-active-user-approval-for-workflow-execution.md +17 -0
- package/docs/adr/0005-parent-owns-workflow-script-authority.md +17 -0
- package/docs/adr/0006-limit-v1-execution-effects-to-isolated-worktrees.md +18 -0
- package/docs/adr/0007-require-fresh-review-for-workflow-scripts.md +19 -0
- package/docs/orchestrated-review-workflow-plan.md +479 -0
- package/docs/research/pdw-architecture-assessment.md +525 -0
- package/docs/research/pi-workflows-sol-advisor.md +255 -0
- package/docs/research/worktree-subagent-orchestration.md +317 -0
- package/docs/worktree-subagents.md +196 -0
- package/examples/role-pack/extension.ts +18 -0
- package/examples/role-pack/package.json +16 -0
- package/examples/role-pack/roles/example-reviewer.md +12 -0
- package/package.json +58 -0
- package/pi-extension/subagents/activity.ts +511 -0
- package/pi-extension/subagents/completion.ts +177 -0
- package/pi-extension/subagents/herdr.ts +541 -0
- package/pi-extension/subagents/index.ts +4730 -0
- package/pi-extension/subagents/lifecycle.ts +477 -0
- package/pi-extension/subagents/model-config.ts +95 -0
- package/pi-extension/subagents/plan-skill.md +262 -0
- package/pi-extension/subagents/plugin/.claude-plugin/plugin.json +5 -0
- package/pi-extension/subagents/plugin/hooks/hooks.json +15 -0
- package/pi-extension/subagents/plugin/hooks/on-stop.sh +68 -0
- package/pi-extension/subagents/runtime-routing.ts +313 -0
- package/pi-extension/subagents/session.ts +216 -0
- package/pi-extension/subagents/status.ts +513 -0
- package/pi-extension/subagents/subagent-done.ts +326 -0
- package/pi-extension/subagents/terminal.ts +163 -0
- package/pi-extension/subagents/workflow-worker.js +56 -0
- package/pi-extension/subagents/workflow.ts +1210 -0
- package/skills/orchestrate/SKILL.md +184 -0
|
@@ -0,0 +1,255 @@
|
|
|
1
|
+
# Research: pi-dynamic-workflows and sol-advisor
|
|
2
|
+
|
|
3
|
+
**Date:** 2026-08-03
|
|
4
|
+
**Question:** What are the architectures, execution/data flows, and extension points of first-party `pi-dynamic-workflows` and `DannyMac180/sol-advisor`, and which ideas transfer to a potential `pi-herdr-subagents` workflow feature?
|
|
5
|
+
**Method:** Read-only review of GitHub source/docs clones. No code modified.
|
|
6
|
+
**Local transfer context (not the research targets):** `giuseppecrj/pi-herdr-agents` ADR-0002 taxonomy and draft orchestrator-designed-workflows spec.
|
|
7
|
+
|
|
8
|
+
> This is preliminary research. The later ADRs and [`../orchestrated-review-workflow-plan.md`](../orchestrated-review-workflow-plan.md) supersede its early recommendation for a declarative workflow document.
|
|
9
|
+
|
|
10
|
+
## Sources pinned
|
|
11
|
+
|
|
12
|
+
| Project | Repo | Branch | Commit | Notes |
|
|
13
|
+
| --- | --- | --- | --- | --- |
|
|
14
|
+
| pi-dynamic-workflows | <https://github.com/Michaelliv/pi-dynamic-workflows> | `main` | `31b2aca0f1cb195aafbfc5e3ee2b8c83ad3f21a2` (Release v1.0.1, 2026-05-31) | Earliest public tree found (created 2026-05-28; many community forks exist). Package version `1.0.1`. |
|
|
15
|
+
| sol-advisor | <https://github.com/DannyMac180/sol-advisor> | `main` | `52c0f5d467a672241665fa45aab15333274c1eef` (merge of Luna task lane, 2026-08-03) | Codex plugin version `0.4.0` in `plugins/sol-advisor/.codex-plugin/plugin.json`. |
|
|
16
|
+
|
|
17
|
+
Related first-party inspiration cited by the workflow package:
|
|
18
|
+
|
|
19
|
+
- Anthropic dynamic workflows post: <https://claude.com/blog/introducing-dynamic-workflows-in-claude-code>
|
|
20
|
+
|
|
21
|
+
## 1. pi-dynamic-workflows
|
|
22
|
+
|
|
23
|
+
### What it is
|
|
24
|
+
|
|
25
|
+
A Pi package that adds one tool: `workflow`. The parent model does not call many subagents itself. It writes a small deterministic JavaScript script; the tool parses and runs that script in a Node `vm` sandbox; the script fans out work through `agent()`, `parallel()`, and `pipeline()`.
|
|
26
|
+
|
|
27
|
+
Install surface (from README / `package.json`):
|
|
28
|
+
|
|
29
|
+
- `pi install npm:pi-dynamic-workflows`
|
|
30
|
+
- Pi package metadata: `"pi": { "extensions": ["extensions/workflow.ts"] }`
|
|
31
|
+
- Peer packages: `@earendil-works/pi-ai`, `@earendil-works/pi-coding-agent`, `@earendil-works/pi-tui` (^0.78.0 in the pinned tree)
|
|
32
|
+
|
|
33
|
+
### Architecture (modules)
|
|
34
|
+
|
|
35
|
+
| Path | Role |
|
|
36
|
+
| --- | --- |
|
|
37
|
+
| `extensions/workflow.ts` | Extension entry: `registerTool(createWorkflowTool())`; on `session_start`, force-activates the tool. |
|
|
38
|
+
| `src/workflow-tool.ts` | Tool definition, prompt guidelines, abort handling, streaming progress via tool updates. |
|
|
39
|
+
| `src/workflow.ts` | Acorn AST parse/validate of `export const meta`, determinism checks, sandboxed runtime, concurrency limiter, globals. |
|
|
40
|
+
| `src/agent.ts` | `WorkflowAgent`: in-memory Pi session per `agent()` call via `createAgentSession` + `SessionManager.inMemory`. |
|
|
41
|
+
| `src/structured-output.ts` | Terminating `structured_output` tool (`terminate: true`) for schema-validated returns. |
|
|
42
|
+
| `src/display.ts` | Snapshot model + compact text/widget renderers for live progress. |
|
|
43
|
+
| `types/workflow.d.ts` | Ambient globals for reusable workflow scripts (`/// <reference types="pi-dynamic-workflows/workflow" />`). |
|
|
44
|
+
|
|
45
|
+
### Execution / data flow
|
|
46
|
+
|
|
47
|
+
```text
|
|
48
|
+
user asks for a workflow
|
|
49
|
+
→ parent Pi model writes a JS script
|
|
50
|
+
→ workflow tool receives { script, args? }
|
|
51
|
+
→ parseWorkflowScript(script)
|
|
52
|
+
- first statement must be export const meta = { name, description, ... }
|
|
53
|
+
- meta is literal-only (no spreads, computed keys, interpolation, calls)
|
|
54
|
+
- whole AST bans Date.now(), Math.random(), new Date()
|
|
55
|
+
→ runWorkflow in vm.createContext
|
|
56
|
+
globals: agent, parallel, pipeline, phase, log, args, cwd, process.cwd, budget
|
|
57
|
+
no require/import/fs/network
|
|
58
|
+
→ each agent() call:
|
|
59
|
+
concurrency-limited
|
|
60
|
+
WorkflowAgent.run → createAgentSession(in-memory) + coding tools
|
|
61
|
+
optional schema → structured_output capture
|
|
62
|
+
returns text or validated object (null on non-abort failure)
|
|
63
|
+
→ live snapshot streams through tool onUpdate / optional UI widget
|
|
64
|
+
→ final structured-cloneable result returned to parent as tool content + details
|
|
65
|
+
→ Esc/abort marks running agents skipped and aborts sessions
|
|
66
|
+
```
|
|
67
|
+
|
|
68
|
+
Important runtime details from source:
|
|
69
|
+
|
|
70
|
+
- Concurrency default: `hardwareConcurrency - 2`, clamped 1–16 (`src/workflow.ts`).
|
|
71
|
+
- Token budget is a rough estimate (`JSON.stringify(result).length / 4`), not provider usage.
|
|
72
|
+
- `model`, `isolation: "worktree"`, and `agentType` on `agent()` options are currently **prompt guidance only** (`buildAgentInstructions`); they are not enforced runtime pins.
|
|
73
|
+
- Subagents share the parent cwd and coding tools; they are not Herdr panes and not durable sessions.
|
|
74
|
+
- README status: prototype. No persisted/resumable runs and no `/workflows` manager yet.
|
|
75
|
+
|
|
76
|
+
### Extension points
|
|
77
|
+
|
|
78
|
+
1. **Script API** — `agent` / `parallel` / `pipeline` / `phase` / `log` / `args` / `budget`.
|
|
79
|
+
2. **Tool args** — optional JSON `args` injected as script global.
|
|
80
|
+
3. **Library API** — `createWorkflowTool`, `runWorkflow`, `WorkflowAgent`, display helpers exported from `src/index.ts` for programmatic use.
|
|
81
|
+
4. **Subagent construction** — `WorkflowAgent` accepts `tools`, `session` (model/auth/resourceLoader overrides), and base `instructions`.
|
|
82
|
+
5. **Display** — tool-update stream and optional widget display factories.
|
|
83
|
+
6. **Structured output** — JSON Schema on `agent()` for machine handoffs.
|
|
84
|
+
|
|
85
|
+
Not extension points today: durable state, role discovery, worktree isolation enforcement, model attestation, parent fire-and-forget delivery.
|
|
86
|
+
|
|
87
|
+
### Strengths for transfer
|
|
88
|
+
|
|
89
|
+
- **Code-mode orchestration**: parent designs graph as executable JS, not only prose.
|
|
90
|
+
- **Deterministic sandbox + literal meta**: keeps scripts auditable and parseable.
|
|
91
|
+
- **Fan-out primitives**: `parallel` (thunks, input order) and `pipeline` (per-item stages) are small and clear.
|
|
92
|
+
- **Live progress snapshot**: phase-grouped agent status without a full TUI framework.
|
|
93
|
+
- **Structured handoff via terminating tool**: avoids an extra prose final turn.
|
|
94
|
+
- **Prompt guidelines as product policy**: when to use workflows, unique labels, null-tolerant synthesis, final assertion agent.
|
|
95
|
+
|
|
96
|
+
### Limits / non-goals (as shipped)
|
|
97
|
+
|
|
98
|
+
- In-process, blocking parent tool call (not async pane orchestration).
|
|
99
|
+
- No crash-safe resume/journal.
|
|
100
|
+
- No enforced role/model/worktree isolation despite option fields.
|
|
101
|
+
- Failed branches soft-fail to `null` unless aborted.
|
|
102
|
+
- No parent-owned Git integration boundary.
|
|
103
|
+
|
|
104
|
+
## 2. sol-advisor
|
|
105
|
+
|
|
106
|
+
### What it is
|
|
107
|
+
|
|
108
|
+
A **Codex plugin / skill**, not a Pi extension. It is an architect-orchestration recipe: primary session stays on **GPT-5.6 Sol / High** and owns requirements, architecture, verification, and acceptance. Implementation is delegated on one of two explicit lanes.
|
|
109
|
+
|
|
110
|
+
Plugin layout (`plugins/sol-advisor/`):
|
|
111
|
+
|
|
112
|
+
| Path | Role |
|
|
113
|
+
| --- | --- |
|
|
114
|
+
| `.codex-plugin/plugin.json` | Plugin manifest v0.4.0; skill root; marketplace UI copy. |
|
|
115
|
+
| `skills/orchestration/SKILL.md` | Primary operating procedure. |
|
|
116
|
+
| `skills/orchestration/references/role-contracts.md` | Native spawn packets and five-part implementation contract. |
|
|
117
|
+
| `skills/orchestration/references/luna-task-lane.md` | Opt-in app-task lane contract. |
|
|
118
|
+
| `agents/sol-advisor-terra-implementer.toml` | Native implementer pin: `gpt-5.6-terra` / high. |
|
|
119
|
+
| `agents/sol-advisor-sol-reviewer.toml` | Native reviewer pin: `gpt-5.6-sol` / high, `sandbox_mode = "read-only"`. |
|
|
120
|
+
| `scripts/install-agents.sh` | Install/check companion TOMLs; exact-byte, non-overwrite, legacy migration. |
|
|
121
|
+
| `scripts/inspect-agent-runtime.sh` | Allowlisted local rollout inspector for omitted model/effort. |
|
|
122
|
+
| `scripts/verify.sh` | Disposable-dir verifier for contracts, installer, inspector fixtures. |
|
|
123
|
+
|
|
124
|
+
Marketplace entry: `.agents/plugins/marketplace.json` → local plugin path.
|
|
125
|
+
|
|
126
|
+
### Architecture (two lanes)
|
|
127
|
+
|
|
128
|
+
**Default native lane (Codex custom agents / subagent V2):**
|
|
129
|
+
|
|
130
|
+
1. Preflight companion files with `install-agents.sh --check` (Terra + Sol exact match; retired Luna TOML absent).
|
|
131
|
+
2. Confirm spawn tool exposes exact `agent_type`s: `sol_advisor_terra_implementer`, `sol_advisor_sol_reviewer`.
|
|
132
|
+
3. Primary writes a complete five-part implementation packet (objective, files/ownership, interfaces, constraints, verification + report schema).
|
|
133
|
+
4. Spawn Terra with `fork_turns: none`; no per-spawn model/effort overrides (TOML pins them).
|
|
134
|
+
5. Observe role/model/effort from public spawn metadata; local inspector only fills omitted fields; public+local must agree.
|
|
135
|
+
6. Primary inspects real diff and reruns verification.
|
|
136
|
+
7. Spawn **fresh** Sol reviewer (new context, `fork_turns: none`) for `ship | fix-first | rethink`.
|
|
137
|
+
8. Only `ship` allows completion; fix-first re-delegates then re-reviews; rethink revises architecture.
|
|
138
|
+
|
|
139
|
+
**Explicit opt-in Luna task lane (Codex app tasks, outside native subagent V2):**
|
|
140
|
+
|
|
141
|
+
1. Requires current-request authorization (“Use the Luna task lane…”). Skill install alone is not enough.
|
|
142
|
+
2. Tools: `list_projects` → `create_thread` (`gpt-5.6-luna`, thinking `max`) → discover real `threadId`/`hostId` if only `clientThreadId` returned → `wait_threads` / `read_thread` / `send_message_to_thread`.
|
|
143
|
+
3. Complete task packet includes starting state/base, git/PR boundary, structured return.
|
|
144
|
+
4. Git projects default to isolated worktree; isolation is not merge safety.
|
|
145
|
+
5. Primary owns corrections (same task), PR authorization (`PR AUTHORIZED FOR <threadId>`), dependent-stack ordering, and final acceptance.
|
|
146
|
+
6. No native Sol reviewer for this lane; primary Sol reviews the actual worktree/diff.
|
|
147
|
+
|
|
148
|
+
### Execution / data flow (native, condensed)
|
|
149
|
+
|
|
150
|
+
```text
|
|
151
|
+
user request
|
|
152
|
+
→ confirm primary is Sol/High
|
|
153
|
+
→ choose lane (native default | Luna only if explicit)
|
|
154
|
+
→ native preflight: exact role files + exposed agent_types
|
|
155
|
+
→ primary keeps architecture + writes complete packet
|
|
156
|
+
→ spawn Terra implementer (fresh thread)
|
|
157
|
+
→ observe routing evidence (public, then local inspector)
|
|
158
|
+
→ primary re-verifies diff/commands
|
|
159
|
+
→ spawn fresh Sol reviewer (read-only requested; observe actual sandbox)
|
|
160
|
+
→ verdict ship/fix-first/rethink gates reporting done
|
|
161
|
+
```
|
|
162
|
+
|
|
163
|
+
### Extension points
|
|
164
|
+
|
|
165
|
+
1. **Skill procedure** — SKILL.md + reference contracts are the product surface.
|
|
166
|
+
2. **Role pins** — user-owned TOML custom agents installed separately; plugin update never silently overwrites divergent local roles.
|
|
167
|
+
3. **Lane selection** — default native vs explicit Luna app-task path.
|
|
168
|
+
4. **Packet schemas** — five-part native implementation report; Luna structured return; review verdict schema.
|
|
169
|
+
5. **Runtime attestation helpers** — install check + allowlisted rollout inspector.
|
|
170
|
+
6. **Verifier script** — contract/stale-claim guards without mutating real Codex config.
|
|
171
|
+
|
|
172
|
+
### Strengths for transfer
|
|
173
|
+
|
|
174
|
+
- **Primary remains architect/acceptor**; workers do not own product decisions.
|
|
175
|
+
- **Fail-closed routing**: missing/stale/unobservable role/model/effort stops the lane; no silent fallback.
|
|
176
|
+
- **Role pins outside the skill text** (exact-byte companion files) so install and discovery are checkable.
|
|
177
|
+
- **Fresh-context final review** with explicit `ship | fix-first | rethink` and re-review after any fix.
|
|
178
|
+
- **Complete task packets** so children do not rely on inherited chat history.
|
|
179
|
+
- **Ownership + concurrency rules**: non-overlapping parallel; shared-file/dependent serial.
|
|
180
|
+
- **Worker report ≠ acceptance**: parent re-runs verification and inspects real diffs.
|
|
181
|
+
- **PR/push as primary-authorized boundary** (especially Luna lane).
|
|
182
|
+
- **Observed sandbox vs requested sandbox** honesty for reviewers.
|
|
183
|
+
- **Explicit opt-in for heavier/user-visible lanes** (Luna) vs default tighter native path.
|
|
184
|
+
|
|
185
|
+
### Limits / non-goals (as shipped)
|
|
186
|
+
|
|
187
|
+
- Codex-specific tools and models; not portable to Pi/Herdr without re-hosting.
|
|
188
|
+
- Policy is mostly prompt/skill text, not an executable graph runner.
|
|
189
|
+
- No durable multi-node scheduler; concurrency is human-procedure based.
|
|
190
|
+
- Sol-on-Sol review is context-clean, not cross-model-family independence (README states this).
|
|
191
|
+
|
|
192
|
+
## 3. Transfer map for pi-herdr-subagents
|
|
193
|
+
|
|
194
|
+
Local package already owns **agent execution** in Herdr (async `subagent`, panes, worktrees, completion steer, role discovery). ADR-0002 says workflows compose roles and should not become a second skill system or general engine. Draft local spec `agent-adrs/specs/0001-orchestrator-designed-workflows.md` already aims at approved `workflow.md` graphs with evidence receipts — closer to sol-advisor’s control plane than to pure code-mode scripts.
|
|
195
|
+
|
|
196
|
+
### High-value transfers
|
|
197
|
+
|
|
198
|
+
| Idea | From | Why it fits herdr-subagents |
|
|
199
|
+
| --- | --- | --- |
|
|
200
|
+
| Workflow as composition layer above roles | both; ADR-0002 already | Keep `subagent` as execution; add workflow registry/runner only when two surfaces share mechanics. |
|
|
201
|
+
| Explicit approval boundary before writers | sol-advisor packets; local draft `workflow.md` | Parent designs graph; user/parent approves before effectful nodes. |
|
|
202
|
+
| Complete task packets / structured handoff envelopes | sol-advisor; pi-dynamic structured_output | Child must not depend on parent chat history; return status, evidence, artifacts, runtime, worktree metadata. |
|
|
203
|
+
| Parent re-verification + fresh review verdict | sol-advisor | Map to existing `reviewer` / adversarial-review patterns; gate on `ship \| fix-first \| rethink`. |
|
|
204
|
+
| Fail-closed model/role policy | sol-advisor | Align with local routing: exact authenticated provider/model refs; no silent substitute. |
|
|
205
|
+
| Parallel writers only with distinct worktrees + non-overlapping ownership | sol-advisor Luna/native; herdr worktree docs | Already supported by `worktree: { branch, base }`; workflow runner should enforce it. |
|
|
206
|
+
| Integration/PR/cleanup reserved for parent | sol-advisor; herdr worktree research | Worker commits/reports; parent integrates. |
|
|
207
|
+
| Live progress snapshot | pi-dynamic-workflows display | Optional overlay on runner state; do not block on in-process tool completion. |
|
|
208
|
+
| Concurrency + budget hard limits | pi-dynamic limiter/budget; sol-advisor limits language | Encode as workflow document limits, not soft prose. |
|
|
209
|
+
|
|
210
|
+
### Borrow carefully / adapt, do not copy wholesale
|
|
211
|
+
|
|
212
|
+
| Idea | Risk if copied raw into herdr-subagents |
|
|
213
|
+
| --- | --- |
|
|
214
|
+
| Parent-written JS `vm` workflow scripts (pi-dynamic) | Powerful but fights current “approved workflow.md / no recursive child graphs” draft. Prefer declarative approved graph first; optional code-mode later. |
|
|
215
|
+
| Blocking in-memory subagent sessions (pi-dynamic) | Contradicts herdr’s non-blocking pane model and completion-steer delivery. Reuse `subagent` launch/watch instead of `SessionManager.inMemory`. |
|
|
216
|
+
| Soft-fail agents to `null` (pi-dynamic) | Hides failures; sol-advisor/local draft prefer explicit node failure and evidence gaps. |
|
|
217
|
+
| Exact Codex TOML role pins + rollout inspector | Concept (attestation) transfers; implementation must use Pi/Herdr session metadata and agent frontmatter/config, not Codex scripts. |
|
|
218
|
+
| Sol/Terra/Luna model family as product identity | Do not hardcode vendor lanes. Express as configurable role→runtime policy. |
|
|
219
|
+
| Skill-only orchestration (sol-advisor) | Good for procedure docs (`/plan`-style), weak for multi-node state, cancellation, and one final receipt. |
|
|
220
|
+
|
|
221
|
+
### Concrete recommended shape (synthesis)
|
|
222
|
+
|
|
223
|
+
1. **Keep execution in `subagent`** (roles, worktrees, model resolution, completion).
|
|
224
|
+
2. **Add workflow as parent-owned composition**: validated document or registry entry with nodes, deps, ownership, limits, verification/review policy — not another agent prompt pretending to be a product surface.
|
|
225
|
+
3. **From sol-advisor**: architect-in-parent, complete packets, fail-closed routing, fresh review verdict, PR/integration authorization, serial dependent stacks.
|
|
226
|
+
4. **From pi-dynamic-workflows**: phase-aware progress snapshot, optional structured terminating handoff, small fan-out helpers *inside the runner* (not necessarily user-authored JS), strict “when to use workflow” guidelines.
|
|
227
|
+
5. **Defer**: durable Temporal-like engine, child-authored recursive graphs, silent model fallback, auto-merge, full code-mode sandbox unless a second consumer needs the same mechanics (ADR-0002 phase 3).
|
|
228
|
+
|
|
229
|
+
### Non-transfers
|
|
230
|
+
|
|
231
|
+
- Replacing Herdr panes with in-memory Pi sessions.
|
|
232
|
+
- Baking GPT-5.6 Sol/Terra/Luna names into package defaults as identity.
|
|
233
|
+
- Growing `agents/` with more outcome-orchestration prompts (ADR-0002 explicitly rejects cloning `adversarial-reviewer` as the pattern).
|
|
234
|
+
- Auto-activating a heavy lane merely because a skill/package is installed (sol-advisor Luna rule is the cautionary example).
|
|
235
|
+
|
|
236
|
+
## 4. Side-by-side summary
|
|
237
|
+
|
|
238
|
+
> Historical research baseline table only. The `herdr-subagents` column records the pinned 2026-08-03 research baseline and is not current package status.
|
|
239
|
+
|
|
240
|
+
| Dimension | pi-dynamic-workflows | sol-advisor | herdr-subagents at research baseline |
|
|
241
|
+
| --- | --- | --- | --- |
|
|
242
|
+
| Host | Pi tool/extension | Codex plugin + skill + custom agents | Pi extension inside Herdr |
|
|
243
|
+
| Orchestration medium | Deterministic JS script in vm | Skill procedure + spawn/app tools | Parent prompts + `subagent` tool + a few commands (`/plan`, `/iterate`, `/btw`) |
|
|
244
|
+
| Child runtime | In-memory Pi session | Codex native thread or app task | Herdr pane/session (Pi or CLI adapter) |
|
|
245
|
+
| Isolation | Shared cwd; worktree option not enforced | Worktree default on Luna Git projects; ownership rules | Optional managed worktrees |
|
|
246
|
+
| Model policy | Guidance strings | Exact TOML pins + attestation | Invocation → agent → config → parent chain |
|
|
247
|
+
| Acceptance | Parent tool result JSON | Parent re-verify + fresh Sol verdict | Completion steer; no first-class workflow receipt |
|
|
248
|
+
| Durability | None | Thread/task identity in Codex | Session files + worktree metadata; no workflow graph state |
|
|
249
|
+
| Status | Prototype v1.0.1 | Plugin 0.4.0 with installer/verifier | Mature execution package; workflow feature was still at the taxonomy/spec stage |
|
|
250
|
+
|
|
251
|
+
## 5. Bottom line
|
|
252
|
+
|
|
253
|
+
- **pi-dynamic-workflows** is a compact **code-mode fan-out engine** for Pi: script → sandbox → many short in-memory agents → one tool result. Best borrowed pieces: progress snapshots, structured handoffs, and tight fan-out primitives — not its blocking in-memory runtime.
|
|
254
|
+
- **sol-advisor** is a **control-plane recipe** for architect/implement/review with fail-closed routing and evidence-based acceptance. Best borrowed pieces: complete packets, primary-owned verification, fresh review verdicts, explicit lane opt-in, and integration authorization.
|
|
255
|
+
- For **pi-herdr-subagents**, the high-leverage path is sol-advisor-style control + herdr execution + optional pi-dynamic presentation/helpers, matching the local draft “approved workflow document → runner → evidence receipt” direction rather than cloning either repo wholesale.
|
|
@@ -0,0 +1,317 @@
|
|
|
1
|
+
# Worktree-based subagent orchestration research
|
|
2
|
+
|
|
3
|
+
> This document records background evidence and design rationale. For supported package behavior and operating instructions, see [Worktree subagents](../worktree-subagents.md) and the [README](../../README.md).
|
|
4
|
+
|
|
5
|
+
**Date:** 2026-07-30
|
|
6
|
+
**Question:** How are coding-agent products and open-source orchestrators using Git worktrees or equivalent isolated checkouts to run parallel tickets, report completion, review results, publish PRs, and clean up?
|
|
7
|
+
|
|
8
|
+
## Executive summary
|
|
9
|
+
|
|
10
|
+
There is no single standard for “worktree agent orchestration.” The products also vary: some allow shared checkouts, and some delegate commit, push, or PR creation to workers. The evidence nevertheless supports these **synthesis recommendations** for this extension:
|
|
11
|
+
|
|
12
|
+
1. **Give each writing ticket run one isolated checkout.** A branch, process, pane, or model context alone is not filesystem isolation.
|
|
13
|
+
2. **Treat agent completion as a handoff, not integration.** Preserve a diff, commit, branch, worktree, transcript, or PR for review.
|
|
14
|
+
3. **Reserve shared and irreversible actions for the orchestrator by default.** Workers edit, test, and commit locally; the parent provisions worktrees, verifies results, pushes, creates or updates PRs, merges, and cleans up. Repositories may explicitly choose a worker-publishes-PR policy instead.
|
|
15
|
+
4. **Parallelize implementation and serialize integration.** Worktrees prevent concurrent file overwrites, but branches can still conflict when integrated.
|
|
16
|
+
5. **Make cleanup state-aware.** Dirty files, untracked files, unique commits, unpushed branches, active processes, and unknown ownership require preservation rather than automatic deletion.
|
|
17
|
+
6. **Track runtime, checkout, branch, transcript, and PR as separate lifecycle resources.** They may be retained or removed independently.
|
|
18
|
+
7. **Treat stacked PRs as a separate advanced workflow.** They require dependency metadata, descendant restacking, lease-safe force pushes, bottom-up merge order, and re-running review/CI gates.
|
|
19
|
+
|
|
20
|
+
The closest precedents for the proposed first version are:
|
|
21
|
+
|
|
22
|
+
- **Claude Code worktree-isolated subagents:** caller/worker completion plus conservative temporary-worktree cleanup.
|
|
23
|
+
- **OpenAI Codex and Cursor local worktrees:** one conversation/task per managed worktree followed by an explicit review/apply/PR decision.
|
|
24
|
+
- **Claude Squad and Shoal:** local control planes mapping task → worktree → terminal/agent session.
|
|
25
|
+
- **OpenWeft and Vigla:** parallel workers with serialized integration.
|
|
26
|
+
- **Gas Town:** the most complete durable worker-to-merge-queue model, useful as long-term inspiration rather than a suitable first implementation.
|
|
27
|
+
|
|
28
|
+
For `pi-herdr-subagents`, the research supports a managed single-call `subagent(... worktree ...)` spawn, typed completion metadata, parent-owned verification, and explicit retention/removal. PR automation, durable ticket DAGs, merge queues, and stacks should come later.
|
|
29
|
+
|
|
30
|
+
## Terminology
|
|
31
|
+
|
|
32
|
+
- **Worktree:** a linked Git checkout with its own working files, `HEAD`, and index while sharing repository objects and most refs. It is isolation from file overwrites, not a security sandbox. ([Git](https://git-scm.com/docs/git-worktree))
|
|
33
|
+
- **Ticket run:** one orchestration attempt for one ticket, including its base commit, branch, worktree, agent session, and result.
|
|
34
|
+
- **Worker completion:** the coding agent has stopped and reported a result. It does not imply that the result was accepted, pushed, reviewed, or merged.
|
|
35
|
+
- **Integration:** the shared operation that applies or publishes worker changes: local merge, push/PR, merge queue, or stack update.
|
|
36
|
+
- **Finalization:** an explicit decision to publish, retain, discard, or remove a completed ticket run.
|
|
37
|
+
|
|
38
|
+
## Product landscape
|
|
39
|
+
|
|
40
|
+
> Historical research baseline table only. Product rows below are pinned evidence from the research date, not current package status.
|
|
41
|
+
|
|
42
|
+
| Product | Concurrent unit | Isolation | Handoff and integration lesson |
|
|
43
|
+
| --- | --- | --- | --- |
|
|
44
|
+
| [OpenAI Codex](https://learn.chatgpt.com/docs/environments/git-worktrees) | Desktop/cloud chat | Desktop uses a managed Git worktree per chat; cloud uses a container checkout | Worktree execution is separate from **Handoff**, branch creation, commit, push, and PR. Managed cleanup retains recent worktrees and snapshots state before eviction. |
|
|
45
|
+
| [Claude Code](https://code.claude.com/docs/en/worktrees) | Session or subagent | Local sessions can use worktrees; custom subagents support `isolation: worktree`; cloud uses isolated VMs | Background child completion returns to the caller. Clean unchanged temporary worktrees can disappear, but changed/untracked/unpushed work is retained. ([Subagents](https://code.claude.com/docs/en/sub-agents)) |
|
|
46
|
+
| [Cursor](https://cursor.com/docs/configuration/worktrees) | Local task or best-of-N candidate | One local worktree per task/candidate; Cloud Agents use VMs and clones | The user reviews a result and separately applies it, commits/pushes it, or opens a PR. Worktree cleanup is capped by age/count. ([Agents Window](https://cursor.com/docs/agent/agents-window)) |
|
|
47
|
+
| [GitHub Copilot cloud agent](https://docs.github.com/en/copilot/concepts/agents/cloud-agent/about-cloud-agent) | Cloud task/session | Ephemeral Actions environment plus one task branch, not a local worktree | Branch/commit/push can be automated while PR creation may be deferred until the user reviews and iterates. Stopping runtime preserves pushed commits. ([Session management](https://docs.github.com/en/copilot/how-tos/copilot-on-github/use-copilot-agents/manage-and-track-agents)) |
|
|
48
|
+
| [Google Jules](https://jules.google/docs/environment/) | Task | Short-lived VM and cloned repository | Completion yields summary/diff and an explicit publish-branch or publish-PR action. Multiple tasks have independent VMs, logs, and changes. ([Tasks](https://jules.google/docs/tasks-repos/)) |
|
|
49
|
+
| [Devin](https://docs.devin.ai/work-with-devin/advanced-capabilities) | Managed child/session | Cloud children use isolated VMs; Desktop conversations use native worktrees | Devin provides a real coordinator/worker precedent: decomposition, bounded parallel children, progress, intervention, conflict handling, and synthesis. Desktop still leaves merge/winner choice to the user. ([Desktop worktrees](https://docs.devin.ai/desktop/cascade/worktrees)) |
|
|
50
|
+
|
|
51
|
+
### Product-level conclusions
|
|
52
|
+
|
|
53
|
+
- Coordination and isolation are orthogonal. Claude agent teams have shared tasks and messaging, but Anthropic still warns that teammates editing the same files can overwrite one another unless separate isolation is used. ([Claude agent teams](https://code.claude.com/docs/en/agent-teams))
|
|
54
|
+
- Products consistently stop at a reviewable artifact rather than treating child exit as merge approval.
|
|
55
|
+
- The control surface matters: Cursor’s Agents Window, GitHub’s agents panel, and Devin’s coordinator expose parallel state while preserving a distinct review/integration decision.
|
|
56
|
+
- Cloud VMs provide a stronger security/runtime boundary than worktrees. The proposed local feature should promise checkout isolation only.
|
|
57
|
+
|
|
58
|
+
## Open-source projects
|
|
59
|
+
|
|
60
|
+
### Closest local control-plane precedents
|
|
61
|
+
|
|
62
|
+
#### Claude Squad
|
|
63
|
+
|
|
64
|
+
[`smtg-ai/claude-squad`](https://github.com/smtg-ai/claude-squad) maps each operator-created task to one Git worktree and one tmux session. It persists branch ownership, base commit, status, and session metadata in JSON. Pause and delete are separate: pause can retain the branch for resume, while deletion removes only worktrees/branches that Claude Squad owns. Its “submit” path pushes and opens the branch URL but does not create or merge a PR. ([README](https://github.com/smtg-ai/claude-squad/blob/2dd388e9857233e07712c8c5b3e2bf3b471b39fa/README.md), [worktree lifecycle](https://github.com/smtg-ai/claude-squad/blob/2dd388e9857233e07712c8c5b3e2bf3b471b39fa/session/git/worktree_ops.go))
|
|
65
|
+
|
|
66
|
+
**Useful lesson:** explicitly record whether the orchestrator created the branch; never delete a pre-existing branch as incidental cleanup.
|
|
67
|
+
|
|
68
|
+
#### Shoal
|
|
69
|
+
|
|
70
|
+
[`TheShoal/shoal-cli`](https://github.com/TheShoal/shoal-cli) persists `task/session → branch → worktree → tmux runtime → status/journal` in SQLite. Provisioning rolls back partial resources. Finalization can either push/create a GitHub PR or merge locally, and conflicted work is preserved for manual repair. ([Architecture](https://github.com/TheShoal/shoal-cli/blob/3d45e0b9eb1bc981b612429c720827d71324e9dd/ARCHITECTURE.md), [lifecycle](https://github.com/TheShoal/shoal-cli/blob/3d45e0b9eb1bc981b612429c720827d71324e9dd/src/shoal/services/lifecycle.py))
|
|
71
|
+
|
|
72
|
+
**Useful lesson:** a vendor-neutral terminal control plane can provide value without embedding a sophisticated planner or merge engine.
|
|
73
|
+
|
|
74
|
+
#### Vibe Kanban
|
|
75
|
+
|
|
76
|
+
[`BloopAI/vibe-kanban`](https://github.com/BloopAI/vibe-kanban) creates a workspace branch and one worktree per selected repository, then launches external coding-agent processes inside it. It persists workspace/session/process/action/turn state and logs. PR publication and guarded local squash integration are separate paths. Worktree deletion and branch deletion are separately controlled. The project’s docs also make the key counterexample explicit: multiple sessions inside one workspace still share files and use last-writer-wins behavior. ([Worktree creation](https://github.com/BloopAI/vibe-kanban/blob/4deb7eca8f381f7cbc1f9d15515a9ab8f8009053/crates/workspace-manager/src/workspace_manager.rs), [shared-session warning](https://github.com/BloopAI/vibe-kanban/blob/4deb7eca8f381f7cbc1f9d15515a9ab8f8009053/docs/workspaces/multi-repo-sessions.mdx))
|
|
77
|
+
|
|
78
|
+
**Useful lesson:** isolation belongs to the ticket run, not merely to the conversation or process.
|
|
79
|
+
|
|
80
|
+
### Workflow orchestrators
|
|
81
|
+
|
|
82
|
+
#### OpenWeft
|
|
83
|
+
|
|
84
|
+
[`NeuraCerebra-AI/openweft`](https://github.com/NeuraCerebra-AI/openweft) divides work into overlap-safe phases, runs bounded workers in separate worktrees, checkpoints worktree/session identity before agent execution, and then priority-sorts and merges completed branches serially. Conflicts are resolved in the feature checkout through bounded worker retries. ([Scheduler](https://github.com/NeuraCerebra-AI/openweft/blob/30427ac8e8f592cf34f771517f12cb25d7fbc9f7/src/orchestrator/realRun.ts), [checkpoint](https://github.com/NeuraCerebra-AI/openweft/blob/30427ac8e8f592cf34f771517f12cb25d7fbc9f7/src/state/checkpoint.ts))
|
|
85
|
+
|
|
86
|
+
**Useful lesson:** parallel execution does not require parallel integration. Serialize only the shared critical section.
|
|
87
|
+
|
|
88
|
+
#### Vigla
|
|
89
|
+
|
|
90
|
+
[`Kilbex/Vigla`](https://github.com/Kilbex/Vigla) uses a mission-level supervisor branch/worktree plus one worktree per dependency-aware worker. Accepted workers integrate serially into the supervisor branch; only explicit final acceptance touches the user’s target branch. Git refs/tags provide recovery anchors in addition to persisted orchestration events. ([Mission workspace](https://github.com/Kilbex/Vigla/blob/bbd19ae2d5a77401502756c550b5dcd4ae59bbc9/crates/orchestrator/src/mission_workspace/mod.rs), [DAG dispatcher](https://github.com/Kilbex/Vigla/blob/bbd19ae2d5a77401502756c550b5dcd4ae59bbc9/crates/orchestrator/src/mission_supervisor_run/mission_loop.rs))
|
|
91
|
+
|
|
92
|
+
**Useful lesson:** if local multi-ticket integration is added later, a dedicated integration branch is safer than letting each worker mutate the user’s target.
|
|
93
|
+
|
|
94
|
+
#### Gas Town
|
|
95
|
+
|
|
96
|
+
[`gastownhall/gastown`](https://github.com/gastownhall/gastown) is the fullest verified example. It separates durable worker identity, reusable worktree, terminal runtime, assignment, and merge request. Worker completion pushes and verifies an exact submitted SHA before creating a durable merge-request record. A separate Refinery serializes target integration, runs gates, handles conflicts as tracked repair work, and can bisect failing batches. ([Architecture](https://github.com/gastownhall/gastown/blob/649b832b7672bc7a2dbef26f5983aba6198b819b/docs/design/architecture.md), [completion handoff](https://github.com/gastownhall/gastown/blob/649b832b7672bc7a2dbef26f5983aba6198b819b/internal/cmd/done.go), [merge engine](https://github.com/gastownhall/gastown/blob/649b832b7672bc7a2dbef26f5983aba6198b819b/internal/refinery/engineer.go))
|
|
97
|
+
|
|
98
|
+
**Useful lesson:** a mature autonomous integrator needs a durable ledger, exact SHA fencing, serialized gates, repair tasks, and crash recovery. This is a later architecture, not an appropriate v1 scope.
|
|
99
|
+
|
|
100
|
+
#### Baton
|
|
101
|
+
|
|
102
|
+
[`mraza007/baton`](https://github.com/mraza007/baton) is a bounded GitHub-issue queue: each issue maps to one branch/worktree and Claude process. The worker is prompted to commit, push, and create a PR; the controller recognizes the PR and releases the claim but does not merge. ([Dispatcher](https://github.com/mraza007/baton/blob/7bb5fb7/symphony/orchestrator.py), [workspace manager](https://github.com/mraza007/baton/blob/7bb5fb7/symphony/workspace.py))
|
|
103
|
+
|
|
104
|
+
**Useful lesson:** one external ticket can be the stable identity for one run, but delegating push/PR to workers trades implementation simplicity for weaker central control and recovery.
|
|
105
|
+
|
|
106
|
+
### Other useful implementations
|
|
107
|
+
|
|
108
|
+
- [Crystal](https://github.com/stravu/crystal) implemented one process/worktree per session, conflict preflight, rebase, and fast-forward integration, but is deprecated in favor of Nimbalyst. It is useful source material, not a dependency recommendation.
|
|
109
|
+
- Vibe Kanban’s current repository says the product is sunsetting. Its implementation remains useful evidence, but it should not become a new dependency.
|
|
110
|
+
- [Conductor](https://www.conductor.build/docs/concepts/git-worktrees) is a relevant commercial product benchmark, but its application source is not public.
|
|
111
|
+
- [`harms-haus/pi-worktrees`](https://github.com/harms-haus/pi-worktrees) provides Pi worktree commands but not parallel agent orchestration.
|
|
112
|
+
- [`aleclarson/agent-merge`](https://github.com/aleclarson/agent-merge) handles integration after agents/worktrees already exist; it intentionally has no session or job lifecycle.
|
|
113
|
+
|
|
114
|
+
## Standards and mature workflow patterns
|
|
115
|
+
|
|
116
|
+
### Git worktree invariants
|
|
117
|
+
|
|
118
|
+
The extension should rely on Git’s supported worktree interface rather than filesystem assumptions:
|
|
119
|
+
|
|
120
|
+
- `git worktree list --porcelain -z` provides scriptable path, branch/detached, lock, and prunable state. ([Git](https://git-scm.com/docs/git-worktree#_porcelain_format))
|
|
121
|
+
- Git normally refuses to check out one branch in multiple worktrees. `--force` bypasses occupancy and stale-path safeguards and should not be a normal recovery strategy. ([Git](https://git-scm.com/docs/git-worktree#Documentation/git-worktree.txt---force))
|
|
122
|
+
- A worktree lock prevents pruning, movement, and ordinary deletion and can store a reason. ([Git](https://git-scm.com/docs/git-worktree#Documentation/git-worktree.txt-lock))
|
|
123
|
+
- Normal removal accepts only clean linked worktrees. Forced removal can discard dirty and untracked state. ([Git](https://git-scm.com/docs/git-worktree#Documentation/git-worktree.txt-remove))
|
|
124
|
+
- Worktrees share most refs and repository configuration. They isolate checkout/index state, not every Git mutation. ([Git refs](https://git-scm.com/docs/git-worktree#_refs))
|
|
125
|
+
- `git worktree repair` and `prune` have distinct recovery purposes; orchestrators should never edit `.git/worktrees/*` directly. ([Git details](https://git-scm.com/docs/git-worktree#_details))
|
|
126
|
+
|
|
127
|
+
### Scheduling
|
|
128
|
+
|
|
129
|
+
Python’s `TopologicalSorter` is a useful standard-library model for future ticket DAGs: validate cycles before side effects, dispatch only `get_ready()` nodes, and release descendants only after explicit `done()` acknowledgement. ([Python](https://docs.python.org/3/library/graphlib.html#graphlib.TopologicalSorter))
|
|
130
|
+
|
|
131
|
+
GitHub Actions provides a mature failure-propagation analogy: failed/skipped prerequisites prevent dependent jobs unless an explicit always-run path is defined. Cleanup/reconciliation should be such an always-run path, while dependent implementation should fail closed. ([GitHub Actions `needs`](https://docs.github.com/en/actions/reference/workflows-and-actions/workflow-syntax#jobsjob_idneeds))
|
|
132
|
+
|
|
133
|
+
### Reconciliation and crash recovery
|
|
134
|
+
|
|
135
|
+
Kubernetes controllers provide the relevant architectural pattern for a later durable orchestrator: persist desired state, observe actual Git/runtime/GitHub state, and apply only missing transitions. ([Kubernetes controller pattern](https://kubernetes.io/docs/concepts/architecture/controller/#controller-pattern))
|
|
136
|
+
|
|
137
|
+
This matters around ambiguous side effects:
|
|
138
|
+
|
|
139
|
+
- after worktree creation, adopt only an exact path/ref/base/ownership match;
|
|
140
|
+
- after push timeout, fetch the exact remote ref before retrying;
|
|
141
|
+
- after PR-create timeout, query by full head/base before creating again;
|
|
142
|
+
- after merge timeout, query the PR’s merged state before retrying;
|
|
143
|
+
- after cleanup failure, keep a visible `cleanup_pending` state.
|
|
144
|
+
|
|
145
|
+
### GitHub publication and gates
|
|
146
|
+
|
|
147
|
+
GitHub treats PR head/base, draft status, required reviews, checks, merge queues, merged state, and branch deletion as distinct facts. Rulesets may layer with branch protection, so GitHub—not a local reimplementation—is authoritative for mergeability. ([Protected branches](https://docs.github.com/en/repositories/configuring-branches-and-merges-in-your-repository/managing-protected-branches/about-protected-branches), [Rulesets](https://docs.github.com/en/repositories/configuring-branches-and-merges-in-your-repository/managing-rulesets/about-rulesets))
|
|
148
|
+
|
|
149
|
+
If rewritten branches are ever supported, use exact `--force-with-lease=<ref>:<expected-sha>` rather than plain force. ([Git push](https://git-scm.com/docs/git-push#Documentation/git-push.txt---force-with-leaseltrefnamegtltexpectgt))
|
|
150
|
+
|
|
151
|
+
## Stacked PRs
|
|
152
|
+
|
|
153
|
+
Graphite is the clearest mature reference. It stores parent relationships that vanilla Git does not, recursively restacks descendants after parent changes, and recommends bottom-up merging followed by sync/restack/submit of the remaining stack. ([Restacking](https://graphite.com/docs/restack-branches), [Manual stack merge](https://graphite.com/docs/merge-stack-prs-github))
|
|
154
|
+
|
|
155
|
+
Its worktree guidance is especially relevant: Graphite generally avoids modifying a branch checked out in another worktree, so a stack spread across worktrees requires deliberate operations in each checkout. ([Graphite worktrees](https://graphite.com/docs/multiple-worktrees))
|
|
156
|
+
|
|
157
|
+
A stack therefore adds:
|
|
158
|
+
|
|
159
|
+
- parent/child branch metadata beyond Git;
|
|
160
|
+
- a serialization lock for rewrites;
|
|
161
|
+
- descendant `stale_base` states;
|
|
162
|
+
- lease-safe force pushes;
|
|
163
|
+
- bottom-up merge order;
|
|
164
|
+
- re-evaluation of checks, reviews, CODEOWNERS, and conflicts after rewrites;
|
|
165
|
+
- compatibility decisions for GitHub merge queues and stale-review policies.
|
|
166
|
+
|
|
167
|
+
**Recommendation:** default to independent PRs based on trunk. Allow hard-dependent work only after its predecessor merges. Add native or Graphite-backed stacks later as an explicit repository capability, not as part of worktree spawning.
|
|
168
|
+
|
|
169
|
+
## Implications for `pi-herdr-subagents`
|
|
170
|
+
|
|
171
|
+
The extension already has several pieces that comparable tools need:
|
|
172
|
+
|
|
173
|
+
- asynchronous launch and parent wake-up;
|
|
174
|
+
- stable child session files and resume flow;
|
|
175
|
+
- Herdr pane status and interruption;
|
|
176
|
+
- a parent widget for concurrent work;
|
|
177
|
+
- bounded completion delivery;
|
|
178
|
+
- an internal launch path that can accept a pre-created Herdr surface;
|
|
179
|
+
- `cwd`-aware child execution.
|
|
180
|
+
|
|
181
|
+
The missing seam is **ticket-run placement and handoff metadata**, not a new general orchestration framework.
|
|
182
|
+
|
|
183
|
+
### Recommended first version
|
|
184
|
+
|
|
185
|
+
Expose one atomic operation through the existing `subagent` interface:
|
|
186
|
+
|
|
187
|
+
```ts
|
|
188
|
+
subagent({
|
|
189
|
+
name: "Ticket 123",
|
|
190
|
+
agent: "worker",
|
|
191
|
+
task: "...",
|
|
192
|
+
worktree: {
|
|
193
|
+
branch: "ticket/123",
|
|
194
|
+
base: "main"
|
|
195
|
+
}
|
|
196
|
+
})
|
|
197
|
+
```
|
|
198
|
+
|
|
199
|
+
Internally:
|
|
200
|
+
|
|
201
|
+
1. Resolve the source repository and exact base SHA.
|
|
202
|
+
2. Before creating resources, persist a small ownership manifest with run ID, source repository, intended branch/base SHA, and label. This need not be a database or full controller.
|
|
203
|
+
3. Use `herdr worktree create --cwd ... --branch ... --base ... --label ... --no-focus`.
|
|
204
|
+
4. Parse the returned Herdr workspace, root pane, worktree path, and branch. Retain the already-resolved base SHA from the manifest because the create response does not include it.
|
|
205
|
+
5. Update the manifest with observed resource identities, then launch the child in the returned root pane and worktree cwd.
|
|
206
|
+
6. Record the same worktree metadata on the running subagent for live status and delivery.
|
|
207
|
+
7. On completion, verify and return machine-readable Git state alongside the prose summary.
|
|
208
|
+
8. Leave changed work available for parent review; do not automatically remove the worktree.
|
|
209
|
+
|
|
210
|
+
Suggested completion metadata:
|
|
211
|
+
|
|
212
|
+
```text
|
|
213
|
+
run ID
|
|
214
|
+
worktree path and Herdr workspace ID
|
|
215
|
+
branch and resolved base SHA
|
|
216
|
+
HEAD/commit SHA and commits ahead
|
|
217
|
+
changed files
|
|
218
|
+
clean/dirty/untracked/conflicted state
|
|
219
|
+
checks reported by the worker
|
|
220
|
+
session path and resume reference
|
|
221
|
+
```
|
|
222
|
+
|
|
223
|
+
Suggested first-version states:
|
|
224
|
+
|
|
225
|
+
```text
|
|
226
|
+
provisioning -> running -> ready_for_review
|
|
227
|
+
-> failed
|
|
228
|
+
ready_for_review -> revising
|
|
229
|
+
-> retained
|
|
230
|
+
-> discarded
|
|
231
|
+
-> finalized
|
|
232
|
+
```
|
|
233
|
+
|
|
234
|
+
Keep these ticket-run states separate from the existing process/turn/delivery lifecycle.
|
|
235
|
+
|
|
236
|
+
### Ownership policy
|
|
237
|
+
|
|
238
|
+
| Action | Worker | Parent/orchestrator |
|
|
239
|
+
| --- | ---: | ---: |
|
|
240
|
+
| Edit, test, make focused commits | Yes | Verify |
|
|
241
|
+
| Create/open/remove worktree | No | Yes |
|
|
242
|
+
| Select branch and base | No | Yes |
|
|
243
|
+
| Push branch | No by default | Explicit action |
|
|
244
|
+
| Create/update PR | No by default | Explicit action |
|
|
245
|
+
| Merge or enqueue | No | Explicit action |
|
|
246
|
+
| Decide retain/discard/cleanup | No | Yes |
|
|
247
|
+
|
|
248
|
+
### Conservative cleanup policy
|
|
249
|
+
|
|
250
|
+
Automatic removal is safe only when all of the following are proven:
|
|
251
|
+
|
|
252
|
+
- the extension created and still owns the worktree;
|
|
253
|
+
- no child process is active;
|
|
254
|
+
- the checkout is clean and not mid-merge/rebase;
|
|
255
|
+
- no untracked files exist;
|
|
256
|
+
- no unique/unpushed commits would be lost;
|
|
257
|
+
- the branch retention decision is explicit.
|
|
258
|
+
|
|
259
|
+
Otherwise, report the blocker and keep the worktree. Pane/process cleanup, worktree cleanup, branch cleanup, transcript retention, and PR retention must remain independent actions.
|
|
260
|
+
|
|
261
|
+
### Explicitly defer
|
|
262
|
+
|
|
263
|
+
Do not include these in the first version:
|
|
264
|
+
|
|
265
|
+
- autonomous push/PR/merge;
|
|
266
|
+
- stacked PR orchestration;
|
|
267
|
+
- ticket dependency DAGs;
|
|
268
|
+
- a full durable database or controller loop beyond the minimal ownership manifest;
|
|
269
|
+
- pooled/reused worktrees;
|
|
270
|
+
- automatic conflict-resolution agents;
|
|
271
|
+
- merge queues;
|
|
272
|
+
- best-of-N candidates;
|
|
273
|
+
- multi-repository ticket workspaces.
|
|
274
|
+
|
|
275
|
+
Add each only after the atomic isolated ticket run and review/resume/cleanup path is reliable.
|
|
276
|
+
|
|
277
|
+
## Recommended implementation sequence
|
|
278
|
+
|
|
279
|
+
1. **Managed worktree spawn:** one worker, one Herdr-managed worktree, one ownership manifest, one completion handoff.
|
|
280
|
+
2. **Review and resume:** parent can inspect and resume the same child/worktree without losing state.
|
|
281
|
+
3. **Explicit finalization:** retain or safely remove; publication can initially use normal `git`/`gh` commands.
|
|
282
|
+
4. **Run reconciliation:** recover and reconcile extension-owned worktrees after Pi/Herdr restart.
|
|
283
|
+
5. **Bounded ticket fleet:** queue and concurrency cap for independent tickets.
|
|
284
|
+
6. **PR adapter:** parent-owned push/create/update with exact branch/SHA metadata.
|
|
285
|
+
7. **Dependency scheduling:** explicit DAG and blocked-upstream behavior.
|
|
286
|
+
8. **Advanced integration:** supervisor branch, merge queue, or opt-in stacked PR adapter.
|
|
287
|
+
|
|
288
|
+
## Primary sources
|
|
289
|
+
|
|
290
|
+
### Standards and workflow primitives
|
|
291
|
+
|
|
292
|
+
- Git worktrees: <https://git-scm.com/docs/git-worktree>
|
|
293
|
+
- Git push leases: <https://git-scm.com/docs/git-push#Documentation/git-push.txt---force-with-leaseltrefnamegtltexpectgt>
|
|
294
|
+
- Python `TopologicalSorter`: <https://docs.python.org/3/library/graphlib.html#graphlib.TopologicalSorter>
|
|
295
|
+
- GitHub protected branches: <https://docs.github.com/en/repositories/configuring-branches-and-merges-in-your-repository/managing-protected-branches/about-protected-branches>
|
|
296
|
+
- GitHub rulesets: <https://docs.github.com/en/repositories/configuring-branches-and-merges-in-your-repository/managing-rulesets/about-rulesets>
|
|
297
|
+
- GitHub merge queues: <https://docs.github.com/en/repositories/configuring-branches-and-merges-in-your-repository/configuring-pull-request-merges/managing-a-merge-queue>
|
|
298
|
+
- Kubernetes controller pattern: <https://kubernetes.io/docs/concepts/architecture/controller/#controller-pattern>
|
|
299
|
+
- Graphite worktrees: <https://graphite.com/docs/multiple-worktrees>
|
|
300
|
+
- Graphite restacking: <https://graphite.com/docs/restack-branches>
|
|
301
|
+
|
|
302
|
+
### Products and projects
|
|
303
|
+
|
|
304
|
+
- OpenAI Codex worktrees: <https://learn.chatgpt.com/docs/environments/git-worktrees>
|
|
305
|
+
- Claude Code worktrees: <https://code.claude.com/docs/en/worktrees>
|
|
306
|
+
- Claude Code subagents: <https://code.claude.com/docs/en/sub-agents>
|
|
307
|
+
- Cursor worktrees: <https://cursor.com/docs/configuration/worktrees>
|
|
308
|
+
- GitHub Copilot cloud agent: <https://docs.github.com/en/copilot/concepts/agents/cloud-agent/about-cloud-agent>
|
|
309
|
+
- Google Jules environment: <https://jules.google/docs/environment/>
|
|
310
|
+
- Devin managed children: <https://docs.devin.ai/work-with-devin/advanced-capabilities>
|
|
311
|
+
- Claude Squad: <https://github.com/smtg-ai/claude-squad>
|
|
312
|
+
- Shoal: <https://github.com/TheShoal/shoal-cli>
|
|
313
|
+
- Vibe Kanban: <https://github.com/BloopAI/vibe-kanban>
|
|
314
|
+
- OpenWeft: <https://github.com/NeuraCerebra-AI/openweft>
|
|
315
|
+
- Vigla: <https://github.com/Kilbex/Vigla>
|
|
316
|
+
- Gas Town: <https://github.com/gastownhall/gastown>
|
|
317
|
+
- Baton: <https://github.com/mraza007/baton>
|