pi-herdsman 0.22.0 → 0.22.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,6 +1,6 @@
1
1
  # Use Herdr worktree removal for project retirement
2
2
 
3
- > **Superseded in part by [ADR 0017](0017-use-project-assignments-for-managed-lead-authority.md):** explicit user `/takeover` is an additional assignment-release path. This ADR continues to define successful Herdr worktree removal as a separate retirement event.
3
+ > **Historical decision; superseded in part.** [ADR 0017](0017-use-project-assignments-for-managed-lead-authority.md) adds confirmed `/takeover` as a separate assignment-release path. [ADR 0019](0019-retire-project-assignments-when-worktrees-are-absent.md) supersedes the event-only retirement rule and the decision to recover assignments after verified worktree absence; the current runtime implements both retirement authorities.
4
4
 
5
5
  ## Decision
6
6
 
@@ -11,8 +11,11 @@ reserved name is excluded from the Agent roster and cannot be delegated to or
11
11
  referenced through an Agent `agents` allowlist.
12
12
 
13
13
  The definition owns configurable launch behavior such as prompt body, model,
14
- thinking, ordinary tools, skills, extensions, and context inheritance. Herdsman
15
- still owns and enforces project identity, supervision, durable Agent ownership,
14
+ thinking, ordinary tools, skills, extensions, and context inheritance. The
15
+ bundled default selects no ordinary tools (`tools: []`); mandatory Lead
16
+ coordination tools are injected at launch, and overlays can enable direct
17
+ tools explicitly. Herdsman still owns and enforces project identity,
18
+ supervision, durable Agent ownership,
16
19
  mandatory Lead coordination tools, handoff behavior, and project/worktree
17
20
  lifecycle.
18
21
 
@@ -1,5 +1,7 @@
1
1
  # Use project assignments for managed-Lead authority
2
2
 
3
+ > **Lifecycle update:** [ADR 0019](0019-retire-project-assignments-when-worktrees-are-absent.md) adds authoritative missing-checkout reconciliation as an assignment-retirement condition. The exact-assignment authority rule and confirmed `/takeover` remain unchanged; the current runtime implements the update.
4
+
3
5
  ## Status
4
6
 
5
7
  Accepted
@@ -10,8 +10,8 @@ Ordinary Lead execution has two modes: `Flexible` and `Orchestrate`. Each maps
10
10
  one-to-one to a standalone reserved definition: `flexible-lead` and
11
11
  `orchestrator-lead`. The definitions do not compose or inherit from one
12
12
  another. Flexible's bundled definition leaves ordinary tools unspecified so
13
- Pi's normal selection remains the baseline; Orchestrate provides
14
- orchestration-first instructions and a conservative ordinary-tool policy.
13
+ Pi's normal selection remains the baseline; Orchestrate uses `tools: []` to
14
+ leave only mandatory coordination tools available by default.
15
15
 
16
16
  Manager-assigned Leads use only the standalone `managed-lead` launch
17
17
  definition. Ordinary execution preference is session state separate from
@@ -49,6 +49,8 @@ Manager authority.
49
49
 
50
50
  ## Consequences
51
51
 
52
+ - Bundled Orchestrate and managed Leads have no ordinary tools by default;
53
+ project/global definition overlays may explicitly enable them.
52
54
  - Runtime profiles may change execution instructions and ordinary active-tool
53
55
  selection, but not launch-time model, thinking, extensions, skills, or
54
56
  context inheritance.
@@ -0,0 +1,88 @@
1
+ # Retire project assignments when worktrees are absent
2
+
3
+ [Documentation index](../README.md)
4
+
5
+ ## Status
6
+
7
+ Accepted on 2026-10-09 and implemented. Matching Herdr removal events and
8
+ verified Git worktree inventory now retire exact assignments when their
9
+ checkout is removed; incomplete or ambiguous evidence preserves them.
10
+
11
+ ## Context
12
+
13
+ A `ProjectAssignment` is a durable Manager-to-Lead authority edge, but it is
14
+ not a long-term backlog or record of finished project work. On 2026-10-09,
15
+ four assignments remained `paused` after the user removed their worktrees
16
+ using Herdr's Remove Worktree action. The exact failure boundary was not
17
+ established.
18
+
19
+ [ADR 0013](0013-use-herdr-worktree-removal-for-project-retirement.md) relies
20
+ on observing a successful Herdr removal event and intentionally preserves
21
+ assignments when a checkout is otherwise missing, allowing
22
+ `resume_project` to recreate it. Herdr events are not durable, so a missed
23
+ notification can leave an assignment indefinitely, even after the checkout
24
+ has been deleted. That recovery policy does not match the intended meaning
25
+ of project assignments as _currently managed work_.
26
+
27
+ ## Decision
28
+
29
+ A project assignment remains managed only while its associated Git worktree
30
+ exists. A stopped Lead, closed Herdr workspace, or replaced Manager does
31
+ not end the assignment while the checkout still exists. Lead settlement,
32
+ review, and ordinary conversation are also nonterminal.
33
+
34
+ Retire the matching assignment and its still-pending project messages when
35
+ either of these is authoritative:
36
+
37
+ - Herdr reports successful removal of the matching linked worktree.
38
+ - Complete, trustworthy repository/worktree evidence establishes that the
39
+ assignment's checkout no longer exists, even if a removal event was missed
40
+ or the checkout was removed outside Herdr.
41
+
42
+ A missing _open workspace_ is not a missing _worktree_. A failed or partial
43
+ inventory, disconnected Herdr instance, ambiguous repository or branch
44
+ identity, or out-of-scope machine is not proof of deletion. In-flight
45
+ worktree creation or restoration must not be mistaken for an abandoned
46
+ checkout. Until absence is verified, preserve the assignment and fail
47
+ closed rather than deleting it speculatively.
48
+
49
+ Retirement must target the exact current assignment; concurrent replacement
50
+ assignments and unrelated projects remain protected. It ends Manager
51
+ authority for that assignment without deleting its Git branch, Pi session,
52
+ conversation, or unrelated work. It does not imply that the task was
53
+ completed, accepted, merged, or discarded.
54
+
55
+ After authoritative checkout absence retires an assignment,
56
+ `resume_project` cannot reconstruct that _retired assignment_. A later
57
+ delegation can start new managed work from the remaining Git branch. The
58
+ branch and historical conversation are not erased.
59
+
60
+ ## Rationale
61
+
62
+ Checkout existence expresses whether the user is still maintaining that
63
+ branch as a managed working area. Treating the assignment as current work,
64
+ rather than a durable project archive, makes the Manager overview useful
65
+ and repairs orphaned assignments after missed lifecycle notifications,
66
+ restarts, and manual checkout removal.
67
+
68
+ This deliberately gives up automatic recovery of an old assignment after
69
+ confirmed checkout deletion. Retaining Git history and Pi conversations
70
+ preserves useful work without retaining obsolete Manager authority.
71
+
72
+ ## Alternatives and boundaries
73
+
74
+ - **Require an observed Herdr removal event:** insufficient because events
75
+ can be lost and external checkout removal has no Herdsman notification.
76
+ - **Retire on workspace closure or observation failure:** unsafe because the
77
+ checkout may still exist or evidence may be temporarily unavailable.
78
+ - **Require manual orphan cleanup:** useful as a separate user-control
79
+ capability if needed, but not a substitute for correct automatic lifecycle
80
+ reconciliation.
81
+
82
+ This supersedes ADR 0013's event-only retirement and missing-checkout
83
+ recovery decisions, and extends the retirement boundary in
84
+ [ADR 0017](0017-use-project-assignments-for-managed-lead-authority.md).
85
+ ADR 0017's exact-session authority checks and confirmed `/takeover` path
86
+ remain unchanged. The existing user-facing guides and runtime contracts
87
+ must be updated alongside the implementation; this ADR alone does not
88
+ change shipped behavior.
@@ -123,9 +123,9 @@ should go through the automatic result; timely questions, clarifications, or
123
123
  warnings may use nonblocking `message_supervisor`. This is ordinary
