feat(desktop,trpc,db,mcp,cli,api,relay): Factory — self-improving issue→PR agent pipeline
KI
2mo ago+21526+21526+01234567890123456789012345678901234567890123456789-8-8-0123456789
A new Factory tab: GitHub issues flow through per-stage agents (classify → analyze → implement → review → human merge gate → verify) running in real workspaces on the user's own hosts — Vercel ai-sdk-factory shaped, local-first. Plan + decisions: `plans/20260812-factory.md`.
What's inside
- Pipeline core: `factories` / `factory_items` (idempotent materialization keys, CAS revisions) / `factory_runs` (evidence ledger with outcomes) / versioned `factory_stage_prompts` (migrations 0066–0068). Stage dispatch reuses the automation dispatch path (shared host-resolution helpers).
- Typed agent reporting: `factory_report` / `factory_propose_prompt` MCP tools + `superset factory report|propose-prompt` CLI fallback (dispatch prompts embed the exact command).
- Self-improvement: thumbs-down runs with notes → improve meta-agent drafts a new stage-prompt version → human approves; signal resets per version.
- Autonomy: `issues.opened`/merged-PR webhooks (App event enabled), optional autoAdvance, QStash-queued dispatch (`/api/factory/dispatch-stage`) with inline fallback, host-side `gh` issue import.
- Tasks mirror: implement creates a started task (Linear-synced), done/rejected completes/cancels it.
- Visibility: stats header, needs-attention strip, stage-age indicators, Metrics sub-view (cycle p50/p90, delivery flow, queue-health age bars — CVD-validated palette, automation coverage).
- Relay: `RELAY_TUNNEL_REQUEST_TIMEOUT_MS` knob (default unchanged 30s) — worktree creation on large repos exceeds 30s.
Verification
- Full-repo typecheck/lint clean; CDP-driven E2E of every UI state (screenshots + demo videos recorded).
- Live E2E completed: with a local relay, a real Claude session classified openclaw#122872 in a real worktree and reported through the CLI fallback; CAS advanced the item. Two live-run findings fixed in this PR (relay timeout knob; skipped-run ledger rows).
- Known follow-ups (in plan): eval replay before prompt activation, trust rules/read-only stages for public repos, per-factory concurrency budget, attempt-scoped branch naming for dispatch retries.
Summary by cubic
Adds a desktop Factory tab and backend that turns GitHub issues into a staged, self‑improving issue→PR pipeline on users’ own hosts. Stages now run in one pinned workspace per item and improve runs reuse a stable factory/improve workspace per factory; manual merge→verify gates auto‑dispatch when autoAdvance is on.
- Run DB migrations
0067_factoryand0068_factory_item_workspace_pin. - QStash: set
QSTASH_TOKENand signing keys; verify/api/factory/dispatch-stageand schedule/api/factory/evaluate(heartbeat polling/sweep). Without QStash, dispatch falls back inline and polling is disabled. - GitHub App: enable Issues events;
issues.opened/reopenedintake and merged‑PR gate deliver toapps/api(optional when heartbeat polling is enabled). - MCP/CLI: ensure
packages/mcpregistersfactory_reportandfactory_propose_prompt; stage agents must callfactory_report; the improve meta‑agent must callfactory_propose_prompt(CLI fallbacks inpackages/cli). - Relay: set
RELAY_TUNNEL_REQUEST_TIMEOUT_MSif large repos exceed 30s workspace creation. - Clients: confirm
factoryrouter in@superset/trpcand/factorynavigation in desktop.
Summary by CodeRabbit
- New Features
- Added a Factory dashboard for managing GitHub issues through staged workflows.
- Added factory creation, issue intake, board views, item details, metrics, alerts, and stage controls.
- Added GitHub webhook and scheduled polling automation for new issues and merged pull requests.
- Added prompt editing, self-improvement workflows, and reviewable prompt drafts.
- Added CLI and MCP tools for reporting runs and proposing prompt improvements.
- Added Factory navigation to the desktop sidebar and command palette.
- Improvements
- Added configurable relay request timeouts and more reliable queued stage execution.
- Added automatic task synchronization as factory items progress.