Skip to content

Five Phase Swarm Workflow

magalz edited this page Nov 26, 2026 · 1 revision

Five-Phase Swarm Workflow

ignis-swarm structures complex feature delivery into 5 deterministic phases so parallel agents never collide on files, drift on interfaces, or degrade as context grows.

flowchart TD
    P0["Phase 0: /plan (ignis-plan)\nDiscovery · YAGNI Gate · Frozen Contracts · Atomic Waves"]
    H1["Handoff Step 1: /compact Preserve: ..."]
    H2["Handoff Step 2: /swarm Execute the approved plan..."]
    W0["Wave 0: Deletions & Shared Contracts"]
    WN["Wave 1..N: Parallel Nuclear Workers\n(5-Field Brief · Exclusive Files · BDD+TDD)"]
    V["Per-Task @verifier\n(Scope · Red->Green · Anti-Mock · Coverage)"]
    CW{"Context Pressure?\n(compaction-watch.mjs)"}
    P3["Phase 3: @doc-auditor\n(1-File ADRs/BDRs + INDEX.md + Opt-In Tracker Sync)"]
    P4["Phase 4: 3-Lens Final Audit\n(blind-edge-hunter + @acceptance-auditor)"]
    P5["Phase 5: Closure\n(Fix HIGH/MEDIUM · Summary · Post-Slice /compact)"]

    P0 --> H1 --> H2 --> W0 --> WN --> V --> CW
    CW -->|"Next wave"| WN
    CW -->|"All waves PASS"| P3 --> P4 --> P5
Loading

Phase 0 — Slice Planning (/plan → ignis-plan)

Run on a High-Reasoning Planning model tier before spawning any workers.

  1. Deterministic Discovery:
    • Map callers, callees, and blast radius via targeted symbol search (and connected code-intelligence MCPs if available).
    • If onboarding.json has memtrace.enabled === true, query Memtrace for prior slice context/gotchas.
    • If onboarding.json has tracker.kind !== "none", inspect the target epic/issues.
    • Read docs/adr/INDEX.md and docs/bdr/INDEX.md (if present); open only individual decision files touching this slice.
  2. Mandatory YAGNI & Subtract-Before-You-Add Gate:
    • Subtract first: Dead code, redundant adapters, duplicate validators, or unused flags to delete/simplify before adding new code.
    • Explicitly out of scope: Speculative abstractions and premature generalizations cut from the slice.
  3. Freeze Interface Contracts:
    • When 2+ parallel workers interact across modules, lock exact types, signatures, error variants, and payloads in the plan.
    • Schedule a Wave 0 task to commit shared contracts/deletions first so parallel workers cannot drift.
  4. Decompose into Non-Colliding Waves of Nuclear Tasks: Each nuclear task covers 1 cohesive responsibility (1–3 files, 0 interface ambiguity) with:
    • Task / Issue ID (T0.1, T1.1, or tracker ID)
    • Exclusive Files (no two workers in the same wave share a file)
    • Model Tier (Standard Coding default, or Mechanical allowlist only)
    • BDD Criteria (1–3 observable Given / When / Then scenarios + edge cases)
    • Audit Flags ([ADR], [BDR], or [PLAYBOOK])
  5. Mandatory 2-Step Post-/plan Handoff: Because Antigravity plugins cannot auto-trigger native slash commands, Phase 0 always ends with:
    • Step 1: A complete, pre-filled /compact Preserve: ... command populated with the real live slice state (never <placeholder> text).
    • Step 2: /swarm Execute the approved plan starting at Wave 0/1 using ignis-swarm.

Phases 1 & 2 — Wave Dispatch & Per-Task Verification (/swarm → ignis-swarm)

The /swarm Coordinator does not write production code itself — it dispatches waves, enforces contracts, tracks state, manages compaction checkpoints, and judges verification reports.

Mandatory 5-Field Nuclear Worker Brief

