fix(drivers): latch failed Modbus reprobes and keep the old VM - #984
Open
frahlg wants to merge 1 commit into
Open
fix(drivers): latch failed Modbus reprobes and keep the old VM#984frahlg wants to merge 1 commit into
frahlg wants to merge 1 commit into
Conversation
PR #982 reloaded a give-up driver, but a missing file retried every poll, failed attempts armed reprobe on a never-online device, and driver_init ran after the previous VM was already closed. Latch on reload failure, arm only after a successful read, and initialize the candidate before swapping so default-mode still has its locals. A long outage still retries: latching after every reload would miss the 9-minute Pixii blip that this path exists to recover. Signed-off-by: Cursor Agent <cursoragent@cursor.com> Co-authored-by: Fredrik Ahlgren <fredrik@sourceful-labs.com>
cursor
Bot
force-pushed
the
cursor/modbus-reprobe-review-fixes-1341
branch
from
August 27, 2026 12:49
3387c42 to
18cf2b9
Compare
frahlg
marked this pull request as ready for review
August 27, 2026 12:49
miravoss26
reviewed
Aug 27, 2026
miravoss26
left a comment
Contributor
There was a problem hiding this comment.
Reviewed. Fixes two real reload-loop bugs in the Lua Modbus give-up path.
What it does:
notePollModbusActivitynow keys offSuccessesinstead ofAttempts— a device that never answers no longer counts as "saw a read," so it stays given-up instead of reload-looping every poll.reprobeLockednow callsdriver_initon the new VM before discarding the old one. If init fails, the old VM is kept (so default-mode keeps working) instead of leaving the driver on a half-initialized VM.- A failed
reprobeLockedcall now latchesskipReprobe = true— a missing driver file no longer gets retried every single poll.
Correctness: the four new tests exercise exactly the distinction that matters here — failed-reload latches vs. successful-reload-but-device-still-down keeps retrying (the sustained-outage test is a good guard against over-latching, given the Pixii 9-minute-flap note in the comment). Old-VM-kept-on-failed-init is directly asserted via register-read counts staying flat and DefaultMode() still working post-failure.
Security: no secrets, no new deps, no new network destinations, no injection surface change. Pure state-machine fix.
Safe to merge from my read.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.


Accepted text proposal
Issue or Discussion: Follow-up to merged #982 (Fredrik merged without reading the reviews).
Maintainer comment that accepted this scope: Fredrik asked to check those reviews and fix anything that needed it.
What changed
The Modbus give-up reload from #982 now matches the safety boundaries that PR stated but did not implement:
os.ReadFile/ execute /driver_init) setsskipReprobe, so a missing file is not a per-poll loop.sawModbusReadis armed only onSuccesses > 0, not on failed attempts. A device that never answered is not reloaded once its give-up tables go quiet.reprobeLockedrunsdriver_initon the candidate VM before closing the previous one. Init failure restores the old VM sodriver_default_modestill has its locals.A prolonged outage still retries after give-up. Codex suggested latching after every reload; that would recover a 15-second flap and miss the ~9-minute Pixii blip this path exists to recover.
Why
Reviews on #982 (Codex P1/P2, Bugbot high + two mediums). Human review by miravoss26 said safe to merge, with a non-blocking question about re-reading from disk. The bot findings contradicted #982's own stated boundaries:
Attempts > 0treated transport failures as success.Boundaries and safety
driver_cleanup(no setpoint 0 as a recovery side effect).Out of scope: changing catalog
pixii.luagive-up to ignore transport errors (belongs insrcfl/device-drivers).Verification
go test ./internal/drivers/ -count=1 -run 'GiveUp|PixiiRecovers'— pass.go test ./internal/drivers/ -count=1— pass.masterafter #981 and srcfl/ftw-webapp#56, so the catalogue drift check should now compare against appmainthat hasdriver.offline/fuse.over_limit.Checklist