Plan B: MCP state server + independent worker processes - #6
Merged
Conversation
… mcp==1.28.1 contract)
…artbeat cancel; strengthen clarify test
…fe; await reaper; robust client error path
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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-writerStore, running the reaper; launchable aspython -m backend.engine.state_server(+appforge_mcp_server.pyalias).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;EngineClientMCP-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 aspython -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.Store.snapshot.Evidence
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) todone.test_server_state.py): two independent MCP clients share state through the server, incl. a CAS conflict.ruff check0 errors,black --checkclean,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.) withblack+ruff. Plan A merged (#5) before that cleanup existed, somainis currently failingblack --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/; reaperMAX_ATTEMPTScap; LangGraph orchestrator retirement + its ~25 coupled tests; the Socket.IO events bridge; installing the repo so the bareappforgeconsole script is on PATH (todaypython -m backend.engine.run run "<idea>"works).