@llblab/pi-actors 0.14.3 → 0.16.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/AGENTS.md +5 -1
- package/BACKLOG.md +54 -32
- package/CHANGELOG.md +39 -0
- package/README.md +53 -61
- package/banner.jpg +0 -0
- package/docs/actor-messages.md +1 -1
- package/docs/async-runs.md +4 -4
- package/docs/command-templates.md +11 -11
- package/docs/recipe-library.md +7 -3
- package/docs/task-first-recipes.md +44 -43
- package/docs/template-recipes.md +45 -23
- package/docs/tool-registry.md +50 -42
- package/index.ts +34 -0
- package/lib/actor-messages.ts +20 -7
- package/lib/async-runs.ts +35 -12
- package/lib/command-templates.ts +6 -1
- package/lib/config.ts +3 -2
- package/lib/execution.ts +9 -5
- package/lib/observability.ts +20 -10
- package/lib/paths.ts +6 -1
- package/lib/prompts.ts +14 -21
- package/lib/recipe-discovery.ts +226 -0
- package/lib/recipe-migration.ts +123 -0
- package/lib/recipe-references.ts +45 -13
- package/lib/recipe-usage.ts +44 -0
- package/lib/registry.ts +48 -15
- package/lib/runtime.ts +59 -15
- package/lib/tools.ts +237 -65
- package/package.json +21 -11
- package/recipes/coordinator-locker.json +46 -0
- package/recipes/music-player.json +16 -2
- package/recipes/pipeline-architect-coordinator.json +11 -3
- package/recipes/pipeline-artifact-bundle.json +12 -3
- package/recipes/pipeline-artifact-report.json +9 -3
- package/recipes/pipeline-artifact-write.json +9 -3
- package/recipes/pipeline-async-run-ops.json +18 -9
- package/recipes/pipeline-checkpoint-continuation.json +14 -3
- package/recipes/pipeline-development-tasking.json +12 -3
- package/recipes/pipeline-docs-maintenance.json +12 -3
- package/recipes/pipeline-media-library.json +12 -3
- package/recipes/pipeline-quorum-review.json +12 -9
- package/recipes/pipeline-release-readiness.json +27 -9
- package/recipes/pipeline-release-summary.json +89 -0
- package/recipes/pipeline-repo-health.json +12 -3
- package/recipes/pipeline-research-synthesis.json +11 -3
- package/recipes/pipeline-review-readiness.json +12 -6
- package/recipes/subagent-artifact.json +9 -3
- package/recipes/subagent-checkpoint.json +10 -3
- package/recipes/subagent-conflict-report.json +11 -3
- package/recipes/subagent-contradiction-map.json +11 -3
- package/recipes/subagent-critic.json +11 -3
- package/recipes/subagent-evidence-map.json +11 -3
- package/recipes/subagent-followup.json +10 -3
- package/recipes/subagent-judge.json +11 -3
- package/recipes/subagent-merge.json +11 -3
- package/recipes/subagent-message.json +8 -3
- package/recipes/subagent-normalize.json +11 -3
- package/recipes/subagent-plan.json +11 -3
- package/recipes/subagent-prompt.json +10 -3
- package/recipes/subagent-quorum.json +10 -7
- package/recipes/subagent-review-coordinator.json +14 -6
- package/recipes/subagent-review.json +11 -3
- package/recipes/subagent-task-card.json +11 -3
- package/recipes/subagent-tools.json +10 -3
- package/recipes/subagent-verify.json +11 -3
- package/recipes/subagents-prompts.json +10 -3
- package/recipes/utility-coordinator-lock-snapshot.json +14 -0
- package/recipes/utility-run-ops-snapshot.json +3 -3
- package/recipes/utility-skill-summary.json +14 -0
- package/scripts/coordinator-locker.mjs +272 -0
- package/scripts/music-player.mjs +2 -1
- package/scripts/recipe-utils.mjs +239 -81
- package/scripts/validate-recipe.mjs +28 -10
- package/skills/actors/SKILL.md +301 -0
- package/skills/swarm/SKILL.md +451 -0
- package/skills/swarm/references/development-swarm.md +596 -0
|
@@ -0,0 +1,451 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: swarm
|
|
3
|
+
description: Subagent orchestration with scoped locks and quorum consensus. Use for multi-model review, parallel scoped work, delegated audit, and coordinated subagent execution.
|
|
4
|
+
metadata:
|
|
5
|
+
version: 0.16.0
|
|
6
|
+
---
|
|
7
|
+
|
|
8
|
+
# Swarm
|
|
9
|
+
|
|
10
|
+
Subagent orchestration: delegated review, quorum consensus, scoped locks, clean-context merge, and post-merge review.
|
|
11
|
+
|
|
12
|
+
## Purpose
|
|
13
|
+
|
|
14
|
+
Run subagents safely and predictably through reusable orchestration contracts.
|
|
15
|
+
|
|
16
|
+
Swarm is independent. It must not require concrete sibling skill names, private repositories, local model aliases, or a specific tool registry layout. Local agents may bind the contracts to their own tools, command templates, model names, and review protocols.
|
|
17
|
+
|
|
18
|
+
## Core Concepts
|
|
19
|
+
|
|
20
|
+
- `Orchestrator`: Main agent. Coordinates subagents, owns safety, and writes final artifacts.
|
|
21
|
+
- `Subagent`: Bounded delegated model call for review, audit, merge, or scoped implementation.
|
|
22
|
+
- `Scope`: File, directory, module, or logical domain that a subagent operates on.
|
|
23
|
+
- `Lock`: Read or write ownership of a scope for bounded time.
|
|
24
|
+
- `Quorum`: Multiple independent subagents reviewing the same target.
|
|
25
|
+
- `Merger`: Clean-context fifth subagent that synthesizes raw quorum outputs.
|
|
26
|
+
- `Reviewer`: Post-merge reviewer that checks report quality, not the original domain by default.
|
|
27
|
+
- `Async Run Adapter`: Local async binding that starts, tracks, lists, tails, and cancels swarm runs through a generic lifecycle runtime.
|
|
28
|
+
- `Async Run`: A local lifecycle envelope around a command-template swarm composer or utility. It owns state, logs, status, cancellation, and observability, not swarm semantics.
|
|
29
|
+
- `Lens`: A deliberately narrow cognitive role assigned to one subagent, such as security, tests, architecture, economics, or operator UX.
|
|
30
|
+
- `Task Card`: A bounded implementation assignment with goal, allowed files, avoided files, expected output, and validation gates.
|
|
31
|
+
- `Component Capability`: An abstract adapter operation such as launcher, reviewer, verifier, merger, quorum, checkpoint, follow-up, judge, or normalizer. Swarm may target these capabilities, but local adapters bind them to concrete tools, recipes, command templates, async runs, or services.
|
|
32
|
+
- `Coordinator Checkpoint`: A deliberate subagent pause where the subagent preserves its working context, sends a bounded question or status to the orchestrator, receives a coordinator reply, and continues in the same subagent context.
|
|
33
|
+
- `Evidence Checkpoint`: A deliberate stop where a subagent records sources, assumptions, confidence, contradictions, or blocking evidence gaps before synthesis.
|
|
34
|
+
- `Integrator`: The human or agent that merges isolated branches/worktrees into the shared target and owns conflict resolution.
|
|
35
|
+
|
|
36
|
+
## Swarm Principle
|
|
37
|
+
|
|
38
|
+
One agent should hold one lens. Many independent lenses make the whole judgement stronger. Parallel lenses make the whole judgement faster.
|
|
39
|
+
|
|
40
|
+
Swarm is useful because focused subagents usually perform better than one overloaded model trying to reason about every concern at once. Each subagent receives the same target but a narrower mandate, reducing cognitive load and making misses less correlated. The merger then synthesizes the independent observations into one decision-grade artifact.
|
|
41
|
+
|
|
42
|
+
Use swarm when the work benefits from parallel cognitive lenses, not merely because more models are available. A good swarm decomposes the task into review surfaces that are independently meaningful, then preserves agreement, disagreement, and minority high-impact findings.
|
|
43
|
+
|
|
44
|
+
## Swarm Shapes
|
|
45
|
+
|
|
46
|
+
Distinguish breadth from confidence before launching subagents.
|
|
47
|
+
|
|
48
|
+
```text
|
|
49
|
+
Lens Swarm = different lenses on one object
|
|
50
|
+
Quorum = one lens, multiple independent judges
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
`Lens Swarm` optimizes coverage. It asks which aspects matter and sends focused agents through different mandates: architecture, security, tests, UX, release, docs, economics, governance, or operations. Use it for brainstorming, product design, architecture exploration, development planning, and broad risk review.
|
|
54
|
+
|
|
55
|
+
`Quorum` optimizes confidence. It keeps the lens constant and varies models, seeds, prompts, or independent instances so several judges answer the same question. Use it mostly for verification: high-stakes review, security verdicts, ambiguous bug hypotheses, publish readiness, and final confidence checks.
|
|
56
|
+
|
|
57
|
+
`Lens Swarm of Quorums` optimizes both breadth and confidence. Each important lens gets its own mini-quorum, and a merger synthesizes across lenses while preserving vote counts and minority high-impact findings. This is expensive and should be reserved for high-stakes systems such as money movement, blockchain protocols, governance, security boundaries, migrations, or public releases.
|
|
58
|
+
|
|
59
|
+
Decision rule:
|
|
60
|
+
|
|
61
|
+
```text
|
|
62
|
+
Need breadth? Use Lens Swarm.
|
|
63
|
+
Need confidence? Use Quorum.
|
|
64
|
+
Need both? Use Lens Swarm of Quorums.
|
|
65
|
+
```
|
|
66
|
+
|
|
67
|
+
## Work Modes
|
|
68
|
+
|
|
69
|
+
Swarm is not only for review. The same lens discipline supports ideation, research-style exploration, planning, implementation coordination, and verification.
|
|
70
|
+
|
|
71
|
+
### Brainstorm Swarm
|
|
72
|
+
|
|
73
|
+
Purpose: turn many possible futures into one recommended direction.
|
|
74
|
+
|
|
75
|
+
Typical lenses:
|
|
76
|
+
|
|
77
|
+
- Product/user value
|
|
78
|
+
- Operator UX
|
|
79
|
+
- Protocol or platform cleanliness
|
|
80
|
+
- Implementation pragmatism
|
|
81
|
+
- Adoption/growth
|
|
82
|
+
- Skeptic/failure modes
|
|
83
|
+
- Constraints and portability
|
|
84
|
+
|
|
85
|
+
Merger output:
|
|
86
|
+
|
|
87
|
+
- Recommended direction
|
|
88
|
+
- Alternatives considered and rejected
|
|
89
|
+
- Open questions
|
|
90
|
+
- First implementation slice
|
|
91
|
+
- Risks and validation gates
|
|
92
|
+
|
|
93
|
+
Brainstorm swarms should not vote mechanically. They should preserve creative tension and synthesize a direction that fits constraints.
|
|
94
|
+
|
|
95
|
+
### Research Swarm
|
|
96
|
+
|
|
97
|
+
Purpose: turn a broad question into evidence-backed synthesis without letting one agent's search path dominate the answer.
|
|
98
|
+
|
|
99
|
+
Typical lenses:
|
|
100
|
+
|
|
101
|
+
- Question/scope formulation
|
|
102
|
+
- Source discovery
|
|
103
|
+
- Source verification
|
|
104
|
+
- Synthesis and contradiction mapping
|
|
105
|
+
- Devil's advocate / counter-evidence
|
|
106
|
+
- Ethics, policy, or stakeholder impact when relevant
|
|
107
|
+
|
|
108
|
+
Research swarm rules:
|
|
109
|
+
|
|
110
|
+
1. Scope first: the coordinator defines the question, non-goals, source classes, and stop condition before launching evidence work.
|
|
111
|
+
2. Search and verification are separate lenses when stakes are high; the searcher finds candidates, the verifier checks quality and support.
|
|
112
|
+
3. Every material claim in synthesis must trace to a source note, inspected artifact, or explicit uncertainty statement.
|
|
113
|
+
4. Contradictory evidence is preserved as a first-class output, not hidden by consensus language.
|
|
114
|
+
5. Evidence checkpoints block synthesis when sources are insufficient, unverifiable, conflicted, or ethically unsafe to use.
|
|
115
|
+
|
|
116
|
+
Merger output:
|
|
117
|
+
|
|
118
|
+
- Bounded research question
|
|
119
|
+
- Evidence map with confidence and source quality
|
|
120
|
+
- Areas of convergence and contradiction
|
|
121
|
+
- Limitations and not-checkable claims
|
|
122
|
+
- Recommended decision or next evidence slice
|
|
123
|
+
|
|
124
|
+
Research swarms are for inquiry and synthesis, not automatic publication pipelines. Keep report formatting local to the caller's domain.
|
|
125
|
+
|
|
126
|
+
### Development Swarm
|
|
127
|
+
|
|
128
|
+
Purpose: turn one accepted direction into coordinated slices.
|
|
129
|
+
|
|
130
|
+
Recommended flow:
|
|
131
|
+
|
|
132
|
+
```text
|
|
133
|
+
Planner → Lens Swarm → Merger → Scoped Implementers → Integrator → Review Swarm
|
|
134
|
+
```
|
|
135
|
+
|
|
136
|
+
Use scoped write locks or a repository-local soft-lock manifest when multiple implementers may edit files. Keep implementation agents bounded by module, artifact, or responsibility: code, tests, docs, examples, migration, or release notes. Prefer one owner per writable scope and run verification with fresh reviewers after implementation.
|
|
137
|
+
|
|
138
|
+
### Small-Team Development Swarm
|
|
139
|
+
|
|
140
|
+
For 2–4 implementation agents, prefer the dedicated MAWP reference instead of expanding the general Swarm skill. The portable idea is simple: isolate writable work surfaces, give each agent a bounded task card, preserve handoff evidence, and merge through one integrator.
|
|
141
|
+
|
|
142
|
+
Use [`references/development-swarm.md`](./references/development-swarm.md) for concrete worktree/branch flow, task-card templates, soft-lock manifests, conflict reports, coordinator checkpoints, and merge rules.
|
|
143
|
+
|
|
144
|
+
### Review Swarm
|
|
145
|
+
|
|
146
|
+
Purpose: turn one result into many risk lenses and a decision-grade verdict.
|
|
147
|
+
|
|
148
|
+
Use lens swarm for broad coverage, quorum for confidence on one critical judgement, or both for high-stakes releases. The final report should separate consensus findings, minority findings, merger findings, risks, and recommended next actions.
|
|
149
|
+
|
|
150
|
+
A review swarm synthesis must not fabricate claims. Every final finding should trace to a reviewer note, checked artifact, command output, source, or explicit merger rationale. Devil's Advocate critical findings must be preserved or explicitly disproved with evidence.
|
|
151
|
+
|
|
152
|
+
## Lens Catalog
|
|
153
|
+
|
|
154
|
+
Choose lenses by risk. Do not run every lens by default; select the smallest set that covers the failure modes of the work.
|
|
155
|
+
|
|
156
|
+
### General Software Lenses
|
|
157
|
+
|
|
158
|
+
- `Architecture`: module boundaries, dependency direction, cohesion, coupling, extensibility, and long-term ownership.
|
|
159
|
+
- `Correctness`: functional behavior, edge cases, invariants, state transitions, and input/output contracts.
|
|
160
|
+
- `Bug Hunter`: likely defects, race conditions, null/empty cases, off-by-one errors, and broken assumptions.
|
|
161
|
+
- `Security`: injection, privilege boundaries, path handling, secrets, deserialization, unsafe shell/process use, and abuse cases.
|
|
162
|
+
- `Tests`: coverage quality, missing regressions, fixture realism, flaky risk, and validation gates.
|
|
163
|
+
- `Performance`: algorithmic cost, latency, memory, IO, batching, backpressure, and hot paths.
|
|
164
|
+
- `Concurrency`: locks, cancellation, timeouts, idempotency, retries, ordering, and stale state.
|
|
165
|
+
- `Data Integrity`: migrations, schema compatibility, durability, rollback, deduplication, and corruption risk.
|
|
166
|
+
- `API Compatibility`: public contract drift, backwards compatibility, versioning, deprecation, and client impact.
|
|
167
|
+
- `Operator UX`: observability, error messages, status, logs, recovery paths, safe defaults, and support burden.
|
|
168
|
+
- `Developer UX`: onboarding, local setup, naming, examples, docs, type ergonomics, and debugging clarity.
|
|
169
|
+
- `Product UX`: user journey, surprising behavior, accessibility, copy, affordances, and feedback loops.
|
|
170
|
+
- `Release`: changelog truth, version bump, package contents, CI gates, publish risk, and rollback readiness.
|
|
171
|
+
- `Documentation`: README accuracy, examples, conceptual consistency, and stale references.
|
|
172
|
+
- `Compliance/Policy`: licenses, privacy, retention, consent, audit trails, and organizational constraints.
|
|
173
|
+
- `Incident Response`: blast radius, detection, containment, rollback, forensics, and runbook quality.
|
|
174
|
+
- `SRE/Reliability`: availability, graceful degradation, monitoring, quotas, rate limits, and dependency failure.
|
|
175
|
+
- `Maintainability`: simplicity, naming, duplication, dead code, testability, and future change cost.
|
|
176
|
+
- `Spec Consistency`: whether code, docs, tests, prompts, and changelog describe the same behavior.
|
|
177
|
+
|
|
178
|
+
### Complex System / Blockchain Lenses
|
|
179
|
+
|
|
180
|
+
Use these for blockchain, distributed systems, financial protocols, governance, or adversarial environments.
|
|
181
|
+
|
|
182
|
+
- `Protocol Invariants`: conservation laws, supply rules, ledger consistency, finality assumptions, and impossible states.
|
|
183
|
+
- `Consensus Safety`: fork choice, quorum thresholds, validator behavior, equivocation, reorg handling, and liveness tradeoffs.
|
|
184
|
+
- `Economic Security`: incentives, MEV, griefing, sybil cost, fee dynamics, slashing, reward leakage, and manipulation paths.
|
|
185
|
+
- `Smart Contract Safety`: reentrancy, authorization, upgradeability, storage layout, oracle trust, token standards, and invariant tests.
|
|
186
|
+
- `Cryptography`: key management, signature/domain separation, nonce use, randomness, hash commitments, and proof assumptions.
|
|
187
|
+
- `Cross-Chain/Bridge`: message replay, finality mismatch, validator set drift, withdrawal delays, and custody assumptions.
|
|
188
|
+
- `Governance`: proposal lifecycle, quorum rules, timelocks, emergency powers, capture risk, and voter/operator UX.
|
|
189
|
+
- `Treasury/Accounting`: balance reconciliation, fee distribution, rounding, precision, reserves, and auditability.
|
|
190
|
+
- `Adversarial Simulation`: attacker goals, cheapest exploit path, denial-of-service vectors, sandwiching, and liquidation games.
|
|
191
|
+
- `Network/P2P`: peer discovery, gossip propagation, eclipse risk, bandwidth limits, spam resistance, and partition behavior.
|
|
192
|
+
- `Node Operations`: sync, snapshots, pruning, backups, observability, upgrades, config safety, and rollback.
|
|
193
|
+
- `Formal Methods`: invariant specification, model checking candidates, property tests, and proof gaps.
|
|
194
|
+
- `Regulatory Surface`: custody, KYC/AML implications, sanctions, securities risk, data retention, and jurisdictional assumptions.
|
|
195
|
+
|
|
196
|
+
## Tool Contracts
|
|
197
|
+
|
|
198
|
+
These are abstract tool contracts. Register them in whatever local tool layer exists. Concrete syntax is an adapter detail outside this skill.
|
|
199
|
+
|
|
200
|
+
- `swarm_review`: single subagent review.
|
|
201
|
+
- `swarm_quorum`: multi-model independent review.
|
|
202
|
+
- `swarm_claim`: acquire a scoped read/write lock.
|
|
203
|
+
- `swarm_release`: release a scoped lock.
|
|
204
|
+
- `swarm_merge`: synthesize raw quorum outputs.
|
|
205
|
+
- `swarm_post_merge_review`: review the merged report quality.
|
|
206
|
+
|
|
207
|
+
## File Handoff
|
|
208
|
+
|
|
209
|
+
Prefer path handoff over attachment syntax. Put the target path directly in the subagent prompt:
|
|
210
|
+
|
|
211
|
+
```text
|
|
212
|
+
Review this local file: /path/to/file.md. First read it from disk.
|
|
213
|
+
```
|
|
214
|
+
|
|
215
|
+
Attachment syntax is optional local optimization, not a swarm contract. Path handoff keeps the skill portable across wrappers without attachment arguments.
|
|
216
|
+
|
|
217
|
+
## `swarm_review`
|
|
218
|
+
|
|
219
|
+
Single subagent review.
|
|
220
|
+
|
|
221
|
+
`Inputs`:
|
|
222
|
+
|
|
223
|
+
- `scope`: file path, directory, module, or logical domain.
|
|
224
|
+
- `model`: model identifier in the local environment.
|
|
225
|
+
- `prompt`: optional review lens or task-specific instructions.
|
|
226
|
+
- `thinking`: optional reasoning depth.
|
|
227
|
+
- `tools`: optional local tool allowlist.
|
|
228
|
+
- `timeout`: timeout in seconds.
|
|
229
|
+
|
|
230
|
+
`Behavior`:
|
|
231
|
+
|
|
232
|
+
1. Optionally claim a read lock for the scope.
|
|
233
|
+
2. Spawn one subagent with a prompt that includes the scope path.
|
|
234
|
+
3. Require the subagent to read the target from disk before judging it.
|
|
235
|
+
4. Return the subagent's raw output.
|
|
236
|
+
5. Release the lock if one was claimed.
|
|
237
|
+
|
|
238
|
+
`Reference prompt`:
|
|
239
|
+
|
|
240
|
+
```text
|
|
241
|
+
Review this local scope: <scope>.
|
|
242
|
+
First read it from disk.
|
|
243
|
+
Use the local review protocol if available.
|
|
244
|
+
Report white spots, contradictions, evidence, and risks.
|
|
245
|
+
```
|
|
246
|
+
|
|
247
|
+
## Async Run Adapter
|
|
248
|
+
|
|
249
|
+
Async run management is an adapter concern, not a portable Swarm script requirement. For non-trivial asynchronous agentic work, use an async-run flow when the local runtime supports it: command-template execution plus a thin detached lifecycle envelope.
|
|
250
|
+
|
|
251
|
+
- `start`: Launch a swarm run in the background and return run metadata.
|
|
252
|
+
- `status`: Report whether the run is running, done, degraded, or failed.
|
|
253
|
+
- `tail`: Show recent structured run events or raw logs.
|
|
254
|
+
- `list`: Show known runs.
|
|
255
|
+
- `cancel`: Stop an owned active run when the adapter can prove pid ownership.
|
|
256
|
+
|
|
257
|
+
`Purpose`: Keep the user interface responsive while reviewers, merger, and post-merge reviewer run. Generic run state belongs to a local async lifecycle runtime; swarm-specific execution stays in atomic utilities or command-template composition. The orchestrator should start the run, return metadata, then inspect status/tail after terminal events instead of blocking on sleeps or foreground waits.
|
|
258
|
+
|
|
259
|
+
`Resumable checkpoint goal`: Advanced adapters should strive to support a paused subagent that can ask the orchestrator for input and then resume in the same subagent context. The portable contract is a structured coordinator checkpoint plus a coordinator reply; the mechanism may be a TTY session, persistent model session, message queue, or runtime-specific resume token. If the runtime cannot preserve context, degrade to a handoff artifact and a new subagent, and mark the context loss explicitly.
|
|
260
|
+
|
|
261
|
+
`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.
|
|
262
|
+
|
|
263
|
+
`Minimum state`: an adapter should expose `run_id`, `status`, timestamps, state directory or output directory, recent events, stdout/stderr logs, and final result metadata.
|
|
264
|
+
|
|
265
|
+
`Terminal statuses`: `done`, `failed`, `timeout`, and `cancelled` are terminal. `running` and `degraded` are observable non-terminal states.
|
|
266
|
+
|
|
267
|
+
`Cancellation boundary`: cancel only an owned active run when pid ownership or runtime ownership can be verified. Stale pid reuse must fail closed.
|
|
268
|
+
|
|
269
|
+
`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.
|
|
270
|
+
|
|
271
|
+
## `swarm_quorum`
|
|
272
|
+
|
|
273
|
+
Multi-model review by independent subagents.
|
|
274
|
+
|
|
275
|
+
`Inputs`:
|
|
276
|
+
|
|
277
|
+
- `scope`: target path or domain.
|
|
278
|
+
- `models`: 2-6 model identifiers.
|
|
279
|
+
- `prompt`: shared review lens.
|
|
280
|
+
- `thinking`: per-model or shared reasoning depth.
|
|
281
|
+
- `timeout`: per-subagent or whole-quorum timeout.
|
|
282
|
+
- `merge_mode`: merge behavior, default `consensus-first`.
|
|
283
|
+
- `merger_model`: explicit model for the clean merger.
|
|
284
|
+
|
|
285
|
+
`Behavior`:
|
|
286
|
+
|
|
287
|
+
1. Claim a shared read lock when the target is local and stable.
|
|
288
|
+
2. Spawn one subagent per model concurrently unless a local rate limit requires throttling.
|
|
289
|
+
3. Give every subagent the same target path and review lens.
|
|
290
|
+
4. Preserve every raw output.
|
|
291
|
+
5. Release the lock.
|
|
292
|
+
6. Run a clean-context merger subagent.
|
|
293
|
+
7. Store or return the merged report.
|
|
294
|
+
8. Optionally run post-merge review.
|
|
295
|
+
|
|
296
|
+
`Reference binding`: Implement this contract through a local adapter such as a command-template composer, registered tool, or async run. The portable Swarm skill intentionally does not ship a runtime-specific quorum runner.
|
|
297
|
+
|
|
298
|
+
`Serious quorum rule`: For high-stakes review, the merger is not the current orchestrator. The merger is a fifth clean-context subagent.
|
|
299
|
+
|
|
300
|
+
## Lock Protocol
|
|
301
|
+
|
|
302
|
+
Locks prevent subagents from interfering with shared scopes. Locks are optional for read-only review, but required for concurrent mutation.
|
|
303
|
+
|
|
304
|
+
### Lock Fields
|
|
305
|
+
|
|
306
|
+
- `scope`: Scope identifier, usually a path or domain label.
|
|
307
|
+
- `owner`: Subagent or quorum run that owns the lock.
|
|
308
|
+
- `type`: `read` or `write`.
|
|
309
|
+
- `acquired`: Acquisition time.
|
|
310
|
+
- `ttl`: Time-to-live in seconds.
|
|
311
|
+
- `expires`: Expiry time derived from acquisition plus TTL.
|
|
312
|
+
|
|
313
|
+
### Conflict Rules
|
|
314
|
+
|
|
315
|
+
- `read` request with no lock: allow.
|
|
316
|
+
- `read` request with existing `read`: allow.
|
|
317
|
+
- `read` request with existing `write`: conflict unless stale.
|
|
318
|
+
- `write` request with no lock: allow.
|
|
319
|
+
- `write` request with existing `read` or `write`: conflict unless stale.
|
|
320
|
+
|
|
321
|
+
### Lifecycle
|
|
322
|
+
|
|
323
|
+
1. `acquire`: prune stale locks, then check conflicts.
|
|
324
|
+
2. `hold`: run the bounded subagent task.
|
|
325
|
+
3. `release`: remove the entry.
|
|
326
|
+
4. `expire`: any later lock operation may prune stale entries.
|
|
327
|
+
|
|
328
|
+
`TTL rule`: Every lock must have a TTL. A lock without expiry is invalid.
|
|
329
|
+
|
|
330
|
+
`Adapter implementation`: Use a local actor/runtime adapter when automation, TTL enforcement, or machine-readable lock state is needed. The portable Swarm skill defines lock semantics but does not ship a lock runtime.
|
|
331
|
+
|
|
332
|
+
## Validation
|
|
333
|
+
|
|
334
|
+
After changing Swarm adapter contracts or packaged documentation, validate the local distribution with whatever checks the host project provides. At minimum, review the text for boundary drift:
|
|
335
|
+
|
|
336
|
+
- no dependency on a specific extension, actor runtime, registry, recipe store, or CLI runner;
|
|
337
|
+
- no bundled broad coordinator or lock runtime as portable Swarm core;
|
|
338
|
+
- no hard-coded model names, private paths, or transport-specific message syntax in the methodology contract;
|
|
339
|
+
- adapter examples remain examples, not requirements.
|
|
340
|
+
|
|
341
|
+
If a host package ships a Swarm self-test, treat it as a local packaging gate rather than part of the portable methodology.
|
|
342
|
+
|
|
343
|
+
## Merge Protocol
|
|
344
|
+
|
|
345
|
+
The merger is not a passive formatter. The merger is the final synthesis agent and can materially affect the output by choosing labels, grouping findings, deciding severity, preserving minority signals, and adding grounded judgement.
|
|
346
|
+
|
|
347
|
+
`Merger influence`: High.
|
|
348
|
+
|
|
349
|
+
`Merger role`: Read all raw outputs, deduplicate, rank, preserve dissent, and produce one decision-grade artifact. The merger may add its own finding only as `merger finding` and only when grounded in evidence.
|
|
350
|
+
|
|
351
|
+
`Merger isolation`: For serious quorum work, the merger should be a dedicated clean-context subagent with explicit model, thinking level, and minimal access. The orchestrator provides the input bundle and writes the final artifact after the merger returns.
|
|
352
|
+
|
|
353
|
+
`Orchestrator merge exception`: The orchestrator may merge quick, low-stakes, or exploratory quorum runs. The report must say the merge was not isolated.
|
|
354
|
+
|
|
355
|
+
### Merge Parameters
|
|
356
|
+
|
|
357
|
+
- `merger_model`: Explicit synthesis model. Required for quorum reports.
|
|
358
|
+
- `merger_context`: Clean or inherited context. Default `clean` for serious quorum.
|
|
359
|
+
- `merger_tools`: Tool access granted to merger. Prefer none if raw text is embedded; otherwise read-only access to raw outputs.
|
|
360
|
+
- `merger_thinking`: Reasoning depth. Use `medium` normally, `high` for architecture, security, money, governance, migrations, or specs.
|
|
361
|
+
- `merge_mode`: Synthesis style. Default `consensus-first`.
|
|
362
|
+
- `consensus_threshold`: Votes needed to promote. Use `3/4` for critical promotion and `2/4` for major discussion by default.
|
|
363
|
+
- `minority_policy`: Treatment of unique findings. Preserve high-impact, evidence-backed minority findings.
|
|
364
|
+
- `attribution`: Which model found what. Required for quorum reports.
|
|
365
|
+
- `raw_retention`: Keep raw outputs until the final report is accepted.
|
|
366
|
+
|
|
367
|
+
### Merge Modes
|
|
368
|
+
|
|
369
|
+
- `faithful`: Minimal editing; preserves subagent wording and uncertainty.
|
|
370
|
+
- `consensus-first`: Groups by agreement and preserves dissent separately.
|
|
371
|
+
- `risk-first`: Promotes high-impact minority findings even without consensus.
|
|
372
|
+
- `design-synthesis`: Converts findings into decisions and repair order.
|
|
373
|
+
|
|
374
|
+
### Merge Guardrails
|
|
375
|
+
|
|
376
|
+
- Preserve raw outputs until the final report is accepted.
|
|
377
|
+
- Do not hide model disagreement.
|
|
378
|
+
- Do not drop high-impact minority findings only for lack of consensus.
|
|
379
|
+
- Do not over-promote repeated low-value nitpicks.
|
|
380
|
+
- Keep model attribution for every major finding.
|
|
381
|
+
- Keep merger identity explicit: model, context, thinking, and tools.
|
|
382
|
+
- Separate `consensus finding`, `minority finding`, and `merger finding`.
|
|
383
|
+
- Separate current-quorum votes from prior-run corroboration.
|
|
384
|
+
|
|
385
|
+
## Post-Merge Review
|
|
386
|
+
|
|
387
|
+
Run a reviewer on the merged report when the output will drive code, architecture, security, money, governance, migrations, or specifications.
|
|
388
|
+
|
|
389
|
+
`Purpose`: Review the review. The reviewer checks whether the merger preserved evidence, ranked severity honestly, avoided hallucinated synthesis, kept minority high-impact findings, and produced an actionable artifact.
|
|
390
|
+
|
|
391
|
+
`Reviewer input`:
|
|
392
|
+
|
|
393
|
+
- Target scope
|
|
394
|
+
- Raw subagent outputs
|
|
395
|
+
- Merged report
|
|
396
|
+
- Merge parameters
|
|
397
|
+
- Intended use of the report
|
|
398
|
+
|
|
399
|
+
`Reviewer output`: Meta-findings about report quality, not a second domain review unless explicitly requested.
|
|
400
|
+
|
|
401
|
+
### Post-Merge Review Lens
|
|
402
|
+
|
|
403
|
+
- `Evidence`: Does each major finding trace to raw outputs or clearly marked merger evidence?
|
|
404
|
+
- `Severity`: Are labels justified by failure impact?
|
|
405
|
+
- `Consensus`: Was agreement counted honestly?
|
|
406
|
+
- `Purity`: Is current quorum separate from prior context?
|
|
407
|
+
- `Minority`: Were unique high-impact findings preserved?
|
|
408
|
+
- `Bias`: Did the merger impose an unsupported narrative?
|
|
409
|
+
- `Actionability`: Are repair order, scope, and gates named?
|
|
410
|
+
- `Consistency`: Do maps, headers, and attribution agree?
|
|
411
|
+
- `Compression`: Were caveats or disagreements lost?
|
|
412
|
+
|
|
413
|
+
### Post-Merge Decisions
|
|
414
|
+
|
|
415
|
+
- `Accept`: Report is decision-grade.
|
|
416
|
+
- `Accept with notes`: Report is useful, with caveats.
|
|
417
|
+
- `Revise merge`: Rerun merger with adjusted parameters.
|
|
418
|
+
- `Rerun quorum`: Raw outputs are too weak, divergent, or under-scoped.
|
|
419
|
+
- `Escalate`: Run cross-merge with another clean merger.
|
|
420
|
+
|
|
421
|
+
## Error Handling
|
|
422
|
+
|
|
423
|
+
- `LOCK_CONFLICT`: Retry, back off, or choose another scope.
|
|
424
|
+
- `SUBAGENT_TIMEOUT`: Keep partial results and release locks by TTL.
|
|
425
|
+
- `COORDINATOR_INPUT_REQUIRED`: Pause only if the adapter can preserve subagent context; otherwise write a checkpoint artifact and stop degraded for coordinator replanning.
|
|
426
|
+
- `MODEL_FAILURE`: Continue with fewer votes and mark degraded quorum.
|
|
427
|
+
- `MERGE_FAILURE`: Return `INSUFFICIENT_DATA` or rerun merger.
|
|
428
|
+
- `REVIEW_FAILURE`: Keep merged report and mark post-review missing.
|
|
429
|
+
|
|
430
|
+
## Composition Contract
|
|
431
|
+
|
|
432
|
+
This skill composes with capabilities, not concrete sibling skills:
|
|
433
|
+
|
|
434
|
+
- Local tool registry for reusable command-template adapters
|
|
435
|
+
- Local review and implementation protocols
|
|
436
|
+
- Scoped lock standard with TTL
|
|
437
|
+
- Subagent runner with file-read access
|
|
438
|
+
- Artifact writer owned by the orchestrator
|
|
439
|
+
|
|
440
|
+
Do not make swarm depend on a specific sibling skill, repository, model alias, or tool registry. The orchestrator may tell subagents to use the local review protocol when one exists.
|
|
441
|
+
|
|
442
|
+
## Portability Lens
|
|
443
|
+
|
|
444
|
+
- `Lock protocol`: Mandatory kernel.
|
|
445
|
+
- `Quorum review`: Optional capability.
|
|
446
|
+
- `Clean merger`: Mandatory for serious quorum.
|
|
447
|
+
- `Post-merge review`: Required for high-stakes outputs.
|
|
448
|
+
- `Command templates`: Local adapter.
|
|
449
|
+
- `Test scripts`: Protocol validation aid.
|
|
450
|
+
|
|
451
|
+
Operational tools, recipes, transport bindings, and runtime-specific adapters belong to the host project documentation, not this methodology skill.
|