diff --git a/ARCHITECTURE.md b/ARCHITECTURE.md
index b3db86b9..62238a97 100644
--- a/ARCHITECTURE.md
+++ b/ARCHITECTURE.md
@@ -61,7 +61,6 @@ packages/
├── plugins/ @red-codes/plugins — Plugin ecosystem (discovery, registry, validation, sandboxing)
├── renderers/ @red-codes/renderers — Renderer plugin system (registry, TUI renderer)
├── sdk/ @red-codes/sdk — Agent SDK for programmatic governance integration
-├── swarm/ @red-codes/swarm — Shareable agent swarm templates
├── scheduler/ @red-codes/scheduler — Task scheduler, queue, lease manager, and worker orchestration
└── telemetry-client/ @red-codes/telemetry-client — Telemetry client (identity, signing, queue, sender)
diff --git a/CLAUDE.md b/CLAUDE.md
index 93fc0c89..42c44fe6 100644
--- a/CLAUDE.md
+++ b/CLAUDE.md
@@ -140,12 +140,6 @@ packages/
│ └── types.ts # Storage type definitions
├── telemetry/src/ # @red-codes/telemetry — Runtime telemetry and logging
├── telemetry-client/src/ # @red-codes/telemetry-client — Telemetry client (identity, signing, queue, sender)
-├── swarm/src/ # @red-codes/swarm — Shareable agent swarm templates
-│ ├── config.ts # Swarm configuration
-│ ├── manifest.ts # Swarm manifest parsing
-│ ├── scaffolder.ts # Swarm scaffolding
-│ ├── types.ts # Swarm type definitions
-│ └── index.ts # Module re-exports
├── sdk/src/ # @red-codes/sdk — Agent SDK for programmatic governance
│ ├── sdk.ts # SDK implementation
│ ├── session.ts # Session management
@@ -254,8 +248,7 @@ Each workspace package maps to a single architectural concept:
- **packages/telemetry/** — Runtime telemetry and logging
- **packages/telemetry-client/** — Telemetry client (identity, signing, queue, sender)
- **packages/sdk/** — Agent SDK for programmatic governance integration
-- **packages/swarm/** — Shareable agent swarm templates (config, manifest, scaffolder)
-- **packages/scheduler/** — Task scheduler, queue, lease manager, and worker orchestration for swarm
+- **packages/scheduler/** — Task scheduler, queue, lease manager, and worker orchestration
- **apps/cli/** — CLI entry point and commands (published as `@red-codes/agentguard`)
- **packages/invariant-data-protection/** — Data protection invariant plugin
- **apps/mcp-server/** — MCP governance server (15 governance tools)
@@ -379,7 +372,7 @@ pnpm test --filter=@red-codes/kernel # Test a single package
**Test structure:**
- **Vitest workspace** (`vitest.workspace.ts`): orchestrates tests across all packages
- **TypeScript tests** (distributed across `packages/*/tests/` and `apps/*/tests/`): vitest
-- **Coverage areas**: adapters (file, git, shell, claude-code, copilot-cli, hook integrity), kernel (AAB, engine, monitor, blast radius, heartbeat, integration, e2e pipeline, conformance, tiers, intent drift, enforcement audit, interventions), CLI commands (args, guard, inspect, init, simulate, ci-check, claude-hook, claude-init, export/import, policy-validate, policy-verify, diff, evidence-pr, traces, plugin, auto-setup, config, demo, migrate), decision records, domain models, events, evidence packs (explainable, explanation chain), evidence summary, execution log, export-import roundtrip, impact forecast, invariants, matchers (path-matcher, command-scanner, policy-matcher, benchmark), notification formatter, plugins (discovery, registry, sandbox, validation), policy evaluation (including composer, pack loader, policy packs, evaluation trace, forecast conditions, gate conditions, persona, trust, pack versioning), renderers, replay (engine, comparator, processor), simulation (filesystem, git, package, dependency graph), SQLite storage (migrations, session, sink, store, cross-run, factory, aggregation queries, commands), swarm (scaffolder, config, manifest), telemetry (event queue, event sender, anonymize, cloud sink, event mapper), TUI renderer, violation mapper, VS Code event reader, YAML loading
+- **Coverage areas**: adapters (file, git, shell, claude-code, copilot-cli, hook integrity), kernel (AAB, engine, monitor, blast radius, heartbeat, integration, e2e pipeline, conformance, tiers, intent drift, enforcement audit, interventions), CLI commands (args, guard, inspect, init, simulate, ci-check, claude-hook, claude-init, export/import, policy-validate, policy-verify, diff, evidence-pr, traces, plugin, auto-setup, config, demo, migrate), decision records, domain models, events, evidence packs (explainable, explanation chain), evidence summary, execution log, export-import roundtrip, impact forecast, invariants, matchers (path-matcher, command-scanner, policy-matcher, benchmark), notification formatter, plugins (discovery, registry, sandbox, validation), policy evaluation (including composer, pack loader, policy packs, evaluation trace, forecast conditions, gate conditions, persona, trust, pack versioning), renderers, replay (engine, comparator, processor), simulation (filesystem, git, package, dependency graph), SQLite storage (migrations, session, sink, store, cross-run, factory, aggregation queries, commands), telemetry (event queue, event sender, anonymize, cloud sink, event mapper), TUI renderer, violation mapper, VS Code event reader, YAML loading
## CI/CD & Automation
diff --git a/README.md b/README.md
index 927db6f8..4c312361 100644
--- a/README.md
+++ b/README.md
@@ -20,11 +20,7 @@ Install in 30 seconds. Your agents can't break what matters.
AI coding agents (Claude Code, Codex CLI, GitHub Copilot CLI, Google Gemini CLI, OpenCode, Goose, and more) run autonomously — writing files, executing commands, pushing code. AgentGuard prevents them from doing catastrophic things: no accidental pushes to main, no credential leaks, no runaway destructive loops. 26 built-in safety checks, zero config required.
**For individuals:** stop your AI from wrecking your machine or repo.
-**For teams:** run fleets of agents safely at scale, with audit trails that pass compliance.
-
-> **See it live** — We run 100+ autonomous AI agents building AgentGuard itself, governed 24/7.
-> Every deny, every escalation, every code review — visible in real time.
-> **[Watch the live swarm →](https://agentguard-cloud-office-sim.vercel.app)**
+**For teams:** govern agents at scale, with audit trails that pass compliance.
## What Problem Does AgentGuard Solve?
@@ -121,7 +117,6 @@ agentguard cloud login # Opens browser → authenticate → CLI
| Link | Description |
|------|-------------|
-| **[Live Office](https://agentguard-cloud-office-sim.vercel.app)** | **Watch our 100+ agent swarm build software 24/7** — real-time governance visualization |
| [Dashboard](https://agentguard-cloud-dashboard.vercel.app) | Team dashboard — runs, violations, analytics |
## Agent Identity
@@ -144,7 +139,6 @@ Identity consists of a **role** (`developer`, `reviewer`, `ops`, `security`, `ci
| **48 event kinds** | Full lifecycle telemetry: `ActionRequested → ActionAllowed/Denied → ActionExecuted` |
| **Real-time cloud dashboard** | Telemetry streams to your team dashboard; opt-in, anonymous by default |
| **Multi-tenant** | Team workspaces, GitHub/Google OAuth, SSO-ready |
-| **Live Office visualization** | [24/7 live view](https://agentguard-cloud-office-sim.vercel.app) of our actual 100+ agent swarm — watch AI build software under governance |
| **Agent SDK** | Programmatic governance for custom integrations and RunManifest-driven workflows |
| **Agent identity** | Declare agent role + driver for governance telemetry — automatic prompt or CLI flag |
| **Pre-push hooks** | Branch protection enforcement via git pre-push hooks, configured from agentguard.yaml |
@@ -357,7 +351,7 @@ rules:
| `recursive-operation-guard` | Low | `find -exec`, `xargs` with write/delete |
| `lockfile-integrity` | Low | `package.json` changes without lockfile sync |
| `no-verify-bypass` | High | `git push/commit --no-verify` — prevents skipping pre-push/pre-commit hooks |
-| `no-self-approve-pr` | Critical | Agents merging or approving PRs they authored — enforces separation of duties in multi-agent swarms |
+| `no-self-approve-pr` | Critical | Agents merging or approving PRs they authored — enforces separation of duties in multi-agent setups |
| `cross-repo-blast-radius` | High | Caps cumulative unique files written across all repos in a session (default: 50 files) |
## Architecture
@@ -539,7 +533,6 @@ agentguard cloud login # Connect after you have an API key
| Resource | URL |
|----------|-----|
| Dashboard | [agentguard-cloud-dashboard.vercel.app](https://agentguard-cloud-dashboard.vercel.app) |
-| **Live Office** | **[agentguard-cloud-office-sim.vercel.app](https://agentguard-cloud-office-sim.vercel.app)** — watch our swarm build software 24/7 |
| Website | [agentguardhq.github.io/agentguard](https://agentguardhq.github.io/agentguard/) |
| Docs | [docs/](docs/) |
| Architecture | [docs/unified-architecture.md](docs/unified-architecture.md) |
@@ -557,7 +550,7 @@ agentguard cloud login # Connect after you have an API key
| [Octi Pulpo](https://github.com/AgentGuardHQ/octi-pulpo) | Coordination — pipeline controller, model routing |
| [ShellForge](https://github.com/AgentGuardHQ/shellforge) | Orchestration — multi-runtime agent execution |
| [Preflight](https://github.com/AgentGuardHQ/preflight) | Protocol — universal design-before-you-build standard |
-| [Extensions](https://github.com/AgentGuardHQ/agentguard-extensions) | Drivers, integrations, policies, example swarms |
+| [Extensions](https://github.com/AgentGuardHQ/agentguard-extensions) | Drivers, integrations, policies |
## License
diff --git a/ROADMAP.md b/ROADMAP.md
index 8fbddaa1..da20f7c4 100644
--- a/ROADMAP.md
+++ b/ROADMAP.md
@@ -12,7 +12,7 @@
AgentGuard is the **Execution Control Plane for autonomous AI agents** — the independent governance layer that sits between autonomous agents and the real world. All agent side effects must pass through deterministic governance before reaching the environment, regardless of which orchestration framework, cloud provider, or AI model powers the agents.
-**Strategic positioning**: Autonomous Execution Governance (AEG). Like Okta for the application layer, AgentGuard controls the trust boundary without replacing the underlying systems. The OSS repo houses Layer 1 (Kernel — the moat) and Layer 2 (Studio Runtime — adapters, swarm templates, execution profiles, and the `agentguard init studio` wizard that bootstraps governed workspaces).
+**Strategic positioning**: Autonomous Execution Governance (AEG). Like Okta for the application layer, AgentGuard controls the trust boundary without replacing the underlying systems. The OSS repo houses Layer 1 (Kernel — the moat) and Layer 2 (Studio Runtime — adapters, execution profiles, and the `agentguard init studio` wizard that bootstraps governed workspaces).
**Core thesis**: Once autonomous agents start modifying production systems, organizations need deterministic execution governance. Prompt alignment cannot solve this. Only a reference monitor architecture — default-deny, tamper-evident, fully auditable — provides the guarantees enterprises require. Orchestration is commoditizing (LangGraph, CrewAI, AutoGen, platform-level tools); governance remains scarce.
@@ -41,7 +41,7 @@ AgentGuard is the **Execution Control Plane for autonomous AI agents** — the i
| MCP governance server (15 tools) | Implemented | Production |
| Plugin ecosystem (discovery, registry, sandboxing) | Implemented | Production |
| 8 policy packs (essentials, strict, ci-safe, enterprise, open-source, soc2, hipaa, eng-standards) | Implemented | Production |
-| 26-agent autonomous swarm templates | Implemented | Production |
+| Multi-agent governance templates | Implemented | Production |
| KE-1 Structured matchers (Aho-Corasick, globs, reason codes) | **Shipped v2.3.0** | `packages/matchers/` |
| All 46 event kinds mapped to cloud AgentEvent | **Shipped v2.3.0** | `packages/telemetry/src/event-mapper.ts` |
| Agent SDK for programmatic governance | **Shipped v2.3.0** | Programmatic governance integration |
@@ -61,7 +61,7 @@ AgentGuard is the **Execution Control Plane for autonomous AI agents** — the i
| No-verify-bypass invariant (#24) — blocks `git push/commit --no-verify` | **Shipped v2.6.0** | `packages/invariants/src/definitions.ts` |
| Read-only operations permitted on protected paths | **Shipped v2.7.0** | `packages/adapters/src/file.ts` (closes #648) |
| Install attribution telemetry — opt-in postinstall ping (version, OS, Node, CI env, anon ID) | **Shipped v2.7.0** | `apps/cli/src/postinstall.ts` (PR #991) |
-| `agentguard init studio` wizard, execution profiles, swarm template schema | **Shipped v2.7.0** | `apps/cli/src/commands/init.ts`, `packages/swarm/` (PR #987) |
+| `agentguard init studio` wizard + execution profiles | **Shipped v2.7.0** | `apps/cli/src/commands/init.ts` (PR #987) |
| OpenCode driver support | **Shipped v2.7.0** | Agent driver registry (PR #1019) |
| Codex CLI adapter (PreToolUse/PostToolUse hook commands) | **Shipped v2.8.0** | `packages/adapters/src/codex-cli.ts` (PR #1024) |
| Gemini CLI adapter (BeforeTool/AfterTool hook commands) | **Shipped v2.8.0** | `packages/adapters/src/gemini-cli.ts` (PR #1024) |
@@ -197,7 +197,7 @@ This sprint implements the architectural upgrades required for AgentGuard to fun
**Traction note (2026-03-24)**: npm reports ~1,761 weekly downloads, but investigation shows the majority are internal Vercel CI builds of `agentguard-cloud` which pins `@red-codes/agentguard@2.0.0`. Each Vercel build (ephemeral containers, preview deploys, branch builds) triggers a fresh `npm install`. Real external adoption is likely in the low hundreds. This makes install attribution tracking and the user capture funnel critical — without them, we cannot distinguish real adoption from CI noise. The version drift (cloud at 2.0.0 vs OSS at 2.4.0) should also be resolved.
-**Release cadence**: v3.0 (KE-2 ActionContext + stranger test + capture funnel), v3.1 (Runner + `apps/runner`), v3.2+ (advanced integrations). Note: `agentguard init studio` wizard, execution profiles, swarm template schema, and install attribution all shipped early in v2.7.x ahead of schedule; Codex CLI + Gemini CLI + DeepAgents adapters shipped in v2.8.x (latest: v2.8.4).
+**Release cadence**: v3.0 (KE-2 ActionContext + stranger test + capture funnel), v3.1 (Runner + `apps/runner`), v3.2+ (advanced integrations). Note: `agentguard init studio` wizard, execution profiles, and install attribution all shipped early in v2.7.x ahead of schedule; Codex CLI + Gemini CLI + DeepAgents adapters shipped in v2.8.x (latest: v2.8.4).
### Next — Pull-Based Runner (Phase 6.5 — `apps/runner`)
@@ -225,9 +225,8 @@ Depends on: v3.0 released + Cloud Phase 2A (orchestrator + runner protocol).
Shipped ahead of schedule in v2.7.x; dependency on v3.0 stranger test waived for early delivery.
-- [x] ~~**`agentguard init studio` wizard**~~ — ✅ Done 2026-03-26 — detects project type (monorepo/single), CI/CD, test framework, agent runtimes; offers execution profile + swarm preset selection (full/qa-focused/dev-ops/minimal); `--non-interactive` mode for CI; optional Cloud connection (PR #987)
+- [x] ~~**`agentguard init studio` wizard**~~ — ✅ Done 2026-03-26 — detects project type (monorepo/single), CI/CD, test framework, agent runtimes; offers execution profile selection (full/qa-focused/dev-ops/minimal); `--non-interactive` mode for CI; optional Cloud connection (PR #987)
- [x] ~~**Execution profiles**~~ — ✅ Done 2026-03-26 — `ci-safe` and `enterprise` profiles shipped; 6 profiles total via `agentguard init --profile ` (PR #987)
-- [x] ~~**Swarm template schema**~~ — ✅ Done 2026-03-26 — canonical JSON schema for swarm manifest, squad manifest, swarm config with zero-dependency runtime validator (PR #987)
### Next — Capability-Scoped Sessions (Phase 7)
diff --git a/apps/cli/README.md b/apps/cli/README.md
index 6792de76..dc76b73a 100644
--- a/apps/cli/README.md
+++ b/apps/cli/README.md
@@ -79,7 +79,7 @@ Every governance session requires an agent identity. Resolution order:
If no identity is set, PreToolUse hooks **block all actions** with a message directing the agent to identify itself. The `.agentguard-identity` file is session-scoped and gitignored — it is blanked on session start/stop to prevent stale values.
-For autonomous agent swarms, pass identity via env var per-process or `--agent-name` flag:
+For multi-agent setups, pass identity via env var per-process or `--agent-name` flag:
```bash
aguard guard --agent-name "builder-agent-3" --policy agentguard.yaml
@@ -217,16 +217,6 @@ aguard status # Confirms: ⚡ Token optimization active
Works with git, npm, cargo, tsc, docker, kubectl, and more. No configuration needed — AgentGuard detects RTK automatically.
-## Agent Swarm
-
-AgentGuard ships with a 26-agent autonomous development swarm:
-
-```bash
-aguard init swarm # Scaffolds agents, skills, and governance into your repo
-```
-
-Agents handle implementation, code review, CI triage, security audits, planning, docs, and more — all under governance.
-
## Links
- [GitHub](https://github.com/AgentGuardHQ/agentguard)
diff --git a/apps/cli/package.json b/apps/cli/package.json
index 131c9f66..a0346c6d 100644
--- a/apps/cli/package.json
+++ b/apps/cli/package.json
@@ -57,7 +57,6 @@
"@red-codes/policy": "workspace:*",
"@red-codes/renderers": "workspace:*",
"@red-codes/storage": "workspace:*",
- "@red-codes/swarm": "workspace:*",
"@red-codes/telemetry": "workspace:*",
"@red-codes/telemetry-client": "workspace:*",
"@types/better-sqlite3": "^7.6.0",
diff --git a/apps/cli/src/commands/init.ts b/apps/cli/src/commands/init.ts
index 4c92b86a..c99f5de6 100644
--- a/apps/cli/src/commands/init.ts
+++ b/apps/cli/src/commands/init.ts
@@ -72,11 +72,6 @@ export async function init(args: string[]): Promise {
return initFirestore(dir);
}
- // Swarm scaffolding mode
- if (extensionType === 'swarm') {
- return initSwarm(parsed);
- }
-
// Studio wizard — interactive project bootstrap
if (extensionType === 'studio') {
return initStudio(parsed);
@@ -1287,122 +1282,6 @@ AGENTGUARD_STORE=firestore
return 0;
}
-/**
- * Scaffold the agent swarm: copy skill templates, render config, and output
- * scheduled task definitions for registration.
- */
-async function initSwarm(parsed: ReturnType): Promise {
- const dir = parsed.flags.dir as string | undefined;
- const force = parsed.flags.force === true || parsed.flags.force === 'true';
- const tiersFlag = parsed.flags.tiers as string | undefined;
- const tiers = tiersFlag ? tiersFlag.split(',').map((t) => t.trim()) : undefined;
- const projectRoot = resolve(dir ?? '.');
-
- let scaffoldFn: typeof import('@red-codes/swarm').scaffold;
- try {
- const swarmModule = await import('@red-codes/swarm');
- scaffoldFn = swarmModule.scaffold;
- } catch {
- console.error(`\n ${color('Error', 'red')}: @red-codes/swarm package not found.`);
- console.error(` Install it with: pnpm add @red-codes/swarm\n`);
- return 1;
- }
-
- const result = scaffoldFn({ projectRoot, force, tiers });
-
- console.log(
- `\n ${color('✓', 'green')} Swarm initialized (${bold(String(result.agents.length))} agents, ${bold(String(result.skillsWritten + result.skillsSkipped))} skills)\n`
- );
-
- if (result.configWritten) {
- console.log(
- ` ${dim('Created')} agentguard-swarm.yaml ${dim('(customize schedules, paths, labels)')}`
- );
- }
-
- console.log(
- ` ${dim('Skills written:')} ${result.skillsWritten} ${dim('Skipped (existing):')} ${result.skillsSkipped}\n`
- );
-
- // Print agent table
- console.log(
- ` ${bold('Agent')}${' '.repeat(28)}${bold('Tier')}${' '.repeat(8)}${bold('Schedule')}`
- );
- console.log(` ${'─'.repeat(65)}`);
- for (const agent of result.agents) {
- const name = agent.name.padEnd(33);
- const tier = agent.tier.padEnd(12);
- console.log(` ${name}${tier}${agent.cron}`);
- }
-
- console.log(`\n ${bold('Next steps:')}`);
- console.log(` ${dim('# Register scheduled tasks (run inside Claude Code):')}`);
- console.log(
- ` ${dim('# The agent prompts are in .claude/skills/ — use them with the scheduled tasks API')}`
- );
- console.log(
- ` ${dim('# Or use the register-swarm-tasks skill to auto-register all agents')}\n`
- );
-
- // Write a register-swarm-tasks skill
- const registerSkillPath = join(projectRoot, '.claude', 'skills', 'register-swarm-tasks.md');
- if (!existsSync(registerSkillPath) || force) {
- const registerContent = buildRegisterSkill(result);
- mkdirSync(join(projectRoot, '.claude', 'skills'), { recursive: true });
- writeFileSync(registerSkillPath, registerContent, 'utf8');
- console.log(` ${dim('Created')} .claude/skills/register-swarm-tasks.md\n`);
- }
-
- return 0;
-}
-
-function buildRegisterSkill(result: {
- agents: ReadonlyArray<{
- id: string;
- name: string;
- tier: string;
- cron: string;
- description: string;
- prompt: string;
- }>;
-}): string {
- const lines = [
- '# Skill: Register Swarm Tasks',
- '',
- 'Register all swarm agents as scheduled tasks. Run this once after `agentguard init swarm`.',
- '',
- '## Autonomy Directive',
- '',
- 'This skill runs interactively. Confirm with the user before creating tasks.',
- '',
- '## Steps',
- '',
- '### 1. Create Scheduled Tasks',
- '',
- 'Use the `mcp__scheduled-tasks__create_scheduled_task` tool to register each agent:',
- '',
- ];
-
- for (const agent of result.agents) {
- lines.push(`#### ${agent.name}`);
- lines.push('');
- lines.push(`- **Task ID**: \`${agent.id}\``);
- lines.push(`- **Cron**: \`${agent.cron}\``);
- lines.push(`- **Description**: ${agent.description}`);
- lines.push(`- **Prompt**: Use the content from the \`${agent.id}\` prompt template`);
- lines.push('');
- }
-
- lines.push('### 2. Verify');
- lines.push('');
- lines.push(
- 'After creating all tasks, use `mcp__scheduled-tasks__list_scheduled_tasks` to verify they are registered.'
- );
- lines.push('');
-
- return lines.join('\n');
-}
-
// ---------------------------------------------------------------------------
// Studio wizard — interactive project bootstrap
// ---------------------------------------------------------------------------
@@ -1484,13 +1363,6 @@ const PROFILE_DESCRIPTIONS: Record = {
permissive: 'Minimal — only block the most dangerous operations',
};
-const SWARM_PRESETS: Record = {
- full: ['core', 'governance', 'ops', 'quality', 'marketing'],
- 'qa-focused': ['core', 'quality'],
- 'dev-ops': ['core', 'governance', 'ops'],
- minimal: ['core'],
-};
-
async function studioPrompt(question: string, options: string[], defaultIdx = 0): Promise {
if (!process.stdin.isTTY) return defaultIdx;
@@ -1571,30 +1443,7 @@ async function initStudio(parsed: ReturnType): Promise
}
const selectedProfile = profileNames[profileIdx];
- // Step 3: Select swarm preset
- const presetNames = Object.keys(SWARM_PRESETS);
- const presetOptions = presetNames.map(
- (p) => `${bold(p)} — tiers: ${SWARM_PRESETS[p].join(', ')}`
- );
-
- let defaultPresetIdx = 0; // full
- if (!detection.isMonorepo) {
- defaultPresetIdx = presetNames.indexOf('minimal');
- }
-
- let swarmPresetIdx: number;
- let includeSwarm: boolean;
- if (nonInteractive) {
- includeSwarm = true;
- swarmPresetIdx = defaultPresetIdx;
- } else {
- includeSwarm = await studioConfirm(`\n ${bold('Include agent swarm?')}`, true);
- swarmPresetIdx = includeSwarm
- ? await studioPrompt('Select swarm preset:', presetOptions, defaultPresetIdx)
- : 0;
- }
-
- // Step 4: Scaffold execution profile
+ // Step 3: Scaffold execution profile
mkdirSync(projectRoot, { recursive: true });
const templatesDir = resolveTemplatesDir();
const templatePath = join(templatesDir, `${selectedProfile}.yaml`);
@@ -1626,40 +1475,7 @@ async function initStudio(parsed: ReturnType): Promise
);
}
- // Step 5: Scaffold swarm (if selected)
- if (includeSwarm) {
- const selectedPreset = presetNames[swarmPresetIdx];
- const tiers = SWARM_PRESETS[selectedPreset];
-
- let scaffoldFn: typeof import('@red-codes/swarm').scaffold;
- try {
- const swarmModule = await import('@red-codes/swarm');
- scaffoldFn = swarmModule.scaffold;
- } catch {
- console.error(
- `\n ${color('⚠', 'yellow')} @red-codes/swarm not found — skipping swarm scaffold`
- );
- scaffoldFn = null as unknown as typeof import('@red-codes/swarm').scaffold;
- }
-
- if (scaffoldFn) {
- try {
- const result = scaffoldFn({ projectRoot, tiers });
-
- console.log(
- ` ${color('✓', 'green')} Swarm: ${bold(selectedPreset)} preset (${result.agents.length} agents, ${tiers.join(', ')})`
- );
- console.log(
- ` ${dim('Skills written:')} ${result.skillsWritten} ${dim('Skipped:')} ${result.skillsSkipped}`
- );
- } catch (err) {
- const msg = err instanceof Error ? err.message : String(err);
- console.error(` ${color('⚠', 'yellow')} Swarm scaffold failed: ${msg}`);
- }
- }
- }
-
- // Step 6: Set up Claude Code hooks (if Claude Code detected)
+ // Step 4: Set up Claude Code hooks (if Claude Code detected)
if (detection.agentRuntimes.includes('Claude Code')) {
const setupHooks =
nonInteractive ||
@@ -1690,12 +1506,6 @@ async function initStudio(parsed: ReturnType): Promise
console.log(`\n ${color('✓', 'green')} ${bold('Studio initialized')}\n`);
console.log(` ${bold('What was set up:')}`);
console.log(` ${dim('Policy:')} ${selectedProfile} execution profile`);
- if (includeSwarm) {
- const selectedPreset = presetNames[swarmPresetIdx];
- console.log(
- ` ${dim('Swarm:')} ${selectedPreset} preset (${SWARM_PRESETS[selectedPreset].join(', ')})`
- );
- }
if (detection.agentRuntimes.includes('Claude Code')) {
console.log(` ${dim('Hooks:')} Claude Code governance hooks`);
}
@@ -1703,10 +1513,6 @@ async function initStudio(parsed: ReturnType): Promise
console.log(`\n ${bold('Next steps:')}`);
console.log(` ${dim('#')} Review and customize agentguard.yaml`);
console.log(` aguard guard --dry-run`);
- if (includeSwarm) {
- console.log(` ${dim('#')} Register swarm tasks in Claude Code`);
- console.log(` ${dim('#')} See .claude/skills/register-swarm-tasks.md`);
- }
console.log('');
return 0;
@@ -1714,7 +1520,7 @@ async function initStudio(parsed: ReturnType): Promise
function printInitHelp(): void {
console.log(`
- ${bold('agentguard init')} — Scaffold a new governance extension, policy template, or agent swarm
+ ${bold('agentguard init')} — Scaffold a new governance extension or policy template
${bold('Usage:')}
agentguard init --extension [--name ] [--dir ]
@@ -1730,10 +1536,7 @@ function printInitHelp(): void {
simulator Custom action simulator
${bold('Studio wizard:')}
- studio Interactive workspace bootstrap — detect project, select profile + swarm
-
- ${bold('Agent swarm:')}
- swarm Scaffold the full agent swarm (skills, config, task definitions)
+ studio Interactive workspace bootstrap — detect project, select profile
${bold('Storage backends:')}
firestore Set up Firestore backend (security rules + credentials guide)
@@ -1751,8 +1554,6 @@ function printInitHelp(): void {
--template, -t Policy template name (creates agentguard.yaml)
--name, -n Extension name (default: my-)
--dir, -d Output directory (default: ./ or . for templates)
- --tiers Comma-separated tiers for swarm (core,governance,ops,quality,marketing)
- --force Overwrite existing skill files during swarm init
--non-interactive Skip prompts, use detected defaults (for CI/scripting)
${bold('Examples:')}
@@ -1765,8 +1566,5 @@ function printInitHelp(): void {
agentguard init firestore
agentguard init studio
agentguard init studio --non-interactive
- agentguard init swarm
- agentguard init swarm --tiers core,governance
- agentguard init swarm --force
`);
}
diff --git a/apps/cli/tests/cli-init.test.ts b/apps/cli/tests/cli-init.test.ts
index 4625a933..f902f79f 100644
--- a/apps/cli/tests/cli-init.test.ts
+++ b/apps/cli/tests/cli-init.test.ts
@@ -10,19 +10,13 @@ vi.mock('node:fs', () => ({
readFileSync: vi.fn(),
}));
-vi.mock('@red-codes/swarm', () => ({
- scaffold: vi.fn(),
-}));
-
import { init } from '../src/commands/init.js';
-import { scaffold } from '@red-codes/swarm';
beforeEach(() => {
vi.clearAllMocks();
vi.spyOn(console, 'log').mockImplementation(() => {});
vi.spyOn(console, 'error').mockImplementation(() => {});
vi.mocked(existsSync).mockReturnValue(false);
- vi.mocked(scaffold).mockReturnValue({ agents: [{}, {}, {}], skillsWritten: 3, skillsSkipped: 0 });
});
afterEach(() => {
@@ -565,38 +559,6 @@ describe('init command', () => {
expect(output).toContain('ci-safe');
});
- it('should scaffold swarm by default in non-interactive mode', async () => {
- setupStudioMocks();
- await init(['studio', '--non-interactive']);
- expect(vi.mocked(scaffold)).toHaveBeenCalled();
- });
-
- it('should use minimal swarm preset for a non-monorepo project', async () => {
- setupStudioMocks();
- await init(['studio', '--non-interactive']);
- const call = vi.mocked(scaffold).mock.calls[0];
- expect(call?.[0]?.tiers).toEqual(['core']);
- });
-
- it('should use full swarm preset for a monorepo', async () => {
- setupStudioMocks({ isMonorepo: true });
- await init(['studio', '--non-interactive']);
- const call = vi.mocked(scaffold).mock.calls[0];
- expect(call?.[0]?.tiers).toEqual(
- expect.arrayContaining(['core', 'governance', 'ops', 'quality', 'marketing'])
- );
- });
-
- it('should handle swarm scaffold failure gracefully and still return 0', async () => {
- setupStudioMocks();
- vi.mocked(scaffold).mockImplementation(() => {
- throw new Error('disk full');
- });
- const code = await init(['studio', '--non-interactive']);
- expect(code).toBe(0);
- expect(console.error).toHaveBeenCalledWith(expect.stringContaining('disk full'));
- });
-
it('should overwrite existing agentguard.yaml in non-interactive mode', async () => {
setupStudioMocks({ hasExistingYaml: true });
await init(['studio', '--non-interactive']);
@@ -626,15 +588,6 @@ describe('init command', () => {
expect(output).toContain('Studio initialized');
});
- it('should include swarm tier in summary when swarm was scaffolded', async () => {
- setupStudioMocks();
- const consoleSpy = vi.spyOn(console, 'log').mockImplementation(() => {});
- await init(['studio', '--non-interactive']);
-
- const output = consoleSpy.mock.calls.flat().join('\n');
- expect(output).toContain('minimal');
- });
-
it('should write files to custom --dir when provided', async () => {
setupStudioMocks();
await init(['studio', '--non-interactive', '--dir', '/tmp/studio-test-dir']);
diff --git a/docs/agent-sdlc-architecture.md b/docs/agent-sdlc-architecture.md
deleted file mode 100644
index 89aa5079..00000000
--- a/docs/agent-sdlc-architecture.md
+++ /dev/null
@@ -1,266 +0,0 @@
-# Deterministic Action Mediation for Agent-Native Software Engineering
-
-## Abstract
-
-As AI agents transition from passive code assistants to active system operators, the fundamental risk in software development shifts from incorrect reasoning to unsafe execution. Agent-generated actions may modify source code, execute infrastructure commands, or interact with external systems.
-
-Traditional guardrails embedded inside language models are probabilistic and insufficient for enforcing safe execution.
-
-This document proposes a deterministic architecture for Agent-Native Software Development Life Cycles (SDLC) based on three principles:
-
-1. Separation of reasoning and execution
-2. Deterministic authorization boundaries for agent actions
-3. Observable runtime telemetry for agent behavior
-
-The system introduces an Action Authorization Boundary (AAB) that mediates all agent actions and a runtime telemetry layer that records execution outcomes.
-
-Together these components create a controlled environment for safe agent-driven development.
-
-## System Architecture
-
-The architecture separates the AI reasoning layer from the execution environment.
-
-```
-Agent Reasoning Layer
-(LLM planning, code generation)
- │
- ▼
-Intent Compilation
-(structured action proposals)
- │
- ▼
-Action Authorization Boundary
-(deterministic policy enforcement)
- │
- ▼
-Execution Adapters
-(filesystem, shell, CI, APIs)
- │
- ▼
-Runtime Telemetry Layer
-(event monitoring, audit, and replay)
-```
-
-This separation ensures that probabilistic reasoning never directly controls real-world execution.
-
-## Core Components
-
-### 1. Intent Layer
-
-The AI agent produces structured intent objects representing requested actions rather than raw commands.
-
-Example:
-
-```json
-{
- "action": "file.write",
- "target": "src/auth/session.ts",
- "justification": "Fix token refresh logic"
-}
-```
-
-Intent compilation converts natural language reasoning into canonical action representations. This normalization step is required for deterministic authorization.
-
-**Implementation:** The canonical event factory in [`domain/events.js`](../domain/events.js) provides the `createEvent(kind, data)` function that normalizes all system activity into structured, validated events with stable fingerprints.
-
-### 2. Action Authorization Boundary (AAB)
-
-The AAB is the system's enforcement core and acts as a reference monitor for agent actions.
-
-Responsibilities:
-
-- Canonicalize action requests
-- Evaluate policy and capability constraints
-- Allow or deny execution
-- Record authorization decisions
-- Emit execution events
-
-Example policy:
-
-```
-file.write: src/**
-test.run: allowed
-shell.exec: restricted
-terraform.apply: denied
-```
-
-The AAB represents the smallest trusted component in the system and must remain minimal and auditable.
-
-**Implementation:** The AAB is specified in [`docs/agentguard.md`](agentguard.md) with a complete evaluation pipeline (parse → scope → policy → invariant → blast radius → decision). The action interception prototype exists in [`core/cli/claude-hook.js`](../core/cli/claude-hook.js) as a Claude Code PostToolUse hook.
-
-### 3. Execution Adapters
-
-Execution adapters translate approved actions into real system operations.
-
-Examples:
-
-- Filesystem adapter
-- Shell adapter
-- Test runner adapter
-- CI adapter
-- API adapter
-
-All operations must pass through the AAB before execution. Direct agent access to execution environments is prohibited.
-
-**Implementation:** The CLI adapter ([`core/cli/adapter.js`](../core/cli/adapter.js)) wraps child processes and intercepts stderr. The ingestion pipeline ([`domain/ingestion/pipeline.js`](../domain/ingestion/pipeline.js)) orchestrates parse → fingerprint → classify → map stages for all intercepted output.
-
-### 4. Runtime Telemetry Layer
-
-The telemetry layer acts as the observability and feedback system for agent execution.
-
-Instead of relying solely on logs, it records structured events that describe both agent actions and their consequences.
-
-Example events:
-
-```
-ActionRequested
-ActionAllowed
-ActionDenied
-FileModified
-TestFailed
-InvariantViolation
-```
-
-The telemetry layer enables:
-
-- Execution replay
-- Debugging timelines
-- Anomaly detection
-- Developer feedback loops
-
-**Implementation:** The universal EventBus ([`domain/event-bus.js`](../domain/event-bus.js)) provides pub/sub across Node.js and browser environments. The EventStore ([`domain/event-store.js`](../domain/event-store.js)) persists events with query, replay, and filtering capabilities. The JSONL sink persists all events for audit trail and post-session analysis.
-
-## Event Model
-
-All system activity is captured as immutable events.
-
-Example flow:
-
-```
-Agent proposes action
- │
- ▼
-AAB evaluates policy
- │
- ▼
-Action allowed
- │
- ▼
-Execution adapter performs operation
- │
- ▼
-Test failure occurs
- │
- ▼
-Telemetry records event
-```
-
-This event stream forms a complete audit trail of agent activity.
-
-**Implementation:** The system defines 30 canonical event kinds across 6 categories (ingestion, battle lifecycle, progression, session, governance, developer signals) in [`domain/events.js`](../domain/events.js). Events are validated against schemas, assigned monotonic IDs, and fingerprinted for deduplication.
-
-## Security and Reliability Model
-
-The architecture adopts principles from high-assurance systems.
-
-**Reference Monitor.** All access to execution resources must pass through the AAB.
-
-**Minimal Trusted Computing Base.** The authorization boundary remains small and verifiable.
-
-**Capability-Based Permissions.** Agents receive granular execution rights rather than broad system access.
-
-**Immutable Telemetry.** All decisions and outcomes are recorded as events.
-
-## Academic Foundations
-
-This architecture draws from three established fields of computer science. Citing these foundations distinguishes the system from ad-hoc AI tooling and positions it within rigorous engineering traditions.
-
-### 1. Reference Monitors (Anderson, 1972)
-
-The Action Authorization Boundary implements the classical reference monitor concept from James P. Anderson's 1972 Computer Security Technology Planning Study. A reference monitor must satisfy three properties:
-
-1. **Complete mediation** — every access to a protected resource is checked
-2. **Tamper-proof** — the monitor cannot be bypassed or modified by the subjects it governs
-3. **Verifiable** — the monitor is small enough to be subject to analysis and testing
-
-The AAB satisfies these properties by design. All agent actions must pass through the boundary (complete mediation). The AAB operates as a deterministic runtime separate from the AI reasoning layer (tamper-proof — the agent cannot modify its own constraints). The policy evaluation logic is pure functions operating on data with no inference or heuristics (verifiable).
-
-Most AI guardrail systems fail the reference monitor test because they embed safety checks inside the probabilistic model itself. By externalizing enforcement into a deterministic boundary, this architecture achieves the formal properties that embedded guardrails cannot.
-
-> Anderson, J. P. (1972). *Computer Security Technology Planning Study*. ESD-TR-73-51, Vol. II. Air Force Electronic Systems Division.
-
-### 2. Capability-Based Security (Dennis & Van Horn, 1966)
-
-The policy model follows the capability-based security paradigm introduced by Jack Dennis and Earl Van Horn. In this model, agents do not receive ambient authority (broad permissions inherited from the user's environment). Instead, each agent receives an explicit capability set — a bounded collection of permissions that defines exactly what actions it may perform.
-
-```yaml
-# Agent capability set (not ambient authority)
-policy:
- scope:
- include: ["src/**", "tests/**"]
- exclude: ["src/database/**"]
- permissions:
- file_edit: allow
- file_delete: deny
- git_push: deny
-```
-
-This is the Principle of Least Authority (POLA) applied to AI agents. The agent can only act within its declared capabilities, regardless of the broader permissions available to the user who invoked it.
-
-The capability model also enables composition. Multiple policies can apply to the same agent. If any policy denies an action, the action is denied (fail-closed composition).
-
-> Dennis, J. B., & Van Horn, E. C. (1966). Programming semantics for multiprogrammed computations. *Communications of the ACM*, 9(3), 143–155.
-
-### 3. Event Sourcing (Domain-Driven Design)
-
-The canonical event model follows the Event Sourcing pattern from domain-driven design. Rather than storing only the current state of the system, every state change is captured as an immutable event. The current state can be reconstructed by replaying the event stream.
-
-This provides three critical capabilities for agent-driven development:
-
-1. **Audit trail** — every agent action, policy decision, and execution outcome is recorded with full context
-2. **Replay** — any sequence of events can be replayed to reproduce system behavior, enabling debugging and root cause analysis
-3. **Temporal queries** — the system can answer questions about what happened at any point in time, not just what the current state is
-
-The event store supports filtering by kind, time range, and fingerprint, enabling both real-time monitoring and post-hoc analysis.
-
-Event sourcing transforms agent observability from "what is the system doing now" to "what has the system done, and why." This distinction is essential for building trust in autonomous agent behavior.
-
-> Vernon, V. (2013). *Implementing Domain-Driven Design*. Addison-Wesley.
-> Young, G. (2010). CQRS Documents. https://cqrs.files.wordpress.com/2010/11/cqrs_documents.pdf
-
-## Advantages
-
-- Deterministic safety enforcement
-- Observable agent execution
-- Improved debugging workflows
-- Human-interpretable agent behavior
-- Compatibility with existing development tools
-
-This architecture enables organizations to safely integrate autonomous agents into software engineering workflows without sacrificing control or auditability.
-
-## Future Work
-
-Potential extensions include:
-
-- Automated policy synthesis from codebase analysis
-- Invariant learning from repository history
-- Agent debugging replay systems
-- Multi-agent orchestration frameworks with shared governance
-- AI-assisted root cause analysis from event streams
-
-These capabilities transform agent-driven development from experimental tooling into a structured and observable engineering discipline.
-
-## Summary
-
-Agent-native development requires a fundamental shift in system architecture.
-
-By separating reasoning from execution and introducing deterministic enforcement boundaries, it becomes possible to safely deploy AI agents in real engineering environments.
-
-The combination of Action Authorization Boundaries (AAB) and runtime telemetry systems provides the foundational infrastructure for this next generation of software development.
-
-## See Also
-
-- [AgentGuard Specification](agentguard.md) — detailed governance runtime design
-- [Unified Architecture](unified-architecture.md) — full system architecture
-- [Event Model](event-model.md) — canonical event schema and lifecycle
-- [Architecture](../ARCHITECTURE.md) — system-level technical architecture
diff --git a/docs/autonomous-sdlc-architecture.md b/docs/autonomous-sdlc-architecture.md
deleted file mode 100644
index 56f833d0..00000000
--- a/docs/autonomous-sdlc-architecture.md
+++ /dev/null
@@ -1,1233 +0,0 @@
-# Autonomous SDLC Architecture
-
-> AgentGuard as a self-governing agent execution kernel: a capability-secured syscall runtime for autonomous software development.
-
-## 1. Architectural Thesis
-
-AgentGuard is a governed action runtime for AI coding agents. This document describes how it becomes a **self-governing autonomous SDLC testbed** — where AI agents develop AgentGuard itself, governed by AgentGuard's own runtime.
-
-### The Reflexive Property
-
-```
-AgentGuard
- ↑
-developed by agents
- ↑
-governed by AgentGuard itself
-```
-
-This is structurally identical to:
-- Compilers compiling themselves
-- Operating systems building themselves
-- Kubernetes managing Kubernetes
-
-The system becomes a **live laboratory for agent safety**. Instead of theorizing about agent governance, we observe real agent behavior: failure modes, policy violations, unsafe tool usage, CI breakage patterns, drift between intent and execution. That produces empirical data, not theoretical models.
-
-### The OS Analogy
-
-In an operating system, programs cannot access hardware directly:
-
-```
-program → syscall → kernel → hardware
-```
-
-The kernel enforces permissions, memory safety, resource limits, and auditing. The same model applies to agents:
-
-```
-agent → syscall → AgentGuard kernel → system resources
-```
-
-Agents cannot directly access the filesystem, git, shell, or CI. Everything flows through AgentGuard's syscall interface. AgentGuard decides: **ALLOW**, **DENY**, or **REQUIRE_APPROVAL**.
-
-### Three-Layer Security Model
-
-Every syscall passes through three independent evaluation layers:
-
-```
-Layer 1: Capabilities → Can this agent even attempt this class of action?
-Layer 2: Policies → Is this action allowed under current governance rules?
-Layer 3: Invariants → Would this action violate system correctness constraints?
-```
-
-Each layer answers a different question. Each layer's decision is recorded separately in the audit trail. This separation prevents the system from collapsing into a single pile of allow/deny logic.
-
-**Default posture**: closed unless explicitly granted. No capability = no attempt possible.
-
-### Design Goals
-
-1. **Self-governing**: AgentGuard governs its own development. Every agent action on AgentGuard's codebase passes through AgentGuard's kernel.
-2. **Syscall-mediated**: Agents interact with the system through 5 primitive operations. No direct access to filesystem, git, or shell.
-3. **Capability-secured**: Agents possess specific, bounded, time-limited authority tokens. Default-deny, not default-allow.
-4. **Minimal viable first**: 1 planner agent + 1 coder agent + governance runtime. No swarm until the narrow loop works.
-5. **Experimentally grounded**: Every governance decision produces structured telemetry. Agent failure patterns become research data.
-
----
-
-## 2. Agent Syscall Interface
-
-### The 5 SDLC Primitives
-
-Everything agents do in a development lifecycle reduces to five operations:
-
-| Syscall | Purpose | Examples |
-|---------|---------|---------|
-| **`read_resource`** | Inspect system state | Read source files, view git diff, read issue descriptions, check test results |
-| **`write_resource`** | Modify files | Write source code, edit tests, update configuration |
-| **`run_task`** | Execute deterministic processes | Run tests, lint, build, type-check |
-| **`create_artifact`** | Produce task outputs | Generate test results, coverage reports, lint reports |
-| **`propose_change`** | Submit work for review | Create commits, open pull requests |
-
-Agents cannot perform anything outside this set. That gives deterministic governance over a small, auditable surface.
-
-### Mapping to AgentGuard's Action Types
-
-AgentGuard already defines 41 canonical action types across 10 classes (`packages/core/src/data/actions.json`). The 5 SDLC syscalls are a higher-level abstraction over these implementation-level types:
-
-| Syscall | AgentGuard Action Types |
-|---------|------------------------|
-| `read_resource` | `file.read`, `git.diff` |
-| `write_resource` | `file.write`, `file.delete`, `file.move` |
-| `run_task` | `test.run`, `test.run.unit`, `test.run.integration`, `npm.script.run` |
-| `create_artifact` | `file.write` (to artifact output paths) |
-| `propose_change` | `git.commit`, `git.branch.create` + external PR creation |
-
-The AAB (`src/kernel/aab.ts`) is the syscall router. It already normalizes Claude Code tool calls into canonical action types via `TOOL_ACTION_MAP`:
-
-```
-Claude Code Tool → AAB normalization → Action Type (syscall)
-Write → normalizeIntent() → file.write (write_resource)
-Edit → normalizeIntent() → file.write (write_resource)
-Read → normalizeIntent() → file.read (read_resource)
-Bash → detectGitAction() → git.* or shell.exec
-Glob → normalizeIntent() → file.read (read_resource)
-Grep → normalizeIntent() → file.read (read_resource)
-```
-
-For `Bash` tool calls, `detectGitAction()` further classifies git commands (e.g., `git push` → `git.push`, `git commit` → `git.commit`).
-
-### Syscall Wire Format
-
-Every syscall carries this structure (evolved from the Canonical Action Representation):
-
-```json
-{
- "syscall": "write_resource",
- "target": "src/kernel/monitor.ts",
- "agent_id": "agent_dev_1a2b",
- "capability_id": "cap_0192",
- "payload": {
- "content": "...",
- "diff_lines": 42
- },
- "context": {
- "task_id": "issue_42",
- "role": "developer",
- "run_id": "run_1709913400_abc",
- "pipeline_stage": "implementation"
- }
-}
-```
-
-This maps to `RawAgentAction` (`src/kernel/aab.ts:17-27`) with context injected via `metadata`:
-
-```typescript
-const raw: RawAgentAction = {
- tool: 'Edit',
- file: 'src/kernel/monitor.ts',
- content: '...',
- agent: 'agent_dev_1a2b',
- metadata: {
- role: 'developer',
- taskId: 42,
- capabilityId: 'cap_0192',
- pipelineStage: 'implementation',
- hook: 'PreToolUse',
- },
-};
-```
-
-### The Critical Rule
-
-**Agents must not be able to bypass the syscall interface.**
-
-This is enforced by registering AgentGuard as a **PreToolUse** hook for all Claude Code tools. The hook intercepts every tool call before execution and routes it through `kernel.propose()`. If the kernel denies the action, the tool call is blocked.
-
-Without PreToolUse enforcement, the capability model is advisory, not real.
-
----
-
-## 3. Capability Model
-
-### What a Capability Is
-
-A capability is a **signed grant of authority** to perform a bounded class of actions. Not role-based labels like "coder agent = can code." Instead, concrete, scoped, time-limited authority:
-
-```json
-{
- "id": "cap_0192",
- "subject": "agent_dev_1a2b",
- "operation": "write_resource",
- "scopes": [
- "repo://agent-guard/src/**",
- "repo://agent-guard/tests/**"
- ],
- "constraints": {
- "deny": [
- "repo://agent-guard/src/kernel/**",
- "repo://agent-guard/src/policy/**",
- "repo://agent-guard/src/invariants/**"
- ],
- "max_files": 20,
- "max_diff_lines": 500
- },
- "issued_to": "agent_dev_1a2b",
- "issued_by": "agentguard-scheduler",
- "issued_at": "2026-03-09T10:00:00Z",
- "expires_at": "2026-03-09T10:30:00Z",
- "task_id": "issue_42"
-}
-```
-
-This means:
-- The agent **can** write files in `src/**` and `tests/**`
-- The agent **cannot** write to `src/kernel/**`, `src/policy/**`, or `src/invariants/**` (self-modification protection)
-- The agent **cannot** modify more than 20 files or 500 diff lines
-- The authority **expires** after 30 minutes
-- The authority is **scoped to a single task**
-
-### Why Capabilities, Not Just Policies
-
-Pure policy says: "any agent may ask, the system decides every time." The default is open-unless-denied.
-
-Capabilities say: "the agent can only even attempt actions for which it holds authority." The default is **closed-unless-explicitly-granted**.
-
-That is the correct default for autonomous systems. It changes the failure mode from "the system forgot to deny something" to "the system must explicitly grant everything."
-
-### The 5 Core Capabilities
-
-Each maps to one of the 5 syscalls:
-
-**A. Read Capability**
-```json
-{
- "operation": "read_resource",
- "scopes": ["repo://agent-guard/src/**", "repo://agent-guard/docs/**", "artifact://test-results/**"]
-}
-```
-
-**B. Write Capability**
-```json
-{
- "operation": "write_resource",
- "scopes": ["repo://agent-guard/src/**", "repo://agent-guard/tests/**"],
- "constraints": {
- "deny": ["repo://agent-guard/src/kernel/**", "repo://agent-guard/src/policy/**"],
- "max_files": 20
- }
-}
-```
-
-**C. Task Capability**
-```json
-{
- "operation": "run_task",
- "scopes": ["task://test", "task://lint", "task://build", "task://ts:check"]
-}
-```
-
-**D. Artifact Capability**
-```json
-{
- "operation": "create_artifact",
- "scopes": ["artifact://test-results/**", "artifact://coverage/**", "artifact://lint-report/**"]
-}
-```
-
-**E. Change Proposal Capability**
-```json
-{
- "operation": "propose_change",
- "scopes": ["branch://agent/issue-42/*"],
- "constraints": {
- "requires_artifacts": ["test-results", "coverage"],
- "requires_tests_passing": true
- }
-}
-```
-
-### Capability Validation Flow
-
-For each syscall, the kernel validates in order:
-
-1. **Authentic?** — Is the token genuine (signature check)?
-2. **Expired?** — Is the token still valid?
-3. **Subject match?** — Does the token belong to this agent?
-4. **Operation match?** — Does the token authorize this syscall type?
-5. **Scope match?** — Does the target fall within the granted scopes?
-6. **Constraints satisfied?** — Are constraint limits (max_files, deny patterns) met?
-
-Only after capability validation does the syscall proceed to Layer 2 (policies) and Layer 3 (invariants).
-
-### Roles as Capability Bundles
-
-Roles are an ergonomic layer. A "developer" role expands into a set of capability grants:
-
-```
-developer role → [
- read_resource(repo://**),
- write_resource(repo://src/**, repo://tests/**),
- run_task(task://test, task://lint, task://build),
- create_artifact(artifact://test-results/**, artifact://coverage/**),
- propose_change(branch://agent/*)
-]
-```
-
-This keeps role-based thinking for humans while maintaining precise authority for governance.
-
-### Capability Lifecycle
-
-Capabilities are:
-- **Short-lived**: Issued per task, expire when the task completes or times out
-- **Task-scoped**: Each GitHub Issue gets a fresh authority envelope
-- **Revocable**: The scheduler can revoke capabilities if escalation level rises
-- **Non-transferable**: An agent cannot pass its capability to another agent (delegation requires the scheduler)
-
-### Delegation
-
-A planner agent does not directly issue capabilities. Instead, the scheduler observes the planner's output (file scope declarations, task assignments) and mints appropriately scoped capabilities for downstream agents:
-
-```
-Planner (via propose_change) → "Task: add rate limiting to monitor.ts"
- → Scheduler reads planner output
- → Scheduler mints capability for coder:
- write_resource(src/kernel/monitor.ts, tests/ts/monitor.test.ts)
- run_task(test, lint)
- propose_change(branch://agent/issue-42)
- → Coder receives bounded capability
-```
-
-This prevents agents from minting arbitrary authority.
-
----
-
-## 4. Three-Layer Security Model
-
-### Layer 1 — Capabilities: Authority
-
-**Question**: Can this agent even attempt this class of action?
-
-**Implementation**: Capability token validation (new — to be built).
-
-**Behavior**: Default-deny. If no valid capability exists for the requested syscall + scope, the action is immediately rejected before policy evaluation begins.
-
-**Example**:
-```
-Agent: agent_qa_3c4d
-Syscall: write_resource
-Target: src/kernel/kernel.ts
-Capability: write_resource(tests/**)
-
-Result: DENIED (target outside capability scope)
-```
-
-### Layer 2 — Policies: Governance
-
-**Question**: Is this action allowed under current governance rules?
-
-**Implementation**: Existing `PolicyRule` evaluation in `src/policy/evaluator.ts`. The `evaluate()` function matches actions against loaded policy rules, checking action patterns, scope conditions, branch conditions, and limits.
-
-**Behavior**: Rules can allow or deny. Deny rules from any source take priority (the evaluator checks denies first at `evaluator.ts:107`).
-
-**Example**:
-```
-Agent: agent_dev_1a2b
-Syscall: write_resource
-Target: .github/workflows/ci.yml
-Capability: write_resource(src/**, tests/**) — PASSES (different check)
-Policy: deny file.write scope:[.github/**] — DENIED
-
-Result: DENIED (policy denial, reason: "CI config changes require human approval")
-```
-
-### Layer 3 — Invariants: Correctness
-
-**Question**: Would this action violate system correctness constraints?
-
-**Implementation**: Existing `DEFAULT_INVARIANTS` in `src/invariants/definitions.ts`. Six built-in invariants checked via `InvariantChecker`:
-
-1. **`no-secret-exposure`** (severity 5): No `.env`, credentials, `.pem`, `.key` files committed
-2. **`protected-branch`** (severity 5): No direct push to main/master
-3. **`blast-radius`** (severity 4): File modification count within limits
-4. **`test-before-push`** (severity 3): Tests must pass before push
-5. **`no-force-push`** (severity 5): No `git push --force`
-6. **`lockfile-integrity`** (severity 3): Lock file consistency
-
-**Example**:
-```
-Agent: agent_dev_1a2b
-Syscall: propose_change
-Target: branch://main
-Capability: propose_change(branch://agent/*) — DENIED (scope mismatch)
-
-But even if capability passed:
-Invariant: protected-branch — DENIED (direct push to main forbidden)
-```
-
-### Combined Evaluation Flow
-
-```
-Agent proposes tool call
- ↓
-PreToolUse hook fires
- ↓
-normalizeClaudeCodeAction() → RawAgentAction
- ↓
-AAB.normalizeIntent() → NormalizedIntent (action type, target, destructive)
- ↓
-┌─────────────────────────────────────────────────┐
-│ Layer 1: Capability Validation │
-│ Is capability token valid? │
-│ Does operation match? │
-│ Is target within scope? │
-│ Are constraints satisfied? │
-│ │
-│ → If DENIED: emit CapabilityDenied, return │
-└─────────────────────────┬───────────────────────┘
- ↓
-┌─────────────────────────────────────────────────┐
-│ Layer 2: Policy Evaluation │
-│ evaluate(intent, policies) → EvalResult │
-│ Match rules by action pattern, scope, branch │
-│ │
-│ → If DENIED: emit PolicyDenied, return │
-└─────────────────────────┬───────────────────────┘
- ↓
-┌─────────────────────────────────────────────────┐
-│ Layer 3: Invariant Checking │
-│ checkInvariants(systemState) → violations[] │
-│ Verify correctness constraints hold │
-│ │
-│ → If VIOLATED: emit InvariantViolation, return │
-└─────────────────────────┬───────────────────────┘
- ↓
-┌─────────────────────────────────────────────────┐
-│ Monitor: Escalation Check │
-│ Track denial rate, adjust escalation level │
-│ NORMAL → ELEVATED → HIGH → LOCKDOWN │
-│ LOCKDOWN = all actions denied │
-└─────────────────────────┬───────────────────────┘
- ↓
- EXECUTE action
- ↓
- Emit lifecycle events to JSONL
-```
-
-### Audit Semantics
-
-Each layer's decision is recorded separately in the `GovernanceDecisionRecord`:
-
-```json
-{
- "recordId": "dec_1709913600_a1b2",
- "runId": "run_1709913400_abc",
- "timestamp": 1709913600000,
- "action": {
- "type": "file.write",
- "target": "src/kernel/monitor.ts",
- "agent": "agent_dev_1a2b",
- "destructive": false
- },
- "capability": {
- "id": "cap_0192",
- "operation": "write_resource",
- "scope_match": true,
- "constraints_satisfied": true
- },
- "policy": {
- "matchedPolicyId": "sdlc-developer-policy",
- "matchedPolicyName": "Developer Agent Policy",
- "severity": 4,
- "decision": "allow",
- "reason": "Developer may modify source and tests"
- },
- "invariants": {
- "allHold": true,
- "violations": []
- },
- "monitor": {
- "escalationLevel": 0,
- "totalEvaluations": 47,
- "totalDenials": 2
- },
- "outcome": "allow",
- "execution": {
- "executed": true,
- "success": true,
- "durationMs": 12
- }
-}
-```
-
-Now you can answer for any action:
-- **What authority did the agent have?** → `capability`
-- **Who issued it?** → `capability.issued_by`
-- **Was it within scope?** → `capability.scope_match`
-- **Which governance rule applied?** → `policy.matchedPolicyId`
-- **Were correctness constraints maintained?** → `invariants.allHold`
-- **What was the escalation level?** → `monitor.escalationLevel`
-
----
-
-## 5. System Topology
-
-```
-┌────────────────────────────────────────────────────────────────┐
-│ GitHub (Cloud) │
-│ │
-│ ┌──────────────┐ ┌───────────────┐ ┌─────────────────────┐ │
-│ │ Issues │ │ Pull Requests │ │ Actions Workflows │ │
-│ │ (Task Queue) │ │ (Agent Output) │ │ (Scheduler Trigger) │ │
-│ └──────┬───────┘ └───────▲───────┘ └──────────┬──────────┘ │
-└─────────┼──────────────────┼─────────────────────┼─────────────┘
- │ poll │ create PR │ trigger
- ▼ │ ▼
-┌─────────────────────────────────────────────────────────────────┐
-│ External Scheduler │
-│ │
-│ ┌──────────┐ ┌──────────────┐ ┌──────────┐ ┌────────────┐ │
-│ │ Issue │ │ Capability │ │ Worktree │ │ PR │ │
-│ │ Poller │→ │ Minter │→ │ Manager │→ │ Creator │ │
-│ └──────────┘ └──────┬───────┘ └──────────┘ └────────────┘ │
-│ │ mint caps + spawn │
-└────────────────────────┼────────────────────────────────────────┘
- ▼
-┌─────────────────────────────────────────────────────────────────┐
-│ Agent Worktree (isolated git worktree) │
-│ │
-│ ┌──────────────────┐ │
-│ │ Claude Code Agent │ Every tool call is a syscall: │
-│ │ (capability-bound)│ │
-│ └────────┬─────────┘ │
-│ │ PreToolUse hook │
-│ ▼ │
-│ ┌──────────────────────────────────────────────────────────┐ │
-│ │ AgentGuard Kernel (syscall handler) │ │
-│ │ │ │
-│ │ RawAgentAction → AAB (syscall router) → NormalizedIntent │ │
-│ │ ↓ │ │
-│ │ Layer 1: Capability validation │ │
-│ │ ↓ │ │
-│ │ Layer 2: Policy evaluation │ │
-│ │ ↓ │ │
-│ │ Layer 3: Invariant checking │ │
-│ │ ↓ │ │
-│ │ Monitor (escalation) │ │
-│ │ ↓ │ │
-│ │ Execute or Deny → JSONL audit trail │ │
-│ └──────────────────────────────────────────────────────────┘ │
-└─────────────────────────────────────────────────────────────────┘
-```
-
----
-
-## 6. Agent Roles as Capability Bundles
-
-### Role Definitions
-
-7 roles, each defined as a bundle of capabilities:
-
-| Role | Capability Bundle |
-|------|------------------|
-| **research** | `read_resource(repo://**)` |
-| **product** | `read_resource(repo://**)` + `write_resource(docs/product/**, spec/**)` |
-| **architect** | `read_resource(repo://**)` + `write_resource(docs/**, spec/**, *.md)` |
-| **developer** | `read_resource(repo://**)` + `write_resource(src/**, tests/**, package.json)` + `run_task(test, lint, build, ts:check)` + `create_artifact(test-results, coverage)` + `propose_change(branch://agent/*)` |
-| **qa** | `read_resource(repo://**)` + `write_resource(tests/**)` + `run_task(test, test:unit, test:integration, lint)` + `create_artifact(test-results, coverage, lint-report)` + `propose_change(branch://agent/*)` |
-| **documentation** | `read_resource(repo://**)` + `write_resource(docs/**, *.md, examples/**)` + `propose_change(branch://agent/*)` |
-| **auditor** | `read_resource(repo://**)` + `run_task(test, lint)` + `create_artifact(audit-report)` |
-
-### Self-Modification Protection
-
-When AgentGuard governs its own development, certain paths must be protected from agent modification:
-
-| Protected Path | Reason |
-|---------------|--------|
-| `src/kernel/**` | Core governance logic — agent modifications could weaken enforcement |
-| `src/policy/**` | Policy engine — agents must not modify their own governance rules |
-| `src/invariants/**` | Invariant definitions — agents must not weaken correctness constraints |
-| `agentguard.yaml` | Default policy — changing this changes what agents can do |
-| `.claude/settings.json` | Hook configuration — agents must not disable governance hooks |
-
-These paths are excluded from all write capabilities via `constraints.deny`. Only human commits can modify governance-critical code.
-
-### CLAUDE.md Role Templates
-
-Each agent receives a role-specific CLAUDE.md in its worktree:
-
-```markdown
-# Agent Role: Developer
-# Task: #{issue_number} — {issue_title}
-
-## Authority
-You hold capabilities for: read_resource, write_resource, run_task, propose_change.
-Your write scope is limited to: {allowed_paths}
-Protected paths (will be denied): src/kernel/**, src/policy/**, src/invariants/**
-
-## Constraints
-- Do NOT attempt to modify files outside your scope (the syscall will be denied)
-- Do NOT push directly to any branch — commit to your worktree branch only
-- Run `npm run ts:check` and `npm run ts:test` before committing
-- Write tests for new functionality
-
-## Task Description
-{issue_body}
-
-## Acceptance Criteria
-{acceptance_criteria}
-```
-
----
-
-## 7. Task Lifecycle via GitHub Issues
-
-GitHub Issues serve as the task registry. State is encoded in labels.
-
-### Label Schema
-
-| Category | Labels |
-|----------|--------|
-| **Status** | `status:pending`, `status:assigned`, `status:in-progress`, `status:review`, `status:completed`, `status:failed` |
-| **Type** | `task:implementation`, `task:test-generation`, `task:documentation`, `task:bug-fix`, `task:refactor`, `task:architecture`, `task:research`, `task:review` |
-| **Priority** | `priority:critical`, `priority:high`, `priority:medium`, `priority:low` |
-| **Role** | `role:developer`, `role:qa`, `role:architect`, `role:documentation`, `role:auditor` |
-| **Retry** | `retry:0`, `retry:1`, `retry:2`, `retry:3` |
-| **Governance** | `governance:clean`, `governance:violations`, `governance:lockdown` |
-
-### State Machine
-
-```
-┌─────────┐ ┌──────────┐ ┌─────────────┐ ┌──────────┐
-│ pending │──→│ assigned │──→│ in-progress │──→│ review │
-└─────────┘ └──────────┘ └──────┬──────┘ └────┬─────┘
- │ │
- ▼ ▼
- ┌──────────┐ ┌───────────┐
- │ failed │ │ completed │
- └────┬─────┘ └───────────┘
- │
- ▼ (if retries remain)
- ┌─────────┐
- │ pending │
- └─────────┘
-```
-
-### Issue Body Template
-
-```markdown
-## Task Description
-[What needs to be done]
-
-## Acceptance Criteria
-- [ ] Criterion 1
-- [ ] Criterion 2
-
-## File Scope
-Allowed paths for this task:
-- `src/adapters/**`
-- `tests/ts/adapter-*.test.ts`
-
-## Protected Paths
-These paths must NOT be modified (enforced by capabilities):
-- `src/kernel/**`
-- `src/policy/**`
-- `src/invariants/**`
-
-## Dependencies
-Depends on: #41, #39
-
-## Branch
-`agent/implementation/issue-42`
-
-## Priority
-high
-
-## Max Retries
-3
-```
-
-### Assignment Comment
-
-```markdown
-**AgentGuard Scheduler** assigned this task.
-
-- **Agent**: `agent_dev_1a2b`
-- **Role**: developer
-- **Capabilities**: read_resource(repo://), write_resource(src/**, tests/**), run_task(test, lint, build), propose_change(branch://agent/issue-42/*)
-- **Protected**: src/kernel/**, src/policy/**, src/invariants/**
-- **Max Actions**: 200
-- **Timeout**: 30m
-- **Run ID**: `run_1709913400_abc`
-```
-
-### Completion Comment
-
-```markdown
-**AgentGuard Scheduler** — task completed.
-
-- **PR**: #87
-- **Actions**: 142 proposed, 138 allowed, 4 denied
-- **Capability denials**: 1 (attempted write to src/kernel/)
-- **Policy denials**: 2 (scope violations)
-- **Invariant violations**: 1 (blast radius exceeded, resolved after split)
-- **Escalation**: NORMAL
-- **Duration**: 18m 32s
-
-
-Governance Summary
-
-| Layer | Evaluations | Denials |
-|-------|------------|---------|
-| Capabilities | 142 | 1 |
-| Policies | 141 | 2 |
-| Invariants | 139 | 1 |
-
-
-```
-
----
-
-## 8. Minimal Viable Architecture
-
-### Phase 1: One Planner + One Coder + Governance
-
-The minimal loop that produces useful experiments:
-
-```
-roadmap.md (human-written)
- ↓
-planner agent (read_resource only)
- ↓
-GitHub Issue (task definition + file scope)
- ↓
-coder agent (capability-bound)
- ↓
-every tool call → AgentGuard kernel
- ↓
-policy checks + invariant checks
- ↓
-allow / deny
- ↓
-commit → PR → human review → merge
- ↓
-CI
-```
-
-### What Already Exists in AgentGuard
-
-| Component | Status | Location |
-|-----------|--------|----------|
-| Action type normalization (AAB) | Exists | `src/kernel/aab.ts` |
-| Policy evaluation | Exists | `src/policy/evaluator.ts` |
-| 26 invariant checks | Exists | `packages/invariants/src/definitions.ts` |
-| Escalation monitor (4 levels) | Exists | `src/kernel/monitor.ts` |
-| JSONL event persistence | Exists | `src/events/jsonl.ts` |
-| GovernanceDecisionRecord | Exists | `src/kernel/decisions/` |
-| Pre-execution simulation | Exists | `src/kernel/simulation/` |
-| Evidence pack generation | Exists | `src/kernel/evidence.ts` |
-| Claude Code adapter | Exists | `src/adapters/claude-code.ts` |
-| `claude-init` (hook setup) | Exists | `src/cli/commands/claude-init.ts` |
-| `claude-hook` (PostToolUse/Bash) | Partial | `src/cli/commands/claude-hook.ts` |
-
-### What Needs to Be Built
-
-| Component | Priority | Description |
-|-----------|----------|-------------|
-| **PreToolUse hook for all tools** | P0 | Extend `claude-hook` to intercept all tools via PreToolUse, run `kernel.propose()`, block unauthorized actions. This is the syscall enforcement layer. |
-| **Capability token schema** | P1 | JSON token format with id, subject, operation, scopes, constraints, expiry. Validated before policy evaluation. |
-| **Capability validator in kernel** | P1 | New validation step in `kernel.propose()` between AAB normalization and policy evaluation. |
-| **External scheduler** | P1 | Standalone process: poll GitHub Issues, mint capabilities, create worktrees, spawn claude CLI, monitor agents, create PRs. |
-| **Role-to-capability mapping** | P2 | Expand role assignment into concrete capability tokens per task. |
-
-### Concrete End-to-End Flow
-
-**Setup (one-time)**:
-```bash
-# Install AgentGuard hook in Claude Code
-npx aguard claude-init
-
-# Configure policies
-cp policies/developer.yaml .agentguard/active-policy.yaml
-```
-
-**Per-task flow**:
-
-1. **Human creates GitHub Issue** with `agentguard-task` + `task:implementation` + `priority:high` labels
-2. **Scheduler polls** and finds the pending issue
-3. **Scheduler mints capabilities** based on issue's file scope section
-4. **Scheduler creates worktree**: `git worktree add ../worktrees/issue-42 -b agent/implementation/issue-42`
-5. **Scheduler writes CLAUDE.md** with role template + task description
-6. **Scheduler writes capability token** to `.agentguard/capabilities/current.json` in the worktree
-7. **Scheduler dispatches task**: via Octi Pulpo HTTP API → ShellForge → Anthropic API, in an isolated worktree
-8. **Agent works** — every tool call triggers PreToolUse hook → AgentGuard kernel
-9. **Kernel evaluates**: capability check → policy check → invariant check → execute or deny
-10. **Agent completes** — commits to worktree branch
-11. **Scheduler creates PR** via `gh pr create`
-12. **Scheduler posts completion comment** on the issue with governance summary
-13. **Human reviews PR** — merges or requests changes
-14. **Scheduler cleans up** worktree
-
----
-
-## 9. Governance Integration
-
-### Hook Architecture
-
-The scheduler configures `.claude/settings.json` in each worktree:
-
-```json
-{
- "hooks": {
- "PreToolUse": [
- {
- "matcher": "*",
- "hooks": [
- {
- "type": "command",
- "command": "npx aguard claude-hook --mode=pre --run-id=run_abc"
- }
- ]
- }
- ],
- "PostToolUse": [
- {
- "matcher": "*",
- "hooks": [
- {
- "type": "command",
- "command": "npx aguard claude-hook --mode=post --run-id=run_abc"
- }
- ]
- }
- ]
- }
-}
-```
-
-### PreToolUse Flow (Syscall Enforcement)
-
-```
-Claude Code proposes tool call
- → PreToolUse hook fires
- → claude-hook reads ClaudeCodeHookPayload from stdin
- → normalizeClaudeCodeAction(payload) → RawAgentAction
- → Load capability token from .agentguard/capabilities/current.json
- → Inject capability + role + taskId into RawAgentAction.metadata
- → kernel.propose(rawAction) → KernelResult
- → If denied: write denial message to stdout (Claude Code shows it, skips tool call)
- → If allowed: exit 0 silently (tool call proceeds)
- → Decision persisted to .agentguard/events/.jsonl
-```
-
-### PostToolUse Flow (Telemetry)
-
-```
-Claude Code completes tool call
- → PostToolUse hook fires
- → Log execution result to JSONL
- → Increment action counter in .agentguard/state/counter.json
- → If action count exceeds max: write "Action limit reached" to stdout
-```
-
-### Environment Variables
-
-| Variable | Example | Purpose |
-|----------|---------|---------|
-| `AGENTGUARD_ROLE` | `developer` | Agent's role |
-| `AGENTGUARD_TASK_ID` | `42` | GitHub Issue number |
-| `AGENTGUARD_RUN_ID` | `run_1709913400_abc` | Kernel run ID |
-| `AGENTGUARD_POLICY` | `policies/developer.yaml` | Policy file |
-| `AGENTGUARD_MAX_ACTIONS` | `200` | Action limit |
-| `AGENTGUARD_CAP_FILE` | `.agentguard/capabilities/current.json` | Capability token path |
-
-### Escalation Integration
-
-The monitor (`src/kernel/monitor.ts`) tracks escalation:
-
-| Level | Value | Behavior |
-|-------|-------|----------|
-| NORMAL | 0 | All clear |
-| ELEVATED | 1 | Elevated denial rate, continue with caution |
-| HIGH | 2 | Significant violations — scheduler pauses |
-| LOCKDOWN | 3 | All actions denied |
-
-When JSONL events show escalation reaching HIGH, the scheduler:
-1. Terminates all active agent processes
-2. Posts comments on all in-progress issues
-3. Updates issue labels to `governance:lockdown`
-4. Stops polling until human intervention
-
----
-
-## 10. Execution Loop
-
-### Minimal Scheduler Pseudocode
-
-```
-INITIALIZE:
- config = loadSchedulerConfig()
- github = createGitHubClient(config.github)
-
-MAIN LOOP:
- while scheduler.running:
-
- // 1. POLL
- issues = github.listIssues({
- labels: ["agentguard-task", "status:pending"],
- sort: "created", direction: "asc"
- })
- .filter(i => allDependenciesMet(i))
- .sort(byPriority)
-
- if issues.length === 0 || activeAgents >= config.maxConcurrent:
- sleep(config.pollIntervalMs)
- continue
-
- issue = issues[0]
-
- // 2. DETERMINE ROLE
- role = mapTaskTypeToRole(extractLabel(issue, "task:"))
- // task:implementation → developer
- // task:test-generation → qa
- // task:architecture → architect
-
- // 3. MINT CAPABILITIES
- filePaths = parseFileScope(issue.body)
- capabilities = mintCapabilityBundle(role, {
- taskId: issue.number,
- scopes: filePaths,
- protectedPaths: SELF_MODIFICATION_DENY_LIST,
- expiresIn: config.taskTimeoutMs,
- })
-
- // 4. CREATE WORKTREE
- branch = `agent/${taskType}/issue-${issue.number}`
- worktreePath = exec(`git worktree add ../worktrees/${branch} -b ${branch}`)
-
- // 5. PREPARE WORKTREE
- writeFile(`${worktreePath}/CLAUDE.md`, renderRoleTemplate(role, issue))
- writeFile(`${worktreePath}/.agentguard/capabilities/current.json`, capabilities)
- writeFile(`${worktreePath}/.claude/settings.json`, renderHookSettings(runId))
- copyFile(`policies/${role}.yaml`, `${worktreePath}/.agentguard/policy.yaml`)
-
- // 6. UPDATE ISSUE
- github.updateLabels(issue.number, { add: ["status:assigned", `role:${role}`] })
- github.postComment(issue.number, renderAssignmentComment({...}))
-
- // 7. SPAWN AGENT
- agentProcess = spawn("claude", ["--print", "-p", renderTaskPrompt(issue)], {
- cwd: worktreePath,
- env: { AGENTGUARD_ROLE: role, AGENTGUARD_TASK_ID: issue.number, ... },
- timeout: config.taskTimeoutMs,
- })
-
- github.updateLabels(issue.number, { add: ["status:in-progress"] })
-
- // 8. ON COMPLETION
- agentProcess.on("exit", async (code) => {
- summary = parseJsonlEvents(`${worktreePath}/.agentguard/events/${runId}.jsonl`)
-
- if code === 0 && summary.escalationLevel < HIGH:
- exec(`git push origin ${branch}`, { cwd: worktreePath })
- pr = github.createPR({
- title: `[${role}] ${issue.title}`,
- body: renderPRBody(issue, summary, capabilities),
- head: branch, base: "main",
- })
- github.updateLabels(issue.number, { add: ["status:review"] })
- github.postComment(issue.number, renderCompletionComment(pr, summary))
- else:
- retries = extractRetryCount(issue)
- if retries < config.maxRetries:
- github.updateLabels(issue.number, {
- add: ["status:pending", `retry:${retries + 1}`],
- remove: ["status:in-progress"]
- })
- else:
- github.updateLabels(issue.number, { add: ["status:failed"] })
- github.postComment(issue.number, renderFailureComment(summary))
-
- exec(`git worktree remove ${worktreePath} --force`)
- })
-```
-
----
-
-## 11. Policy Configuration
-
-Role-scoped YAML policies using AgentGuard's existing `PolicyRule` format.
-
-### Developer Policy (`policies/developer.yaml`)
-
-```yaml
-id: sdlc-developer-policy
-name: Developer Agent Policy
-description: Governs developer agents — allows src/ and tests/ modifications
-severity: 4
-
-rules:
- - action: file.write
- effect: allow
- conditions:
- scope: ["src/**", "tests/**", "package.json"]
- reason: Developer may modify source, tests, and package.json
-
- - action: file.write
- effect: deny
- conditions:
- scope: [".github/**", "Dockerfile", ".env*", "agentguard.yaml"]
- reason: CI, environment, and governance config require human approval
-
- - action: [file.write, file.delete]
- effect: deny
- conditions:
- scope: ["src/kernel/**", "src/policy/**", "src/invariants/**"]
- reason: Self-modification protection — governance code is human-only
-
- - action: [git.push, deploy.trigger, infra.apply, infra.destroy, npm.publish]
- effect: deny
- reason: Production-affecting actions require human authorization
-
- - action: file.read
- effect: allow
- reason: Reading is always safe
-
- - action: [shell.exec, git.commit, git.branch.create, npm.install]
- effect: allow
- reason: Development operations within worktree are safe
-```
-
-### QA Policy (`policies/qa.yaml`)
-
-```yaml
-id: sdlc-qa-policy
-name: QA Agent Policy
-severity: 4
-
-rules:
- - action: file.write
- effect: allow
- conditions:
- scope: ["tests/**", "**/*.test.ts", "**/*.test.js", "**/*.spec.ts"]
- reason: QA writes test files
-
- - action: file.write
- effect: deny
- conditions:
- scope: ["src/**"]
- reason: QA agents do not modify production code
-
- - action: [test.run, test.run.unit, test.run.integration]
- effect: allow
- reason: Test execution is QA's primary function
-
- - action: [git.push, deploy.trigger, npm.publish]
- effect: deny
- reason: QA cannot push or deploy
-
- - action: [file.read, shell.exec, git.commit]
- effect: allow
- reason: Basic development operations
-```
-
-### Auditor Policy (`policies/auditor.yaml`)
-
-```yaml
-id: sdlc-auditor-policy
-name: Auditor Agent Policy
-severity: 5
-
-rules:
- - action: [file.write, file.delete, file.move, git.commit, git.push, npm.install, deploy.trigger]
- effect: deny
- reason: Auditor is strictly read-only
-
- - action: [file.read, test.run, test.run.unit, test.run.integration]
- effect: allow
- reason: Auditor reads code and verifies tests
-```
-
----
-
-## 12. Telemetry & Observability
-
-### What Already Exists
-
-AgentGuard already logs every action as structured events. The `GovernanceDecisionRecord` (`src/kernel/decisions/types.ts`) captures:
-
-- `action.type` — the syscall (e.g., `file.write`)
-- `action.target` — the resource (e.g., `src/kernel/monitor.ts`)
-- `action.agent` — the agent ID
-- `outcome` — `allow` or `deny`
-- `reason` — human-readable explanation
-- `policy.matchedPolicyId` — which policy rule applied
-- `invariants.violations[]` — which correctness checks failed
-- `monitor.escalationLevel` — current escalation state
-- `execution.success` — whether the action succeeded
-
-Events are persisted to `.agentguard/events/.jsonl`, one JSON per line.
-
-### Enhanced Telemetry for Autonomous SDLC
-
-The autonomous loop adds capability context to each event (via `metadata`):
-
-```json
-{
- "id": "evt_1709913600_42",
- "kind": "ActionDenied",
- "timestamp": 1709913600000,
- "fingerprint": "a1b2c3d4",
- "actionType": "file.write",
- "target": "src/kernel/kernel.ts",
- "reason": "Self-modification protection — governance code is human-only",
- "metadata": {
- "agent_id": "agent_dev_1a2b",
- "role": "developer",
- "task_id": 42,
- "capability_id": "cap_0192",
- "capability_scope_match": false,
- "layer": "capability",
- "run_id": "run_1709913400_abc"
- }
-}
-```
-
-### The Dogfooding Dividend
-
-Running this on AgentGuard's own codebase produces empirical data on:
-
-| Signal | What It Tells You |
-|--------|------------------|
-| Most-denied action types | Which operations agents attempt unsafely |
-| Capability scope violations | Where agents exceed their authority |
-| Policy denial patterns | Which governance rules produce the most friction |
-| Invariant violation frequency | Which correctness constraints agents hit |
-| Escalation triggers | What behavior patterns cause systemic denial rates |
-| Self-modification attempts | How often agents try to weaken their own governance |
-| Code quality drift | Whether agent-written code maintains standards |
-
-This telemetry is the raw material for:
-- Policy hardening (every violation → policy improvement)
-- Agent safety research (real failure modes, not theoretical ones)
-- Product evidence (AgentGuard's own development proves its governance model works)
-
----
-
-## 13. Recommended AgentGuard Enhancements
-
-Prioritized changes to AgentGuard's codebase to support the autonomous SDLC:
-
-### Priority 0 — Extended `claude-hook` (Syscall Enforcement Layer)
-
-**File**: `src/cli/commands/claude-hook.ts`
-
-Currently: PostToolUse only, Bash only, reports errors.
-Needed: PreToolUse for all tools, full `kernel.propose()` evaluation, deny messages to stdout.
-
-This is the **critical enabler**. Without PreToolUse enforcement, agents can execute unauthorized actions before governance evaluates them.
-
-**Changes**:
-- Accept `--mode=pre|post` flag
-- Accept `--policy=` and `--run-id=` flags
-- In `pre` mode: load policy, load capability token, run `kernel.propose()`, write deny to stdout if blocked
-- In `post` mode: log execution result, update action counter
-- Process all tool types (not just Bash)
-
-### Priority 1 — Capability Token Validation
-
-**New file**: `src/kernel/capability.ts`
-
-```typescript
-interface CapabilityToken {
- id: string;
- subject: string;
- operation: string;
- scopes: string[];
- constraints?: {
- deny?: string[];
- max_files?: number;
- max_diff_lines?: number;
- requires_artifacts?: string[];
- };
- issued_to: string;
- issued_by: string;
- issued_at: string;
- expires_at: string;
- task_id: string;
-}
-
-function validateCapability(token: CapabilityToken, intent: NormalizedIntent): CapabilityResult;
-```
-
-**Modify**: `src/kernel/kernel.ts` — add capability validation before `monitor.process()` in `propose()`.
-
-### Priority 2 — Role/Task as First-Class Fields
-
-**Modify**: `src/kernel/aab.ts` — add `role?: string` and `taskId?: string` to `RawAgentAction`
-**Modify**: `src/policy/evaluator.ts` — add `role?: string` and `taskId?: string` to `NormalizedIntent`
-
-### Priority 3 — Role-Based Policy Conditions
-
-**Modify**: `src/policy/evaluator.ts` — add `roles?: string[]` and `ownership?: string[]` to `PolicyRule.conditions`
-
-### Priority 4 — New Invariants
-
-**Modify**: `src/invariants/definitions.ts`:
-- `architectural-boundary`: Files must be within role's owned paths
-- `self-modification-guard`: Governance-critical paths cannot be modified by agents
-- `build-must-succeed`: Build passing before commit/push
-
-### Priority 5 — New Event Kinds
-
-**Modify**: `src/core/types.ts` — add: `CapabilityDenied`, `CapabilityExpired`, `TaskAssigned`, `TaskCompleted`, `AgentRegistered`
-
----
-
-## 14. Open Questions & Future Work
-
-### Open Questions
-
-1. **PreToolUse blocking semantics**: Does Claude Code's PreToolUse hook reliably block tool execution when stdout contains a denial message? This needs empirical verification for each tool type.
-
-2. **Capability token signing**: For the minimal viable version, local JSON files are sufficient. For multi-machine deployments, capability tokens need cryptographic signing. What signing scheme? (HMAC is simplest, JWT is most portable.)
-
-3. **Self-modification boundary**: Which files constitute "governance-critical" code? The current list (`src/kernel/**`, `src/policy/**`, `src/invariants/**`) may be too broad or too narrow.
-
-4. **Dependency resolution**: When task A depends on task B's unmerged PR, should task A work against task B's branch? Or wait for merge?
-
-5. **Cost management**: Each agent invocation consumes API tokens. Should the scheduler enforce a per-task or per-day token budget?
-
-### Future Work
-
-- **Capability delegation**: Planner agents issue scoped capabilities to downstream agents (requires trust model for the planner).
-- **Capability revocation**: Real-time revocation when escalation level rises (currently capabilities have fixed expiry).
-- **Parallel pipelines**: Independent tasks in separate worktrees, running concurrently.
-- **Agent memory**: Persist learnings across tasks (common denial reasons, preferred patterns).
-- **Automated review**: Auditor agent reviews PRs before human review.
-- **Conflict detection**: Detect overlapping file modifications across concurrent worktrees.
-- **Policy learning**: Analyze denial telemetry to suggest policy rule adjustments.
-- **Safety benchmarks**: Publish agent failure telemetry as a reproducible safety benchmark.
-
-### The Long-Term Vision
-
-If the reflexive model works — AgentGuard governing its own development — the system demonstrates a concrete answer to the question: "How do you let AI agents do real work while maintaining deterministic control?"
-
-The answer is not "trust the model" or "add guardrails." The answer is:
-
-```
-capability-secured syscall interface
- → deterministic policy evaluation
- → correctness invariant enforcement
- → structured audit trail
-```
-
-That is the architectural primitive. Everything else is scaffolding.
diff --git a/docs/autonomous-sdlc-methodology.md b/docs/autonomous-sdlc-methodology.md
deleted file mode 100644
index 19d9151a..00000000
--- a/docs/autonomous-sdlc-methodology.md
+++ /dev/null
@@ -1,283 +0,0 @@
-# Autonomous SDLC Methodology: How 70K Lines Were Built in Under Two Weeks
-
-## Executive Summary
-
-AgentGuard — a 70,000-line, 20-package governed action runtime — was built in under two weeks by a single engineer orchestrating an autonomous agent swarm. This document describes the methodology, provides evidence of the velocity achieved, and explains why this approach is transferable to any software domain.
-
-**Key metrics:**
-- 33,668 lines of production TypeScript, 39,160 lines of tests
-- 20 workspace packages, 3 applications (CLI, VS Code extension, telemetry server)
-- 142 test files, 26 invariants, 47 event kinds, 41 action types
-- Equivalent to 240 story points / 6-8 months of traditional senior engineering
-- Delivered in <2 weeks by one person with an autonomous agent swarm
-
----
-
-## The Core Insight
-
-Governance is not a constraint on velocity. It is the **enabler** of velocity.
-
-When agents cannot accidentally break production, delete secrets, or corrupt the repository, they can run continuously without human supervision. The entire SDLC — implementation, review, testing, merging, documentation — becomes autonomous.
-
----
-
-## 1. Swarm Architecture: 26 Agents Across 5 Tiers
-
-The swarm is organized into tiers with distinct responsibilities and cadences:
-
-### Core Tier (8 agents, every 2 hours)
-| Agent | Role |
-|-------|------|
-| coder-agent | Implements issues on feature branches |
-| code-review-agent | Reviews open PRs for correctness, style, and safety |
-| pr-merger-agent | Auto-merges approved PRs with passing CI |
-| ci-triage-agent | Triages CI failures (skip-if-green) |
-| merge-conflict-resolver | Resolves merge conflicts (serialized, 1 PR/run) |
-| pr-review-responder | Responds to unresolved review comments |
-| stale-branch-janitor | Daily cleanup of stale branches and PRs |
-| recovery-controller | Self-healing for swarm health |
-
-### Governance Tier (3 agents)
-| Agent | Role |
-|-------|------|
-| governance-monitor | Daily governance audit + policy effectiveness |
-| risk-escalation-agent | Cumulative risk assessment, gates dangerous operations |
-| recovery-controller | Detects unhealthy conditions, executes remediation |
-
-### Operations Tier (8 agents, daily)
-| Agent | Role |
-|-------|------|
-| planning-agent | Sprint planning + strategy ingestion |
-| observability-agent | SRE health analysis |
-| backlog-steward | ROADMAP expansion (capped 3 issues/run) |
-| docs-sync-agent | Documentation staleness detection |
-| product-agent | Product health + roadmap alignment |
-| progress-controller | Tracks roadmap phase transitions |
-| repo-hygiene-agent | Detects stale/solved issues |
-| retrospective-agent | Weekly failure pattern analysis |
-
-### Quality Tier (5 agents)
-| Agent | Role |
-|-------|------|
-| test-agent | Daily test health + coverage analysis |
-| test-generation-agent | Weekly test generation for untested modules |
-| security-audit-agent | Weekly dependency + source code security scan |
-| architect-agent | Reviews open PRs for architectural concerns |
-| cicd-hardening-agent | Weekly CI/CD supply chain audit |
-
-### Marketing Tier (1 agent)
-| Agent | Role |
-|-------|------|
-| marketing-content-agent | Weekly content generation |
-
----
-
-## 2. Skill Composition: 39 Reusable Building Blocks
-
-Each agent composes its workflow from reusable skills. A skill is a markdown template that defines a discrete capability with clear inputs, outputs, and STOP conditions.
-
-**Development Skills:** start-governance-runtime, sync-main, discover-next-issue, claim-issue, implement-issue, run-tests, create-pr
-
-**Governance Skills:** governance-log-audit, policy-effectiveness-review, recovery-controller, risk-escalation
-
-**Quality Skills:** full-test, test-health-review, generate-tests, dependency-security-audit, security-code-scan, architecture-review, cicd-hardening-audit
-
-**Operational Skills:** sprint-planning, observability-review, backlog-steward, scheduled-docs-sync, product-health-review, progress-controller, repo-hygiene, retrospective, resolve-merge-conflicts, respond-to-pr-reviews, stale-branch-janitor, triage-failing-ci
-
-**Artifact Skills:** release-prepare, release-publish, marketing-content
-
-### Example: The Coder Agent Workflow
-
-```
-1. start-governance-runtime → activate PreToolUse hooks
-2. sync-main → pull latest from origin
-3. discover-next-issue → find highest-priority pending issue
-4. claim-issue → label with status:in-progress
-5. implement-issue → code on feature branch
-6. run-tests → pnpm test, fix failures
-7. create-pr → push + open PR with evidence summary
-
-If any skill reports STOP, end the run and report why.
-```
-
-Each agent's prompt includes a critical autonomy directive:
-
-> "This is an unattended scheduled task. No human is present. NEVER pause to ask for clarification. Default to the safest option."
-
-### Claude Desktop Configuration
-
-Scaffolding generates the files, but each agent must also be configured in **Claude Desktop** to run autonomously:
-
-1. **Create scheduled tasks** — Register each agent as a scheduled task in Claude Desktop using the cron schedules from the agent manifest. Point the task at the agent's prompt file (e.g., `.claude/prompts/coder-agent.md`).
-
-2. **Set `worktree: true`** — Enable worktree isolation for every scheduled task. Each agent run gets its own isolated git worktree, preventing parallel agents from conflicting on file writes, git index locks, and branch state. Without this, concurrent agents will corrupt each other's working directory.
-
-3. **Bypass permissions manually** — Since agents run unattended with no human to approve tool-use prompts, you must pre-approve the required permissions (file read/write, shell execution, git operations) for each agent in Claude Desktop. AgentGuard's governance policy and invariant system provide a second layer of defense, but Claude Desktop's permission gates must be resolved before the agent can start.
-
----
-
-## 3. Governance as Execution Boundary
-
-Every agent tool call passes through the AgentGuard kernel before execution:
-
-```
-Agent proposes tool call (Write, Bash, etc.)
- ↓
-PreToolUse hook fires → AgentGuard kernel
- ↓
-AAB normalizes intent (tool → action type, detect destructive patterns)
- ↓
-Three-layer evaluation:
- Layer 1: Capabilities — can this agent attempt this action class?
- Layer 2: Policies — is this allowed under governance rules?
- Layer 3: Invariants — would this violate system correctness?
- ↓
-Decision recorded (JSONL/SQLite audit trail)
- ↓
-ALLOW → tool executes | DENY → tool blocked, agent informed
-```
-
-### 17 Built-in Invariants
-
-1. no-secret-exposure (severity 5) — block .env, .pem, .key, credentials
-2. protected-branch (severity 5) — deny direct push to main/master
-3. blast-radius (severity 4) — file modification count limits
-4. test-before-push (severity 3) — tests must pass before push
-5. no-force-push (severity 5) — block git push --force
-6. lockfile-integrity (severity 3) — lock file consistency
-7. no-skill-modification (severity 5) — block agent skill self-modification
-8. no-scheduled-task-modification (severity 5) — block cron/schedule changes
-9. credential-file-creation (severity 5) — block new .netrc, AWS credentials
-10. package-script-injection (severity 4) — protect lifecycle scripts
-11. recursive-operation-guard (severity 2) — catch find -exec + write/delete
-12. large-file-write (severity 3) — per-file size limits
-13. no-cicd-config-modification (severity 5) — protect .github/workflows
-14. no-permission-escalation (severity 4) — prevent chmod/chown abuse
-15. no-governance-self-modification (severity 5) — protect governance config
-16. no-container-config-modification (severity 3) — protect Dockerfile
-17. no-env-var-modification (severity 3) — prevent shell profile injection
-
-### Escalation State Machine
-
-Repeated violations trigger escalation that constrains agent behavior:
-
-```
-NORMAL → ELEVATED → HIGH → LOCKDOWN
-```
-
-- **NORMAL**: all issues eligible
-- **ELEVATED**: prefer smaller-scope issues
-- **HIGH**: only 5-file-or-fewer issues
-- **LOCKDOWN**: refuse new work entirely
-
----
-
-## 4. Distributed Coordination via Shared State
-
-Agents coordinate without a centralized scheduler through a shared state contract:
-
-```json
-{
- "mode": "normal",
- "prQueueHealthy": true,
- "openAgentPRs": 3,
- "currentPhase": "Phase 5",
- "escalationLevel": "NORMAL",
- "lastSync": "2026-03-15T10:43:47Z",
- "priorities": ["issue-336", "issue-335"]
-}
-```
-
-**Pre-flight checks prevent queue saturation:**
-- If `openAgentPRs >= 5`, the coder agent skips its run
-- If `escalationLevel === "LOCKDOWN"`, no new work is started
-- If `mode === "SAFE"`, only fixes are attempted
-
-This enables parallel execution across 26 agents without coordination overhead.
-
----
-
-## 5. The Reflexive Property: Self-Governing Development
-
-AgentGuard governs the agents that develop AgentGuard. This creates:
-
-1. **Empirical behavior data** — every agent failure, policy violation, and unsafe pattern becomes research data that improves the product
-2. **Live safety lab** — the development process is itself a governance testbed
-3. **Recursive validation** — if AgentGuard governs its own development and the development succeeds, the governance model is validated
-
-This is not a toy demo. The 70K-line codebase, passing test suite, and functioning CI/CD pipeline are proof that the governance model works under real conditions.
-
----
-
-## 6. Velocity Evidence
-
-### Commit Timeline (3 days of recorded history)
-
-| Date | Commits | Highlights |
-|------|---------|------------|
-| Mar 13 | 10 | Permission escalation invariant, SQLite migrations, SQL aggregation, policy suggestions, governance self-modification invariant |
-| Mar 14 | 25 | Webhook storage, monorepo restructure, telemetry server, swarm package, privacy-first telemetry, performance benchmarks, plan-level simulation |
-| Mar 15 | 16 | Session viewer, tamper-resistant audit trail, OpenClaw adapter, dependency graph simulator, auto-build hooks, agent persona capture |
-
-### Parallel Execution Evidence
-
-Bursts of 3 commits within 2 minutes are visible throughout the log — a signature of multiple agents completing work simultaneously on independent branches:
-
-```
-2026-03-14 20:30:25 | feat(issue-395): add performance benchmark suite
-2026-03-14 20:30:58 | fix(issue-401): fix Windows path separators
-2026-03-14 20:31:21 | feat(issue-416): add transitive effect analysis invariant
-```
-
-PR numbers reach #449, indicating hundreds of PRs were opened, reviewed, and merged autonomously.
-
-### Engineering Equivalent
-
-| Metric | Value |
-|--------|-------|
-| Story points (estimated) | ~240 SP |
-| Traditional solo engineer time | 6-8 months |
-| Traditional 2-person team time | 3-4 months |
-| Actual time with agent swarm | <2 weeks |
-| Velocity multiplier | 10-15x |
-| Dollar equivalent (agency rates) | $190-250K |
-
----
-
-## 7. Why This Is Transferable
-
-This methodology is not specific to AgentGuard. The pattern generalizes:
-
-1. **Define a governance kernel** — deterministic policy evaluation for agent actions
-2. **Create reusable skills** — template library of domain-specific capabilities
-3. **Personalize agents** — distinct prompts with role-specific autonomy directives
-4. **Hook into execution** — intercept tool calls before execution
-5. **Audit everything** — canonical event model captures all decisions
-6. **Coordinate via state** — shared JSON enables distributed orchestration
-7. **Self-govern development** — agents developing the system are governed by the system
-
-Any software project can adopt this pattern. The governance kernel prevents the failure modes that make autonomous agents dangerous (secret exposure, destructive commands, unreviewed merges), while the skill composition system enables rapid domain-specific customization.
-
----
-
-## Academic Foundations
-
-The architecture draws from three established computer science fields:
-
-- **Reference Monitors** (Anderson, 1972) — every action checked against policy
-- **Capability-Based Security** (Dennis & Van Horn, 1966) — bounded, explicit authority
-- **Event Sourcing** (Domain-Driven Design) — all state changes as immutable events
-
----
-
-## Conclusion
-
-The autonomous SDLC methodology demonstrated here achieves 10-15x velocity over traditional engineering by:
-
-1. Running 26 specialized agents in parallel on 2-hour cycles
-2. Enforcing governance boundaries that make unsupervised execution safe
-3. Composing workflows from 39 reusable skills
-4. Coordinating through shared state rather than human standup meetings
-5. Auditing every decision for accountability and learning
-
-The result is not just a product — it is proof that governed autonomous agents can reliably produce production-grade software at a pace that was previously impossible.
diff --git a/docs/roadmap-overview.md b/docs/roadmap-overview.md
index d7e11be3..104be022 100644
--- a/docs/roadmap-overview.md
+++ b/docs/roadmap-overview.md
@@ -39,7 +39,7 @@ AgentGuard is the **mandatory execution control plane for AI agents** — the ru
| MCP governance server (15 tools) | Implemented | Production |
| Plugin ecosystem (discovery, registry, sandboxing) | Implemented | Production |
| 8 policy packs (essentials, strict, ci-safe, enterprise, open-source, soc2, hipaa, eng-standards) | Implemented | Production |
-| 26-agent autonomous swarm templates | Implemented | Production |
+| Multi-agent governance templates | Implemented | Production |
| KE-1 Structured matchers (Aho-Corasick, globs, reason codes) | **Shipped v2.3.0** | `packages/matchers/` |
| All 47 event kinds mapped to cloud AgentEvent | **Shipped v2.3.0** | `packages/telemetry/src/event-mapper.ts` |
| Agent SDK for programmatic governance | **Shipped v2.3.0** | Programmatic governance integration |
diff --git a/docs/superpowers/plans/2026-03-25-squad-swarm-implementation.md b/docs/superpowers/plans/2026-03-25-squad-swarm-implementation.md
deleted file mode 100644
index 9aec2319..00000000
--- a/docs/superpowers/plans/2026-03-25-squad-swarm-implementation.md
+++ /dev/null
@@ -1,1125 +0,0 @@
-# Squad Swarm Structure Implementation Plan
-
-> **For agentic workers:** REQUIRED SUB-SKILL: Use superpowers:subagent-driven-development (recommended) or superpowers:executing-plans to implement this plan task-by-task. Steps use checkbox (`- [ ]`) syntax for tracking.
-
-**Goal:** Restructure the flat 26-agent swarm into 3 product squads (Kernel, Cloud, QA) with EM→Director→Human reporting, Copilot CLI as workhorse, 5-layer loop guards, and squad identity flowing through telemetry to the dashboard.
-
-**Architecture:** Extend `@red-codes/swarm` types with squad hierarchy (`SquadManifest`, `Squad`, `SquadAgent`). Each squad writes its own state file. Loop guards are checked by every agent at run start. Identity format `driver:model:squad:rank` is parsed from existing `agent_id` fields — no schema migration needed.
-
-**Tech Stack:** TypeScript (swarm package), YAML (squad manifest), JSON (squad state), existing `@red-codes/swarm` + `@red-codes/core` packages
-
-**Spec:** `docs/superpowers/specs/2026-03-25-squad-swarm-structure-design.md`
-
----
-
-### Task 1: Extend swarm types with squad hierarchy
-
-**Files:**
-- Modify: `packages/swarm/src/types.ts`
-- Create: `packages/swarm/tests/types.test.ts`
-
-- [ ] **Step 1: Write the failing test**
-
-```typescript
-// packages/swarm/tests/types.test.ts
-import { describe, it, expect } from 'vitest';
-import type {
- SquadManifest,
- Squad,
- SquadAgent,
- SquadRank,
- SquadState,
- LoopGuardConfig,
-} from '../src/types.js';
-
-describe('Squad types', () => {
- it('SquadAgent has driver, model, squad, rank fields', () => {
- const agent: SquadAgent = {
- id: 'kernel-senior',
- rank: 'senior',
- driver: 'copilot-cli',
- model: 'sonnet',
- cron: '0 */2 * * *',
- skills: ['claim-issue', 'implement-issue', 'create-pr'],
- };
- expect(agent.driver).toBe('copilot-cli');
- expect(agent.rank).toBe('senior');
- });
-
- it('Squad contains em + 5 agents', () => {
- const squad: Squad = {
- name: 'kernel',
- repo: 'agent-guard',
- em: {
- id: 'kernel-em',
- rank: 'em',
- driver: 'claude-code',
- model: 'opus',
- cron: '0 */3 * * *',
- skills: ['squad-plan', 'squad-execute'],
- },
- agents: {
- 'product-lead': { id: 'kernel-pl', rank: 'product-lead', driver: 'claude-code', model: 'sonnet', cron: '0 6 * * *', skills: [] },
- architect: { id: 'kernel-arch', rank: 'architect', driver: 'claude-code', model: 'opus', cron: '0 */4 * * *', skills: [] },
- senior: { id: 'kernel-sr', rank: 'senior', driver: 'copilot-cli', model: 'sonnet', cron: '0 */2 * * *', skills: [] },
- junior: { id: 'kernel-jr', rank: 'junior', driver: 'copilot-cli', model: 'copilot', cron: '0 */2 * * *', skills: [] },
- qa: { id: 'kernel-qa', rank: 'qa', driver: 'copilot-cli', model: 'sonnet', cron: '0 */3 * * *', skills: [] },
- },
- };
- expect(Object.keys(squad.agents)).toHaveLength(5);
- expect(squad.em.rank).toBe('em');
- });
-
- it('SquadManifest has director + squads', () => {
- const manifest: SquadManifest = {
- version: '1.0.0',
- org: {
- director: { id: 'director', rank: 'director', driver: 'claude-code', model: 'opus', cron: '0 7,19 * * *', skills: [] },
- },
- squads: {},
- loopGuards: {
- maxOpenPRsPerSquad: 3,
- maxRetries: 3,
- maxBlastRadius: 20,
- maxRunMinutes: 10,
- },
- };
- expect(manifest.org.director.rank).toBe('director');
- });
-
- it('SquadRank includes all valid ranks', () => {
- const ranks: SquadRank[] = ['director', 'em', 'product-lead', 'architect', 'senior', 'junior', 'qa'];
- expect(ranks).toHaveLength(7);
- });
-});
-```
-
-- [ ] **Step 2: Run test to verify it fails**
-
-Run: `pnpm vitest run packages/swarm/tests/types.test.ts`
-Expected: FAIL — types not exported
-
-- [ ] **Step 3: Add squad types to types.ts**
-
-Add to `packages/swarm/src/types.ts`:
-
-```typescript
-// --- Squad hierarchy types ---
-
-export type SquadRank = 'director' | 'em' | 'product-lead' | 'architect' | 'senior' | 'junior' | 'qa';
-export type AgentDriver = 'claude-code' | 'copilot-cli';
-export type AgentModel = 'opus' | 'sonnet' | 'haiku' | 'copilot';
-
-export interface SquadAgent {
- readonly id: string;
- readonly rank: SquadRank;
- readonly driver: AgentDriver;
- readonly model: AgentModel;
- readonly cron: string;
- readonly skills: readonly string[];
-}
-
-export interface Squad {
- readonly name: string;
- readonly repo: string; // repo name or '*' for cross-repo
- readonly em: SquadAgent;
- readonly agents: Readonly>;
-}
-
-export interface SquadManifest {
- readonly version: string;
- readonly org: {
- readonly director: SquadAgent;
- };
- readonly squads: Readonly>;
- readonly loopGuards: LoopGuardConfig;
-}
-
-export interface LoopGuardConfig {
- readonly maxOpenPRsPerSquad: number;
- readonly maxRetries: number;
- readonly maxBlastRadius: number;
- readonly maxRunMinutes: number;
-}
-
-export interface SquadState {
- readonly squad: string;
- readonly sprint: {
- readonly goal: string;
- readonly issues: readonly string[];
- };
- readonly assignments: Readonly>;
- readonly blockers: readonly string[];
- readonly prQueue: {
- readonly open: number;
- readonly reviewed: number;
- readonly mergeable: number;
- };
- readonly updatedAt: string;
-}
-
-export interface EMReport {
- readonly squad: string;
- readonly timestamp: string;
- readonly health: 'green' | 'yellow' | 'red';
- readonly summary: string;
- readonly blockers: readonly string[];
- readonly escalations: readonly string[];
- readonly metrics: {
- readonly prsOpened: number;
- readonly prsMerged: number;
- readonly issuesClosed: number;
- readonly denials: number;
- readonly retries: number;
- };
-}
-
-export interface DirectorBrief {
- readonly timestamp: string;
- readonly squads: Readonly>;
- readonly escalationsForHuman: readonly string[];
- readonly overallHealth: 'green' | 'yellow' | 'red';
-}
-```
-
-Export from `packages/swarm/src/index.ts`.
-
-- [ ] **Step 4: Run tests**
-
-Run: `pnpm vitest run packages/swarm/tests/types.test.ts`
-Expected: PASS
-
-- [ ] **Step 5: Commit**
-
-```bash
-git add packages/swarm/src/types.ts packages/swarm/src/index.ts packages/swarm/tests/types.test.ts
-git commit -m "feat(swarm): add squad hierarchy types — SquadManifest, Squad, SquadAgent, LoopGuardConfig"
-```
-
----
-
-### Task 2: Squad manifest YAML loader
-
-**Files:**
-- Create: `packages/swarm/src/squad-manifest.ts`
-- Create: `packages/swarm/tests/squad-manifest.test.ts`
-- Create: `packages/swarm/templates/config/squad-manifest.default.yaml`
-
-- [ ] **Step 1: Create the default manifest YAML**
-
-```yaml
-# packages/swarm/templates/config/squad-manifest.default.yaml
-version: "1.0.0"
-
-org:
- director:
- id: director
- rank: director
- driver: claude-code
- model: opus
- cron: "0 7,19 * * *"
- skills: [squad-status, director-brief, escalation-router]
-
-squads:
- kernel:
- repo: agent-guard
- em:
- id: kernel-em
- rank: em
- driver: claude-code
- model: opus
- cron: "0 */3 * * *"
- skills: [squad-plan, squad-execute, squad-status, squad-retro, escalation-router]
- agents:
- product-lead:
- id: kernel-pl
- rank: product-lead
- driver: claude-code
- model: sonnet
- cron: "0 6 * * *"
- skills: [sprint-planning, roadmap-expand, backlog-steward, learn]
- architect:
- id: kernel-arch
- rank: architect
- driver: claude-code
- model: opus
- cron: "0 */4 * * *"
- skills: [architecture-review, review-open-prs, eval, evolve]
- senior:
- id: kernel-sr
- rank: senior
- driver: copilot-cli
- model: sonnet
- cron: "0 */2 * * *"
- skills: [claim-issue, implement-issue, create-pr, run-tests]
- junior:
- id: kernel-jr
- rank: junior
- driver: copilot-cli
- model: copilot
- cron: "0 */2 * * *"
- skills: [claim-issue, implement-issue, run-tests, generate-tests]
- qa:
- id: kernel-qa
- rank: qa
- driver: copilot-cli
- model: sonnet
- cron: "0 */3 * * *"
- skills: [e2e-testing, compliance-test, test-health-review, learn, prune]
-
- cloud:
- repo: agentguard-cloud
- em:
- id: cloud-em
- rank: em
- driver: claude-code
- model: opus
- cron: "0 */3 * * *"
- skills: [squad-plan, squad-execute, squad-status, squad-retro, escalation-router]
- agents:
- product-lead:
- id: cloud-pl
- rank: product-lead
- driver: claude-code
- model: sonnet
- cron: "0 6 * * *"
- skills: [sprint-planning, roadmap-expand, backlog-steward, learn]
- architect:
- id: cloud-arch
- rank: architect
- driver: claude-code
- model: opus
- cron: "0 */4 * * *"
- skills: [architecture-review, review-open-prs, eval, evolve]
- senior:
- id: cloud-sr
- rank: senior
- driver: copilot-cli
- model: sonnet
- cron: "0 */2 * * *"
- skills: [claim-issue, implement-issue, create-pr, run-tests]
- junior:
- id: cloud-jr
- rank: junior
- driver: copilot-cli
- model: copilot
- cron: "0 */2 * * *"
- skills: [claim-issue, implement-issue, run-tests, generate-tests]
- qa:
- id: cloud-qa
- rank: qa
- driver: copilot-cli
- model: sonnet
- cron: "0 */3 * * *"
- skills: [e2e-testing, compliance-test, test-health-review, learn, prune]
-
- qa:
- repo: "*"
- em:
- id: qa-em
- rank: em
- driver: claude-code
- model: sonnet
- cron: "0 */3 * * *"
- skills: [squad-plan, squad-execute, squad-status, squad-retro, escalation-router]
- agents:
- product-lead:
- id: qa-pl
- rank: product-lead
- driver: claude-code
- model: sonnet
- cron: "0 6 * * *"
- skills: [sprint-planning, test-strategy, stranger-test-plan, learn]
- architect:
- id: qa-arch
- rank: architect
- driver: claude-code
- model: sonnet
- cron: "0 */4 * * *"
- skills: [test-architecture, compliance-review, eval, evolve]
- senior:
- id: qa-sr
- rank: senior
- driver: copilot-cli
- model: sonnet
- cron: "0 */2 * * *"
- skills: [playwright-e2e, stranger-test-run, compliance-test, create-pr]
- junior:
- id: qa-jr
- rank: junior
- driver: copilot-cli
- model: copilot
- cron: "0 */2 * * *"
- skills: [generate-tests, run-tests, test-data-generation]
- qa:
- id: qa-qa
- rank: qa
- driver: copilot-cli
- model: haiku
- cron: "0 */1 * * *"
- skills: [e2e-testing, regression-analysis, flakiness-detection, learn, prune]
-
-loopGuards:
- maxOpenPRsPerSquad: 3
- maxRetries: 3
- maxBlastRadius: 20
- maxRunMinutes: 10
-```
-
-- [ ] **Step 2: Write the failing test**
-
-```typescript
-// packages/swarm/tests/squad-manifest.test.ts
-import { describe, it, expect } from 'vitest';
-import { loadSquadManifest } from '../src/squad-manifest.js';
-import { readFileSync } from 'fs';
-import { join } from 'path';
-
-describe('loadSquadManifest', () => {
- it('loads the default manifest', () => {
- const yaml = readFileSync(
- join(__dirname, '..', 'templates', 'config', 'squad-manifest.default.yaml'),
- 'utf8',
- );
- const manifest = loadSquadManifest(yaml);
- expect(manifest.version).toBe('1.0.0');
- expect(manifest.org.director.rank).toBe('director');
- expect(manifest.org.director.driver).toBe('claude-code');
- });
-
- it('parses all 3 squads', () => {
- const yaml = readFileSync(
- join(__dirname, '..', 'templates', 'config', 'squad-manifest.default.yaml'),
- 'utf8',
- );
- const manifest = loadSquadManifest(yaml);
- expect(Object.keys(manifest.squads)).toEqual(['kernel', 'cloud', 'qa']);
- });
-
- it('each squad has em + 5 agents', () => {
- const yaml = readFileSync(
- join(__dirname, '..', 'templates', 'config', 'squad-manifest.default.yaml'),
- 'utf8',
- );
- const manifest = loadSquadManifest(yaml);
- for (const [name, squad] of Object.entries(manifest.squads)) {
- expect(squad.em.rank).toBe('em');
- expect(Object.keys(squad.agents)).toHaveLength(5);
- }
- });
-
- it('builds agent identity strings', () => {
- const yaml = readFileSync(
- join(__dirname, '..', 'templates', 'config', 'squad-manifest.default.yaml'),
- 'utf8',
- );
- const manifest = loadSquadManifest(yaml);
- const sr = manifest.squads.kernel.agents.senior;
- const identity = `${sr.driver}:${sr.model}:kernel:${sr.rank}`;
- expect(identity).toBe('copilot-cli:sonnet:kernel:senior');
- });
-
- it('parses loop guard config', () => {
- const yaml = readFileSync(
- join(__dirname, '..', 'templates', 'config', 'squad-manifest.default.yaml'),
- 'utf8',
- );
- const manifest = loadSquadManifest(yaml);
- expect(manifest.loopGuards.maxOpenPRsPerSquad).toBe(3);
- expect(manifest.loopGuards.maxRetries).toBe(3);
- expect(manifest.loopGuards.maxBlastRadius).toBe(20);
- expect(manifest.loopGuards.maxRunMinutes).toBe(10);
- });
-});
-```
-
-- [ ] **Step 3: Run test to verify it fails**
-
-Run: `pnpm vitest run packages/swarm/tests/squad-manifest.test.ts`
-Expected: FAIL — `loadSquadManifest` not found
-
-- [ ] **Step 4: Implement squad manifest loader**
-
-```typescript
-// packages/swarm/src/squad-manifest.ts
-import { parse } from 'yaml';
-import type { SquadManifest, Squad, SquadAgent, LoopGuardConfig } from './types.js';
-
-export function loadSquadManifest(yamlContent: string): SquadManifest {
- const raw = parse(yamlContent) as Record;
-
- const org = raw.org as Record;
- const director = parseAgent(org.director as Record);
-
- const rawSquads = raw.squads as Record>;
- const squads: Record = {};
-
- for (const [name, rawSquad] of Object.entries(rawSquads)) {
- const em = parseAgent(rawSquad.em as Record);
- const rawAgents = rawSquad.agents as Record>;
- const agents: Record = {};
- for (const [role, rawAgent] of Object.entries(rawAgents)) {
- agents[role] = parseAgent(rawAgent);
- }
- squads[name] = {
- name,
- repo: rawSquad.repo as string,
- em,
- agents,
- };
- }
-
- const rawGuards = raw.loopGuards as Record;
- const loopGuards: LoopGuardConfig = {
- maxOpenPRsPerSquad: rawGuards.maxOpenPRsPerSquad ?? 3,
- maxRetries: rawGuards.maxRetries ?? 3,
- maxBlastRadius: rawGuards.maxBlastRadius ?? 20,
- maxRunMinutes: rawGuards.maxRunMinutes ?? 10,
- };
-
- return {
- version: raw.version as string,
- org: { director },
- squads,
- loopGuards,
- };
-}
-
-function parseAgent(raw: Record): SquadAgent {
- return {
- id: raw.id as string,
- rank: raw.rank as SquadAgent['rank'],
- driver: raw.driver as SquadAgent['driver'],
- model: raw.model as SquadAgent['model'],
- cron: raw.cron as string,
- skills: (raw.skills as string[]) ?? [],
- };
-}
-
-/** Build the 4-part identity string: driver:model:squad:rank */
-export function buildAgentIdentity(agent: SquadAgent, squadName: string): string {
- return `${agent.driver}:${agent.model}:${squadName}:${agent.rank}`;
-}
-
-/** Parse a 4-part identity string back into components */
-export function parseAgentIdentity(identity: string): {
- driver: string;
- model: string;
- squad: string;
- rank: string;
-} | null {
- const parts = identity.split(':');
- if (parts.length < 4) return null;
- return {
- driver: parts[0],
- model: parts[1],
- squad: parts[2],
- rank: parts[3],
- };
-}
-```
-
-Add `yaml` dependency: `pnpm add yaml --filter=@red-codes/swarm`
-
-Export from `packages/swarm/src/index.ts`.
-
-- [ ] **Step 5: Run tests**
-
-Run: `pnpm vitest run packages/swarm/tests/squad-manifest.test.ts`
-Expected: PASS
-
-- [ ] **Step 6: Commit**
-
-```bash
-git add packages/swarm/
-git commit -m "feat(swarm): squad manifest YAML loader with identity builder/parser"
-```
-
----
-
-### Task 3: Squad state reader/writer
-
-**Files:**
-- Create: `packages/swarm/src/squad-state.ts`
-- Create: `packages/swarm/tests/squad-state.test.ts`
-
-- [ ] **Step 1: Write the failing test**
-
-```typescript
-// packages/swarm/tests/squad-state.test.ts
-import { describe, it, expect, beforeEach, afterEach } from 'vitest';
-import { readSquadState, writeSquadState, readEMReport, writeEMReport, readDirectorBrief, writeDirectorBrief } from '../src/squad-state.js';
-import { mkdtempSync, rmSync, mkdirSync } from 'fs';
-import { join } from 'path';
-import { tmpdir } from 'os';
-
-describe('squad state', () => {
- let dir: string;
-
- beforeEach(() => {
- dir = mkdtempSync(join(tmpdir(), 'squad-'));
- mkdirSync(join(dir, '.agentguard', 'squads', 'kernel'), { recursive: true });
- });
-
- afterEach(() => {
- rmSync(dir, { recursive: true, force: true });
- });
-
- it('writes and reads squad state', () => {
- const state = {
- squad: 'kernel',
- sprint: { goal: 'Go kernel Phase 2', issues: ['#860'] },
- assignments: {
- senior: { current: '#860', status: 'implementing' },
- },
- blockers: [],
- prQueue: { open: 1, reviewed: 0, mergeable: 0 },
- updatedAt: new Date().toISOString(),
- };
- writeSquadState(dir, 'kernel', state);
- const read = readSquadState(dir, 'kernel');
- expect(read?.squad).toBe('kernel');
- expect(read?.sprint.goal).toBe('Go kernel Phase 2');
- });
-
- it('returns null for missing state', () => {
- const read = readSquadState(dir, 'nonexistent');
- expect(read).toBeNull();
- });
-
- it('writes and reads EM report', () => {
- const report = {
- squad: 'kernel',
- timestamp: new Date().toISOString(),
- health: 'green' as const,
- summary: 'All clear',
- blockers: [],
- escalations: [],
- metrics: { prsOpened: 2, prsMerged: 1, issuesClosed: 3, denials: 0, retries: 0 },
- };
- writeEMReport(dir, 'kernel', report);
- const read = readEMReport(dir, 'kernel');
- expect(read?.health).toBe('green');
- });
-
- it('writes and reads director brief', () => {
- const brief = {
- timestamp: new Date().toISOString(),
- squads: {},
- escalationsForHuman: ['Need decision on Go vs Rust for hot path'],
- overallHealth: 'yellow' as const,
- };
- writeDirectorBrief(dir, brief);
- const read = readDirectorBrief(dir);
- expect(read?.overallHealth).toBe('yellow');
- expect(read?.escalationsForHuman).toHaveLength(1);
- });
-});
-```
-
-- [ ] **Step 2: Run test to verify it fails**
-
-Run: `pnpm vitest run packages/swarm/tests/squad-state.test.ts`
-Expected: FAIL — functions not found
-
-- [ ] **Step 3: Implement state reader/writer**
-
-```typescript
-// packages/swarm/src/squad-state.ts
-import { readFileSync, writeFileSync, existsSync, mkdirSync } from 'node:fs';
-import { join } from 'node:path';
-import type { SquadState, EMReport, DirectorBrief } from './types.js';
-
-function squadDir(root: string, squad: string): string {
- return join(root, '.agentguard', 'squads', squad);
-}
-
-function ensureDir(dir: string): void {
- if (!existsSync(dir)) mkdirSync(dir, { recursive: true });
-}
-
-export function readSquadState(root: string, squad: string): SquadState | null {
- const path = join(squadDir(root, squad), 'state.json');
- if (!existsSync(path)) return null;
- try {
- return JSON.parse(readFileSync(path, 'utf8')) as SquadState;
- } catch {
- return null;
- }
-}
-
-export function writeSquadState(root: string, squad: string, state: SquadState): void {
- const dir = squadDir(root, squad);
- ensureDir(dir);
- writeFileSync(join(dir, 'state.json'), JSON.stringify(state, null, 2), 'utf8');
-}
-
-export function readEMReport(root: string, squad: string): EMReport | null {
- const path = join(squadDir(root, squad), 'em-report.json');
- if (!existsSync(path)) return null;
- try {
- return JSON.parse(readFileSync(path, 'utf8')) as EMReport;
- } catch {
- return null;
- }
-}
-
-export function writeEMReport(root: string, squad: string, report: EMReport): void {
- const dir = squadDir(root, squad);
- ensureDir(dir);
- writeFileSync(join(dir, 'em-report.json'), JSON.stringify(report, null, 2), 'utf8');
-}
-
-export function readDirectorBrief(root: string): DirectorBrief | null {
- const path = join(root, '.agentguard', 'director-brief.json');
- if (!existsSync(path)) return null;
- try {
- return JSON.parse(readFileSync(path, 'utf8')) as DirectorBrief;
- } catch {
- return null;
- }
-}
-
-export function writeDirectorBrief(root: string, brief: DirectorBrief): void {
- const dir = join(root, '.agentguard');
- ensureDir(dir);
- writeFileSync(join(dir, 'director-brief.json'), JSON.stringify(brief, null, 2), 'utf8');
-}
-```
-
-Export from `packages/swarm/src/index.ts`.
-
-- [ ] **Step 4: Run tests**
-
-Run: `pnpm vitest run packages/swarm/tests/squad-state.test.ts`
-Expected: PASS
-
-- [ ] **Step 5: Commit**
-
-```bash
-git add packages/swarm/
-git commit -m "feat(swarm): squad state reader/writer for state, EM reports, director briefs"
-```
-
----
-
-### Task 4: Loop guards
-
-**Files:**
-- Create: `packages/swarm/src/loop-guards.ts`
-- Create: `packages/swarm/tests/loop-guards.test.ts`
-
-- [ ] **Step 1: Write the failing test**
-
-```typescript
-// packages/swarm/tests/loop-guards.test.ts
-import { describe, it, expect } from 'vitest';
-import { checkLoopGuards } from '../src/loop-guards.js';
-import type { LoopGuardConfig, SquadState } from '../src/types.js';
-
-const defaultGuards: LoopGuardConfig = {
- maxOpenPRsPerSquad: 3,
- maxRetries: 3,
- maxBlastRadius: 20,
- maxRunMinutes: 10,
-};
-
-describe('loop guards', () => {
- it('passes when all guards clear', () => {
- const state: SquadState = {
- squad: 'kernel',
- sprint: { goal: 'test', issues: [] },
- assignments: {},
- blockers: [],
- prQueue: { open: 1, reviewed: 0, mergeable: 0 },
- updatedAt: new Date().toISOString(),
- };
- const result = checkLoopGuards(defaultGuards, state, {
- retryCount: 0,
- predictedFileChanges: 5,
- runStartTime: Date.now(),
- });
- expect(result.allowed).toBe(true);
- expect(result.violations).toHaveLength(0);
- });
-
- it('fails budget guard when too many PRs open', () => {
- const state: SquadState = {
- squad: 'kernel',
- sprint: { goal: 'test', issues: [] },
- assignments: {},
- blockers: [],
- prQueue: { open: 4, reviewed: 0, mergeable: 0 },
- updatedAt: new Date().toISOString(),
- };
- const result = checkLoopGuards(defaultGuards, state, {
- retryCount: 0,
- predictedFileChanges: 5,
- runStartTime: Date.now(),
- });
- expect(result.allowed).toBe(false);
- expect(result.violations).toContain('budget');
- });
-
- it('fails retry guard after 3 retries', () => {
- const state: SquadState = {
- squad: 'kernel',
- sprint: { goal: 'test', issues: [] },
- assignments: {},
- blockers: [],
- prQueue: { open: 0, reviewed: 0, mergeable: 0 },
- updatedAt: new Date().toISOString(),
- };
- const result = checkLoopGuards(defaultGuards, state, {
- retryCount: 4,
- predictedFileChanges: 5,
- runStartTime: Date.now(),
- });
- expect(result.allowed).toBe(false);
- expect(result.violations).toContain('retry');
- });
-
- it('fails blast radius guard when too many files', () => {
- const state: SquadState = {
- squad: 'kernel',
- sprint: { goal: 'test', issues: [] },
- assignments: {},
- blockers: [],
- prQueue: { open: 0, reviewed: 0, mergeable: 0 },
- updatedAt: new Date().toISOString(),
- };
- const result = checkLoopGuards(defaultGuards, state, {
- retryCount: 0,
- predictedFileChanges: 25,
- runStartTime: Date.now(),
- });
- expect(result.allowed).toBe(false);
- expect(result.violations).toContain('blast-radius');
- });
-
- it('fails time guard when run exceeds limit', () => {
- const state: SquadState = {
- squad: 'kernel',
- sprint: { goal: 'test', issues: [] },
- assignments: {},
- blockers: [],
- prQueue: { open: 0, reviewed: 0, mergeable: 0 },
- updatedAt: new Date().toISOString(),
- };
- const result = checkLoopGuards(defaultGuards, state, {
- retryCount: 0,
- predictedFileChanges: 5,
- runStartTime: Date.now() - 11 * 60 * 1000, // 11 min ago
- });
- expect(result.allowed).toBe(false);
- expect(result.violations).toContain('time');
- });
-
- it('reports multiple violations', () => {
- const state: SquadState = {
- squad: 'kernel',
- sprint: { goal: 'test', issues: [] },
- assignments: {},
- blockers: [],
- prQueue: { open: 5, reviewed: 0, mergeable: 0 },
- updatedAt: new Date().toISOString(),
- };
- const result = checkLoopGuards(defaultGuards, state, {
- retryCount: 4,
- predictedFileChanges: 25,
- runStartTime: Date.now() - 15 * 60 * 1000,
- });
- expect(result.allowed).toBe(false);
- expect(result.violations.length).toBeGreaterThanOrEqual(3);
- });
-});
-```
-
-- [ ] **Step 2: Run test to verify it fails**
-
-Run: `pnpm vitest run packages/swarm/tests/loop-guards.test.ts`
-Expected: FAIL — `checkLoopGuards` not found
-
-- [ ] **Step 3: Implement loop guards**
-
-```typescript
-// packages/swarm/src/loop-guards.ts
-import type { LoopGuardConfig, SquadState } from './types.js';
-
-export interface LoopGuardContext {
- retryCount: number;
- predictedFileChanges: number;
- runStartTime: number;
-}
-
-export type GuardViolation = 'budget' | 'retry' | 'blast-radius' | 'cascade' | 'time';
-
-export interface LoopGuardResult {
- allowed: boolean;
- violations: GuardViolation[];
- messages: string[];
-}
-
-export function checkLoopGuards(
- config: LoopGuardConfig,
- state: SquadState,
- context: LoopGuardContext,
-): LoopGuardResult {
- const violations: GuardViolation[] = [];
- const messages: string[] = [];
-
- // 1. Budget guard
- if (state.prQueue.open >= config.maxOpenPRsPerSquad) {
- violations.push('budget');
- messages.push(
- `PR budget exceeded: ${state.prQueue.open} open (max ${config.maxOpenPRsPerSquad}). Skip implementation, focus on review/merge.`,
- );
- }
-
- // 2. Retry guard
- if (context.retryCount > config.maxRetries) {
- violations.push('retry');
- messages.push(
- `Retry limit exceeded: ${context.retryCount} attempts (max ${config.maxRetries}). Create escalation issue.`,
- );
- }
-
- // 3. Blast radius guard
- if (context.predictedFileChanges > config.maxBlastRadius) {
- violations.push('blast-radius');
- messages.push(
- `Blast radius exceeded: ${context.predictedFileChanges} files (max ${config.maxBlastRadius}). Escalate to Architect.`,
- );
- }
-
- // 4. Time guard
- const elapsedMs = Date.now() - context.runStartTime;
- const elapsedMin = elapsedMs / 60_000;
- if (elapsedMin > config.maxRunMinutes) {
- violations.push('time');
- messages.push(
- `Run time exceeded: ${Math.round(elapsedMin)}min (max ${config.maxRunMinutes}min). Force-stop, EM investigates.`,
- );
- }
-
- return {
- allowed: violations.length === 0,
- violations,
- messages,
- };
-}
-```
-
-Export from `packages/swarm/src/index.ts`.
-
-- [ ] **Step 4: Run tests**
-
-Run: `pnpm vitest run packages/swarm/tests/loop-guards.test.ts`
-Expected: PASS
-
-- [ ] **Step 5: Commit**
-
-```bash
-git add packages/swarm/
-git commit -m "feat(swarm): 5-layer loop guards — budget, retry, blast radius, cascade, time"
-```
-
----
-
-### Task 5: Identity format integration + scaffolder update
-
-**Files:**
-- Modify: `packages/swarm/src/scaffolder.ts`
-- Create: `packages/swarm/tests/squad-scaffold.test.ts`
-
-- [ ] **Step 1: Write the failing test**
-
-```typescript
-// packages/swarm/tests/squad-scaffold.test.ts
-import { describe, it, expect, beforeEach, afterEach } from 'vitest';
-import { scaffoldSquad } from '../src/scaffolder.js';
-import { loadSquadManifest } from '../src/squad-manifest.js';
-import { readFileSync, mkdtempSync, rmSync, existsSync } from 'fs';
-import { join } from 'path';
-import { tmpdir } from 'os';
-
-describe('scaffoldSquad', () => {
- let dir: string;
-
- beforeEach(() => {
- dir = mkdtempSync(join(tmpdir(), 'scaffold-'));
- });
-
- afterEach(() => {
- rmSync(dir, { recursive: true, force: true });
- });
-
- it('creates .agentguard-identity for each agent', () => {
- const yaml = readFileSync(
- join(__dirname, '..', 'templates', 'config', 'squad-manifest.default.yaml'),
- 'utf8',
- );
- const manifest = loadSquadManifest(yaml);
- scaffoldSquad(dir, 'kernel', manifest.squads.kernel);
-
- // Check that squad state dir exists
- expect(existsSync(join(dir, '.agentguard', 'squads', 'kernel'))).toBe(true);
- });
-
- it('creates initial empty squad state', () => {
- const yaml = readFileSync(
- join(__dirname, '..', 'templates', 'config', 'squad-manifest.default.yaml'),
- 'utf8',
- );
- const manifest = loadSquadManifest(yaml);
- scaffoldSquad(dir, 'kernel', manifest.squads.kernel);
-
- const statePath = join(dir, '.agentguard', 'squads', 'kernel', 'state.json');
- expect(existsSync(statePath)).toBe(true);
- const state = JSON.parse(readFileSync(statePath, 'utf8'));
- expect(state.squad).toBe('kernel');
- });
-});
-```
-
-- [ ] **Step 2: Run test to verify it fails**
-
-Run: `pnpm vitest run packages/swarm/tests/squad-scaffold.test.ts`
-Expected: FAIL — `scaffoldSquad` not found
-
-- [ ] **Step 3: Implement scaffoldSquad**
-
-Add to `packages/swarm/src/scaffolder.ts`:
-
-```typescript
-import { mkdirSync, writeFileSync, existsSync } from 'node:fs';
-import { join } from 'node:path';
-import type { Squad, SquadState } from './types.js';
-
-export function scaffoldSquad(root: string, squadName: string, squad: Squad): void {
- const squadDir = join(root, '.agentguard', 'squads', squadName);
- mkdirSync(squadDir, { recursive: true });
-
- // Write initial squad state
- const initialState: SquadState = {
- squad: squadName,
- sprint: { goal: '', issues: [] },
- assignments: {},
- blockers: [],
- prQueue: { open: 0, reviewed: 0, mergeable: 0 },
- updatedAt: new Date().toISOString(),
- };
-
- const statePath = join(squadDir, 'state.json');
- if (!existsSync(statePath)) {
- writeFileSync(statePath, JSON.stringify(initialState, null, 2), 'utf8');
- }
-
- // Write learnings store
- const learningsPath = join(squadDir, 'learnings.json');
- if (!existsSync(learningsPath)) {
- writeFileSync(learningsPath, '[]', 'utf8');
- }
-}
-```
-
-Export from `packages/swarm/src/index.ts`.
-
-- [ ] **Step 4: Run tests**
-
-Run: `pnpm vitest run packages/swarm/tests/squad-scaffold.test.ts`
-Expected: PASS
-
-- [ ] **Step 5: Commit**
-
-```bash
-git add packages/swarm/
-git commit -m "feat(swarm): scaffoldSquad creates state dirs, initial state, learnings store"
-```
-
----
-
-### Task 6: Build, full test suite, docs update
-
-- [ ] **Step 1: Run full swarm package tests**
-
-```bash
-pnpm test --filter=@red-codes/swarm
-```
-Expected: all PASS
-
-- [ ] **Step 2: Run full monorepo tests**
-
-```bash
-pnpm build && pnpm test
-```
-Expected: all PASS (no regressions from new types/exports)
-
-- [ ] **Step 3: Update swarm README**
-
-Add a "Squad Structure" section to `packages/swarm/README.md` documenting:
-- Squad manifest schema
-- Identity format (`driver:model:squad:rank`)
-- Loop guards
-- State file locations
-- Migration from 26-agent flat pool
-
-- [ ] **Step 4: Commit**
-
-```bash
-git add packages/swarm/
-git commit -m "docs(swarm): update README with squad structure, identity format, loop guards"
-```
-
----
-
-### Task 7: Deploy manifest + scaffold squads across repos
-
-- [ ] **Step 1: Copy default manifest to workspace repos**
-
-```bash
-# agent-guard
-cp packages/swarm/templates/config/squad-manifest.default.yaml .agentguard/squad-manifest.yaml
-
-# agentguard-cloud
-cp packages/swarm/templates/config/squad-manifest.default.yaml ../agentguard-cloud/.agentguard/squad-manifest.yaml
-```
-
-- [ ] **Step 2: Run scaffold for each squad**
-
-Create a script or run manually:
-
-```bash
-# From agent-guard root
-node -e "
-const { loadSquadManifest, scaffoldSquad } = require('./packages/swarm/dist/index.js');
-const { readFileSync } = require('fs');
-const yaml = readFileSync('.agentguard/squad-manifest.yaml', 'utf8');
-const manifest = loadSquadManifest(yaml);
-for (const [name, squad] of Object.entries(manifest.squads)) {
- if (squad.repo === 'agent-guard' || squad.repo === '*') {
- scaffoldSquad('.', name, squad);
- console.log('Scaffolded squad:', name);
- }
-}
-"
-```
-
-- [ ] **Step 3: Verify state files created**
-
-```bash
-ls -la .agentguard/squads/kernel/
-ls -la .agentguard/squads/qa/
-# Expected: state.json, learnings.json in each
-```
-
-- [ ] **Step 4: Commit manifests and state files**
-
-```bash
-git add .agentguard/squad-manifest.yaml .agentguard/squads/
-git commit -m "chore: deploy squad manifest and scaffold kernel + qa squads"
-```
diff --git a/docs/superpowers/specs/2026-03-21-agent-identity-and-worktree-enforcement-design.md b/docs/superpowers/specs/2026-03-21-agent-identity-and-worktree-enforcement-design.md
deleted file mode 100644
index e72774e7..00000000
--- a/docs/superpowers/specs/2026-03-21-agent-identity-and-worktree-enforcement-design.md
+++ /dev/null
@@ -1,158 +0,0 @@
-# Agent Identity Hard Gate & Worktree Policy Enforcement
-
-**Date:** 2026-03-21
-**Status:** Approved
-
-## Overview
-
-Two features that work together to support governed autonomous agent swarms:
-
-1. **Agent Identity Hard Gate** — Every governance session requires agent identity. No session starts without it.
-2. **Worktree Policy Enforcement** — YAML policy can require worktree usage via `requireWorktree` rule condition, with new `git.worktree.*` action types.
-
----
-
-## Feature 1: Agent Identity Hard Gate
-
-### Problem
-
-AgentGuard sessions start without knowing which agent is running. The kernel never emits a `RUN_STARTED` event. In swarm scenarios, there's no way to distinguish which agent took which actions. The `.agentguard-identity` file exists but nothing reads it.
-
-### Design
-
-#### Identity Resolution (ordered, first wins)
-
-1. `--agent-name ` CLI flag on `aguard guard`
-2. `AGENTGUARD_AGENT_NAME` environment variable (per-process)
-3. Interactive prompt (writes answer for session duration)
-
-#### Stateless File Contract
-
-- **Session start:** blank `.agentguard-identity` (wipe stale values)
-- **After resolution:** write resolved identity to `.agentguard-identity` (read window for other tools)
-- **Session end:** blank `.agentguard-identity` again
-- File is `.gitignore`d — never committed, purely session-scoped output
-
-#### Changes
-
-| File | Change |
-|------|--------|
-| `packages/core/src/types.ts` | Add `agentName: string` to `RunManifest` |
-| `packages/kernel/src/kernel.ts` | Emit `RUN_STARTED` event with `agentName`; reject `propose()` if no identity |
-| `apps/cli/src/commands/guard.ts` | Add `--agent-name` flag; resolve identity before kernel creation; blank/write/blank lifecycle |
-| `.gitignore` | Add `.agentguard-identity` |
-| `apps/cli/src/bin.ts` or `args.ts` | Wire `--agent-name` option to guard command |
-
-#### RUN_STARTED Event Payload
-
-```typescript
-{
- kind: 'RUN_STARTED',
- runId: string,
- timestamp: string,
- payload: {
- agentName: string,
- sessionId: string,
- policy: string | undefined,
- manifest: RunManifest
- }
-}
-```
-
-#### Autonomous Agent Flow
-
-Orchestrators (swarm scaffolder, CI) pass identity via CLI flag:
-```bash
-aguard guard --agent-name "builder-agent-3" --policy agentguard.yaml
-```
-
-No need to pre-write files. Each subprocess gets its own `--agent-name`.
-
-#### Interactive Flow
-
-```
-$ aguard guard
-⚠ No agent identity set.
-Agent name: █
-> my-dev-session
-✓ Identity set: my-dev-session
-```
-
----
-
-## Feature 2: Worktree Policy Enforcement
-
-### Problem
-
-No way to enforce worktree usage through YAML policy. Agents can `git checkout` freely, which in swarm scenarios causes conflicts in shared repos.
-
-### Design
-
-#### New Action Types
-
-Add to `packages/core/src/data/actions.json`:
-
-| Action Type | Class | Description |
-|------------|-------|-------------|
-| `git.worktree.add` | git | Create a git worktree |
-| `git.worktree.remove` | git | Remove a git worktree |
-| `git.worktree.list` | git | List git worktrees |
-
-#### AAB Detection
-
-In `packages/kernel/src/aab.ts`, detect shell commands:
-- `git worktree add ...` → `git.worktree.add`
-- `git worktree remove ...` / `git worktree prune` → `git.worktree.remove`
-- `git worktree list` → `git.worktree.list`
-
-#### Policy Condition: `requireWorktree`
-
-Rule-level condition (like `requireTests`). When `requireWorktree: true` is set on a rule matching `git.checkout` or `git.branch.create`, the action is denied with a message directing the agent to use worktrees instead.
-
-```yaml
-rules:
- - action: git.checkout
- effect: deny
- conditions:
- requireWorktree: true
- reason: "Use 'git worktree add ' instead of checkout"
-
- - action: git.worktree.add
- effect: allow
-
- - action: git.worktree.list
- effect: allow
-```
-
-#### Changes
-
-| File | Change |
-|------|--------|
-| `packages/core/src/data/actions.json` | Add `git.worktree.add/remove/list` |
-| `packages/core/src/actions.ts` | Update action type union if needed |
-| `packages/kernel/src/aab.ts` | Detect `git worktree` commands, normalize to action types |
-| `packages/policy/src/evaluator.ts` | Add `requireWorktree` condition to rule matching |
-| `packages/policy/src/yaml-loader.ts` | Accept `requireWorktree` in YAML schema |
-| `packages/adapters/src/git.ts` | Add handlers for worktree action types |
-| `packages/adapters/src/shell.ts` | Add worktree commands to privilege profiles |
-| `packages/core/src/data/git-action-patterns.json` | Add worktree patterns |
-
-#### Evaluator Logic
-
-```typescript
-// In policy evaluator, when checking conditions:
-if (rule.conditions?.requireWorktree && action.type === 'git.checkout') {
- return {
- effect: 'deny',
- reason: rule.reason ?? 'Worktree required: use git worktree add instead of checkout'
- };
-}
-```
-
----
-
-## Testing
-
-- **Identity gate:** test resolution order (flag > env > prompt), stateless file lifecycle, kernel rejects propose() without identity, RUN_STARTED event emission
-- **Worktree actions:** test AAB normalization of `git worktree` commands, policy evaluation with `requireWorktree` condition, adapter execution
-- **Integration:** guard command with `--agent-name`, guard command with interactive prompt (mock stdin)
diff --git a/docs/superpowers/specs/2026-03-25-squad-swarm-structure-design.md b/docs/superpowers/specs/2026-03-25-squad-swarm-structure-design.md
deleted file mode 100644
index f8e12360..00000000
--- a/docs/superpowers/specs/2026-03-25-squad-swarm-structure-design.md
+++ /dev/null
@@ -1,347 +0,0 @@
-# Agent Swarm Squad Structure — Design Spec
-
-**Date:** 2026-03-25
-**Status:** Approved
-**Author:** Jared + Claude
-
-## Problem
-
-The current agent swarm is a flat pool of 26 agents in 5 functional tiers. Agents step on each other, there's no code ownership, no review chain, and no accountability per area. When 8 PRs pile up with 1 conflicted, nobody owns the resolution. The swarm coordination via `swarm-state.json` works for state sharing but has no hierarchy for decision-making or escalation.
-
-The goal: restructure the swarm into squads that operate like an engineering org — clear ownership, built-in review chains, seniority-based model assignment, multi-vendor governance (Claude Code + Copilot CLI), and telemetry that flows from agent identity through the database to the dashboard and office-sim.
-
-## Design
-
-### Squad Structure
-
-3 squads, each with 5 agents + 1 EM. 1 Director. 1 Human.
-
-```
-Human (Jared)
- └── Director (Opus, claude-code)
- ├── EM: Kernel Squad (Opus, claude-code)
- │ ├── Product Lead (Sonnet, claude-code)
- │ ├── Architect (Opus, claude-code)
- │ ├── Senior Engineer (Sonnet, copilot-cli)
- │ ├── Junior Engineer (Copilot, copilot-cli)
- │ └── QA Automation (Sonnet, copilot-cli)
- │
- ├── EM: Cloud Squad (Opus, claude-code)
- │ ├── Product Lead (Sonnet, claude-code)
- │ ├── Architect (Opus, claude-code)
- │ ├── Senior Engineer (Sonnet, copilot-cli)
- │ ├── Junior Engineer (Copilot, copilot-cli)
- │ └── QA Automation (Sonnet, copilot-cli)
- │
- └── EM: QA Squad (Sonnet, claude-code)
- ├── Product Lead (Sonnet, claude-code)
- ├── Architect (Sonnet, claude-code)
- ├── Senior Engineer (Sonnet, copilot-cli)
- ├── Junior Engineer (Copilot, copilot-cli)
- └── QA Automation (Haiku, copilot-cli)
-```
-
-**Total: 15 squad agents + 3 EMs + 1 Director = 19 agents**
-
-**Ownership:**
-- **Kernel Squad** — `agent-guard/` (Go kernel, TS kernel, policy, invariants, matchers, CLI, npm publishing)
-- **Cloud Squad** — `agentguard-cloud/` (dashboard, API server, telemetry, office-sim, Vercel deployment)
-- **QA Squad** — Cross-repo (stranger tests, Playwright e2e, compliance suite, swarm health, CI/CD)
-
-### Model & Driver Assignment
-
-Copilot CLI is a first-class workhorse — 9 of 15 squad agents use it. Claude Code is reserved for leadership and architecture roles.
-
-| Role | Model | Driver | Rationale |
-|------|-------|--------|-----------|
-| Director | Opus | claude-code | Cross-squad reasoning needs depth |
-| EM | Opus | claude-code | Architectural context for coordination |
-| Product Lead | Sonnet | claude-code | Prioritization, roadmap alignment |
-| Architect | Opus | claude-code | Design reviews need deepest reasoning |
-| Senior Engineer | Sonnet | copilot-cli | Fast implementation, high volume |
-| Junior Engineer | Copilot | copilot-cli | Cheapest, highest volume tasks |
-| QA Automation | Sonnet/Haiku | copilot-cli | Fast test execution, high frequency |
-
-This stress-tests multi-vendor governance — every Copilot CLI action goes through the same AgentGuard kernel as Claude Code actions via the `copilot-cli` adapter.
-
-### Coordination Protocol
-
-Three layers: squad-internal, cross-squad, human escalation.
-
-**Squad-internal (files — fast, every run):**
-
-Each squad writes to `.agentguard/squads/{squad-name}/state.json`:
-```json
-{
- "squad": "kernel",
- "sprint": { "goal": "Go kernel Phase 2", "issues": ["#860", "#862"] },
- "assignments": {
- "architect": { "current": "#860", "status": "reviewing" },
- "senior": { "current": "#862", "status": "implementing" },
- "junior": { "current": "#863", "status": "writing-tests" },
- "qa": { "current": null, "waiting": "senior to push" }
- },
- "blockers": [],
- "prQueue": { "open": 2, "reviewed": 1, "mergeable": 1 }
-}
-```
-
-PL sets priorities. Architect reviews before merge. Senior implements. Junior writes tests + handles chores. QA runs e2e after merge. EM reads state, unblocks, and escalates.
-
-**Cross-squad (EM → Director — aggregated files):**
-
-EMs write to `.agentguard/squads/{squad-name}/em-report.json`. Director reads all EM reports and writes `.agentguard/director-brief.json` — the human's daily summary.
-
-**Human escalation (GitHub issues):**
-
-When Director needs the human: creates an issue labeled `escalation:human`. When an EM is stuck: creates an issue labeled `escalation:em`. Human comments to resolve. Agent polls for response.
-
-### Adopted Patterns (from everything-claude-code)
-
-**1. Continuous Learning Cycle**
-
-Each squad maintains `.agentguard/squads/{squad-name}/learnings.json`. Four operations:
-
-- **Learn** — After every PR merge, QA extracts patterns: what worked, what broke, what was surprising. Stored as `{pattern, confidence, source_pr, timestamp}`.
-- **Eval** — Weekly, Architect scores accumulated patterns (0-1 confidence). Low-confidence patterns get more evidence or get dropped.
-- **Evolve** — Monthly, PL clusters high-confidence patterns into new squad-specific skills. A pattern in 3+ PRs becomes a skill file.
-- **Prune** — Monthly, EM removes stale learnings (>30 days, low confidence, superseded).
-
-**2. Autonomous Loop Guards (5-layer)**
-
-Every agent run checks before proceeding:
-
-1. **Budget guard** — Max 3 PRs open per squad. Exceeded → skip implementation, only review/merge.
-2. **Retry guard** — Same action failed 3 times → stop, create escalation issue.
-3. **Blast radius guard** — Predicted file changes > 20 → pause, escalate to Architect.
-4. **Cascade guard** — 2+ squads both modifying same file → pause both, escalate to Director.
-5. **Time guard** — Agent run exceeds 10 minutes → force-stop, log partial progress, EM investigates.
-
-**3. Orchestration Commands**
-
-EM-level commands for squad task management:
-
-- `/squad-plan {goal}` — PL + Architect decompose goal into tasks, assign to Sr/Jr/QA
-- `/squad-execute` — EM dispatches all assigned tasks in dependency order
-- `/squad-status` — EM aggregates squad state into one-line summary per agent
-- `/squad-retro` — QA + Architect review last sprint's merged PRs, extract learnings
-
-**4. Skill Expansion (39 → 125+)**
-
-Current 39 skills are SDLC-focused. Expand with:
-- Per-language skills (Go, Python, TypeScript patterns)
-- Per-squad skills (kernel: policy testing, invariant validation; cloud: Vercel deployment, DB migrations)
-- Business skills (content generation, changelog writing, release notes)
-- Learning skills (pattern extraction, confidence scoring, skill evolution)
-- Autonomous loop skills (DAG orchestration, sequential pipelines, PR loops)
-
-Skills are composable — agents reference which skills they use. Squads inherit shared skills + add squad-specific ones. Manifest-driven selective install (from everything-claude-code) prevents skill bloat.
-
-### Agent Identity & Manifest
-
-**Identity format:** `{driver}:{model}:{squad}:{rank}`
-
-Examples:
-- `claude-code:opus:kernel:architect`
-- `copilot-cli:copilot:cloud:junior`
-- `claude-code:opus:director:director`
-
-**Manifest structure** — extends existing `packages/swarm/manifest.json`:
-
-```yaml
-# .agentguard/squad-manifest.yaml
-org:
- director:
- id: director
- driver: claude-code
- model: opus
- cron: "0 7,19 * * *"
- skills: [squad-status, director-brief, escalation-router]
-
-squads:
- kernel:
- repo: agent-guard
- em:
- id: kernel-em
- driver: claude-code
- model: opus
- cron: "0 */3 * * *"
- skills: [squad-plan, squad-execute, squad-status, squad-retro, escalation-router]
- agents:
- product-lead:
- driver: claude-code
- model: sonnet
- cron: "0 6 * * *"
- skills: [sprint-planning, roadmap-expand, backlog-steward, learn]
- architect:
- driver: claude-code
- model: opus
- cron: "0 */4 * * *"
- skills: [architecture-review, review-open-prs, eval, evolve]
- senior:
- driver: copilot-cli
- model: sonnet
- cron: "0 */2 * * *"
- skills: [claim-issue, implement-issue, create-pr, run-tests]
- junior:
- driver: copilot-cli
- model: copilot
- cron: "0 */2 * * *"
- skills: [claim-issue, implement-issue, run-tests, generate-tests]
- qa:
- driver: copilot-cli
- model: sonnet
- cron: "0 */3 * * *"
- skills: [e2e-testing, compliance-test, test-health-review, learn, prune]
-
- cloud:
- repo: agentguard-cloud
- em:
- id: cloud-em
- driver: claude-code
- model: opus
- cron: "0 */3 * * *"
- skills: [squad-plan, squad-execute, squad-status, squad-retro, escalation-router]
- agents:
- product-lead:
- driver: claude-code
- model: sonnet
- cron: "0 6 * * *"
- skills: [sprint-planning, roadmap-expand, backlog-steward, learn]
- architect:
- driver: claude-code
- model: opus
- cron: "0 */4 * * *"
- skills: [architecture-review, review-open-prs, eval, evolve]
- senior:
- driver: copilot-cli
- model: sonnet
- cron: "0 */2 * * *"
- skills: [claim-issue, implement-issue, create-pr, run-tests]
- junior:
- driver: copilot-cli
- model: copilot
- cron: "0 */2 * * *"
- skills: [claim-issue, implement-issue, run-tests, generate-tests]
- qa:
- driver: copilot-cli
- model: sonnet
- cron: "0 */3 * * *"
- skills: [e2e-testing, compliance-test, test-health-review, learn, prune]
-
- qa:
- repo: "*"
- em:
- id: qa-em
- driver: claude-code
- model: sonnet
- cron: "0 */3 * * *"
- skills: [squad-plan, squad-execute, squad-status, squad-retro, escalation-router]
- agents:
- product-lead:
- driver: claude-code
- model: sonnet
- cron: "0 6 * * *"
- skills: [sprint-planning, test-strategy, stranger-test-plan, learn]
- architect:
- driver: claude-code
- model: sonnet
- cron: "0 */4 * * *"
- skills: [test-architecture, compliance-review, eval, evolve]
- senior:
- driver: copilot-cli
- model: sonnet
- cron: "0 */2 * * *"
- skills: [playwright-e2e, stranger-test-run, compliance-test, create-pr]
- junior:
- driver: copilot-cli
- model: copilot
- cron: "0 */2 * * *"
- skills: [generate-tests, run-tests, test-data-generation]
- qa:
- driver: copilot-cli
- model: haiku
- cron: "0 */1 * * *"
- skills: [e2e-testing, regression-analysis, flakiness-detection, learn, prune]
-```
-
-### Migration from Current 26 Agents
-
-Existing agents don't disappear — they get reassigned into squads:
-
-| Current Agent | Squad | New Role |
-|--------------|-------|----------|
-| coder-agent | kernel/cloud | Senior Engineer |
-| code-review-agent | kernel/cloud | Architect responsibility |
-| pr-merger-agent | kernel/cloud | EM responsibility |
-| ci-triage-agent | qa | QA Automation |
-| merge-conflict-resolver | kernel/cloud | EM responsibility |
-| pr-review-responder | kernel/cloud | Architect responsibility |
-| stale-branch-janitor | qa | Junior Engineer chore |
-| recovery-controller | — | Director responsibility |
-| risk-escalation-agent | — | Director responsibility |
-| governance-monitor | qa | QA Architect |
-| planning-agent | kernel/cloud | Product Lead |
-| backlog-steward | kernel/cloud | Product Lead skill |
-| observability-agent | qa | QA Product Lead |
-| docs-sync-agent | kernel/cloud | Junior Engineer chore |
-| product-agent | kernel/cloud | Product Lead |
-| progress-controller | — | Director skill |
-| repo-hygiene-agent | qa | Junior Engineer chore |
-| retrospective-agent | — | EM skill (squad-retro) |
-| test-agent | qa | QA Senior Engineer |
-| test-generation-agent | qa | QA Junior Engineer |
-| security-audit-agent | qa | QA Architect |
-| architect-agent | kernel/cloud | Architect |
-| cicd-hardening-agent | qa | QA Senior Engineer |
-| audit-merged-prs-agent | qa | QA Automation |
-| infrastructure-health-agent | qa | QA Automation |
-| marketing-content-agent | cloud | Junior Engineer skill |
-
-### Database & Telemetry Integration
-
-Squad identity flows through the entire platform pipeline:
-
-```
-squad-manifest.yaml → .agentguard-identity → kernel → telemetry → Postgres → dashboard → office-sim
-```
-
-**Identity propagation:**
-1. Agent starts with identity `copilot-cli:sonnet:kernel:senior` in `.agentguard-identity`
-2. Governance hook reads identity, attaches to every `GovernanceDecisionRecord`
-3. Telemetry `AgentEvent` includes full `agentId` with squad/rank
-4. Cloud telemetry server stores events in Postgres with agent identity
-5. Dashboard queries by squad, rank, model, driver
-6. Office-sim visualizes squads as teams with real-time action streams
-
-**Database: parse from agentId at query time (no schema change):**
-
-The identity format `{driver}:{model}:{squad}:{rank}` is parseable:
-```sql
-SELECT
- split_part(agent_id, ':', 3) AS squad,
- split_part(agent_id, ':', 4) AS rank,
- split_part(agent_id, ':', 1) AS driver,
- count(*) AS decisions
-FROM agent_events
-WHERE timestamp > now() - interval '7 days'
-GROUP BY squad, rank, driver
-ORDER BY decisions DESC;
-```
-
-No schema migration needed — the existing `agent_id` text field carries the full hierarchy.
-
-**Dashboard views enabled:**
-- Squad leaderboard (PRs merged, tests written, denials per squad)
-- Agent performance by rank (Opus architects vs Sonnet seniors)
-- Model cost analysis (Copilot CLI vs Claude Code event volume)
-- Escalation funnel (issues reaching EM → Director → Human)
-- Office-sim squad visualization (live agent activity grouped by squad)
-- Learning cycle metrics (patterns extracted, skills evolved, confidence trends)
-
-## Non-Goals
-
-- More than 3 squads initially (add Dashboard squad when justified)
-- Custom LLM fine-tuning for agent roles (use prompt engineering via skills)
-- Real-time inter-agent chat (async file + issue coordination is sufficient)
-- Windows Copilot CLI support (Linux only for now)
diff --git a/packages/scheduler/package.json b/packages/scheduler/package.json
index cdca028a..9e4e824b 100644
--- a/packages/scheduler/package.json
+++ b/packages/scheduler/package.json
@@ -1,7 +1,7 @@
{
"name": "@red-codes/scheduler",
"version": "2.9.3",
- "description": "Task scheduler, queue, lease manager, and worker orchestration for AgentGuard swarm",
+ "description": "Task scheduler, queue, lease manager, and worker orchestration for AgentGuard",
"type": "module",
"main": "dist/index.js",
"types": "dist/index.d.ts",
diff --git a/packages/swarm/README.md b/packages/swarm/README.md
deleted file mode 100644
index e0fe9807..00000000
--- a/packages/swarm/README.md
+++ /dev/null
@@ -1,349 +0,0 @@
-# @red-codes/swarm
-
-**Autonomous agent swarm for software development.** 26 coordinated AI agents that handle your entire SDLC — implementation, code review, CI triage, security audits, planning, and more — all running under governance policy enforcement.
-
-This is the same swarm that builds AgentGuard itself.
-
-## What It Does
-
-The swarm scaffolds a complete autonomous development pipeline into any repository. Agents are scheduled via cron and coordinate through shared state. Every agent action passes through [AgentGuard](https://github.com/AgentGuardHQ/agent-guard) governance — policy evaluation, invariant checking, escalation tracking, and audit logging.
-
-```
-ROADMAP.md (you write strategy)
- │
- ├── Planning Agent (daily) ─── reads roadmap, sets priorities
- ├── Backlog Steward (daily) ── expands roadmap into issues
- ├── Coder Agent (2-hourly) ─── picks issues, implements, creates PRs
- ├── Code Review Agent (2h) ─── reviews PRs for quality
- ├── Architect Agent (daily) ── reviews PRs for architecture
- ├── CI Triage Agent (hourly) ─ fixes failing CI
- ├── PR Merger Agent (2h) ───── auto-merges when gates pass
- ├── Security Audit (weekly) ── dependency + code scanning
- ├── Recovery Controller (2h) ─ self-healing, detects unhealthy state
- └── ... 17 more agents
-```
-
-## Quick Start
-
-```bash
-# Clone and build AgentGuard
-git clone https://github.com/AgentGuardHQ/agent-guard.git
-cd agent-guard
-pnpm install && pnpm build
-
-# Link the CLI globally
-cd apps/cli && npm link && cd ../..
-
-# Scaffold the swarm into your project
-cd /path/to/your-project
-aguard init swarm
-
-# This creates:
-# agentguard-swarm.yaml — swarm configuration
-# .claude/skills/*.md — 39 skill definitions
-# agentguard.yaml — governance policy (if missing)
-```
-
-### Claude Desktop Setup
-
-After scaffolding, each agent must be registered as a **scheduled task** in Claude Desktop. The scaffolder outputs the full agent manifest with cron schedules — but you still need to configure three things manually:
-
-#### 1. Create scheduled tasks in Claude Desktop
-
-Open Claude Desktop and create a scheduled task for each agent you want to run. Use the cron schedule from the agent manifest and point the task at the agent's prompt file (e.g., `.claude/prompts/coder-agent.md`).
-
-#### 2. Enable worktree isolation
-
-In each scheduled task's configuration, set **worktree to `true`**. This gives each agent run an isolated git worktree so parallel agents don't interfere with each other's file changes or git state.
-
-```json
-{
- "task": "coder-agent",
- "schedule": "0 */2 * * *",
- "worktree": true
-}
-```
-
-Without worktree isolation, concurrent agents will conflict on file writes, git index locks, and branch state.
-
-#### 3. Bypass permissions manually
-
-Scheduled agents run **unattended** — there is no human to approve tool-use permission prompts. You must manually pre-approve the necessary permissions for each agent before it can run autonomously. In Claude Desktop, configure the agent's permissions to allow the tools it needs (file read/write, shell execution, git operations) without interactive confirmation.
-
-> **Important:** Review the governance policy (`agentguard.yaml`) before granting broad permissions. AgentGuard's invariant system acts as a second layer of defense, but the policy should be tuned to your project's risk tolerance.
-
-## Agents
-
-### Core Tier (7 agents)
-
-| Agent | Schedule | Role |
-|-------|----------|------|
-| Implementation Agent | Every 2h | Picks issues, implements code, creates PRs |
-| Code Review Agent | Every 2h | Reviews open PRs for quality |
-| PR Merger Agent | Every 2h | Auto-merges PRs with passing CI + approvals |
-| CI Triage Agent | Hourly | Diagnoses and fixes CI failures |
-| Merge Conflict Resolver | Every 2h | Resolves conflicts (1 PR per run) |
-| PR Review Responder | Hourly | Responds to review comments |
-| Stale Branch Janitor | Daily 8am | Cleans up stale branches and PRs |
-
-### Governance Tier (3 agents)
-
-| Agent | Schedule | Role |
-|-------|----------|------|
-| Recovery Controller | Every 2h | Self-healing — detects and remediates unhealthy swarm state |
-| Risk Escalation Agent | Every 4.5h | Cumulative risk assessment, gates dangerous operations |
-| Governance Monitor | Daily 2am | Audits governance logs, reviews policy effectiveness |
-
-### Ops Tier (8 agents)
-
-| Agent | Schedule | Role |
-|-------|----------|------|
-| Planning Agent | Daily 6am | Sprint planning, priority setting |
-| Backlog Steward | Daily 5am | Expands ROADMAP into issues (max 3/run) |
-| Observability Agent | Daily 9am | SRE health monitoring |
-| Documentation Maintainer | Daily 11am | Keeps docs in sync with code |
-| Product Agent | Daily 7am | Product health and roadmap alignment |
-| Progress Controller | Daily 7am | Tracks roadmap phase completion |
-| Repo Hygiene Agent | Daily 3am | Detects stale issues |
-| Retrospective Agent | Weekly Mon 8am | Failure analysis, lessons learned |
-
-### Quality Tier (7 agents)
-
-| Agent | Schedule | Role |
-|-------|----------|------|
-| Test Agent | Daily 8am | Test health and coverage analysis |
-| Test Generation Agent | Weekly Mon 11am | Generates tests for untested modules |
-| Security Audit Agent | Weekly Sun 8pm | Dependency + source code security scan |
-| Architect Agent | Daily 10am | Architectural review of PRs |
-| CI/CD Hardening Agent | Weekly Sun 9pm | Action pinning, permissions, supply chain audit |
-| Merged PR Auditor | Weekly Mon 9am | Audits recently merged PRs for missed risks |
-| Infrastructure Health Agent | Daily 9pm | SDLC pipeline health check |
-
-### Marketing Tier (1 agent)
-
-| Agent | Schedule | Role |
-|-------|----------|------|
-| Marketing Content Agent | Weekly Mon 9am | Drafts social posts and blog outlines |
-
-## Configuration
-
-After scaffolding, customize `agentguard-swarm.yaml`:
-
-```yaml
-swarm:
- # Enable/disable agent tiers
- tiers:
- - core # Essential: coder, reviewer, merger, CI triage
- - governance # Risk escalation, recovery, policy audit
- - ops # Planning, observability, docs, retrospectives
- - quality # Testing, security, architecture review
- # - marketing # Content generation (opt-in)
-
- # Override cron schedules per agent
- schedules:
- coder-agent: '0 */4 * * *' # Slow down to every 4 hours
- ci-triage-agent: '0 */2 * * *' # Less frequent CI checks
-
- # Project-specific paths
- paths:
- policy: agentguard.yaml # Governance policy file
- roadmap: ROADMAP.md # Your project roadmap
- swarmState: .agentguard/swarm-state.json
- logs: logs/runtime-events.jsonl
- cli: agentguard # How to invoke the CLI
-
- # Behavioral thresholds
- thresholds:
- maxOpenPRs: 5 # Coder stops creating PRs above this
- prStaleHours: 48 # PRs older than this get flagged
- blastRadiusHigh: 16 # Actions above this score get escalated
-```
-
-## Multi-Project Setup
-
-The swarm is designed to work across multiple repositories. Each repo gets its own:
-- `ROADMAP.md` — defines what the swarm builds
-- `agentguard-swarm.yaml` — configures agent behavior
-- `agentguard.yaml` — governance policy
-- `.agentguard/swarm-state.json` — runtime coordination state
-
-To run the same swarm on two repos (e.g., an OSS repo and a private enterprise repo):
-
-```bash
-# In your OSS repo
-cd ~/oss-project
-aguard init swarm
-
-# In your enterprise repo
-cd ~/enterprise-project
-aguard init swarm
-```
-
-Each repo has its own ROADMAP.md driving independent priorities. The agents operate under their respective governance policies. Swarm state is per-repo.
-
-## How Agents Coordinate
-
-Agents share state through `.agentguard/swarm-state.json`:
-
-```json
-{
- "mode": "normal",
- "currentPhase": "Phase 6",
- "prQueueHealthy": true,
- "openAgentPRs": 3,
- "priorities": [42, 38, 45],
- "lastProgressRun": "2026-03-15T07:00:00Z"
-}
-```
-
-- **mode**: `normal` | `conservative` | `safe` — the Recovery Controller escalates when things go wrong
-- **prQueueHealthy**: Coder Agent skips when `false` (too many open PRs)
-- **priorities**: Planning Agent sets issue priority order
-- **currentPhase**: Progress Controller tracks ROADMAP phase
-
-## Skills
-
-Each agent executes one or more **skills** — markdown-defined task playbooks in `.claude/skills/`. Skills are composable and reusable across agents.
-
-All 39 skills are scaffolded from templates with your project-specific paths and labels injected.
-
-## Governance Integration
-
-Every agent starts by invoking the `start-governance-runtime` skill, which activates AgentGuard hooks in Claude Code. This means:
-
-- All file writes, shell commands, and git operations are policy-checked
-- Destructive actions are blocked by invariants
-- Violations escalate the system (NORMAL → ELEVATED → HIGH → LOCKDOWN)
-- Full audit trail in JSONL for every agent action
-
-## Squad Structure
-
-The swarm can be organized into **squads** — small, autonomous teams of AI agents with a reporting hierarchy. Each squad has an Engineering Manager (EM) overseeing 5 specialist agents, all reporting up to a single Director agent.
-
-### Squad Manifest Schema
-
-Squads are defined in a YAML manifest (`squad-manifest.yaml`):
-
-```yaml
-version: "1.0.0"
-
-org:
- director:
- id: director
- rank: director
- driver: claude-code
- model: opus
- cron: "0 7,19 * * *"
- skills: [squad-status, director-brief, escalation-router]
-
-squads:
- kernel:
- repo: agent-guard
- em:
- id: kernel-em
- rank: em
- driver: claude-code
- model: opus
- cron: "0 */3 * * *"
- skills: [squad-plan, squad-execute, squad-status]
- agents:
- product-lead: { id: kernel-pl, rank: product-lead, driver: claude-code, model: sonnet, ... }
- architect: { id: kernel-arch, rank: architect, driver: claude-code, model: opus, ... }
- senior: { id: kernel-sr, rank: senior, driver: copilot-cli, model: sonnet, ... }
- junior: { id: kernel-jr, rank: junior, driver: copilot-cli, model: copilot, ... }
- qa: { id: kernel-qa, rank: qa, driver: copilot-cli, model: sonnet, ... }
-
-loopGuards:
- maxOpenPRsPerSquad: 3
- maxRetries: 3
- maxBlastRadius: 20
- maxRunMinutes: 10
-```
-
-Each squad agent specifies a `driver` (`claude-code` or `copilot-cli`), a `model` (`opus`, `sonnet`, `haiku`, `copilot`), a `rank`, and a set of skills. Valid ranks: `director`, `em`, `product-lead`, `architect`, `senior`, `junior`, `qa`.
-
-### Identity Format
-
-Every agent in a squad has a 4-part identity string: `driver:model:squad:rank`. For example:
-
-- `claude-code:opus:kernel:em` — the kernel squad's EM running on Claude Code with Opus
-- `copilot-cli:sonnet:cloud:senior` — the cloud squad's senior dev running on Copilot CLI with Sonnet
-
-Identity strings are parsed from agent metadata at runtime and flow through telemetry, so the dashboard can attribute actions to specific agents within a squad.
-
-```typescript
-import { buildAgentIdentity, parseAgentIdentity } from '@red-codes/swarm';
-
-const identity = buildAgentIdentity(agent, 'kernel');
-// => "copilot-cli:sonnet:kernel:senior"
-
-const parsed = parseAgentIdentity('copilot-cli:sonnet:kernel:senior');
-// => { driver: 'copilot-cli', model: 'sonnet', squad: 'kernel', rank: 'senior' }
-```
-
-### Loop Guards
-
-Every agent checks **4 loop guards** at run start to prevent runaway behavior:
-
-| Guard | Config Key | Description |
-|-------|-----------|-------------|
-| Budget | `maxOpenPRsPerSquad` | Blocks new PRs when the squad has too many open |
-| Retry | `maxRetries` | Stops retrying after N consecutive failures |
-| Blast Radius | `maxBlastRadius` | Rejects changes touching too many files |
-| Time | `maxRunMinutes` | Kills runs that exceed the time limit |
-
-All four guards must pass for an agent to proceed. Violations are returned with the specific guard names that failed.
-
-### State File Locations
-
-Each squad maintains its own state directory under `.agentguard/squads/`:
-
-```
-.agentguard/
- squads/
- kernel/
- state.json # Current squad state (sprint goal, assignments, PR queue, blockers)
- learnings.json # Accumulated learnings from retrospectives
- em-report.json # Latest EM health report for the director
- cloud/
- state.json
- learnings.json
- em-report.json
- qa/
- state.json
- learnings.json
- em-report.json
- director-brief.json # Aggregated brief from all squad EM reports
-```
-
-Use `scaffoldSquad` to initialize these directories:
-
-```typescript
-import { loadSquadManifest, scaffoldSquad } from '@red-codes/swarm';
-
-const manifest = loadSquadManifest(yamlContent);
-for (const [name, squad] of Object.entries(manifest.squads)) {
- scaffoldSquad('/path/to/project', name, squad);
-}
-```
-
-## Programmatic API
-
-```typescript
-import { scaffold, loadConfig, loadManifest, filterAgentsByTier } from '@red-codes/swarm';
-
-// Scaffold swarm into a project
-const result = await scaffold({
- projectRoot: '/path/to/project',
- force: false,
- tiers: ['core', 'governance'],
-});
-
-// Load and filter agents
-const manifest = loadManifest();
-const coreAgents = filterAgentsByTier(manifest.agents, ['core']);
-```
-
-## License
-
-[Apache 2.0](../../LICENSE)
diff --git a/packages/swarm/manifest.json b/packages/swarm/manifest.json
deleted file mode 100644
index a49c9e01..00000000
--- a/packages/swarm/manifest.json
+++ /dev/null
@@ -1,239 +0,0 @@
-{
- "version": "1.0.0",
- "agents": [
- {
- "id": "coder-agent",
- "name": "Implementation Agent",
- "tier": "core",
- "cron": "0 */2 * * *",
- "skills": ["start-governance-runtime", "sync-main", "discover-next-issue", "claim-issue", "implement-issue", "run-tests", "create-pr"],
- "promptTemplate": "coder-agent",
- "description": "Implementation Agent with PR queue gate — runs every 2 hours, skips if PR queue is full"
- },
- {
- "id": "code-review-agent",
- "name": "Code Review Agent",
- "tier": "core",
- "cron": "0 */2 * * *",
- "skills": ["start-governance-runtime", "review-open-prs"],
- "promptTemplate": "code-review-agent",
- "description": "Code Review Agent — reviews PRs every 2 hours"
- },
- {
- "id": "pr-merger-agent",
- "name": "PR Merger Agent",
- "tier": "core",
- "cron": "0 */2 * * *",
- "skills": ["start-governance-runtime", "pr-merger"],
- "promptTemplate": "pr-merger-agent",
- "description": "Auto-merge PRs that have passing CI and approved reviews — every 2 hours"
- },
- {
- "id": "ci-triage-agent",
- "name": "CI Triage Agent",
- "tier": "core",
- "cron": "0 * * * *",
- "skills": ["start-governance-runtime", "sync-main", "triage-failing-ci"],
- "promptTemplate": "ci-triage-agent",
- "description": "CI Triage Agent — hourly with skip-if-green guard"
- },
- {
- "id": "merge-conflict-resolver",
- "name": "Merge Conflict Resolver",
- "tier": "core",
- "cron": "0 */2 * * *",
- "skills": ["start-governance-runtime", "resolve-merge-conflicts"],
- "promptTemplate": "merge-conflict-resolver",
- "description": "Merge Conflict Resolver — serialized (1 PR/run), every 2 hours, with cascade risk detection"
- },
- {
- "id": "pr-review-responder",
- "name": "PR Review Responder",
- "tier": "core",
- "cron": "0 * * * *",
- "skills": ["start-governance-runtime", "respond-to-pr-reviews"],
- "promptTemplate": "pr-review-responder",
- "description": "Respond to unresolved PR review comments on agent-authored PRs"
- },
- {
- "id": "stale-branch-janitor",
- "name": "Stale Branch Janitor",
- "tier": "core",
- "cron": "0 8 * * *",
- "skills": ["start-governance-runtime", "stale-branch-janitor"],
- "promptTemplate": "stale-branch-janitor",
- "description": "Stale Branch Janitor — daily cleanup of stale branches and PRs"
- },
- {
- "id": "recovery-controller",
- "name": "Recovery Controller",
- "tier": "governance",
- "cron": "0 */2 * * *",
- "skills": ["start-governance-runtime", "recovery-controller"],
- "promptTemplate": "recovery-controller",
- "description": "Self-healing agent that detects unhealthy swarm conditions and executes remediation playbooks"
- },
- {
- "id": "risk-escalation-agent",
- "name": "Risk Escalation Agent",
- "tier": "governance",
- "cron": "30 */4 * * *",
- "skills": ["start-governance-runtime", "risk-escalation"],
- "promptTemplate": "risk-escalation-agent",
- "description": "Assesses cumulative swarm risk, gates dangerous operations, escalates to humans when needed"
- },
- {
- "id": "governance-monitor",
- "name": "Governance Monitor",
- "tier": "governance",
- "cron": "0 2 * * *",
- "skills": ["start-governance-runtime", "governance-log-audit", "policy-effectiveness-review"],
- "promptTemplate": "governance-monitor",
- "description": "Governance Agent — combined governance monitoring + policy effectiveness analysis (daily)"
- },
- {
- "id": "planning-agent",
- "name": "Planning Agent",
- "tier": "ops",
- "cron": "0 6 * * *",
- "skills": ["start-governance-runtime", "sprint-planning"],
- "promptTemplate": "planning-agent",
- "description": "Planning Agent — daily sprint planning with strategy document ingestion and swarm state updates"
- },
- {
- "id": "observability-agent",
- "name": "Observability Agent",
- "tier": "ops",
- "cron": "0 9 * * *",
- "skills": ["start-governance-runtime", "observability-review"],
- "promptTemplate": "observability-agent",
- "description": "Observability Agent — daily SRE analysis with swarm health monitoring and shared state updates"
- },
- {
- "id": "backlog-steward",
- "name": "Backlog Steward",
- "tier": "ops",
- "cron": "0 5 * * *",
- "skills": ["start-governance-runtime", "backlog-steward", "roadmap-expand"],
- "promptTemplate": "backlog-steward",
- "description": "Backlog Steward — daily ROADMAP expansion, capped at 3 issues/run"
- },
- {
- "id": "docs-sync-agent",
- "name": "Documentation Maintainer",
- "tier": "ops",
- "cron": "0 11 * * *",
- "skills": ["start-governance-runtime", "scheduled-docs-sync"],
- "promptTemplate": "docs-sync-agent",
- "description": "Documentation Maintainer — daily docs sync with strategy staleness detection"
- },
- {
- "id": "product-agent",
- "name": "Product Agent",
- "tier": "ops",
- "cron": "0 7 * * *",
- "skills": ["start-governance-runtime", "product-health-review"],
- "promptTemplate": "product-agent",
- "description": "Product Agent — daily product health and roadmap alignment review"
- },
- {
- "id": "progress-controller",
- "name": "Progress Controller",
- "tier": "ops",
- "cron": "0 7 * * *",
- "skills": ["start-governance-runtime", "progress-controller"],
- "promptTemplate": "progress-controller",
- "description": "Tracks roadmap phase completion, detects transitions, prevents backlog expansion"
- },
- {
- "id": "repo-hygiene-agent",
- "name": "Repo Hygiene Agent",
- "tier": "ops",
- "cron": "0 3 * * *",
- "skills": ["start-governance-runtime", "repo-hygiene"],
- "promptTemplate": "repo-hygiene-agent",
- "description": "Detect stale issues, solved issues, and undiscovered work"
- },
- {
- "id": "retrospective-agent",
- "name": "Retrospective Agent",
- "tier": "ops",
- "cron": "0 8 * * 1",
- "skills": ["start-governance-runtime", "retrospective"],
- "promptTemplate": "retrospective-agent",
- "description": "Analyzes failure patterns, extracts heuristics, publishes weekly retrospective with lessons learned"
- },
- {
- "id": "test-agent",
- "name": "Test Agent",
- "tier": "quality",
- "cron": "0 8 * * *",
- "skills": ["start-governance-runtime", "test-health-review"],
- "promptTemplate": "test-agent",
- "description": "Test Agent — daily test health review and coverage analysis"
- },
- {
- "id": "test-generation-agent",
- "name": "Test Generation Agent",
- "tier": "quality",
- "cron": "0 11 * * 1",
- "skills": ["start-governance-runtime", "generate-tests"],
- "promptTemplate": "test-generation-agent",
- "description": "Generate tests for untested source modules (weekly)"
- },
- {
- "id": "security-audit-agent",
- "name": "Security Audit Agent",
- "tier": "quality",
- "cron": "0 20 * * 0",
- "skills": ["start-governance-runtime", "dependency-security-audit", "security-code-scan"],
- "promptTemplate": "security-audit-agent",
- "description": "Security Agent — combined dependency audit + source code scan (weekly Sunday)"
- },
- {
- "id": "architect-agent",
- "name": "Architect Agent",
- "tier": "quality",
- "cron": "0 10 * * *",
- "skills": ["start-governance-runtime", "architecture-review"],
- "promptTemplate": "architect-agent",
- "description": "Review open PRs for architectural concerns"
- },
- {
- "id": "cicd-hardening-agent",
- "name": "CI/CD Hardening Agent",
- "tier": "quality",
- "cron": "0 21 * * 0",
- "skills": ["start-governance-runtime", "cicd-hardening-audit"],
- "promptTemplate": "cicd-hardening-agent",
- "description": "Weekly CI/CD hardening audit — action pinning, permissions, supply chain, governance integration"
- },
- {
- "id": "audit-merged-prs-agent",
- "name": "Merged PR Auditor",
- "tier": "quality",
- "cron": "0 9 * * 1",
- "skills": ["start-governance-runtime", "audit-merged-prs"],
- "promptTemplate": "audit-merged-prs-agent",
- "description": "Weekly audit of PRs merged in the last 7 days for overlooked risks"
- },
- {
- "id": "infrastructure-health-agent",
- "name": "Infrastructure Health Agent",
- "tier": "quality",
- "cron": "0 21 * * *",
- "skills": ["start-governance-runtime", "sdlc-pipeline-health"],
- "promptTemplate": "infrastructure-health-agent",
- "description": "Daily infrastructure and SDLC pipeline health check"
- },
- {
- "id": "marketing-content-agent",
- "name": "Marketing Content Agent",
- "tier": "marketing",
- "cron": "0 9 * * 1",
- "skills": ["start-governance-runtime", "marketing-content"],
- "promptTemplate": "marketing-content-agent",
- "description": "Weekly content generation — drafts LinkedIn posts, Twitter/X posts, and blog outlines"
- }
- ]
-}
diff --git a/packages/swarm/package.json b/packages/swarm/package.json
deleted file mode 100644
index c8b0d43a..00000000
--- a/packages/swarm/package.json
+++ /dev/null
@@ -1,38 +0,0 @@
-{
- "name": "@red-codes/swarm",
- "version": "2.9.3",
- "description": "Agent swarm templates and scaffolder for AgentGuard",
- "type": "module",
- "main": "dist/index.js",
- "types": "dist/index.d.ts",
- "exports": {
- ".": {
- "import": "./dist/index.js",
- "types": "./dist/index.d.ts"
- }
- },
- "files": [
- "dist",
- "manifest.json",
- "templates"
- ],
- "scripts": {
- "build": "tsc -b",
- "ts:check": "tsc --noEmit",
- "test": "vitest run",
- "lint": "eslint src/"
- },
- "dependencies": {
- "yaml": "^2.8.3"
- },
- "devDependencies": {
- "vitest": "^4.1.0",
- "typescript": "^5.8.3"
- },
- "keywords": [
- "agentguard",
- "swarm",
- "agent",
- "scaffolder"
- ]
-}
diff --git a/packages/swarm/src/config.ts b/packages/swarm/src/config.ts
deleted file mode 100644
index ad3e784a..00000000
--- a/packages/swarm/src/config.ts
+++ /dev/null
@@ -1,61 +0,0 @@
-import { readFileSync, existsSync } from 'node:fs';
-import { join, dirname } from 'node:path';
-import { fileURLToPath } from 'node:url';
-import { parse as parseYaml } from 'yaml';
-import type { SwarmConfig, SwarmTier } from './types.js';
-
-const __dirname = dirname(fileURLToPath(import.meta.url));
-const PACKAGE_ROOT = join(__dirname, '..');
-const DEFAULT_CONFIG_PATH = join(
- PACKAGE_ROOT,
- 'templates',
- 'config',
- 'agentguard-swarm.default.yaml'
-);
-
-export function loadDefaultConfig(): SwarmConfig {
- const raw = readFileSync(DEFAULT_CONFIG_PATH, 'utf8');
- return parseYaml(raw) as SwarmConfig;
-}
-
-export function loadConfig(projectRoot: string): SwarmConfig {
- const configPath = join(projectRoot, 'agentguard-swarm.yaml');
- const defaults = loadDefaultConfig();
-
- if (!existsSync(configPath)) {
- return defaults;
- }
-
- const raw = readFileSync(configPath, 'utf8');
- const userConfig = parseYaml(raw) as Partial;
-
- return mergeConfig(defaults, userConfig);
-}
-
-function mergeConfig(defaults: SwarmConfig, overrides: Partial): SwarmConfig {
- const user = overrides.swarm ?? {};
-
- return {
- swarm: {
- tiers: (user as Record).tiers
- ? ((user as Record).tiers as SwarmTier[])
- : defaults.swarm.tiers,
- schedules: {
- ...defaults.swarm.schedules,
- ...((user as Record).schedules as Record | undefined),
- },
- paths: {
- ...defaults.swarm.paths,
- ...((user as Record).paths as Record | undefined),
- },
- labels: {
- ...defaults.swarm.labels,
- ...((user as Record).labels as Record | undefined),
- },
- thresholds: {
- ...defaults.swarm.thresholds,
- ...((user as Record).thresholds as Record | undefined),
- },
- },
- };
-}
diff --git a/packages/swarm/src/index.ts b/packages/swarm/src/index.ts
deleted file mode 100644
index 2dda42af..00000000
--- a/packages/swarm/src/index.ts
+++ /dev/null
@@ -1,45 +0,0 @@
-export { scaffold, scaffoldSquad } from './scaffolder.js';
-export type { ScaffoldOptions } from './scaffolder.js';
-export { loadConfig, loadDefaultConfig } from './config.js';
-export { loadManifest, filterAgentsByTier, resolveSchedule, collectSkills } from './manifest.js';
-export { loadSquadManifest, buildAgentIdentity, parseAgentIdentity } from './squad-manifest.js';
-export {
- readSquadState,
- writeSquadState,
- readEMReport,
- writeEMReport,
- readDirectorBrief,
- writeDirectorBrief,
-} from './squad-state.js';
-export { checkLoopGuards } from './loop-guards.js';
-export {
- SWARM_MANIFEST_SCHEMA,
- SQUAD_MANIFEST_SCHEMA,
- SWARM_CONFIG_SCHEMA,
- validateSwarmManifest,
- validateSquadManifest,
- validateSwarmConfig,
-} from './schema.js';
-export type { ValidationError, ValidationResult } from './schema.js';
-export type { LoopGuardContext, GuardViolation, LoopGuardResult } from './loop-guards.js';
-export type {
- SwarmAgent,
- SwarmConfig,
- SwarmManifest,
- SwarmTier,
- SwarmPaths,
- SwarmLabels,
- SwarmThresholds,
- ScaffoldResult,
- ScaffoldedAgent,
- SquadRank,
- AgentDriver,
- AgentModel,
- SquadAgent,
- Squad,
- SquadManifest,
- LoopGuardConfig,
- SquadState,
- EMReport,
- DirectorBrief,
-} from './types.js';
diff --git a/packages/swarm/src/loop-guards.ts b/packages/swarm/src/loop-guards.ts
deleted file mode 100644
index ce8cd61f..00000000
--- a/packages/swarm/src/loop-guards.ts
+++ /dev/null
@@ -1,64 +0,0 @@
-import type { LoopGuardConfig, SquadState } from './types.js';
-
-export interface LoopGuardContext {
- retryCount: number;
- predictedFileChanges: number;
- runStartTime: number;
-}
-
-export type GuardViolation = 'budget' | 'retry' | 'blast-radius' | 'cascade' | 'time';
-
-export interface LoopGuardResult {
- allowed: boolean;
- violations: GuardViolation[];
- messages: string[];
-}
-
-export function checkLoopGuards(
- config: LoopGuardConfig,
- state: SquadState,
- context: LoopGuardContext
-): LoopGuardResult {
- const violations: GuardViolation[] = [];
- const messages: string[] = [];
-
- // 1. Budget guard
- if (state.prQueue.open >= config.maxOpenPRsPerSquad) {
- violations.push('budget');
- messages.push(
- `PR budget exceeded: ${state.prQueue.open} open (max ${config.maxOpenPRsPerSquad}). Skip implementation, focus on review/merge.`
- );
- }
-
- // 2. Retry guard
- if (context.retryCount > config.maxRetries) {
- violations.push('retry');
- messages.push(
- `Retry limit exceeded: ${context.retryCount} attempts (max ${config.maxRetries}). Create escalation issue.`
- );
- }
-
- // 3. Blast radius guard
- if (context.predictedFileChanges > config.maxBlastRadius) {
- violations.push('blast-radius');
- messages.push(
- `Blast radius exceeded: ${context.predictedFileChanges} files (max ${config.maxBlastRadius}). Escalate to Architect.`
- );
- }
-
- // 4. Time guard
- const elapsedMs = Date.now() - context.runStartTime;
- const elapsedMin = elapsedMs / 60_000;
- if (elapsedMin > config.maxRunMinutes) {
- violations.push('time');
- messages.push(
- `Run time exceeded: ${Math.round(elapsedMin)}min (max ${config.maxRunMinutes}min). Force-stop, EM investigates.`
- );
- }
-
- return {
- allowed: violations.length === 0,
- violations,
- messages,
- };
-}
diff --git a/packages/swarm/src/manifest.ts b/packages/swarm/src/manifest.ts
deleted file mode 100644
index 52fda677..00000000
--- a/packages/swarm/src/manifest.ts
+++ /dev/null
@@ -1,34 +0,0 @@
-import { readFileSync } from 'node:fs';
-import { join, dirname } from 'node:path';
-import { fileURLToPath } from 'node:url';
-import type { SwarmManifest, SwarmAgent, SwarmConfig, SwarmTier } from './types.js';
-
-const __dirname = dirname(fileURLToPath(import.meta.url));
-const PACKAGE_ROOT = join(__dirname, '..');
-const MANIFEST_PATH = join(PACKAGE_ROOT, 'manifest.json');
-
-export function loadManifest(): SwarmManifest {
- const raw = readFileSync(MANIFEST_PATH, 'utf8');
- return JSON.parse(raw) as SwarmManifest;
-}
-
-export function filterAgentsByTier(
- agents: readonly SwarmAgent[],
- enabledTiers: readonly SwarmTier[]
-): SwarmAgent[] {
- return agents.filter((a) => enabledTiers.includes(a.tier));
-}
-
-export function resolveSchedule(agent: SwarmAgent, config: SwarmConfig): string {
- return config.swarm.schedules[agent.id] ?? agent.cron;
-}
-
-export function collectSkills(agents: readonly SwarmAgent[]): string[] {
- const seen = new Set();
- for (const agent of agents) {
- for (const skill of agent.skills) {
- seen.add(skill);
- }
- }
- return [...seen].sort();
-}
diff --git a/packages/swarm/src/scaffolder.ts b/packages/swarm/src/scaffolder.ts
deleted file mode 100644
index 32d9144c..00000000
--- a/packages/swarm/src/scaffolder.ts
+++ /dev/null
@@ -1,188 +0,0 @@
-import {
- readFileSync,
- writeFileSync,
- existsSync,
- mkdirSync,
- copyFileSync,
- readdirSync,
-} from 'node:fs';
-import { join, dirname } from 'node:path';
-import { fileURLToPath } from 'node:url';
-import { loadConfig } from './config.js';
-import { loadManifest, filterAgentsByTier, resolveSchedule, collectSkills } from './manifest.js';
-import type { SwarmConfig, ScaffoldResult, ScaffoldedAgent, Squad, SquadState } from './types.js';
-
-const __dirname = dirname(fileURLToPath(import.meta.url));
-const PACKAGE_ROOT = join(__dirname, '..');
-const TEMPLATES_DIR = join(PACKAGE_ROOT, 'templates');
-const SKILLS_TEMPLATE_DIR = join(TEMPLATES_DIR, 'skills');
-const PROMPTS_TEMPLATE_DIR = join(TEMPLATES_DIR, 'prompts');
-const DEFAULT_CONFIG_TEMPLATE = join(TEMPLATES_DIR, 'config', 'agentguard-swarm.default.yaml');
-
-export interface ScaffoldOptions {
- readonly projectRoot: string;
- readonly force?: boolean;
- readonly tiers?: readonly string[];
-}
-
-export function scaffold(options: ScaffoldOptions): ScaffoldResult {
- const { projectRoot, force = false } = options;
-
- // Write config file if it doesn't exist
- const configPath = join(projectRoot, 'agentguard-swarm.yaml');
- const configWritten = writeConfigIfMissing(configPath);
-
- // Load config (user's or default)
- const config = loadConfig(projectRoot);
-
- // Apply tier override from CLI flags
- const effectiveConfig: SwarmConfig = options.tiers
- ? {
- swarm: {
- ...config.swarm,
- tiers: options.tiers as SwarmConfig['swarm']['tiers'],
- },
- }
- : config;
-
- // Load manifest and filter agents
- const manifest = loadManifest();
- const enabledAgents = filterAgentsByTier(manifest.agents, effectiveConfig.swarm.tiers);
- const requiredSkills = collectSkills(enabledAgents);
-
- // Scaffold skills
- const skillsDir = join(projectRoot, '.claude', 'skills');
- mkdirSync(skillsDir, { recursive: true });
-
- let skillsWritten = 0;
- let skillsSkipped = 0;
-
- // Copy all available skill templates that are needed by enabled agents
- const availableTemplates = readdirSync(SKILLS_TEMPLATE_DIR).filter((f) => f.endsWith('.md'));
-
- for (const templateFile of availableTemplates) {
- const skillName = templateFile.replace('.md', '');
- if (!requiredSkills.includes(skillName)) {
- continue;
- }
-
- const targetPath = join(skillsDir, templateFile);
- if (existsSync(targetPath) && !force) {
- skillsSkipped++;
- continue;
- }
-
- const templateContent = readFileSync(join(SKILLS_TEMPLATE_DIR, templateFile), 'utf8');
- const rendered = renderTemplate(templateContent, effectiveConfig);
- writeFileSync(targetPath, rendered, 'utf8');
- skillsWritten++;
- }
-
- // Also copy skills that exist as templates but aren't in any agent's skill list
- // (utility skills like full-test, release-prepare, etc.)
- for (const templateFile of availableTemplates) {
- const skillName = templateFile.replace('.md', '');
- if (requiredSkills.includes(skillName)) {
- continue; // Already handled above
- }
-
- const targetPath = join(skillsDir, templateFile);
- if (existsSync(targetPath) && !force) {
- skillsSkipped++;
- continue;
- }
-
- const templateContent = readFileSync(join(SKILLS_TEMPLATE_DIR, templateFile), 'utf8');
- const rendered = renderTemplate(templateContent, effectiveConfig);
- writeFileSync(targetPath, rendered, 'utf8');
- skillsWritten++;
- }
-
- // Build agent entries with resolved prompts
- const agents: ScaffoldedAgent[] = enabledAgents.map((agent) => {
- const promptFile = join(PROMPTS_TEMPLATE_DIR, `${agent.promptTemplate}.md`);
- const promptContent = existsSync(promptFile) ? readFileSync(promptFile, 'utf8') : '';
- const renderedPrompt = renderTemplate(promptContent, effectiveConfig);
-
- return {
- id: agent.id,
- name: agent.name,
- tier: agent.tier,
- cron: resolveSchedule(agent, effectiveConfig),
- description: agent.description,
- prompt: renderedPrompt,
- };
- });
-
- return {
- skillsWritten,
- skillsSkipped,
- promptsWritten: agents.length,
- configWritten,
- agents,
- };
-}
-
-function writeConfigIfMissing(configPath: string): boolean {
- if (existsSync(configPath)) {
- return false;
- }
- copyFileSync(DEFAULT_CONFIG_TEMPLATE, configPath);
- return true;
-}
-
-export function scaffoldSquad(root: string, squadName: string, _squad: Squad): void {
- const squadDir = join(root, '.agentguard', 'squads', squadName);
- mkdirSync(squadDir, { recursive: true });
-
- // Write initial squad state if not present
- const statePath = join(squadDir, 'state.json');
- if (!existsSync(statePath)) {
- const initialState: SquadState = {
- squad: squadName,
- sprint: { goal: '', issues: [] },
- assignments: {},
- blockers: [],
- prQueue: { open: 0, reviewed: 0, mergeable: 0 },
- updatedAt: new Date().toISOString(),
- };
- writeFileSync(statePath, JSON.stringify(initialState, null, 2), 'utf8');
- }
-
- // Write learnings store if not present
- const learningsPath = join(squadDir, 'learnings.json');
- if (!existsSync(learningsPath)) {
- writeFileSync(learningsPath, '[]', 'utf8');
- }
-}
-
-function renderTemplate(content: string, config: SwarmConfig): string {
- const { paths, labels } = config.swarm;
-
- const replacements: Record = {
- 'paths.policy': paths.policy,
- 'paths.roadmap': paths.roadmap,
- 'paths.swarmState': paths.swarmState,
- 'paths.logs': paths.logs,
- 'paths.reports': paths.reports,
- 'paths.swarmLogs': paths.swarmLogs,
- 'paths.cli': paths.cli,
- 'labels.pending': labels.pending,
- 'labels.inProgress': labels.inProgress,
- 'labels.review': labels.review,
- 'labels.blocked': labels.blocked,
- 'labels.critical': labels.critical,
- 'labels.high': labels.high,
- 'labels.medium': labels.medium,
- 'labels.low': labels.low,
- 'labels.developer': labels.developer,
- 'labels.architect': labels.architect,
- 'labels.auditor': labels.auditor,
- };
-
- let result = content;
- for (const [key, value] of Object.entries(replacements)) {
- result = result.replaceAll(`<%= ${key} %>`, value);
- }
- return result;
-}
diff --git a/packages/swarm/src/schema.ts b/packages/swarm/src/schema.ts
deleted file mode 100644
index a31afad8..00000000
--- a/packages/swarm/src/schema.ts
+++ /dev/null
@@ -1,327 +0,0 @@
-// JSON Schema definitions for swarm template validation.
-// Provides compile-time type alignment and runtime validation for
-// swarm manifests, squad manifests, and swarm config files.
-
-import type { SwarmManifest, SquadManifest, SwarmConfig } from './types.js';
-
-/** JSON Schema for a single SwarmAgent entry. */
-const SWARM_AGENT_SCHEMA = {
- type: 'object',
- required: ['id', 'name', 'tier', 'cron', 'skills', 'promptTemplate', 'description'],
- additionalProperties: false,
- properties: {
- id: { type: 'string', minLength: 1, pattern: '^[a-z0-9][a-z0-9-]*$' },
- name: { type: 'string', minLength: 1 },
- tier: { type: 'string', enum: ['core', 'governance', 'ops', 'quality', 'marketing'] },
- cron: { type: 'string', minLength: 1 },
- skills: { type: 'array', items: { type: 'string', minLength: 1 } },
- promptTemplate: { type: 'string', minLength: 1 },
- description: { type: 'string', minLength: 1 },
- },
-} as const;
-
-/** JSON Schema for the swarm manifest (manifest.json). */
-export const SWARM_MANIFEST_SCHEMA = {
- $schema: 'https://json-schema.org/draft/2020-12/schema',
- title: 'AgentGuard Swarm Manifest',
- description: 'Defines the full set of agents available in an AgentGuard swarm.',
- type: 'object',
- required: ['version', 'agents'],
- additionalProperties: false,
- properties: {
- version: { type: 'string', pattern: '^\\d+\\.\\d+\\.\\d+$' },
- agents: { type: 'array', items: SWARM_AGENT_SCHEMA, minItems: 1 },
- },
-} as const;
-
-/** JSON Schema for a single SquadAgent entry. */
-const SQUAD_AGENT_SCHEMA = {
- type: 'object',
- required: ['id', 'rank', 'driver', 'model', 'cron', 'skills'],
- additionalProperties: false,
- properties: {
- id: { type: 'string', minLength: 1 },
- rank: {
- type: 'string',
- enum: ['director', 'em', 'product-lead', 'architect', 'senior', 'junior', 'qa'],
- },
- driver: { type: 'string', enum: ['claude-code', 'copilot-cli'] },
- model: { type: 'string', enum: ['opus', 'sonnet', 'haiku', 'copilot'] },
- cron: { type: 'string', minLength: 1 },
- skills: { type: 'array', items: { type: 'string' } },
- },
-} as const;
-
-/** JSON Schema for a Squad entry. */
-const SQUAD_SCHEMA = {
- type: 'object',
- required: ['name', 'repo', 'em', 'agents'],
- additionalProperties: false,
- properties: {
- name: { type: 'string', minLength: 1 },
- repo: { type: 'string', minLength: 1 },
- em: SQUAD_AGENT_SCHEMA,
- agents: { type: 'object', additionalProperties: SQUAD_AGENT_SCHEMA },
- },
-} as const;
-
-/** JSON Schema for the squad manifest (squad-manifest.yaml). */
-export const SQUAD_MANIFEST_SCHEMA = {
- $schema: 'https://json-schema.org/draft/2020-12/schema',
- title: 'AgentGuard Squad Manifest',
- description: 'Defines squad hierarchy, agent roles, and loop guard configuration.',
- type: 'object',
- required: ['version', 'org', 'squads', 'loopGuards'],
- additionalProperties: false,
- properties: {
- version: { type: 'string', pattern: '^\\d+\\.\\d+\\.\\d+$' },
- org: {
- type: 'object',
- required: ['director'],
- additionalProperties: false,
- properties: { director: SQUAD_AGENT_SCHEMA },
- },
- squads: { type: 'object', additionalProperties: SQUAD_SCHEMA },
- loopGuards: {
- type: 'object',
- required: ['maxOpenPRsPerSquad', 'maxRetries', 'maxBlastRadius', 'maxRunMinutes'],
- additionalProperties: false,
- properties: {
- maxOpenPRsPerSquad: { type: 'number', minimum: 1 },
- maxRetries: { type: 'number', minimum: 0 },
- maxBlastRadius: { type: 'number', minimum: 1 },
- maxRunMinutes: { type: 'number', minimum: 1 },
- },
- },
- },
-} as const;
-
-/** JSON Schema for swarm config (agentguard-swarm.yaml). */
-export const SWARM_CONFIG_SCHEMA = {
- $schema: 'https://json-schema.org/draft/2020-12/schema',
- title: 'AgentGuard Swarm Config',
- description: 'User-customizable swarm configuration for schedules, paths, and thresholds.',
- type: 'object',
- required: ['swarm'],
- additionalProperties: false,
- properties: {
- swarm: {
- type: 'object',
- required: ['tiers', 'schedules', 'paths', 'labels', 'thresholds'],
- additionalProperties: false,
- properties: {
- tiers: {
- type: 'array',
- items: {
- type: 'string',
- enum: ['core', 'governance', 'ops', 'quality', 'marketing'],
- },
- minItems: 1,
- },
- schedules: { type: 'object', additionalProperties: { type: 'string' } },
- paths: {
- type: 'object',
- required: ['policy', 'roadmap', 'swarmState', 'logs', 'reports', 'swarmLogs', 'cli'],
- additionalProperties: false,
- properties: {
- policy: { type: 'string' },
- roadmap: { type: 'string' },
- swarmState: { type: 'string' },
- logs: { type: 'string' },
- reports: { type: 'string' },
- swarmLogs: { type: 'string' },
- cli: { type: 'string' },
- },
- },
- labels: {
- type: 'object',
- additionalProperties: { type: 'string' },
- },
- thresholds: {
- type: 'object',
- required: ['maxOpenPRs', 'prStaleHours', 'blastRadiusHigh'],
- additionalProperties: false,
- properties: {
- maxOpenPRs: { type: 'number', minimum: 1 },
- prStaleHours: { type: 'number', minimum: 1 },
- blastRadiusHigh: { type: 'number', minimum: 1 },
- },
- },
- },
- },
- },
-} as const;
-
-// ---------------------------------------------------------------------------
-// Validation
-// ---------------------------------------------------------------------------
-
-export interface ValidationError {
- readonly path: string;
- readonly message: string;
-}
-
-export interface ValidationResult {
- readonly valid: boolean;
- readonly errors: readonly ValidationError[];
-}
-
-/**
- * Lightweight JSON Schema validator. Covers the subset of JSON Schema used by
- * our swarm schemas (type, required, enum, minLength, minimum, pattern,
- * additionalProperties, minItems). Does NOT implement the full spec — use a
- * library like Ajv for that. This is intentionally zero-dependency.
- */
-function validateValue(
- value: unknown,
- schema: Record,
- path: string
-): ValidationError[] {
- const errors: ValidationError[] = [];
-
- if (schema.type === 'object') {
- if (typeof value !== 'object' || value === null || Array.isArray(value)) {
- errors.push({ path, message: `Expected object, got ${typeof value}` });
- return errors;
- }
-
- const obj = value as Record;
- const required = (schema.required as string[] | undefined) ?? [];
- for (const key of required) {
- if (!(key in obj)) {
- errors.push({ path: `${path}.${key}`, message: 'Required property missing' });
- }
- }
-
- const properties =
- (schema.properties as Record> | undefined) ?? {};
- for (const [key, propSchema] of Object.entries(properties)) {
- if (key in obj) {
- errors.push(...validateValue(obj[key], propSchema, `${path}.${key}`));
- }
- }
-
- if (schema.additionalProperties === false) {
- for (const key of Object.keys(obj)) {
- if (!(key in properties)) {
- errors.push({ path: `${path}.${key}`, message: 'Unexpected additional property' });
- }
- }
- } else if (
- typeof schema.additionalProperties === 'object' &&
- schema.additionalProperties !== null
- ) {
- const addSchema = schema.additionalProperties as Record;
- for (const [key, val] of Object.entries(obj)) {
- if (!(key in properties)) {
- errors.push(...validateValue(val, addSchema, `${path}.${key}`));
- }
- }
- }
-
- return errors;
- }
-
- if (schema.type === 'array') {
- if (!Array.isArray(value)) {
- errors.push({ path, message: `Expected array, got ${typeof value}` });
- return errors;
- }
-
- const minItems = (schema.minItems as number | undefined) ?? 0;
- if (value.length < minItems) {
- errors.push({ path, message: `Array must have at least ${minItems} items` });
- }
-
- if (schema.items && typeof schema.items === 'object') {
- const itemSchema = schema.items as Record;
- for (let i = 0; i < value.length; i++) {
- errors.push(...validateValue(value[i], itemSchema, `${path}[${i}]`));
- }
- }
-
- return errors;
- }
-
- if (schema.type === 'string') {
- if (typeof value !== 'string') {
- errors.push({ path, message: `Expected string, got ${typeof value}` });
- return errors;
- }
-
- const minLength = (schema.minLength as number | undefined) ?? 0;
- if (value.length < minLength) {
- errors.push({ path, message: `String must be at least ${minLength} characters` });
- }
-
- if (schema.pattern) {
- const regex = new RegExp(schema.pattern as string);
- if (!regex.test(value)) {
- errors.push({ path, message: `String does not match pattern ${schema.pattern}` });
- }
- }
-
- if (schema.enum && Array.isArray(schema.enum)) {
- if (!schema.enum.includes(value)) {
- errors.push({
- path,
- message: `Value must be one of: ${(schema.enum as string[]).join(', ')}`,
- });
- }
- }
-
- return errors;
- }
-
- if (schema.type === 'number') {
- if (typeof value !== 'number') {
- errors.push({ path, message: `Expected number, got ${typeof value}` });
- return errors;
- }
-
- if (schema.minimum !== undefined && value < (schema.minimum as number)) {
- errors.push({ path, message: `Value must be >= ${schema.minimum}` });
- }
- }
-
- return errors;
-}
-
-/** Validate a swarm manifest object against its schema. */
-export function validateSwarmManifest(manifest: unknown): ValidationResult {
- const errors = validateValue(
- manifest,
- SWARM_MANIFEST_SCHEMA as unknown as Record,
- '$'
- );
- return { valid: errors.length === 0, errors };
-}
-
-/** Validate a squad manifest object against its schema. */
-export function validateSquadManifest(manifest: unknown): ValidationResult {
- const errors = validateValue(
- manifest,
- SQUAD_MANIFEST_SCHEMA as unknown as Record,
- '$'
- );
- return { valid: errors.length === 0, errors };
-}
-
-/** Validate a swarm config object against its schema. */
-export function validateSwarmConfig(config: unknown): ValidationResult {
- const errors = validateValue(
- config,
- SWARM_CONFIG_SCHEMA as unknown as Record,
- '$'
- );
- return { valid: errors.length === 0, errors };
-}
-
-// Type-level assertions to ensure schemas stay aligned with TypeScript interfaces.
-// These are compile-time only — no runtime cost.
-type _AssertManifest = SwarmManifest;
-type _AssertSquadManifest = SquadManifest;
-type _AssertConfig = SwarmConfig;
-void (0 as unknown as _AssertManifest);
-void (0 as unknown as _AssertSquadManifest);
-void (0 as unknown as _AssertConfig);
diff --git a/packages/swarm/src/squad-manifest.ts b/packages/swarm/src/squad-manifest.ts
deleted file mode 100644
index 12a0d65e..00000000
--- a/packages/swarm/src/squad-manifest.ts
+++ /dev/null
@@ -1,75 +0,0 @@
-import { parse } from 'yaml';
-import type { SquadManifest, Squad, SquadAgent, LoopGuardConfig } from './types.js';
-
-export function loadSquadManifest(yamlContent: string): SquadManifest {
- const raw = parse(yamlContent) as Record;
-
- const org = raw.org as Record;
- const director = parseAgent(org.director as Record);
-
- const rawSquads = raw.squads as Record>;
- const squads: Record = {};
-
- for (const [name, rawSquad] of Object.entries(rawSquads)) {
- const em = parseAgent(rawSquad.em as Record);
- const rawAgents = rawSquad.agents as Record>;
- const agents: Record = {};
- for (const [role, rawAgent] of Object.entries(rawAgents)) {
- agents[role] = parseAgent(rawAgent);
- }
- squads[name] = {
- name,
- repo: rawSquad.repo as string,
- em,
- agents,
- };
- }
-
- const rawGuards = raw.loopGuards as Record;
- const loopGuards: LoopGuardConfig = {
- maxOpenPRsPerSquad: rawGuards.maxOpenPRsPerSquad ?? 3,
- maxRetries: rawGuards.maxRetries ?? 3,
- maxBlastRadius: rawGuards.maxBlastRadius ?? 20,
- maxRunMinutes: rawGuards.maxRunMinutes ?? 10,
- };
-
- return {
- version: raw.version as string,
- org: { director },
- squads,
- loopGuards,
- };
-}
-
-function parseAgent(raw: Record): SquadAgent {
- return {
- id: raw.id as string,
- rank: raw.rank as SquadAgent['rank'],
- driver: raw.driver as SquadAgent['driver'],
- model: raw.model as SquadAgent['model'],
- cron: raw.cron as string,
- skills: (raw.skills as string[]) ?? [],
- };
-}
-
-/** Build the 4-part identity string: driver:model:squad:rank */
-export function buildAgentIdentity(agent: SquadAgent, squadName: string): string {
- return `${agent.driver}:${agent.model}:${squadName}:${agent.rank}`;
-}
-
-/** Parse a 4-part identity string back into components */
-export function parseAgentIdentity(identity: string): {
- driver: string;
- model: string;
- squad: string;
- rank: string;
-} | null {
- const parts = identity.split(':');
- if (parts.length < 4) return null;
- return {
- driver: parts[0],
- model: parts[1],
- squad: parts[2],
- rank: parts[3],
- };
-}
diff --git a/packages/swarm/src/squad-state.ts b/packages/swarm/src/squad-state.ts
deleted file mode 100644
index 1e47de16..00000000
--- a/packages/swarm/src/squad-state.ts
+++ /dev/null
@@ -1,59 +0,0 @@
-import { readFileSync, writeFileSync, existsSync, mkdirSync } from 'node:fs';
-import { join } from 'node:path';
-import type { SquadState, EMReport, DirectorBrief } from './types.js';
-
-function squadDir(root: string, squad: string): string {
- return join(root, '.agentguard', 'squads', squad);
-}
-
-function ensureDir(dir: string): void {
- if (!existsSync(dir)) mkdirSync(dir, { recursive: true });
-}
-
-export function readSquadState(root: string, squad: string): SquadState | null {
- const path = join(squadDir(root, squad), 'state.json');
- if (!existsSync(path)) return null;
- try {
- return JSON.parse(readFileSync(path, 'utf8')) as SquadState;
- } catch {
- return null;
- }
-}
-
-export function writeSquadState(root: string, squad: string, state: SquadState): void {
- const dir = squadDir(root, squad);
- ensureDir(dir);
- writeFileSync(join(dir, 'state.json'), JSON.stringify(state, null, 2), 'utf8');
-}
-
-export function readEMReport(root: string, squad: string): EMReport | null {
- const path = join(squadDir(root, squad), 'em-report.json');
- if (!existsSync(path)) return null;
- try {
- return JSON.parse(readFileSync(path, 'utf8')) as EMReport;
- } catch {
- return null;
- }
-}
-
-export function writeEMReport(root: string, squad: string, report: EMReport): void {
- const dir = squadDir(root, squad);
- ensureDir(dir);
- writeFileSync(join(dir, 'em-report.json'), JSON.stringify(report, null, 2), 'utf8');
-}
-
-export function readDirectorBrief(root: string): DirectorBrief | null {
- const path = join(root, '.agentguard', 'director-brief.json');
- if (!existsSync(path)) return null;
- try {
- return JSON.parse(readFileSync(path, 'utf8')) as DirectorBrief;
- } catch {
- return null;
- }
-}
-
-export function writeDirectorBrief(root: string, brief: DirectorBrief): void {
- const dir = join(root, '.agentguard');
- ensureDir(dir);
- writeFileSync(join(dir, 'director-brief.json'), JSON.stringify(brief, null, 2), 'utf8');
-}
diff --git a/packages/swarm/src/types.ts b/packages/swarm/src/types.ts
deleted file mode 100644
index 81dab3df..00000000
--- a/packages/swarm/src/types.ts
+++ /dev/null
@@ -1,166 +0,0 @@
-export interface SwarmAgent {
- readonly id: string;
- readonly name: string;
- readonly tier: SwarmTier;
- readonly cron: string;
- readonly skills: readonly string[];
- readonly promptTemplate: string;
- readonly description: string;
-}
-
-export type SwarmTier = 'core' | 'governance' | 'ops' | 'quality' | 'marketing';
-
-export interface SwarmManifest {
- readonly version: string;
- readonly agents: readonly SwarmAgent[];
-}
-
-export interface SwarmPaths {
- readonly policy: string;
- readonly roadmap: string;
- readonly swarmState: string;
- readonly logs: string;
- readonly reports: string;
- readonly swarmLogs: string;
- readonly cli: string;
-}
-
-export interface SwarmLabels {
- readonly pending: string;
- readonly inProgress: string;
- readonly review: string;
- readonly blocked: string;
- readonly critical: string;
- readonly high: string;
- readonly medium: string;
- readonly low: string;
- readonly developer: string;
- readonly architect: string;
- readonly auditor: string;
-}
-
-export interface SwarmThresholds {
- readonly maxOpenPRs: number;
- readonly prStaleHours: number;
- readonly blastRadiusHigh: number;
-}
-
-export interface SwarmConfig {
- readonly swarm: {
- readonly tiers: readonly SwarmTier[];
- readonly schedules: Readonly>;
- readonly paths: SwarmPaths;
- readonly labels: SwarmLabels;
- readonly thresholds: SwarmThresholds;
- };
-}
-
-export interface ScaffoldResult {
- readonly skillsWritten: number;
- readonly skillsSkipped: number;
- readonly promptsWritten: number;
- readonly configWritten: boolean;
- readonly agents: readonly ScaffoldedAgent[];
-}
-
-export interface ScaffoldedAgent {
- readonly id: string;
- readonly name: string;
- readonly tier: SwarmTier;
- readonly cron: string;
- readonly description: string;
- readonly prompt: string;
-}
-
-// --- Squad hierarchy types ---
-
-export type SquadRank =
- | 'director'
- | 'em'
- | 'product-lead'
- | 'architect'
- | 'senior'
- | 'junior'
- | 'qa';
-export type AgentDriver = 'claude-code' | 'copilot-cli';
-export type AgentModel = 'opus' | 'sonnet' | 'haiku' | 'copilot';
-
-export interface SquadAgent {
- readonly id: string;
- readonly rank: SquadRank;
- readonly driver: AgentDriver;
- readonly model: AgentModel;
- readonly cron: string;
- readonly skills: readonly string[];
-}
-
-export interface Squad {
- readonly name: string;
- readonly repo: string; // repo name or '*' for cross-repo
- readonly em: SquadAgent;
- readonly agents: Readonly>;
-}
-
-export interface SquadManifest {
- readonly version: string;
- readonly org: {
- readonly director: SquadAgent;
- };
- readonly squads: Readonly>;
- readonly loopGuards: LoopGuardConfig;
-}
-
-export interface LoopGuardConfig {
- readonly maxOpenPRsPerSquad: number;
- readonly maxRetries: number;
- readonly maxBlastRadius: number;
- readonly maxRunMinutes: number;
-}
-
-export interface SquadState {
- readonly squad: string;
- readonly sprint: {
- readonly goal: string;
- readonly issues: readonly string[];
- };
- readonly assignments: Readonly<
- Record<
- string,
- {
- readonly current: string | null;
- readonly status: string;
- readonly waiting?: string;
- }
- >
- >;
- readonly blockers: readonly string[];
- readonly prQueue: {
- readonly open: number;
- readonly reviewed: number;
- readonly mergeable: number;
- };
- readonly updatedAt: string;
-}
-
-export interface EMReport {
- readonly squad: string;
- readonly timestamp: string;
- readonly health: 'green' | 'yellow' | 'red';
- readonly summary: string;
- readonly blockers: readonly string[];
- readonly escalations: readonly string[];
- readonly metrics: {
- readonly prsOpened: number;
- readonly prsMerged: number;
- readonly issuesClosed: number;
- readonly denials: number;
- readonly retries: number;
- };
-}
-
-export interface DirectorBrief {
- readonly timestamp: string;
- readonly squads: Readonly>;
- readonly escalationsForHuman: readonly string[];
- readonly overallHealth: 'green' | 'yellow' | 'red';
-}
diff --git a/packages/swarm/templates/config/agentguard-swarm.default.yaml b/packages/swarm/templates/config/agentguard-swarm.default.yaml
deleted file mode 100644
index 554dd2af..00000000
--- a/packages/swarm/templates/config/agentguard-swarm.default.yaml
+++ /dev/null
@@ -1,51 +0,0 @@
-# AgentGuard Swarm Configuration
-# Generated by: agentguard init swarm
-# Customize values below to adapt the swarm to your project.
-
-swarm:
- # Which agent tiers to install.
- # core: coder, reviewer, merger, CI triage, branch janitor, merge conflict resolver, PR review responder
- # governance: risk escalation, recovery controller, governance monitor, policy effectiveness
- # ops: planning, observability, retrospective, docs sync, product health, progress controller, backlog steward, repo hygiene
- # quality: test agent, security audit, architecture review, CI/CD hardening, test generation, audit merged PRs
- # marketing: marketing content generator
- tiers:
- - core
- - governance
- - ops
- - quality
- - marketing
-
- # Override cron schedules per agent (local time, 5-field cron).
- # Agents not listed here use the default from manifest.json.
- schedules: {}
-
- # Project-specific paths.
- paths:
- policy: agentguard.yaml
- roadmap: ROADMAP.md
- swarmState: .agentguard/swarm-state.json
- logs: logs/runtime-events.jsonl
- reports: .agentguard/reports
- swarmLogs: .agentguard/logs/swarm.log
- cli: node apps/cli/dist/bin.js
-
- # GitHub label scheme used by the swarm for issue/PR management.
- labels:
- pending: 'status:pending'
- inProgress: 'status:in-progress'
- review: 'status:review'
- blocked: 'status:blocked'
- critical: 'priority:critical'
- high: 'priority:high'
- medium: 'priority:medium'
- low: 'priority:low'
- developer: 'role:developer'
- architect: 'role:architect'
- auditor: 'role:auditor'
-
- # Thresholds for swarm behavior.
- thresholds:
- maxOpenPRs: 5
- prStaleHours: 48
- blastRadiusHigh: 16
diff --git a/packages/swarm/templates/config/squad-manifest.default.yaml b/packages/swarm/templates/config/squad-manifest.default.yaml
deleted file mode 100644
index f48377da..00000000
--- a/packages/swarm/templates/config/squad-manifest.default.yaml
+++ /dev/null
@@ -1,206 +0,0 @@
-version: "1.0.0"
-
-org:
- director:
- id: director
- rank: director
- driver: claude-code
- model: opus
- cron: "0 7,19 * * *"
- skills: [squad-status, director-brief, escalation-router]
-
-squads:
- kernel:
- name: Kernel
- repo: agent-guard
- em:
- id: kernel-em
- rank: em
- driver: claude-code
- model: opus
- cron: "0 */3 * * *"
- skills: [squad-plan, squad-execute, squad-status, squad-retro, escalation-router]
- agents:
- product-lead:
- id: kernel-pl
- rank: product-lead
- driver: claude-code
- model: sonnet
- cron: "0 6 * * *"
- skills: [sprint-planning, roadmap-expand, backlog-steward, learn]
- architect:
- id: kernel-arch
- rank: architect
- driver: claude-code
- model: opus
- cron: "0 */4 * * *"
- skills: [architecture-review, review-open-prs, eval, evolve]
- senior:
- id: kernel-sr
- rank: senior
- driver: copilot-cli
- model: sonnet
- cron: "0 */2 * * *"
- skills: [claim-issue, implement-issue, create-pr, run-tests]
- junior:
- id: kernel-jr
- rank: junior
- driver: copilot-cli
- model: copilot
- cron: "0 */2 * * *"
- skills: [claim-issue, implement-issue, run-tests, generate-tests]
- qa:
- id: kernel-qa
- rank: qa
- driver: copilot-cli
- model: sonnet
- cron: "0 */3 * * *"
- skills: [e2e-testing, compliance-test, test-health-review, learn, prune]
-
- cloud:
- name: Cloud
- repo: agentguard-cloud
- em:
- id: cloud-em
- rank: em
- driver: claude-code
- model: opus
- cron: "0 */3 * * *"
- skills: [squad-plan, squad-execute, squad-status, squad-retro, escalation-router]
- agents:
- product-lead:
- id: cloud-pl
- rank: product-lead
- driver: claude-code
- model: sonnet
- cron: "0 6 * * *"
- skills: [sprint-planning, roadmap-expand, backlog-steward, learn]
- architect:
- id: cloud-arch
- rank: architect
- driver: claude-code
- model: opus
- cron: "0 */4 * * *"
- skills: [architecture-review, review-open-prs, eval, evolve]
- senior:
- id: cloud-sr
- rank: senior
- driver: copilot-cli
- model: sonnet
- cron: "0 */2 * * *"
- skills: [claim-issue, implement-issue, create-pr, run-tests]
- junior:
- id: cloud-jr
- rank: junior
- driver: copilot-cli
- model: copilot
- cron: "0 */2 * * *"
- skills: [claim-issue, implement-issue, run-tests, generate-tests]
- qa:
- id: cloud-qa
- rank: qa
- driver: copilot-cli
- model: sonnet
- cron: "0 */3 * * *"
- skills: [e2e-testing, compliance-test, test-health-review, learn, prune]
-
- qa:
- name: QA
- repo: "*"
- em:
- id: qa-em
- rank: em
- driver: claude-code
- model: sonnet
- cron: "0 */3 * * *"
- skills: [squad-plan, squad-execute, squad-status, squad-retro, escalation-router]
- agents:
- product-lead:
- id: qa-pl
- rank: product-lead
- driver: claude-code
- model: sonnet
- cron: "0 6 * * *"
- skills: [sprint-planning, test-strategy, stranger-test-plan, learn]
- architect:
- id: qa-arch
- rank: architect
- driver: claude-code
- model: sonnet
- cron: "0 */4 * * *"
- skills: [test-architecture, compliance-review, eval, evolve]
- senior:
- id: qa-sr
- rank: senior
- driver: copilot-cli
- model: sonnet
- cron: "0 */2 * * *"
- skills: [playwright-e2e, stranger-test-run, compliance-test, create-pr]
- junior:
- id: qa-jr
- rank: junior
- driver: copilot-cli
- model: copilot
- cron: "0 */2 * * *"
- skills: [generate-tests, run-tests, test-data-generation]
- qa:
- id: qa-qa
- rank: qa
- driver: copilot-cli
- model: haiku
- cron: "0 */1 * * *"
- skills: [e2e-testing, regression-analysis, flakiness-detection, learn, prune]
-
-
- studio:
- name: Studio
- repo: agentguard-workspace
- em:
- id: studio-em
- rank: em
- driver: claude-code
- model: opus
- cron: "0 */3 * * *"
- skills: [squad-plan, squad-execute, squad-status, squad-retro, escalation-router]
- agents:
- product-lead:
- id: studio-pl
- rank: product-lead
- driver: claude-code
- model: sonnet
- cron: "0 6 * * *"
- skills: [sprint-planning, roadmap-expand, backlog-steward, learn]
- architect:
- id: studio-arch
- rank: architect
- driver: claude-code
- model: opus
- cron: "0 */4 * * *"
- skills: [architecture-review, review-open-prs, eval, evolve]
- senior:
- id: studio-sr
- rank: senior
- driver: copilot-cli
- model: sonnet
- cron: "0 */2 * * *"
- skills: [claim-issue, implement-issue, create-pr, run-tests]
- junior:
- id: studio-jr
- rank: junior
- driver: copilot-cli
- model: copilot
- cron: "0 */2 * * *"
- skills: [claim-issue, implement-issue, run-tests, generate-tests]
- qa:
- id: studio-qa
- rank: qa
- driver: copilot-cli
- model: sonnet
- cron: "0 */3 * * *"
- skills: [e2e-testing, compliance-test, test-health-review, learn, prune]
-
-loopGuards:
- maxOpenPRsPerSquad: 3
- maxRetries: 3
- maxBlastRadius: 20
- maxRunMinutes: 10
diff --git a/packages/swarm/templates/prompts/architect-agent.md b/packages/swarm/templates/prompts/architect-agent.md
deleted file mode 100644
index 3f09a642..00000000
--- a/packages/swarm/templates/prompts/architect-agent.md
+++ /dev/null
@@ -1,18 +0,0 @@
-You are the Architect Agent for this repository. You perform architecture reviews of open pull requests.
-
-## Autonomy Directive
-
-This is an unattended scheduled task. No human is present.
-
-- NEVER pause to ask for clarification — make your best judgment and proceed
-- NEVER use AskUserQuestion or any interactive prompt
-- Default to the safest option in every ambiguous situation
-
-## Task
-
-Execute these skills in order:
-
-1. `start-governance-runtime` — Start the governance kernel
-2. `architecture-review` — Review open PRs for architectural consistency, pattern adherence, and design quality
-
-If any skill reports STOP, end the run and report why.
diff --git a/packages/swarm/templates/prompts/audit-merged-prs-agent.md b/packages/swarm/templates/prompts/audit-merged-prs-agent.md
deleted file mode 100644
index bd913763..00000000
--- a/packages/swarm/templates/prompts/audit-merged-prs-agent.md
+++ /dev/null
@@ -1,18 +0,0 @@
-You are the Audit Merged PRs Agent for this repository. You audit recently merged pull requests for compliance and quality.
-
-## Autonomy Directive
-
-This is an unattended scheduled task. No human is present.
-
-- NEVER pause to ask for clarification — make your best judgment and proceed
-- NEVER use AskUserQuestion or any interactive prompt
-- Default to the safest option in every ambiguous situation
-
-## Task
-
-Execute these skills in order:
-
-1. `start-governance-runtime` — Start the governance kernel
-2. `audit-merged-prs` — Review recently merged PRs for governance compliance and quality issues
-
-If any skill reports STOP, end the run and report why.
diff --git a/packages/swarm/templates/prompts/backlog-steward.md b/packages/swarm/templates/prompts/backlog-steward.md
deleted file mode 100644
index 720c97f0..00000000
--- a/packages/swarm/templates/prompts/backlog-steward.md
+++ /dev/null
@@ -1,19 +0,0 @@
-You are the Backlog Steward for this repository. You manage the backlog and expand the roadmap with new issues.
-
-## Autonomy Directive
-
-This is an unattended scheduled task. No human is present.
-
-- NEVER pause to ask for clarification — make your best judgment and proceed
-- NEVER use AskUserQuestion or any interactive prompt
-- Default to the safest option in every ambiguous situation
-
-## Task
-
-Execute these skills in order:
-
-1. `start-governance-runtime` — Start the governance kernel
-2. `backlog-steward` — Groom and organize the issue backlog
-3. `roadmap-expand` — Identify gaps and create new issues to expand the roadmap
-
-If any skill reports STOP, end the run and report why.
diff --git a/packages/swarm/templates/prompts/ci-triage-agent.md b/packages/swarm/templates/prompts/ci-triage-agent.md
deleted file mode 100644
index 08d30a4e..00000000
--- a/packages/swarm/templates/prompts/ci-triage-agent.md
+++ /dev/null
@@ -1,23 +0,0 @@
-You are the CI Triage Agent for this repository. You fix failing CI on open PR branches.
-
-## Autonomy Directive
-
-This is an unattended scheduled task. No human is present.
-
-- NEVER pause to ask for clarification — make your best judgment and proceed
-- NEVER use AskUserQuestion or any interactive prompt
-- Default to the safest option in every ambiguous situation
-
-## Pre-flight Check
-
-If there are no open PRs with failing CI runs, report "No failing CI — skipping this run" and STOP.
-
-## Task
-
-Execute these skills in order:
-
-1. `start-governance-runtime` — Start the governance kernel
-2. `sync-main` — Sync local main branch with remote
-3. `triage-failing-ci` — Diagnose and fix failing CI on open PR branches
-
-If any skill reports STOP, end the run and report why.
diff --git a/packages/swarm/templates/prompts/cicd-hardening-agent.md b/packages/swarm/templates/prompts/cicd-hardening-agent.md
deleted file mode 100644
index 06f4a788..00000000
--- a/packages/swarm/templates/prompts/cicd-hardening-agent.md
+++ /dev/null
@@ -1,18 +0,0 @@
-You are the CI/CD Hardening Agent for this repository. You audit CI/CD pipelines for security, reliability, and performance.
-
-## Autonomy Directive
-
-This is an unattended scheduled task. No human is present.
-
-- NEVER pause to ask for clarification — make your best judgment and proceed
-- NEVER use AskUserQuestion or any interactive prompt
-- Default to the safest option in every ambiguous situation
-
-## Task
-
-Execute these skills in order:
-
-1. `start-governance-runtime` — Start the governance kernel
-2. `cicd-hardening-audit` — Audit CI/CD workflows for hardening opportunities
-
-If any skill reports STOP, end the run and report why.
diff --git a/packages/swarm/templates/prompts/code-review-agent.md b/packages/swarm/templates/prompts/code-review-agent.md
deleted file mode 100644
index f48a68ce..00000000
--- a/packages/swarm/templates/prompts/code-review-agent.md
+++ /dev/null
@@ -1,18 +0,0 @@
-You are the Code Review Agent for this repository. You review open pull requests for correctness, style, and safety.
-
-## Autonomy Directive
-
-This is an unattended scheduled task. No human is present.
-
-- NEVER pause to ask for clarification — make your best judgment and proceed
-- NEVER use AskUserQuestion or any interactive prompt
-- Default to the safest option in every ambiguous situation
-
-## Task
-
-Execute these skills in order:
-
-1. `start-governance-runtime` — Start the governance kernel
-2. `review-open-prs` — Review all open pull requests that need review
-
-If any skill reports STOP, end the run and report why.
diff --git a/packages/swarm/templates/prompts/coder-agent.md b/packages/swarm/templates/prompts/coder-agent.md
deleted file mode 100644
index 86f503f4..00000000
--- a/packages/swarm/templates/prompts/coder-agent.md
+++ /dev/null
@@ -1,33 +0,0 @@
-You are the Coder Agent for this repository. You pick up issues, implement them, and open pull requests.
-
-## Autonomy Directive
-
-This is an unattended scheduled task. No human is present.
-
-- NEVER pause to ask for clarification — make your best judgment and proceed
-- NEVER use AskUserQuestion or any interactive prompt
-- Default to the safest option in every ambiguous situation
-
-## Pre-flight Check
-
-Before starting, check the PR queue:
-
-```bash
-cat .agentguard/swarm-state.json 2>/dev/null
-```
-
-If `prQueueHealthy` is `false` or `openAgentPRs >= 5`, report "PR queue full — skipping this run" and STOP.
-
-## Task
-
-Execute these skills in order:
-
-1. `start-governance-runtime` — Start the governance kernel
-2. `sync-main` — Sync local main branch with remote
-3. `discover-next-issue` — Find the next unassigned issue to work on
-4. `claim-issue` — Claim the discovered issue so no other agent picks it up
-5. `implement-issue` — Implement the solution on a feature branch
-6. `run-tests` — Run the test suite and fix any failures
-7. `create-pr` — Open a pull request for the implementation
-
-If any skill reports STOP, end the run and report why.
diff --git a/packages/swarm/templates/prompts/docs-sync-agent.md b/packages/swarm/templates/prompts/docs-sync-agent.md
deleted file mode 100644
index 4d55be64..00000000
--- a/packages/swarm/templates/prompts/docs-sync-agent.md
+++ /dev/null
@@ -1,18 +0,0 @@
-You are the Docs Sync Agent for this repository. You keep documentation in sync with the codebase.
-
-## Autonomy Directive
-
-This is an unattended scheduled task. No human is present.
-
-- NEVER pause to ask for clarification — make your best judgment and proceed
-- NEVER use AskUserQuestion or any interactive prompt
-- Default to the safest option in every ambiguous situation
-
-## Task
-
-Execute these skills in order:
-
-1. `start-governance-runtime` — Start the governance kernel
-2. `scheduled-docs-sync` — Scan for documentation drift and update docs to match current code
-
-If any skill reports STOP, end the run and report why.
diff --git a/packages/swarm/templates/prompts/governance-monitor.md b/packages/swarm/templates/prompts/governance-monitor.md
deleted file mode 100644
index 8bc3e470..00000000
--- a/packages/swarm/templates/prompts/governance-monitor.md
+++ /dev/null
@@ -1,19 +0,0 @@
-You are the Governance Monitor for this repository. You audit governance logs and review policy effectiveness.
-
-## Autonomy Directive
-
-This is an unattended scheduled task. No human is present.
-
-- NEVER pause to ask for clarification — make your best judgment and proceed
-- NEVER use AskUserQuestion or any interactive prompt
-- Default to the safest option in every ambiguous situation
-
-## Task
-
-Execute these skills in order:
-
-1. `start-governance-runtime` — Start the governance kernel
-2. `governance-log-audit` — Audit recent governance logs for anomalies or violations
-3. `policy-effectiveness-review` — Review policy effectiveness and suggest improvements
-
-If any skill reports STOP, end the run and report why.
diff --git a/packages/swarm/templates/prompts/infrastructure-health-agent.md b/packages/swarm/templates/prompts/infrastructure-health-agent.md
deleted file mode 100644
index b02f9708..00000000
--- a/packages/swarm/templates/prompts/infrastructure-health-agent.md
+++ /dev/null
@@ -1,18 +0,0 @@
-You are the Infrastructure Health Agent for this repository. You monitor SDLC pipeline health and reliability.
-
-## Autonomy Directive
-
-This is an unattended scheduled task. No human is present.
-
-- NEVER pause to ask for clarification — make your best judgment and proceed
-- NEVER use AskUserQuestion or any interactive prompt
-- Default to the safest option in every ambiguous situation
-
-## Task
-
-Execute these skills in order:
-
-1. `start-governance-runtime` — Start the governance kernel
-2. `sdlc-pipeline-health` — Assess SDLC pipeline health, build times, and reliability metrics
-
-If any skill reports STOP, end the run and report why.
diff --git a/packages/swarm/templates/prompts/marketing-content-agent.md b/packages/swarm/templates/prompts/marketing-content-agent.md
deleted file mode 100644
index 02f98e89..00000000
--- a/packages/swarm/templates/prompts/marketing-content-agent.md
+++ /dev/null
@@ -1,18 +0,0 @@
-You are the Marketing Content Agent for this repository. You generate marketing content based on recent project activity.
-
-## Autonomy Directive
-
-This is an unattended scheduled task. No human is present.
-
-- NEVER pause to ask for clarification — make your best judgment and proceed
-- NEVER use AskUserQuestion or any interactive prompt
-- Default to the safest option in every ambiguous situation
-
-## Task
-
-Execute these skills in order:
-
-1. `start-governance-runtime` — Start the governance kernel
-2. `marketing-content` — Generate marketing content from recent project milestones and features
-
-If any skill reports STOP, end the run and report why.
diff --git a/packages/swarm/templates/prompts/merge-conflict-resolver.md b/packages/swarm/templates/prompts/merge-conflict-resolver.md
deleted file mode 100644
index f9698089..00000000
--- a/packages/swarm/templates/prompts/merge-conflict-resolver.md
+++ /dev/null
@@ -1,22 +0,0 @@
-You are the Merge Conflict Resolver for this repository. You rebase PRs that have merge conflicts against main.
-
-## Autonomy Directive
-
-This is an unattended scheduled task. No human is present.
-
-- NEVER pause to ask for clarification — make your best judgment and proceed
-- NEVER use AskUserQuestion or any interactive prompt
-- Default to the safest option in every ambiguous situation
-
-## Constraints
-
-Process at most 1 PR per run. If multiple PRs have conflicts, pick the oldest one.
-
-## Task
-
-Execute these skills in order:
-
-1. `start-governance-runtime` — Start the governance kernel
-2. `resolve-merge-conflicts` — Find a PR with merge conflicts, rebase it, and push
-
-If any skill reports STOP, end the run and report why.
diff --git a/packages/swarm/templates/prompts/observability-agent.md b/packages/swarm/templates/prompts/observability-agent.md
deleted file mode 100644
index 35a7bd34..00000000
--- a/packages/swarm/templates/prompts/observability-agent.md
+++ /dev/null
@@ -1,18 +0,0 @@
-You are the Observability Agent for this repository. You perform SRE-style analysis of system health and reliability.
-
-## Autonomy Directive
-
-This is an unattended scheduled task. No human is present.
-
-- NEVER pause to ask for clarification — make your best judgment and proceed
-- NEVER use AskUserQuestion or any interactive prompt
-- Default to the safest option in every ambiguous situation
-
-## Task
-
-Execute these skills in order:
-
-1. `start-governance-runtime` — Start the governance kernel
-2. `observability-review` — Analyze runtime telemetry, error rates, and system health
-
-If any skill reports STOP, end the run and report why.
diff --git a/packages/swarm/templates/prompts/planning-agent.md b/packages/swarm/templates/prompts/planning-agent.md
deleted file mode 100644
index ecc42e60..00000000
--- a/packages/swarm/templates/prompts/planning-agent.md
+++ /dev/null
@@ -1,18 +0,0 @@
-You are the Planning Agent for this repository. You perform sprint planning by analyzing the backlog and prioritizing work.
-
-## Autonomy Directive
-
-This is an unattended scheduled task. No human is present.
-
-- NEVER pause to ask for clarification — make your best judgment and proceed
-- NEVER use AskUserQuestion or any interactive prompt
-- Default to the safest option in every ambiguous situation
-
-## Task
-
-Execute these skills in order:
-
-1. `start-governance-runtime` — Start the governance kernel
-2. `sprint-planning` — Analyze the backlog, prioritize issues, and plan the next sprint
-
-If any skill reports STOP, end the run and report why.
diff --git a/packages/swarm/templates/prompts/pr-merger-agent.md b/packages/swarm/templates/prompts/pr-merger-agent.md
deleted file mode 100644
index ab64951c..00000000
--- a/packages/swarm/templates/prompts/pr-merger-agent.md
+++ /dev/null
@@ -1,18 +0,0 @@
-You are the PR Merger Agent for this repository. You auto-merge approved pull requests that have passing CI.
-
-## Autonomy Directive
-
-This is an unattended scheduled task. No human is present.
-
-- NEVER pause to ask for clarification — make your best judgment and proceed
-- NEVER use AskUserQuestion or any interactive prompt
-- Default to the safest option in every ambiguous situation
-
-## Task
-
-Execute these skills in order:
-
-1. `start-governance-runtime` — Start the governance kernel
-2. `pr-merger` — Find and merge approved PRs with passing CI checks
-
-If any skill reports STOP, end the run and report why.
diff --git a/packages/swarm/templates/prompts/pr-review-responder.md b/packages/swarm/templates/prompts/pr-review-responder.md
deleted file mode 100644
index c6e7af19..00000000
--- a/packages/swarm/templates/prompts/pr-review-responder.md
+++ /dev/null
@@ -1,18 +0,0 @@
-You are the PR Review Responder for this repository. You respond to review comments on agent-authored pull requests.
-
-## Autonomy Directive
-
-This is an unattended scheduled task. No human is present.
-
-- NEVER pause to ask for clarification — make your best judgment and proceed
-- NEVER use AskUserQuestion or any interactive prompt
-- Default to the safest option in every ambiguous situation
-
-## Task
-
-Execute these skills in order:
-
-1. `start-governance-runtime` — Start the governance kernel
-2. `respond-to-pr-reviews` — Address review comments on agent PRs with code changes or replies
-
-If any skill reports STOP, end the run and report why.
diff --git a/packages/swarm/templates/prompts/product-agent.md b/packages/swarm/templates/prompts/product-agent.md
deleted file mode 100644
index fb196283..00000000
--- a/packages/swarm/templates/prompts/product-agent.md
+++ /dev/null
@@ -1,18 +0,0 @@
-You are the Product Agent for this repository. You perform product health reviews to assess feature completeness and quality.
-
-## Autonomy Directive
-
-This is an unattended scheduled task. No human is present.
-
-- NEVER pause to ask for clarification — make your best judgment and proceed
-- NEVER use AskUserQuestion or any interactive prompt
-- Default to the safest option in every ambiguous situation
-
-## Task
-
-Execute these skills in order:
-
-1. `start-governance-runtime` — Start the governance kernel
-2. `product-health-review` — Assess product health, feature completeness, and quality metrics
-
-If any skill reports STOP, end the run and report why.
diff --git a/packages/swarm/templates/prompts/progress-controller.md b/packages/swarm/templates/prompts/progress-controller.md
deleted file mode 100644
index 7c502d7a..00000000
--- a/packages/swarm/templates/prompts/progress-controller.md
+++ /dev/null
@@ -1,18 +0,0 @@
-You are the Progress Controller for this repository. You track roadmap phase progress and update milestones.
-
-## Autonomy Directive
-
-This is an unattended scheduled task. No human is present.
-
-- NEVER pause to ask for clarification — make your best judgment and proceed
-- NEVER use AskUserQuestion or any interactive prompt
-- Default to the safest option in every ambiguous situation
-
-## Task
-
-Execute these skills in order:
-
-1. `start-governance-runtime` — Start the governance kernel
-2. `progress-controller` — Track roadmap phase progress, update milestones, and flag blockers
-
-If any skill reports STOP, end the run and report why.
diff --git a/packages/swarm/templates/prompts/recovery-controller.md b/packages/swarm/templates/prompts/recovery-controller.md
deleted file mode 100644
index 710daf09..00000000
--- a/packages/swarm/templates/prompts/recovery-controller.md
+++ /dev/null
@@ -1,18 +0,0 @@
-You are the Recovery Controller for this repository. You perform self-healing checks on swarm health and recover from failures.
-
-## Autonomy Directive
-
-This is an unattended scheduled task. No human is present.
-
-- NEVER pause to ask for clarification — make your best judgment and proceed
-- NEVER use AskUserQuestion or any interactive prompt
-- Default to the safest option in every ambiguous situation
-
-## Task
-
-Execute these skills in order:
-
-1. `start-governance-runtime` — Start the governance kernel
-2. `recovery-controller` — Assess swarm health and recover from stuck or failed states
-
-If any skill reports STOP, end the run and report why.
diff --git a/packages/swarm/templates/prompts/repo-hygiene-agent.md b/packages/swarm/templates/prompts/repo-hygiene-agent.md
deleted file mode 100644
index 855b3e0c..00000000
--- a/packages/swarm/templates/prompts/repo-hygiene-agent.md
+++ /dev/null
@@ -1,18 +0,0 @@
-You are the Repo Hygiene Agent for this repository. You manage stale issues and close solved issues.
-
-## Autonomy Directive
-
-This is an unattended scheduled task. No human is present.
-
-- NEVER pause to ask for clarification — make your best judgment and proceed
-- NEVER use AskUserQuestion or any interactive prompt
-- Default to the safest option in every ambiguous situation
-
-## Task
-
-Execute these skills in order:
-
-1. `start-governance-runtime` — Start the governance kernel
-2. `repo-hygiene` — Identify stale issues, close solved issues, and clean up the issue tracker
-
-If any skill reports STOP, end the run and report why.
diff --git a/packages/swarm/templates/prompts/retrospective-agent.md b/packages/swarm/templates/prompts/retrospective-agent.md
deleted file mode 100644
index 748b7e3a..00000000
--- a/packages/swarm/templates/prompts/retrospective-agent.md
+++ /dev/null
@@ -1,18 +0,0 @@
-You are the Retrospective Agent for this repository. You run weekly retrospectives on swarm performance.
-
-## Autonomy Directive
-
-This is an unattended scheduled task. No human is present.
-
-- NEVER pause to ask for clarification — make your best judgment and proceed
-- NEVER use AskUserQuestion or any interactive prompt
-- Default to the safest option in every ambiguous situation
-
-## Task
-
-Execute these skills in order:
-
-1. `start-governance-runtime` — Start the governance kernel
-2. `retrospective` — Analyze the past week of swarm activity and produce a retrospective report
-
-If any skill reports STOP, end the run and report why.
diff --git a/packages/swarm/templates/prompts/risk-escalation-agent.md b/packages/swarm/templates/prompts/risk-escalation-agent.md
deleted file mode 100644
index 920d8f8e..00000000
--- a/packages/swarm/templates/prompts/risk-escalation-agent.md
+++ /dev/null
@@ -1,18 +0,0 @@
-You are the Risk Escalation Agent for this repository. You assess cumulative risk across the swarm and escalate when thresholds are exceeded.
-
-## Autonomy Directive
-
-This is an unattended scheduled task. No human is present.
-
-- NEVER pause to ask for clarification — make your best judgment and proceed
-- NEVER use AskUserQuestion or any interactive prompt
-- Default to the safest option in every ambiguous situation
-
-## Task
-
-Execute these skills in order:
-
-1. `start-governance-runtime` — Start the governance kernel
-2. `risk-escalation` — Assess cumulative risk from recent governance sessions and escalate if needed
-
-If any skill reports STOP, end the run and report why.
diff --git a/packages/swarm/templates/prompts/security-audit-agent.md b/packages/swarm/templates/prompts/security-audit-agent.md
deleted file mode 100644
index 1c2ecfa4..00000000
--- a/packages/swarm/templates/prompts/security-audit-agent.md
+++ /dev/null
@@ -1,19 +0,0 @@
-You are the Security Audit Agent for this repository. You scan dependencies and code for security vulnerabilities.
-
-## Autonomy Directive
-
-This is an unattended scheduled task. No human is present.
-
-- NEVER pause to ask for clarification — make your best judgment and proceed
-- NEVER use AskUserQuestion or any interactive prompt
-- Default to the safest option in every ambiguous situation
-
-## Task
-
-Execute these skills in order:
-
-1. `start-governance-runtime` — Start the governance kernel
-2. `dependency-security-audit` — Audit dependencies for known vulnerabilities
-3. `security-code-scan` — Scan source code for security anti-patterns and vulnerabilities
-
-If any skill reports STOP, end the run and report why.
diff --git a/packages/swarm/templates/prompts/stale-branch-janitor.md b/packages/swarm/templates/prompts/stale-branch-janitor.md
deleted file mode 100644
index 7439f8aa..00000000
--- a/packages/swarm/templates/prompts/stale-branch-janitor.md
+++ /dev/null
@@ -1,18 +0,0 @@
-You are the Stale Branch Janitor for this repository. You clean up stale branches and abandoned PRs.
-
-## Autonomy Directive
-
-This is an unattended scheduled task. No human is present.
-
-- NEVER pause to ask for clarification — make your best judgment and proceed
-- NEVER use AskUserQuestion or any interactive prompt
-- Default to the safest option in every ambiguous situation
-
-## Task
-
-Execute these skills in order:
-
-1. `start-governance-runtime` — Start the governance kernel
-2. `stale-branch-janitor` — Identify and clean up stale branches and abandoned PRs
-
-If any skill reports STOP, end the run and report why.
diff --git a/packages/swarm/templates/prompts/test-agent.md b/packages/swarm/templates/prompts/test-agent.md
deleted file mode 100644
index 313f548b..00000000
--- a/packages/swarm/templates/prompts/test-agent.md
+++ /dev/null
@@ -1,18 +0,0 @@
-You are the Test Agent for this repository. You review test health and coverage.
-
-## Autonomy Directive
-
-This is an unattended scheduled task. No human is present.
-
-- NEVER pause to ask for clarification — make your best judgment and proceed
-- NEVER use AskUserQuestion or any interactive prompt
-- Default to the safest option in every ambiguous situation
-
-## Task
-
-Execute these skills in order:
-
-1. `start-governance-runtime` — Start the governance kernel
-2. `test-health-review` — Analyze test coverage, flaky tests, and overall test suite health
-
-If any skill reports STOP, end the run and report why.
diff --git a/packages/swarm/templates/prompts/test-generation-agent.md b/packages/swarm/templates/prompts/test-generation-agent.md
deleted file mode 100644
index 2e28680c..00000000
--- a/packages/swarm/templates/prompts/test-generation-agent.md
+++ /dev/null
@@ -1,18 +0,0 @@
-You are the Test Generation Agent for this repository. You generate tests for untested or under-tested modules.
-
-## Autonomy Directive
-
-This is an unattended scheduled task. No human is present.
-
-- NEVER pause to ask for clarification — make your best judgment and proceed
-- NEVER use AskUserQuestion or any interactive prompt
-- Default to the safest option in every ambiguous situation
-
-## Task
-
-Execute these skills in order:
-
-1. `start-governance-runtime` — Start the governance kernel
-2. `generate-tests` — Identify untested modules and generate test files for them
-
-If any skill reports STOP, end the run and report why.
diff --git a/packages/swarm/templates/skills/architecture-review.md b/packages/swarm/templates/skills/architecture-review.md
deleted file mode 100644
index c59bb60b..00000000
--- a/packages/swarm/templates/skills/architecture-review.md
+++ /dev/null
@@ -1,158 +0,0 @@
-# Skill: Architecture Review
-
-Review open PRs for architectural concerns: module boundary violations, dependency direction, cross-layer coupling, and consistency with the unified architecture. Complements the `review-open-prs` skill with deeper structural analysis. Designed for periodic scheduled execution.
-
-## Prerequisites
-
-Run `start-governance-runtime` first. All scheduled skills must operate under governance.
-
-## Steps
-
-### 1. Start Governance Runtime
-
-Invoke the `start-governance-runtime` skill to ensure the AgentGuard kernel is active. If governance cannot be activated, STOP.
-
-### 2. List Open PRs
-
-```bash
-gh pr list --state open --json number,title,headRefName,additions,deletions --limit 10
-```
-
-If no open PRs exist, report "No open PRs to review" and STOP.
-
-### 3. Filter PRs Needing Architecture Review
-
-Select PRs that touch structural files (skip docs-only, config-only, or test-only PRs):
-
-```bash
-gh pr view --json files --jq '.files[].path'
-```
-
-A PR needs architecture review if it modifies files in:
-- `packages/kernel/src/` — core governance engine
-- `packages/events/src/` — canonical event model
-- `packages/policy/src/` — policy system
-- `packages/invariants/src/` — invariant system
-- `packages/adapters/src/` — execution adapters
-- `packages/core/src/` — shared types and utilities
-- `apps/cli/src/` — CLI entry points and commands
-
-Skip PRs that already have an `**Architect Agent**` comment. Select up to **2 PRs** per run.
-
-### 4. Review Each PR
-
-For each selected PR:
-
-#### 4a. Read the Diff
-
-```bash
-gh pr diff
-```
-
-#### 4b. Analyze Module Boundaries
-
-The architecture defines 7 distinct workspace packages with strict dependency rules:
-
-```
-@red-codes/core ← (shared types, no imports from other packages)
- ↑
-@red-codes/events ← (may import from core)
- ↑
-@red-codes/policy ← (may import from core)
- ↑
-@red-codes/invariants ← (may import from core, events)
- ↑
-@red-codes/kernel ← (may import from core, events, policy, invariants)
- ↑
-@red-codes/adapters ← (may import from core, events, kernel)
- ↑
-apps/cli ← (may import from anything)
-```
-
-Check the diff for import statements that violate these dependency rules:
-- `@red-codes/kernel` must NOT import from `@red-codes/adapters` or `apps/cli`
-- `@red-codes/adapters` must NOT import from `apps/cli`
-- `@red-codes/events` must NOT import from `kernel`, `policy`, `invariants`, `adapters`, or `cli`
-- `@red-codes/policy` must NOT import from `kernel`, `invariants`, `adapters`, or `cli`
-- `@red-codes/core` must NOT import from any other workspace package
-
-#### 4c. Check Event Model Consistency
-
-If the PR adds new event kinds:
-- New events must be defined in `packages/events/src/schema.ts`
-- New events must follow the existing naming convention (PascalCase)
-- New events must have a factory function for creation
-- New events must be documented in the appropriate event category
-
-#### 4d. Check Action Type Consistency
-
-If the PR adds new action types:
-- New actions must be registered in `packages/core/src/actions.ts`
-- New actions must follow the `class.verb` naming convention (e.g., `file.read`, `git.push`)
-- New action classes must have a corresponding adapter in `packages/adapters/src/`
-
-#### 4e. Check Public API Surface
-
-If the PR modifies exports from barrel files (`index.ts`):
-- Removing exports is a breaking change — flag it
-- Adding exports should be intentional, not accidental
-
-#### 4f. Assess Coupling
-
-Analyze the changed files for coupling concerns:
-- Does the change introduce circular dependencies?
-- Does the change add imports from multiple unrelated layers?
-- Does the change leak implementation details across layer boundaries?
-- Could the change be implemented with fewer cross-layer imports?
-
-### 5. Post Architecture Review
-
-For each reviewed PR, post a structured comment:
-
-```bash
-gh pr comment --body "**Architect Agent** — architecture review
-
-## Module Boundary Analysis
-
-| Layer | Files Changed | Boundary Status |
-|-------|--------------|----------------|
-| kernel/ | N | CLEAN/VIOLATION |
-| events/ | N | CLEAN/VIOLATION |
-| policy/ | N | CLEAN/VIOLATION |
-| invariants/ | N | CLEAN/VIOLATION |
-| adapters/ | N | CLEAN/VIOLATION |
-| cli/ | N | CLEAN/VIOLATION |
-| core/ | N | CLEAN/VIOLATION |
-
-## Findings
-
-| # | Severity | Category | Details |
-|---|----------|----------|---------|
-| 1 | | | |
-
-## Recommendations
-
-
-
----
-*Architecture review by Architect Agent on $(date -u +%Y-%m-%dT%H:%M:%SZ)*"
-```
-
-### 6. Summary
-
-Report:
-- **PRs reviewed**: N (list PR numbers)
-- **Boundary violations found**: N
-- **Coupling concerns**: N
-- **API surface changes**: N
-- If all clean: "Architecture review passed — no structural concerns"
-
-## Rules
-
-- Review a maximum of **2 PRs per run** (architecture review is deeper than code review).
-- **Never approve or merge PRs** — post informational comments only.
-- **Never modify PR code** — review is read-only.
-- Skip PRs that already have an `**Architect Agent**` comment.
-- Skip docs-only, config-only, and test-only PRs — they don't affect architecture.
-- Focus on structural concerns, not coding style (that is the Reviewer Agent's job).
-- If `gh` CLI is not authenticated, report the error and STOP.
diff --git a/packages/swarm/templates/skills/audit-merged-prs.md b/packages/swarm/templates/skills/audit-merged-prs.md
deleted file mode 100644
index 6a225871..00000000
--- a/packages/swarm/templates/skills/audit-merged-prs.md
+++ /dev/null
@@ -1,253 +0,0 @@
-# Skill: Audit Merged PRs
-
-Audit pull requests merged in the last 7 days for risks that may have been overlooked — unresolved review comments, dismissed change requests, bypassed CI, or governance violations. Creates a consolidated risk report as a GitHub issue. Designed for weekly scheduled execution.
-
-## Autonomy Directive
-
-This skill runs as an **unattended scheduled task**. No human is present to answer questions.
-
-- **NEVER pause to ask for clarification or confirmation** — make your best judgment and proceed
-- **NEVER use AskUserQuestion or any interactive prompt** — all decisions must be made autonomously
-- If risk classification is ambiguous, round **up** to the higher risk level (err on the side of caution)
-- If governance activation fails, log the failure and **STOP** — do not ask what to do
-- If `gh` CLI fails, log the error and **STOP** — do not ask for credentials
-- If a PR's data is incomplete or malformed, **skip that PR** and note it in the summary
-- Default to the **safest option** in every ambiguous situation (flag risk > ignore risk)
-- When in doubt about any decision, choose the conservative path and document why in the summary
-
-## Prerequisites
-
-Run `start-governance-runtime` first. All scheduled skills must operate under governance. Requires `gh` CLI authenticated with repo access.
-
-## Steps
-
-### 1. Start Governance Runtime
-
-Invoke the `start-governance-runtime` skill to ensure the AgentGuard kernel is active and intercepting all tool calls. If governance cannot be activated, STOP — do not proceed without governance.
-
-### 2. Ensure Labels Exist
-
-```bash
-gh label create "audit" --color "FBCA04" --description "Post-merge risk audit finding" 2>/dev/null || true
-gh label create "source:merged-pr-audit" --color "C5DEF5" --description "Auto-created by Merged PR Audit skill" 2>/dev/null || true
-gh label create "<%= labels.high %>" --color "D93F0B" --description "High priority" 2>/dev/null || true
-gh label create "<%= labels.medium %>" --color "FBCA04" --description "Medium priority" 2>/dev/null || true
-```
-
-### 3. List Recently Merged PRs
-
-```bash
-gh pr list --state merged --json number,title,mergedAt,author,mergedBy,headRefName,additions,deletions,labels --limit 50
-```
-
-Filter results:
-- **Include**: PRs where `mergedAt` is within the last 7 days
-- **Exclude**: PRs already audited (check for a comment by `**AgentGuard Merged PR Audit Bot**`)
-
-If no recently merged PRs exist, report "No recently merged PRs to audit" and STOP.
-
-### 4. Audit Each Merged PR
-
-For each merged PR, collect evidence across five risk dimensions:
-
-#### 4a. Review Comment Analysis
-
-Check for unresolved review threads at time of merge:
-
-```bash
-gh pr view --json reviewThreads --jq '[.reviewThreads[] | select(.isResolved == false)] | length'
-```
-
-Check for change-request reviews that were never addressed:
-
-```bash
-gh pr view --json reviews --jq '[.reviews[] | select(.state == "CHANGES_REQUESTED")] | length'
-```
-
-Check if change-request reviews were followed by approvals or remained outstanding:
-
-```bash
-gh pr view --json reviews --jq '[.reviews[] | {author: .author.login, state: .state, submittedAt: .submittedAt}]'
-```
-
-**Risk signals**:
-- Unresolved review threads at merge → **HIGH**
-- Outstanding CHANGES_REQUESTED with no subsequent approval by the same reviewer → **HIGH**
-- Security-related keywords in dismissed/unresolved comments (e.g., "vulnerability", "injection", "auth", "secret", "credential", "XSS", "CSRF", "sanitize") → **CRITICAL**
-
-#### 4b. CI Status at Merge
-
-```bash
-gh pr view --json statusCheckRollup --jq '[.statusCheckRollup[] | select(.status != "COMPLETED" or .conclusion != "SUCCESS")]'
-```
-
-**Risk signals**:
-- Any required check not passing at merge time → **CRITICAL**
-- CI checks skipped entirely (no check runs at all) → **HIGH**
-- Only optional/non-required checks failing → **LOW**
-
-#### 4c. Governance Report Analysis
-
-Read the PR body and look for the `## Governance Report` section:
-
-```bash
-gh pr view --json body --jq '.body'
-```
-
-Parse the governance report for:
-- `PolicyDenied` count > 0 → **MEDIUM**
-- `InvariantViolation` count > 0 → **HIGH**
-- `ActionDenied` count > 0 → **MEDIUM**
-- No governance report at all (for agent-authored PRs) → **MEDIUM**
-
-#### 4d. Size and Scope Assessment
-
-```bash
-gh pr view --json additions,deletions,files --jq '{additions: .additions, deletions: .deletions, fileCount: (.files | length)}'
-```
-
-**Risk signals**:
-- PR > 500 lines changed with no evidence of review → **MEDIUM**
-- PR > 1000 lines changed → **MEDIUM** (flag for scope assessment regardless)
-- PR touches > 10 files → **LOW** (informational)
-
-#### 4e. Protected File Changes
-
-```bash
-gh pr view --json files --jq '[.files[].path]'
-```
-
-Check if any changed files are in protected paths:
-- `packages/kernel/src/**` — core governance kernel
-- `packages/policy/src/**` — policy evaluation engine
-- `packages/invariants/src/**` — invariant system
-- `<%= paths.policy %>` — default policy
-- `.claude/settings.json` — hook configuration
-
-**Risk signals**:
-- Protected kernel/policy/invariant files modified → **HIGH**
-- `<%= paths.policy %>` or `.claude/settings.json` modified → **CRITICAL**
-
-### 5. Score and Classify Each PR
-
-Assign risk scores:
-- **CRITICAL** = 4 points
-- **HIGH** = 3 points
-- **MEDIUM** = 2 points
-- **LOW** = 1 point
-
-For each PR, sum all risk scores. Classify the PR:
-
-| Total Score | Overall Risk |
-|-------------|-------------|
-| 0 | CLEAN |
-| 1-2 | LOW |
-| 3-4 | MEDIUM |
-| 5-7 | HIGH |
-| 8+ | CRITICAL |
-
-### 6. Generate Risk Report
-
-If any PR has risk level **MEDIUM or above**, generate a consolidated report.
-
-If no risks at MEDIUM or above, report "All merged PRs pass audit — no risks detected" and STOP.
-
-#### 6a. Check for Existing Open Audit Issue
-
-```bash
-gh issue list --state open --label "source:merged-pr-audit" --json number,title --limit 1
-```
-
-#### 6b. Compile the Report
-
-```
-## Merged PR Risk Audit Report
-
-**Audit period**: to
-**PRs audited**:
-**PRs with risks**:
-
-### Risk Summary
-
-| PR | Title | Merged By | Risk Level | Score | Top Finding |
-|----|-------|-----------|------------|-------|-------------|
-| # | | @ | | | |
-
-### Detailed Findings
-
-#### PR #:
-
-**Risk level**: (score: )
-**Merged by**: @ on
-**Changes**: + - across files
-
-| Risk | Level | Details |
-|------|-------|---------|
-| | | |
-
-= MEDIUM>
-
-### Patterns Observed
-
-
-
-### Recommendations
-
-
-
----
-*Automated audit by audit-merged-prs skill on *
-```
-
-#### 6c. Create or Update Issue
-
-If an existing open audit issue exists, comment on it:
-
-```bash
-gh issue comment --body ""
-```
-
-If no existing issue, create one:
-
-```bash
-gh issue create \
- --title "audit: Merged PR Risk Report — to " \
- --body "" \
- --label "audit" --label "source:merged-pr-audit" --label "priority:"
-```
-
-#### 6d. Mark Audited PRs
-
-For each audited PR (regardless of risk level), post a brief audit receipt comment:
-
-```bash
-gh pr comment --body "**AgentGuard Merged PR Audit Bot** — audited
-
-Risk level: **** (score: )
-Findings: ()
-Full report: #
-
----
-*Automated audit by audit-merged-prs skill on $(date -u +%Y-%m-%dT%H:%M:%SZ)*"
-```
-
-### 7. Summary
-
-Report:
-- **PRs audited**: N (list PR numbers)
-- **Risk breakdown**: N CRITICAL, N HIGH, N MEDIUM, N LOW, N CLEAN
-- **Issue created/updated**: # (or "none — all PRs clean")
-- **Top risks**:
-- If clean: "All merged PRs pass audit — governance is healthy"
-
-## Rules
-
-- **Read-only** — never modify merged PRs, never revert merges, never reopen closed PRs
-- **Never close existing audit issues** — only create new ones or comment on existing open ones
-- **Only create an issue if risks at MEDIUM or above are found** — do not create noise for LOW/CLEAN results
-- **Cap audit at 50 merged PRs per run** — if more exist, audit the 50 most recent and note the overflow
-- **Skip PRs already audited** — check for `**AgentGuard Merged PR Audit Bot**` comment
-- **Do not name or blame individuals** — focus on process gaps and systemic patterns, not personal attribution
-- Be factual and objective in findings — avoid inflammatory language
-- If `gh` CLI is not authenticated, report the error and STOP
-- If no merged PRs exist in the audit window, report cleanly and STOP
diff --git a/packages/swarm/templates/skills/backlog-steward.md b/packages/swarm/templates/skills/backlog-steward.md
deleted file mode 100644
index e663fbc1..00000000
--- a/packages/swarm/templates/skills/backlog-steward.md
+++ /dev/null
@@ -1,123 +0,0 @@
-# Skill: Backlog Steward
-
-Expand ROADMAP items into GitHub issues. Cross-reference against open issues to avoid duplicates. Designed for daily scheduled execution.
-
-**Scope**: ROADMAP expansion ONLY. Code annotation scanning (TODO/FIXME/HACK) is handled by the Repo Hygiene Agent — do NOT scan annotations here to avoid duplicate issue creation.
-
-## Prerequisites
-
-Run `start-governance-runtime` first. All scheduled skills must operate under governance.
-
-## Steps
-
-### 1. Start Governance Runtime
-
-Invoke the `start-governance-runtime` skill to ensure the AgentGuard kernel is active and intercepting all tool calls. If governance cannot be activated, STOP — do not proceed without governance.
-
-### 1b. Check System Mode
-
-```bash
-cat <%= paths.swarmState %> 2>/dev/null | grep -o '"mode":"[^"]*"' 2>/dev/null
-```
-
-- If mode is `safe`: output "System in SAFE MODE — skipping backlog expansion" and **STOP immediately**
-- If mode is `conservative`: reduce cap to **1 issue per run** instead of 3
-
-### 2. Scan ROADMAP Unchecked Items
-
-Read `<%= paths.roadmap %>` and extract all unchecked items:
-
-```bash
-grep -n "\- \[ \]" <%= paths.roadmap %>
-```
-
-For each match, extract the item description and its parent section (Phase name).
-
-### 3. Fetch Issues for Deduplication
-
-Retrieve ALL open issues (any source agent) as the deduplication reference:
-
-```bash
-gh issue list --state open --limit 200 --json number,title,body,labels
-```
-
-Also retrieve recently closed issues (last 30 days) to avoid re-filing resolved work:
-
-```bash
-gh issue list --state closed --limit 100 --json number,title,labels,closedAt
-```
-
-Filter closed issues to only those closed within the last 30 days.
-
-### 4. Deduplicate (Strict Multi-Signal Matching)
-
-For each ROADMAP item, check whether an existing issue (open OR recently closed) already covers it. Use ALL of the following matching signals — a match on ANY signal means SKIP:
-
-**Signal 1 — Substring match**: The ROADMAP checkbox text appears as a substring in any issue title (case-insensitive).
-
-**Signal 2 — Keyword overlap**: Extract the 3-5 most distinctive keywords from the ROADMAP item (nouns and verbs, excluding common words like "add", "implement", "support", "the", "for", "with"). Extract the same from each issue title. If ≥60% of the ROADMAP item's keywords appear in an issue title, it is a match.
-
-**Signal 3 — Cross-agent label check**: Check issues with ANY `source:*` label, not just `source:backlog-steward`. Issues created by `source:roadmap-agent`, `source:planning-agent`, `source:test-agent`, or any other agent count as existing coverage.
-
-**Signal 4 — Closed issue recency**: If an issue matching Signals 1-3 was closed in the last 30 days, treat it as covered. Do NOT re-file work that was recently completed or intentionally closed.
-
-### 4b. Batch Dedup Verification
-
-Before creating ANY issues, compile the full list of proposed new issues (titles only). Review them as a batch and remove any that:
-- Are semantically equivalent to each other (two proposed issues covering the same work)
-- Are semantically equivalent to any existing open or recently-closed issue identified in Step 4
-- Describe work that is clearly a subset of an existing open issue
-
-Only the de-duplicated list proceeds to Step 5.
-
-### 5. Create Issues for New Items
-
-For each unmatched item (up to **3 per run**), create a GitHub issue:
-
-```bash
-gh issue create \
- --title ": " \
- --body "## Source
-
-- **Type**:
-- **Location**: \`:\` (or <%= paths.roadmap %> section)
-- **Original text**:
-
-## Task Description
-
-
-
-## Labels
-
-Created automatically by the Backlog Steward skill.
-
----
-*Discovered by backlog-steward on $(date -u +%Y-%m-%dT%H:%M:%SZ)*" \
- --label "source:backlog-steward" --label "<%= labels.pending %>"
-```
-
-Add task type label for ROADMAP items → `task:implementation`
-
-Ensure the `source:backlog-steward` label exists before using it:
-
-```bash
-gh label create "source:backlog-steward" --color "C5DEF5" --description "Auto-created by Backlog Steward skill" 2>/dev/null || true
-```
-
-### 6. Summary
-
-Report:
-- **ROADMAP unchecked items**: N
-- **Already tracked**: N (matched to existing issues)
-- **New issues created**: N (list issue numbers and titles)
-- **Skipped (cap reached)**: N (if more than 3 unmatched items exist)
-
-## Rules
-
-- Create a maximum of **3 new issues per run** — if more unmatched items exist, report the overflow count but do not create them
-- **Never close, modify, or comment on existing issues** — this skill is create-only
-- **Never create duplicate issues** — always check against open issues first (title substring match)
-- **Do NOT scan code annotations** (TODO/FIXME/HACK) — that is the Repo Hygiene Agent's job
-- If `gh` CLI is not authenticated, report the error and STOP
-- If no unchecked ROADMAP items are found, report "Backlog clean — no new items discovered" and STOP
-- Only create issues relevant to the current active ROADMAP phase and the next phase
diff --git a/packages/swarm/templates/skills/cicd-hardening-audit.md b/packages/swarm/templates/skills/cicd-hardening-audit.md
deleted file mode 100644
index f621a199..00000000
--- a/packages/swarm/templates/skills/cicd-hardening-audit.md
+++ /dev/null
@@ -1,249 +0,0 @@
-# Skill: CI/CD Hardening Audit
-
-Audit CI/CD pipeline configuration for security hardening, best practices, and governance integration. Verify that all workflows enforce required checks, use pinned action versions, have proper permissions, and integrate with AgentGuard governance. Designed for weekly scheduled execution.
-
-## Autonomy Directive
-
-This skill runs as an **unattended scheduled task**. No human is present to answer questions.
-
-- **NEVER pause to ask for clarification or confirmation** — make your best judgment and proceed
-- **NEVER use AskUserQuestion or any interactive prompt** — all decisions must be made autonomously
-- If data is unavailable or ambiguous, proceed with available data and note limitations
-- If governance activation fails, log the failure and **STOP**
-- If `gh` CLI fails, log the error and **STOP**
-- Default to the **safest option** in every ambiguous situation
-
-## Prerequisites
-
-Run `start-governance-runtime` first. All scheduled skills must operate under governance.
-
-## Steps
-
-### 1. Start Governance Runtime
-
-Invoke the `start-governance-runtime` skill to ensure the AgentGuard kernel is active and intercepting all tool calls. If governance cannot be activated, STOP — do not proceed without governance.
-
-### 2. Audit Workflow Files
-
-Read all GitHub Actions workflow files:
-
-```bash
-ls .github/workflows/*.yml .github/workflows/*.yaml 2>/dev/null
-```
-
-For each workflow file, check:
-
-#### 2a. Action Version Pinning
-
-```bash
-grep -n "uses:" .github/workflows/
-```
-
-Flag:
-- Actions using `@main` or `@master` instead of a pinned SHA or version tag — **HIGH risk** (supply chain attack vector)
-- Actions using floating tags like `@v4` instead of exact versions like `@v4.1.2` — **MEDIUM risk**
-
-#### 2b. Workflow Permissions
-
-```bash
-grep -n "permissions:" .github/workflows/
-```
-
-Flag:
-- Workflows without explicit `permissions:` block — **HIGH risk** (gets default write-all)
-- Workflows with `permissions: write-all` — **HIGH risk** (overly permissive)
-- Workflows that should use `contents: read` but have `contents: write` — **MEDIUM risk**
-
-#### 2c. Secret Usage
-
-```bash
-grep -n "secrets\." .github/workflows/
-```
-
-Flag:
-- Secrets passed to third-party actions — **MEDIUM risk**
-- Secrets used in `run:` steps without environment variable indirection — **LOW risk**
-
-#### 2d. Trigger Configuration
-
-```bash
-grep -n "on:" .github/workflows/
-```
-
-Flag:
-- `pull_request_target` trigger without proper safeguards — **HIGH risk** (can run untrusted code with repo secrets)
-- Missing branch protection on push triggers — **MEDIUM risk**
-
-### 3. Check Branch Protection
-
-```bash
-gh api repos/{owner}/{repo}/branches/main/protection 2>/dev/null
-```
-
-Verify:
-- **Required status checks** are configured
-- **Required reviews** count is >= 1 (or 0 if fully autonomous — note this)
-- **Dismiss stale reviews** is enabled
-- **Require up-to-date branches** is enabled
-- **Enforce for administrators** is enabled
-
-If branch protection API fails (may require admin access), note "Branch protection: unable to query (may require admin access)" and continue.
-
-### 4. Audit GitHub Actions Security
-
-Check for common CI/CD security issues:
-
-#### 4a. Script Injection
-
-```bash
-grep -rn '\${{.*github\.event' .github/workflows/ 2>/dev/null
-```
-
-Flag any use of `${{ github.event.* }}` in `run:` steps — **HIGH risk** (script injection via PR titles, comments, etc.)
-
-#### 4b. Artifact Security
-
-```bash
-grep -n "actions/upload-artifact\|actions/download-artifact" .github/workflows/*.yml 2>/dev/null
-```
-
-Check for:
-- Artifacts with sensitive data — **MEDIUM risk**
-- Missing artifact retention limits — **LOW risk**
-
-### 5. Check AgentGuard Governance Integration
-
-Verify that CI/CD integrates with AgentGuard governance:
-
-```bash
-grep -rn "agentguard" .github/workflows/ 2>/dev/null
-```
-
-Check for:
-- `agentguard ci-check` in CI workflows — governance verification
-- `agentguard evidence-pr` in PR workflows — evidence attachment
-- Governance hook configuration in `.claude/settings.json`
-
-Flag:
-- CI workflows that modify code without governance — **MEDIUM risk**
-- PR workflows that don't attach governance evidence — **LOW risk** (nice-to-have)
-- Missing `agentguard-governance.yml` reusable workflow usage — **LOW risk**
-
-### 6. Check Dependency Supply Chain
-
-```bash
-grep -rn "npm ci\|npm install\|yarn install\|pnpm install" .github/workflows/ 2>/dev/null
-```
-
-Flag:
-- `npm install` instead of `npm ci` in CI — **MEDIUM risk** (non-deterministic)
-- Missing `--ignore-scripts` flag for untrusted deps — **LOW risk**
-- Missing npm provenance in publish workflow — **MEDIUM risk**
-
-### 7. Generate Hardening Report
-
-Compose a structured report in markdown:
-
-**Header**:
-- Audit timestamp (UTC)
-- Number of workflows analyzed
-- Overall hardening score (0-100 based on findings)
-
-**Findings Summary**:
-| Severity | Count | Examples |
-|----------|-------|----------|
-| HIGH | N | |
-| MEDIUM | N | |
-| LOW | N | |
-
-**Detailed Findings**:
-For each finding:
-- **Severity**: HIGH / MEDIUM / LOW
-- **Category**: action-pinning / permissions / secrets / triggers / branch-protection / script-injection / supply-chain / governance
-- **File**: workflow file and line number
-- **Description**: What was found
-- **Recommendation**: Specific fix
-- **Auto-fixable**: Yes / No
-
-**Governance Integration Status**:
-| Check | Status |
-|-------|--------|
-| CI governance verification | Present / Missing |
-| PR evidence attachment | Present / Missing |
-| Hook configuration | Valid / Missing / Invalid |
-
-**Hardening Score Calculation**:
-- Start at 100
-- Deduct 15 per HIGH finding
-- Deduct 5 per MEDIUM finding
-- Deduct 1 per LOW finding
-- Minimum score: 0
-
-### 8. Publish Report
-
-Check if a previous hardening report exists:
-
-```bash
-gh issue list --state open --label "source:cicd-hardening" --json number --jq '.[0].number'
-```
-
-If a previous report exists, close it:
-
-```bash
-gh issue close --comment "Superseded by new CI/CD hardening audit."
-```
-
-Create the new report:
-
-```bash
-gh label create "source:cicd-hardening" --color "0E8A16" --description "CI/CD Hardening Audit" 2>/dev/null || true
-gh issue create \
- --title "CI/CD Hardening Audit — $(date +%Y-%m-%d)" \
- --body "" \
- --label "source:cicd-hardening" --label "<%= labels.pending %>"
-```
-
-### 9. Create Fix Issues for HIGH Findings
-
-For each HIGH severity finding that is auto-fixable, create a targeted fix issue:
-
-```bash
-gh issue create \
- --title "fix(ci): " \
- --body "## CI/CD Hardening Fix
-
-- **Severity**: HIGH
-- **Finding**:
-- **File**:
-- **Fix**:
-
-Discovered by CI/CD Hardening Audit on $(date +%Y-%m-%d).
-
----
-*Auto-created by cicd-hardening-audit skill*" \
- --label "source:cicd-hardening" --label "<%= labels.high %>" --label "task:implementation" --label "<%= labels.pending %>"
-```
-
-Cap at **2 fix issues per run**.
-
-### 10. Summary
-
-Report:
-- **Workflows audited**: N
-- **Hardening score**: N/100
-- **HIGH findings**: N
-- **MEDIUM findings**: N
-- **LOW findings**: N
-- **Fix issues created**: N
-- **Governance integration**: Complete / Partial / Missing
-- **Top concern**: Brief statement of the most critical finding
-
-## Rules
-
-- Create a maximum of **1 hardening report issue per run**
-- Create a maximum of **2 fix issues per run**
-- **Never modify workflow files directly** — only report findings and create fix issues for the Coder Agent
-- **Never close issues** — only close previous hardening report issues labeled `source:cicd-hardening`
-- If `gh` CLI is not authenticated, report the error and STOP
-- When assessing severity, err on the side of higher severity (flag rather than ignore)
-- Always check actual file content — do not assume based on file names alone
diff --git a/packages/swarm/templates/skills/claim-issue.md b/packages/swarm/templates/skills/claim-issue.md
deleted file mode 100644
index 28b2cf19..00000000
--- a/packages/swarm/templates/skills/claim-issue.md
+++ /dev/null
@@ -1,75 +0,0 @@
-# Skill: Claim Issue
-
-Claim a discovered GitHub issue for the current agent session. Updates labels, creates a working branch, and posts a start comment.
-
-## Prerequisites
-
-Run `discover-next-issue` first to identify the issue number.
-
-## Steps
-
-### 1. Update Issue Status
-
-Remove the pending label and mark as in-progress:
-
-```bash
-gh issue edit --remove-label "<%= labels.pending %>" --add-label "<%= labels.inProgress %>"
-```
-
-If label update fails because the label does not exist on the repository, create it first:
-
-```bash
-gh label create "<%= labels.inProgress %>" --color "0E8A16" --description "Agent is actively working on this"
-```
-
-Then retry the edit command.
-
-### 2. Determine Branch Name
-
-Map the task type label to a branch prefix:
-
-| Label | Branch Prefix |
-|-------|--------------|
-| `task:implementation` | `agent/implementation/issue-` |
-| `task:bug-fix` | `agent/bugfix/issue-` |
-| `task:refactor` | `agent/refactor/issue-` |
-| `task:test-generation` | `agent/tests/issue-` |
-| `task:documentation` | `agent/docs/issue-` |
-| (default) | `agent/task/issue-` |
-
-### 3. Create Working Branch
-
-```bash
-git checkout -b agent//issue-
-```
-
-If the branch already exists (from a previous attempt):
-
-```bash
-git checkout agent//issue-
-```
-
-### 4. Verify Branch
-
-```bash
-git branch --show-current
-```
-
-Confirm the output matches the expected branch name.
-
-### 5. Post Start Comment
-
-```bash
-gh issue comment --body "**AgentGuard Agent** — work started.
-
-- **Branch**: \`agent//issue-\`
-- **Governance**: Active (PreToolUse hooks enforcing policy)
-- **Started**: $(date -u +%Y-%m-%dT%H:%M:%SZ)"
-```
-
-## Rules
-
-- If the branch already exists, check it out instead of creating a new one
-- Always verify you are on the correct branch before proceeding
-- If the issue is already `status:in-progress`, check if it was previously assigned — if so, resume work on the existing branch rather than starting fresh
-- Do not claim more than one issue at a time
diff --git a/packages/swarm/templates/skills/create-pr.md b/packages/swarm/templates/skills/create-pr.md
deleted file mode 100644
index e6160daf..00000000
--- a/packages/swarm/templates/skills/create-pr.md
+++ /dev/null
@@ -1,201 +0,0 @@
-# Skill: Create Pull Request
-
-Create a pull request with a governance telemetry summary, risk assessment, and decision records. Pushes the branch, reads governance event data, runs pre-push simulation, generates a structured PR body, and updates the issue status.
-
-## Prerequisites
-
-All tests must pass — run `run-tests` first.
-
-## Steps
-
-### 1. Stage Governance Telemetry
-
-Stage governance event files so they are committed with the PR branch:
-
-```bash
-git add .agentguard/events/*.jsonl 2>/dev/null || true
-git add .agentguard/decisions/*.jsonl 2>/dev/null || true
-git add <%= paths.logs %> 2>/dev/null || true
-```
-
-If no governance files exist yet, this is a no-op — proceed normally.
-
-### 2. Pre-Push Simulation
-
-Run impact simulation before pushing to assess blast radius and policy compliance:
-
-```bash
-<%= paths.cli %> simulate --action git.push --branch $(git branch --show-current) --policy <%= paths.policy %> --json 2>/dev/null
-```
-
-Parse the JSON output for:
-- **riskLevel**: low / medium / high
-- **blastRadius**: weighted score
-- **predictedChanges**: list of affected resources
-- **policyResult**: allowed / denied
-
-If simulation shows a policy denial, report the denial reason and STOP — do not push a branch that would violate governance policy.
-
-If the simulate command is not available or fails, note "Simulation: not available" and proceed.
-
-### 3. Push Branch to Remote
-
-```bash
-git push -u origin $(git branch --show-current)
-```
-
-If push fails due to remote rejection, diagnose and report. Do NOT force push.
-
-### 4. Collect Governance Telemetry
-
-Use the evidence-pr command in dry-run mode to collect and format governance telemetry:
-
-```bash
-<%= paths.cli %> evidence-pr --last --dry-run --store sqlite 2>/dev/null
-```
-
-If the command fails or returns no output, fall back to JSONL mode:
-
-```bash
-<%= paths.cli %> evidence-pr --last --dry-run 2>/dev/null
-```
-
-If no telemetry files exist, note "No governance telemetry recorded" — still proceed with PR creation.
-
-### 5. Collect Decision Records
-
-Read governance decision records for this session:
-
-```bash
-ls -la .agentguard/decisions/ 2>/dev/null
-cat .agentguard/decisions/*.jsonl 2>/dev/null | wc -l
-cat .agentguard/decisions/*.jsonl 2>/dev/null | grep -c '"outcome":"deny"' || echo 0
-```
-
-Parse decision records to extract:
-- **Total decisions recorded**
-- **Deny outcomes** and their reasons
-- **Escalation levels** observed (NORMAL, ELEVATED, HIGH, LOCKDOWN)
-- **Intervention types** (deny, rollback, pause, test-only)
-
-### 6. Compute Risk Score
-
-Run the analytics engine for a per-session risk assessment:
-
-```bash
-<%= paths.cli %> analytics --format json 2>/dev/null | head -50
-```
-
-Extract:
-- **Risk score** (0-100)
-- **Risk level** (low / medium / high / critical)
-- **Top violation patterns** (if any)
-
-If the analytics command is not available, compute a basic risk level from telemetry:
-- 0 denials + 0 violations → **low**
-- 1-2 denials or violations → **medium**
-- 3+ denials or any escalation → **high**
-- Any LOCKDOWN event → **critical**
-
-### 7. Generate PR Body
-
-Use this structure:
-
-```markdown
-## Summary
-- <1-3 bullet points describing what was implemented>
-- Closes #
-
-## Changes
--
-
-## Test Plan
-- [ ] TypeScript build passes (`pnpm build`)
-- [ ] Vitest tests pass (`pnpm test`)
-- [ ] ESLint clean (`pnpm lint`)
-- [ ] Prettier clean (`pnpm format`)
-
-## Risk Assessment
-
-| Metric | Value |
-|--------|-------|
-| Risk level | |
-| Risk score | /100 |
-| Blast radius | (weighted) |
-| Simulation result | |
-
-## Governance Report
-
-| Metric | Count |
-|--------|-------|
-| Total events | |
-| Actions allowed | |
-| Actions denied | |
-| Policy denials | |
-| Invariant violations | |
-| Escalation events | |
-| Decision records | |
-
-
-Governance details
-
-**Source**: `.agentguard/events/`, `.agentguard/decisions/`, `<%= paths.logs %>`
-
-**Decision Records**: total, denials
-**Escalation levels observed**:
-**Pre-push simulation**:
-
-[List any notable denials or violations with their reasons]
-
-
-```
-
-### 8. Create the PR
-
-```bash
-gh pr create --title "(issue-): " --body ""
-```
-
-Use the issue title as the basis for the PR title. Keep it under 70 characters. Use conventional prefixes: `feat`, `fix`, `refactor`, `test`, `docs`.
-
-If a PR already exists for this branch:
-
-```bash
-gh pr view --json url --jq '.url'
-```
-
-Update the existing PR instead:
-
-```bash
-gh pr edit --body ""
-```
-
-### 9. Update Issue Label
-
-```bash
-gh issue edit --remove-label "<%= labels.inProgress %>" --add-label "<%= labels.review %>"
-```
-
-### 10. Comment on Issue
-
-```bash
-gh issue comment --body "**AgentGuard Agent** — pull request created.
-
-- **PR**:
-- **Branch**: \`$(git branch --show-current)\`
-- **Risk level**:
-- **Actions evaluated**:
-- **Denials**:
-- **Decision records**:
-- **Completed**: $(date -u +%Y-%m-%dT%H:%M:%SZ)"
-```
-
-## Rules
-
-- Do NOT force push — if push fails, diagnose and report
-- If `gh pr create` fails because a PR already exists, update the existing PR
-- If no governance telemetry exists, still create the PR but note "Governance telemetry: not available" in the report
-- If pre-push simulation shows a policy denial, STOP and report — do not create a PR for policy-violating changes
-- Mark all test plan checkboxes that passed during `run-tests`
-- The PR title must be under 70 characters
-- If analytics or simulation commands are not available, degrade gracefully and note the limitation
diff --git a/packages/swarm/templates/skills/dependency-security-audit.md b/packages/swarm/templates/skills/dependency-security-audit.md
deleted file mode 100644
index 29c587ea..00000000
--- a/packages/swarm/templates/skills/dependency-security-audit.md
+++ /dev/null
@@ -1,254 +0,0 @@
-# Skill: Dependency Security Audit
-
-Run security audits on project dependencies, check for known vulnerabilities, identify outdated packages, and review Dependabot alerts. Creates a high-priority issue if critical or high-severity vulnerabilities are found. Designed for periodic scheduled execution.
-
-## Prerequisites
-
-Run `start-governance-runtime` first. All scheduled skills must operate under governance. Also requires `npm` and `gh` CLI.
-
-## Steps
-
-### 1. Start Governance Runtime
-
-Invoke the `start-governance-runtime` skill to ensure the AgentGuard kernel is active and intercepting all tool calls. If governance cannot be activated, STOP — do not proceed without governance.
-
-### 2. Run npm Audit
-
-```bash
-npm audit --json 2>/dev/null || npm audit 2>/dev/null
-```
-
-Parse the output to extract:
-- **Total vulnerabilities** by severity (critical, high, moderate, low)
-- **Affected packages** and their vulnerable version ranges
-- **Fix available**: whether a non-breaking fix exists (`npm audit fix --dry-run`)
-
-If `npm audit` reports 0 vulnerabilities, note "npm audit: clean".
-
-### 3. Check for Outdated Packages
-
-```bash
-npm outdated --json 2>/dev/null || npm outdated 2>/dev/null
-```
-
-For each outdated package, extract:
-- **Package name**
-- **Current version** vs **latest version**
-- **Update type**: patch, minor, or major (breaking)
-
-Categorize by risk:
-- Major version behind on a runtime dependency → **HIGH** risk
-- Major version behind on a dev dependency → **MODERATE** risk
-- Minor/patch behind → **LOW** risk
-
-### 4. Check Dependabot Alerts
-
-```bash
-gh api repos/{owner}/{repo}/dependabot/alerts --jq '[.[] | select(.state=="open")] | length' 2>/dev/null || echo "Dependabot API not available"
-```
-
-If alerts are available, list open ones:
-
-```bash
-gh api repos/{owner}/{repo}/dependabot/alerts --jq '.[] | select(.state=="open") | {number: .number, package: .security_vulnerability.package.name, severity: .security_vulnerability.severity, summary: .security_advisory.summary}' 2>/dev/null
-```
-
-### 5. Check for Known Supply Chain Risks
-
-Review `package-lock.json` for concerning patterns:
-
-```bash
-# Check total dependency count
-node -e "const lock = require('./package-lock.json'); const deps = Object.keys(lock.packages || {}).filter(k => k !== ''); console.log('Total packages:', deps.length)"
-
-# Check for install scripts (potential supply chain risk)
-node -e "const lock = require('./package-lock.json'); const pkgs = lock.packages || {}; Object.entries(pkgs).forEach(([name, info]) => { if (info.hasInstallScript) console.log('Install script:', name) })" 2>/dev/null
-```
-
-### 6. Check Fix Availability
-
-For any critical or high vulnerabilities, check if automated fixes are available:
-
-```bash
-npm audit fix --dry-run 2>/dev/null
-```
-
-Report which vulnerabilities can be auto-fixed and which require manual intervention (breaking changes).
-
-### 7. License Compliance Check
-
-Check licenses of all dependencies for compatibility:
-
-```bash
-npx license-checker --json --production 2>/dev/null | head -200
-```
-
-If `license-checker` is not available, fall back to manual inspection:
-
-```bash
-node -e "
-const lock = require('./package-lock.json');
-const pkg = require('./package.json');
-const deps = Object.keys(pkg.dependencies || {});
-deps.forEach(d => {
- try {
- const p = require('./node_modules/' + d + '/package.json');
- console.log(d + ': ' + (p.license || 'UNKNOWN'));
- } catch(e) { console.log(d + ': UNREADABLE'); }
-});
-"
-```
-
-Flag problematic licenses:
-- **GPL-2.0, GPL-3.0, AGPL** → **HIGH** risk (copyleft, may require source disclosure)
-- **UNKNOWN, UNLICENSED** → **MEDIUM** risk (legal uncertainty)
-- **MIT, Apache-2.0, BSD, ISC** → OK (permissive)
-
-### 8. Secret Detection in Configuration
-
-Scan project configuration files for accidentally committed secrets:
-
-```bash
-grep -rn "password\|secret\|api.key\|token\|credential" .env* *.yaml *.json --include="*.env" --include="*.yaml" --include="*.json" 2>/dev/null | grep -v "node_modules\|package-lock\|dist" | head -20
-```
-
-Also check git history for recently added secrets:
-
-```bash
-git log --oneline -20 --diff-filter=A -- "*.env" "*.key" "*.pem" 2>/dev/null
-```
-
-Flag:
-- Any `.env` files tracked in git → **CRITICAL**
-- Any credential-like strings in YAML/JSON config → **HIGH**
-- Any key/pem files committed → **CRITICAL**
-
-### 9. Compare with Previous Audit
-
-Check if a previous audit issue exists and compare:
-
-```bash
-gh issue list --state all --label "source:security-audit" --json number,title,createdAt --limit 5
-```
-
-If a previous audit exists, note:
-- **New vulnerabilities** since last audit
-- **Resolved vulnerabilities** since last audit
-- **Trend**: improving, stable, or degrading
-
-### 10. Generate Report
-
-Compile findings into a structured report:
-
-```
-## Dependency Security Audit Report
-
-**Date**:
-**Node version**: $(node -v)
-**npm version**: $(npm -v)
-
-### Vulnerability Summary
-
-| Severity | Count |
-|----------|-------|
-| Critical | N |
-| High | N |
-| Moderate | N |
-| Low | N |
-
-### Outdated Packages
-
-| Package | Current | Latest | Type | Risk |
-|---------|---------|--------|------|------|
-| | | | | |
-
-### Dependabot Alerts
-
-| # | Package | Severity | Summary |
-|---|---------|----------|---------|
-| | | | |
-
-### Supply Chain Notes
-
-- Total dependency count: N
-- Packages with install scripts: N
-
-### License Compliance
-
-| License | Count | Risk |
-|---------|-------|------|
-| MIT | N | OK |
-| Apache-2.0 | N | OK |
-| GPL-* | N | HIGH |
-| UNKNOWN | N | MEDIUM |
-
-### Secret Detection
-
-| Finding | File | Severity |
-|---------|------|----------|
-| | | |
-
-### Trend (vs. Previous Audit)
-
-- New vulnerabilities: N
-- Resolved vulnerabilities: N
-- Trend: Improving / Stable / Degrading
-
-### Recommendations
-
-
-```
-
-### 11. Create or Update Issue (if critical/high found)
-
-If any critical or high-severity vulnerabilities, license issues, or secret detections exist, check for an existing audit issue:
-
-```bash
-gh issue list --state open --label "source:security-audit" --json number,title --limit 1
-```
-
-Ensure the label exists:
-
-```bash
-gh label create "source:security-audit" --color "D93F0B" --description "Auto-created by Dependency Security Audit skill" 2>/dev/null || true
-```
-
-If an existing issue is open, update it with the latest findings:
-
-```bash
-gh issue comment --body ""
-```
-
-If no existing issue is open, create one:
-
-```bash
-gh issue create \
- --title "security-audit: critical/ high vulnerabilities found" \
- --body "" \
- --label "source:security-audit" --label "<%= labels.critical %>"
-```
-
-Use `priority:critical` if any critical vulnerabilities or secrets detected, otherwise `priority:high`.
-
-### 12. Summary
-
-Report:
-- **Vulnerabilities**: N critical, N high, N moderate, N low
-- **Outdated packages**: N (N high-risk)
-- **Dependabot alerts**: N open
-- **Auto-fixable**: N vulnerabilities
-- **License issues**: N (N high-risk copyleft, N unknown)
-- **Secrets detected**: N
-- **Trend**: improving/stable/degrading vs. previous audit
-- **Issue**: created/updated/none needed
-- If clean: "No security issues found — dependencies healthy"
-
-## Rules
-
-- **Never run `npm audit fix`** without `--dry-run` — this skill is analysis-only, not remediation
-- **Never modify `package.json` or `package-lock.json`** — only read and report
-- **Never close existing security issues** — only create new ones or comment on existing open ones
-- If `npm audit` fails (no lockfile, network error), report the error and continue with other checks
-- If Dependabot API is not available (permissions, not enabled), skip that step and continue
-- If no vulnerabilities are found, report "Dependencies healthy" and STOP — do not create an issue
-- If `gh` CLI is not authenticated, still generate the report to console but skip issue creation
diff --git a/packages/swarm/templates/skills/discover-next-issue.md b/packages/swarm/templates/skills/discover-next-issue.md
deleted file mode 100644
index 391fdc48..00000000
--- a/packages/swarm/templates/skills/discover-next-issue.md
+++ /dev/null
@@ -1,139 +0,0 @@
-# Skill: Discover Next Issue
-
-Find the next GitHub issue to work on from the project's issue queue. Issues are selected by the `status:pending` label, sorted by priority, and assessed for governance risk level. Escalation context is checked to avoid high-risk work during elevated governance states.
-
-## Autonomy Directive
-
-This skill runs as an **unattended scheduled task**. No human is present to answer questions.
-
-- **NEVER pause to ask for clarification or confirmation** — make your best judgment and proceed
-- **NEVER use AskUserQuestion or any interactive prompt** — all decisions must be made autonomously
-- If no issues match criteria, report cleanly and **STOP**
-- If governance activation fails, log the failure and **STOP**
-- If `gh` CLI fails, log the error and **STOP**
-- Default to the **safest option** in every ambiguous situation
-
-## Prerequisites
-
-Run `start-governance-runtime` first.
-
-## Steps
-
-### 0. Read Swarm State (if available)
-
-Check for shared swarm state to inform issue selection:
-
-```bash
-cat <%= paths.swarmState %> 2>/dev/null
-```
-
-If the file exists and is valid JSON, extract:
-- **mode**: if `safe`, output "System in SAFE MODE — skipping issue discovery" and STOP immediately. If `conservative`, reduce to smallest-scope issues only (< 5 files in scope)
-- **prQueueHealthy**: if `false`, output "PR queue unhealthy — skipping issue discovery" and STOP
-- **currentPhase**: prefer issues aligned with this ROADMAP phase
-- **priorities**: if present, prefer issues listed in the priorities array
-
-If the file does not exist or is invalid, proceed with standard discovery.
-
-### 1. Query Pending Issues
-
-```bash
-gh issue list --label "<%= labels.pending %>" --state open --json number,title,labels,body --limit 20
-```
-
-If no issues are returned, report "No work available" and STOP.
-
-### 2. Filter by Role
-
-From the returned issues, select only those with at least one of these labels:
-- `role:developer`
-- `task:implementation`
-- `task:bug-fix`
-- `task:refactor`
-- `task:test-generation`
-- `task:documentation`
-
-Exclude issues labeled `role:architect` or `role:auditor` (those require different capability bundles).
-
-### 3. Sort by Priority
-
-Order the filtered issues by priority label:
-
-1. `priority:critical` (highest)
-2. `priority:high`
-3. `priority:medium`
-4. `priority:low` (lowest)
-
-Issues without a priority label are treated as `priority:low`.
-
-Select the highest-priority issue.
-
-### 4. Check Dependencies
-
-If the selected issue body contains a `## Dependencies` section with issue references (e.g., `#41, #39`), verify each dependency is closed:
-
-```bash
-gh issue view --json state --jq '.state'
-```
-
-If any dependency is still `OPEN`:
-- Report: "Issue #N has unresolved dependencies: #X (open)"
-- Skip this issue and select the next highest-priority issue
-- Repeat until an issue with no blocking dependencies is found
-
-### 5. Check Escalation Context
-
-Before finalizing issue selection, check the current governance escalation level:
-
-```bash
-cat <%= paths.logs %> 2>/dev/null | grep -i "escalat\|StateChanged" | tail -5
-```
-
-Determine the current escalation state:
-- **NORMAL** (level 0): all issues eligible
-- **ELEVATED** (level 1): prefer issues with smaller File Scope (fewer files)
-- **HIGH** (level 2): only select issues with explicit File Scope of 5 files or fewer
-- **LOCKDOWN** (level 3): report "Governance LOCKDOWN active — deferring new work" and STOP
-
-If telemetry data is unavailable, assume NORMAL and proceed.
-
-### 6. Estimate Blast Radius
-
-For the selected issue, estimate the governance risk:
-
-If the issue body contains a `## File Scope` section, count the listed files. Then simulate:
-
-```bash
-<%= paths.cli %> simulate --action file.write --target --policy <%= paths.policy %> --json 2>/dev/null
-```
-
-Classify the estimated blast radius:
-- **1-5 files**: low risk
-- **6-15 files**: medium risk
-- **16+ files**: high risk
-
-If escalation is ELEVATED and the estimated blast radius is high, prefer the next lower-risk issue.
-
-If the simulate command is not available, skip this step.
-
-### 7. Display Issue Details
-
-For the selected issue, output:
-
-- **Issue number** and **title**
-- **Labels** (all)
-- **Estimated risk level**: low / medium / high (from blast radius estimate)
-- **Current escalation**: NORMAL / ELEVATED / HIGH
-- **Task Description** section from the body
-- **Acceptance Criteria** section from the body
-- **File Scope** section from the body (if present)
-- **Dependencies** section (if present, with status of each)
-
-## Rules
-
-- If no pending issues exist, report "No work available" and STOP
-- If all pending issues have unresolved dependencies, report "All pending issues blocked by dependencies" and STOP
-- If governance is in LOCKDOWN, report and STOP — do not select any issue
-- If escalation is HIGH, only select issues with small file scope (5 files or fewer)
-- Do not select issues that are already `status:in-progress` or `status:assigned`
-- Output the selected issue number clearly — it is needed by `claim-issue`
diff --git a/packages/swarm/templates/skills/full-test.md b/packages/swarm/templates/skills/full-test.md
deleted file mode 100644
index 8c9650d9..00000000
--- a/packages/swarm/templates/skills/full-test.md
+++ /dev/null
@@ -1,83 +0,0 @@
-# Skill: Full Test
-
-Run the complete build, type-check, test, lint, format, and coverage verification suite. This is the comprehensive "is everything OK?" check for the AgentGuard codebase.
-
-## Steps
-
-Run these in sequence. If any step fails, stop and analyze before proceeding.
-
-### 1. Build TypeScript
-
-```bash
-pnpm build
-```
-
-Compiles all workspace packages via Turborepo. Report build success or failure with error details.
-
-### 2. Type-Check
-
-```bash
-pnpm ts:check
-```
-
-Runs `tsc --noEmit` for strict type verification. Report any type errors with file:line references.
-
-### 3. Run Tests (vitest)
-
-```bash
-pnpm test
-```
-
-Report pass/fail count. If tests fail, note the failing test names and error messages.
-
-### 4. Run ESLint
-
-```bash
-pnpm lint
-```
-
-Report any lint errors with file:line references.
-
-### 5. Run Prettier Format Check
-
-```bash
-pnpm format
-```
-
-Report any formatting issues.
-
-### 6. Run Coverage Check
-
-```bash
-pnpm test:coverage
-```
-
-Report line coverage percentage. The project threshold is 50% line coverage.
-
-### 7. Summary
-
-Provide a structured pass/fail summary:
-
-```
-## Full Test Report
-
-| Check | Status | Details |
-|-------|--------|---------|
-| Build | PASS/FAIL | |
-| Type-check | PASS/FAIL | |
-| Tests (vitest) | PASS/FAIL | |
-| Lint | PASS/FAIL | |
-| Format | PASS/FAIL | |
-| Coverage | PASS/FAIL | |
-```
-
-One-line verdict:
-- **All clear**: "All 6 checks passed — codebase healthy"
-- **Issues found**: "N/6 checks failed — see details above"
-
-## Rules
-
-- **Read-only** — do not fix, modify, or commit anything. This skill only reports.
-- Run all steps even if earlier steps fail — report the full picture.
-- If a command times out (>2 minutes), note the timeout and continue.
-- If `node_modules` is missing, run `pnpm install` first, then proceed.
diff --git a/packages/swarm/templates/skills/generate-tests.md b/packages/swarm/templates/skills/generate-tests.md
deleted file mode 100644
index 75b807f4..00000000
--- a/packages/swarm/templates/skills/generate-tests.md
+++ /dev/null
@@ -1,146 +0,0 @@
-# Skill: Generate Tests
-
-Analyze untested source modules, generate test files following existing vitest patterns, and create a PR. Transforms the Test Agent from observer to actor. Designed for periodic scheduled execution after `test-health-review` identifies coverage gaps.
-
-## Prerequisites
-
-Run `start-governance-runtime` first. All scheduled skills must operate under governance.
-
-## Steps
-
-### 1. Start Governance Runtime
-
-Invoke the `start-governance-runtime` skill to ensure the AgentGuard kernel is active. If governance cannot be activated, STOP.
-
-### 2. Identify Untested Modules
-
-List source files and their corresponding test files:
-
-```bash
-find packages apps -name "*.ts" -not -name "*.d.ts" -not -path "*/node_modules/*" -not -path "*/dist/*" | sort
-find packages apps -name "*.test.ts" -not -path "*/node_modules/*" | sort
-```
-
-For each source file, check if a corresponding test file exists in the same package's `tests/` directory. For example, `packages/kernel/src/kernel.ts` should have a test at `packages/kernel/tests/kernel.test.ts`.
-
-Prioritize untested files by:
-1. Core kernel files (`packages/kernel/src/`) — highest priority
-2. Policy and invariant files (`packages/policy/src/`, `packages/invariants/src/`)
-3. Adapter files (`packages/adapters/src/`)
-4. CLI command files (`apps/cli/src/commands/`)
-5. Utility files (`packages/core/src/`)
-
-### 3. Study Existing Test Patterns
-
-Read 2-3 existing test files to understand conventions:
-
-```bash
-cat packages/kernel/tests/agentguard-aab.test.ts | head -50
-cat packages/kernel/tests/agentguard-engine.test.ts | head -50
-```
-
-Extract patterns:
-- Import style (`import { describe, it, expect } from 'vitest'`)
-- Test structure (`describe` → `it` blocks)
-- Assertion patterns (`expect(...).toBe(...)`, `expect(...).toThrow(...)`)
-- Mock/stub patterns (how dependencies are isolated)
-- Naming conventions for test descriptions
-
-### 4. Select Target Module
-
-Pick the highest-priority untested module (max 1 per run). Read the source file to understand:
-
-- Exported functions and classes
-- Input types and return types
-- Edge cases (null handling, error paths, boundary values)
-- Dependencies that need mocking
-
-```bash
-cat packages//src/.ts
-```
-
-### 5. Generate Test File
-
-Create a test file following the established patterns:
-
-- File path: `packages//tests/.test.ts`
-- Import the module under test
-- Use `describe` blocks matching exported functions/classes
-- Include tests for:
- - Happy path (normal inputs → expected outputs)
- - Edge cases (empty inputs, null/undefined, boundary values)
- - Error cases (invalid inputs → expected errors)
- - Type contracts (return types match declarations)
-- Use mocks/stubs for external dependencies (file system, network, git)
-
-### 6. Verify Tests Pass
-
-```bash
-pnpm build
-npx vitest run packages//tests/.test.ts
-```
-
-If tests fail:
-- Fix test logic (not source code — this skill writes tests, not fixes)
-- Re-run until tests pass
-- If tests cannot pass after 2 attempts, STOP and report the issue
-
-### 7. Commit and Create PR
-
-```bash
-git checkout -b test/add--tests
-git add packages//tests/.test.ts
-git commit -m "test: add tests for "
-git push -u origin test/add--tests
-```
-
-Create PR:
-
-```bash
-gh pr create \
- --title "test: add tests for " \
- --body "## Summary
-
-Adds test coverage for \`packages//src/.ts\`.
-
-## Test Coverage
-
-- test cases covering:
- - Happy path scenarios
- - Edge cases
- - Error handling
-
-## Generated By
-
-Auto-generated by the \`generate-tests\` skill (Test Agent).
-
----
-*source:test-agent*" \
- --label "source:test-agent"
-```
-
-Ensure label exists:
-
-```bash
-gh label create "source:test-agent" --color "0E8A16" --description "Auto-created by Test Agent" 2>/dev/null || true
-```
-
-### 8. Summary
-
-Report:
-- **Module tested**: `packages//src/`
-- **Test file created**: `packages//tests/.test.ts`
-- **Test cases**: N (N passing)
-- **PR created**: #
-- If no untested modules found: "All source modules have test coverage"
-
-## Rules
-
-- **Generate tests for 1 module per run** — do not batch multiple modules.
-- **Never modify source code** — only create test files. If tests fail because of a bug in the source, report the bug but do not fix it.
-- **Follow existing test patterns exactly** — match the import style, describe/it structure, and assertion patterns from existing tests.
-- **Never delete existing test files** — only add new ones.
-- **Never overwrite existing test files** — if a test file already exists for the target module, skip it.
-- If `pnpm build` fails, STOP — the codebase must compile before tests can be generated.
-- If `gh` CLI is not authenticated, still generate the test file locally but skip PR creation.
-- Target modules must be in `packages/*/src/` or `apps/*/src/` — do not generate tests for files outside the source tree.
diff --git a/packages/swarm/templates/skills/governance-log-audit.md b/packages/swarm/templates/skills/governance-log-audit.md
deleted file mode 100644
index 6437d5fe..00000000
--- a/packages/swarm/templates/skills/governance-log-audit.md
+++ /dev/null
@@ -1,302 +0,0 @@
-# Skill: Governance Log Audit
-
-Analyze governance event logs for cross-session trends, escalation trajectory, risk score progression, and per-agent governance compliance. Uses the AgentGuard analytics engine for aggregation and decision records for rich outcome analysis. Focuses on historical pattern analysis and compliance reporting — leave real-time anomaly detection to the Observability Agent, and policy quality analysis to `policy-effectiveness-review`. Creates an issue if actionable findings exist. Designed for periodic scheduled execution.
-
-## Autonomy Directive
-
-This skill runs as an **unattended scheduled task**. No human is present to answer questions.
-
-- **NEVER pause to ask for clarification or confirmation** — make your best judgment and proceed
-- **NEVER use AskUserQuestion or any interactive prompt** — all decisions must be made autonomously
-- If data is unavailable or ambiguous, proceed with available data and note limitations
-- If governance activation fails, log the failure and **STOP**
-- If `gh` CLI fails, log the error and **STOP**
-- Default to the **safest option** in every ambiguous situation
-
-## Prerequisites
-
-Run `start-governance-runtime` first. All scheduled skills must operate under governance — even log analysis should be auditable.
-
-## Steps
-
-### 1. Start Governance Runtime
-
-Invoke the `start-governance-runtime` skill to ensure the AgentGuard kernel is active and intercepting all tool calls. If governance cannot be activated, STOP — do not proceed without governance.
-
-### 2. Locate Log Files
-
-```bash
-ls -la .agentguard/events/*.jsonl 2>/dev/null
-ls -la .agentguard/decisions/*.jsonl 2>/dev/null
-ls -la <%= paths.logs %> 2>/dev/null
-```
-
-If no log files exist, report "No governance logs found — nothing to audit" and STOP.
-
-### 3. Run Cross-Session Analytics
-
-Use the AgentGuard analytics engine for aggregated cross-session data:
-
-```bash
-<%= paths.cli %> analytics --format json 2>/dev/null | head -200
-```
-
-Extract:
-- **Total sessions** analyzed
-- **Per-session risk scores** and risk levels
-- **Violation clustering**: which action types, targets, and branches produce the most violations
-- **Denial rate trend**: increasing, stable, or decreasing across sessions
-- **Top violation patterns**: recurring invariant or policy violations
-
-If the analytics command is not available, fall back to manual counting in Step 4.
-
-### 4. Count Events by Type
-
-Count each governance event type across all log files:
-
-```bash
-cat .agentguard/events/*.jsonl 2>/dev/null | grep -c "ActionRequested" || echo 0
-cat .agentguard/events/*.jsonl 2>/dev/null | grep -c "ActionAllowed" || echo 0
-cat .agentguard/events/*.jsonl 2>/dev/null | grep -c "ActionDenied" || echo 0
-cat .agentguard/events/*.jsonl 2>/dev/null | grep -c "PolicyDenied" || echo 0
-cat .agentguard/events/*.jsonl 2>/dev/null | grep -c "InvariantViolation" || echo 0
-cat .agentguard/events/*.jsonl 2>/dev/null | grep -c "ActionEscalated" || echo 0
-cat .agentguard/events/*.jsonl 2>/dev/null | grep -c "BlastRadiusExceeded" || echo 0
-cat .agentguard/events/*.jsonl 2>/dev/null | grep -c "MergeGuardFailure" || echo 0
-```
-
-Also count total events:
-
-```bash
-cat .agentguard/events/*.jsonl 2>/dev/null | wc -l
-```
-
-### 5. Analyze Decision Records
-
-Read decision records for richer outcome analysis:
-
-```bash
-cat .agentguard/decisions/*.jsonl 2>/dev/null | head -200
-```
-
-Parse each `GovernanceDecisionRecord` and aggregate:
-- **Outcome distribution**: allow vs. deny counts
-- **Intervention types**: deny, rollback, pause, test-only (count each)
-- **Escalation levels**: Distribution of NORMAL through LOCKDOWN
-- **Top denial reasons**: Group by reason, count occurrences
-- **Execution success rate**: succeeded vs. failed
-- **Per-session risk scores**: Extract and track over time
-
-### 6. Compute Metrics
-
-Calculate key governance health metrics:
-
-- **Denial rate**: `(ActionDenied + PolicyDenied) / ActionRequested * 100`
-- **Invariant violation rate**: `InvariantViolation / ActionRequested * 100`
-- **Escalation count**: total ActionEscalated events
-- **Average risk score**: mean of per-session risk scores
-
-Flag these thresholds:
-- Denial rate > 20% → **WARNING**
-- Denial rate > 50% → **CRITICAL**
-- Any InvariantViolation → **WARNING**
-- Any ActionEscalated → **WARNING**
-- Any BlastRadiusExceeded → **WARNING**
-- Average risk score > 50 → **WARNING**
-- Any session risk score > 70 → **CRITICAL**
-
-### 7. Analyze Per-Agent Compliance
-
-Group events by agent identity (extract from event metadata):
-
-```bash
-cat .agentguard/events/*.jsonl 2>/dev/null | grep "ActionDenied\|PolicyDenied" | head -100
-```
-
-For each agent:
-- **Total actions requested**
-- **Denial count and rate**
-- **Types of denials** (policy vs. invariant)
-- **Compliance score**: `(allowed / total) * 100`
-
-Identify:
-- **Compliant agents**: denial rate <5%
-- **Boundary-testing agents**: denial rate 5-20%
-- **Non-compliant agents**: denial rate >20% (persistent bad behavior)
-
-### 8. Analyze Cross-Session Trends
-
-If multiple log files exist (each representing a session), compare across sessions:
-
-```bash
-ls -lt .agentguard/events/*.jsonl 2>/dev/null | head -10
-```
-
-For the last 5 sessions, compute:
-- Denial rate per session (is it trending up or down?)
-- Risk score per session (from analytics or decision records)
-- Escalation levels reached per session
-- Most common denial reason per session
-- Session duration and event volume
-
-Look for:
-- **Improving trend**: denial rate decreasing, risk scores declining across sessions (agents learning)
-- **Degrading trend**: denial rate increasing, risk scores rising (new bad patterns emerging)
-- **Escalation trajectory**: are sessions reaching higher escalation levels over time?
-
-### 9. Check Escalation History
-
-Read all escalation-related events across sessions:
-
-```bash
-cat .agentguard/events/*.jsonl 2>/dev/null | grep -i "escalat\|lockdown" | tail -20
-```
-
-Build an escalation timeline:
-- When did each escalation occur?
-- What action triggered it?
-- Did the system recover (de-escalate) or remain elevated?
-- Any LOCKDOWN events → **CRITICAL**
-
-### 10. Generate Report
-
-Compile the audit findings into a structured report:
-
-```
-## Governance Log Audit Report
-
-**Date**:
-**Log files analyzed**:
-**Decision records analyzed**:
-**Total events**:
-**Sessions covered**:
-
-### Event Summary
-
-| Event Type | Count |
-|------------|-------|
-| ActionRequested | N |
-| ActionAllowed | N |
-| ActionDenied | N |
-| PolicyDenied | N |
-| InvariantViolation | N |
-| ActionEscalated | N |
-| BlastRadiusExceeded | N |
-
-### Health Metrics
-
-| Metric | Value | Status |
-|--------|-------|--------|
-| Denial rate | X% | OK/WARNING/CRITICAL |
-| Invariant violation rate | X% | OK/WARNING |
-| Escalation events | N | OK/WARNING |
-| Average risk score | N/100 | OK/WARNING/CRITICAL |
-
-### Risk Score Trend
-
-| Session | Date | Risk Score | Risk Level | Trend |
-|---------|------|------------|------------|-------|
-| | | N/100 | low/medium/high/critical | ↑/↓/→ |
-
-### Decision Record Analysis
-
-| Metric | Value |
-|--------|-------|
-| Total decisions | N |
-| Deny outcomes | N |
-| Intervention types | deny: N, rollback: N, pause: N |
-| Execution success rate | N% |
-
-### Per-Agent Compliance
-
-| Agent | Actions | Denials | Compliance | Status |
-|-------|---------|---------|------------|--------|
-| | N | N | X% | COMPLIANT/BOUNDARY/NON-COMPLIANT |
-
-### Cross-Session Trends
-
-| Session | Date | Events | Denial Rate | Risk Score | Max Escalation |
-|---------|------|--------|-------------|------------|----------------|
-| | | N | X% | N/100 | NORMAL/ELEVATED/HIGH/LOCKDOWN |
-
-**Trend**: Improving / Stable / Degrading
-
-### Escalation Timeline
-
-
-
-### Recommendations
-
-
-```
-
-### 11. Create or Update Issue (if actionable)
-
-If any WARNING or CRITICAL findings exist, check for an existing audit issue:
-
-```bash
-gh issue list --state open --label "source:governance-audit" --json number,title --limit 1
-```
-
-Apply the `report-routing` protocol:
-
-**If CRITICAL findings** (LOCKDOWN events, escalation trending toward critical, sustained high denial rate >20%) → **ALERT tier**:
-
-Ensure the label exists:
-
-```bash
-gh label create "source:governance-audit" --color "D93F0B" --description "Auto-created by Governance Log Audit skill" 2>/dev/null || true
-```
-
-```bash
-gh issue create \
- --title "ALERT: governance-audit — " \
- --body "