Blog · Building · · 7 min read

Why valid AI code can still drive the wrong machine

Checking that AI-generated control code imports real software libraries does not confirm that it matches the physical machine on the floor. Keeping pumps, valves, and local accelerators safe requires matching every script against declared hardware wiring and holding the whole job at a hardware gate before any register changes.

Unframed sepia-and-pastel watercolor vignette on warm cream paper showing a wooden workshop bench where a slate-blue socket wrench slips beside a brass valve nut on the left, while a sage-green mechanical interlock gate with a brass pin holds a copper coupling steady before a terracotta water pump housing on the right.

When real software packages talk to the wrong controller

Checking that AI-generated control code imports real software libraries does not confirm that it matches the physical machine on the floor. Keeping pumps, valves, and local accelerators safe requires matching every script against declared hardware wiring and holding the whole job at a hardware gate before any register changes.

Most automated code checkers today look for invented package names. When an AI coding assistant writes a Python script, the linter checks whether each imported library exists in the registry and whether its method names compile. Passing that check feels reassuring on a laptop screen.

Physical equipment fails under a different mistake. A metric socket wrench in a toolbox is a genuine steel tool, yet forcing a thirteen-millimeter socket onto a half-inch brass valve nut rounds off the corners under load. Confirming that the wrench is real tells you nothing about whether it fits the pipe in front of you.

In November 2026, S M Zia Ur Rashid, Sazidul Islam Hira, and Suman Rath audited 883 AI-generated Python scripts written to drive industrial programmable logic controllers.1 Their static verifier, Proteus-OT, checked each script against a version-pinned map of documented vendor protocols.1 Across those 883 scripts, 180 carried an import-level mismatch against the declared target controller, a 20.4 percent error rate.1 On single-vendor targets, 16.3 percent mismatched the hardware, and 14.2 percent carried the incompatible library straight into an active protocol communication call.1

Standard hallucination checks missed almost the entire problem. Within the balanced audit subset, 96.6 percent of mismatching scripts imported genuine Python packages and called real methods.1 None of the 28 adjudicable human control files carried a vendor-protocol mismatch, though that human sample was too small to estimate a broad industry rate.1

Why writing hardware registers one by one leaves a gap

Matching the right software library to the right controller closes only the top half of the dispatch path. Beneath Python scripts, host processors configure local hardware accelerators and field-programmable gate arrays by writing control registers one address at a time.2

In November 2026, hardware researcher Mohamed El-Hadedy showed how register-by-register dispatch breaks trust on system-on-chip accelerators.2 Standard access rules check who may reach an accelerator or protect its memory, yet the processor still writes control words piecemeal.2 Faulty or compromised host software can alter one register address mid-flight or resend a previously approved command.2 In software modeling, checking each register write individually allowed hybrid jobs stitched together from two separate approved runs.2

Existence-only code checks and piecemeal register writes contrasted with target-matched static verification and whole-job hardware gates Left column shows existence-only package checks letting 20.4 percent of controller scripts mismatch target protocols and piecemeal register writes allowing mixed or replayed jobs. Right column shows static vendor-protocol matching, whole-job authenticated FPGA gates blocking all 14,700 altered or replayed runs, and passive physical safety relays. UNCHECKED WIRING & PIECEMEAL WRITES Compiler checks syntax while host writes registers live 1. Package-Existence Check Only 96.6% of mismatched scripts call real libraries 2. Wrong Controller Protocol 20.4% mismatch target; 14.2% reach live calls 3. Register-by-Register Dispatch Host splices or replays individual register writes Result: Valid code drives unapproved hardware runs TARGET MATCH & WHOLE-JOB GATE Pinned protocol graph, sealed job gate, and relay fuse 1. Pinned Vendor-Protocol Audit Verifies imports match declared machine model 2. Whole-Job Hardware Logic Gate 21,000 approved run; 0 of 14,700 altered pass 3. Multi-Sensor Check & Dead-Man Relay Safe-hold brake cuts motor power on fault Result: Physical motion waits on verified ticket Piecemeal hardware dispatch versus whole-job hardware gates on mobile Stacked mobile diagram contrasting existence-only package checks and piecemeal register writes against static vendor-protocol matching, whole-job FPGA gates, and physical dead-man relays. UNSEALED: PIECEMEAL DISPATCH 20.4% Wrong Controller Imports 96.6% still call real Python packages Register-by-Register Splicing Host mixes or replays single writes SEALED: WHOLE-JOB CHIP GATE 1. Pinned Vendor-Protocol Audit Matches code to declared machine 2. Sealed Whole-Job Logic Gate 0 of 14,700 altered jobs released 3. Cross-Sensor & Dead-Man Relay ~10 us gate cost & safe power cut
Checking only whether imported libraries exist misses wrong-controller protocols, and piecemeal register writes let compromised software splice commands (left). Matching code to pinned device wiring, verifying sealed whole jobs in hardware logic, and wiring physical safety relays stops altered dispatches before equipment moves (right).

El-Hadedy closed that gap with WADJET, a single logic gate placed directly in front of an unmodified accelerator.2 A separate authority encrypts and signs the entire approved job with a fresh sequence number.2 The hardware gate holds the whole job back until verified, retires the sequence number so nobody can replay it, and writes the registers itself.2

On a Zynq-7020 chip running a language model, the gate released all 21,000 approved jobs and zero of 14,700 altered or repeated ones.2 It used one-third the logic lookup tables of earlier register-level guards and added roughly ten microseconds to job startup.2

Coupling physical reach to human oversight

Systems researchers Damir Safin and Dian Balta explain why these hardware boundaries matter more as software runs longer unattended.3 In regulated settings, autonomy (how long an agent acts without human check-ins) and agency (what equipment or records it can touch) pull against each other.3 Whenever human error-catching steps back, safe design must narrow the actions hardware will physically accept.3

Bench tests on physical chips show what happens when safety relies on model training alone. In November 2026, Peter Horvath and colleagues showed that timed electromagnetic pulses on edge memory chips wiped safety refusals without crashing the system and made a robot arm lunge twice.4 Zheyuan Liu and colleagues also showed that stopping a robot mid-motion takes dedicated safe-hold routines, cutting prohibited task completion to 1.3 percent without dropping held objects.5

We propose three engineering fuses for any team connecting AI coding or planning tools to physical equipment:

  1. Audit every script against pinned machine metadata before execution. Verify that imported libraries and communication calls match the exact vendor and controller model wired to the bench, producing an inspectable witness before deployment.1
  2. Hold whole jobs at an independent hardware gate. Require sealed, sequence-numbered approvals checked in hardware logic before any control register is written, blocking mid-stream edits and replayed commands.2
  3. Keep sensors cross-checked and motor power behind physical relays. Pair one-way optical sensor links and mid-run safe-hold routines with passive dead-man switches that cut motor power whenever local human or safety approval drops.4,5,6

The strongest objection and what remains unsolved

Industrial and embedded teams often object that static protocol maps and hardware dispatch gates add setup friction across mixed-vendor plants. Yet ten microseconds of gate latency and a fast pre-run static check cost far less than recovering from a damaged pump or an unapproved actuator cycle.1,2,7

Three real limits remain unsolved:

  • Protocol match is not physical safety. As Rashid, Hira, and Rath note, matching a script to the right vendor protocol confirms wiring compatibility, yet it cannot verify safe pressure limits, temperatures, or site intent.1
  • Hardware gates rely on root keys and reset lines. El-Hadedy notes that whole-job FPGA verification still assumes trusted control over the signing key, hardware reset pin, and chip configuration stream.2
  • Sensors can be spoofed before digitization. Kun Wang and colleagues demonstrated across 14 sensor models and 6 physical principles that analog hardware Trojans triggered above 95 percent while leaving digital signatures intact, making cross-sensor checks mandatory.6

What you can do now

  • If you maintain industrial, lab, or home-automation code, add version-pinned vendor-protocol checks to your build pipeline alongside standard syntax linters.1
  • If you build edge accelerators or robotics controllers, test whole-job dispatch gates and safe-hold routines using the engineering patterns in For builders and our simulation wind tunnels.2,5
  • Explore how sensor cross-checks and expiring permissions work together in Sensor Boundary, Protocol Inspector, and Shared Horizon.

Related reading: Why a signed sensor can still be fooled. Why field crews need portable edge AI with a proof gate. Why faster AI code still waits on the test bench. AI agents should hold permissions that expire. Shared Horizon action library.

Sources

  1. S M Zia Ur Rashid, Sazidul Islam Hira, and Suman Rath, "Real Package, Wrong Controller: Static Auditing of Vendor--Protocol Mismatches in LLM-Generated PLC Code," arXiv preprint (2026), arXiv:2611.33227.
  2. Mohamed El-Hadedy, "WADJET: Whole-Job Authorization and Dispatch for Job Execution Trust on FPGA System-on-Chip Accelerators," arXiv preprint (2026), arXiv:2611.33406.
  3. Damir Safin and Dian Balta, "Autonomy and Agency in Agentic AI: Architectural Tactics for Regulated Contexts," arXiv preprint (2026), arXiv:2605.12105.
  4. Peter Horvath, Ilia Shumailov, Zhuoran Liu, Lukasz Chmielewski, and Lejla Batina, "FATCAT: Fault Injection Attacks Targeting Chip-level Alignment," arXiv preprint (2026), arXiv:2611.31129.
  5. Zheyuan Liu, Chuhan Wang, Jinduo Guo, Yue Huang, Xiangchi Yuan, Ningshan Ma, and Meng Jiang, "Teaching Vision-Language-Action Models to Stop Safely," arXiv preprint (2026), arXiv:2611.26239.
  6. Kun Wang, Ruochen Zhou, Wenjun Zhu, Shilin Xiao, Kai Wang, Chen Yan, Xiaoyu Ji, and Wenyuan Xu, "SenTrojan: Revealing Analog Hardware Trojan Attacks on Sensors," arXiv preprint (2026), arXiv:2611.06103.
  7. Dwarkesh Patel, "AI researchers debate whether we need to pause AI now," YouTube discussion on compute and time pressure tempting shortcuts around safer verification (27 November 2026, 32:44, 1:05:31), https://www.youtube.com/watch?v=TbKkN1cesTo; and Stanford Online, "What Data Do AI Agents Need? | Stanford CS329Z Lecture 10 with John Yang," YouTube lecture on execution-environment validation for coding agents (24 November 2026, 58:29, 1:24:15), https://www.youtube.com/watch?v=HbgZFwWj4vY.
  8. Henk Birkholz, Dave Thaler, Michael Richardson, Ned Smith, and Wei Pan, Remote ATtestation procedureS (RATS) Architecture, IETF RFC 9334 (2023), rfc-editor.org/rfc/rfc9334; Kevin Fu and Wenyuan Xu, "Risks of trusting the physics of sensors," Communications of the ACM 61, no. 2 (2018): 20 to 23, doi:10.1145/3176402; and Coalition for Content Provenance and Authenticity, C2PA Technical Specification, v2.1 (2024), c2pa.org.
  9. Jack M. Balkin, "Information Fiduciaries and the First Amendment," UC Davis Law Review 49, no. 4 (2016): 1183 to 1234, lawreview.law.ucdavis.edu; Karl Friston, "Life as We Know It," Journal of the Royal Society Interface 10, no. 86 (2013): 20130475, doi:10.1098/rsif.2013.0475; and Jack B. Dennis and Earl C. Van Horn, "Programming Semantics for Multiprogrammed Computations," Communications of the ACM 9, no. 3 (1966): 143 to 155, doi:10.1145/365230.365252.
  10. Henk Birkholz, Antoine Delignat-Lavaud, Cedric Fournet, Yogesh Deshpande, and Steve Lasker, An Architecture for Trustworthy and Transparent Digital Supply Chains (SCITT), IETF RFC 9943 (2026), rfc-editor.org/rfc/rfc9943; John Meluso, Amanda Casari, Katie McLaughlin, and Milo Z. Trujillo, "Invisible Labor in Open Source Software Ecosystems," arXiv preprint (2024), arXiv:2401.06889; James Stodder, "Complementary Credit Networks and Macroeconomic Stability: Switzerland's Wirtschaftsring," Journal of Economic Behavior & Organization 72, no. 1 (2009): 79 to 95, doi:10.1016/j.jebo.2009.06.002; Rudolf Meidner, Employee Investment Funds: An Approach to Collective Capital Formation (George Allen & Unwin, 1978), archive.org/details/employeeinvestme0000meid; and Elinor Ostrom, Governing the Commons: The Evolution of Institutions for Collective Action (Cambridge University Press, 1990), doi:10.1017/CBO9780511807763.

← All articles

Recent articles

Value ·

Why AI resumes and hiring bots scramble who gets hired

Automated hiring portals scramble who gets hired when job seekers use AI models to rewrite resumes for keyword-scoring bots, displacing qualified workers across occupations. Recognizing real work requires verifiable task receipts, machine-speed mutual net-zero transparency between personal and employer agents, and cooperative ownership as automation grows.

Read · 8 min

Governing ·

Why secret AI models behind lab walls cannot prove they are safe

Keeping stronger AI models hidden inside company walls to build successor systems blinds the public while missing real-world failures that surface strictly in open use. Global transparency requires signed compute receipts, expiring permissions, and machine-speed mutual net-zero transparency across personal and community agents.

Read · 8 min

Seeing ·

Why society needs civic electronic warfare for rogue sensors

Satellite constellations and street sensor fleets have tripled under private corporate ownership while pixel blurring fails against modern AI. Surviving superhuman and corporate-controlled agent swarms requires a public electronic-warfare shield that detects non-participating sensors, alerts participants to information leaks, and expels off-contract espionage from trade networks.

Read · 9 min