The Governance Layer separates ontology storage behind a single abstract interface —Documentation Index
Fetch the complete documentation index at: https://mintlify.com/xcoder-es/governance-layer/llms.txt
Use this file to discover all available pages before exploring further.
OntologyBackend — so governance code never imports a database driver directly. Two concrete implementations are shipped: a lightweight in-memory backend used by default and a Neo4j Aura backend that provides durable, queryable storage across process restarts.
The abstract interface
All backend operations go through theOntologyBackend ABC defined in src/governance/ontology/backend.py. The contract is intentionally minimal:
MemoryBackend (default)
MemoryBackend stores everything in plain Python dicts and lists — no external process, no credentials, no network. It is the default choice when no Neo4j credentials are present.
hashlib.sha256(secrets.token_bytes(16)), making them collision-resistant without requiring a database sequence.
Neo4jBackend (persistent)
Neo4jBackend connects to a Neo4j Aura instance using the official neo4j driver (included in the base dependencies as neo4j>=5.20). It stores entities as graph nodes with a JSON-serialised properties field and relationships as RELATES edges.
The backend reads credentials from the .env file at the project root, falling back to environment variables if the file is absent:
.env file:
backend.close() when you are done to release the driver connection.
Auto-detection in the dashboard
The Streamlit dashboard (src/governance/dashboard/app.py) auto-detects which backend to use at startup. It reads the .env file and checks whether NEO4J_URI is set. If a valid URI is found, it attempts to connect and falls back silently to MemoryBackend on failure.
What the ontology stores
Both backends record the same categories of data during a parliament session:| Entity type | Contents |
|---|---|
"action" | Named action entries from the identity ontology |
"decision" | Per-step decisions: action, reward, violations, is_default flag |
"member_score" | Per-member scores attached to each decision |
"benchmark" | Aggregate benchmark run statistics |
Identity node | The current identity vector (Neo4j only: persisted as a dedicated node) |
"outgoing", "incoming") and are navigable from any entity using query_relationships.
Choosing a backend
MemoryBackend
Use for: local development, unit tests, quick demos, CI runs.
- Zero configuration — just
importand instantiate - No network latency
- Data is ephemeral; lost on process restart
- Already the default in all dashboard and experiment code
Neo4jBackend
Use for: persistent decision logging, multi-session research, production-adjacent deployments.
- Durable storage across restarts
- Full graph query capability via Cypher
- Requires a running Neo4j instance and valid credentials in
.env neo4j>=5.20is included in core dependencies — no extra install needed