124
124
  coordination, not assignment state; there is no deduplication between a
125
125
  message and a later result.
126
- Project assignments end only on explicit events, not settlement or review:
127
- successful Herdr worktree removal or user-confirmed `/takeover` by the assigned
128
- Lead. Takeover removes the assignment and pending project messages while
126
+ Project assignments end on successful Herdr worktree removal, verified Git
127
+ checkout absence, or user-confirmed `/takeover` by the assigned Lead—not on
128
+ settlement or review. Takeover removes the assignment and pending project messages while
129
129
  preserving the session, conversation, branch, worktree,
130
130
  running process, and Lead-owned Agents; it does not imply completion or
131
131
  acceptance. See
@@ -133,14 +133,18 @@ acceptance. See
133
133
 
134
134
  `stop_lead` pauses assigned execution while preserving the assignment, Pi
135
135
  session, branch, and worktree; `resume_project` resumes the existing
136
- assignment. These operations do not change project authority. Successful
137
- Herdr worktree removal retires the matching assignment and any still-pending
138
- project messages while preserving the Git branch. Explicit `/takeover` by the
136
+ assignment while its checkout exists. These operations do not change project
137
+ authority. Successful Herdr worktree removal or verified checkout absence
138
+ retires the matching assignment and any still-pending project messages while
139
+ preserving the Git branch. Explicit `/takeover` by the
139
140
  assigned Lead is a separate assignment-release path. Manually continuing the
140
141
  exact assigned Pi session remains managed; `managed-lead` is launch policy,
141
142
  not authority.
142
- A worktree that is merely missing does not retire the assignment; it remains
143
- recoverable through `resume_project`.
143
+ A complete Git worktree inventory that verifies the checkout is absent retires
144
+ the exact assignment and pending project messages, even when a Herdr removal
145
+ event was missed. Failed or ambiguous inventory preserves the assignment.
146
+ `resume_project` cannot restore a retired assignment; a new delegation may
147
+ reuse the remaining Git branch.
144
148
 
145
149
  For the task-oriented workflow, see
146
150
  [Project orchestration](../guides/project-orchestration.md). Exact operations
@@ -68,9 +68,10 @@ Successful Herdr worktree removal retires the matching project assignment and
68
68
  any still-pending project messages. The assigned Lead can also explicitly
69
69
  release Manager control with confirmed `/takeover`, which removes the
70
70
  assignment and pending project messages while preserving its session, branch,
71
- worktree, process, and owned Agents. A missing worktree alone does not retire
72
- an assignment; `resume_project` can reconstruct the checkout when its branch
73
- remains available.
71
+ worktree, process, and owned Agents. Verified Git worktree inventory showing
72
+ the checkout absent also retires the assignment. Failed or ambiguous inventory
73
+ preserves it. A retired assignment cannot be resumed, but new work may reuse
74
+ its remaining branch.
74
75
 
75
76
  An assigned project Lead uses `message_supervisor` for timely Manager
76
77
  coordination; an ordinary Lead and a Manager use it to contact Chief. An
@@ -96,6 +96,13 @@ Optional participation may be absent; participating behavior that cannot be
96
96
  initialized correctly should fail explicitly rather than continue in a
97
97
  partially valid state.
98
98
 
99
+ Treat performance and efficiency as design goals across runtime, model-facing
100
+ interactions, and development workflows. As workloads and Agent counts grow,
101
+ avoid unnecessary latency, token use, computation, I/O, and resource
102
+ consumption. Prefer eliminating work over adding caches or infrastructure,
103
+ and justify optimization complexity with evidence. Never trade correctness,
104
+ reliability, security, or recovery for speed.
105
+
99
106
  ## Decision test
100
107
 
101
108
  For any proposed feature, ask:
@@ -56,9 +56,10 @@ managed descendants do not load the probe.
56
56
  The available scenarios are `core` (nested delegation and candidate-extension
57
57
  propagation), `continuation` (persisted Pi-session continuation across managed
58
58
  generations), `chief-tree` (current Chief/session_tree behavior), and
59
- `manager-recovery` (Manager delegation, review messaging, `stop_lead`, missing
60
- worktree reconstruction with exact Pi-session continuity, retained project
61
- messages across Manager turnover, and Herdr-driven project retirement).
59
+ `manager-recovery` (Manager delegation, review messaging, `stop_lead`, verified
60
+ pause/resume with an intact checkout, Manager turnover with a pending project
61
+ message, verified missing-worktree retirement without recreating the assignment,
62
+ and refusal to resume retired work).
62
63
  `chief-tree` records ordinary Lead, Chief, and post-`session_tree` tool
63
64
  snapshots and verifies Chief differs from Lead while selecting a pre-Chief
64
65
  branch restores ordinary Lead tools. It does not
@@ -366,11 +367,11 @@ After every smoke:
366
367
  ## Project Manager / Chief supervision live matrix
367
368
 
368
369
  `manager-recovery` is the canonical automated live Manager lifecycle check. It
369
- covers fresh delegation, project review messaging, pause/resume, missing
370
- worktree recovery without an explicit Herdr removal event, exact Pi-session
371
- continuity, pending project messages across Manager absence and delivery,
372
- retirement after
373
- successful Herdr worktree removal, and exact cleanup.
370
+ covers fresh delegation, project review messaging, pause/resume, Manager
371
+ turnover while a project message is pending and its later delivery, missing
372
+ worktree retirement without an explicit Herdr removal event, refusal to resume
373
+ the retired assignment, exact Pi-session continuity before retirement, and
374
+ exact cleanup.
374
375
 
375
376
  The broader matrix below remains optional exploratory acceptance for supervision
376
377
  behavior not covered by the automated scenarios. A NOT RUN entry is not a claim
@@ -23,9 +23,9 @@ inheritance, or Agent/permission policy are not supported.
23
23
 
24
24
  The bundled `flexible-lead` leaves `tools` unspecified, preserving Pi's normal
25
25
  ordinary tool baseline, and supplies flexible direct/delegated-work guidance.
26
- The bundled `orchestrator-lead` selects `read`, `ls`, `find`, and `grep` and
27
- guides the Lead to delegate bounded execution whenever an Agent can reasonably
28
- own it. Example user overlay:
26
+ The bundled `orchestrator-lead` sets `tools: []`, leaving only mandatory
27
+ Herdsman coordination tools available. Inspection and execution are delegated
28
+ to Agents by default. Example user overlay to opt into direct tools:
29
29
 
30
30
  ```markdown
31
31
  ---
@@ -38,8 +38,11 @@ Use the repository's documented smoke command when validating integration work.
38
38
  ```
39
39
 
40
40
  An explicit tool list selects registered ordinary tools; exclusions are then
41
- applied. Herdsman-owned tools cannot be enabled through a profile, and required
42
- Lead coordination tools are retained. A configured tool that is not registered
41
+ applied. At the effective-definition level, `tools: []` disables ordinary
42
+ tools, whereas an absent `tools` field preserves Pi's normal selection.
43
+ Overlays that omit `tools` still inherit the bundled `[]`. Herdsman-owned
44
+ tools cannot be enabled through a profile, and required Lead coordination
45
+ tools are retained. A configured tool that is not registered
43
46
  is simply unavailable. Profile resolution respects project trust. Definition
44
47
  changes take effect when the profile is next resolved: at session start/resume,
