@llblab/pi-actors 0.23.0 → 0.24.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (158) hide show
  1. package/AGENTS.md +125 -60
  2. package/BACKLOG.md +133 -176
  3. package/CHANGELOG.md +27 -0
  4. package/README.md +13 -0
  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 +3 -2
  15. package/dist/lib/actor-inspector-tui.js +5 -32
  16. package/dist/lib/actor-rooms.d.ts +8 -0
  17. package/dist/lib/actor-rooms.js +64 -20
  18. package/dist/lib/actor-worker.d.ts +13 -0
  19. package/dist/lib/actor-worker.js +86 -0
  20. package/dist/lib/async-runner.d.ts +5 -0
  21. package/dist/lib/async-runner.js +134 -0
  22. package/dist/lib/async-runs.js +9 -28
  23. package/dist/lib/conformance.d.ts +12 -0
  24. package/dist/lib/conformance.js +28 -0
  25. package/dist/lib/coordinator.d.ts +5 -0
  26. package/dist/lib/coordinator.js +574 -0
  27. package/dist/lib/locker.d.ts +5 -0
  28. package/dist/lib/locker.js +310 -0
  29. package/dist/lib/mailbox-loop.d.ts +41 -0
  30. package/dist/lib/mailbox-loop.js +62 -0
  31. package/dist/lib/observability.d.ts +2 -2
  32. package/dist/lib/observability.js +51 -53
  33. package/dist/lib/prompts.d.ts +1 -1
  34. package/dist/lib/prompts.js +1 -1
  35. package/dist/lib/recipe-references.js +25 -2
  36. package/dist/lib/recipe-utils.d.ts +5 -0
  37. package/dist/lib/recipe-utils.js +385 -0
  38. package/dist/lib/runtime-notifier.js +3 -7
  39. package/dist/lib/state-readers.d.ts +21 -0
  40. package/dist/lib/state-readers.js +74 -0
  41. package/dist/lib/tools.js +1 -1
  42. package/dist/lib/validate-recipe.d.ts +6 -0
  43. package/dist/lib/validate-recipe.js +104 -0
  44. package/dist/recipes/actor-worker.json +35 -0
  45. package/dist/recipes/coordinator-locker.json +45 -0
  46. package/dist/recipes/lens-swarm.json +66 -0
  47. package/dist/recipes/locker.json +45 -0
  48. package/dist/recipes/music-player.json +38 -0
  49. package/dist/recipes/pipeline-architect-coordinator.json +95 -0
  50. package/dist/recipes/pipeline-artifact-bundle.json +100 -0
  51. package/dist/recipes/pipeline-artifact-report.json +58 -0
  52. package/dist/recipes/pipeline-artifact-write.json +72 -0
  53. package/dist/recipes/pipeline-async-run-ops.json +70 -0
  54. package/dist/recipes/pipeline-checkpoint-continuation.json +67 -0
  55. package/dist/recipes/pipeline-development-tasking.json +81 -0
  56. package/dist/recipes/pipeline-docs-maintenance.json +80 -0
  57. package/dist/recipes/pipeline-media-library.json +59 -0
  58. package/dist/recipes/pipeline-quorum-review.json +79 -0
  59. package/dist/recipes/pipeline-release-readiness.json +110 -0
  60. package/dist/recipes/pipeline-release-summary.json +88 -0
  61. package/dist/recipes/pipeline-repo-health.json +89 -0
  62. package/dist/recipes/pipeline-research-synthesis.json +94 -0
  63. package/dist/recipes/pipeline-review-readiness.json +54 -0
  64. package/dist/recipes/pipeline-room-swarm.json +50 -0
  65. package/dist/recipes/subagent-artifact.json +32 -0
  66. package/dist/recipes/subagent-checkpoint.json +33 -0
  67. package/dist/recipes/subagent-conflict-report.json +32 -0
  68. package/dist/recipes/subagent-contradiction-map.json +33 -0
  69. package/dist/recipes/subagent-critic.json +35 -0
  70. package/dist/recipes/subagent-evidence-map.json +33 -0
  71. package/dist/recipes/subagent-followup.json +33 -0
  72. package/dist/recipes/subagent-judge.json +33 -0
  73. package/dist/recipes/subagent-merge.json +33 -0
  74. package/dist/recipes/subagent-message.json +34 -0
  75. package/dist/recipes/subagent-normalize.json +31 -0
  76. package/dist/recipes/subagent-plan.json +33 -0
  77. package/dist/recipes/subagent-prompt.json +28 -0
  78. package/dist/recipes/subagent-quorum.json +43 -0
  79. package/dist/recipes/subagent-review-coordinator.json +114 -0
  80. package/dist/recipes/subagent-review.json +37 -0
  81. package/dist/recipes/subagent-task-card.json +35 -0
  82. package/dist/recipes/subagent-tools.json +27 -0
  83. package/dist/recipes/subagent-verify.json +34 -0
  84. package/dist/recipes/subagents-prompts.json +51 -0
  85. package/dist/recipes/utility-actor-message.json +23 -0
  86. package/dist/recipes/utility-artifact-manifest.json +16 -0
  87. package/dist/recipes/utility-artifact-write.json +16 -0
  88. package/dist/recipes/utility-changelog-head.json +11 -0
  89. package/dist/recipes/utility-changelog-section.json +13 -0
  90. package/dist/recipes/utility-coordinator-lock-snapshot.json +13 -0
  91. package/dist/recipes/utility-git-log.json +11 -0
  92. package/dist/recipes/utility-git-status.json +9 -0
  93. package/dist/recipes/utility-jsonl-tail.json +10 -0
  94. package/dist/recipes/utility-markdown-index.json +14 -0
  95. package/dist/recipes/utility-package-summary.json +11 -0
  96. package/dist/recipes/utility-playlist-build.json +17 -0
  97. package/dist/recipes/utility-playlist-scan.json +11 -0
  98. package/dist/recipes/utility-run-ops-snapshot.json +17 -0
  99. package/dist/recipes/utility-run-state-files.json +13 -0
  100. package/dist/recipes/utility-run-summary.json +11 -0
  101. package/dist/recipes/utility-skill-summary.json +13 -0
  102. package/dist/recipes/utility-validate-recipe.json +13 -0
  103. package/dist/recipes/utility-validation-wrapper.json +13 -0
  104. package/dist/scripts/actor-worker.mjs +31 -0
  105. package/dist/scripts/async-runner.mjs +31 -0
  106. package/dist/scripts/build-dist.mjs +33 -0
  107. package/dist/scripts/conformance.mjs +33 -0
  108. package/dist/scripts/coordinator.mjs +31 -0
  109. package/dist/scripts/locker.mjs +33 -0
  110. package/dist/scripts/music-player.mjs +964 -0
  111. package/dist/scripts/recipe-utils.mjs +31 -0
  112. package/dist/scripts/validate-recipe.mjs +34 -0
  113. package/dist/skills/actors/SKILL.md +377 -0
  114. package/dist/skills/swarm/SKILL.md +467 -0
  115. package/dist/skills/swarm/references/development-swarm.md +596 -0
  116. package/docs/actor-messages.md +2 -2
  117. package/docs/async-runs.md +11 -0
  118. package/docs/template-recipes.md +1 -1
  119. package/fixtures/protocol/actor-message-branch.json +13 -0
  120. package/fixtures/protocol/artifact-manifest.json +9 -0
  121. package/fixtures/protocol/mailbox-contract.json +15 -0
  122. package/fixtures/protocol/recipe-summary.json +16 -0
  123. package/fixtures/protocol/room-message.json +11 -0
  124. package/fixtures/protocol/room-roster.json +11 -0
  125. package/fixtures/protocol/run-inbox-message.json +9 -0
  126. package/fixtures/protocol/run-outbox-event.json +9 -0
  127. package/fixtures/protocol/run-state.json +10 -0
  128. package/index.ts +3 -0
  129. package/lib/actor-inspector-tui.ts +11 -34
  130. package/lib/actor-rooms.ts +88 -18
  131. package/lib/actor-worker.ts +118 -0
  132. package/lib/async-runner.ts +173 -0
  133. package/lib/async-runs.ts +12 -22
  134. package/lib/conformance.ts +46 -0
  135. package/lib/coordinator.ts +664 -0
  136. package/lib/locker.ts +340 -0
  137. package/lib/mailbox-loop.ts +148 -0
  138. package/lib/observability.ts +24 -19
  139. package/lib/prompts.ts +1 -1
  140. package/lib/recipe-references.ts +37 -2
  141. package/lib/recipe-utils.ts +486 -0
  142. package/lib/runtime-notifier.ts +4 -6
  143. package/lib/state-readers.ts +93 -0
  144. package/lib/tools.ts +1 -1
  145. package/lib/validate-recipe.ts +110 -0
  146. package/package.json +10 -2
  147. package/recipes/actor-worker.json +35 -0
  148. package/recipes/pipeline-quorum-review.json +12 -7
  149. package/scripts/actor-worker.mjs +31 -0
  150. package/scripts/async-runner.mjs +11 -201
  151. package/scripts/build-dist.mjs +33 -0
  152. package/scripts/conformance.mjs +21 -35
  153. package/scripts/coordinator.mjs +15 -625
  154. package/scripts/locker.mjs +20 -332
  155. package/scripts/recipe-utils.mjs +17 -477
  156. package/scripts/validate-recipe.mjs +18 -121
  157. package/skills/actors/SKILL.md +8 -3
  158. package/skills/swarm/SKILL.md +3 -1
package/AGENTS.md CHANGED
@@ -2,81 +2,146 @@
2
2
 
3
3
  ## Meta-Protocol Principles
4
4
 
5
- - `Constraint-Driven Evolution`: Add structure when real project constraints justify it
6
- - `Single Source of Truth`: Keep durable protocol, open work, completed delivery, and docs in separate files
7
- - `Context Hygiene`: Compress stale context before it becomes coordination drag
8
- - `Boundary Clarity`: README is the human entrypoint, `AGENTS.md` is durable protocol, `BACKLOG.md` is open work, and `CHANGELOG.md` is delivery history
5
+ - `Constraint-Driven Evolution`: Add structure when real project constraints justify it.
6
+ - `Single Source of Truth`: Keep durable protocol, open work, completed delivery, and docs in separate files.
7
+ - `Context Hygiene`: Compress stale context before it becomes coordination drag.
8
+ - `Boundary Clarity`: README is the human entrypoint, `AGENTS.md` is durable protocol, `BACKLOG.md` is open work, and `CHANGELOG.md` is delivery history.
9
9
 
10
10
  ## Concept
11
11
 
12
- `pi-actors` is a local-first actor runtime and orchestrator for pi. It wraps trusted local programs, scripts, services, pipelines, and recipes as addressable actors that agents can `spawn`, control with typed `message` envelopes, and observe with `inspect`. It also persists user/agent-registered actor-control tools as recipe files under `~/.pi/agent/recipes`, giving agents durable operational muscle memory for launching and managing the local actor zoo.
12
+ `pi-actors` is a local-first actor runtime and orchestrator for Pi. It wraps trusted local programs, scripts, services, pipelines, and recipes as addressable actors that agents can `spawn`, control with typed `message` envelopes, and observe with `inspect`. It also persists user/agent-registered actor-control tools as recipe files under `~/.pi/agent/recipes`, giving agents durable operational muscle memory for launching and managing the local actor zoo.
13
+
14
+ Treat this extension as an experimental self-evolution membrane for the agent harness: a way for agents that are not pretrained on local workflows to acquire, preserve, inspect, and refine operational capabilities through explicit local actors, recipes, fixtures, skills, and state rather than hidden assumptions. Keep that potential grounded in small, testable, operator-visible protocol slices.
13
15
 
14
16
  ## Topology
15
17
 
16
- - `/index.ts`: Minimal extension coordinator/composition root; it wires live pi ports and should avoid owning domain behavior
17
- - `/lib/*.ts`: Flat Domain DAG modules for cohesive reusable behavior; `command-templates.ts` mirrors the shared portable command-template standard, `schema.ts` owns tool arg declarations and placeholder-derived tool schemas, `identity.ts` owns names, `config.ts` owns config persistence, `registry.ts` owns registry register/update/delete use-cases, `output.ts` owns result formatting/truncation, `execution.ts` owns registered-tool execution, `recipe-references.ts` owns template recipe reference detection and path resolution, `async-runs.ts` owns async run state, `actor-rooms.ts` owns room timelines/rosters/communication snapshots with burst-safe roster and branch snapshot writes, locked branch-local inbox mutations, plus status reads that avoid parsing full timelines, `actor-inspector-tui.ts` owns compact terminal previews, branch-inbox unread/current-branch filtering, and selected-message inspection for actor communications, `observability.ts` owns ambient run summaries, `temp.ts` owns pi-agent temp cleanup, `prompts.ts` owns LLM-facing copy, `tools.ts` owns pi-facing tool definitions for both `register_tool`, async run primitives, and generated runtime tools, `runtime.ts` owns load/conflict/registration coordination, and `paths.ts` owns config/tmp path resolution
18
- - `index.ts` should import local domains as namespaces (`import * as CommandTemplates from "./lib/command-templates.ts"`) so orchestration reads through domain names instead of flat helper imports
19
- - `/scripts/*.mjs`: Thin helper processes for detached async run execution; keep policy in registered tool config and reusable logic in `/lib`
20
- - `/recipes/*.json`: Packaged standard recipe library; keep recipes optional, composable, and policy-light; prefer public args for operator/agent decisions instead of baking project-specific prompts, file names, or concrete model-version defaults into reusable recipes
21
- - `/skills/actors/SKILL.md`: Dense practical reference for operating pi-actors itself
22
- - `/skills/swarm/SKILL.md`: Bundled methodology skill for multi-agent standards, strategies, and portable examples; keep it theory/strategy-oriented while pi-actors recipes/scripts provide the local execution engine
23
- - `/scripts/music-player.mjs`: Standard helper script for the packaged music-player recipe; keep it executable and avoid restoring parallel shell-wrapper variants unless a concrete portability need appears
24
- - `/tests/*.test.ts`: Focused regression tests for pure domains
25
- - `/README.md`: Human-facing install, usage, and runtime semantics
26
- - `/BACKLOG.md`: Canonical open work; keep it empty when no actionable or gated work remains
27
- - `/CHANGELOG.md`: Completed delivery history
28
- - `/docs/README.md`: Documentation index
18
+ - `/index.ts`: Minimal extension coordinator/composition root. It wires live pi ports and should avoid owning domain behavior.
19
+
20
+ ## Domain Modules
21
+
22
+ - `/lib/*.ts`: Flat Domain DAG modules for cohesive reusable behavior.
23
+ - `command-templates.ts`: portable command-template execution graph.
24
+ - `schema.ts`: tool arg declarations and placeholder-derived schemas.
25
+ - `identity.ts`, `paths.ts`, `config.ts`: names, paths, and persistence.
26
+ - `registry.ts`, `runtime.ts`: register/update/delete, load/conflict/registration coordination.
27
+ - `execution.ts`, `output.ts`, `limits.ts`: registered-tool execution and bounded output.
28
+ - `recipe-references.ts`, `recipe-discovery.ts`, `recipe-usage.ts`: recipe graph, discovery, and usage metadata.
29
+ - `async-runs.ts`, `runtime-notifier.ts`, `mailbox-loop.ts`: detached run state, wake notifications, and mailbox worker helpers.
30
+ - `actor-rooms.ts`, `actor-inspector-tui.ts`, `observability.ts`: rooms, communication previews, and ambient run status.
31
+ - `prompts.ts`, `tools.ts`, `temp.ts`: LLM-facing copy, pi-facing tool definitions, and temp cleanup.
32
+
33
+ ## Repo Surfaces
34
+
35
+ - `/scripts/*.mjs`: Stable executable shims for detached/helper processes.
36
+ - `/lib/*.ts`: Compiled domain and script-entrypoint logic. Keep `scripts/*.mjs` lightweight and move substantive behavior into named domain modules so `dist/lib` is the JS-only runtime surface. This intentionally grows a standard library: script-born behavior should gain a clear domain name when reuse is plausible. Exception: self-contained application/build scripts with no expected second consumer, such as `music-player.mjs` or `build-dist.mjs`, may remain standalone `.mjs` files.
37
+ - `/recipes/*.json`: Packaged standard recipe library. Keep recipes optional, composable, policy-light, and caller-configurable.
38
+ - `/skills/actors/SKILL.md`: Dense practical reference for operating pi-actors itself.
39
+ - `/skills/swarm/SKILL.md`: Bundled methodology skill for multi-agent standards, strategies, and portable examples.
40
+ - `/tests/*.test.ts`: Focused regression tests for pure domains.
41
+ - `/README.md`: Human-facing install, usage, and runtime semantics.
42
+ - `/BACKLOG.md`: Canonical open work; only completable future work.
43
+ - `/CHANGELOG.md`: Completed delivery history.
44
+ - `/docs/README.md`: Documentation index.
29
45
 
30
46
  ## Operating Principles
31
47
 
32
- - Prefer explicit migration boundaries over silent user-config rewrites
33
- - Keep published documentation portable: use `~`, `<repo>`, or relative paths instead of machine-local absolute paths
34
- - Preserve runtime output discipline because tool output flows directly into agent context
35
- - Keep the project lens local-first and cybernetic: agents wrap durable local capabilities as actors, then use semantic tools and messages instead of repeatedly reconstructing shell commands
36
- - Design recipes as agent-callable tools: make prompts, scopes, paths, models, and policy knobs public args/defaults when the caller should decide them at invocation time
37
-
38
- ## Durable Conventions
39
-
40
- - `Knowledge surface separation`: pi-actors has distinct knowledge surfaces with different context-entry behavior: injected prompt is always present and should stay a tiny bootstrap/reminder; packaged `actors` skill is auto-matched by name/description and should signal that its body is the highest-density practical guide for operating the extension plus the shortest navigator to bundled recipes; packaged `swarm` skill is auto-matched for multi-agent methodology, strategies, standards, and portable examples; README is the human entrypoint explaining concept, rhythm, benefits, and scenarios but is not automatically in context; `/docs` are detailed transportable standards read on demand; `AGENTS.md` is project context and architectural constraints for agents changing the repo | Trigger: Editing prompt copy, README, docs, skills, or project context | Action: Keep each surface on its own wave, avoid duplicating prompt and skill headers, keep the actors skill recipe navigator compact and concrete, avoid duplicating scenario catalogs or changelog narratives in the actors skill, avoid turning the prompt into docs, keep multi-agent methodology in swarm-oriented guidance rather than the actors skill, keep packaged extension skill metadata versions synchronized with `package.json` version, and avoid extra colons in skill frontmatter scalar lines because skill formatters treat them poorly
41
- - `Tool registry is executable muscle memory`: `~/.pi/agent/recipes/*.json` is the persistent user tool surface by location: every recipe in that agent root is automatically registered as an agent tool across sessions, and `register_tool` creates/updates/deletes recipe files there under the hood | Trigger: Any runtime registration, recipe discovery, migration, docs, skill, prompt, or recipe authoring work | Action: Treat the directory like `MEMORY.md` for executable habits; preserve filename identity, atomic writes, explicit operator-gated migration paths, and keep recipe files transportable by making exposure a function of location rather than recipe content; packaged/ad hoc recipes outside the agent root are components, not tools
42
- - `Current runtime contract`: Register trusted command templates with tool names from registry keys, placeholder-derived args, progressive typed arg declarations, inline/default/`??`/ternary config fallback, placeholder-derived numeric node controls, split-first command-arg construction, sequential or `parallel: true` composition, direct no-shell execution, optional per-node `when`, optional per-node positive `timeout` disabled by default, lightweight warnings for obvious trusted-executable risk shapes, per-node `delay`, bounded leaf/node `retry`, `failure: "continue|branch|root"` propagation, `recover` cleanup between retry attempts, template recipes with explicit `async: true` detached mode, actor-oriented `spawn`/`message`/`inspect` tools with run-local JSONL outbox messages, Unix FIFO send, graceful cancel, and force kill, generic detached run primitives with process-group cancellation, injected async `{run_id}` and `{state_dir}` values, coordinator-scoped event-driven observability with at least one triangle per active async run and extra triangles for active parallel branches, runtime-inferred `command.done` bubbling for packaged multi-agent fanout, terminal follow-ups for `done`/`failed`/unhandled `killed`/`exited` states, recipe-persistence suggestions for successful direct inline/ad hoc `spawn` runs and successful recipes outside the durable user recipe root, named recipe `artifacts`, recipe `mailbox` metadata, `template` recipe references, recipe-layer `imports`, file-backed async recipe JSONL context bundles for child `pi -p` actors with raw entry/import recipes and `"you_are_here": true`, co-located recipe entries, `~/.pi/agent/recipes/*.json` template recipe files, run state under `~/.pi/agent/tmp/pi-actors/runs`, and `{file}` as the canonical local file path arg | Trigger: Changing registration or invocation behavior | Action: Keep README, command-template docs, template-recipe docs, async-run docs, actor-message docs, implementation, and migration notes aligned
43
- - `Typed arg authoring`: Typed args support `string`, `path`, `int`, `number`, `bool`, and `enum(...)` plus two equivalent readability styles: metadata-first (`args` + `defaults` + simple `{name}` placeholders) for long command lines, and inline-first (`{name:type=default}` placeholders) for compact one-property templates | Trigger: Changing arg parsing, docs, schema generation, or registry serialization | Action: Preserve both styles, keep explicit `args` type declarations higher priority than inline placeholder types, and make breaking cleanup explicit when removing old arg shapes
44
- - `Template recipe graph`: The valid execution chain is `tool → template → recipe → run → template`; file-backed and co-located recipes are storage variants of that chain | Trigger: Adding registry bindings, recipes, docs, or runtime shortcuts | Action: Keep command templates synchronous and portable, use `async: true` as the detached run switch, require every recipe to own `template` directly, and reject cyclic shortcuts where saved recipes point back at generated tools
45
- - `Layer boundary discipline`: Command-template evolution must be separated from template-recipe configuration and async-run lifecycle configuration | Trigger: Adding syntax, placeholders, imports, async controls, or docs | Action: Put portable execution graph semantics in `docs/command-templates.md`, recipe storage/import/default/reference behavior in `docs/template-recipes.md`, and detached lifecycle/state/IPC behavior in `docs/async-runs.md`; type imported recipes as command-template-shaped recipe definitions, not async-run instances
46
- - `Executable script recipes`: Recipe templates may point directly at executable helper scripts, including JavaScript `.mjs` files with shebangs; do not prefix such recipes with `node` unless the script is intentionally not executable | Trigger: Adding or editing script-backed recipes and docs | Action: Keep the script executable bit, call `{repo}/scripts/name.mjs ...` directly, keep the standard library on one maintained wrapper per capability unless a second wrapper has a concrete platform reason, and ship compiled `dist/lib/*.js` runtime modules for installed npm script entrypoints and ensure those scripts do not import `.ts` files from under `node_modules` through Node native type stripping
47
- - `Registry safety boundaries`: Tool definitions use `template`, not `script`, and built-in/core tool names must not be shadowed | Trigger: Loading/editing persisted config or registration logic | Action: Reject legacy `script` entries explicitly, avoid silent user-config rewrites outside the repo, and keep conflict checks before persistence/runtime registration
48
- - `Async run observability`: Ambient triangles count active async work units across the visible run tree: each running async run contributes at least one triangle, reported active parallel command/subagent branches contribute the visible branch count when greater than one, and descendant `pi -p` subagent processes are folded in so coordinator-plus-workers scenarios expand beyond a single coordinator marker. Event-driven terminal/outbox watchers should initiate follow-up for unhandled terminal completion/failure states, failed or in-flight `command.done` branch completions, and coordinator-bound script-authored messages with bounded body previews; actor `message` is the explicit coordinator-to-run command channel paired with these upward events. Do not restore busy-polling loops, sleep-then-status smoke examples, duplicate follow-ups for final successful leaf commands, or duplicate follow-ups for `cancel`, `kill`, or control-stop actions already handled by synchronous tool results. | Trigger: Changing async run UI, notifications, actor-message routing, or smoke-test interpretation | Action: Preserve branch-aware triangles from `progress.activeSubagents`, runtime-inferred branch bubbling for packaged fanout completion, process-tree expansion for coordinator-launched workers, terminal notifications as event-driven behavior, and docs/examples that teach reactive run→coordinator→message loops before sleep-polling patterns.
49
- - `Communication direction`: The design target is an organic universal message layer across sync tasks, async runs, branches, tools, and coordinators. Breaking changes are allowed to compress concepts, remove accidental duplication, and make duplex communication symmetric where the domain is symmetric. | Trigger: Designing APIs or recipes that communicate | Action: Prefer a concentrated actor/message protocol (`spawn`, `message`, `inspect`, addressed endpoints, typed message envelopes, mailbox accepts/emits) over exposing FIFO/outbox/status mechanics directly; use one envelope for upward, downward, lateral, parent/branch, and branch/parent messages; absorb runtime async primitives into actor API instead of preserving parallel public concepts.
50
- - `Runtime IO discipline`: Tool stdout and temp state must stay bounded and local | Trigger: Changing execution, formatting, temp files, run state, logs, or artifacts | Action: Keep tail truncation/full-output temp files/failure formatting intact; keep extension-owned temp state under `~/.pi/agent/tmp/pi-actors` unless explicitly overridden
51
- - `Backlog is planning, not history`: `BACKLOG.md` should contain only completable future work with current task/scope/exit criteria; completed delivery history belongs in `CHANGELOG.md`, and durable or evergreen behavior belongs in `AGENTS.md`, README, docs, or skills | Trigger: Editing backlog or reconciling completed slices | Action: Remove historical progress narratives, version-scoped headings, watch-mode/monitoring principles, open-ended “continue evolving” items, and conditional “if usage proves” notes unless they are framed as a concrete gated task; keep priority order and prefer an 80/20 focus list when many remaining tasks compete for attention
52
- - `Changelog signal only`: Changelog bullets describe meaningful user/operator/developer changes, not release bookkeeping | Trigger: Preparing or editing release notes | Action: Do not add bullets that only say package, lockfile, or packaged skill metadata versions were bumped for this package; the version heading already carries that information. Mention dependency or package metadata changes only when the metadata change itself has user-visible or operational meaning
53
- - `Release artifact hygiene`: PR/release summaries become stale during active branch work and do not belong in the repository documentation tree | Trigger: Preparing release notes or PR bodies | Action: Create temporary/operator-facing artifacts outside the repo only during explicit release finalization; keep durable release evidence in `CHANGELOG.md` and open gates in `BACKLOG.md`
54
- - `Graceful actor retirement`: Coordinator/helper actors that exist only to supervise a bounded worker tree should have explicit retirement semantics instead of relying on the operator or LLM to remember cleanup | Trigger: Designing coordinator recipes, helper actors, worker fanout, locker-backed swarms, or auto-stop behavior | Action: Make retirement opt-in through recipe/run metadata, keep candidates blocked while active command-template branches or descendant `pi -p` workers are still running, retire only after observed child actors are terminal and outputs are flushed, prefer graceful control messages before process termination, record retirement events, and never infer retirement for persistent services or backlog implementers
55
- - `Persistent implementer workflows are recipe composition`: Backlog implementer scenarios should be launched through reusable component recipes, not one-off scripts or ad hoc shell orchestration | Trigger: Designing implementer swarms, backlog workers, coordinator-assigned task loops, or related recipes | Action: Compose cells such as `coordinator-locker`, subagent launchers, and actor-message utilities; preserve JSON envelope object shape across handoffs; add missing reusable component recipes only when needed; update the actors skill launcher map with supported scenarios
56
- - `Modular coordination and separate lock state`: The coordination of multi-agent workflows is split into two cleanly decoupled layers: the active coordinator and the stateful locker. The locker manages task queueing and resource lock leases over Unix FIFO/pipes without project policy. The coordinator script (`scripts/coordinator.mjs`) manages process pools, rooms, and lifecycles, and supports different pluggable mode strategies (`pipeline`, `fanout`, `pool`, `consensus`). | Trigger: Modifying coordination scripts, queues, locking, or parallel worker flows | Action: Keep the locker generic and thin, and implement all orchestration strategy rules inside the multi-mode coordinator.
57
- - `Active branch inbox queues`: Direct branch messages are active, work-triggering inbox queues rather than passive files. During subagent execution, the coordinator atomically claims (`claimed`), assigns missing message IDs, injects, and handles (`handled`/`failed`) queued branch-local direct messages to allow interactive/resumable worker workflows. | Trigger: Delivering branch messages, executing subagents, or updating branch queues | Action: Ensure direct messages can continue or wake long-lived branch runners, guard branch-local inbox append/status rewrites with the branch inbox lock, and keep the FIFO queue status transitions clean and fully tested.
58
- - `Recipe library growth is demand-driven`: Packaged recipes should grow from concrete repeated task patterns, not speculative scenario catalogs | Trigger: Adding packaged utilities, pipelines, or component recipes | Action: Prefer existing component composition, keep recipes policy-light with caller-owned prompts/models/paths/knobs, avoid scenario-specific scripts when existing components suffice, and document new reusable launch scenarios in the actors skill only after the recipe exists
59
- - `Context sync`: Meaningful implementation or docs changes must reconcile `BACKLOG.md`, `CHANGELOG.md`, README, and docs navigation | Trigger: Closing, narrowing, or discovering work | Action: Run the context validator before final status when practical
60
- - `Public path hygiene`: Published docs must not include machine-local absolute paths | Trigger: Adding validation commands, examples, or local instructions to README/AGENTS/docs/changelog | Action: Use `~/.pi/...`, `<repo>/...`, `${SKILL_DIR}/...`, or relative paths
48
+ - Prefer explicit migration boundaries over silent user-config rewrites.
49
+ - Keep published documentation portable: use `~`, `<repo>`, or relative paths instead of machine-local absolute paths.
50
+ - Preserve runtime output discipline because tool output flows directly into agent context.
51
+ - Keep the project lens local-first and cybernetic: agents wrap durable local capabilities as actors, then use semantic tools and messages instead of repeatedly reconstructing shell commands.
52
+ - Design recipes as agent-callable tools: make prompts, scopes, paths, models, and policy knobs public args/defaults when the caller should decide them at invocation time.
53
+ - Decompose oversized bullets into sublists or hierarchy; long flat list items are a context-smell.
54
+
55
+ ## Knowledge Surfaces
56
+
57
+ - Injected prompt: tiny bootstrap/reminder, never full docs.
58
+ - README: public face of the project. Keep it current, focused, pruned, and limited to highest-signal scenarios.
59
+ - `actors` skill: agent-facing manual for operating the extension and navigating bundled recipes.
60
+ - `swarm` skill: multi-agent methodology, strategies, standards, and portable examples.
61
+ - `/docs`: detailed transportable standards read on demand.
62
+ - `AGENTS.md`: durable project protocol for agents changing this repo.
63
+ - Skill evolution is passive-active: when implementation yields durable mechanics, invariants, warnings, or orchestration lessons, update `skills/actors/SKILL.md` or `skills/swarm/SKILL.md` immediately instead of carrying evergreen skill-upkeep items in `BACKLOG.md`.
64
+
65
+ ## Public Actor Model
66
+
67
+ - Preserve the public verbs: `spawn`, `message`, `inspect`.
68
+ - Prefer one typed actor-message envelope for upward, downward, lateral, parent/branch, and branch/parent messages.
69
+ - Prefer actor addresses and inspect views over exposing FIFO, outbox, or status mechanics as public concepts.
70
+ - Keep route and semantic type separate: delivery behavior comes from `to`, while `type` describes intent.
71
+ - Treat dotted message types as the minimal action surface: `channel.action` should often be enough for script-backed actors, with `body` reserved for extra context or free-form prompts to LLM-backed actors.
72
+
73
+ ## Runtime Contract
74
+
75
+ - Register trusted command templates with placeholder-derived args, progressive typed arg declarations, inline/default/`??`/ternary fallback, and split-first command argv construction.
76
+ - Keep command templates synchronous and portable; `async: true` is the detached run switch.
77
+ - Preserve node controls: `when`, positive `timeout`, `delay`, bounded `retry`, `failure`, and `recover` cleanup.
78
+ - Keep async run state under `~/.pi/agent/tmp/pi-actors/runs` with injected `{run_id}` and `{state_dir}` values.
79
+ - Preserve event-driven observability: terminal follow-ups, coordinator-bound outbox messages, branch-aware triangles, process-tree expansion, and bounded body previews.
80
+ - Do not restore busy-polling examples, duplicate terminal follow-ups, or duplicate follow-ups for handled `cancel`, `kill`, or control-stop actions.
81
+
82
+ ## Recipes And Registry
83
+
84
+ - `~/.pi/agent/recipes/*.json` is executable muscle memory: recipes there become persistent tools by location.
85
+ - Preserve filename identity, atomic writes, explicit operator-gated migration paths, and local transportability.
86
+ - Packaged/ad hoc recipes outside the agent root are components, not user tools.
87
+ - Tool definitions use `template`, not `script`, and built-in/core tool names must not be shadowed.
88
+ - Packaged recipe growth is demand-driven: prefer reusable components over speculative scenario catalogs.
89
+ - Recipe templates may point directly at executable helper scripts; keep script executable bits and avoid unnecessary `node` prefixes.
90
+
91
+ ## Command And Recipe Layers
92
+
93
+ - Keep command-template semantics in `docs/command-templates.md`.
94
+ - Keep recipe storage/import/default/reference behavior in `docs/template-recipes.md`.
95
+ - Keep detached lifecycle/state/IPC behavior in `docs/async-runs.md`.
96
+ - Imported recipes are command-template-shaped definitions, not async-run instances.
97
+ - Valid chain: `tool → template → recipe → run → template`; reject cyclic shortcuts.
98
+ - Typed args support `string`, `path`, `int`, `number`, `bool`, `array`, and `enum(...)`.
99
+ - Preserve both metadata-first args and inline-first placeholder style.
100
+
101
+ ## State, IO, And Safety
102
+
103
+ - Tool stdout and temp state must stay bounded and local.
104
+ - Keep tail truncation, full-output temp files, failure formatting, and centralized limits intact.
105
+ - Published docs must not include machine-local absolute paths.
106
+ - Any view scanning run directories must apply coordinator/session ownership filters before exposing summaries or previews.
107
+ - Direct branch messages are active inbox queues; guard branch-local append/status rewrites with the branch inbox lock and keep claim/handled/failed transitions tested.
108
+ - Room/branch provenance checks should validate that accepted `from` addresses belong to the addressed run.
109
+
110
+ ## Coordination And Lifecycle
111
+
112
+ - Persistent implementer workflows are recipe composition, not one-off scripts.
113
+ - Compose cells such as `coordinator-locker`, subagent launchers, actor-message utilities, and mailbox-loop helpers.
114
+ - Preserve JSON envelope object shape across handoffs.
115
+ - Keep locker state generic and thin; orchestration strategy belongs in the coordinator.
116
+ - Graceful actor retirement is opt-in through recipe/run metadata and must not infer retirement for persistent services or backlog implementers.
117
+
118
+ ## Context And Planning Hygiene
119
+
120
+ - `BACKLOG.md` is planning, not history: only completable future work with current scope and exit criteria.
121
+ - Completed delivery belongs in `CHANGELOG.md`.
122
+ - Durable/evergreen behavior belongs in `AGENTS.md`, README, docs, or skills.
123
+ - Changelog bullets describe meaningful user/operator/developer changes, not release bookkeeping.
124
+ - PR/release summaries are temporary artifacts; keep durable release evidence in `CHANGELOG.md` and gates in `BACKLOG.md`.
125
+ - Meaningful implementation or docs changes must reconcile `BACKLOG.md`, `CHANGELOG.md`, README, and docs navigation.
61
126
 
62
127
  ## Validation
63
128
 
64
- - `npm run check`: Lightweight extension-load sanity check
65
- - `npm test`: Focused regression tests for extracted pure domains
66
- - `npm run pack:dry`: Verify package contents and npm metadata
67
- - `npm run conformance`: Compact protocol conformance runner for actor/recipe behavior
68
- - `bash ~/.pi/agent/skills/abcd-context/scripts/validate-context.sh`: Validate context split, links, and README/docs reachability
129
+ - `npm run check`: Lightweight extension-load sanity check.
130
+ - `npm test`: Focused regression tests for extracted pure domains.
131
+ - `npm run pack:dry`: Verify package contents and npm metadata.
132
+ - `npm run conformance`: Compact protocol conformance runner for actor/recipe behavior.
133
+ - `bash ~/.pi/agent/skills/abcd-context/scripts/validate-context.sh`: Validate context split, links, and README/docs reachability.
69
134
 
70
135
  ## Pre-Task Preparation
71
136
 
72
- 1. Read this file, `BACKLOG.md`, and `README.md`
73
- 2. Inspect `index.ts` around the touched tool/runtime path
74
- 3. Prefer targeted edits over broad rewrites
75
- 4. Run the smallest validation set that covers the touched scope
137
+ 1. Read this file, `BACKLOG.md`, and `README.md`.
138
+ 2. Inspect `index.ts` around the touched tool/runtime path.
139
+ 3. Prefer targeted edits over broad rewrites.
140
+ 4. Run the smallest validation set that covers the touched scope.
76
141
 
77
142
  ## Task Completion Protocol
78
143
 
79
- 1. Reconcile backlog state with reality: close, narrow, split, defer, or gate items explicitly
80
- 2. Update README/docs when public behavior, setup, package contents, or navigation changes
81
- 3. Record meaningful delivered slices in `CHANGELOG.md`
82
- 4. Run relevant validation and report exact commands
144
+ 1. Reconcile backlog state with reality: close, narrow, split, defer, or gate items explicitly.
145
+ 2. Update README/docs when public behavior, setup, package contents, or navigation changes.
146
+ 3. Record meaningful delivered slices in `CHANGELOG.md`.
147
+ 4. Run relevant validation and report exact commands.
package/BACKLOG.md CHANGED
@@ -43,232 +43,189 @@ 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
48
+ ### M-01 State Corruption Recovery
71
49
 
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`.
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.
54
+ - Direction:
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.
81
58
  - 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.
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.
86
62
 
87
- ### M-04 Actor Loop Helper SDK
63
+ ### M-02 Actor Loop Helper Minimal Core
88
64
 
89
- - Priority: Medium.
90
- - 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.
91
69
  - Files:
92
- - `lib/actor-loop.ts`.
93
- - `scripts/actor-loop.mjs`.
94
- - Capabilities:
95
- - Initial reconciliation.
96
- - Wake subscription.
97
- - Polling fallback.
98
- - Run and branch inbox claiming.
99
- - Handled and failed status transitions.
100
- - Outbox emission.
101
- - Progress updates.
102
- - Graceful stop handling.
70
+ - `lib/mailbox-loop.ts`.
71
+ - Direction:
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.
103
75
  - Acceptance:
104
- - A packaged demo recipe uses a mailbox-only control endpoint.
105
- - Concurrent wake and poll paths do not double-process messages.
106
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.
107
80
 
108
- ### M-13 Packaged Actor Worker Recipe Template
81
+ ### M-03 Canonical Worker Recipe Template
109
82
 
110
- - Priority: Medium.
111
- - 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.
112
88
  - Direction:
113
- - Worker joins room.
114
- - Worker declares mailbox accepts and emits.
115
- - Worker claims branch inbox messages.
89
+ - Worker joins the default room.
90
+ - Worker declares typed mailbox accepts/emits.
91
+ - Worker claims branch inbox work.
116
92
  - Worker posts `task.claim`, `task.result`, and `awaiting_assignment`.
117
93
  - Worker handles `control.stop`.
118
94
  - Acceptance:
119
- - Recipe demonstrates correct mailbox loop semantics.
120
- - It is a recipe-authoring example, not a product feature.
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.
121
98
 
122
- ### M-17 Windows And Nix Portability Pass
99
+ ### M-04 Protocol Contract Fixtures
123
100
 
124
101
  - Priority: Medium.
125
- - Goal: Strengthen current portability around FIFO, named-pipe, and mailbox-only paths without adding a new backend.
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.
126
105
  - Direction:
127
- - Doctor flags FIFO-only recipes on native Windows.
128
- - Keep mailbox-only demo cross-platform.
129
- - Document platform matrix.
130
- - Cover named-pipe adapter with injected sender where practical.
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.
131
108
  - Acceptance:
132
- - Native Windows limitations are visible before launch.
133
- - Mailbox-only recipe works cross-platform.
134
- - Docs and tests cover the adapter split.
109
+ - Public examples and fixtures validate in tests.
110
+ - No migration is forced.
111
+ - No external transport/MCP standard is introduced.
135
112
 
136
- ### M-18 State Corruption Recovery
113
+ ### M-05 Follow-Up Deduplication Hardening
137
114
 
138
115
  - Priority: Medium.
139
- - Goal: Add resilient JSON and JSONL state readers.
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.
140
119
  - Direction:
141
- - Malformed JSONL lines should not kill entire inspect paths.
142
- - Corrupt JSON files should report diagnostics with paths.
143
- - Consider optional `.corrupt` quarantine helper.
120
+ - Continue using event id and stateDir for deduplication where available.
121
+ - Preserve terminal handled semantics.
122
+ - Simulate watcher restart in tests.
144
123
  - Acceptance:
145
- - Inspect remains useful when partial state survives.
146
- - Corrupt paths are reported clearly.
147
- - Canonical state is not silently rewritten without explicit action.
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.
148
127
 
149
- ### M-20 Spawn Preflight Mode
128
+ ### M-06 Portability Reality Pass
150
129
 
151
130
  - Priority: Medium.
152
- - Goal: Add dry-run launch planning for `spawn` and async recipe tool invocation.
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.
153
134
  - Direction:
154
- - Resolve recipe, imports, args, artifacts, state dir, command graph, and mailbox metadata.
155
- - Do not start a process.
156
- - Return warnings and resolved launch plan.
135
+ - Doctor flags FIFO-only recipes on native Windows.
136
+ - Keep mailbox-only worker demo cross-platform.
137
+ - Document a small platform matrix.
138
+ - Cover named-pipe adapter with injected sender where practical.
157
139
  - Acceptance:
158
- - `preflight=true` returns a resolved plan.
159
- - No process is spawned.
160
- - Missing args and risky commands are reported before launch.
140
+ - Native Windows limitations are visible before launch.
141
+ - Mailbox-only recipe works cross-platform.
142
+ - Docs and tests cover the adapter split.
161
143
 
162
- ### M-21 Run Restart And Reattach Policy
144
+ ### M-07 Compiled Script Entrypoints
163
145
 
164
146
  - Priority: Medium.
165
- - Goal: Clarify and implement safe behavior for reused `run_id` and `state_dir`.
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.
166
150
  - Direction:
167
- - Active reuse fails closed.
168
- - Terminal restart with same id is allowed under explicit semantics.
169
- - Record generation or restarted time.
170
- - Preserve previous terminal-state policy.
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.
171
159
  - Acceptance:
172
- - Active reuse remains blocked.
173
- - Terminal restart records generation or `restartedAt`.
174
- - Inspect shows restart semantics.
175
- - Docs are updated.
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.
176
164
 
177
- ### M-22 Actor Address Helper CLI And Tooling
165
+ ### M-08 Recipe Doctor Remediation UX
178
166
 
179
- - Priority: Medium.
180
- - Goal: Improve address normalization and diagnostics for recipe authors and tests.
167
+ - Priority: High.
168
+ - Status: Open.
169
+ - Goal: Turn recipe doctor output into an operator action surface, not just a diagnostic listing.
170
+ - Why now: Recipe registry warnings are intentionally actionable; the next value is helping operators decide whether to fix, disable, delete, or inspect a recipe without hiding the warning.
181
171
  - Direction:
182
- - Add helper functions or inspect view for address validation.
183
- - Improve invalid-address diagnostics.
172
+ - Summarize invalid, blocking, shadowed, disabled, and risky shell-boundary entries with compact recommended actions.
173
+ - Keep remediation advisory by default; no automatic mutation of user recipes.
174
+ - Preserve detailed diagnostics through verbose inspection.
184
175
  - Acceptance:
185
- - Diagnostics include expected forms.
186
- - Examples cover branch, room, run, session, and tool addresses.
187
- - No new public address kinds are added.
176
+ - `inspect target=recipes view=doctor` identifies the highest-priority actionable maintenance item.
177
+ - Blocking invalid recipes include the blocked lower-priority candidate when available.
178
+ - Tests cover at least invalid/blocking, disabled, shadowed, and risky shell diagnostics.
188
179
 
189
- ### M-24 Coordinator Follow-Up Deduplication
180
+ ### M-09 Actor Worker v2
190
181
 
191
- - Priority: Medium.
192
- - Goal: Suppress duplicate terminal transitions and outbox follow-ups across watcher reloads, session restarts, or line-counter resets.
182
+ - Priority: High.
183
+ - Status: Open.
184
+ - Goal: Promote `actor-worker` from a minimal demo into the canonical standard-worker reference pattern.
185
+ - Why now: Mailbox-loop semantics are now stable enough to show artifact production, compact status, and stale-claim recovery without adding a scheduler or broker.
193
186
  - Direction:
194
- - Use event id and stateDir for deduplication where available.
195
- - Preserve terminal handled semantics.
196
- - Simulate watcher restart in tests.
187
+ - Add optional task result artifact writing.
188
+ - Expose compact worker status for `inspect` and room events.
189
+ - Add stale-claim recovery or timeout semantics where they fit the mailbox-loop helper.
190
+ - Preserve policy-light behavior: no model choice, prompt design, or project task selection.
197
191
  - Acceptance:
198
- - Duplicate follow-up is suppressed after reasonable watcher reset.
199
- - Terminal handled state remains effective.
200
- - Tests cover restart and line-counter reset scenarios.
192
+ - Worker can produce a durable artifact path for handled work.
193
+ - Stale claimed work can be surfaced or recovered deterministically.
194
+ - The actors skill documents the v2 worker pattern.
201
195
 
202
- ### M-25 Documentation Refactor Runtime Contracts First
196
+ ### M-10 Dist Package Contract Hardening
203
197
 
204
198
  - Priority: Medium.
205
- - Goal: Reorganize docs so implementation agents find stable contracts before examples.
206
- - Target order:
207
- - `docs/runtime-contracts.md`.
208
- - `docs/actor-messages.md`.
209
- - `docs/async-runs.md`.
210
- - `docs/tool-registry.md`.
211
- - `docs/template-recipes.md`.
212
- - `docs/command-templates.md`.
213
- - `docs/recipe-authoring.md`.
214
- - `docs/troubleshooting.md`.
199
+ - Status: Open.
200
+ - Goal: Make the dist-first package contract difficult to regress after the 0.24 packaging shift.
201
+ - Why now: `dist/` is now the default JS-only runtime surface and carries mirrored scripts, recipes, fixtures, and skills.
202
+ - Direction:
203
+ - Add package-layout checks for default metadata, source metadata, mirrored assets, and compiled script-domain modules.
204
+ - Add negative checks for stale renamed dist files and source-only runtime imports from installed packages.
205
+ - Keep source files packaged for TypeScript-native runtimes unless a future package-size decision changes that explicitly.
215
206
  - Acceptance:
216
- - No polling-first examples.
217
- - Every example matches fixtures.
218
- - Docs distinguish protocol semantics from Pi UI commands.
219
- - No external standard or MCP work is introduced.
207
+ - `npm run validate` fails if default Pi metadata points outside `dist` unexpectedly.
208
+ - Installed-package tests cover every script shim that imports compiled domain logic.
209
+ - Pack dry assertions cover `dist/scripts`, `dist/recipes`, `dist/fixtures`, and `dist/skills`.
220
210
 
221
- ## Suggested Milestone Order
211
+ ## Explicitly Deferred
222
212
 
223
- ```text
224
- Patch release:
225
- H-01..H-12
213
+ These are valid ideas but not current focus. Reintroduce only with concrete evidence from real actor workflows.
226
214
 
227
- Minor 0.23 — Contract consolidation:
228
- M-01, M-02, M-03, M-12, M-25
215
+ - Spawn preflight mode: useful later, but lower value than resilient inspect and mailbox-loop consolidation.
216
+ - Run restart/reattach policy: risky for isolation; defer until corruption recovery and protocol fixtures are stronger.
217
+ - Actor address helper CLI: keep diagnostics improving opportunistically inside existing parser/tests.
218
+ - Documentation refactor: defer until the canonical mailbox loop and worker recipe exist; avoid rewriting docs twice.
219
+ - Host-level tool unregistration: blocked on host API support.
220
+ - Branch-local checkpoint semantics: wait for real collaborative branch-runner experiments.
221
+ - Actor recipe feedback loop: keep advisory and operator-gated after real runs produce evidence.
229
222
 
230
- Minor 0.24 — Runtime/message reliability:
231
- M-04, M-05, M-06, M-13, M-24
232
-
233
- Minor 0.25 — Operator hygiene:
234
- M-07, M-08, M-09, M-14, M-15, M-16
223
+ ## Suggested Milestone Order
235
224
 
236
- Minor 0.26 — Inspector and state scaling:
237
- M-10, M-11, M-18, M-19, M-23
225
+ ```text
226
+ 0.25 — Operator remediation and worker maturity:
227
+ M-08, M-09
238
228
 
239
- Minor 0.27 — Portability and lifecycle polish:
240
- M-17, M-20, M-21, M-22
229
+ 0.26 — Package contract hardening:
230
+ M-10
241
231
  ```
242
-
243
- ## Blocked Or Opportunistic Carry-Over
244
-
245
- ### Branch-Local Checkpoint Semantics
246
-
247
- - Priority: Low.
248
- - Blocked by: At least one real collaborative branch-runner async-run experiment.
249
- - Goal: Validate whether `failure: "branch"`, node-level `retry`, and `recover` cleanup are enough for branch-local validation and bounded reattempts.
250
- - Exit:
251
- - Record one decision: sufficient, documentation-only refinement needed, or propose one minimal command-template extension with tests.
252
-
253
- ### Host-Level Tool Unregistration
254
-
255
- - Priority: Low.
256
- - Blocked by: Host API support for custom tool unregistration.
257
- - Goal: Remove stale dynamically registered tool definitions completely when the host API supports it.
258
- - Direction:
259
- - Track pi extension API support for custom tool unregistration.
260
- - Replace active-tool deactivation fallback with real unregister when available.
261
- - Preserve current safe behavior: deleted tools should not remain active after reload.
262
- - Exit:
263
- - Deleting a recipe file removes the corresponding runtime tool definition and active-tool entry without session restart.
264
-
265
- ### Actor Recipe Feedback Loop
266
-
267
- - Priority: Low.
268
- - Goal: Turn actor recipe-context awareness into a practical improvement loop for packaged recipes and operator-owned recipe memory.
269
- - Direction:
270
- - After real multi-agent runs, capture whether child actors report that recipe/import/mailbox/role boundaries fit the task.
271
- - Keep the loop advisory and operator-gated.
272
- - Prefer small recipe, README, and skill refinements over scenario catalogs.
273
- - Exit:
274
- - At least one real run produces recipe-boundary feedback that is applied or explicitly rejected with rationale.