Skip to content

Repository files navigation

MidSphere

MidSphere Autonomous Context Circuit-Breaker Engine

Autonomous Context Circuit-Breaker Engine for Data Platforms
DataHub · MCP · Google Antigravity SDK · Gemini

CIDeploy frontendDeploy backendApache 2.0Upstream skills PR 88

Organizations deploy AI agents faster than they can keep catalog context trustworthy.

Schema drift, quality defects, ungoverned PII, and missing ownership do not stop at an alert. Agents that continue to read the catalog inherit the damage.

Many catalogs only record that something failed. MidSphere treats that as insufficient. It runs a closed loop that audits context, scores selective blast radius, applies advisory quarantine, produces a dry-run fix artifact, and leaves an MBOM attestation path so the next human or agent can inherit safer knowledge.

When DataHub mutations are enabled and GMS is reachable, quarantine is written as graph state (tags, structured properties, documents). Otherwise it remains job-local with mutations_applied=false. MidSphere Consumer Gate returns BLOCKED for MidSphere-aware clients. This repository does not claim that every third-party MCP consumer is automatically denied by the platform.

Built for Build with DataHub: The Agent Hackathon.

Why not a scanner or a gateway

MCP security scanners and gateways inspect tool metadata and block at the proxy. MidSphere starts where those stop.

CapabilityScanners and gatewaysMidSphere
Detection surfaceTool metadata and tool callsCatalog context: quality, PII, freshness, ownership
Action on findingAlert or proxy denyAdvisory quarantine written to DataHub graph state (tags, structured properties, documents)
ReversibilityReconfigure the proxyLift via remove_tags through the official MCP server
Consumer enforcementAt the gatewayConsumer Gate returns BLOCKED for MidSphere-aware clients only (no platform-wide claim)
EvidenceScan reportMBOM attestation and dry-run fix artifact

Live surfaces

SurfaceURL
Command Centerhttps://midsphere.vercel.app
API (Cloud Run)https://midsphere-api-1053689941073.us-central1.run.app
Sourcehttps://github.com/adi-IL/MidSphere

Status honesty (Command Center)

The UI is minimal monochrome (no emoji). Status labels are defined as follows.

UI labelMeaning
API · JobAPI is up and the canvas job came from the API (latest, Run, or Trip)
API · SampleAPI is up but the canvas is a local demo fixture (e.g. scenario tab without Run)
OfflineAPI unreachable; sample fixtures from frontend/src/lib/demoJob.ts
GMS / GMS offAPI GMS probe (datahub_reachable)
Pipeline Sample / Agent / Live MCPRun kind derived from execution_mode and job source
Run completesClosed loop finished (Google Antigravity primary and/or deterministic fallback)
Decision Fix / AttestationScenario paths under examples/ (dry-run)
Live tags / save_document / Lift remove_tagsGMS reachable and TOOLS_IS_MUTATION_ENABLED=true (see job mutations_applied and TOOL events)

Operator path: open the live app, select Hospital, Retail, or Taxi, click Run, inspect the selective graph (impacted vs open fork), use Decision Findings / Gate / Attestation, then Trip / Lift. Expand Telemetry for stage logs. When mutations are live, look for add_tags official_mcp ok after trip/Run and remove_tags official_mcp ok after Lift (also in the Network response body).

Manual smoke checklist:docs/MANUAL_TEST.md.

Closed loop

StageComponentShipping behavior
1. AuditContextSentinelScenario findings (quality, PII, freshness)
2. TopologyCascadeAnalyzerSelective blast radius and risk score
3. BreakCircuitBreakerAdvisory quarantine; live tags only if GMS and mutations are enabled
4. FixFixArchitectDry-run SQL/dbt path under examples/prs/
5. InheritMBOMEngineMBOM path under examples/mboms/; live save_document only if mutations are enabled
flowchart LR
T([Trigger]) --> S1["ContextSentinel<br/>1 · Audit"]
S1 --> S2["CascadeAnalyzer<br/>2 · Topology"]
S2 --> S3["CircuitBreaker<br/>3 · Break"]
S3 --> S4["FixArchitect<br/>4 · Fix"]
S4 --> S5["MBOMEngine<br/>5 · Inherit"]
MCP[["DataHub MCP<br/>when GMS is configured"]]
MCP -. "read: list_schema_fields" .-> S1
MCP -. "read: get_lineage" .-> S2
MCP -. "write: add_tags / remove_tags" .-> S3
MCP -. "write: save_document" .-> S5
classDef stage fill:#ffffff,stroke:#333333,stroke-width:1px,color:#111111;
classDef mcp fill:#f5f5f5,stroke:#333333,stroke-width:1px,stroke-dasharray:4 3,color:#111111;
class T,S1,S2,S3,S4,S5 stage;
class MCP mcp;
Loading

Primary workforce:Google Antigravity SDK for Python (pip install google-antigravity; Agent + LocalAgentConfig with custom MidSphere stage tools on Vertex Gemini). Official DataHub MCP attaches when GMS is reachable. Stage tools may call get_lineage, list_schema_fields, add_tags, and save_document when mutations are enabled. On Agent failure, a deterministic fallback completes the job with simulated telemetry labels when offline.

Scenario packs

Packs are defined in backend/agents/scenarios.py and mirrored in Command Center fixtures.

ScenarioRoot datasetRiskQuarantine targetOpen fork
Hospital (healthcare)healthcare.raw_patients61mart_billingmart_demographics
Retail (ecommerce PII)ecommerce.raw_customers88mart_customer_360mart_product_catalog
Taxi (NYC freshness)nyctaxi.raw_yellow_trips65mart_monthly_revenuemart_trip_distance_stats

Timeline (graph control, off by default) is a closed-loop narrative scrubber. It is not a live GMS history browser.

Stack

LayerTechnology
FrontendReact 18, Vite, TypeScript, Tailwind, React Flow, Geist
BackendFastAPI, Pydantic, httpx, uvicorn
Primary workforceGoogle Antigravity SDK (Python package google-antigravity) + backend/agents/stage_tools.py
FallbackDeterministic stages in backend/agents/pipeline.py
ModelsGemini via Vertex AI (ADC)
CatalogDataHub GMS and official mcp-server-datahub via uvx
DeployVercel project midsphere, GCP Cloud Run midsphere-api

MCP tools (real names only)

Read:search, get_entities, list_schema_fields, get_lineage, get_lineage_paths_between, get_dataset_queries

Write (requires TOOLS_IS_MUTATION_ENABLED=true on the MCP server): add_tags, remove_tags, add_structured_properties, save_document

No invented datahub_* tool prefixes. No MCP create_incident.

Quick start

git clone https://github.com/adi-IL/MidSphere.git
cd MidSphere
cp .env.example .env
# optional: DATAHUB_GMS_URL / DATAHUB_GMS_TOKEN# Vertex: GOOGLE_CLOUD_PROJECT and ADCcd backend
python3 -m venv .venv &&source .venv/bin/activate
pip install -r requirements.txt
export ANTIGRAVITY_ENABLED=true
export USE_OFFICIAL_MCP=true
PYTHONPATH=. uvicorn app.main:app --reload --port 8000
# second terminalcd frontend && npm install && npm run dev

Cloud Run cannot use laptop localhost as GMS. Operators run official DataHub quickstart on GCE and set DATAHUB_GMS_URL to the VM public IP (see scripts/README.md).

./scripts/gce_datahub_schedule.sh apply # weekday start / nightly stop
./scripts/gce_datahub_schedule.sh stop-now
./scripts/gce_datahub_schedule.sh start-now # starts VM, re-points Cloud Run, waits for GMS

API

MethodPathPurpose
GET/v1/healthHealth and stack metadata
POST/v1/jobsRun closed loop
GET/v1/jobs/latestLatest job (404 if none; does not auto-run)
GET/v1/jobs/{id}Job by id
POST/v1/jobs/{id}/liftLift quarantine
POST/v1/jobs/{id}/tripRe-run closed loop with auto-trip
GET/v1/gate/{urn}Consumer Gate decision
GET/v1/gate-default-blockedConvenience gate for healthcare mart_billing only (not “latest job blocked entity”)

Sample Datasets

To ensure MidSphere's agents operate on realistic, complex lineage graphs, we developed three custom data environments for this project.

Because these datasets contain raw sample data and ingestion recipes that would bloat the core application repository, they are hosted separately.

Accessing the Datasets

You can view and download the full dataset schemas, mock data, and DataHub ingestion recipes here: datahub-project/static-assets/tree/main/datasets

The Environments

  1. Healthcare (healthcare/):

    • Simulates a hospital billing and demographics pipeline.
    • Planted Issue: Negative billing amounts.
    • MidSphere Action: Quarantines mart_billing, leaves mart_demographics open.
  2. Retail (fiction-retail/):

    • Simulates an e-commerce platform with customer 360 and product catalog marts.
    • Planted Issue: Unmasked SSN (PII leak).
    • MidSphere Action: Quarantines mart_customer_360.
  3. NYC Taxi (nyc-taxi/):

    • Simulates a high-volume transit data pipeline.
    • Planted Issue: Data freshness / delayed ingestion.
    • MidSphere Action: Quarantines mart_monthly_revenue.

If you are running the GCE VM Quickstart, you can use scripts/load_healthcare.sh in conjunction with these datasets to populate your live DataHub instance.

Open-source contribution

Upstream skills PR (open):
datahub-project/datahub-skills#88 (datahub-circuit-breaker, datahub-quality-circuit).

Local mirrors: skills/.

Repository layout

Public OSS tree aligned with common monorepo practice and the hackathon submission requirements (public source, Apache 2.0, setup instructions, optional sample artifacts):

.
├── LICENSE Apache 2.0 (required; visible at repo root)
├── README.md Overview, honesty table, quick start
├── ARCHITECTURE.md Shipping contracts (short)
├── .env.example Env template (no secrets)
├── .gitignore
├── .github/ CI + deploy workflows
│ ├── DEPLOY.md
│ └── workflows/
├── backend/ Closed-loop API (Cloud Run)
│ ├── app/ api/ agents/ gate/ midsphere_mcp/ models/ tests/
│ ├── requirements.txt
│ └── Dockerfile
├── frontend/ Command Center (Vercel)
│ ├── src/ public/
│ └── package.json
├── examples/ Judge-readable sample outputs (optional but present)
│ └── mboms/ prs/ jobs/ telemetry/
├── skills/ Upstream skill mirrors (datahub-skills PR #88)
├── scripts/ Operator helpers (GCE GMS schedule, bootstrap)
└── docs/ Index + MANUAL_TEST.md (judge smoke)
PathRole for judges
Live Command CenterEnd-to-end UI
examples/Offline MBOMs, dry-run diffs, telemetry without running the stack
backend/ + frontend/Full source to run locally
LICENSEApache 2.0

Local-only material (not part of the public product surface) is gitignored: resource/, internal/, large recon dumps.

Documentation

  1. ARCHITECTURE.md: shipping system contracts
  2. docs/MANUAL_TEST.md: judge / operator manual smoke
  3. examples/README.md: scenario artifacts
  4. backend/README.md, frontend/README.md
  5. .github/DEPLOY.md: deploy isolation

License

Apache License 2.0. See LICENSE.

About

MidSphere: autonomous context circuit-breaker for DataHub (MCP, Antigravity/Gemini, selective quarantine, Command Center)

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages