Skip to content

feat: plchealth — live PLC fault/diagnostic reader - #1

Merged
carbon-evolution merged 14 commits into
mainfrom
feat/plc-health
Jul 19, 2026
Merged

feat: plchealth — live PLC fault/diagnostic reader#1
carbon-evolution merged 14 commits into
mainfrom
feat/plc-health

Conversation

@carbon-evolution

Copy link
Copy Markdown
Owner

Adds the plchealth package: reads live PLC health over Modbus/S7comm/EtherNet-IP, decodes fault/CPU state, and reports it with scriptable exit codes (0 healthy, 1 fault, 2 unreachable). Read-only — never writes to a PLC.

What's included

  • Per-protocol probes (probes/modbus.py, probes/s7.py, probes/enip.py) returning a common PLCHealth model
  • poller.py with protocol auto-detect; cli.py poll subcommand with JSON/CSV output
  • Fault decode tables (Modbus exceptions, S7 CPU states, CIP status bits)
  • Extended sandbox mocks (S7 SZL 0x0424/0x00A0 diagnostics, ENIP status/state overrides) + new Modbus mock

Testing

  • 29 tests against bundled stdlib mock servers (runs in CI, no external deps)
  • 3 gated cross-checks against real simulators (pymodbus/snap7/cpppo), skipped unless installed
  • End-to-end verified: faulted S7 mock → state=STOP + diag fault → exit 1

Spec and plan in docs/superpowers/.

🤖 Generated with Claude Code

carbon-evolution and others added 14 commits July 19, 2026 16:35
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Common health model shared by all probes: State enum with 8 states (RUN,
STOP, STARTUP, HOLD, DEFECT, FAULT, UNKNOWN, UNREACHABLE); Fault dataclass
for fault reporting with code/description/source; PLCHealth dataclass
tracking host/port/proto/reachability/state/faults with healthy() check
and to_dict() JSON serialization. Includes unreachable() classmethod.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Also set allow_reuse_address on the Modbus mock so the test harness can
rebind a port still in TIME_WAIT from a prior run (fixes full-suite flake).

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@carbon-evolution
carbon-evolution merged commit ca1dddc into main Jul 19, 2026
2 checks passed
@carbon-evolution
carbon-evolution deleted the feat/plc-health branch July 19, 2026 09:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant