datahub-sentinel
Sentinel — an autonomous ML pre-mortem agent for DataHub.
Category: Production ML Agents (Build with DataHub: The Agent Hackathon). Sentinel catches ML failure modes that don't throw errors — target leakage, silent upstream drift, and governance gaps like missing ownership or documentation — by reasoning over DataHub's lineage graph, then writes what it found back into DataHub and opens a PR with the fix.
Summary extracted from the README.
Sentinel — an ML pre-mortem agent for DataHub
Category: Production ML Agents (Build with DataHub: The Agent Hackathon).
Sentinel catches ML failure modes that don't throw errors — target leakage, silent upstream drift, and governance gaps like missing ownership or documentation — by reasoning over DataHub's lineage graph, then writes what it found back into DataHub and opens a PR with the fix.
A model with leakage like this doesn't fail loudly — it ships, looks fine in offline eval, and quietly underperforms in production for as long as it takes someone to notice the gap between the two, which is usually a retraining cycle or two, and always after the trust is already spent. Nothing in a standard ML pipeline catches this; only the lineage graph can, because it's the only place that records when each piece of training data actually existed relative to the label.
If you'd rather not run anything
The whole thing is reproducible (make demo), but here's the fast path for a judge:
- Demo video (<3 min) — the whole thing end-to-end.
- The CI badge above is real. Click it — GitHub spins up DataHub on a clean machine and runs Sentinel against it on every push. The build fails if it doesn't find both planted bugs. That's the core claim, checked automatically, not asserted in prose.
examples/triage_report.md— an unedited LLM reasoning trace over this project's data (11/12 correct, one honest miss explained).examples/showcase_ecommerce_validation.md— the same assessor run against DataHub's ownshowcase-ecommercesample data, which it had never seen (13/13, zero false positives).examples/real_catalog_validation.md— two of the five detectors don't need this repo's planted bugs at all; checked them against that same realshowcase-ecommercedata and found a real governance pattern (70% of real datasets have no owner, 79% no documentation — see below).examples/investigation_trace.md— a real, unedited trace of the agentic investigation layer choosing its own next MCP call, step by step, once a finding is already proven. Or runmake investigateto watch it happen live in under a minute.examples/generated_prs/— the dbt diffs Sentinel generated, one per model per finding.- A PR Sentinel actually opened against a throwaway sandbox repo. Real diff, not a screenshot.
- Two open-source contributions back to DataHub: datahub-skills#40 (a new ML-lineage skill) and mcp-server-datahub#141 (docs for three agent-author gotchas I hit building this).
tests/— 40 unit tests, no Docker needed:pip install -r requirements-dev.txt && pytest tests/.
The scenario
A churn model (churn_predictor) is in production. Nothing is broken in any
way a monitor would catch, but two things are wrong:
- Target leakage. Two features,
days_since_last_refundandrefund_count, come from refund data that only exists after a customer has churned — people file refunds on their way out. Offline AUC is a flattering 0.85; drop those two features and it's 0.78. The model looks great in eval and is quietly worthless in production. - Silent drift. An upstream
paymentstable was replaced (raw_payments→raw_payments_v2,amount→amount_usd) and nobody repointed the pipeline.total_payment_amounthas been computed from a frozen table ever since. No error, no alert.
Both are the "obvious in hindsight, expensive in the meantime" category, and both are only visible if you follow the lineage.
What Sentinel does with it
For every model in the catalog, Sentinel:
- Reads each dataset's real description and asks an LLM whether the data is causally downstream of a business outcome (leakage risk). If it is, Sentinel tags it in DataHub. This is discovery — the flag isn't pre-planted (see below).
- Walks the lineage graph through the MCP server to prove the finding deterministically.
- Explains it in plain English for whoever's on call.
- Writes it back to DataHub: tags, an updated model description, and a linked incident memo, so the next person doesn't start from zero.
- Generates the fix as a diff against the dbt project that built the feature, and can open a real PR (opt-in).
- Does all of this for every model sharing the risky data, not just the one that triggered the run.
Discovery, not a planted flag
An earlier version of this demo pre-tagged the leaky tables at ingest and the detector just read the tag back. That's the fair thing to distrust: it finds what you told it to find.
So that's gone. At ingest, raw_refunds gets a plain-English description a
data engineer would actually write ("Refunds are frequently filed by a user in
the days immediately before they churn...") and no tag. Before any
model-specific detection, the semantic triage pass in
sentinel/agent/triage.py scans every dataset,
reads its description, and asks the LLM to judge leakage risk from the prose
alone. If it decides yes, Sentinel attaches the PostOutcomeEvent glossary
term itself. Only then does the deterministic detector read it.
I checked this three ways rather than trusting one run:
- Own data, real LLM (Ollama /
llama3.2, not the keyword fallback): triage flagsraw_refundsand leaves the ordinary tables (raw_orders,raw_users, the feature mart) alone. Verified against a live DataHub. - Third-party data it had never seen: the 13 documented dataset
descriptions from DataHub's
showcase-ecommercesample pack, run through the same assessor. 13/13 correctly called "not a risk." A leakage detector that fires oncustomersandordersis useless; this one didn't. - A second model on the same feature store (below), to confirm one tag protects more than the model that triggered the audit.
With no LLM reachable, triage falls back to a keyword heuristic so the pipeline still runs, but the part worth looking at — judgment on prose a keyword match would miss — needs a real model. Either backend is free; see below.
The detectors are model-agnostic
churn_predictor isn't the only model in the catalog. fraud_predictor uses a
subset of the same feature store (order_count, total_payment_amount,
refund_count), which is what a real shared feature store looks like. Triage
and both detectors take a model_urn rather than hardcoding one, so the agent
audits every MLModel it finds:
auditing churn_predictor ...
found 2 issue(s): target leakage, blast radius
auditing fraud_predictor ...
found 2 issue(s): target leakage, blast radius (same root cause,
caught independently)
Triage only tagged raw_refunds once. Both models are covered because both
detectors read the same governance metadata.
Two detectors don't need this repo's planted bugs at all
detect_target_leakage, detect_blast_radius, and detect_stale_training_data
all rely on something specific to this demo's synthetic world — a tagged
dataset, a marked stale sibling, a training-run timestamp. That's fair
grounds for skepticism: does any of this generalize past the fixtures this
repo ships?
detect_missing_ownership and detect_undocumented_upstream don't have that
problem. They check two universal facts — does DataHub have an owner on file
for this upstream dataset, and does it have a description — and those are
real governance gaps on any catalog, not a scenario written for this repo.
They correctly stay silent on this project's own demo world (everything here
is deliberately fully governed), and I checked them against DataHub's own
real showcase-ecommerce sample pack instead: 47 of 67 real datasets have no
owner recorded, 53 of 67 have no description anywhere. The pattern is more
interesting than a flat number — governance holds at the dbt source of truth
(12/13 owned, 13/13 documented) and evaporates across the 54 downstream
copies in Snowflake, Postgres, Looker, PowerBI, S3, and Tableau (8/54 owned,
1/54 documented). See
examples/real_catalog_validation.md
for the full breakdown.
Column-level lineage is ingested, but not (yet) traversable via MCP
marts.customer_features.refund_count and .days_since_last_refund carry
real column-level lineage back to staging.stg_refunds.refund_date — emitted
as a FineGrainedLineageClass edge in sentinel/ingest.py, not a table-level
guess. The goal was to have detect_target_leakage name the exact tainted
column instead of matching feature names against the dataset name by string
overlap (the "crude stem match" in detectors.py).
It turned out DataHub doesn't expose a way to get there through MCP yet.
I confirmed live (a direct GMS aspect read) that the fine-grained edge is
stored correctly, but get_lineage_paths_between silently falls back to a
dataset-level path — and returns "no lineage path found" if you instead pass
the two schemaField URNs directly, even though a FineGrainedLineageClass
connects those exact fields. get_entities doesn't project lineage aspects at
all. There's currently no MCP tool that would let an agent read this back.
Rather than break this project's own MCP-only rule (every read/write goes
through mcp-server-datahub, no direct GraphQL/SDK calls) to get around a gap
in the tool itself, the detector keeps its existing name-based matching, and
the gap is filed as a third finding in
mcp-server-datahub#141
instead. The lineage stays in the graph either way — real data-model depth,
honestly reported as not yet actionable through the agent tooling.
Architecture
┌─────────────────────────────────────────┐
│ DataHub (OSS) │
│ datasets · lineage · glossary terms · │
│ ML entities · tags · Analysis documents │
└───────────────┬───────────────┬──────────┘
│ MCP (stdio) │ MCP (stdio)
│ reads │ writes
┌───────────────▼───────────────────────────┐
│ mcp-server-datahub │
│ search · get_lineage · get_entities · │
│ add_tags · add_terms · save_document · │
│ update_description │
└───────────────┬───────────────────────────┘
│
┌────────────────────────────────▼────────────────────────────────┐
│ Sentinel │
│ │
│ triage.py semantic discovery: LLM reads real descriptions, │
│ tags governance risk before detection runs │
│ │ │
│ ▼ │
│ detectors.py deterministic graph analysis, model-agnostic, │
│ runs across every MLModel │
│ │ │
│ ▼ │
│ llm.py explains an already-proven finding; Gemini or │
│ local Ollama; never invents a finding │
│ │ │
│ ▼ │
│ investigate.py agentic: LLM chooses its own next MCP read call, │
│ step by step, to gather context beyond the │
│ finding -- read-only, can't mutate or invent │
│ │ │
│ ▼ │
│ actions.py writes tags / description / memo (incl. the │
│ investigation trace) back to DataHub │
│ │ │
│ ├──▶ notify.py optional Slack alert │
│ │ │
│ ▼ │
│ remediate.py generates a dbt diff + PR body, optionally opens │
│ a real PR via real_pr.py │
└────────────────────────────────────────────────────────────────┘
Every read and write goes through mcp-server-datahub over stdio — the same
server Claude Code or Cursor would talk to. Detector, triage, and action code
never make a direct REST or GraphQL call.
Why the graph proves findings, and where the LLM actually drives
An LLM eyeballing numbers and "noticing" a leak is unconvincing and sometimes wrong. Detection and reasoning are kept separate:
triage.pyuses the LLM for the thing LLMs are good at: reading prose it's never seen and making a judgment call. That judgment becomes a glossary term attachment, not a finding.detectors.py(detect_target_leakage,detect_blast_radius,detect_stale_training_data,detect_missing_ownership,detect_undocumented_upstream) are plain graph traversals with no LLM in the loop. Same metadata in, same finding out, every time.llm.pygets an already-proven finding and writes it up for an on-call engineer. It can't invent a finding, and if no backend is reachable it uses a deterministic template so a missing API key never breaks the run.investigate.pyis the one place the LLM actually makes decisions rather than judging a single input or narrating a fixed one: given a proven finding, it chooses which MCP read tool to call next --search,get_entities, orget_lineage-- based on what the previous call returned, up to 4 steps, deciding for itself when it's learned enough to stop. It can't write anything (no mutation tools are reachable from this loop) and it can't contradict the finding (the facts were already proven before this runs) -- but which tool, with what arguments, and when to stop are real choices made turn by turn, not a script. If the step budget runs out before the model voluntarily finishes, a final forced-conclusion call (no tool options, just "summarize what you actually saw") guarantees a grounded answer instead of a non-answer -- seeexamples/investigation_trace.mdfor an unedited real run, including summaries that honestly say the evidence wasn't conclusive rather than overclaiming.
Quickstart
Needs Docker and Python 3.11.
git clone https://github.com/AshrafAhmed9/datahub-sentinel.git
cd datahub-sentinel
make setup # .venv + pinned deps
make datahub-up # DataHub OSS via docker quickstart
make demo # build the world, train the model, ingest, run Sentinel
No local Docker? Click the Open in GitHub Codespaces badge above --
it provisions a cloud environment (via .devcontainer/) with Python and
Docker-in-Docker ready, so the same three make commands above work without
installing anything locally. GitHub's free tier covers this comfortably for
a one-off run. Being upfront: this .devcontainer/ config is untested end-to-end
in an actual Codespace as of writing (I don't have a way to spin one up and
verify from here) -- if make datahub-up needs more resources than the
default machine type offers, Codespaces lets you pick a larger one before
creating it. The make setup && make datahub-up && make demo sequence itself
is exactly what CI runs on every push, so that part is proven; only the
Codespaces environment layer around it is new.
Open http://localhost:9002 (login datahub / datahub) and look at
churn_predictor and fraud_predictor: you'll see the tags Sentinel added
(model-at-risk, leakage-suspect), the rewritten descriptions, and the
linked Analysis documents with the evidence. Search PostOutcomeEvent to see
which dataset triage tagged and why. Generated remediation diffs land in
examples/generated_prs/.
Watching the agentic investigation happen, in isolation
make investigate GMS_URL=http://localhost:8082
make demo already runs this as part of the full pipeline (see the
[investigate] lines in its output, or examples/investigation_trace.md),
but this runs it standalone, read-only, against whatever finding comes back
first — the fastest way to actually watch investigate.py choose its own
next MCP call step by step, without reading through triage/detection/
remediation output first.
Continuous mode (--watch)
DATAHUB_GMS_URL=http://localhost:8080 python -m sentinel.agent.run --watch --interval 30
Polls DataHub for newly registered MLModel entities and audits each one as it
shows up, instead of running once and exiting.
Opening a real PR (opt-in)
By default remediation stops at a diff file in examples/. That's the right
default: a make demo that opened GitHub PRs would break for anyone without
gh set up and spam duplicates on every re-run. To watch it open a real one:
export SENTINEL_OPEN_REAL_PR=true # needs `gh` authenticated
make demo GMS_URL=http://localhost:8082
It targets
sentinel-remediation-sandbox,
a throwaway repo seeded with this project's dbt code, so it never touches
anything a judge owns. Live result:
sentinel-remediation-sandbox#2.
Slack (opt-in)
export SENTINEL_SLACK_WEBHOOK_URL=<your webhook URL>
Posts a summary when findings are written back, mirroring the "alert on-call" step in DataHub's reference architecture for ML agents. Off by default; findings land in DataHub regardless.
CI
.github/workflows/demo.yml runs the full
pipeline — real DataHub OSS, world build, ingest, agent — on every push and
fails if Sentinel doesn't find both planted bugs. It's not a "nothing crashed"
smoke test; it's a standing check that the main claim in this README is still
true.
Port conflicts
The quickstart compose file pins GMS to 8080 and Kafka to 9092. If those
are taken:
DATAHUB_MAPPED_GMS_PORT=8082 make datahub-up
make demo GMS_URL=http://localhost:8082
(Kafka's published port lives in ~/.datahub/quickstart/docker-compose.yml;
edit the published: value under the broker service if you need to remap it
too.)
LLM backend (optional, free either way)
Triage and explanations need no API key. They default to local Ollama and fall back to a heuristic/template if it isn't running:
brew install ollama && ollama serve &
ollama pull llama3.2
For Google's Gemini free tier instead:
export SENTINEL_LLM_BACKEND=gemini
export GEMINI_API_KEY=<your free-tier key>
Layout
world/ synthetic e-commerce data + dbt project + churn model
generate_data.py synthetic users/orders/payments/refunds, two bugs baked in
dbt_project/ staging + feature-mart dbt models (DuckDB)
ml/train.py trains churn_predictor (scikit-learn)
sentinel/
ingest.py loads the world into DataHub: datasets, lineage, glossary
term definitions (unattached), ML entity chain for both models
agent/
mcp_client.py async wrapper over mcp-server-datahub (stdio)
triage.py semantic discovery: LLM reads descriptions, tags risk
detectors.py the five deterministic, model-agnostic detectors
llm.py explanation layer (Gemini / Ollama / template)
investigate.py agentic investigation: LLM drives its own MCP tool
calls around an already-proven finding, read-only
actions.py DataHub write-back (tags, description, Analysis doc,
investigation trace)
notify.py optional Slack webhook
remediate.py generates dbt diffs + PR bodies
real_pr.py optional: opens a real PR against the sandbox
run.py entrypoint: triage → detect → explain → investigate →
write back → remediate; supports --watch
skills/ml-lineage/ DataHub Skill contribution (see below)
examples/generated_prs/ committed sample output, so judges can evaluate
quality without running anything
.github/workflows/demo.yml CI proving both bugs are found on every push
Open-source contributions
Two, both from building this against OSS DataHub:
- datahub-skills#40 —
a new
ml-lineageskill: how to audit ML lineage over MCP, when to reach forget_lineagevsget_entities, and a remediation-PR template grounded in the real pipeline files lineage points at. Other entrants have opened adjacent PRs there (drift causation, freshness, statistical leakage checks); what's different here is the mechanism the repo actually runs — proving leakage from a governance term attached via semantic discovery, backed by a working, tested implementation rather than a spec. - mcp-server-datahub#141 —
docs for three things that cost me real debugging time and aren't written
down anywhere:
searchis eventually consistent after a write/ingest,get_lineagedoesn't return relationships modeled as entity aspects (anMLModel's deployments and features among them, so you needget_entitiesfor those), and column-level lineage is stored correctly by DataHub but isn't surfaced by any current MCP tool (see next section).
Judging criteria, mapped
- Use of DataHub: full ML lineage chain ingested and traversed across two
models; reads via
search/get_lineage/get_entities, writes viaadd_tags/add_terms/save_document/update_description, all through the MCP server. Triage means the agent also produces governance metadata, not just consumes it, andinvestigate.pymeans the agent decides its own sequence of MCP calls at runtime rather than following a fixed read path. - Technical execution:
make demoreproduces everything from a clean checkout with pinned deps, and CI proves it green against real DataHub on every push. - Originality: inferring leakage risk from prose (not a hardcoded flag), propagating that one discovery to every model on the tainted data, generating/opening real remediation PRs, and an agentic investigation layer that chooses its own next tool call around a proven finding — past the detect-and-alert reference architecture.
- Real-world usefulness: two of the five detectors (leakage, blast
radius) target failure modes every team with a shared feature store fears;
the other two (missing ownership, undocumented upstream) are universal
governance gaps validated against a real third-party DataHub catalog, not
just this repo's fixtures (see
examples/real_catalog_validation.md). Output is a mergeable PR and a Slack message either way, not another dashboard. - Submission quality: this README, a <3-minute video,
committed
examples/for reading over running, and a live example PR (sentinel-remediation-sandbox#2).