Skip to main content

Governance infrastructure for AI coding agents — backend (MCP server + HTTP API + services)

Project description

GovForge Backend

Python backend for GovForge: services + policy engine + FastMCP server + FastAPI HTTP API + SQLAlchemy models.

Stack

  • Python 3.12+
  • FastMCP 3.x — MCP server framework
  • FastAPI — local HTTP API on 127.0.0.1:8787
  • SQLAlchemy 2 + Alembic — ORM + migrations
  • Pydantic v2 — schemas
  • GitPython — read-only Git extraction
  • SQLite (Phase 1, local-only) → Postgres (Phase 3 SaaS)

Layout

backend/
├── pyproject.toml
├── src/govforge/
│   ├── core/
│   │   ├── enums.py            # 9 StrEnums (RiskLevel, DecisionStatus, …)
│   │   ├── ids.py              # display-id helpers (TASK-001, DEC-001, …)
│   │   ├── models.py           # 12 SQLAlchemy 2 entities + relationships
│   │   ├── git.py              # read-only Git extractor (allowlisted verbs)
│   │   ├── policies/           # Policy ABC + 5 defaults + TOML loader + runner
│   │   └── services/           # 9 services orchestrating models + git + events
│   ├── mcp/                    # FastMCP server (11 tools / 5 resources / 3 prompts)
│   ├── api/                    # FastAPI app, deps, errors, routers/, schemas
│   └── db/                     # engine + session factory + SQLite pragmas
└── tests/
    ├── unit/                   # 88 unit tests across services / policies / API / MCP / git / security
    └── integration/            # full pipeline test (devis §21.2)

Setup

cd backend
python -m venv .venv && source .venv/bin/activate
pip install -e ".[dev]"
pytest -q                       # 97 tests, ~3s
ruff format --check src tests
ruff check src tests
mypy src                        # strict mode

Running components directly

The user-facing CLI is gf (Go binary, in ../cli/). The backend is normally spawned by gf mcp serve / gf api serve. For local development you can run each component directly:

# MCP server (stdio transport — for Claude Code / Codex / Cursor / Cline)
python -m govforge.mcp.server

# HTTP API
python -m govforge.api.server                                  # 127.0.0.1:8787
# or with reload during dev:
uvicorn govforge.api.app:app --host 127.0.0.1 --port 8787 --reload

The DB defaults to .govforge/govforge.db in the current directory; override with GOVFORGE_DB=/path/to/file.db (or a full SQLAlchemy URL like postgresql://…).

Architecture in one breath

agents (Claude / Codex / Cursor / …)
    │   stdio
    ▼
FastMCP server  ──┐
                  │
gf CLI ──HTTP─▶  FastAPI  ──▶  Services  ──▶  Models / SQLite
                  │              │  │
UI cockpit ───────┘              │  └──▶  Event store (audit log)
                                 │
                                 └─▶  Git extractor (read-only)
                                 │
                                 └─▶  Policy engine (5 defaults)

See ../docs/architecture.md for the full picture and ../docs/data-model.md for the entity diagram.

Tests

Layer Coverage
core/ 84-100%
mcp/ 73-100%
api/ 76-100%
TOTAL 90%
pytest --cov=govforge --cov-report=term-missing

Security guarantees are pinned by source-grep tests in tests/unit/test_security.py. See ../docs/threat-model.md.

License

Apache 2.0 — see ../LICENSE.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

govforge-0.1.0.tar.gz (81.2 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

govforge-0.1.0-py3-none-any.whl (83.7 kB view details)

Uploaded Python 3

File details

Details for the file govforge-0.1.0.tar.gz.

File metadata

  • Download URL: govforge-0.1.0.tar.gz
  • Upload date:
  • Size: 81.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for govforge-0.1.0.tar.gz
Algorithm Hash digest
SHA256 3d6b26a71603eba75ba448cf9c089189f900cc4687fed32ebc62a78cf2b64b63
MD5 77cab7121591e48fa5fd3511fbcaca7c
BLAKE2b-256 d05d57cd27f81351adb859a23aefdc73f6ea5663c431f496e0b378d05dbeb69b

See more details on using hashes here.

Provenance

The following attestation bundles were made for govforge-0.1.0.tar.gz:

Publisher: pypi.yml on ericvaillancourt/govforge

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file govforge-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: govforge-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 83.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for govforge-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 43ab59156eff6bb75eb49ac97e2fef6e812c8ae3f7331ee22bb19b52ac6dd562
MD5 cb04de5ec1acb6b22b9776349a6dc208
BLAKE2b-256 a5d6a5e6df52ad8731368b5c505608241d19a8bddb6b4d85824ca229dbc3b1fb

See more details on using hashes here.

Provenance

The following attestation bundles were made for govforge-0.1.0-py3-none-any.whl:

Publisher: pypi.yml on ericvaillancourt/govforge

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page