@llblab/pi-actors 0.42.3 → 0.43.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/AGENTS.md +127 -175
- package/BACKLOG.md +189 -1
- package/CHANGELOG.md +183 -292
- package/README.md +115 -276
- package/dist/fixtures/protocol/control-endpoint.json +6 -0
- package/dist/fixtures/protocol/control-record.json +9 -0
- package/dist/fixtures/protocol/recipe-summary.json +4 -12
- package/dist/fixtures/protocol/trace-event.json +9 -0
- package/dist/index.js +1 -1
- package/dist/lib/async-runs.d.ts +15 -38
- package/dist/lib/async-runs.js +173 -111
- package/dist/lib/automatic-review-runtime.d.ts +1 -1
- package/dist/lib/automatic-review-runtime.js +5 -5
- package/dist/lib/command-templates.d.ts +2 -0
- package/dist/lib/command-templates.js +38 -4
- package/dist/lib/control-projection.d.ts +20 -0
- package/dist/lib/control-projection.js +66 -0
- package/dist/lib/control.d.ts +15 -0
- package/dist/lib/control.js +97 -0
- package/dist/lib/draft-sleep.js +3 -3
- package/dist/lib/execution-sessions.d.ts +17 -0
- package/dist/lib/execution-sessions.js +85 -0
- package/dist/lib/file-state.d.ts +2 -0
- package/dist/lib/file-state.js +114 -46
- package/dist/lib/inspector-actions.d.ts +2 -2
- package/dist/lib/inspector-actions.js +2 -2
- package/dist/lib/inspector-command.js +3 -3
- package/dist/lib/inspector-overlay.d.ts +54 -70
- package/dist/lib/inspector-overlay.js +576 -910
- package/dist/lib/inspector.d.ts +3 -71
- package/dist/lib/inspector.js +19 -665
- package/dist/lib/limits.d.ts +7 -3
- package/dist/lib/limits.js +7 -3
- package/dist/lib/observability.d.ts +16 -16
- package/dist/lib/observability.js +43 -82
- package/dist/lib/prompts.d.ts +1 -1
- package/dist/lib/prompts.js +3 -3
- package/dist/lib/recipe-control.d.ts +7 -0
- package/dist/lib/recipe-control.js +43 -0
- package/dist/lib/recipes-discovery.js +2 -0
- package/dist/lib/recipes-references.d.ts +1 -14
- package/dist/lib/recipes-references.js +6 -21
- package/dist/lib/review-control.d.ts +1 -1
- package/dist/lib/review-control.js +4 -5
- package/dist/lib/review-projection.js +1 -5
- package/dist/lib/run-ui-runtime.js +2 -2
- package/dist/lib/runs-control-delivery.d.ts +28 -0
- package/dist/lib/runs-control-delivery.js +150 -0
- package/dist/lib/runs-controls.d.ts +37 -0
- package/dist/lib/runs-controls.js +146 -0
- package/dist/lib/runs-retention.d.ts +7 -0
- package/dist/lib/runs-retention.js +27 -3
- package/dist/lib/runs-start.js +4 -2
- package/dist/lib/runs-status.js +11 -6
- package/dist/lib/runs-trace.d.ts +24 -0
- package/dist/lib/runs-trace.js +102 -0
- package/dist/lib/runtime-identity.d.ts +7 -0
- package/dist/lib/runtime-identity.js +35 -0
- package/dist/lib/runtime-notifier.d.ts +1 -1
- package/dist/lib/runtime-notifier.js +1 -1
- package/dist/lib/runtime-triage.d.ts +29 -0
- package/dist/lib/runtime-triage.js +76 -0
- package/dist/lib/tool-review-scheduler.js +7 -7
- package/dist/lib/tools-inspect.d.ts +3 -3
- package/dist/lib/tools-inspect.js +241 -707
- package/dist/lib/tools-local.js +2 -10
- package/dist/lib/tools-message.d.ts +6 -7
- package/dist/lib/tools-message.js +95 -396
- package/dist/lib/tools-response.d.ts +1 -5
- package/dist/lib/tools-response.js +5 -48
- package/dist/lib/tools-spawn.js +16 -28
- package/dist/lib/tools.d.ts +1 -1
- package/dist/lib/tools.js +2 -3
- package/dist/lib/trace-projection.d.ts +22 -0
- package/dist/lib/trace-projection.js +185 -0
- package/dist/recipes/draft-review.json +0 -10
- package/dist/recipes/lens-swarm.json +0 -14
- package/dist/recipes/music-player.json +10 -19
- package/dist/recipes/pipeline-architect-coordinator.json +0 -11
- package/dist/recipes/pipeline-artifact-bundle.json +1 -22
- package/dist/recipes/pipeline-artifact-report.json +1 -18
- package/dist/recipes/pipeline-artifact-write.json +1 -18
- package/dist/recipes/pipeline-async-run-ops.json +0 -12
- package/dist/recipes/pipeline-checkpoint-continuation.json +0 -14
- package/dist/recipes/pipeline-development-tasking.json +0 -12
- package/dist/recipes/pipeline-docs-maintenance.json +0 -12
- package/dist/recipes/pipeline-media-library.json +0 -12
- package/dist/recipes/pipeline-quorum-review.json +0 -12
- package/dist/recipes/pipeline-release-readiness.json +0 -12
- package/dist/recipes/pipeline-release-summary.json +0 -12
- package/dist/recipes/pipeline-repo-health.json +0 -12
- package/dist/recipes/pipeline-research-synthesis.json +0 -11
- package/dist/recipes/pipeline-review-readiness.json +0 -12
- package/dist/recipes/resource-locker.json +27 -0
- package/dist/recipes/subagent-artifact.json +0 -9
- package/dist/recipes/subagent-checkpoint.json +0 -10
- package/dist/recipes/subagent-conflict-report.json +0 -11
- package/dist/recipes/subagent-contradiction-map.json +0 -11
- package/dist/recipes/subagent-critic.json +0 -11
- package/dist/recipes/subagent-evidence-map.json +0 -11
- package/dist/recipes/subagent-followup.json +0 -10
- package/dist/recipes/subagent-judge.json +0 -11
- package/dist/recipes/subagent-merge.json +0 -11
- package/dist/recipes/subagent-normalize.json +0 -11
- package/dist/recipes/subagent-plan.json +0 -11
- package/dist/recipes/subagent-preflight.json +0 -11
- package/dist/recipes/subagent-prompt.json +0 -10
- package/dist/recipes/subagent-quorum.json +0 -10
- package/dist/recipes/subagent-review-coordinator.json +0 -14
- package/dist/recipes/subagent-review.json +0 -11
- package/dist/recipes/subagent-task-card.json +0 -11
- package/dist/recipes/subagent-tools.json +0 -10
- package/dist/recipes/subagent-verify.json +0 -11
- package/dist/recipes/subagents-prompts.json +0 -10
- package/dist/recipes/tool-review.json +0 -10
- package/dist/scripts/async-runner.mjs +25 -25
- package/dist/scripts/conformance.mjs +4 -2
- package/dist/scripts/locker.mjs +196 -69
- package/dist/scripts/music-player.mjs +162 -159
- package/dist/scripts/recipe-utils.mjs +6 -96
- package/dist/scripts/release-gates.mjs +91 -0
- package/dist/scripts/validate-recipe.mjs +8 -57
- package/dist/skills/actors/SKILL.md +57 -265
- package/dist/skills/swarm/SKILL.md +10 -34
- package/docs/0.43-baseline.md +39 -0
- package/docs/README.md +4 -6
- package/docs/actor-inspector.md +26 -64
- package/docs/async-runs.md +81 -328
- package/docs/command-templates.md +8 -118
- package/docs/recipe-library.md +55 -182
- package/docs/releasing.md +28 -0
- package/docs/template-recipes.md +76 -289
- package/docs/tool-registry.md +41 -161
- package/fixtures/protocol/control-endpoint.json +6 -0
- package/fixtures/protocol/control-record.json +9 -0
- package/fixtures/protocol/recipe-summary.json +4 -12
- package/fixtures/protocol/trace-event.json +9 -0
- package/index.ts +1 -1
- package/lib/async-runs.ts +218 -204
- package/lib/automatic-review-runtime.ts +7 -7
- package/lib/command-templates.ts +44 -4
- package/lib/control-projection.ts +105 -0
- package/lib/control.ts +117 -0
- package/lib/draft-sleep.ts +3 -3
- package/lib/execution-sessions.ts +111 -0
- package/lib/file-state.ts +84 -64
- package/lib/inspector-actions.ts +2 -2
- package/lib/inspector-command.ts +3 -3
- package/lib/inspector-overlay.ts +617 -1126
- package/lib/inspector.ts +46 -979
- package/lib/limits.ts +7 -3
- package/lib/observability.ts +60 -101
- package/lib/prompts.ts +3 -3
- package/lib/recipe-control.ts +52 -0
- package/lib/recipes-discovery.ts +2 -0
- package/lib/recipes-references.ts +9 -45
- package/lib/review-control.ts +4 -5
- package/lib/review-projection.ts +1 -5
- package/lib/run-ui-runtime.ts +2 -2
- package/lib/runs-control-delivery.ts +209 -0
- package/lib/runs-controls.ts +213 -0
- package/lib/runs-retention.ts +38 -3
- package/lib/runs-start.ts +4 -2
- package/lib/runs-status.ts +11 -6
- package/lib/runs-trace.ts +136 -0
- package/lib/runtime-identity.ts +39 -0
- package/lib/runtime-notifier.ts +1 -1
- package/lib/runtime-triage.ts +120 -0
- package/lib/tool-review-scheduler.ts +7 -7
- package/lib/tools-inspect.ts +283 -900
- package/lib/tools-local.ts +2 -12
- package/lib/tools-message.ts +112 -520
- package/lib/tools-response.ts +5 -64
- package/lib/tools-spawn.ts +16 -32
- package/lib/tools.ts +5 -6
- package/lib/trace-projection.ts +244 -0
- package/package.json +2 -1
- package/recipes/draft-review.json +0 -10
- package/recipes/lens-swarm.json +0 -14
- package/recipes/music-player.json +10 -19
- package/recipes/pipeline-architect-coordinator.json +0 -11
- package/recipes/pipeline-artifact-bundle.json +1 -22
- package/recipes/pipeline-artifact-report.json +1 -18
- package/recipes/pipeline-artifact-write.json +1 -18
- package/recipes/pipeline-async-run-ops.json +0 -12
- package/recipes/pipeline-checkpoint-continuation.json +0 -14
- package/recipes/pipeline-development-tasking.json +0 -12
- package/recipes/pipeline-docs-maintenance.json +0 -12
- package/recipes/pipeline-media-library.json +0 -12
- package/recipes/pipeline-quorum-review.json +0 -12
- package/recipes/pipeline-release-readiness.json +0 -12
- package/recipes/pipeline-release-summary.json +0 -12
- package/recipes/pipeline-repo-health.json +0 -12
- package/recipes/pipeline-research-synthesis.json +0 -11
- package/recipes/pipeline-review-readiness.json +0 -12
- package/recipes/resource-locker.json +27 -0
- package/recipes/subagent-artifact.json +0 -9
- package/recipes/subagent-checkpoint.json +0 -10
- package/recipes/subagent-conflict-report.json +0 -11
- package/recipes/subagent-contradiction-map.json +0 -11
- package/recipes/subagent-critic.json +0 -11
- package/recipes/subagent-evidence-map.json +0 -11
- package/recipes/subagent-followup.json +0 -10
- package/recipes/subagent-judge.json +0 -11
- package/recipes/subagent-merge.json +0 -11
- package/recipes/subagent-normalize.json +0 -11
- package/recipes/subagent-plan.json +0 -11
- package/recipes/subagent-preflight.json +0 -11
- package/recipes/subagent-prompt.json +0 -10
- package/recipes/subagent-quorum.json +0 -10
- package/recipes/subagent-review-coordinator.json +0 -14
- package/recipes/subagent-review.json +0 -11
- package/recipes/subagent-task-card.json +0 -11
- package/recipes/subagent-tools.json +0 -10
- package/recipes/subagent-verify.json +0 -11
- package/recipes/subagents-prompts.json +0 -10
- package/recipes/tool-review.json +0 -10
- package/scripts/async-runner.mjs +25 -25
- package/scripts/conformance.mjs +4 -2
- package/scripts/locker.mjs +196 -69
- package/scripts/music-player.mjs +162 -159
- package/scripts/recipe-utils.mjs +6 -96
- package/scripts/release-gates.mjs +91 -0
- package/scripts/validate-recipe.mjs +8 -57
- package/skills/actors/SKILL.md +57 -265
- package/skills/swarm/SKILL.md +10 -34
- package/dist/fixtures/protocol/actor-message-branch.json +0 -13
- package/dist/fixtures/protocol/mailbox-contract.json +0 -15
- package/dist/fixtures/protocol/room-message.json +0 -11
- package/dist/fixtures/protocol/room-roster.json +0 -11
- package/dist/fixtures/protocol/run-inbox-message.json +0 -9
- package/dist/fixtures/protocol/run-outbox-event.json +0 -9
- package/dist/lib/mailbox-loop.d.ts +0 -41
- package/dist/lib/mailbox-loop.js +0 -60
- package/dist/lib/messages.d.ts +0 -25
- package/dist/lib/messages.js +0 -122
- package/dist/lib/rooms.d.ts +0 -104
- package/dist/lib/rooms.js +0 -647
- package/dist/lib/runs-mailbox.d.ts +0 -25
- package/dist/lib/runs-mailbox.js +0 -146
- package/dist/lib/runs-messages.d.ts +0 -15
- package/dist/lib/runs-messages.js +0 -179
- package/dist/lib/runs-outbox.d.ts +0 -41
- package/dist/lib/runs-outbox.js +0 -87
- package/dist/lib/tools-mailbox.d.ts +0 -8
- package/dist/lib/tools-mailbox.js +0 -48
- package/dist/recipes/actor-worker.json +0 -39
- package/dist/recipes/coordinator-locker.json +0 -45
- package/dist/recipes/locker.json +0 -45
- package/dist/recipes/pipeline-room-swarm.json +0 -50
- package/dist/recipes/subagent-message.json +0 -32
- package/dist/recipes/utility-actor-message.json +0 -23
- package/dist/scripts/actor-worker.mjs +0 -214
- package/dist/scripts/coordinator.mjs +0 -799
- package/docs/actor-messages.md +0 -225
- package/docs/actors-deep-reference.md +0 -66
- package/docs/component-recipes.md +0 -148
- package/docs/task-first-recipes.md +0 -263
- package/fixtures/protocol/actor-message-branch.json +0 -13
- package/fixtures/protocol/mailbox-contract.json +0 -15
- package/fixtures/protocol/room-message.json +0 -11
- package/fixtures/protocol/room-roster.json +0 -11
- package/fixtures/protocol/run-inbox-message.json +0 -9
- package/fixtures/protocol/run-outbox-event.json +0 -9
- package/lib/mailbox-loop.ts +0 -144
- package/lib/messages.ts +0 -151
- package/lib/rooms.ts +0 -939
- package/lib/runs-mailbox.ts +0 -208
- package/lib/runs-messages.ts +0 -252
- package/lib/runs-outbox.ts +0 -144
- package/lib/tools-mailbox.ts +0 -56
- package/recipes/actor-worker.json +0 -39
- package/recipes/coordinator-locker.json +0 -45
- package/recipes/locker.json +0 -45
- package/recipes/pipeline-room-swarm.json +0 -50
- package/recipes/subagent-message.json +0 -32
- package/recipes/utility-actor-message.json +0 -23
- package/scripts/actor-worker.mjs +0 -214
- package/scripts/coordinator.mjs +0 -799
package/skills/actors/SKILL.md
CHANGED
|
@@ -1,311 +1,103 @@
|
|
|
1
1
|
---
|
|
2
2
|
name: actors
|
|
3
|
-
description: Required practical guide for non-trivial pi-actors use
|
|
4
|
-
metadata:
|
|
5
|
-
version: 0.42.3
|
|
3
|
+
description: Required practical guide for non-trivial pi-actors use and Run-kernel work. Read before using or changing spawn, message, inspect, Runs, tools, Recipes, command templates, Control, Trace, artifacts, or lifecycle mechanics.
|
|
6
4
|
---
|
|
7
5
|
|
|
8
6
|
# Actors (pi-actors)
|
|
9
7
|
|
|
10
|
-
`pi-actors`
|
|
11
|
-
|
|
12
|
-
Maintain this skill as the extension's agent-facing manual. When implementation changes reveal new durable mechanics, invariants, warnings, or safer operating patterns, update this skill alongside code/docs so future agents learn the current actor model instead of rediscovering it.
|
|
13
|
-
|
|
14
|
-
## Knowledge Surfaces
|
|
15
|
-
|
|
16
|
-
Context arrives in layers:
|
|
17
|
-
|
|
18
|
-
- **Injected prompt**: always present at extension load. It is a bootstrap/reminder of current verbs, paths, and runtime rules; it should not try to be documentation.
|
|
19
|
-
- **Skill header**: automatically matched by agents from `name`/`description`. Its job is to signal: if pi-actors use is unclear, read this skill body.
|
|
20
|
-
- **This skill body**: highest-density practical reference. It should explain extension operation from multiple angles and link to deeper docs without becoming a changelog or swarm-methodology guide.
|
|
21
|
-
- **README**: human entrypoint. It explains what pi-actors is, why it matters, benefits, rhythm, and representative scenarios; it is not automatically in agent context.
|
|
22
|
-
- **Docs**: transportable standards by domain: command templates, recipes, async runs, actor messages, registry, recipe library; read on demand.
|
|
23
|
-
- **AGENTS.md**: project context for agents changing pi-actors: architecture constraints, durable conventions, do/don't rules, validation; read for repo work.
|
|
24
|
-
|
|
25
|
-
## Core Nouns
|
|
8
|
+
`pi-actors` treats any runnable local capability—a script, tool, service, pipeline, or subagent—as an actor. A Recipe is its reusable executable definition; a Run is one concrete actor instance:
|
|
26
9
|
|
|
27
10
|
```text
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
-> Recipe saved actor definition
|
|
31
|
-
-> spawn starts one run instance
|
|
32
|
-
-> run:<id> addressable actor
|
|
33
|
-
|
|
34
|
-
Trusted local capability
|
|
35
|
-
-> Command template or recipe
|
|
36
|
-
-> register_tool persists an agent-callable wrapper
|
|
37
|
-
-> tool:<name> addressable tool actor
|
|
11
|
+
Recipe --spawn--> Run
|
|
12
|
+
Run = Recipe + Trace + Control
|
|
38
13
|
```
|
|
39
14
|
|
|
40
|
-
|
|
41
|
-
- **Recipe**: saved JSON definition wrapping a template with args, defaults, imports, mailbox, artifacts, metadata, and optional `async: true`.
|
|
42
|
-
- **Run actor**: one detached execution instance addressable as `run:<id>` with status, logs, messages, mailbox metadata, files, and artifacts.
|
|
43
|
-
- **Tool actor**: registered persistent capability addressable as `tool:<name>` and callable through the generated tool or `message`. `tool:pi-actors` is reserved for runtime status and explicit automatic-review retry/reset control.
|
|
44
|
-
- **Artifact**: named durable output path declared by a recipe/run.
|
|
45
|
-
- **Mailbox**: interaction contract: message types the actor accepts/emits.
|
|
46
|
-
- **Advanced group/coordination surfaces**: `branch:<run>/<branch>`, `room:<run>`, `coordinator`, `session:<id>`, and communication snapshots exist for multi-actor workflows and diagnostics; do not make them the default mental model.
|
|
15
|
+
Use the swarm skill separately for decomposition, quorum design, reviewer lenses, and consensus methodology.
|
|
47
16
|
|
|
48
|
-
##
|
|
17
|
+
## Public Verbs
|
|
49
18
|
|
|
50
|
-
|
|
19
|
+
- `spawn`: create one Run from a Recipe or inline command template.
|
|
20
|
+
- `message`: send one actor-local Control to `run:<id>`, or the reserved review actions to `runtime`.
|
|
21
|
+
- `inspect`: inspect `run:<id>`, `runtime`, `recipes`, or `tool:<name>`.
|
|
22
|
+
- `register_tool`: persist a trusted capability; it does not address a running actor.
|
|
51
23
|
|
|
52
|
-
|
|
24
|
+
A Run target exposes exactly three inspect views: `recipe`, `trace`, and `control`.
|
|
53
25
|
|
|
54
|
-
|
|
26
|
+
## Recipe
|
|
55
27
|
|
|
56
|
-
|
|
28
|
+
A Recipe defines execution. It may declare args, defaults, imports, artifacts, command-template flags, and `control: ["action"]` when a long-lived service actually consumes actor-local inputs.
|
|
57
29
|
|
|
58
|
-
|
|
59
|
-
{
|
|
60
|
-
"as": "run:repo-health",
|
|
61
|
-
"file": "pipeline-repo-health",
|
|
62
|
-
"values": { "path": "/repo" },
|
|
63
|
-
"artifacts": { "report": "/tmp/repo-health.md" }
|
|
64
|
-
}
|
|
65
|
-
```
|
|
30
|
+
Do not declare Control for ordinary one-shot work. Runtime lifecycle actions such as `kill` stay runtime-owned and must not appear in Recipe Control declarations. Imported Recipes act as local definitions inside one Run; they do not create nested Runs unless execution explicitly spawns them.
|
|
66
31
|
|
|
67
|
-
|
|
32
|
+
Prefer maintained packaged Recipes over ad hoc wrappers. Keep model, thinking, mission, concurrency, quorum, and timeout choices caller-owned unless a Recipe documents a stable policy.
|
|
68
33
|
|
|
69
|
-
|
|
70
|
-
- Use `file`/`recipe` for saved recipes; bare names resolve under `~/.pi/agent/recipes`.
|
|
71
|
-
- Use inline `template` for one-off experiments; promote useful repeats to recipes.
|
|
72
|
-
- Terminal follow-up context contains only run id, status, one base path, and relative artifact names. Inspect the run for contents; semantic output and correlation remain in non-LLM details and state. Decide whether a successful pattern deserves durable tool memory only after inspection, and ask before writing the user recipe root.
|
|
73
|
-
- Use stable `as` names when you will inspect or message the actor later.
|
|
74
|
-
- Public run state is runtime-owned; do not pass custom `state_dir` paths. This keeps `run:<id>` addressability and retention on one boundary.
|
|
75
|
-
- `async: true` on the recipe is the detached run switch.
|
|
34
|
+
## Trace
|
|
76
35
|
|
|
77
|
-
|
|
36
|
+
Trace records bounded structured observations in `trace.jsonl`:
|
|
78
37
|
|
|
79
38
|
```json
|
|
80
39
|
{
|
|
81
|
-
"
|
|
82
|
-
"
|
|
83
|
-
"
|
|
84
|
-
"
|
|
40
|
+
"id": "…",
|
|
41
|
+
"ts": "…",
|
|
42
|
+
"kind": "progress.update",
|
|
43
|
+
"summary": "…",
|
|
44
|
+
"data": {},
|
|
45
|
+
"level": "info",
|
|
46
|
+
"attention": "notify"
|
|
85
47
|
}
|
|
86
48
|
```
|
|
87
49
|
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
- Required: `to`, `type`.
|
|
91
|
-
- Useful: `summary`, `body`, `from`, `reply_to`, `correlation_id`, `metadata`.
|
|
92
|
-
- Core addresses: `run:<id>`, `tool:<name>`.
|
|
93
|
-
- Advanced addresses: `branch:<run>/<branch>`, `room:<run>` for group timeline/roster, `coordinator`, `session:<id>`.
|
|
94
|
-
- Group posts to `room:<run>` require `from` from the same run (`run:<run>` or `branch:<run>/<branch>`).
|
|
95
|
-
- Runtime termination message: `control.kill` is the only documented actor message that kills a run. `control.stop` and `control.cancel` are actor-local mailbox vocabulary only when a recipe declares and handles them. Terminal retention messages: `control.archive`, `control.prune`.
|
|
96
|
-
- Long-lived child processes should remain in the run-owned process group unless the recipe implements an explicit daemon termination bridge; do not leave unowned detached services behind `control.kill`.
|
|
97
|
-
- Run controls revalidate a persisted cross-platform process identity proof at authorization and again immediately before signaling. Treat `dead pid`, `owner mismatch`, and `unsupported proof` as distinct fail-closed states; on Unix, only process-group `ESRCH` plus one more matching identity check permits exact-pid fallback, while permission/authorization errors remain terminal. Node exposes no portable pidfd/process-group handle, so retain the documented residual exit/reuse window instead of claiming atomic signaling or bypassing control with direct pid signals.
|
|
98
|
-
- Detached actors survive ordinary agent turns. On `session_shutdown` (quit, reload, or session replacement), pi-actors attempts canonical `control.kill` for each discovered readable still-running exact-owner run. Control compares immutable run generation inside the canonical boundary and serializes against same-directory restart; terminal, ambiguous, changed-generation, and other-session runs remain untouched. Teardown scans without the ordinary index depth cap, reports unreadable/corrupt state as failures, and persists a bounded summary under the run root. Descendant Pi sessions remain separate owners and rely on their own shutdown hooks; hard host termination can still leave an orphan requiring summary-guided OS/manual recovery, so never describe teardown as an absolute no-survivor guarantee.
|
|
50
|
+
Trace never carries sender, recipient, route, reply, or message-envelope fields. First-party writers use the canonical append authority, which validates and size-checks under a token-owned cross-process lock before one append-only JSONL write. Use `attention: "notify"` for visible notification and `attention: "followup"` only when the coordinator must receive semantic follow-up context. Prefer artifacts or complete execution captures for large evidence.
|
|
99
51
|
|
|
100
|
-
|
|
52
|
+
## Control
|
|
101
53
|
|
|
102
|
-
|
|
54
|
+
The public Control request is exact:
|
|
103
55
|
|
|
104
56
|
```json
|
|
105
|
-
{ "target": "run:
|
|
106
|
-
{ "target": "run:repo-health", "view": "tail", "lines": "80" }
|
|
107
|
-
{ "target": "run:repo-health", "view": "messages" }
|
|
108
|
-
{ "target": "run:repo-health", "view": "artifacts" }
|
|
109
|
-
{ "target": "tool:pi-actors", "view": "status" }
|
|
110
|
-
{ "target": "tool:music_player", "view": "status" }
|
|
111
|
-
{ "target": "recipes", "view": "status" }
|
|
112
|
-
{ "target": "coordinator", "view": "status" }
|
|
57
|
+
{ "target": "run:<id>", "action": "pause", "input": {}, "verbose": false }
|
|
113
58
|
```
|
|
114
59
|
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
- `status`: lifecycle, pid, values, progress, result, compact summary.
|
|
118
|
-
- `tail`: recent stdout/stderr/log tail.
|
|
119
|
-
- `messages`: actor messages emitted by the run, or room timeline entries for `room:*`.
|
|
120
|
-
- Advanced `communication`: run/branch group-coordination snapshot with self/root/default-room/member/contact hints.
|
|
121
|
-
- Advanced `roster`: room member list with address, role, parent, caps, claim, status, and last seen.
|
|
122
|
-
- Advanced `contacts`: roster-derived direct-message targets without full roster metadata.
|
|
123
|
-
- Advanced `previews`: TUI-ready bounded group-message previews with timestamp/from/to/type/summary/body_preview.
|
|
124
|
-
- `mailbox`: declared accepts/emits contract for runs; queued direct branch inbox messages for `branch:<run>/<branch>` with `id`, status, route/type, and queue/handling timestamps.
|
|
125
|
-
- `files`: run state file summary plus a `lines`-bounded `review-evidence.json` manifest when present, including total/truncated command counts and stage capture paths.
|
|
126
|
-
- `artifacts`: declared artifact paths/status plus the same bounded owned review-evidence manifest when present.
|
|
127
|
-
- `recipes` target: registry summary for active, shadowed, invalid, disabled, and diagnostic recipe entries.
|
|
128
|
-
|
|
129
|
-
Let terminal notifications arrive. They queue through Pi's follow-up delivery mode, so a busy coordinator finishes its current work before receiving concurrently completed actor results; the host's `followUpMode` controls whether queued results arrive together or one at a time. Pi injects these notifications invisibly into LLM context while waking an idle coordinator, avoiding a duplicate custom-message copy in the transcript. Their LLM context content stays limited to run id, status, one base path, and relative artifact names; inspect state for raw output while correlation and semantic details remain outside LLM context. File watching accelerates delivery, while a bounded ten-second terminal-only reconciliation pass recovers missed or failed watcher activity without replaying outbox traffic; watcher degradation and rearm remain visible diagnostics. When a deferred actor result gates the next step, wait for that terminal follow-up instead of scheduling continuation loops, repeatedly inspecting, or mutating the actor's reviewed scope. Idle coordinators still start a normal turn through `triggerTurn: true`. Inspect early only for an operator request, a meaningful actor event, or diagnosis of an overdue or stuck run.
|
|
130
|
-
|
|
131
|
-
## Runtime Communication Rules
|
|
132
|
-
|
|
133
|
-
- Keep one public communication model: `spawn` creates actors, `message` sends typed envelopes, and `inspect` observes. Avoid adding public side channels or storage nouns when a normal actor address/view can express the operation.
|
|
134
|
-
- Keep route and semantic type separate. Direct, room, coordinator, and session messages may share `type`; delivery behavior comes from `to`.
|
|
135
|
-
- Treat persisted communication logs as recipe evidence. Use `inspect room:<run> view=messages|previews` and `inspect run:<id> view=communication` to improve mailbox/artifact conventions after real runs.
|
|
136
|
-
- Any UI, summary, or aggregate view that scans run directories must apply coordinator/session ownership filters before exposing summaries or body previews.
|
|
137
|
-
- Treat `communication.json` as visible actor context, not a global mutable truth table. Run-level snapshots should identify the run actor; branch-local snapshots should identify the branch actor.
|
|
138
|
-
- Prefer same-run provenance checks on lateral actor routes. If `from` is accepted for room or branch routes, validate that it belongs to the addressed run.
|
|
139
|
-
|
|
140
|
-
## Command Template Standard
|
|
141
|
-
|
|
142
|
-
Forms:
|
|
143
|
-
|
|
144
|
-
```json
|
|
145
|
-
"npm test -- {file}"
|
|
146
|
-
["npm run typecheck", "npm test"]
|
|
147
|
-
{ "parallel": true, "template": ["job-a", "job-b"] }
|
|
148
|
-
```
|
|
149
|
-
|
|
150
|
-
Controls:
|
|
151
|
-
|
|
152
|
-
- `args`, `defaults`: public placeholder declarations and defaults.
|
|
153
|
-
- `parallel: true`: fanout child nodes.
|
|
154
|
-
- `when`: conditional execution.
|
|
155
|
-
- `accept_output: review_evidence`: fail closed unless the exact first non-whitespace stdout line is `ACTOR_REVIEW_RESULT`; marker prefixes are rejected and rejected stdout remains diagnostic evidence.
|
|
156
|
-
- `timeout`, `delay`, `retry`: timing and retry controls; string placeholders are allowed where supported.
|
|
157
|
-
- `failure`: `continue`, `branch`, or `root` propagation.
|
|
158
|
-
- `recover`: cleanup between retry attempts.
|
|
159
|
-
- `repeat`: repeated node expansion.
|
|
160
|
-
- `output`: output behavior selection.
|
|
161
|
-
- Command stdout/stderr use bounded tails plus complete spill files; tool/run diagnostics expose byte counts, truncation, and spill paths, while pipelines fail with `incomplete pipeline stdin` rather than consuming a partial tail.
|
|
162
|
-
- Detached child `pi -p` commands receive isolated session storage under `sessions/command-NNN` in their owned run state, and command evidence records any resulting JSONL files. Coordinator-managed room/swarm participants use role/phase-scoped directories under the same run-local `sessions/` root so their turns remain discoverable too. Explicit `--no-session`, `--session`, `--session-id`, `--session-dir`, or `--fork` policy remains caller-owned and is never replaced.
|
|
163
|
-
- Persisted child-session inspection follows the latest JSONL entry branch, correlates tool results by call id, bounds previews, and redacts common secret-bearing fields/text. Thinking content is evidence only when Pi persisted an explicit `thinking` block; never infer or advertise hidden reasoning.
|
|
164
|
-
|
|
165
|
-
Placeholders:
|
|
166
|
-
|
|
167
|
-
- `{name}` required value.
|
|
168
|
-
- `{name=default}` inline default.
|
|
169
|
-
- `{name:type=default}` typed inline arg.
|
|
170
|
-
- `{value??fallback}` nullish fallback.
|
|
171
|
-
- `{flag?yes:no}` ternary fallback.
|
|
172
|
-
|
|
173
|
-
Templates are synchronous and portable. Recipes give them identity and lifecycle.
|
|
174
|
-
|
|
175
|
-
## Recipe Standard
|
|
176
|
-
|
|
177
|
-
Minimal actor recipe:
|
|
178
|
-
|
|
179
|
-
```json
|
|
180
|
-
{
|
|
181
|
-
"async": true,
|
|
182
|
-
"args": ["path:path", "model:string"],
|
|
183
|
-
"defaults": {},
|
|
184
|
-
"mailbox": {
|
|
185
|
-
"accepts": ["control.kill"],
|
|
186
|
-
"emits": ["command.done", "run.done", "run.failed"]
|
|
187
|
-
},
|
|
188
|
-
"artifacts": { "report": "{path}/report.md" },
|
|
189
|
-
"template": "some-command {path} --model {model}"
|
|
190
|
-
}
|
|
191
|
-
```
|
|
60
|
+
Valid Controls persist in `controls.jsonl` before delivery; invalid envelopes remain outside the journal. Token-owned locks serialize atomic journal replacements. Service endpoints publish readiness in `control-endpoint.json` with the immutable startup `run_instance_id`; only FIFO and named-pipe endpoints transport Controls. Both transports share one portable envelope: action is at most 64 lowercase ASCII characters, serialized JSON input is at most 380 bytes, and the newline-terminated wire record is at most 512 bytes. Partial writes fail, and controlled FIFO readers remain gap-free across writers. Put larger data in a declared artifact/path and send only its bounded reference or instruction through Control. Delivery revalidates owner, generation, running state, and process identity under the lifecycle lock.
|
|
192
61
|
|
|
193
|
-
|
|
62
|
+
`kill` remains a runtime lifecycle action. Use an actor-local action such as `stop` only when the Recipe declares and implements it.
|
|
194
63
|
|
|
195
|
-
|
|
196
|
-
2. `async: true` makes spawned work a detached actor run.
|
|
197
|
-
3. Public knobs belong in `args`/`defaults`; hidden launch mechanics stay inside `template`.
|
|
198
|
-
4. Use `imports` to compose recipes; imported recipes are definitions, not nested async runs.
|
|
199
|
-
5. Direct recipe delegation is the thin-wrapper case: when a `template` value is just a ready recipe name/path, the intended behavior is to delegate to that recipe rather than execute the recipe file as a program. Use this for simple handoffs and wrapper tools; use `imports` + `{ "name": "alias" }` when you need rich composition, multiple nodes, or import-specific values/defaults.
|
|
200
|
-
6. When exposing an already-authored recipe as a user tool before direct delegation is available or when composition is needed, make a small wrapper recipe in `~/.pi/agent/recipes` that imports the source recipe and uses a `{ "name": "alias" }` node. Do not copy the ready recipe's script command, defaults, mailbox, or artifacts into a second template.
|
|
201
|
-
7. Declare `mailbox` for actors that accept or emit meaningful messages.
|
|
202
|
-
8. Declare `artifacts` for durable outputs the coordinator should inspect.
|
|
203
|
-
9. File-backed recipe identity comes from the filename basename; legacy top-level `name` fields are ignored by loaders.
|
|
204
|
-
10. File-backed async recipes pass child `pi -p` actors a bounded JSONL recipe context bundle by default: raw entry/import recipe records, derived `name`, import path/alias, and `"you_are_here": true` on the launching recipe node. The runner collapses all natural-language positional fragments into one prompt under `prompts/command-NNN.md`, keeps intentional `@file` attachments separate, and invokes Pi with one authoritative prompt-file arg so large prompts and recipe context stay inspectable and argv-safe. Set `"actor_context": false` or `"off"` to suppress recipe context for minimal prompts.
|
|
205
|
-
11. Keep packaged recipes generic: no machine-local paths, no private companion identities, no project-specific defaults unless the recipe is explicitly project-specific.
|
|
206
|
-
12. Do not ship concrete model-version defaults in packaged recipes. For review-oriented subagent/lens recipes, default model/thinking args through `{current_model}` and `{current_thinking}` so they inherit the selected Pi session policy; keep `model`, `models`, `thinking`, and stage-specific model args explicit so callers can override policy at launch.
|
|
64
|
+
## Run State and Safety
|
|
207
65
|
|
|
208
|
-
|
|
66
|
+
Run state lives under `~/.pi/agent/tmp/pi-actors/runs/<run>/`. Important evidence includes:
|
|
209
67
|
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
68
|
+
- `run.json`: captured Run identity, Recipe, owner, generation, process identity, and policy.
|
|
69
|
+
- `trace.jsonl`: structured observations.
|
|
70
|
+
- `controls.jsonl`: durable actor-local inputs and outcomes.
|
|
71
|
+
- `control-endpoint.json`: generation-fenced service readiness.
|
|
72
|
+
- `execution.json`: command/session provenance and bounded complete-capture references.
|
|
73
|
+
- `result.json`, logs, and declared artifacts.
|
|
214
74
|
|
|
215
|
-
|
|
75
|
+
Never bypass owner filtering, immutable generation fencing, process-identity verification, path containment, redaction, terminal reconciliation, or shutdown kill behavior. Do not edit active Run state to force a result.
|
|
216
76
|
|
|
217
|
-
|
|
77
|
+
## Operating Pattern
|
|
218
78
|
|
|
219
|
-
1.
|
|
220
|
-
2.
|
|
79
|
+
1. Inspect the Recipe before launch when its contract or policy matters.
|
|
80
|
+
2. Spawn with explicit values and retain the returned `run:<id>`.
|
|
81
|
+
3. Let short Runs finish; avoid polling.
|
|
82
|
+
4. Inspect Trace when evidence or attention requires it.
|
|
83
|
+
5. Send only declared actor-local Controls.
|
|
84
|
+
6. Use runtime kill/cancel behavior for lifecycle termination.
|
|
85
|
+
7. Inspect artifacts and execution evidence for final validation.
|
|
221
86
|
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
Usage lens: user recipe launches update an extension-maintained canonical name-and-priority lineage ledger under `.usage/recipes/<recipe-name>.json`; authored recipe files are not rewritten for telemetry. Accounting briefly shares the portfolio mutation fence so source quarantine cannot erase an authorized launch; if another session already changed the source, the stale invocation rejects and requests reload rather than executing without evidence. Lifetime calls survive rename, revision, promotion, and demotion, while revision-local calls restart when executable content changes. The bounded unversioned ledger retains former names/paths, revision ancestry, transition events, and review epochs. Discovery merges lineage usage into inspection. Agents should not hand-edit counters; usage remains evidence rather than a sufficient usefulness verdict.
|
|
225
|
-
|
|
226
|
-
Automatic review lens: successful transient/ad hoc actor runs leave replayable drafts rather than active tools. At twelve eligible drafts, pi-actors captures one exact trusted batch and attaches only its identity-opaque value-free structural projection to a silent no-tools reviewer after the foreground turn and active actors finish. Its complete quota-free `promote`/`discard` result contains no recipe content: the deterministic executor derives promotions from exact captured sources and revalidates source/target CAS, complete recipes, root identity, quarantine hashes, and recovery state before commit. Newer drafts remain for a later batch; malformed, stale, unsafe, or incomplete decisions fail closed. Unchanged automatic demotions remain in cooldown until their executable fingerprint changes. Prefer fenced `register_tool draft=...` for an explicit single-draft promotion. A deliberate move/copy into the recipe root also remains valid, but may invalidate and defer an already captured batch; do not reconstruct removed batch commands or ask the operator to drive an automatic batch.
|
|
227
|
-
|
|
228
|
-
Portfolio lens: thirty-six eligible non-sensitive active revisions trigger a no-tools review of an attached value-free structural projection; canonical names, draft basenames, raw hashes, recipe bodies, template/default values, authored prose, and filesystem paths remain in the separate trusted capture; batch-local occurrence IDs and equality-only content groups preserve correlation and deduplication. Set `PI_ACTORS_AUTOMATIC_REVIEW=off` before Pi starts to disable both reviewer scheduling and safe-boundary portfolio activation; verify the effective value with `inspect target=tool:pi-actors view=status`. The reviewer may select keep, unchanged-source rename, unchanged-source demotion, or deduplication of canonically identical captured recipes; it cannot return recipe content. Replacement, split, and executable contract changes require explicit operator authoring. Approval remains immutable until the next safe session boundary, where journaled filesystem and lineage executors apply only the captured recipe bytes. Use `inspect target=recipes view=reviews` for bounded evidence including failed stage/error/next action. Recover a failed cycle through `message to=tool:pi-actors type=review.retry body={"scope":"draft"|"tool"}`. Draft retry resumes an existing authenticated transaction plan and original reviewer run rather than generating decisions after filesystem commit; `review.reset` clears only disposable terminal admission state and rejects tool recovery evidence that must roll forward.
|
|
229
|
-
|
|
230
|
-
## Registered Tools
|
|
231
|
-
|
|
232
|
-
`register_tool` persists trusted local capabilities as recipe files in `~/.pi/agent/recipes/*.json`; hand-authored Markdown recipes in the same directory are also discovered as tools.
|
|
233
|
-
|
|
234
|
-
Use it when a command/template/recipe should become durable agent muscle memory. Prefer typed args or placeholder-derived args; use `update=true` for replacement and `template=null` or `template=""` for deletion. `register_tool` should create/update/delete simple recipe files in the user recipe root; direct recipe-file editing is the right path when the wrapper needs `imports` or other top-level recipe metadata not exposed by the interactive mutation API.
|
|
235
|
-
|
|
236
|
-
Ready-recipe registration patterns:
|
|
237
|
-
|
|
238
|
-
Thin delegation target shape:
|
|
239
|
-
|
|
240
|
-
```json
|
|
241
|
-
{
|
|
242
|
-
"description": "Run a ready recipe through a local tool name.",
|
|
243
|
-
"args": ["source:path", "volume:int=70"],
|
|
244
|
-
"template": "/path/to/ready-recipe.json"
|
|
245
|
-
}
|
|
246
|
-
```
|
|
247
|
-
|
|
248
|
-
Delegation is for one-to-one handoff: expose or call a maintained recipe directly, preserving that recipe as the source of truth. If the runtime does not yet support direct recipe references in `template`, or if you need composition, use the import-node wrapper below.
|
|
249
|
-
|
|
250
|
-
Composition/import wrapper:
|
|
251
|
-
|
|
252
|
-
```json
|
|
253
|
-
{
|
|
254
|
-
"description": "Run the ABCd context validator through its skill recipe.",
|
|
255
|
-
"imports": {
|
|
256
|
-
"validate_context": "{agent}/skills/abcd-context/recipes/validate-context.json"
|
|
257
|
-
},
|
|
258
|
-
"args": ["path:path=."],
|
|
259
|
-
"template": { "name": "validate_context" }
|
|
260
|
-
}
|
|
261
|
-
```
|
|
262
|
-
|
|
263
|
-
Use delegation or this import pattern whenever a reusable recipe already exists: packaged pi-actors components, project-local recipes, ad hoc reviewed recipe files, and especially skill-owned recipes that wrap skill scripts. The wrapper owns only the public tool name, description, optional narrowed args/defaults, and local usage metadata. The delegated/imported recipe remains the source of truth for the script path, default values, mailbox contract, artifacts, and future fixes.
|
|
264
|
-
|
|
265
|
-
Tool-registration lenses are open-ended prompts for deciding what deserves durable tool status:
|
|
266
|
-
|
|
267
|
-
1. **Reliability lens**: register wrappers for operations where agents commonly omit checks, run steps out of order, pass ambiguous inputs, or recover poorly from partial failure.
|
|
268
|
-
2. **Safety lens**: prefer read-only diagnostics, dry-runs, preflights, confirmations, or bounded adapters around high-impact operations before registering direct action tools.
|
|
269
|
-
3. **Context-affordance lens**: register tools whose mere presence in the injected capability list should steer agents toward the right operational habit.
|
|
270
|
-
4. **Existing-recipe lens**: scan already-authored recipes before inventing a new tool. Packaged recipes, ad hoc project recipes, and recipes co-located under skill directories are the first candidates to delegate to or import from a user-root wrapper when they match a recurring local workflow.
|
|
271
|
-
5. **Skill-recipe lens**: when a skill ships a recipe for its script, local tools must delegate to or import that recipe instead of calling the skill script directly. This preserves the skill's maintained interface and keeps future script/default changes centralized.
|
|
272
|
-
6. **Composition lens**: register small semantic entrypoints over reusable recipe components instead of baking one large scenario-specific shell command into a tool; prefer direct delegation for one recipe, imports for composed graphs.
|
|
273
|
-
7. **Portability lens**: keep recipe files transportable; make tool exposure a consequence of placement in `~/.pi/agent/recipes`, not recipe-owned markers or machine-local assumptions.
|
|
274
|
-
|
|
275
|
-
Default bias: register diagnostic/preflight tools before action tools, and promote existing recipes before writing new orchestration. A good persistent tool shrinks the chance of a subtle operational mistake, not just the number of keystrokes.
|
|
276
|
-
|
|
277
|
-
Tool templates may be:
|
|
278
|
-
|
|
279
|
-
- A foreground command template.
|
|
280
|
-
- A file-backed recipe name/path for thin delegation.
|
|
281
|
-
- A complete recipe body, optionally `async: true`.
|
|
282
|
-
|
|
283
|
-
The user recipe root is the default tool set by location. It accepts canonical JSON recipes and literate Markdown recipes with frontmatter plus fenced `template`/`json recipe` blocks; same-id JSON shadows Markdown in the same priority layer. Packaged recipes are lower-priority standard-library components and are not tools unless copied or registered into the agent recipe root. Ideal runtime behavior is reactive: create/edit/delete recipe files, validate them, then connect valid tools or surface diagnostics without requiring agents to hand-maintain a separate registry.
|
|
87
|
+
If work may outlive the current turn, needs steering, produces artifacts, fans out, or must remain inspectable, use a Run rather than shell backgrounding.
|
|
284
88
|
|
|
285
89
|
## Top Recipes
|
|
286
90
|
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
- [
|
|
292
|
-
- [`pipeline-repo-health`](../../recipes/pipeline-repo-health.json): git/doc/validation evidence → normalized repository health report.
|
|
293
|
-
- [`pipeline-release-readiness`](../../recipes/pipeline-release-readiness.json): changelog/package/skill/validation evidence → release review → artifact report.
|
|
294
|
-
- [`actor-worker`](../../recipes/actor-worker.json): canonical mailbox-backed branch worker reference for claim/handle/status/artifact patterns.
|
|
295
|
-
- [`coordinator-locker`](../../recipes/coordinator-locker.json): queue + lease locks + journaled coordinator messages for multi-actor ownership.
|
|
91
|
+
- [Repository health](../../recipes/pipeline-repo-health.json)
|
|
92
|
+
- [Quorum review](../../recipes/pipeline-quorum-review.json)
|
|
93
|
+
- [Artifact bundle](../../recipes/pipeline-artifact-bundle.json)
|
|
94
|
+
- [Music player service](../../recipes/music-player.json)
|
|
95
|
+
- [Resource locker service](../../recipes/resource-locker.json)
|
|
296
96
|
|
|
297
97
|
## Deep References
|
|
298
98
|
|
|
299
|
-
-
|
|
300
|
-
-
|
|
301
|
-
-
|
|
302
|
-
- `docs/async-runs.md` — detached lifecycle, state, cancellation, observability.
|
|
303
|
-
- `docs/actor-messages.md` — addressed envelope protocol and mailbox model.
|
|
304
|
-
- `docs/tool-registry.md` — persistent tool registry and generated tools.
|
|
305
|
-
- `docs/recipe-library.md` — packaged recipes.
|
|
306
|
-
- `docs/task-first-recipes.md` — deriving reusable pipelines from operator tasks.
|
|
307
|
-
- `docs/component-recipes.md` — reusable coordinator/subagent building blocks.
|
|
308
|
-
|
|
309
|
-
## One-Sentence Contract
|
|
99
|
+
- [Recipe library](../../docs/recipe-library.md)
|
|
100
|
+
- [Async Runs](../../docs/async-runs.md)
|
|
101
|
+
- [Baseline and preservation gates](../../docs/0.43-baseline.md)
|
|
310
102
|
|
|
311
|
-
|
|
103
|
+
Read repository source and tests for exact contracts when changing pi-actors itself. Update this skill whenever durable Run mechanics change.
|
package/skills/swarm/SKILL.md
CHANGED
|
@@ -1,8 +1,6 @@
|
|
|
1
1
|
---
|
|
2
2
|
name: swarm
|
|
3
3
|
description: Subagent and actor orchestration with scoped locks, fanout, and quorum consensus. Use before launching multiple parallel actors or subagents for independent implementation, artifact generation, review, delegated audit, coordinated execution, or any workflow that needs autonomous coordinator decomposition and integration.
|
|
4
|
-
metadata:
|
|
5
|
-
version: 0.42.3
|
|
6
4
|
---
|
|
7
5
|
|
|
8
6
|
# Swarm
|
|
@@ -263,48 +261,26 @@ Use the local review protocol if available.
|
|
|
263
261
|
Report white spots, contradictions, evidence, and risks.
|
|
264
262
|
```
|
|
265
263
|
|
|
266
|
-
##
|
|
264
|
+
## Run Adapter
|
|
267
265
|
|
|
268
|
-
|
|
266
|
+
Detached execution is an adapter concern, not a portable Swarm-script requirement. When the host offers Runs, launch the composed Recipe, return its id, and rely on terminal follow-up rather than blocking or polling.
|
|
269
267
|
|
|
270
|
-
|
|
271
|
-
- `status`: Report whether the run is running, done, degraded, or failed.
|
|
272
|
-
- `tail`: Show recent structured run events or raw logs.
|
|
273
|
-
- `list`: Show known runs.
|
|
274
|
-
- `cancel`: Stop an owned active run when the adapter can prove pid ownership.
|
|
268
|
+
`Progress contract`: expose bounded structured Trace, logs, artifacts, status, timestamps, and final result evidence. Read these through Run inspection rather than scraping process output.
|
|
275
269
|
|
|
276
|
-
`
|
|
270
|
+
`Resumable checkpoint goal`: a controlled agent-backed Run may preserve context and accept a declared Control. When the host cannot preserve context, write a handoff artifact and launch a clean-context Run while marking the context loss explicitly.
|
|
277
271
|
|
|
278
|
-
`
|
|
279
|
-
|
|
280
|
-
`Progress contract`: async runs should expose structured state such as `progress.json`, `events.jsonl`, logs, and final result metadata. Local tools should read these files through async-run verbs instead of scraping process output.
|
|
281
|
-
|
|
282
|
-
`Minimum state`: an adapter should expose `run_id`, `status`, timestamps, state directory or output directory, recent events, stdout/stderr logs, and final result metadata.
|
|
283
|
-
|
|
284
|
-
`Terminal statuses`: `done`, `failed`, `timeout`, and `cancelled` are terminal. `running` and `degraded` are observable non-terminal states.
|
|
285
|
-
|
|
286
|
-
`Cancellation boundary`: cancel only an owned active run when pid ownership or runtime ownership can be verified. Stale pid reuse must fail closed.
|
|
287
|
-
|
|
288
|
-
`Reference binding`: Use a local generic async-run runtime or tool registry adapter. If the local runtime exposes a single action tool, bind these verbs as actions rather than adding more Swarm scripts. Swarm scripts themselves should stay atomic and narrowly specialized.
|
|
272
|
+
`Cancellation boundary`: terminate only an owned active generation whose process identity the runtime can prove. Stale pid reuse must fail closed.
|
|
289
273
|
|
|
290
274
|
## Stable Multi-Agent Review Rules
|
|
291
275
|
|
|
292
|
-
- Prefer independent read-only reviewers
|
|
293
|
-
- Treat
|
|
294
|
-
- Smoke-test provider/model availability before
|
|
295
|
-
- Keep methodology and runtime split: Swarm chooses decomposition, quorum, lenses, lock discipline, and merge shape; the
|
|
276
|
+
- Prefer independent read-only reviewers so they do not converge before synthesis.
|
|
277
|
+
- Treat Trace, artifacts, and immutable reviewer results as methodology evidence.
|
|
278
|
+
- Smoke-test provider/model availability before expensive fanout.
|
|
279
|
+
- Keep methodology and runtime split: Swarm chooses decomposition, quorum, lenses, lock discipline, and merge shape; the Run kernel supplies execution, Trace, Control, artifacts, and lifecycle safety.
|
|
296
280
|
|
|
297
281
|
## Persistent Implementer Pattern
|
|
298
282
|
|
|
299
|
-
Use
|
|
300
|
-
|
|
301
|
-
1. Coordinator assigns a concrete task with `task.assign` or an adapter-equivalent envelope.
|
|
302
|
-
2. Actor claims before editing or mutating shared state.
|
|
303
|
-
3. Actor executes and validates the slice.
|
|
304
|
-
4. Actor posts a result plus an explicit availability/blocked status.
|
|
305
|
-
5. Actor stays alive until another assignment or an explicit runtime/domain stop.
|
|
306
|
-
|
|
307
|
-
Use opposite-end or lens-specific implementers only to reduce overlap, not as a default. If a host adapter cannot express this scenario from reusable cells, add missing generic cells before packaging a broad workflow.
|
|
283
|
+
Use long-lived controlled services only when repeated assignments justify them. Keep task selection with the orchestrator and use explicit artifacts or task cards for claims/results. Resource exclusion may use the optional `resource-locker`; it does not become swarm authority. Prefer multiple scoped Runs over a peer protocol.
|
|
308
284
|
|
|
309
285
|
## `swarm_quorum`
|
|
310
286
|
|
|
@@ -1,13 +0,0 @@
|
|
|
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
|
-
}
|
|
@@ -1,41 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Mailbox worker loop primitives.
|
|
3
|
-
* Zones: mailbox-consuming actors, run/branch inbox claiming, handler status transitions
|
|
4
|
-
* Owns reusable claim/handle/drain behavior across run and branch inboxes; scheduling and task policy stay outside.
|
|
5
|
-
*/
|
|
6
|
-
import { type BranchInboxRecord } from "./rooms.ts";
|
|
7
|
-
import { type RunInboxMessage } from "./async-runs.ts";
|
|
8
|
-
export type MailboxLoopMessage = RunInboxMessage | BranchInboxRecord;
|
|
9
|
-
export type MailboxLoopTarget = {
|
|
10
|
-
kind: "run";
|
|
11
|
-
runOrDir: string;
|
|
12
|
-
} | {
|
|
13
|
-
address: string;
|
|
14
|
-
kind: "branch";
|
|
15
|
-
run: string;
|
|
16
|
-
stateDir: string;
|
|
17
|
-
};
|
|
18
|
-
export interface MailboxLoopClaimOptions {
|
|
19
|
-
owner?: string;
|
|
20
|
-
statuses?: string[];
|
|
21
|
-
}
|
|
22
|
-
export interface MailboxLoopHandleResult {
|
|
23
|
-
handled: boolean;
|
|
24
|
-
id?: string;
|
|
25
|
-
message?: MailboxLoopMessage;
|
|
26
|
-
target: MailboxLoopTarget;
|
|
27
|
-
}
|
|
28
|
-
export interface MailboxLoopDrainOptions extends MailboxLoopClaimOptions {
|
|
29
|
-
maxMessages?: number;
|
|
30
|
-
stopOnControl?: boolean;
|
|
31
|
-
}
|
|
32
|
-
export interface MailboxLoopDrainResult {
|
|
33
|
-
handled: number;
|
|
34
|
-
stopped: boolean;
|
|
35
|
-
target: MailboxLoopTarget;
|
|
36
|
-
}
|
|
37
|
-
export declare function isMailboxLoopStopMessage(message: unknown): boolean;
|
|
38
|
-
export declare function claimMailboxLoopMessage(target: MailboxLoopTarget, options?: MailboxLoopClaimOptions): MailboxLoopMessage | undefined;
|
|
39
|
-
export declare function updateMailboxLoopMessageStatus(target: MailboxLoopTarget, id: string, status: "claimed" | "handled" | "failed", metadata?: Record<string, unknown>): boolean;
|
|
40
|
-
export declare function handleMailboxLoopOnce(target: MailboxLoopTarget, handler: (message: MailboxLoopMessage) => Promise<void> | void, options?: MailboxLoopClaimOptions): Promise<MailboxLoopHandleResult>;
|
|
41
|
-
export declare function drainMailboxLoopMessages(target: MailboxLoopTarget, handler: (message: MailboxLoopMessage) => Promise<void> | void, options?: MailboxLoopDrainOptions): Promise<MailboxLoopDrainResult>;
|