@llblab/pi-actors 0.22.5 → 0.24.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.
Files changed (180) hide show
  1. package/AGENTS.md +125 -59
  2. package/BACKLOG.md +88 -403
  3. package/CHANGELOG.md +39 -0
  4. package/README.md +14 -1
  5. package/dist/fixtures/protocol/actor-message-branch.json +13 -0
  6. package/dist/fixtures/protocol/artifact-manifest.json +9 -0
  7. package/dist/fixtures/protocol/mailbox-contract.json +15 -0
  8. package/dist/fixtures/protocol/recipe-summary.json +16 -0
  9. package/dist/fixtures/protocol/room-message.json +11 -0
  10. package/dist/fixtures/protocol/room-roster.json +11 -0
  11. package/dist/fixtures/protocol/run-inbox-message.json +9 -0
  12. package/dist/fixtures/protocol/run-outbox-event.json +9 -0
  13. package/dist/fixtures/protocol/run-state.json +10 -0
  14. package/dist/index.js +18 -2
  15. package/dist/lib/actor-inspector-tui.d.ts +4 -0
  16. package/dist/lib/actor-inspector-tui.js +58 -44
  17. package/dist/lib/actor-rooms.d.ts +16 -0
  18. package/dist/lib/actor-rooms.js +123 -28
  19. package/dist/lib/actor-worker.d.ts +13 -0
  20. package/dist/lib/actor-worker.js +86 -0
  21. package/dist/lib/async-runner.d.ts +5 -0
  22. package/dist/lib/async-runner.js +134 -0
  23. package/dist/lib/async-runs.d.ts +34 -2
  24. package/dist/lib/async-runs.js +224 -50
  25. package/dist/lib/build-dist.d.ts +5 -0
  26. package/dist/lib/build-dist.js +24 -0
  27. package/dist/lib/command-templates.js +5 -5
  28. package/dist/lib/conformance.d.ts +12 -0
  29. package/dist/lib/conformance.js +28 -0
  30. package/dist/lib/coordinator.d.ts +5 -0
  31. package/dist/lib/coordinator.js +557 -0
  32. package/dist/lib/limits.d.ts +11 -0
  33. package/dist/lib/limits.js +11 -0
  34. package/dist/lib/locker.d.ts +5 -0
  35. package/dist/lib/locker.js +310 -0
  36. package/dist/lib/mailbox-loop.d.ts +41 -0
  37. package/dist/lib/mailbox-loop.js +62 -0
  38. package/dist/lib/observability.d.ts +2 -2
  39. package/dist/lib/observability.js +57 -57
  40. package/dist/lib/output.js +4 -5
  41. package/dist/lib/prompts.d.ts +1 -1
  42. package/dist/lib/prompts.js +1 -1
  43. package/dist/lib/recipe-discovery.js +1 -0
  44. package/dist/lib/recipe-references.d.ts +11 -2
  45. package/dist/lib/recipe-references.js +29 -4
  46. package/dist/lib/recipe-usage.d.ts +2 -1
  47. package/dist/lib/recipe-usage.js +15 -3
  48. package/dist/lib/recipe-utils.d.ts +5 -0
  49. package/dist/lib/recipe-utils.js +385 -0
  50. package/dist/lib/runtime-notifier.js +3 -7
  51. package/dist/lib/runtime.js +12 -2
  52. package/dist/lib/state-readers.d.ts +21 -0
  53. package/dist/lib/state-readers.js +74 -0
  54. package/dist/lib/tools.js +198 -39
  55. package/dist/lib/validate-recipe.d.ts +6 -0
  56. package/dist/lib/validate-recipe.js +104 -0
  57. package/dist/recipes/actor-worker.json +35 -0
  58. package/dist/recipes/coordinator-locker.json +45 -0
  59. package/dist/recipes/lens-swarm.json +66 -0
  60. package/dist/recipes/locker.json +45 -0
  61. package/dist/recipes/music-player.json +38 -0
  62. package/dist/recipes/pipeline-architect-coordinator.json +95 -0
  63. package/dist/recipes/pipeline-artifact-bundle.json +100 -0
  64. package/dist/recipes/pipeline-artifact-report.json +58 -0
  65. package/dist/recipes/pipeline-artifact-write.json +72 -0
  66. package/dist/recipes/pipeline-async-run-ops.json +70 -0
  67. package/dist/recipes/pipeline-checkpoint-continuation.json +67 -0
  68. package/dist/recipes/pipeline-development-tasking.json +81 -0
  69. package/dist/recipes/pipeline-docs-maintenance.json +80 -0
  70. package/dist/recipes/pipeline-media-library.json +59 -0
  71. package/dist/recipes/pipeline-quorum-review.json +79 -0
  72. package/dist/recipes/pipeline-release-readiness.json +110 -0
  73. package/dist/recipes/pipeline-release-summary.json +88 -0
  74. package/dist/recipes/pipeline-repo-health.json +89 -0
  75. package/dist/recipes/pipeline-research-synthesis.json +94 -0
  76. package/dist/recipes/pipeline-review-readiness.json +54 -0
  77. package/dist/recipes/pipeline-room-swarm.json +50 -0
  78. package/dist/recipes/subagent-artifact.json +32 -0
  79. package/dist/recipes/subagent-checkpoint.json +33 -0
  80. package/dist/recipes/subagent-conflict-report.json +32 -0
  81. package/dist/recipes/subagent-contradiction-map.json +33 -0
  82. package/dist/recipes/subagent-critic.json +35 -0
  83. package/dist/recipes/subagent-evidence-map.json +33 -0
  84. package/dist/recipes/subagent-followup.json +33 -0
  85. package/dist/recipes/subagent-judge.json +33 -0
  86. package/dist/recipes/subagent-merge.json +33 -0
  87. package/dist/recipes/subagent-message.json +34 -0
  88. package/dist/recipes/subagent-normalize.json +31 -0
  89. package/dist/recipes/subagent-plan.json +33 -0
  90. package/dist/recipes/subagent-prompt.json +28 -0
  91. package/dist/recipes/subagent-quorum.json +43 -0
  92. package/dist/recipes/subagent-review-coordinator.json +114 -0
  93. package/dist/recipes/subagent-review.json +37 -0
  94. package/dist/recipes/subagent-task-card.json +35 -0
  95. package/dist/recipes/subagent-tools.json +27 -0
  96. package/dist/recipes/subagent-verify.json +34 -0
  97. package/dist/recipes/subagents-prompts.json +51 -0
  98. package/dist/recipes/utility-actor-message.json +23 -0
  99. package/dist/recipes/utility-artifact-manifest.json +16 -0
  100. package/dist/recipes/utility-artifact-write.json +16 -0
  101. package/dist/recipes/utility-changelog-head.json +11 -0
  102. package/dist/recipes/utility-changelog-section.json +13 -0
  103. package/dist/recipes/utility-coordinator-lock-snapshot.json +13 -0
  104. package/dist/recipes/utility-git-log.json +11 -0
  105. package/dist/recipes/utility-git-status.json +9 -0
  106. package/dist/recipes/utility-jsonl-tail.json +10 -0
  107. package/dist/recipes/utility-markdown-index.json +14 -0
  108. package/dist/recipes/utility-package-summary.json +11 -0
  109. package/dist/recipes/utility-playlist-build.json +17 -0
  110. package/dist/recipes/utility-playlist-scan.json +11 -0
  111. package/dist/recipes/utility-run-ops-snapshot.json +17 -0
  112. package/dist/recipes/utility-run-state-files.json +13 -0
  113. package/dist/recipes/utility-run-summary.json +11 -0
  114. package/dist/recipes/utility-skill-summary.json +13 -0
  115. package/dist/recipes/utility-validate-recipe.json +13 -0
  116. package/dist/recipes/utility-validation-wrapper.json +13 -0
  117. package/dist/scripts/actor-worker.mjs +31 -0
  118. package/dist/scripts/async-runner.mjs +31 -0
  119. package/dist/scripts/build-dist.mjs +25 -0
  120. package/dist/scripts/conformance.mjs +33 -0
  121. package/dist/scripts/coordinator.mjs +31 -0
  122. package/dist/scripts/locker.mjs +33 -0
  123. package/dist/scripts/music-player.mjs +964 -0
  124. package/dist/scripts/recipe-utils.mjs +31 -0
  125. package/dist/scripts/validate-recipe.mjs +34 -0
  126. package/dist/skills/actors/SKILL.md +375 -0
  127. package/dist/skills/swarm/SKILL.md +467 -0
  128. package/dist/skills/swarm/references/development-swarm.md +596 -0
  129. package/docs/actor-messages.md +2 -2
  130. package/docs/async-runs.md +13 -1
  131. package/docs/template-recipes.md +2 -2
  132. package/docs/tool-registry.md +0 -1
  133. package/fixtures/protocol/actor-message-branch.json +13 -0
  134. package/fixtures/protocol/artifact-manifest.json +9 -0
  135. package/fixtures/protocol/mailbox-contract.json +15 -0
  136. package/fixtures/protocol/recipe-summary.json +16 -0
  137. package/fixtures/protocol/room-message.json +11 -0
  138. package/fixtures/protocol/room-roster.json +11 -0
  139. package/fixtures/protocol/run-inbox-message.json +9 -0
  140. package/fixtures/protocol/run-outbox-event.json +9 -0
  141. package/fixtures/protocol/run-state.json +10 -0
  142. package/index.ts +21 -0
  143. package/lib/actor-inspector-tui.ts +138 -59
  144. package/lib/actor-rooms.ts +241 -60
  145. package/lib/actor-worker.ts +118 -0
  146. package/lib/async-runner.ts +173 -0
  147. package/lib/async-runs.ts +302 -53
  148. package/lib/build-dist.ts +30 -0
  149. package/lib/command-templates.ts +5 -5
  150. package/lib/conformance.ts +46 -0
  151. package/lib/coordinator.ts +649 -0
  152. package/lib/limits.ts +12 -0
  153. package/lib/locker.ts +340 -0
  154. package/lib/mailbox-loop.ts +148 -0
  155. package/lib/observability.ts +34 -23
  156. package/lib/output.ts +4 -6
  157. package/lib/prompts.ts +1 -1
  158. package/lib/recipe-discovery.ts +1 -0
  159. package/lib/recipe-references.ts +57 -6
  160. package/lib/recipe-usage.ts +31 -4
  161. package/lib/recipe-utils.ts +486 -0
  162. package/lib/runtime-notifier.ts +4 -6
  163. package/lib/runtime.ts +31 -7
  164. package/lib/state-readers.ts +93 -0
  165. package/lib/tools.ts +297 -58
  166. package/lib/validate-recipe.ts +110 -0
  167. package/package.json +11 -2
  168. package/recipes/actor-worker.json +35 -0
  169. package/recipes/pipeline-quorum-review.json +12 -7
  170. package/scripts/actor-worker.mjs +31 -0
  171. package/scripts/async-runner.mjs +11 -195
  172. package/scripts/build-dist.mjs +25 -0
  173. package/scripts/conformance.mjs +33 -0
  174. package/scripts/coordinator.mjs +19 -616
  175. package/scripts/locker.mjs +23 -322
  176. package/scripts/music-player.mjs +21 -2
  177. package/scripts/recipe-utils.mjs +20 -467
  178. package/scripts/validate-recipe.mjs +23 -113
  179. package/skills/actors/SKILL.md +7 -4
  180. package/skills/swarm/SKILL.md +3 -1
package/BACKLOG.md CHANGED
@@ -43,452 +43,137 @@ No open hotfix items.
43
43
 
44
44
  ## Minor Backlog
45
45
 
46
- ### M-01 Internal Protocol Contract Pack
46
+ The backlog is intentionally pruned to the 20% of work most likely to deliver 80% of value for `pi-actors` as a local actor kernel. Bias toward consolidation, smaller public surface area, and reliability over new feature breadth.
47
47
 
48
- - Priority: Medium.
49
- - Goal: Add machine-readable internal schemas and fixtures for implementation, docs, tests, and inspector consistency.
50
- - Files:
51
- - `schemas/actor-message.schema.json`.
52
- - `schemas/actor-address.schema.json`.
53
- - `schemas/run-state.schema.json`.
54
- - `schemas/run-inbox-message.schema.json`.
55
- - `schemas/run-outbox-event.schema.json`.
56
- - `schemas/room-message.schema.json`.
57
- - `schemas/room-roster.schema.json`.
58
- - `schemas/communication-snapshot.schema.json`.
59
- - `schemas/recipe.schema.json`.
60
- - `fixtures/protocol/run-minimal.json`.
61
- - `fixtures/protocol/message-branch.json`.
62
- - `fixtures/protocol/message-room-join.json`.
63
- - `fixtures/protocol/mailbox-contract.json`.
64
- - Acceptance:
65
- - Normalization outputs validate.
66
- - Docs examples validate.
67
- - Fixtures are usable by tests.
68
- - Schemas are versioned with package version.
69
-
70
- ### M-02 Unified Actor Event Base
71
-
72
- - Priority: Medium.
73
- - Goal: Add a shared base envelope for actor event-like records without forcing one storage file.
74
- - Target channels:
75
- - `events`.
76
- - `inbox`.
77
- - `outbox`.
78
- - `wake`.
79
- - `room`.
80
- - `branch`.
81
- - Acceptance:
82
- - New append helpers generate ids consistently.
83
- - Existing files remain readable.
84
- - `inspect` can show id, correlation, and causation.
85
- - No migration is forced.
48
+ ### M-01 State Corruption Recovery
86
49
 
87
- ### M-03 Mailbox Contract v1
88
-
89
- - Priority: Medium.
90
- - Goal: Extend `mailbox.accepts` and `mailbox.emits` from string arrays to backward-compatible typed contracts.
50
+ - Priority: High.
51
+ - Status: Done.
52
+ - Goal: Keep `inspect` useful when file-backed run, room, branch, or recipe state is partially corrupted.
53
+ - Why now: The extension's core promise is local, inspectable, durable actor state. Corrupt JSON/JSONL should degrade visibility, not break the operator membrane.
91
54
  - Direction:
92
- - Keep string declarations valid.
93
- - Normalize typed entries for inspection.
94
- - Support fields such as body schema, ack requirement, idempotency, response requirement, level, and summary.
55
+ - Continue migrating repeated JSON/JSONL inspect paths to `lib/state-readers.ts`.
56
+ - Preserve valid records and report corrupt paths/counts.
57
+ - Do not silently rewrite canonical state without an explicit repair action.
95
58
  - Acceptance:
96
- - String declarations still work.
97
- - `inspect view=mailbox` shows normalized contracts.
98
- - Messages outside accepts produce advisory warnings by default, not hard blocks.
99
- - Docs clarify advisory versus strict mode.
59
+ - Malformed JSONL lines do not kill inspect paths.
60
+ - Corrupt JSON files surface diagnostics with paths.
61
+ - Tests cover run, branch, room, and recipe-adjacent state where practical.
100
62
 
101
- ### M-04 Actor Loop Helper SDK
63
+ ### M-02 Actor Loop Helper Minimal Core
102
64
 
103
- - Priority: Medium.
104
- - Goal: Provide reusable helpers for mailbox-consuming actors so recipe authors do not rewrite loops.
65
+ - Priority: High.
66
+ - Status: Done.
67
+ - Goal: Provide one small reusable mailbox loop so recipe authors do not duplicate claim/handle/status logic.
68
+ - Why now: Long-lived actors and worker recipes are the natural center of `pi-actors`; a minimal helper consolidates behavior without adding a broker or scheduler DSL.
105
69
  - Files:
106
- - `lib/actor-loop.ts`.
107
- - `scripts/actor-loop.mjs`.
108
- - Capabilities:
109
- - Initial reconciliation.
110
- - Wake subscription.
111
- - Polling fallback.
112
- - Run and branch inbox claiming.
113
- - Handled and failed status transitions.
114
- - Outbox emission.
115
- - Progress updates.
116
- - Graceful stop handling.
117
- - Acceptance:
118
- - A packaged demo recipe uses a mailbox-only control endpoint.
119
- - Concurrent wake and poll paths do not double-process messages.
120
- - Helper supports run inbox and branch inbox.
121
-
122
- ### M-05 Branch Delivery Unification
123
-
124
- - Priority: Medium.
125
- - Goal: Route direct branch messages and room multicast branch copies through one internal helper.
126
- - Target helper:
127
- - `routeBranchEnvelope(stateDir, runId, message, { source })`.
128
- - Acceptance:
129
- - Direct branch messages and room multicast produce the same durable branch inbox shape.
130
- - Parent run dispatch envelope is consistent.
131
- - Tests cover both paths.
132
-
133
- ### M-06 Attention Semantics v1
134
-
135
- - Priority: Medium.
136
- - Goal: Formalize coordinator attention behavior through semantic metadata rather than transport knobs.
137
- - Direction:
138
- - Support attention metadata such as `requires_response=true` and reason.
139
- - Map response-required messages to follow-up.
140
- - Keep progress/info messages inspectable or notify-only.
141
- - Preserve existing internal `delivery` behavior.
142
- - Acceptance:
143
- - `requires_response=true` becomes coordinator follow-up.
144
- - Progress info stays log or notification.
145
- - Explicit stop and kill controls do not create duplicate terminal follow-up.
146
-
147
- ### M-07 Recipe Doctor
148
-
149
- - Priority: Medium.
150
- - Goal: Add intentional recipe health inspection.
151
- - Surface:
152
- - `inspect target=recipes view=doctor`.
153
- - `inspect target=recipes view=doctor verbose=true`.
154
- - Checks:
155
- - Import graph health.
156
- - Shadowing and blockers.
157
- - Invalid or disabled recipes.
158
- - Risky command templates.
159
- - Absolute path portability.
160
- - OS compatibility.
161
- - Root permissions.
162
- - Mailbox completeness.
163
- - Artifact placeholder resolution.
164
- - Stale or unused usage.
165
- - Acceptance:
166
- - Compact output is grouped by severity.
167
- - Verbose output is structured.
168
- - No automatic cleanup happens.
169
- - Every diagnostic has reason and suggested actions.
170
-
171
- ### M-08 Artifact Manifest v1
172
-
173
- - Priority: Medium.
174
- - Goal: Extend recipe artifacts from string paths to backward-compatible artifact metadata.
70
+ - `lib/mailbox-loop.ts`.
175
71
  - Direction:
