swarm: DAG swarm workflows (declarative task graphs: harness kind, executor, eval) - #2452
Closed
sethkarten wants to merge 1 commit into
Closed
sethkarten wants to merge 1 commit into
sethkarten wants to merge 1 commit into
Conversation
…, eval) Declarative task-graph orchestration for subagent swarms, from the "Swarm DAGs: declarative orchestration in Continual Harness" spec. Three components in one PR: 1. Swarm specification (harness entry kind "swarm"): a versioned DAG of subagent nodes with stable ids, subagent references (harness entries or inline specs), task/resident lifecycles, typed input/output ports, per-node and run budgets, retries, fail_fast/continue/escalate failure policies, and bounded foreach fan-out. Write-time dry run: validate_swarm_spec enforces 12 rule groups (ids, cycles over depends_on + data edges, port type matching, resident constraints, foreach bounds, budget sanity, 1024-node cap); an invalid DAG never reaches the store. rlm.harness.create_swarm/update_swarm/delete_swarm; /refine accepts the kind; the harness digest renders the invoke contract. 2. Executor (rlm.swarm.run/status/stop/resume): nonblocking admission (re-validates, resolves references, reports all failures, starts only ready nodes, ends the model turn), then a kernel control loop resumes through bounded collect polls; binds typed outputs into dependent prompts (json ports via fenced blocks), foreach fan-out with max clamp, retries, rate-limit backoff, injectable-clock budgets, failure policies (fail_fast cancels in-flight siblings, escalate pauses with one quiet notice), cancellation cascade via delete_subagent, event ledger with arrived/shown/read stages, and one swarm.progress notice per milestone (mirrors bash.completed). asyncio imports deferred to preserve the repl boot contract. 3. Capability evaluation harness: three reference swarms (review sweep with typed fan-in and escalation, N-wide builder with per-node budgets, resident watcher with teardown) against hand-written baselines with identical inputs/models/budgets; deterministic replay and ledger checks, verdict rules per the spec, metrics report. Never runs in CI (no token spend); offline checks are unit-tested. Review history: PR-G round caught and fixed foreach mixed-instance policy handling and a stop() race (verified by repro re-runs); PR-H round fixed replay seq gaps, retry settle accounting, baseline tautology and fairness (single-listing substitution), and fail-fast --swarms validation. All suites green: 90+122 py, 134+52 TS, tsgo and biome clean; rlm boot contract verified. Known merge-time item: main's test-line budget (check:test-policy) fails by design - the feature is contract-test-heavy (~1.8k net test lines over source); the reviewed-override mechanism lives on the unmerged security/release-hardening branch. Consolidates #2397, #2401, #2402 (closed in favor of this PR).
This was referenced Sep 18, 2026
Draft
Prime Agent performance — runningPR Benchmarking the latest PR commit. Results will appear here when this run finishes. |
Contributor
Author
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
DAG Swarm Workflows — one consolidated PR
From the spec: Swarm DAGs: declarative orchestration in Continual Harness (https://app.notion.com/p/3da72940136f-81a8-8554-e6ec7119270e). This consolidates #2397 (harness kind + validator), #2401 (executor), and #2402 (capability eval) into a single review and merge unit, per the review plan.
What you get
1. The
swarmharness entry kind — a versioned DAG of subagent nodes: stable ids, subagent references (harness entries or inline specs),task/residentlifecycles, typed input/output ports withfrombindings, per-node and run budgets, retries,fail_fast/continue/escalatefailure policies, and boundedforeachfan-out. Write-time dry run:validate_swarm_specenforces 12 rule groups (ids, cycles over effective dependencies, port type matching, resident constraints, foreach bounds, budget sanity, 1024-node cap) — an invalid DAG never reaches the store.2. The executor —
rlm.swarm.run/status/stop/resume: nonblocking admission (re-validate, resolve references, start only ready nodes, end the model turn), then a kernel control loop resuming via boundedcollectpolls. Binds typed outputs into dependent prompts (json ports via fenced blocks), foreach fan-out with max clamp, retries, rate-limit backoff (respects the 32-concurrent glm-5.3-fast pool), injectable-clock budgets, failure policies (fail_fast cancels in-flight siblings; escalate pauses with one quiet notice), cancellation cascade, an event ledger witharrived/shown/readstages, and oneswarm.progressnotice per milestone — same injection path asbash.completed. The executor owns run state in kernel memory; the supervisor owns the children. asyncio imports are deferred to preserve the repl boot contract.3. The capability evaluation harness — three reference swarms (review sweep with typed fan-in + escalation, N-wide builder with per-node budgets, resident watcher with teardown) vs hand-written baselines under identical inputs/model/budgets; deterministic replay + ledger checks, spec verdict rules, metrics report. Spends real tokens only when run deliberately; never in CI.
Review history baked in
stop()race admitting/finalizing after stop) — both fixed with regression tests and verified by repro re-runs.--swarmsvalidation — all fixed with tests.import rlmboot contract verified. Only the two pre-existingtest_bashfailures remain anywhere (identical on clean main).Merge-time note (reviewer decision)
Main's test-line budget (
check:test-policy) fails this PR by design: the feature is contract-test-heavy (~1.8k net test lines over source) — the suites that caught two executor bugs and eight eval findings. The repo's reviewed-override mechanism lives on the unmergedsecurity/release-hardeningbranch; if it lands first, register the overage there, or grant the exception however you prefer. No test coverage was deleted to fit the budget.Out of scope
The communication series (#2351–#2356) is deliberately separate and deferred; this PR depends only on main. Supersedes and closes #2397, #2401, #2402.
Draft only — review withheld per workflow.
Note
Add DAG swarm workflows with executor, harness integration, and evaluation
validate_swarm_spec, canonicalization, topological ordering, and a lifecycle API (run,status,stop,resume) for executing declarative task graphsswarmas a newHarnessKindin harness.py with CRUD methods that validate the DAG on create and update; exposesrlm.swarm.*operations via the rlm namespaceAgentSessionvia aswarm.progresshost handler andcreateSwarmProgressMessagein messages.ts, injecting progress notices with admission-pause tolerancescripts/in tsconfig compilationstartsAgentRunnow returns true for swarm progress custom messages;emptyHarnessStateand corrupt-state recovery now include a swarm entry collectionMacroscope summarized ea2a7e6.