fastapi-gsap/gsap_broker/app.py
Tyler J King 0987704264 feat: governed connector module
GCAP-SPEC-CONNECTOR-DESCRIPTOR-0001 implementation.

ConnectorPlugin — abstract base for governed connectors.
ConnectorRegistry — register/discover connectors.
ConnectorRuntime — wraps invoke with Chronicle lineage.
EchoConnector — dev/test example.

API endpoints:
  GET  /connectors/           — browse catalogue
  GET  /connectors/{id}/      — connector descriptor
  POST /connectors/{id}/invoke/ — governed invocation
  GET  /connectors/{id}/health/ — health check

5 tests passing.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-30 16:42:38 -04:00

28 lines
1.4 KiB
Python

"""fastapi-gsap: Lightweight GSAP broker — GCAP-SPEC-SHELLBOUND-BROKER-0001."""
import structlog
from contextlib import asynccontextmanager
from fastapi import FastAPI
from fastapi.middleware.cors import CORSMiddleware
from gsap_broker.settings import settings
from gsap_broker.db import init_db
from gsap_broker.routers import authorize, complete, session, elevate, health, drivers, connectors
logger = structlog.get_logger()
@asynccontextmanager
async def lifespan(app: FastAPI):
await init_db()
logger.info("fastapi-gsap started", broker_did=settings.broker_did)
yield
app = FastAPI(title="fastapi-gsap", description="GSAP broker PoC — GCAP-SPEC-SHELLBOUND-BROKER-0001",
version="0.1.0", lifespan=lifespan)
app.add_middleware(CORSMiddleware, allow_origins=settings.cors_origins, allow_credentials=True,
allow_methods=["*"], allow_headers=["*"])
app.include_router(authorize.router, prefix="/governance", tags=["AC"])
app.include_router(complete.router, prefix="/governance", tags=["CR"])
app.include_router(session.router, prefix="/governance", tags=["Session"])
app.include_router(elevate.router, prefix="/governance", tags=["Elevation"])
app.include_router(drivers.router, prefix="/governance", tags=["Drivers"])
app.include_router(connectors.router, prefix="/connectors", tags=["Connectors"])
app.include_router(health.router, tags=["Health"])