How thakur-sahab-01/air-gapped-noc-copilot works
1. System boundary
This repo is an offline predictive NOC copilot for MPLS links. The architecture is split into an offline build/train phase and an air-gapped inference phase. At runtime, the system is designed to operate with zero outbound network calls.
2. Top-level orchestration
setup_pipeline.py is the bootstrap entry point. It checks whether trained artifacts already exist, otherwise it runs the generation/training pipeline and then launches the dashboard. The repo also supports running each stage manually.
3. Synthetic telemetry source
src/synthetic_data.py generates the operational dataset in data/telemetry.csv. It simulates multiple links over time with realistic daily patterns and failure signatures, including latency, jitter, loss, utilisation, interface errors, BGP/LSP flaps, CPU, and temperature.
4. Feature engineering layer
src/features.py turns raw telemetry into rolling-window features used by the models. This is the main transformation boundary between time-series telemetry and supervised learning inputs. The README indicates the features are built per link over historical windows.
5. Model training and artifacts
src/train_model.py trains two XGBoost classifiers for different prediction horizons: 30 minutes and 240 minutes ahead. The resulting artifacts are saved under models/ as model_target_30min.joblib, model_target_240min.joblib, plus feature_columns.json and metrics.json.
6. Generalisation strategy
The models are evaluated on unseen links, not just later timestamps, using a group-based split by link_id. That means the architecture is intentionally validating whether the predictors generalize across infrastructure instances, not only across time.
7. Live simulation / replay
src/simulate.py and the dashboard together provide the runtime telemetry stream. The dashboard can advance a simulated clock and inject failures, which feeds the prediction pipeline with fresh link state as if it were a live NOC feed.
8. Prediction + explainability
src/explain.py provides SHAP-based attribution for each prediction. It maps raw feature contributions into one of five root-cause categories such as congestion, interface degradation, BGP instability, LSP flapping, or hardware/control-plane fault, and produces a confidence score for that diagnosis.
9. Operator narrative generation
src/copilot.py converts the structured diagnosis into a human-readable NOC briefing. It has two backends: a local template-based narrator and an optional Ollama LLM backend. The template fallback is important because it preserves offline operation if no local model is available.
10. Offline knowledge base
src/knowledge_base.py implements retrieval over the runbook corpus in data/runbooks/ using TF-IDF. This gives the copilot grounded operational guidance without any external search or model download dependency.
11. Dashboard as the integration point
dashboard.py is the user-facing integration layer. It ties together the simulated telemetry, risk ranking, SHAP visualization, copilot explanation, runbook retrieval, and operator feedback controls into a single Streamlit NOC console.
12. Data and model flow
The end-to-end flow is: synthetic telemetry → feature windows → trained classifiers → risk scores → SHAP explanation → root-cause mapping → narrative/runbook guidance → operator action. The main architectural boundary is that all of these steps run locally from checked-in code plus generated artifacts in data/ and models/.
13. External dependency boundary
The only optional external runtime dependency is Ollama, used locally for richer narrative generation. If it is unavailable, the system falls back automatically, so the core architecture remains fully functional in an isolated environment.
Main entry points: dashboard.py NOC dashboard · knowledge_base.py Runbook retrieval · train_model.py Train model · features.py Feature windows
Components 19
Offline build/train
Synthetic data generation, feature engineering, and model training that produce local artifacts.
- Setup pipeline · Checks for existing artifacts, runs training if needed, then launches the dashboard.
setup_pipeline.py - Synthetic telemetry · Generates multi-link telemetry with daily patterns and fault signatures.
src/synthetic_data.py - Telemetry CSV · Generated operational telemetry used for feature building and training.
- Feature windows · Builds rolling per-link features from historical telemetry.
src/features.py - Train model · Trains horizon-specific XGBoost classifiers and writes model artifacts.
src/train_model.py - 30 min model · Classifier for near-term prediction horizon.
models/model_target_30min.joblib - 240 min model · Classifier for longer prediction horizon.
models/model_target_240min.joblib - Feature schema · Saved feature column list used to align inference inputs.
models/feature_columns.json - Training metrics · Saved evaluation results for the trained models.
models/metrics.json
Air-gapped runtime
Simulation, prediction, explanation, and operator-facing copilot flow with no outbound calls.
- Telemetry replay · Advances simulated time and injects failures for live-like operation.
src/simulate.py - NOC dashboard · Main operator interface combining telemetry, risk ranking, explanations, and controls.
dashboard.py - Explain risk · Maps model outputs to root-cause categories with confidence scoring.
src/explain.py - Copilot briefing · Turns structured diagnosis into a human-readable NOC briefing.
src/copilot.py
Local knowledge
Runbook corpus and retrieval used to ground operator guidance offline.
- Runbook retrieval · Retrieves grounded guidance from local runbooks using offline text search.
src/knowledge_base.py - BGP runbook · Guidance for instability and control-plane issues.
data/runbooks/bgp_instability.txt - Congestion runbook · Guidance for sustained utilization and latency issues.
data/runbooks/congestion.txt - Hardware runbook · Guidance for device faults and environmental problems.
data/runbooks/hardware_fault.txt - Interface runbook · Guidance for interface degradation and errors.
data/runbooks/interface_degradation.txt - LSP runbook · Guidance for path flapping and MPLS instability.
data/runbooks/lsp_flapping.txt
Connections 22
- Setup pipeline → Synthetic telemetry: generate data · Creates telemetry when artifacts are missing.
- Synthetic telemetry → Telemetry CSV: write dataset · Persists the simulated telemetry dataset.
- Telemetry CSV → Feature windows: window features · Transforms raw telemetry into supervised learning inputs.
- Feature windows → Train model: train on · Feeds engineered windows into the training pipeline.
- Train model → 30 min model: save · Writes the 30-minute horizon classifier.
- Train model → 240 min model: save · Writes the 240-minute horizon classifier.
- Train model → Feature schema: save · Stores the feature schema used at inference time.
- Train model → Training metrics: save · Stores evaluation results and model metrics.
- Setup pipeline → NOC dashboard: launch · Starts the operator console after artifacts are ready.
- Telemetry replay → NOC dashboard: feed telemetry · Provides live-like link state to the console.
- NOC dashboard → Feature windows: infer features · Builds the same rolling inputs for scoring.
- NOC dashboard → 30 min model: score 30m · Runs the near-term risk classifier.
- NOC dashboard → 240 min model: score 240m · Runs the longer-horizon risk classifier.
- NOC dashboard → Explain risk: explain prediction · Generates SHAP-based root-cause attribution.
- Explain risk → Copilot briefing: diagnosis · Passes category and confidence into narration.
- Copilot briefing → Runbook retrieval: ground guidance · Retrieves relevant runbook content for the briefing.
- Runbook retrieval → BGP runbook: index · Uses BGP instability guidance.
- Runbook retrieval → Congestion runbook: index · Uses congestion guidance.
- Runbook retrieval → Hardware runbook: index · Uses hardware fault guidance.
- Runbook retrieval → Interface runbook: index · Uses interface degradation guidance.
- Runbook retrieval → LSP runbook: index · Uses LSP flapping guidance.
- NOC dashboard → Copilot briefing: brief operator · Renders the human-readable recommendation.