Skip to content
AaaaarinPublic

About

The enforcement layer for data agents. DataHub gives agents context; Gatehouse makes context decide what agents may do.

Topics

Resources

Stars

1 star

Watchers

0 watching

Forks

Repository files navigation

Gatehouse

DataHub gives agents context. Gatehouse makes context decide what agents may do.

Gatehouse is an enforcement gateway that sits between AI agents and your data stack. It wraps the official DataHub MCP server unchanged, adds a governed warehouse tool, and checks every tool call against policy before it runs. The facts behind every decision come live from the DataHub graph: PII tags, glossary terms, ownership, deprecation, domains, active incidents. Every decision is streamed to a live console, sealed into a hash-chained audit log, and written back to DataHub as first-class metadata.

No LLM sits in the decision path. Policy is deterministic, testable, and sub-millisecond.

See a real run without installing anything → A recorded replay of the console: every decision, latency, rule id and graph-fact citation is verbatim from the gateway, captured off the same WebSocket the live console listens on. To drive it yourself, the offline quickstart below needs no DataHub and no Docker.

The moment that explains it

  1. The quality agent scans mart_billing and finds 1,215 negative billing amounts (corruption DataHub planted in its own healthcare starter dataset).
  2. It calls report_data_issue. Gatehouse checks its scope, then raises a real Incident on the dataset in DataHub.
  3. Seconds later the analytics agent asks a routine revenue question against the same table. Gatehouse reads the graph, sees the active incident, and refuses, citing the incident the quality agent just wrote.

The two agents never exchanged a message. One agent's discovery changed what another agent was allowed to do, through the catalog alone. That is the context graph working as a control plane, not a lookup service.

What gets written back to DataHub

Gatehouse event Becomes in DataHub
Registered agent DataJob under the gatehouse/agent-fleet DataFlow, with owner, scopes, risk tier
Agent session DataProcessInstance run with real inlets/outlets, visible in lineage and Runs tabs
Policy violation Incident raised on the offending dataset, citing the rule and the graph facts
Agent access to a governed dataset Run results on a custom agent access policy assertion (Validations tab)
Confirmed data issue found by an agent Incident via the governed report_data_issue tool

Architecture

flowchart LR
    A1[Claude Code] --> GW
    A2[Scripted agents] --> GW
    A3[Any MCP client] --> GW
    subgraph GW [Gatehouse gateway :8484]
        MW[Policy middleware<br/>every tool call] --> PE[Policy engine<br/>deterministic rules]
        MW --> DH_MCP[official DataHub MCP server<br/>mounted unchanged]
        MW --> WH[run_sql<br/>governed warehouse]
        PE --> FS[Fact store<br/>15s TTL cache]
        MW --> AU[Hash-chained audit log]
        MW --> WB[Write-back worker]
        CON[Live console<br/>approvals + e-stop]
    end
    FS -->|GraphQL: tags, terms, domains,<br/>deprecation, incidents| DH[(DataHub OSS v1.7.0)]
    WB -->|agents, sessions, incidents,<br/>assertion runs| DH
    DH_MCP --> DH
Loading

The gateway is one process on one port: the MCP endpoint at /mcp/, the console at /. Agents identify with an X-Gatehouse-Agent header; everything else is ordinary MCP.

Quickstart

Fast path: offline demo, no DataHub required (2 minutes)

Runs the entire gateway against a snapshot of real DataHub facts. Policy engine, console, audit chain, approvals, and the fleet e-stop all run for real; run_sql hits the real healthcare data. Perfect for judges who want to see it work now.

git clone https://github.com/Aaaaarin/gatehouse && cd gatehouse
uv venv --python 3.12 .venv && uv pip install --python .venv -e ".[dev]"
.venv/bin/python demo/setup_offline.py                       # downloads healthcare.db only
.venv/bin/python -m gatehouse.cli --config gatehouse-offline.yaml serve

Console: http://127.0.0.1:8484/. In another terminal, run the scenes:

.venv/bin/python demo/scenario.py redteam   # then work, inherit, fix, storm

(On Windows use .venv\Scripts\python.exe.)

Full path: live DataHub, with write-back to the graph

Shows the incidents, agent-fleet DataFlow, sessions, and assertions Gatehouse writes back into a real DataHub. Needs Docker (8 GB RAM).

pip install --upgrade acryl-datahub
datahub docker quickstart --version v1.7.0

uv pip install --python .venv "acryl-datahub[sqlalchemy]"
.venv/bin/python demo/setup_demo.py          # seeds the healthcare catalog + domain
.venv/bin/python -m gatehouse.cli serve      # uses gatehouse.yaml (live mode)

Console: http://127.0.0.1:8484/ · DataHub: http://localhost:9002 (datahub / datahub)

Run the demo

Each scene is one beat. Watch the console and the DataHub UI side by side.

python demo/scenario.py redteam   # five attacks, five denials, each citing a different graph fact
python demo/scenario.py work      # quality agent finds the planted corruption, raises an incident
python demo/scenario.py inherit   # analytics agent is circuit-broken by that incident
python demo/scenario.py fix       # engineer's UPDATE waits for your approval at the console
python demo/scenario.py storm     # background traffic; hit EMERGENCY STOP at the console

The five red-team denials, each resting on different metadata:

Attack Rule Graph fact cited
Unregistered agent queries the warehouse unregistered-agent absent from the fleet registry
Analyst selects patient names pii-access pii tag on raw_patients
Query against the legacy export deprecated-data deprecation note on the dataset
E-commerce agent reads healthcare data domain-fence Healthcare domain vs agent's allowed domains
Query names an uncataloged table unknown-to-catalog no entry in DataHub, so Gatehouse fails closed

A DENY is not just a wall. The error message an agent receives names the rule, the facts, and the audit record id, so LLM agents can self-correct instead of retrying blind.

Measured

On a laptop (i5-class, Windows 11), against live DataHub OSS v1.7.0:

Metric p50 p95
Policy decision, facts cached 0.054 ms 0.176 ms
Policy decision + SQL analysis 0.465 ms 1.196 ms
Graph fact fetch (cold, once per dataset per 15 s TTL) 286 ms 700 ms
End-to-end governed run_sql vs raw sqlite +59 ms

python -m gatehouse.cli benchmark reproduces these. The end-to-end overhead is dominated by MCP HTTP transport and result serialization, not policy.

Tests: python -m pytest tests (28 tests, every demo verdict pinned). Audit: python -m gatehouse.cli verify-audit walks the hash chain and localizes tampering to the exact record.

The policy pack

Policies are YAML, evaluated top-down, first match wins (policies.yaml). Conditions reference agents (scope, risk tier) and live graph facts (tags, terms, deprecation, domains, active incidents, catalog absence). Every deny carries citations: which URN, which fact, which value. The default posture fails closed: catalog mutations and warehouse writes are denied unless a rule says otherwise, unparseable SQL is denied, uncataloged tables are denied.

Which means: catalog coverage becomes enforceable. If a table is not in DataHub, agents cannot touch it. Teams get a live reason to catalog everything.

Real today vs roadmap

Real and demonstrated Roadmap
MCP gateway wrapping the official DataHub MCP server OAuth per-agent identity instead of headers
Policy on live graph facts with 15 s staleness bound Push invalidation via DataHub Actions events (kafka)
Incidents, assertions, sessions, fleet registry written back Session briefings as DataHub documents
Approval queue + fleet e-stop on the console Slack approvals via subscriptions
SQLite demo warehouse (DataHub's starter kits) Snowflake / BigQuery / Postgres executors
Column-aware SQL analysis (table level enforcement) Column-level masking and redaction

Repo layout

gatehouse/            the gateway: server, policy engine, facts, warehouse, write-back, audit
  policy/             engine.py (rules), facts.py (graph fact store), sql.py (statement analysis)
  writeback/          agents -> DataJobs, sessions -> DPIs, violations -> Incidents, assertions
  console/static/     the live console (no external assets, works offline)
demo/                 setup_demo.py (one-command world), scenario.py (scripted scenes)
tests/                28 unit tests: every demo verdict, chain tampering, SQL edge cases
benchmark/            the numbers above
examples/             captured real outputs: decisions, deny messages, audit records
contrib/datahub-skill/ agent-governance Skill contributed back to the DataHub ecosystem
docs/                  the hosted replay page (GitHub Pages) + gallery stills
  replay.json          a real run recorded off the console WebSocket, replayed by index.html
policies.yaml         the policy pack
agents.yaml           the fleet registry

How this uses DataHub

Built on DataHub OSS v1.7.0 with the MCP Server (mounted in-process, all read and mutation tools pass through Gatehouse policy). Reads: tags, glossary terms, ownership, domains, deprecation, incidents via GraphQL. Writes: DataFlow/DataJob fleet registry, DataProcessInstance sessions with lineage, raiseIncident, upsertCustomAssertion + reportAssertionResult. Demo data: DataHub's official healthcare starter dataset and showcase-ecommerce datapack.

License

Apache 2.0

About

The enforcement layer for data agents. DataHub gives agents context; Gatehouse makes context decide what agents may do.

Topics

Resources

Stars

1 star

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages