Skip to content

Repository files navigation

DriftGuard Banner

Multi-agent AI system that detects, diagnoses, and remediates anomalies in oil & gas well operations.

Quick Start Docker Dashboard

Python License Tests Agents Coverage
Last Commit Issues Contributors Stars


🎯 Why DriftGuard?

Oil and gas operations generate thousands of sensor alerts daily. In 2026, the industry faces three compounding challenges:

Challenge Impact DriftGuard Solution
False Alarm Fatigue 85% of alerts are noise β€” operators ignore critical warnings Sentinel Agent triages with confidence scoring, suppresses noise
Methane Compliance EPA/OGMP 2.0 demands continuous monitoring with audit trails Compliance Agent tracks emissions + generates regulatory reports
Pilot-to-Production Gap 95% of AI pilots deliver no P&L impact (MIT, 2025) Agentic system that acts autonomously, not just predicts

"The question is no longer whether you can detect anomalies β€” it's what happens in the 30 seconds after detection."


πŸ—οΈ Architecture

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚                      ORCHESTRATOR                                β”‚
β”‚            Hierarchical Agent Coordination Layer                 β”‚
β””β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
       β”‚              β”‚              β”‚              β”‚
β”Œβ”€β”€β”€β”€β”€β”€β–Όβ”€β”€β”€β”€β”€β”€β” β”Œβ”€β”€β”€β”€β–Όβ”€β”€β”€β”€β”€β”€β”€β” β”Œβ”€β”€β”€β”€β–Όβ”€β”€β”€β”€β”€β”€β”€β” β”Œβ”€β”€β”€β–Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚ πŸ” SENTINEL β”‚ β”‚ 🩺 DIAGNOSTβ”‚ β”‚ πŸ’Š PRESC-  β”‚ β”‚ πŸ“‹ COMPLIANCEβ”‚
β”‚             β”‚ β”‚   -ICIAN   β”‚ β”‚   RIPTOR   β”‚ β”‚              β”‚
β”‚ Isolation   β”‚ β”‚ Z-score    β”‚ β”‚ Action     β”‚ β”‚ Methane      β”‚
β”‚ Forest +    β”‚ β”‚ analysis + β”‚ β”‚ catalog +  β”‚ β”‚ emissions +  β”‚
β”‚ Severity    β”‚ β”‚ Domain     β”‚ β”‚ Risk-based β”‚ β”‚ Regulatory   β”‚
β”‚ Triage      β”‚ β”‚ knowledge  β”‚ β”‚ escalation β”‚ β”‚ thresholds   β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
       β”‚              β”‚              β”‚              β”‚
β”Œβ”€β”€β”€β”€β”€β”€β–Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β–Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β–Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β–Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚               SHARED INFRASTRUCTURE                              β”‚
β”‚     Pydantic Schemas β€’ Structured Logging β€’ Configuration       β”‚
β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€
β”‚                     FastAPI Gateway                              β”‚
β”‚          REST API (port 8000) β€’ Swagger Docs                    β”‚
β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€
β”‚                   Streamlit Dashboard                            β”‚
β”‚     File Upload β€’ Pipeline Viz β€’ Process Logs (port 8501)       β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

⚑ Quick Start

See It In Action

DriftGuard pipeline: upload data β†’ auto-detect β†’ diagnose β†’ prescribe β†’ comply

Docker (Recommended)

git clone https://github.com/YOUR_USERNAME/driftguard.git
cd driftguard
cp .env.example .env
docker compose up

Open http://localhost:8501 β€” upload a CSV and click Run Pipeline.

Local Development

git clone https://github.com/YOUR_USERNAME/driftguard.git
cd driftguard
python -m venv .venv && source .venv/bin/activate
pip install -e .
pip install streamlit plotly

# Run dashboard
streamlit run dashboard/app.py

# Or run API only
python -m driftguard.main

# Run tests
pytest tests/ -v

πŸ–₯️ Dashboard

Pipeline Tab

  • Upload CSV or select sample data
  • Auto-splits: 70% training / 30% analysis
  • Real-time progress tracking
  • Agent result cards with metrics

Process Log Tab

  • Timestamped execution log
  • Color-coded levels (INFO / WARNING / ERROR)
  • Downloadable as text file
  • Per-agent activity tracking

Sensor Data Tab

  • Interactive time-series charts for all 8 sensors
  • Statistical summary table (mean, std, min, max)
  • Raw data preview

UI Features

  • πŸŒ™ Dark / Light Mode toggle in sidebar
  • πŸ“‘ Activity Monitor β€” real-time log of pipeline actions in the sidebar
  • πŸ”— DMN Solutions branding β€” clickable logo links to dmnsolutions.com.au
  • ⚠️ Error reporting β€” full tracebacks shown on failure with downloadable logs

πŸ€– Agents

πŸ” Sentinel Agent

Role: First line of defense β€” detects anomalies and triages by severity.

  • Model: Isolation Forest (200 estimators, 5% contamination)
  • Triage levels: NOISE β†’ WATCH β†’ ACT β†’ CRITICAL
  • Key metric: Reduces false positives by ~80% through confidence-gated escalation

🩺 Diagnostician Agent

Role: Root cause analysis on escalated anomalies.

  • Method: Z-score analysis against baseline + domain knowledge correlation
  • Knowledge base: 8 event type signatures from 3W dataset (BSW increase, DHSV closure, slugging, etc.)
  • Output: Probable cause, confidence score, contributing sensors, urgency level

πŸ’Š Prescriptor Agent

Role: Translates diagnoses into actionable remediation steps.

  • Action catalog: 6+ predefined actions (choke adjustment, gas-lift tuning, inspection scheduling, emergency shutdown)
  • Risk assessment: LOW / MEDIUM / HIGH with human approval gates
  • Escalation: Automatic for critical events or high-risk actions

πŸ“‹ Compliance Agent

Role: Regulatory emissions monitoring and audit reporting.

  • Metrics: Methane emissions (daily/hourly kg), intensity percentage
  • Frameworks: EPA NSPS OOOOa/b/c, OGMP 2.0, EU Methane Regulation
  • Output: Compliance alerts, violation detection, audit-ready reports

πŸ“Š Data

Built for the Petrobras 3W Dataset β€” a curated collection of real and simulated offshore oil well events.

Property Value
Sensors P-PDG, P-TPT, T-TPT, P-MON-CKP, T-JUS-CKP, P-JUS-CKGL, T-JUS-CKGL, QGL
Event Types 9 (Normal + 8 fault types)
Real wells 17 production wells
Time resolution 1 second
License CC BY 4.0

🐳 Docker

# docker-compose.yml provides two services:
services:
  dashboard:   # Streamlit UI on port 8501
  api:         # FastAPI backend on port 8000
# Start both services
docker compose up -d

# View logs
docker compose logs -f

# Stop
docker compose down

Image details:

  • Base: python:3.11-slim (multi-stage build)
  • Security: Non-root user, tini init system
  • Size: ~450MB compressed

πŸ§ͺ Testing

# Run all tests (11 tests covering full pipeline)
pytest tests/ -v

# Run E2E demo against real 3W data
python run_demo.py

Test coverage:

  • βœ… Full pipeline integration (async)
  • βœ… Sentinel anomaly detection
  • βœ… Sentinel false positive rate
  • βœ… Diagnostician diagnosis quality
  • βœ… Diagnostician baseline validation
  • βœ… Orchestrator training
  • βœ… Orchestrator error handling
  • βœ… Pipeline state management

πŸ“ Project Structure

driftguard/
β”œβ”€β”€ driftguard/
β”‚   β”œβ”€β”€ agents/
β”‚   β”‚   β”œβ”€β”€ sentinel/        # Anomaly detection + severity triage
β”‚   β”‚   β”œβ”€β”€ diagnostician/   # Root cause analysis + domain knowledge
β”‚   β”‚   β”œβ”€β”€ prescriptor/     # Action recommendations + escalation
β”‚   β”‚   └── compliance/      # Emissions monitoring + regulatory
β”‚   β”œβ”€β”€ orchestrator/        # Pipeline state machine + coordination
β”‚   β”œβ”€β”€ shared/
β”‚   β”‚   β”œβ”€β”€ schemas/         # Pydantic event models
β”‚   β”‚   β”œβ”€β”€ config.py        # Environment configuration
β”‚   β”‚   β”œβ”€β”€ data_loader.py   # 3W dataset loading + feature engineering
β”‚   β”‚   └── logging.py       # Structured logging (structlog)
β”‚   β”œβ”€β”€ api/                 # FastAPI REST gateway
β”‚   └── main.py              # Uvicorn entry point
β”œβ”€β”€ dashboard/
β”‚   β”œβ”€β”€ app.py               # Streamlit main application
β”‚   β”œβ”€β”€ components.py        # Reusable UI components
β”‚   └── logger.py            # Process execution logger
β”œβ”€β”€ tests/                   # pytest suite
β”œβ”€β”€ assets/                  # Banner and images
β”œβ”€β”€ scripts/                 # Docker entrypoint
β”œβ”€β”€ Dockerfile               # Multi-stage container build
β”œβ”€β”€ docker-compose.yml       # Service orchestration
β”œβ”€β”€ pyproject.toml           # Project metadata + dependencies
β”œβ”€β”€ requirements.txt         # Pinned production dependencies
β”œβ”€β”€ run_demo.py              # E2E demo script
└── .env.example             # Environment template

πŸ› οΈ Tech Stack

Component Technology Version
API FastAPI 0.115.0
ML scikit-learn (Isolation Forest) 1.5.1
Data pandas + NumPy 2.2.2 / 1.26.4
Validation Pydantic 2.8.2
Dashboard Streamlit + Plotly 1.37+
Logging structlog 24.4.0
Container Docker + Compose multi-stage
Testing pytest + pytest-asyncio 8.3.2

πŸ—ΊοΈ Roadmap

  • LLM-powered Diagnostician (natural language root cause explanations)
  • WebSocket real-time streaming for live sensor feeds
  • Model drift detection (monitor Sentinel's own performance)
  • Multi-well orchestration (fleet-level anomaly correlation)
  • Grafana/Prometheus metrics export
  • Kubernetes deployment manifests

🀝 Contributing

We welcome contributions! Whether you're adding new ML models, cloud deployments, integrations, or documentation β€” check our Contributing Guide to get started.

Looking for a place to start? Browse issues labeled good first issue or help wanted.


πŸ™ Acknowledgments

This project builds upon the foundational work of Suleman Mohammed and his Industrial Time-Series Anomaly Detection for Oil Wells project, which demonstrated how machine learning can support predictive monitoring using the Petrobras 3W dataset with supervised classification, feature engineering, and dashboard-based monitoring.

DriftGuard extends this concept into a fully agentic architecture β€” moving beyond detection into autonomous diagnosis, prescription, and compliance monitoring. While the original project answers "Is this reading abnormal?", DriftGuard answers "Why is it abnormal, what should we do about it, and are we still compliant?"


πŸ“„ License

MIT License. See LICENSE for details.


Built with Purpose
Because every suppressed false alarm is an operator who stays focused on what matters.

About

πŸ›‘οΈ DriftGuard β€” Agentic Anomaly Detection for Oil & Gas Operations. Multi-agent AI system with Sentinel, Diagnostician, Prescriptor & Compliance agents.

Resources

Contributing

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages