Implement Phase 3: dynamic graph builder, blueprint persistence, and CRUD API
- Add dynamic_graph_builder.py that constructs LangGraph graphs at runtime
from frontend CouncilBlueprint JSON (no more hardcoded graphs in production)
- Add PostgreSQL persistence via SQLAlchemy async with Blueprint model
- Add blueprint CRUD endpoints (POST/GET/PUT/DELETE /api/councils/)
- Add POST /api/councils/{id}/run to execute blueprints dynamically
- Add Alembic migration infrastructure with initial blueprints table
- Add database.py with async engine and SQLite fallback for dev/test
- Fix missing typing-extensions and add aiosqlite dependency
- Add 42 new tests (80/80 total passing) covering dynamic graph building,
blueprint service CRUD, and API integration
https://claude.ai/code/session_014yZUxrPsgZbvkebXbCXR4U
This commit is contained in:
parent
89ba3aacd4
commit
437db4ca68
16 changed files with 1698 additions and 11 deletions
|
|
@ -5,10 +5,16 @@ Start the server:
|
|||
uvicorn main:app --reload --port 8000
|
||||
|
||||
API Overview:
|
||||
POST /api/councils/run — Start a council run
|
||||
GET /api/councils/run/{run_id} — Poll run status/result
|
||||
GET /api/health — Health check
|
||||
WS /ws/council/{run_id} — Real-time agent status events
|
||||
POST /api/councils/ — Create a blueprint
|
||||
GET /api/councils/ — List all blueprints
|
||||
GET /api/councils/{id} — Get specific blueprint
|
||||
PUT /api/councils/{id} — Update a blueprint
|
||||
DELETE /api/councils/{id} — Delete a blueprint
|
||||
POST /api/councils/run — Start a run (Phase 1 hard-coded graph)
|
||||
POST /api/councils/{id}/run — Start a run from a blueprint (Phase 3)
|
||||
GET /api/councils/run/{run_id} — Poll run status/result
|
||||
GET /api/health — Health check
|
||||
WS /ws/council/{run_id} — Real-time agent status events
|
||||
"""
|
||||
|
||||
from contextlib import asynccontextmanager
|
||||
|
|
@ -16,14 +22,19 @@ from fastapi import FastAPI
|
|||
from fastapi.middleware.cors import CORSMiddleware
|
||||
|
||||
from api.routes import router
|
||||
from api.blueprint_routes import blueprint_router
|
||||
from api.websocket import ws_router
|
||||
from database import init_db, close_db
|
||||
|
||||
|
||||
@asynccontextmanager
|
||||
async def lifespan(app: FastAPI):
|
||||
"""Application lifespan: startup and shutdown logic."""
|
||||
print("CouncilOS API starting up...")
|
||||
await init_db()
|
||||
print("Database initialized.")
|
||||
yield
|
||||
await close_db()
|
||||
print("CouncilOS API shutting down...")
|
||||
|
||||
|
||||
|
|
@ -34,7 +45,7 @@ app = FastAPI(
|
|||
"Orchestrates LangGraph council runs and streams real-time agent "
|
||||
"status via WebSockets."
|
||||
),
|
||||
version="0.1.0",
|
||||
version="0.2.0",
|
||||
lifespan=lifespan,
|
||||
)
|
||||
|
||||
|
|
@ -49,6 +60,7 @@ app.add_middleware(
|
|||
|
||||
# Mount REST routes under /api prefix
|
||||
app.include_router(router, prefix="/api")
|
||||
app.include_router(blueprint_router, prefix="/api")
|
||||
|
||||
# Mount WebSocket routes (no prefix — path is /ws/council/{run_id})
|
||||
app.include_router(ws_router)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue