Parallel Inquiry as a Primitive
One compound task, many independent branches, one coherent result. The architect decomposes. Branches build in isolation. Contracts keep the seams aligned. Validators catch drift. The tree turns plural problems into parallel work.
A compound task is one that naturally splits into independent sub-investigations that need to reconverge. Build a server plus a frontend plus tests. Write a research paper with a literature review, methodology, results, and discussion. Draft a book, one branch per chapter. Design a data pipeline with ingestion, transform, validate, export.
Swarm is the primitive that turns these into parallel work without losing coherence. The architect writes contracts that define the invariants all branches must share. Each branch becomes its own tree node with its own AI session, its own workspace, and its own validators. Branches never see each other directly. They see the contracts.
When all branches finish, validators cross-check the actual output against the contracts. Any branch that drifted gets flipped to failed with a specific violation signal, then retried. The swarm produces a coherent compound result or tells you exactly why it couldn't.
Five phases. Each phase is its own AI turn or background pass.
The architect reads the compound request and emits two blocks:[[CONTRACTS]] declares the invariants every branch must respect. [[BRANCHES]] names the sub-investigations with a spec, a mode, a path, and the files or sections each branch owns.
Each branch becomes a child node under the project root. Swarm spawns one AI session per branch at its own tree position. Contracts get injected into every branch's system prompt. Branches start blind to each other but aligned to the same invariants.
Branches write in parallel. Each emits contract signals as it produces output, which cascade to siblings. A branch that's stuck or ambiguous can read what its siblings have already claimed to hold.
Once all branches declare done, validators fire. Contract conformance checks the actual output against the declared contracts. Domain-specific validators (syntax, seam, smoke, fact-check, citation-check) plug in via hooks. Any violation produces a signal on the offending branch.
Failed branches get one more shot with the violation signal in their enrichContext. Most small drifts fix on retry. Unfixable ones surface as part of the final plan.md, which writes the distributed subPlan as a human-readable summary.
These are not the same thing. They work at different layers and for different kinds of work.
One turn, one thought. The orchestrator takes a single natural-language request and decides what to do with it at the current position. Parse the grammar. Classify the intent. Pick the mode. Run the continuation loop. Dispatch one AI conversation, possibly with many tool calls, into one coherent response.
It handles nouns, verbs, tenses, pronouns, conjunctions, prepositions. It routes between extensions. It respects per-node mode overrides. It's the compiler that turns language into execution at a position.
Example: "add a vowel counter to lib.js" — one turn, one file written, done.
One request, many parallel conversations. Swarm takes a compound request, decomposes it into independent branches, runs them in parallel, and reconverges with cross-branch validation. Each branch is its own orchestrator invocation at its own tree position.
Swarm does not compile language. It coordinates. It owns the decomposition turn (the architect), the parallel build phase, the contract contract storage, the validator hook lifecycle, and the retry loop. The orchestrator handles each individual branch.
Example: "build a polygon pong chatroom with a backend and a frontend" — architect decomposes, two branches build in parallel, contract conformance validates, retry fixes the seam.
The orchestrator is always running. Swarm only fires when the architect's turn produces a [[BRANCHES]] block. A simple request passes through the orchestrator and never touches swarm. A compound request passes through the orchestrator, hits the architect mode, and hands off to swarm for the parallel build.
A contract is whatever invariant keeps parallel branches coherent. The shape depends on the domain.
Wire message types. Payload fields. Shared type definitions. The frontend and backend of a WebSocket game agree on every message shape before either writes a line.
Terminology definitions. Citation conventions. Variable symbols. Every section uses the same term for the same concept.
Character names. Timeline events. Voice conventions. Chapter four doesn't resurrect a character chapter two killed.
Schemas for each handoff. Ingestion's output equals transform's input. Validate and export share the same field definitions.
Learning objectives per module. Prerequisite chains. Shared vocabulary. Module three assumes module two's vocabulary is known.
Shared KPIs and assumptions. Market's growth rate equals financials' growth rate. Product and ops speak the same customer profile.
Swarm is the common bus. Domain-specific extensions subscribe to its hooks and bring their own validators.
The reference consumer. Compound code projects decompose into backend, frontend, persistence, and shared-contracts branches. Validators include syntax, smoke, integration probe, WebSocket seam analysis, and contract conformance. Every file write cascades contract signals to siblings.
Live preview per project at /api/v1/preview/<slug>/. Contracts keep the wire protocol aligned between the backend's sender and the frontend's receiver.
Compound research projects decompose into literature review, methodology, results, and discussion branches. Validators check citations, cross-reference claims, enforce terminology consistency. Contracts define the vocabulary and the citation graph.
Each section is a branch node. The architect produces a claim map. Validators flag unsupported assertions against the citation contract.
Long-form drafts decompose into chapter branches. Validators enforce character consistency, timeline sanity, voice uniformity. Contracts define the cast, the world state, and the narrative voice.
Chapter seven can't reintroduce a character that died in chapter three. The contract is the story bible.
Courses decompose into module branches. Validators enforce prerequisite ordering, objective coverage, vocabulary reuse. Contracts define learning outcomes and the concept graph.
A module can't teach a concept whose prerequisite isn't covered earlier in the sequence.
code-workspace ships today. The others are what the primitive enables. Install just swarm plus a domain workspace and that kind of compound work becomes parallel on your land.
Swarm emits hooks at every stage. Extensions subscribe without importing from each other.
Contracts parsed and stored on the project root. Consumers can index them, run schema checks, or prepare validator state.
A branch's AI session is about to dispatch. Consumers can inject per-branch context, stamp metadata, or claim resources.
A branch wrote output. Consumers extract contract signals, run per-file syntax checks, and cascade to siblings.
A branch declared done. Consumers run per-branch smoke validators and stamp status.
All branches finished. Consumers run cross-branch validators (conformance, seam, integration). Violations flip branches to failed, which triggers the retry loop.
Humans already do this. Teams split a project into parts, each person works in their own head, and they reconverge through shared language and specs. The word "contract" isn't new. The word "branch" isn't new. What's new is making it native to an AI operating system instead of a process a human ties together.
Small models don't have room to hold a backend, a frontend, a persistence layer, and a test suite in the same context window. They can hold one of those at a time. Swarm gives each one its own context, its own position, its own conversation. Coherence is handled by the contracts, not by cramming everything into one turn.
The result is compound work that would take a 200B model hours in one shot, done by many 27B models in parallel with validators keeping them aligned.