Skip to content

Plan B: MCP state server + independent worker processes - #6

Merged
adbarc92 merged 11 commits into
mainfrom
feat/engine-plan-b-server-workers
Jul 25, 2026
Merged

Plan B: MCP state server + independent worker processes#6
adbarc92 merged 11 commits into
mainfrom
feat/engine-plan-b-server-workers

Conversation

@adbarc92

Copy link
Copy Markdown
Owner

Plan B — MCP state server + independent worker processes

Second of the engine build (Plan A landed in #5). This makes the "MCP-based state server" and "independent processes resolving execution order and shared state without collision" resume claims literally demonstrable, and brings the whole engine to CI-green.

What this adds (on top of Plan A's coordination core)

  • state_server.py — a genuine FastMCP server (streamable-HTTP, mcp==1.28.1) wrapping the single-writer Store, running the reaper; launchable as python -m backend.engine.state_server (+ appforge_mcp_server.py alias).
  • mcp_tools.py / client.py — the full MCP tool surface (create/claim/complete/heartbeat/fail/approve/get_state/put_state/get_run), JSON in/out; EngineClient MCP-client wrapper.
  • agent_adapter.py — task→agent bridge via the existing registry (mock/real), including the Clarify Q&A loop that produces a PRD from mock agents autonomously.
  • worker.py — the independent worker loop (claim → execute + background heartbeat → complete/fail), runnable as python -m backend.engine.worker.
  • run.py — controller/CLI that boots the server, spawns N worker subprocesses, drives approval gates, and tears everything down leak-free.
  • Read-only Store.snapshot.

Evidence

  • Marquee multi-process demo (tests/engine/test_run_e2e.py): a full pipeline runs across 3 real OS worker subprocesses (distinct PIDs), traversing all six phases (Clarify→Design→Code→Test→Deploy→Iterate) to done.
  • Two-process state sharing (test_server_state.py): two independent MCP clients share state through the server, incl. a CAS conflict.
  • Every task went through TDD + an independent spec/quality review; the whole branch had a final opus whole-branch review (verdict: ready to merge, no Critical/Important).
  • CI-green: ruff check 0 errors, black --check clean, pytest tests/ = 168 passed, 86.99% coverage (gate 70%).

Note on the diff

This PR also reformats the Plan A files already on main (store.py, scheduler.py, etc.) with black + ruff. Plan A merged (#5) before that cleanup existed, so main is currently failing black --check; merging this PR fixes it. The reformatting is style-only (verified behavior-preserving in review).

Deferred to Plan C (scoped out, not broken)

Live claim-time budget downgrade + a real-run assertion; the N≫workers concurrency stress test (the true collision-freedom proof); preserved documented-run artifacts under docs/runs/; reaper MAX_ATTEMPTS cap; LangGraph orchestrator retirement + its ~25 coupled tests; the Socket.IO events bridge; installing the repo so the bare appforge console script is on PATH (today python -m backend.engine.run run "<idea>" works).

@adbarc92
adbarc92 merged commit 1deec04 into main Jul 25, 2026
0 of 5 checks passed
@adbarc92
adbarc92 deleted the feat/engine-plan-b-server-workers branch July 25, 2026 02:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant