Agentic Workflow

Darwin component map

The architectural inventory — every named piece of the agent execution stack and how they connect.

This page is the ground truth for the PRD-to-PR pipeline: which Darwin components are wired in today, which are useful but parked in a separate vertical, and which are outstanding. The prioritized "outstanding" list in §(c) is the build queue.

The audit pass that produced this map ran 2026-04-30 across be-agent-service/agents/prompts/, be-agent-service/apps/server/, beta-appcaire/.claude/agents/, beta-appcaire/scripts/, beta-appcaire/.github/workflows/, and beta-appcaire/docs/dossiers/. Refreshed 2026-04-30 evening after the runner end-to-end validation.

(a) Used by PRD-to-PR pipeline (engineering vertical)

These components are invoked by the pipeline today. Components marked (2026-04-30) moved here from §(c) after shipping.

Component Location Pipeline use
POST /api/prd-to-pr + 9-stage runner (2026-04-30) be-agent-service/apps/server/{routes/prd-to-pr.ts,pipeline/runner.ts} The state machine that walks every stage. Persists transitions to prd_to_pr_runs in agent-service.db. Honors MAX_REVIEW_CYCLES=3, MAX_CONCURRENT_PRD_RUNS=10, MAX_RUNS_PER_DAY=30. Re-entry edges 5→4 and 6→4.
Stage modules (2026-04-30) be-agent-service/apps/server/src/pipeline/stages/{intake,prd,spec,tests,implement,review,verify,reviewerLoop,merge}.ts One per stage. intake.ts does worktree creation + env replication + yarn install + yarn generate + per-server db:generate. tests.ts WIP-commits the architect's spec and the test-writer's tests so the editor's git stash can't destroy them. implement.ts runs the iteration loop with transactional stash. verify.ts runs the dossier bundler then re-enters implement on Playwright failure with a verifyHint.
Dossier bundler (2026-04-30) be-agent-service/apps/server/src/pipeline/dossier.ts Captures Playwright trace + final-state screenshot, filters console output, emits summary.json + a human-readable README.md, writes everything to docs/dossiers/<feature>/ and stages a commit. Stage 6 fails if any required artifact is missing.
Named agent prompts (2026-04-30) be-agent-service/agents/prompts/engineering/{architect,test-writer,editor,verifier,reviewer-feedback}.md Spawned via claude -p in their respective stages. architect.md is route-locked (must copy /, /home, etc. verbatim from PRD). editor.md carries the iteration contract.
L1 dashboard pages (2026-04-30) be-agent-service/apps/dashboard/src/pages/PRDToPR{Page,DetailPage}.tsx Run list, detail view with live-ticking elapsed clock, per-stage timing table fed from summary_json.stageHistory[], artifact viewer (PRD body / spec / tests / diff / dossier), Approve / Reject buttons. Stage log endpoint globs <stage>.*.log so every agent invocation surfaces.
Codex / CodeRabbit polling (2026-04-30) be-agent-service/apps/server/src/pipeline/stages/reviewerLoop.ts Runs gh push then polls gh api repos/{org}/{repo}/pulls/<n>/comments. Parses P1/P2/P3 severity. Re-enters implement on unresolved P1/P2; argues down via PR description text where applicable.
Auto-kill switch + Max Plan OAuth (2026-04-30) be-agent-service/apps/server/src/pipeline/env.ts enforceAutoKillSwitch() blocks new runs past concurrency / daily caps; HTTP 429 surfaced. isMaxPlanPreferred() reads CLAUDE_USE_MAX_PLAN=1 from ~/.config/caire/env and strips ANTHROPIC_API_KEY from spawned subprocess env so claude -p falls through to the macOS Keychain OAuth credentials.
Three review subagents — resolver-reviewer, dashboard-reviewer, perf-reviewer beta-appcaire/.claude/agents/*.md (tracked via a .gitignore negation rule that re-includes .claude/agents/**) Stage 5. Wired and invoked in parallel before stage 6 verify. Routing decided by the architect's spec metadata.
engineering/orchestrator agent prompt be-agent-service/agents/prompts/engineering/orchestrator.md Coordinates the compound nightly workflow. Not invoked by the PRD-to-PR runner — the runner.ts state machine plays that role.
engineering/backend-specialist, frontend-specialist, db-architect-specialist, infrastructure-specialist, ux-designer-specialist be-agent-service/agents/prompts/engineering/*.md Available to Cursor Composer / Claude Code in a worktree (the L0 path). Not invoked by the PRD-to-PR runner — that path uses the named editor.md agent.
engineering/senior-code-reviewer, verification-specialist be-agent-service/agents/prompts/engineering/*.md Same: L0 path.
management/interface-agent be-agent-service/agents/prompts/management/interface-agent.md Target-state stage 0 / stage 8 Telegram bridge. Already brokers Telegram traffic for ad-hoc requests; needs a routing rule to recognise PRD-style messages — see §(c).1 below.
management/cpo-cto be-agent-service/agents/prompts/management/cpo-cto.md Target-state cross-team router and quarterly model-routing ratifier (per model-and-vendor-agnosticism.md).
Darwin runtime be-agent-service/apps/server/src/index.ts:42 (port 3010) HTTP host for /api/prd-to-pr/*. Also serves /api/repos, /api/agents, /api/workspace, /api/jobs, /api/schedules, /api/metrics.
SQLite state .compound-state/agent-service.db Persists prd_to_pr_runs rows + per-stage stageHistory[] in summary_json. Throughput log per throughput-and-business-signals.md.
Launchd job slots be-agent-service/scripts/manage-darwin-dashboard-launchd.sh Hosts the unified server in production. Same job slot also runs schedule research and compound nightly.
Compound nightly workflow be-agent-service/scripts/compound/{auto-compound,daily-compound-review,loop,analyze-report}.sh Separate vertical (priorities-driven nightly review). Pre-existing; not replaced by the PRD-to-PR runner.
Worktree scripts beta-appcaire/scripts/git/worktree-{add,remove}.sh Stage 0 worktree creation. Mandatory for PRD-driven work per the standing memory rule.
GitHub Merge Queue beta-appcaire/.github/workflows/pr-checks.yml (merge_group: triggers, dashboard-server tests (required for merge) aggregator) Stage 8 gate. Live; the pipeline targets it via gh pr merge --auto --squash.
docs/dossiers/<feature>/ beta-appcaire/docs/dossiers/* Stage 6 storage. Now populated automatically by the dossier bundler. Pre-existing hand-crafted dossiers (e.g. visit-chain-scope) remain as historical reference.
wiki/plans/<feature>-YYYY-MM-DD.md PRD convention beta-appcaire/wiki/plans/* Stage 1 input. Convention is in active use; humans write PRDs here.

(b) Parked — separate verticals, not used by PRD-to-PR

These components are part of Darwin but solve different problems. They should not be merged into the PRD-to-PR pipeline; mixing verticals produces ambiguous orchestration. Listed here so the reader can rule them out without re-doing the audit.

Component Location Why it's not in the PRD-to-PR pipeline
Marketing team — jarvis-orchestrator, shuri-product-analyst, fury-customer-researcher, vision-seo-analyst, loki-content-writer, quill-social-media, pepper-email-marketing, wanda-designer, friday-developer, wong-notion-agent be-agent-service/agents/prompts/marketing/*.md Marketing/content vertical with its own pipeline (loki-content-writer.sh etc.) and its own humanizer skill. Different intake, different output.
Optimization team — optimization-mathematician, timefold-specialist be-agent-service/agents/prompts/optimization/*.md Schedule research vertical. Reads benchmark history, proposes constraint-weight changes. Consumes the throughput log produced by the PRD-to-PR pipeline (per throughput-and-business-signals.md) but is not part of it.
management/ceo, management/hr-agent-lead be-agent-service/agents/prompts/management/*.md Strategic / org concerns. Useful for budget allocation per vision commitment (d), but not invoked per-PR.
Hannes Dashboard be-agent-service/scripts/manage-hannes-dashboard-launchd.sh Separate launchd job for a separate stakeholder view. Distinct concern from the engineering Dashboard at localhost:3010.
Schedule research loop be-agent-service/apps/server/src/routes/schedule-runs/* Optimization vertical's runtime. Reuses Darwin's launchd slots and SQLite, but is not feature delivery.

(c) Outstanding — the prioritized build queue

Items 1–5 from the original queue (pipeline runner, dossier bundler, Codex polling, named agent prompts, L1 dashboard UI) shipped between commits 92bc142 and 0270e90 and have moved to §(a). What remains:

1. Telegram → POST /api/prd-to-pr routing — ~1 day

2. Runner orphan resilience — ~half a day

3. Per-iteration live telemetry inside stage 4 — ~half a day

4. Token / cost accounting

5. (Defer) Model adapter + scale-or-kill / GrowthBook ramp

How to use this map

Cross-references