Sujahath Siddeek
All work

TeardownNov 2026Solo project

GridTwin-HIL

AI agents attack a real energy controller, prove each failure with a hardware timer, fix it, and then attack their own fix.

Built for the Meta Global AI Developer Hackathon, Indie track.

The GridTwin bench: an STM32 Nucleo board wired to a Raspberry Pi 5, with a breadboard and the trip LED.
The real bench. A Nucleo-G491RE plays the battery, a Raspberry Pi 5 runs the controller under test, and the LED is the trip line.
safety bugs found, measured and fixed on hardware
4
verification checks passed
31/31
worst-case trip of the final controller, against a 500 ms limit
123.4 ms

Replay the campaign

Pick a round, choose the controller before or after the fix, and inject the fault. The timings are the measured results from the real bench; the traces are a simulation of it.

Over-voltage at 500 ms polling, worst-case timing
100 ms/div
Trip
–
Limit
500 ms
Result
–

Polling the battery emulator. Inject a fault to measure the trip.

What the attacker found

At the slowest allowed polling (500 ms), a healthy link misses the 500 ms deadline. The attacker didn't trust the fixer's code comment and measured it.

The fix

Cap the safety-check period at 400 ms.

The problem

Every home battery and solar inverter is run by a controller that must cut power the moment something goes wrong. Testing that is the hard part. You can't over-charge a real 48 V lithium bank to see if the code reacts in time, and professional hardware-in-the-loop rigs cost tens of thousands of dollars.

So small energy teams test against mocks, and find the timing bugs in the field.

How I built it

A $20 STM32 Nucleo-G491RE pretends to be the battery, inverter and grid. It answers Modbus RTU like a real BMS, so the controller under test is the code you would ship, running on a real Raspberry Pi 5.

Three Meta Muse agents run the campaign. The attacker reads the code and designs fault scenarios. The judge (Muse Spark Open, open weights) reproduces each failure, runs a control and minimises it. The fixer patches the controller, and the judge reviews the patch before it reaches the Pi.

The trip line is a physical wire. The Pi raises a GPIO pin and the STM32 timestamps the edge in an interrupt with a 1 MHz counter. The AI decides what to test and how to fix it. The microcontroller decides whether it passed.

The rule is enforced in code, not in prompts: a finding is refused unless the agent's own hardware runs include a measured failure. A plain Python orchestrator deploys each approved patch and replays every earlier failure. Anything that fails is rolled back.

What happened

  • 5 rounds, 68 hardware runs, 14 measured failures and 4 fixes, each accepted on the first attempt. 31 of 31 verification checks passed, 70 minutes end to end.
  • Round 2: the attacker didn't trust the fixer's own code comment. At 500 ms polling, with no faults at all, it measured a 503.4 ms trip against a 500 ms deadline. The judge reproduced it independently.
  • Round 4: the round 3 fix tripped on a single lost reply, so ordinary line noise at 1% loss would shut a site down. The final controller has no nuisance trips and a worst-case trip of 123.4 ms.
  • An outside review then found the trip line wasn't fail-safe. After a new fail-safe interlock, the judge approved five patches with a heartbeat watchdog bug, and a hidden freeze check rejected all five. That round is recorded as open.
A convincing review is not a measurement.
From the GridTwin README

Architecture

AgentsAttackerMuse SparkJudgeMuse Spark OpenFixerMuse SparkOrchestratorPythonRaspberry Pi 5controller under testSTM32 Nucleobattery emulator, µs timerfindingverdicttoolsSSH deployUSB serialModbus RTUtrip wire
  • Python
  • Multi-agent systems
  • Meta Muse
  • STM32
  • Raspberry Pi 5
  • Modbus RTU
  • GitHub Actions

Next teardown

AeroIntel

RAG that refuses by design