45
48
  or when a user explicitly selects an execution mode with `/lead` (including
@@ -61,10 +64,11 @@ and cannot be delegated to. It appears first in the flat Definitions list, with
61
64
  Model, Thinking, and Details settings but no `Enabled` action. These settings
62
65
  do not add it to Agent discovery or delegation.
63
66
 
64
- The bundled default is orchestration-focused: it gives the Lead read-only
65
- inspection tools plus mandatory Herdsman coordination tools. Executable project work is delegated to managed
66
- Agents by default. Manager owns project supervision and assignment
67
- boundaries; the Lead owns technical decisions and execution orchestration.
67
+ The bundled default is coordination-only (`tools: []`): mandatory Herdsman
68
+ coordination tools remain available, while ordinary inspection and execution
69
+ are delegated to managed Agents. Manager owns project supervision and
70
+ assignment boundaries; the Lead owns technical decisions and execution
71
+ orchestration.
68
72
  Herdsman automatically hands off the normal assignment response, deferring it
69
73
  until delegated Agent work settles. See [Project orchestration](project-orchestration.md)
70
74
  for the automatic result and `message_supervisor` coordination contract.
@@ -55,10 +55,11 @@ Pi Herdsman can generate one. The first delegation can create the first linked
55
55
  worktree, and an unoccupied existing worktree for the branch is reused.
56
56
 
57
57
  Start new work with `delegate_project`. Resume existing work with
58
- `resume_project` using its branch. If its worktree is missing, Herdsman recreates
59
- it from the existing branch and resumes the exact persisted Pi session when
60
- available. The saved session cwd is used when history exists; if the branch
61
- itself is unavailable, recreation fails closed.
58
+ `resume_project` using its branch. A verified Git inventory showing the
59
+ assignment's worktree checkout is absent retires that assignment and its
60
+ pending project messages; failed or ambiguous inventory preserves it. A retired
61
+ assignment cannot be resumed, but a new delegation may start managed work from
62
+ the remaining Git branch. Retirement does not delete branches or Pi sessions.
62
63
 
63
64
  Whenever Herdsman actually launches the project Lead process, it resolves the
64
65
  current `managed-lead` definition from the target worktree plus the global
@@ -135,10 +136,10 @@ See [`stop_lead`](../reference/staff.md#stop_lead) and
135
136
 
136
137
  ## Retire project work
137
138
 
138
- Successful Herdr worktree removal retires the matching project assignment,
139
- any still-pending messages; the Git branch remains. A worktree that is merely
140
- missing does not imply retirement, so the assignment remains recoverable with
141
- `resume_project` when its branch is available. An assigned Lead can explicitly
139
+ Successful Herdr worktree removal or verified checkout absence retires the
140
+ matching project assignment and any still-pending messages; the Git branch
141
+ remains. Failed or ambiguous inventory does not imply absence, so the
142
+ assignment is preserved until authoritative evidence is available. An assigned Lead can explicitly
142
143
  release Manager control with `/takeover`; after confirmation, the assignment
143
144
  and pending project messages are removed while its Pi session, conversation,
144
145
  branch, worktree, running process, and owned Agents remain. The continuing
@@ -238,8 +238,9 @@ live assigned Lead. Manager staff reports contain only live exact Leads named
238
238
  by current project assignments; physical worktree scope alone grants no
239
239
  authority. Project assignments survive Manager replacement and manual
240
240
  continuation of the exact assigned Pi session. `managed-lead` is launch policy,
241
- not authority. Successful Herdr worktree removal retires an assignment; a
242
- missing worktree alone leaves it recoverable with `resume_project`.
241
+ not authority. Successful Herdr worktree removal or verified checkout absence
242
+ retires an assignment; failed or ambiguous inventory preserves it. A retired
243
+ assignment cannot be resumed, though new work may use the remaining Git branch.
243
244
 
244
245
  An eligible ordinary Lead can activate runtime Chief mode with `/chief`.
245
246
  While Chief, `/chief` opens the overview and `/chief leave` exits the mode.
@@ -40,9 +40,9 @@ Returns a fresh direct-report projection and fresh `available_tools`. For
40
40
  Manager, `work` lists durable project assignments by branch with derived status
41
41
  and a bounded task summary. Status is `active`, `paused`, or `conflict`; active
42
42
  work may include the live Lead's separate `runtime_state`. Paused work remains
43
- listed without a running Lead. A missing worktree can be reconstructed when
44
- resuming the assignment and its branch remains available. Work items do not
45
- expose assignment session IDs, workspace IDs, or pane IDs.
43
+ listed without a running Lead. Verified checkout absence retires the assignment;
44
+ unavailable or ambiguous Git inventory preserves it. Work items do not expose
45
+ assignment session IDs, workspace IDs, or pane IDs.
46
46
 
47
47
  For Manager, `open_workspaces` separately reports current Herdr topology. It is
48
48
  not assignment ownership. A branch is the project-work handle; a report's
@@ -122,11 +122,10 @@ Manager only. Resume existing unresolved project work using its exact branch:
122
122
 
123
123
  The assignment must already exist; resume does not create or replace it.
124
124
  Resuming already-running work returns the current exact Lead instead of
125
- starting another. A stopped Lead is relaunched with the same assignment. If
126
- the worktree is missing, Herdsman recreates it from the existing branch and
127
- resumes the exact saved Pi session; its saved cwd is used when available. If
128
- the branch no longer exists, recovery fails closed rather than creating it
129
- from the current default branch.
125
+ starting another. A stopped Lead is relaunched with the same assignment while
126
+ its worktree exists. Verified checkout absence retires the assignment rather
127
+ than recreating it. A retired assignment cannot be resumed; new work may use
128
+ `delegate_project` with the remaining branch.
130
129
 
131
130
  ## `stop_lead`
132
131
 
@@ -139,9 +138,9 @@ execution tree. The assignment, Pi session, Git branch, and worktree are
139
138
  preserved. Resume the work with
140
139
  `resume_project` using its branch. An unassigned Lead is not a Manager staff-stop
141
140
  target. Failed or ambiguous cleanup does not retire an assignment. Successful
142
- Herdr worktree removal retires the assignment and removes pending project
143
- messages; a missing worktree alone leaves the assignment recoverable with
144
- `resume_project`. The
141
+ Herdr worktree removal or verified checkout absence retires the assignment and
142
+ removes pending project messages. Failed or ambiguous inventory preserves the
143
+ assignment. The
145
144
  assigned Lead may separately release Manager authority through confirmed
146
145
  `/takeover`, which removes the assignment and pending project messages without
147
146
  stopping the session or owned Agents.
@@ -96,12 +96,19 @@ Unmanaged or invalid agent environments do not receive the managed widget.
96
96
 
97
97
  ## Refresh
98
98
 
99
- The widget refreshes managed herdr data plus mailbox state every two seconds.
100
-
101
- Refresh performs a bounded herdr pane-list lookup to validate the lead
102
- boundary. It does not add a socket transport or another agent-control protocol.
103
-
104
- A refresh failure never mutates mailbox/control eligibility.
99
+ Ordinary status refreshes on explicit requests and controller or Herdr
100
+ invalidations, with a 10-second reconciliation while its TUI widget is active.
101
+ Herdr events invalidate the view; presentation-only events refresh status but
102
+ do not trigger health scans.
103
+
104
+ Full Chief/Manager supervision observation is event- and local-invalidation-
105
+ driven, with a 10-second reconciliation while active TUI supervision is
106
+ enabled. The Manager elapsed-time widget redraws every two seconds for
107
+ presentation, without acquiring a new authoritative snapshot.
108
+
109
+ Headless mode has no UI-only periodic supervision observation. Explicit and
110
+ model-context refreshes still acquire fresh state. A refresh failure never
111
+ mutates mailbox/control eligibility.
105
112
 
106
113
  ## Lead execution
107
114
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pi-herdsman",
3
- "version": "0.22.0",
3
+ "version": "0.22.2",
4
4
  "type": "module",
5
5
  "description": "Asynchronous Pi subagents and agent fleet orchestration for parallel coding agents with nested delegation, background work, and supervision in herdr.",
6
6
  "license": "Apache-2.0",