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.2.tar.gz (116.0 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.2-py3-none-any.whl (106.2 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: govforge-0.1.2.tar.gz
  • Upload date:
  • Size: 116.0 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.2.tar.gz
Algorithm Hash digest
SHA256 3f5b3fbae417d5687b477daf71f09db1a0d60c1bf4c1e06c8dfc586545db0d11
MD5 a10bf11172894ce5deef13150fce5e26
BLAKE2b-256 ec5617220e6ee259d98d3147bef1f0204bc22dd69f56bf3aab468e8020a10ed6

See more details on using hashes here.

Provenance

The following attestation bundles were made for govforge-0.1.2.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.2-py3-none-any.whl.

File metadata

  • Download URL: govforge-0.1.2-py3-none-any.whl
  • Upload date:
  • Size: 106.2 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.2-py3-none-any.whl
Algorithm Hash digest
SHA256 0c7ac9b4a6c6aaefd7acac173daf399950962ac836b37cf159df692b2be203c1
MD5 7f822a615585339a01f59a7e7f1687c0
BLAKE2b-256 eef418a94e35f19115a41d5238a46e2f3788d67d71de469f7f3f7abd3f6b9925

See more details on using hashes here.

Provenance

The following attestation bundles were made for govforge-0.1.2-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