Every coding or mechanical worker brief posted to the /swarm board must contain:

  1. Task & Goal — Issue/Task ID + 1–2 crisp sentences defining the exact nuclear responsibility.
  2. Exclusive File Ownership & Frozen Contracts — Exact writable files, read-only frozen contract files/signatures, and explicit out-of-scope boundary.
  3. Requirements (BDD + TDD) — Follow ignis-tdd-bdd, targeted discovery, Given / When / Then criteria, edge cases, Red → Green → Refactor, boundary-only mocking.
  4. Code & Documentation Constraints — Zero narrative inline comments; [ADR]/[BDR] notes reported back for @doc-auditor.
  5. Done Gate & Board Report Format — Exact verification command + Board Report Contract:
    • Status: PASS | ISSUES | BLOCKED
    • Evidence: exact commands + real outputs (including Red → Green proof)
    • Observed coverage: factual % (if tests ran)
    • Issues / Decisions for @doc-auditor: file:line + minimal repro or bullet list

Shared builds: When 2+ workers in the same wave might compile/test concurrently or touch shared build artifacts, dispatch them with workspace: "share" so each gets an isolated working copy sharing the underlying repo directory.

Capability-Tier Model Routing

Role Capability Tier Notes
/plan (Phase 0) High-Reasoning Planning (pro) Single high-leverage pass to freeze contracts and enforce YAGNI
/swarm Coordinator High-Reasoning Coordination Wave orchestration, conflict resolution, escalation
Coding Workers (default) Standard Coding Tier All domain logic, BDD/TDD tests, error handling, refactors, concurrency, security
Mechanical Workers (strict allowlist) Lightweight / Mechanical Tier Only zero-logic tasks: caller/import listing, mechanical renames specified in plan, pure DTO/fixture scaffolding, INDEX.md formatting, repetitive test runs
Per-Task @verifier & @doc-auditor Balanced Verification Tier Fast, clean-context verification and ADR/BDR drafting
@blind-edge-hunter & @acceptance-auditor Independent Pro / High-Reasoning Tier Unbiased final slice audit

Escalation Rules

  • Mechanical worker gets logic ISSUES from @verifier: Immediately re-run the task on the Standard Coding Tier.
  • Coding worker fails the same verification gate 2x: Stop patching and trigger attack-the-premise — write down the shared assumption, inspect at Coordinator tier, and fix the plan/contract before attempt #3.

Context Compaction Checkpoints

Keeping Coordinator context lean preserves attention and prevents drift across long multi-wave slices.

Key Antigravity behavior: /compact never removes AGENTS.md/GEMINI.md rules, skills, built-in tools, MCP servers, artifacts, or live subagents. Only preserve dynamic workflow state (issue IDs, completed SHAs, remaining tasks, frozen contracts, rejected approaches, pending ADR/BDR notes).

Hard Checkpoints (Always Compact)

  1. Post-/plan (2-step handoff before /swarm)
  2. Pre-Phase 4 (after all coding waves + @doc-auditor, before final 3-lens audit)
  3. Post-Slice / Post-PR Merge (before starting the next /plan)

Active Threshold & hooks/compaction-watch.mjs

  • hooks/compaction-watch.mjs (PostInvocation) automatically measures active transcript bytes since the last compaction boundary.
  • Default threshold: 550 KB (configurable via compaction.transcriptThresholdKb in ~/.ignis-broker/onboarding.json), with a 150 KB cooldown that resets automatically after a compaction boundary.
  • When alerted, the Coordinator pauses cleanly at a wave boundary (never mid-task) and emits a complete, pre-filled /compact Preserve: ... command.

Phase 3, Phase 4 & Phase 5

  • Phase 3 (@doc-auditor): Writes 1 file per flagged [ADR]/[BDR], updates INDEX.md (enforced by stop-gate.mjs), and mirrors/comments in your opt-in issue tracker if enabled. See TDD-BDD-and-Audit-Documentation.
  • Phase 4 (3-Lens Final Audit): Runs @blind-edge-hunter (strictly diff-only) and @acceptance-auditor (full plan/tracker/ADR access). See Blind-Review-and-Final-Audit.
  • Phase 5 (Closure): Fixes proven HIGH/MEDIUM findings, re-verifies, presents a concise Audit Summary (waves, issues, ADRs/BDRs, observed coverage, verdict), and emits a pre-filled post-slice /compact Preserve: ... command.

Clone this wiki locally