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.1.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.1-py3-none-any.whl (83.7 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: govforge-0.1.1.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.1.tar.gz
Algorithm Hash digest
SHA256 ae84d594c8d4c4341ab85b7b9f713462c084ef2090f6de13314e36804a52ed18
MD5 cb049a27e027c3f6afbc5ef492423eb9
BLAKE2b-256 fa103760c876943986320c83540a290c150ae5f08f33e96288b64c10e3c4e198

See more details on using hashes here.

Provenance

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

File metadata

  • Download URL: govforge-0.1.1-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.1-py3-none-any.whl
Algorithm Hash digest
SHA256 0d307f91f31b5bd4b8f2003d2d751979b0c139ca140eb27b28af2aeec7e8d580
MD5 c5a086ace14509dd18197950e336977e
BLAKE2b-256 6d85229c1ccca0052f041133866f5159c9c319c845a00100cce4b9cdc14bdd25

See more details on using hashes here.

Provenance

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