176
- - Keep string artifact paths valid.
177
- - Add optional object fields such as path, kind, media type, and required.
178
- - Resolve manifests with existence, size, and optional hash.
72
+ - Support run inbox claiming, branch inbox claiming, handled/failed status transitions, bounded drains, duplicate-claim protection, and graceful stop-message detection.
73
+ - Defer live wake subscription and polling wrappers until the canonical worker recipe needs them.
74
+ - Keep policy out: no task selection, no model choice, no project prompts.
179
75
  - Acceptance:
180
- - String artifacts remain valid.
181
- - Runtime resolves manifest with `exists`, `size`, and optional `sha256`.
182
- - Terminal follow-ups group named artifacts.
183
- - Missing required artifacts are visible in result and inspect output.
184
-
185
- ### M-09 Lifecycle Retention Policy
186
-
187
- - Priority: Medium.
188
- - Goal: Add explicit archive and prune behavior for terminal run state.
189
- - Messages:
190
- - `control.archive`.
191
- - `control.prune`.
192
- - Direction:
193
- - Only terminal runs can be archived or pruned.
194
- - Active runs fail closed.
195
- - Archive moves or compresses state with a tombstone.
196
- - Prune deletes terminal state after ownership checks, optionally preserving artifacts.
197
- - Acceptance:
198
- - Terminal cleanup candidates are inspectable.
199
- - Artifacts can be preserved.
200
- - Active run deletion is impossible.
201
-
202
- ### M-10 Inspector v2 For Unread Mentions And Needs Response
203
-
204
- - Priority: Medium.
205
- - Goal: Strengthen the TUI inspector as the operator membrane for multi-actor sessions.
206
- - Direction:
207
- - Add stable event ids in previews.
208
- - Add unread cursor per session, run, and room.
209
- - Preserve mention filtering.
210
- - Add needs-response marker from attention semantics.
211
- - Distinguish room timeline rows from branch inbox rows.
212
- - Acceptance:
213
- - `/actors-inspector-filter unread` works.
214
- - `/actors-inspector-filter mention <text>` works.
215
- - `/actors-inspect <number>` marks the item read for the current session.
216
- - Unread state stays UI/session metadata, not protocol truth.
217
-
218
- ### M-11 Run State Index
219
-
220
- - Priority: Medium.
221
- - Goal: Add a rebuildable run-state index to reduce recursive scans and improve observability performance.
222
- - Target file:
223
- - `~/.pi/agent/tmp/pi-actors/runs/index.json`.
224
- - Contents:
225
- - State dir.
226
- - Run id.
227
- - Owner id.
228
- - Status.
229
- - Updated time.
230
- - Recipe or tool.
231
- - Acceptance:
232
- - Index accelerates list and summarize.
233
- - Corruption falls back to scan.
234
- - Rebuild helper exists.
235
- - Nested runs are represented without id collision.
236
-
237
- ### M-12 Internal Conformance Runner
238
-
239
- - Priority: Medium.
240
- - Goal: Add a CI-ready internal conformance runner for pi-actors protocol behavior.
241
- - Script:
242
- - `npm run conformance`.
243
- - Suites:
244
- - Recipe discovery.
245
- - Register, update, and delete.
246
- - Spawn lifecycle.
247
- - Message routing.
248
- - Room roster.
249
- - Branch inbox.
250
- - Ownership checks.
251
- - Artifacts.
252
- - Attention semantics.
253
- - Acceptance:
254
- - Runs without Pi UI where possible.
255
- - Outputs compact report.
256
- - Fixtures live in the repository.
257
- - CI can run it.
76
+ - Helper supports run inbox and branch inbox.
77
+ - Claim/handle/fail transitions are covered by tests.
78
+ - Duplicate branch claims do not double-process one message.
79
+ - Bounded drains stop on standard control messages.
258
80
 
259
- ### M-13 Packaged Actor Worker Recipe Template
81
+ ### M-03 Canonical Worker Recipe Template
260
82
 
261
- - Priority: Medium.
262
- - Goal: Add a canonical packaged recipe or template for a long-lived worker-backed branch actor.
83
+ - Priority: High.
84
+ - Status: Done.
85
+ - Depends on: M-02.
86
+ - Goal: Add one canonical packaged worker recipe/template demonstrating the intended long-lived actor pattern.
87
+ - Why now: The extension should teach one excellent mailbox loop rather than accumulate scenario-specific scripts.
263
88
  - Direction:
264
- - Worker joins room.
265
- - Worker declares mailbox accepts and emits.
266
- - Worker claims branch inbox messages.
89
+ - Worker joins the default room.
90
+ - Worker declares typed mailbox accepts/emits.
91
+ - Worker claims branch inbox work.
267
92
  - Worker posts `task.claim`, `task.result`, and `awaiting_assignment`.
268
93
  - Worker handles `control.stop`.
269
94
  - Acceptance:
270
- - Recipe demonstrates correct mailbox loop semantics.
271
- - It is a recipe-authoring example, not a product feature.
272
-
273
- ### M-14 Recipe Usage Integrity Improvements
274
-
275
- - Priority: Medium.
276
- - Goal: Make recipe usage tracking more explainable.
277
- - Direction:
278
- - Add fingerprint diff reason.
279
- - Add reset reason.
280
- - Consider optional last error.
281
- - Split launch counts by tool, spawn, and direct recipe.
282
- - Acceptance:
283
- - `inspect recipes view=summary verbose=true` shows whether usage refers to current recipe content.
284
- - Doctor can flag unused current meaning instead of stale old recipe history.
95
+ - Demonstrates correct mailbox loop semantics.
96
+ - Stays a recipe-authoring reference, not a product workflow catalog.
97
+ - Actor skill links it as the canonical worker pattern.
285
98
 
286
- ### M-15 Safer Command Warning Policy
99
+ ### M-04 Protocol Contract Fixtures
287
100
 
288
101
  - Priority: Medium.
289
- - Goal: Unify command-template diagnostics by severity and make warnings actionable without startup spam.
290
- - Severity:
291
- - `info`: portability.
292
- - `warning`: broad mutation, shell, or eval.
293
- - `error`: impossible, invalid, or unsafe repeat.
102
+ - Status: Done.
103
+ - Goal: Freeze the current protocol behavior with compact internal fixtures before further surface growth.
104
+ - Why now: `spawn`, `message`, `inspect`, mailbox contracts, artifacts, rooms, and run indexes now have enough shape to merit regression fixtures; schemas should document reality, not invent a new standard.
294
105
  - Direction:
295
- - Treat legitimate `bash` wrappers as expected trusted boundaries when already packaged or explicitly registered.
296
- - Keep routine shell wrapper notes out of startup warning blocks.
297
- - Surface shell/eval/destructive diagnostics through register-time warnings, doctor, and verbose recipe inspection.
106
+ - Add fixtures for representative run state, actor message, run inbox/outbox, room message/roster, mailbox contract, artifact manifest, and recipe summary.
107
+ - Add lightweight schema or shape validation only where it protects existing behavior.
298
108
  - Acceptance:
299
- - Command-template warnings include command label, reason, and suggested mitigation.
300
- - `register_tool` shows relevant warnings.
301
- - Recipe doctor aggregates warning policy.
302
- - Startup no longer emits large warning blocks only because recipes wrap `bash`.
109
+ - Public examples and fixtures validate in tests.
110
+ - No migration is forced.
111
+ - No external transport/MCP standard is introduced.
303
112
 
304
- ### M-16 Output And Log Size Governance
113
+ ### M-05 Follow-Up Deduplication Hardening
305
114
 
306
115
  - Priority: Medium.
307
- - Goal: Keep stdout, stderr, result, outbox, and actor-message previews bounded in agent context.
116
+ - Status: Done.
117
+ - Goal: Suppress duplicate terminal transitions and outbox follow-ups across watcher reloads, session restarts, or line-counter resets.
118
+ - Why now: Operator-facing observability should be calm and trustworthy as actor count grows.
308
119
  - Direction:
309
- - Centralize constants for body preview, outbox preview, inspector preview, and tail lines.
310
- - Keep verbose output opt-in.
311
- - Prefer files or artifacts for large bodies.
120
+ - Continue using event id and stateDir for deduplication where available.
121
+ - Preserve terminal handled semantics.
122
+ - Simulate watcher restart in tests.
312
123
  - Acceptance:
313
- - Actor messages and previews share consistent caps.
314
- - Verbose mode is explicit.
315
- - Large bodies do not flood normal tool output.
124
+ - Duplicate follow-up is suppressed after reasonable watcher reset.
125
+ - Terminal handled state remains effective.
126
+ - Tests cover restart and line-counter reset scenarios.
316
127
 
317
- ### M-17 Windows And Nix Portability Pass
128
+ ### M-06 Portability Reality Pass
318
129
 
319
130
  - Priority: Medium.
320
- - Goal: Strengthen current portability around FIFO, named-pipe, and mailbox-only paths without adding a new backend.
131
+ - Status: Done.
132
+ - Goal: Make current Linux/macOS/WSL/native-Windows behavior explicit without adding a new backend.
133
+ - Why now: Mailbox-only paths and named-pipe support exist; operators need accurate diagnostics, not hidden platform assumptions.
321
134
  - Direction:
322
135
  - Doctor flags FIFO-only recipes on native Windows.
323
- - Keep mailbox-only demo cross-platform.
324
- - Document platform matrix.
136
+ - Keep mailbox-only worker demo cross-platform.
137
+ - Document a small platform matrix.
325
138
  - Cover named-pipe adapter with injected sender where practical.
326
139
  - Acceptance:
327
140
  - Native Windows limitations are visible before launch.
328
141
  - Mailbox-only recipe works cross-platform.
329
142
  - Docs and tests cover the adapter split.
330
143
 
331
- ### M-18 State Corruption Recovery
332
-
333
- - Priority: Medium.
334
- - Goal: Add resilient JSON and JSONL state readers.
335
- - Direction:
336
- - Malformed JSONL lines should not kill entire inspect paths.
337
- - Corrupt JSON files should report diagnostics with paths.
338
- - Consider optional `.corrupt` quarantine helper.
339
- - Acceptance:
340
- - Inspect remains useful when partial state survives.
341
- - Corrupt paths are reported clearly.
342
- - Canonical state is not silently rewritten without explicit action.
343
-
344
- ### M-19 Recipe Import Graph Inspector
345
-
346
- - Priority: Medium.
347
- - Goal: Add focused inspection for recipe import graphs.
348
- - Surface:
349
- - `inspect target=recipes view=imports`.
350
- - `inspect target=recipes view=imports verbose=true`.
351
- - Acceptance:
352
- - Shows import graph, aliases, resolved paths, and shadowed imports.
353
- - Shows cyclic and depth diagnostics.
354
- - Helps debug packaged and user recipe composition.
355
-
356
- ### M-20 Spawn Preflight Mode
357
-
358
- - Priority: Medium.
359
- - Goal: Add dry-run launch planning for `spawn` and async recipe tool invocation.
360
- - Direction:
361
- - Resolve recipe, imports, args, artifacts, state dir, command graph, and mailbox metadata.
362
- - Do not start a process.
363
- - Return warnings and resolved launch plan.
364
- - Acceptance:
365
- - `preflight=true` returns a resolved plan.
366
- - No process is spawned.
367
- - Missing args and risky commands are reported before launch.
368
-
369
- ### M-21 Run Restart And Reattach Policy
370
-
371
- - Priority: Medium.
372
- - Goal: Clarify and implement safe behavior for reused `run_id` and `state_dir`.
373
- - Direction:
374
- - Active reuse fails closed.
375
- - Terminal restart with same id is allowed under explicit semantics.
376
- - Record generation or restarted time.
377
- - Preserve previous terminal-state policy.
378
- - Acceptance:
379
- - Active reuse remains blocked.
380
- - Terminal restart records generation or `restartedAt`.
381
- - Inspect shows restart semantics.
382
- - Docs are updated.
383
-
384
- ### M-22 Actor Address Helper CLI And Tooling
385
-
386
- - Priority: Medium.
387
- - Goal: Improve address normalization and diagnostics for recipe authors and tests.
388
- - Direction:
389
- - Add helper functions or inspect view for address validation.
390
- - Improve invalid-address diagnostics.
391
- - Acceptance:
392
- - Diagnostics include expected forms.
393
- - Examples cover branch, room, run, session, and tool addresses.
394
- - No new public address kinds are added.
395
-
396
- ### M-23 Room Compaction Metadata Improvements
144
+ ### M-07 Compiled Script Entrypoints
397
145
 
398
146
  - Priority: Medium.
399
- - Goal: Record richer room compaction metadata.
147
+ - Status: Done.
148
+ - Goal: Bring packaged script entrypoints under the build so installed npm recipes run against compiled runtime code.
149
+ - Why now: Recipes increasingly depend on helper scripts that import extension internals; compiling script logic closes the gap between source-tree development and installed package behavior.
400
150
  - Direction:
401
- - Track dropped count.
402
- - Track first and last kept timestamps.
403
- - Track configured max.
151
+ - Keep stable executable recipe paths through thin `scripts/*.mjs` shims.
152
+ - Keep substantive reusable script logic in compiled `lib/*.ts` modules so scripts stay lightweight runners and `dist/lib` is the JS-only runtime surface; allow self-contained application scripts to remain standalone `.mjs` when no reuse is expected.
153
+ - Keep `npm run build` checking packaged script entrypoint syntax while compiled module migration proceeds.
154
+ - Make installed scripts prefer `dist` runtime modules and avoid importing `.ts` from `node_modules`.
155
+ - Preserve source-tree developer ergonomics without requiring global install.
156
+ - Expose compiled JS as the default Node-compatible extension entrypoint and source TS/skill paths as optional metadata for TypeScript-native runtimes.
157
+ - Treat `dist/` as the JS-only distributive tree: mirror runtime assets (`scripts/`, `recipes/`, `fixtures/`, and `skills/`) there during build and point default package metadata at those dist assets.
158
+ - Track each converted script with a compiled module existence regression so shim drift is caught before packaging.
404
159
  - Acceptance:
405
- - `inspect room:<run> view=status verbose=true` shows compaction info.
406
- - Compaction never corrupts JSONL.
407
- - Tests cover low `PI_ACTORS_ROOM_MAX_MESSAGES`.
160
+ - `npm run build` covers packaged script logic, not only extension library code.
161
+ - Installed-script tests prove packaged recipes do not import TypeScript from `node_modules`.
162
+ - `npm run pack:dry` includes expected compiled/script files.
163
+ - Recipe paths remain stable or migrations are explicitly documented.
408
164
 
409
- ### M-24 Coordinator Follow-Up Deduplication
165
+ ## Explicitly Deferred
410
166
 
411
- - Priority: Medium.
412
- - Goal: Suppress duplicate terminal transitions and outbox follow-ups across watcher reloads, session restarts, or line-counter resets.
413
- - Direction:
414
- - Use event id and stateDir for deduplication where available.
415
- - Preserve terminal handled semantics.
416
- - Simulate watcher restart in tests.
417
- - Acceptance:
418
- - Duplicate follow-up is suppressed after reasonable watcher reset.
419
- - Terminal handled state remains effective.
420
- - Tests cover restart and line-counter reset scenarios.
167
+ These are valid ideas but not current focus. Reintroduce only with concrete evidence from real actor workflows.
421
168
 
422
- ### M-25 Documentation Refactor Runtime Contracts First
423
-
424
- - Priority: Medium.
425
- - Goal: Reorganize docs so implementation agents find stable contracts before examples.
426
- - Target order:
427
- - `docs/runtime-contracts.md`.
428
- - `docs/actor-messages.md`.
429
- - `docs/async-runs.md`.
430
- - `docs/tool-registry.md`.
431
- - `docs/template-recipes.md`.
432
- - `docs/command-templates.md`.
433
- - `docs/recipe-authoring.md`.
434
- - `docs/troubleshooting.md`.
435
- - Acceptance:
436
- - No polling-first examples.
437
- - Every example matches fixtures.
438
- - Docs distinguish protocol semantics from Pi UI commands.
439
- - No external standard or MCP work is introduced.
169
+ - Spawn preflight mode: useful later, but lower value than resilient inspect and mailbox-loop consolidation.
170
+ - Run restart/reattach policy: risky for isolation; defer until corruption recovery and protocol fixtures are stronger.
171
+ - Actor address helper CLI: keep diagnostics improving opportunistically inside existing parser/tests.
172
+ - Documentation refactor: defer until the canonical mailbox loop and worker recipe exist; avoid rewriting docs twice.
173
+ - Host-level tool unregistration: blocked on host API support.
174
+ - Branch-local checkpoint semantics: wait for real collaborative branch-runner experiments.
175
+ - Actor recipe feedback loop: keep advisory and operator-gated after real runs produce evidence.
440
176
 
441
177
  ## Suggested Milestone Order
442
178
 
443
- ```text
444
- Patch release:
445
- H-01..H-12
446
-
447
- Minor 0.23 — Contract consolidation:
448
- M-01, M-02, M-03, M-12, M-25
449
-
450
- Minor 0.24 — Runtime/message reliability:
451
- M-04, M-05, M-06, M-13, M-24
452
-
453
- Minor 0.25 — Operator hygiene:
454
- M-07, M-08, M-09, M-14, M-15, M-16
455
-
456
- Minor 0.26 — Inspector and state scaling:
457
- M-10, M-11, M-18, M-19, M-23
458
-
459
- Minor 0.27 — Portability and lifecycle polish:
460
- M-17, M-20, M-21, M-22
461
- ```
462
-
463
- ## Blocked Or Opportunistic Carry-Over
464
-
465
- ### Branch-Local Checkpoint Semantics
466
-
467
- - Priority: Low.
468
- - Blocked by: At least one real collaborative branch-runner async-run experiment.
469
- - Goal: Validate whether `failure: "branch"`, node-level `retry`, and `recover` cleanup are enough for branch-local validation and bounded reattempts.
470
- - Exit:
471
- - Record one decision: sufficient, documentation-only refinement needed, or propose one minimal command-template extension with tests.
472
-
473
- ### Host-Level Tool Unregistration
474
-
475
- - Priority: Low.
476
- - Blocked by: Host API support for custom tool unregistration.
477
- - Goal: Remove stale dynamically registered tool definitions completely when the host API supports it.
478
- - Direction:
479
- - Track pi extension API support for custom tool unregistration.
480
- - Replace active-tool deactivation fallback with real unregister when available.
481
- - Preserve current safe behavior: deleted tools should not remain active after reload.
482
- - Exit:
483
- - Deleting a recipe file removes the corresponding runtime tool definition and active-tool entry without session restart.
484
-
485
- ### Actor Recipe Feedback Loop
486
-
487
- - Priority: Low.
488
- - Goal: Turn actor recipe-context awareness into a practical improvement loop for packaged recipes and operator-owned recipe memory.
489
- - Direction:
490
- - After real multi-agent runs, capture whether child actors report that recipe/import/mailbox/role boundaries fit the task.
491
- - Keep the loop advisory and operator-gated.
492
- - Prefer small recipe, README, and skill refinements over scenario catalogs.
493
- - Exit:
494
- - At least one real run produces recipe-boundary feedback that is applied or explicitly rejected with rationale.
179
+ All milestone tasks in this backlog are currently complete. Reopen this section only with concrete follow-up work from real actor workflows, release preflight, or operator diagnostics.
package/CHANGELOG.md CHANGED
@@ -2,6 +2,45 @@
2
2
 
3
3
  ## Unreleased
4
4
 
5
+ ## 0.24.0: Reliability, Mailbox Workers, and Dist-First Packaging
6
+
7
+ - `[Prompts]` Clarified that recipe registry warnings are actionable maintenance: invalid or blocking recipes should be fixed, removed, or disabled rather than ignored.
8
+ - `[Backlog]` Pruned and refocused the backlog around reliability, mailbox-loop consolidation, protocol fixtures, follow-up deduplication, and portability reality checks.
9
+ - `[State]` Added resilient JSON/JSONL state reader helpers and routed room, inspector, runtime wake, run inbox, and observability outbox reads through them so malformed state records degrade instead of breaking previews; room status now reports state diagnostic counts and reader degradation behavior has direct regression coverage.
10
+ - `[Observability]` Deduplicated run outbox events by stable event id so line-counter resets do not replay already-seen follow-ups; stale dedupe state is pruned with terminal and missing runs.
11
+ - `[Mailbox Loop]` Added initial run/branch mailbox claim-and-handle helpers plus branch inbox claiming support, failed-handler transitions, standard stop-message detection, bounded message drains, duplicate-claim coverage, and a packaged `actor-worker` demo recipe for canonical mailbox loops.
12
+ - `[Scripts]` Added installed-package coverage proving the packaged `actor-worker` script uses compiled `dist` runtime modules instead of importing TypeScript from `node_modules`; `npm run build` now cleans stale `dist` output, mirrors packaged `scripts/`, `recipes/`, and `fixtures/` into `dist/`, and syntax-checks the built script entrypoints. The `actor-worker`, `async-runner`, `validate-recipe`, and `conformance` executables are now thin shims over compiled TypeScript entrypoint logic in `lib/actor-worker.ts`, `lib/async-runner.ts`, `lib/validate-recipe.ts`, and `lib/conformance.ts`, with build-output regressions for the compiled shim modules.
13
+ - `[Packaging]` Exposed optional `pi.sourceExtensions` metadata pointing at the root TypeScript entrypoint while keeping Node-compatible `pi.extensions` on compiled `dist` output.
14
+ - `[Context]` Clarified the project frame as an experimental self-evolution membrane for local agent capabilities, grounded in explicit actors, recipes, fixtures, skills, and inspectable state.
15
+ - `[Protocol]` Clarified dotted `channel.action` message types as the minimal action surface: scripts can often dispatch from `type` alone while agents may use `body` for free-form prompts.
16
+ - `[Recipes]` Fixed `pipeline-quorum-review` registry loading by inlining the quorum fanout over its `models` array instead of importing a nested repeated recipe with unresolved runtime values.
17
+ - `[Recipes]` Made Markdown recipe frontmatter more forgiving: `args` can be a comma-separated scalar and `defaults` can be a list of `key: value` entries, both normalizing to the canonical JSON recipe shape.
18
+ - `[Packaging]` Build output now mirrors packaged `skills/` into `dist/` alongside scripts, recipes, and fixtures so the JS-only distributive tree carries the project skills; package skill metadata now points at `dist/skills` with `pi.sourceSkills` preserving root TypeScript/source-tree paths, and README now documents the dist-first/source-optional package shape. The dist build pipeline now lives in `scripts/build-dist.mjs` instead of an inline package script, completing the compiled script entrypoint backlog slice.
19
+ - `[Docs]` Added a platform support matrix for mailbox-only, FIFO, named-pipe, and process-control behavior across Linux/macOS/WSL and native Windows, with regressions proving native Windows FIFO limits remain visible and the canonical worker recipe stays mailbox-only.
20
+ - `[Backlog]` Marked the reliability, mailbox loop, protocol fixture, portability, and compiled-entrypoint milestone set complete; future backlog additions should come from concrete actor workflow evidence.
21
+ - `[Scripts]` Migrated `recipe-utils`, `build-dist`, `locker`, `coordinator`, and `validate-recipe` command logic behind compiled TypeScript domain modules while preserving the stable `scripts/*.mjs` shim paths; project guidance frames this as deliberate standard-library growth with clear domain boundaries while keeping self-contained application scripts such as `music-player.mjs` standalone.
22
+ - `[Protocol]` Added compact protocol fixtures for actor messages, mailbox contracts, run inbox/outbox records, room messages/rosters, run state, recipe summaries, and artifact manifests with regression coverage.
23
+ - `[Skills]` Documented the passive-active skill evolution discipline: `actors` tracks extension mechanics while `swarm` tracks orchestration standards and lessons.
24
+
25
+ ## 0.23.0: Actor Manifests, Inspection, and Runtime Hygiene
26
+
27
+ - `[Tools]` Unified branch-envelope routing for direct branch messages and selected-recipient room multicast so both paths persist the same branch-local inbox shape before dispatching through the parent run mailbox.
28
+ - `[Async Runs]` Added attention semantics for coordinator-bound actor messages: `metadata.requires_response=true` now produces a follow-up while ordinary coordinator progress messages default to notification-level delivery.
29
+ - `[Registry]` Added `inspect target=recipes view=doctor` as an intentional recipe health surface with compact severity/action counts and structured verbose diagnostics.
30
+ - `[Async Runs]` Added artifact manifest resolution for string and object artifact declarations, including `exists`, `size`, `sha256`, and missing required artifact visibility in artifact inspection.
31
+ - `[Async Runs]` Added explicit terminal run retention controls via `control.archive` and `control.prune`, with active-run fail-closed behavior and optional artifact preservation during prune.
32
+ - `[Inspector]` Added stable event ids, needs-response markers, and session-local read markers to actor inspector previews and selected-item details.
33
+ - `[Registry]` Suppressed routine trusted `bash` wrapper diagnostics from startup warning notifications while keeping them available through recipe diagnostics surfaces.
34
+ - `[Async Runs]` Added a rebuildable run-state index for run listing and observability discovery, with corrupt-index fallback to recursive scan and nested-run-safe state directory entries.
35
+ - `[Testing]` Added `npm run conformance` for a compact CI-ready protocol conformance runner covering recipes, registry, spawn lifecycle, messaging, rooms, branch inboxes, ownership, artifacts, and attention semantics.
36
+ - `[Mailbox]` Added backward-compatible typed mailbox contracts with normalized inspection and advisory warnings for undeclared run message types.
37
+ - `[Output]` Centralized inspect, preview, and tool-output size limits so bounded output governance is shared across tools, room previews, and the actor inspector.
38
+ - `[Registry]` Added explicit mitigation guidance to command-template trust-boundary warnings for shells, eval modes, and broad filesystem mutation.
39
+ - `[Scripts]` Added top-of-file descriptions to packaged helper scripts so their purpose, boundaries, and policy ownership are clear when opened directly.
40
+ - `[Rooms]` Added room compaction metadata with dropped count, configured maximum, and first/last kept timestamps exposed through room status inspection.
41
+ - `[Recipes]` Improved usage telemetry with launch-kind counters (`tool`, `spawn`, `direct`) and explicit reset reasons when recipe content fingerprints change.
42
+ - `[Inspect]` Added `inspect target=recipes view=imports` to summarize recipe import aliases and source references for debugging recipe composition.
43
+
5
44
  ## 0.22.5: CI Stability Hotfix
