pi-herdsman 0.1.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.
@@ -0,0 +1,175 @@
1
+ # Documentation maintenance
2
+
3
+ [Documentation index](../README.md)
4
+
5
+ The documentation is deliberately split by responsibility so each feature stays
6
+ on its canonical page while readers can enter through audience-specific paths.
7
+
8
+ ## Ownership rule
9
+
10
+ Every public concept has one canonical page.
11
+
12
+ Use the ownership table in [the documentation index](../README.md).
13
+
14
+ When another page needs the same concept:
15
+
16
+ - summarize only enough to establish context;
17
+ - link to the canonical page;
18
+ - do not paste the complete table or contract again.
19
+
20
+ Audience entry pages are navigation, not competing ownership. They may establish
21
+ reading order and show a minimal first-use example, but exhaustive behavior stays
22
+ on the canonical concept, guide, or reference page.
23
+
24
+ Asynchronous orchestration is owned by [Lifecycle](../concepts/lifecycle.md).
25
+ README, Getting started, and Agent coordination API may repeat the concise user
26
+ or caller consequence, but they must link back to Lifecycle for the exact
27
+ contract.
28
+
29
+ ## Page types
30
+
31
+ ### Audience entry points
32
+
33
+ The documentation index routes readers first by audience:
34
+
35
+ - [Getting started](../getting-started.md) is the shortest human UI and
36
+ configuration path;
37
+ - [Agent coordination API](../agent-api.md) is the model and agent coordination
38
+ reading path;
39
+ - development pages are maintainer-only.
40
+
41
+ These pages should link across audiences when useful, but must not grow parallel
42
+ copies of the same API, lifecycle, configuration, or presentation contract.
43
+
44
+ The physical `concepts`, `guides`, `reference`, and `development` directories
45
+ remain content-type organization. Do not add another documentation hierarchy or
46
+ navigation manifest just to represent audiences.
47
+
48
+ ### Getting started
49
+
50
+ Shortest human path from prerequisites to useful Pi Herdsman delegation,
51
+ continued lead-session interaction, UI, configuration, and observability.
52
+
53
+ Do not turn it into a structured API reference.
54
+
55
+ ### Agent coordination API
56
+
57
+ Reading order and first-use orientation for model and agent-facing coordination.
58
+
59
+ Link to the exact `worker`, `ask_owner`, lifecycle, delegation, handoff, state,
60
+ and error owners instead of restating their full contracts.
61
+
62
+ ### Concepts
63
+
64
+ Explain mental models and invariants.
65
+
66
+ Do not enumerate every request field.
67
+
68
+ ### Guides
69
+
70
+ Task-oriented procedures and examples.
71
+
72
+ Link to reference for exhaustive semantics.
73
+
74
+ ### Reference
75
+
76
+ Exact accepted values, precedence, states, and API rules.
77
+
78
+ Avoid tutorial narrative.
79
+
80
+ ### Development
81
+
82
+ Maintainer-only validation, smoke, and documentation-process material.
83
+
84
+ Do not mix these procedures into normal user setup.
85
+
86
+ ### `SKILL.md`
87
+
88
+ Optional model-facing reinforcement of the self-contained runtime operational
89
+ contract plus deeper strategy, rationale, examples, and recovery guidance.
90
+
91
+ It does not own product API schemas or runtime behavior.
92
+
93
+ ## Runtime and skill synchronization
94
+
95
+ Pi Herdsman has one deliberate instruction duplication.
96
+
97
+ The runtime controller and managed-worker instructions are the authoritative,
98
+ self-contained operational contract. Root `SKILL.md` intentionally mirrors
99
+ those mandatory operational instructions so loading the skill can reinforce
100
+ them in a long model context.
101
+
102
+ Therefore:
103
+
104
+ - every mandatory operational rule must exist at runtime;
105
+ - corresponding operational guidance must remain represented in `SKILL.md`;
106
+ - `SKILL.md` may add strategy, rationale, examples, and deeper explanation;
107
+ - no capability or normal workflow may depend on loading `SKILL.md`;
108
+ - runtime wins if the two surfaces conflict;
109
+ - a change to either mirrored runtime or skill instructions requires checking
110
+ the other side in the same change.
111
+
112
+ This is intentional reinforcement, not competing authority.
113
+
114
+ Do not replace it with runtime skill loading, generated prompt files, a prompt
115
+ registry, or another synchronization subsystem.
116
+
117
+ ## Style
118
+
119
+ - Plain Markdown.
120
+ - Relative repository links.
121
+ - One H1 per file.
122
+ - Short descriptive headings.
123
+ - Current behavior only.
124
+ - Spell the visible product name `Pi Herdsman`, the package and repository identifier `pi-herdsman`, the local coordination directory `.pi-herdsman`, the settings namespace `piHerdsman`, and the upstream dependency `herdr`.
125
+ - No backlog task numbers in product docs.
126
+ - Keep canonical user and reference pages focused on current behavior.
127
+ - Examples must match current accepted schemas.
128
+ - Never document unshipped backlog behavior as available.
129
+ - Avoid em dashes in product documentation.
130
+
131
+ ## Cross-links
132
+
133
+ Every page under `docs/` links back to the documentation index.
134
+
135
+ Audience entry pages may also link directly to each other so a reader can switch
136
+ paths without returning to the index.
137
+
138
+ Use a `See also` section when the neighboring concept is useful.
139
+
140
+ Do not create a separate nav manifest or documentation framework unless plain
141
+ Markdown stops meeting a demonstrated need.
142
+
143
+ ## Source verification
144
+
145
+ When implementation and existing prose disagree:
146
+
147
+ 1. public source/test behavior is authoritative;
148
+ 2. current accepted runtime evidence can clarify integration behavior;
149
+ 3. stale prose should be deleted, not preserved as an alternative contract.
150
+
151
+ Particularly verify the runtime implementation for `worker`, `ask_owner`,
152
+ `/workers`, `/chief`, `staff`, states, definition schema/composition, text-file snapshots,
153
+ state projection, error categories, and presentation behavior;
154
+
155
+ - `package.json` for supported Pi versions and package resources.
156
+
157
+ ## Link integrity
158
+
159
+ Before handoff, resolve every repository-relative Markdown link. Links must
160
+ target current repository pages and anchors; do not reference deleted pages or
161
+ removed examples.
162
+
163
+ ## Update policy
164
+
165
+ A feature should normally change:
166
+
167
+ - its one canonical reference page;
168
+ - a guide or concept only when user workflow or mental model changes;
169
+ - an audience entry page only when its reading path or first-use experience
170
+ changes;
171
+ - README only when first-use or product capability changes;
172
+ - SKILL only when controller coordination guidance changes.
173
+
174
+ Update only the surfaces whose current ownership or links change; keep README,
175
+ SKILL, smoke testing, guides, and status docs aligned with their responsibilities.
@@ -0,0 +1,293 @@
1
+ # Smoke testing
2
+
3
+ [Documentation index](../README.md)
4
+
5
+ These are maintainer acceptance checks for behavior that benefits from a real
6
+ Pi/herdr boundary.
7
+
8
+ Use disposable workers and exact-ID cleanup. Do not disturb unrelated user
9
+ workspaces or agents.
10
+
11
+ ## Preconditions
12
+
13
+ Verify:
14
+
15
+ ```sh
16
+ node --version
17
+ pi --version
18
+ herdr --version
19
+ herdr integration status
20
+ ```
21
+
22
+ The supported repository contract requires:
23
+
24
+ - Node `>=22.19.0`
25
+ - Pi `>=0.84.2 <0.86.0`
26
+ - herdr `>=0.8.0`
27
+ - herdr Pi integration version `2` or newer
28
+
29
+ Run the repository validation gate first.
30
+
31
+ ## Current mailbox contract
32
+
33
+ For a current managed run, inspect the persisted state, request, ask, and
34
+ result records and verify they use protocol version `3` and contain no lifetime
35
+ field. Control prompts use the `__PI_HERDSMAN_WORKER_V3__:` marker prefix.
36
+
37
+ ## One-shot definition and session continuation
38
+
39
+ Delegate a small deterministic read-only task to the `scout` definition. Record
40
+ the returned worker, request, session, and pane identities.
41
+
42
+ Verify:
43
+
44
+ - one managed worker starts;
45
+ - the task is acknowledged;
46
+ - the worker completes with exactly one result reaching the owner;
47
+ - the terminal result identifies the exact session;
48
+ - cleanup removes the worker, pane, mailbox, and runtime;
49
+ - the exact Pi session remains available.
50
+
51
+ Use the exact returned session ID or path for a follow-up assignment:
52
+
53
+ ```json
54
+ {
55
+ "action": "delegate",
56
+ "session": "<exact session>",
57
+ "task": "Continue the investigation with one short follow-up."
58
+ }
59
+ ```
60
+
61
+ Verify:
62
+
63
+ - the same Pi session and session file are used;
64
+ - a new worker generation, run ID, request ID, and pane are created;
65
+ - the saved conversation context is available;
66
+ - the current effective definition configuration is used;
67
+ - exactly one result reaches the owner;
68
+ - cleanup removes the second worker, pane, mailbox, and runtime.
69
+
70
+ While the continuation assignment is active, submit another
71
+ `delegate.session` request for the same exact session. Verify it fails with
72
+ `worker_busy`, creates no duplicate worker or pane, and leaves the active
73
+ assignment unchanged. After both assignments finish, `worker list` must show
74
+ no completed idle worker.
75
+
76
+ ## Historical session delegation
77
+
78
+ Use an exact saved session path or full UUID.
79
+
80
+ Verify:
81
+
82
+ - saved definition and cwd are respected;
83
+ - session delegation uses the saved cwd;
84
+ - current effective agent override values are used for the new worker
85
+ generation;
86
+ - the exact session continues.
87
+
88
+ ## Fork
89
+
90
+ Delegate to a definition with `fork` pointing to an exact saved session.
91
+
92
+ Verify:
93
+
94
+ - a new worker/session is created;
95
+ - the fork source is explicit;
96
+ - the current controller session is not implicitly used.
97
+
98
+ ## Inferred delegation
99
+
100
+ Use a bundled delegating worker definition whose source `tools` list does not explicitly
101
+ contain `worker`, such as the current `implementer`.
102
+
103
+ Ask it to delegate one bounded scout task.
104
+
105
+ Verify:
106
+
107
+ - the real Pi worker can call `worker`;
108
+ - worker result reaches the delegating worker;
109
+ - delegating worker integrates it once;
110
+ - all one-shot workers clean up.
111
+
112
+ This proves effective-definition inference reaches Pi launch policy rather than
113
+ only metadata.
114
+
115
+ ## Body reference expansion
116
+
117
+ Create a temporary global definition with a whole-line body reference:
118
+
119
+ ```markdown
120
+ ---
121
+ name: worker
122
+ bodyMode: append
123
+ ---
124
+
125
+ @../temporary-policy.md
126
+ ```
127
+
128
+ Use a distinctive instruction in the referenced file.
129
+
130
+ Verify the worker obeys that instruction through the expanded private prompt.
131
+
132
+ Afterward remove the temporary definition and referenced file, confirm discovery
133
+ no longer lists the temporary definition, and verify no repository file changed.
134
+
135
+ ## `ask_owner` round trip
136
+
137
+ Give a worker a task whose correct continuation requires an owner choice.
138
+
139
+ Verify:
140
+
141
+ 1. worker calls `ask_owner` alone;
142
+ 2. owner receives one question;
143
+ 3. worker becomes `blocked`;
144
+ 4. owner replies with exact `worker reply`;
145
+ 5. reply continues the same assignment;
146
+ 6. worker produces exactly one final result;
147
+ 7. no worker/mailbox leak remains.
148
+
149
+ ## Delegating-worker natural waiting
150
+
151
+ Ask a delegating worker to delegate required reconnaissance when no useful independent
152
+ local work remains.
153
+
154
+ Inspect the actual transcript and verify the delegating worker:
155
+
156
+ - ends its turn normally after the assignment;
157
+ - does not poll `worker list`;
158
+ - does not sleep or use a separate wait mechanism;
159
+ - wakes when the worker result is delivered;
160
+ - integrates the result into one final delegating worker outcome.
161
+
162
+ ## Useful concurrency
163
+
164
+ Give a delegating worker one delegated task A and independent local task B.
165
+
166
+ Verify it can work on B while A is active, then ends its turn when no useful
167
+ independent work remains and integrates A after result delivery.
168
+
169
+ ## Lead `/workers` commands
170
+
171
+ In a lead session with UI:
172
+
173
+ ### `/workers agents`
174
+
175
+ Verify the native Definitions selector shows:
176
+
177
+ - bundled, project (when trusted project discovery is enabled), and global
178
+ definitions in the effective roster;
179
+ - project participation marked `[project]`, with `*` for a global override
180
+ (`[project] *` means both layers contribute);
181
+ - compact, aligned name/model/thinking columns, including Unicode names;
182
+ - model, thinking, enabled, and details actions for a selected definition;
183
+ - `Use default` for model and thinking;
184
+ - narrow panes remain width-safe.
185
+
186
+ Structured `worker list` should still retain exact deterministic metadata.
187
+
188
+ Select a disposable bundled, project, or global definition and change its
189
+ model, thinking, and enabled state. Confirm that project discovery requires a
190
+ trusted project's `piHerdsman.projectAgents: true` setting and that these edits
191
+ write global overrides only, not project files.
192
+
193
+ Verify unrelated frontmatter and body remain unchanged, `Use default` removes
194
+ only the selected field, fresh definition delegations and session continuations
195
+ use the current effective value, and running workers are not mutated.
196
+
197
+ ### `/workers placement`
198
+
199
+ Open the native selector, change to the alternate value, verify, then restore
200
+ the original value.
201
+
202
+ ### `/workers stop`
203
+
204
+ With disposable owned workers, verify the owned tree closes while an unrelated
205
+ herdr agent remains untouched.
206
+
207
+ ## Failure diagnostics
208
+
209
+ Use a disposable invalid resource/launch configuration only when safe.
210
+
211
+ Verify startup failure:
212
+
213
+ - settles within the bounded budget;
214
+ - reports the stage and best available diagnostic;
215
+ - performs exact ownership-safe rollback;
216
+ - does not leave a false successful worker.
217
+
218
+ ## Cleanup checklist
219
+
220
+ After every smoke:
221
+
222
+ - `worker list` has no unintended managed workers;
223
+ - temporary global definitions are removed;
224
+ - temporary prompt/body files are removed;
225
+ - disposable herdr resources are closed by exact ID;
226
+ - no repository source file changed unless the smoke explicitly required it.
227
+
228
+ ## Chief supervision live matrix
229
+
230
+ No live Pi/herdr smoke was run for the current worktree. Every scenario below
231
+ is **NOT RUN**, not a claim of failure or success. The automated tests are not
232
+ substitutes for these checks.
233
+
234
+ | Scenario | Result |
235
+ | ------------------------------------------------------------------------------------------------------------------------------------ | ------- |
236
+ | Normal lead has `worker` and `chief`, not `staff` | NOT RUN |
237
+ | Active Chief has exactly `staff`, not lead controller tools | NOT RUN |
238
+ | Persisted Chief resume collision becomes suspended | NOT RUN |
239
+ | Ordinary losing `/chief` collision remains a lead with its tools and offers Focus/Cancel | NOT RUN |
240
+ | Delegating worker and worker retain their current role tools | NOT RUN |
241
+ | Activate one Chief with `/chief` | NOT RUN |
242
+ | Activation refuses a lead with owned or unresolved worker work | NOT RUN |
243
+ | Two exact simultaneous Chief claims have one winner | NOT RUN |
244
+ | Stale exact lease recovery | NOT RUN |
245
+ | Malformed role, lead state, lease, or descriptor fails closed; coordination publication invalidates stale state and disables actions | NOT RUN |
246
+ | Discover leads across multiple workspaces | NOT RUN |
247
+ | Exclude managed workers and the active Chief from leads | NOT RUN |
248
+ | Worker exclusion uses the production validated snapshot and stale/ambiguous generations fail closed | NOT RUN |
249
+ | Herdr `agent_status ?? status` lifecycle normalization is reflected | NOT RUN |
250
+ | Nested worker aggregation attaches only to the proven lead | NOT RUN |
251
+ | A blocked worker does not mark its lead `needs you` | NOT RUN |
252
+ | Duplicate live agents, coordination records, or worker evidence fail closed | NOT RUN |
253
+ | Target disappearance or replacement between list and action is rejected | NOT RUN |
254
+ | Inspect a lead and compare bounded peek evidence | NOT RUN |
255
+ | Focus a lead after exact revalidation | NOT RUN |
256
+ | Chief `message` to idle, working, or blocked leads | NOT RUN |
257
+ | Two Chief messages queue and arrive once and in order | NOT RUN |
258
+ | A quarantined message does not block a new message to the same lead | NOT RUN |
259
+ | Leads retain descendant ownership after a Chief `message` | NOT RUN |
260
+ | Lead `chief message` reaches the active Chief | NOT RUN |
261
+ | Lead `chief ask` reaches the active Chief and creates one pending ask | NOT RUN |
262
+ | Pending ask projects as `needs_you` with bounded public question and exact reply action | NOT RUN |
263
+ | A second lead ask while one is pending is rejected | NOT RUN |
264
+ | Exact Chief `reply` reaches the lead and clears the ask after local acceptance | NOT RUN |
265
+ | Pending ask remains replyable after chief replacement using the unchanged ask ID/current lease | NOT RUN |
266
+ | Failed ask queue restores the exact previous pending-ask state | NOT RUN |
267
+ | Metadata publication failure does not remove communication eligibility | NOT RUN |
268
+ | Ordinary lead messages leave lead coordination state unchanged | NOT RUN |
269
+ | Follow-up delivery while the receiver is streaming, never steering | NOT RUN |
270
+ | Receiver restart delivers each queued message once | NOT RUN |
271
+ | Accepted-before-delete crash deduplicates without reinjection | NOT RUN |
272
+ | Failed delivery/acceptance retains the queued record | NOT RUN |
273
+ | Transient authorization lookup failure retains the queued message | NOT RUN |
274
+ | Stale lease, wrong sender/generation, duplicate identity, and malformed records fail closed | NOT RUN |
275
+ | Lead/Chief messages show bounded direction-aware model-visible sender and target identity | NOT RUN |
276
+ | Queued inbox records are ordered by `createdAt`, then ID | NOT RUN |
277
+ | Resume with a free or occupied lease | NOT RUN |
278
+ | Confirm `/chief leave` without mutating supervised leads | NOT RUN |
279
+ | Empty-roster Escape closes the native custom UI | NOT RUN |
280
+ | Empty-roster Ctrl+C closes the native custom UI | NOT RUN |
281
+ | Real terminal arrow sequences navigate the visual order | NOT RUN |
282
+ | Space switches overview to peek and Escape/Space returns without nested custom UI | NOT RUN |
283
+ | Ctrl+C closes from peek | NOT RUN |
284
+ | Enter focuses the lead and closes the overview | NOT RUN |
285
+ | Background refresh redraws the open overview | NOT RUN |
286
+ | Ambient and overview rendering stay within the supplied width | NOT RUN |
287
+ | Named herdr sockets independently support one Chief each | NOT RUN |
288
+
289
+ Named herdr socket independence is also **NOT RUN** because no live Pi/herdr
290
+ runtime was available for this worktree.
291
+
292
+ The automated test gate is the available evidence for this worktree; see
293
+ [Validation](validation.md).
@@ -0,0 +1,124 @@
1
+ # Development validation
2
+
3
+ [Documentation index](../README.md)
4
+
5
+ Repository handoff is not complete until the current validation gates have been
6
+ run or a concrete environment blocker is recorded.
7
+
8
+ ## Required gate
9
+
10
+ Run:
11
+
12
+ ```sh
13
+ prettier . --write
14
+ npm run check
15
+ git diff --check
16
+ ```
17
+
18
+ When reviewing staged work, also run as appropriate:
19
+
20
+ ```sh
21
+ git diff HEAD --check
22
+ ```
23
+
24
+ ## What `npm run check` does
25
+
26
+ The repository check command validates the development source and tests.
27
+
28
+ It discovers the extension's TypeScript source and runs, under one bounded
29
+ suite deadline:
30
+
31
+ 1. Node syntax checking for every extension TypeScript file;
32
+ 2. an import check for the extension entry point;
33
+ 3. the complete Node test set.
34
+
35
+ The test phase uses:
36
+
37
+ ```text
38
+ --experimental-test-module-mocks
39
+ --experimental-strip-types
40
+ --test
41
+ --test-timeout=10000
42
+ ```
43
+
44
+ ## Process containment
45
+
46
+ Validation phases run in detached POSIX process groups.
47
+
48
+ On the suite deadline, the runner attempts:
49
+
50
+ 1. `SIGTERM`;
51
+ 2. a bounded grace period;
52
+ 3. `SIGKILL` when required;
53
+ 4. bounded proof that the process group disappeared.
54
+
55
+ A phase that leaks descendants after normal exit is reported as a failure and
56
+ cleaned through the same group boundary.
57
+
58
+ Windows is not supported by this process-group validation runner.
59
+
60
+ ## Focused tests
61
+
62
+ During implementation, use Node's direct test runner through the normal npm
63
+ interface:
64
+
65
+ ```sh
66
+ # all tests
67
+ npm test
68
+
69
+ # one test file
70
+ npm test -- extension/<area>.test.ts
71
+
72
+ # one test name within a selected file
73
+ npm test -- --test-name-pattern="<pattern>" extension/<area>.test.ts
74
+ ```
75
+
76
+ For supervision changes, useful focused examples are:
77
+
78
+ ```sh
79
+ npm test -- extension/supervision.test.ts
80
+ npm test -- --test-name-pattern="lease" extension/supervision.test.ts
81
+ npm test -- --test-name-pattern="inspect" extension/controller-api.test.ts
82
+ ```
83
+
84
+ These are command examples, not recorded results. Live Pi/herdr acceptance is
85
+ tracked separately in [Smoke testing](smoke-testing.md).
86
+
87
+ File selection is the primary focusing mechanism. A name pattern narrows the
88
+ tests within the selected file; it does not select which files Node loads.
89
+
90
+ Before final acceptance, run the full repository gate:
91
+
92
+ ```sh
93
+ npm run check
94
+ ```
95
+
96
+ `npm run check` remains the bounded full gate, including process-group cleanup
97
+ when a validation phase times out or leaks descendants.
98
+
99
+ ## Dependency availability
100
+
101
+ A fresh auxiliary worktree may not contain `node_modules`.
102
+
103
+ Do not silently install dependencies as part of a source-only task unless that
104
+ installation is authorized. If validation uses an existing dependency tree via a
105
+ temporary link, record that fact and remove the link afterward.
106
+
107
+ ## Failed or non-converging check
108
+
109
+ Record:
110
+
111
+ - exact command;
112
+ - exit/result classification;
113
+ - process evidence when relevant;
114
+ - cleanup result;
115
+ - whether failure is source-related or environment-related.
116
+
117
+ Do not claim a passing full check from a partial focused run.
118
+
119
+ ## Live verification
120
+
121
+ Deterministic tests are the repository gate. Cross-process Pi/herdr behavior may
122
+ also require the live smoke suite.
123
+
124
+ See [Smoke testing](smoke-testing.md).