Skip to content

Keep Oops/lock-out through MCU reboot; add Oops-clear safety tests (#201) - #206

Merged
jantman merged 1 commit into
mainfrom
robot-army/issue-201-machines-reportedly-power-back-on-after
Nov 21, 2026
Merged

jantman merged 1 commit into
mainfrom
robot-army/issue-201-machines-reportedly-power-back-on-after

Conversation

@jantman

@jantman jantman commented Nov 21, 2026

Copy link
Copy Markdown
Contributor

Addresses #201 (does not close it: the hardware follow-up is still open).

Changes

  • Fix: MachineState._handle_reboot() no longer turns the relay on for an always_enabled machine that is Oopsed or locked out. Latent: no production machine sets always_enabled.
  • Fix: a reboot of an Oopsed or locked-out machine keeps the Oops / lock-out display and LED instead of resetting to idle (the Resaw 2026-11-18 observation).
  • Tests: tests/views/test_oops_clear_safety.py. Oops with the card present → clear → same card keeps the relay off, including across a server restart (cache reload) and an MCU reboot; a fresh insert still logs in. The 4 reboot tests fail on the old code. The 5 card-present tests pass on both old and new code and stay as regression guards.
  • Docs: docs/2026-11-21-oops-clear-power-on-analysis.md with the findings.
  • Version 0.15.1 → 0.15.2.

Findings

I found no server or firmware path that closes the relay on an Oops clear for a normal machine. The firmware only energizes the relay on a 2xx response with "relay": true, and the switch uses the ESPHome default ALWAYS_OFF at boot. The most likely cause is machine switches left ON with no no-volt-release switch, so the next authorized login starts the motor. That needs staff input and hardware work, listed in the doc.

Testing

nox -s tests passed (362 tests, 98% coverage); pre-commit and mypy passed.

🤖 Generated with Claude Code

https://claude.ai/code/session_01KQ8DrLrQmFXweBWZzoxu7i

)

_handle_reboot() restored the always-on state for always_enabled machines
without checking is_oopsed / is_locked_out, so an MCU reboot energized the
relay of an Oopsed or locked-out always-enabled machine. For every other
machine it reset the LCD and status LED to the idle defaults, so a rebooted
Oopsed machine stopped showing the Oops message (seen on Resaw 2026-11-18).
It now keeps the relay off and the Oops / lock-out display for an Oopsed or
locked-out machine, and restores always-on only otherwise.

Adds tests/views/test_oops_clear_safety.py: Oops with the card present,
clear, then heartbeats with the same card keep the relay off, including
across a server restart (cache reload) and an MCU reboot; a fresh insert
still logs in. Plus reboot-while-Oopsed/locked-out cases, which fail on the
old code.

docs/2026-11-21-oops-clear-power-on-analysis.md records the investigation:
no server or firmware path closes the relay on a clear for a normal machine,
so the reported power-ons most likely come from machine switches left ON
(no no-volt-release switch), which needs hardware follow-up.

Bump version to 0.15.2.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01KQ8DrLrQmFXweBWZzoxu7i

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Claude Code review
From Claude, via the Claude PR Review workflow -- hence github-actions[bot].

Fixes _handle_reboot() so an Oopsed or locked-out machine keeps its relay off and its Oops/lock-out display after an MCU reboot, adds tests and an analysis doc, and bumps the version to 0.15.2. I found no bugs or CLAUDE.md violations in the change.

No issues found. Checked for bugs and CLAUDE.md compliance.


🔎 10s · 4 turns · $0.1116 · run log

@github-actions

Copy link
Copy Markdown

Coverage

Coverage Report
FileStmtsMissBranchBrPartCoverMissing
src/dm_mac
   __init__.py75060100% 
   cli_utils.py15000100% 
   neon_fob_adder.py2321560593%78->79, 79, 116–117, 124, 208->205, 269->270, 270, 333–334, 341, 364–367, 440->445, 454–456, 551->549
   neongetter.py231160399%313->314, 314, 455->459, 535->537
   slack_handler.py2200560100% 
   utils.py25040100% 
   webhook.py620100100% 
src/dm_mac/models
   __init__.py0000100% 
   api_schemas.py49000100% 
   machine.py658152181696%670->671, 671, 677->exit, 750->751, 751, 799->801, 1125->1126, 1126–1128, 1191->1193, 1243->1244, 1244–1253, 1416->exit
   users.py1030320100% 
src/dm_mac/views
   __init__.py0000100% 
   api.py41000100% 
   machine.py1030120100% 
   prometheus.py132012199%67->69
TOTAL1946314702598% 
Tests Skipped Failures Errors Time
362 0 💤 0 ❌ 0 🔥 17.865s ⏱️

@jantman
jantman merged commit 6cec936 into main Nov 21, 2026
17 checks passed
@jantman
jantman deleted the robot-army/issue-201-machines-reportedly-power-back-on-after branch November 21, 2026 12:57
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