6
45
 
7
46
  - `[Tests]` Stabilized the Windows named-pipe control endpoint regression by keeping its synthetic run alive longer under slower full-suite CI scheduling.
package/README.md CHANGED
@@ -43,6 +43,8 @@ Or from git:
43
43
  pi install git:github.com/llblab/pi-actors
44
44
  ```
45
45
 
46
+ The npm package is dist-first for JavaScript-only runtimes: default Pi metadata points at compiled `dist/` entrypoints and mirrored runtime assets. Source TypeScript and source skills remain in the package for TypeScript-native runtimes through optional source metadata.
47
+
46
48
  ## Address Surface
47
49
 
48
50
  Actors and coordination endpoints are addressed with compact route strings:
@@ -161,7 +163,7 @@ The terminal actor inspector is hidden by default. When opened without an explic
161
163
  /actors-inspect 3
162
164
  ```
163
165
 
164
- The table is compact and optimistic by default: bounded route/type/summary/body previews, capped noisy room rows, branch-local inbox previews, and an inline roster summary in the form `name/role` that wraps only when needed. Active roster members use the target color; members that sent `actor.leave` remain visible as inactive/muted participants from the current run. Use `unread` to focus queued branch inbox work and `branch <name>` / `current-branch <name>` to focus one branch's room/direct/inbox traffic. `/actors-inspect <number>` opens the selected row as a full-message view; toggle again to return to the table or close it. Actor display names come from room `actor.join` roster metadata or branch addresses, keeping debugger output plain and name-driven.
166
+ The table is compact and optimistic by default: bounded route/type/summary/body previews, capped noisy room rows, branch-local inbox previews, stable event ids in selected-message details, and an inline roster summary in the form `name/role` that wraps only when needed. Active roster members use the target color; members that sent `actor.leave` remain visible as inactive/muted participants from the current run. Use `unread` to focus queued branch inbox work and `branch <name>` / `current-branch <name>` to focus one branch's room/direct/inbox traffic. Rows with `metadata.requires_response=true` show a `!` attention marker. `/actors-inspect <number>` opens the selected row as a full-message view and marks it read for the current session filter; toggle again to return to the table or close it. Actor display names come from room `actor.join` roster metadata or branch addresses, keeping debugger output plain and name-driven.
165
167
 
166
168
  ## Registry Model
167
169
 
@@ -255,6 +257,17 @@ Use mailbox declarations when an actor has a stable conversational surface.
255
257
 
256
258
  Core actor state, inspection, foreground tools, and basic async runs are portable Node.js behavior. Run-local messaging and stop/kill use a platform adapter under the same `message` API: Unix-compatible recipes can use their existing local control endpoint, while native Windows recipes can expose a Windows-native endpoint in run state. Some packaged scripts still depend on Unix tools and are WSL/Linux/macOS-only until migrated; their public recipe surface should stay `spawn` / `message` / `inspect` either way.
257
259
 
260
+ | Surface | Linux/macOS/WSL | Native Windows |
261
+ | --- | --- | --- |
262
+ | Foreground tools, recipe discovery, inspect | Supported | Supported |
263
+ | Async runs and file-backed state | Supported | Supported |
264
+ | Mailbox-only actors and worker recipe | Supported | Supported |
265
+ | FIFO control endpoints | Supported | Not supported; use mailbox or named pipe |
266
+ | Named-pipe control endpoints | Not needed | Supported when recipe exposes one |
267
+ | Process cancel/kill | Process group signal with pid fallback | Windows process-tree adapter |
268
+
269
+ Packaged recipes should prefer mailbox/wake behavior for portable control. Recipes that require FIFO, Unix shell tools, or platform-specific media backends should make that limitation visible in docs or diagnostics before launch.
270
+
258
271
  ## Safety Boundary
259
272
 
260
273
  `pi-actors` is local-first, not sandbox-first.
@@ -0,0 +1,13 @@
1
+ {
2
+ "to": "branch:demo/reviewer",
3
+ "from": "run:demo",
4
+ "type": "task.assign",
5
+ "summary": "Review the current slice",
6
+ "body": {
7
+ "task": "Check mailbox loop semantics"
8
+ },
9
+ "correlation_id": "task-001",
10
+ "metadata": {
11
+ "requires_response": true
12
+ }
13
+ }
@@ -0,0 +1,9 @@
1
+ {
2
+ "report": {
3
+ "path": "{state_dir}/report.md",
4
+ "kind": "markdown",
5
+ "media_type": "text/markdown",
6
+ "required": true
7
+ },
8
+ "journal": "{state_dir}/journal.jsonl"
9
+ }