Skip to content

asdspal/gridtrace

Repository files navigation

GridTrace

Institutional memory for power grid operators — built on Hermes Agent by NousResearch.

Built for the Hermes Agent Hackathon 2026.


The problem

Every time a grid failure happens and engineers bring it back online, that knowledge gets written into a report. Most of those reports are never read again. The next time the same fault occurs, the same diagnosis happens from scratch — sometimes years later, sometimes at 3am during a heat wave.

Worse: after major incidents, investigators recommend corrective actions. Many of those recommendations are never implemented. The failure recurs. The recommendation sits in a PDF.

GridTrace changes that.


What it does

GridTrace is a self-improving agent that ingests grid incident reports and makes their knowledge queryable in real time.

Feed it a new fault description. It searches 787 historical US power grid incidents spanning 2019–2026 and returns:

  • How many times this pattern has occurred before
  • Which balancing authority, when, and at what scale
  • The unimplemented fix — the corrective action recommended after prior incidents that was never acted upon
  • Whether the event matches a NERC-verified documented failure
  • Whether the pattern is systemic across multiple balancing authorities

The key field is unimplemented_fix. GridTrace doesn't just say "this happened before." It says: "here is the specific fix that was recommended and ignored — which may be why it is happening again."


Self-improving architecture

GridTrace uses Hermes Agent's native skill system. Every query updates the skill library:

  • After each incident query — the skill file for that (root_cause, balancing_authority) pair is patched with reasoning shortcuts discovered during the session
  • After cross-BA pattern detection — a meta-skill is created documenting the systemic pattern
  • After each nightly digest — seasonal patterns are written to persistent memory

Session 50 is faster and more accurate than session 1. The skill library grows with use.


Dataset

Vigil Infrastructure Memory Dataset — 787 curated US power grid incident records spanning 2019–2026.

Built from EIA EBA (Energy Information Administration Bulk Electricity API) hourly demand time series across 20 balancing authorities. Hours where demand dropped more than 12% below a rolling 7-day median baseline were flagged as anomaly events, deduplicated, and cross-referenced against 13 known NERC documented events.

Field Description
incident_id Unique incident identifier
event_date Date of the event
balancing_authority ERCO, CISO, PJM, MISO, NYIS, etc.
severity CRITICAL / HIGH / MEDIUM
mw_deviation MW drop from baseline
duration_hours Duration of the anomaly
root_cause Inferred or verified failure cause
nerc_label NERC-verified event name if applicable
unimplemented_fix The fix recommended after the incident that was never implemented

Composition: 197 CRITICAL · 404 HIGH · 186 MEDIUM
NERC-verified anchor events: 47 records tied to real documented failures including the 2021 Texas Winter Storm Uri, 2020 California Rolling Blackouts, 2023 Texas Heat Wave Near-Miss, and others.

The dataset is not included in this repository. Place your CSV at data/gridtrace_incidents.csv.


Architecture

Browser (React dashboard)
    ↓
FastAPI server (gridtrace_server.py)
    ↓ pandas queries (fast, in-memory)
    ↓ structured match report
    ↑ streaming response

Hermes Agent (CLI, background)
    ↓ reads AGENTS.md + SOUL.md
    ↓ writes/patches skill files after each query
    ↑ skill library grows over time

The data layer (CSV querying, match report formatting) runs entirely in the FastAPI server using pandas — fast and reliable. Hermes Agent handles reasoning, skill writing, and the self-improvement loop.


Setup

Requirements

  • Python 3.10+ with pandas, fastapi, uvicorn, python-dotenv
  • Node.js 18+
  • Hermes Agent installed
  • A Nous Portal subscription or OpenRouter API key

1. Install Hermes Agent

curl -fsSL https://raw.githubusercontent.com/NousResearch/hermes-agent/main/scripts/install.sh | bash
source ~/.bashrc
hermes login   # Nous Portal OAuth

2. Clone and configure GridTrace

git clone https://github.com/yourusername/gridtrace.git
cd gridtrace
cp .env.example .env
nano .env   # fill in your paths

.env fields:

GRIDTRACE_DIR=/home/youruser/gridtrace
HERMES_BIN=/home/youruser/.hermes/hermes-agent/venv/bin/hermes
SKILLS_DIR=/home/youruser/.hermes/skills/grid

3. Place the dataset

mkdir -p data/
cp /path/to/gridtrace_incidents.csv data/

4. Install Python dependencies

pip install fastapi uvicorn pandas python-dotenv

5. Ingest the dataset into Hermes skill library

python gridtrace_ingest.py --dry-run   # preview
python gridtrace_ingest.py             # write skills
cp -r skills/grid/ ~/.hermes/skills/grid/

6. Copy agent configuration

cp SOUL.md ~/.hermes/SOUL.md
# AGENTS.md is read automatically when hermes is launched from this directory

7. Start the API server

python gridtrace_server.py
# Running at http://localhost:8000

8. Start the React dashboard

cd gridtrace-ui
npm install
npm run dev
# Running at http://localhost:5173

9. (Optional) Start Hermes for skill self-improvement

# In a separate terminal, from the gridtrace directory:
hermes gateway   # enables cron + background skill writing

Usage

Open http://localhost:5173 and describe an incident in plain language:

ERCO, resource adequacy failure, extreme heat, 13000 MW deviation, 8 hours
PJM, load shedding near-miss, demand spike, 9000 MW deviation, 4 hours
Is resource adequacy extreme heat systemic across multiple balancing authorities?

GridTrace parses the query, searches the dataset, and streams back a structured match report with the unimplemented fix prominently highlighted.


Query types

Query What GridTrace does
ERCO, extreme heat, 13000 MW, 8 hours Direct BA + cause match, surfaces prior incidents and unimplemented fix
PJM, load shedding near-miss, 9000 MW Pattern match, broadens to all BAs if local count < 3
Is extreme heat systemic across multiple BAs? Cross-BA analysis, flags systemic patterns
Show me all ignored warnings Accountability report — all patterns with recurring unimplemented fixes

Project structure

gridtrace/
├── data/
│   └── gridtrace_incidents.csv      ← dataset (not in repo)
├── skills/
│   └── grid/                        ← base skill files (generated by ingest)
├── gridtrace-ui/                    ← React dashboard (Vite)
│   └── src/
│       └── App.jsx
├── AGENTS.md                        ← Hermes workflow instructions
├── SOUL.md                          ← GridTrace agent persona
├── gridtrace_ingest.py              ← bulk skill generator
├── gridtrace_server.py              ← FastAPI bridge
├── .env.example                     ← config template
└── .gitignore

Hermes skill library (auto-generated, lives outside the repo):

~/.hermes/skills/grid/
├── resource_adequacy_extreme_heat_erco/
│   └── SKILL.md                     ← base + reasoning shortcuts
├── load_shedding_near_miss_pjm/
│   └── SKILL.md
├── meta_resource_adequacy_extreme_heat/
│   └── SKILL.md                     ← cross-BA meta-skill (agent-created)
└── ...

Nightly digest

GridTrace can run a scheduled daily digest delivered to Telegram, Discord, or Slack via Hermes gateway:

# Inside hermes CLI
/cron add "0 6 * * *" "Run the GridTrace nightly digest"
hermes gateway install

The digest covers events from the past 7 days, flags watch BAs (2+ CRITICAL events), surfaces all outstanding unimplemented fixes, and detects cross-BA systemic patterns.


Built with

  • Hermes Agent — NousResearch's open-source self-improving agent framework
  • Hermes 3 Llama 70B — NousResearch's tool-calling model via Nous Portal
  • EIA Bulk Electricity API — source data for the incident dataset
  • FastAPI — API server
  • React + Vite — dashboard frontend
  • pandas — dataset querying

Why critical infrastructure

Power grid operators retire. Their knowledge — accumulated over decades of fault diagnosis, near-misses, and recovery procedures — retires with them. Recommended fixes go unimplemented because there is no system to surface them when the same fault recurs.

GridTrace is a step toward institutional memory that persists, grows, and actively surfaces what was known but forgotten.


Hackathon

Built for the Hermes Agent Hackathon — March 2026.

Judged on creativity, usefulness, and presentation.


License

MIT

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors