Skip to content

swarm: DAG swarm workflows (declarative task graphs: harness kind, executor, eval) - #2452

Closed
sethkarten wants to merge 1 commit into
mainfrom
swarm/dag-workflows
Closed

sethkarten wants to merge 1 commit into
mainfrom
swarm/dag-workflows

Conversation

@sethkarten

@sethkarten sethkarten commented Sep 18, 2026

Copy link
Copy Markdown
Contributor

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 swarm harness entry kind — a versioned DAG of subagent nodes: stable ids, subagent references (harness entries or inline specs), task/resident lifecycles, typed input/output ports with from bindings, 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 effective dependencies, port type matching, resident constraints, foreach bounds, budget sanity, 1024-node cap) — an invalid DAG never reaches the store.

2. The executorrlm.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 bounded collect polls. 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 with arrived/shown/read stages, and one swarm.progress notice per milestone — same injection path as bash.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

  • Executor round: two must-fix bugs (foreach mixed-instance policy bypass; stop() race admitting/finalizing after stop) — both fixed with regression tests and verified by repro re-runs.
  • Eval round: replay seq-gap detection, retry settle accounting, baseline tautology removal, single-listing baseline fairness, fail-fast --swarms validation — all fixed with tests.
  • Gates on this exact tree: 122 + 90 Python, 134 + 52 TS tests pass, tsgo and biome clean, import rlm boot contract verified. Only the two pre-existing test_bash failures 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 unmerged security/release-hardening branch; 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

  • Adds swarm.py with validate_swarm_spec, canonicalization, topological ordering, and a lifecycle API (run, status, stop, resume) for executing declarative task graphs
  • Registers swarm as a new HarnessKind in harness.py with CRUD methods that validate the DAG on create and update; exposes rlm.swarm.* operations via the rlm namespace
  • Integrates swarm progress into AgentSession via a swarm.progress host handler and createSwarmProgressMessage in messages.ts, injecting progress notices with admission-pause tolerance
  • Extends refinement in refinement.ts to accept swarm entries, requiring a non-null object DAG on create and update edits
  • Adds swarm-dag-eval.ts, a CLI evaluation harness with reference swarms, deterministic ledger replay, verdict computation, and markdown reporting; includes scripts/ in tsconfig compilation
  • Behavioral Change: startsAgentRun now returns true for swarm progress custom messages; emptyHarnessState and corrupt-state recovery now include a swarm entry collection

Macroscope summarized ea2a7e6.

…, 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).
@github-actions

Copy link
Copy Markdown

Prime Agent performance — running

PR ea2a7e65 compared with main ff40ea24.

Benchmarking the latest PR commit. Results will appear here when this run finishes.

Run, logs, and downloadable raw results

@sethkarten

Copy link
Copy Markdown
Contributor Author

Reverted: the user wants the DAG work as a STACKED PR series, not a single PR. Reopening #2397 -> #2401 -> #2402 as the review stack; this consolidated branch will be deleted.

@sethkarten sethkarten closed this Sep 18, 2026
@sethkarten
sethkarten deleted the swarm/dag-workflows branch September 18, 2026 06:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant