Repository navigation
fix: don't start the trigger after a Stop during scan pre-flight (#318) - #320
Merged
Merged
Conversation
A Stop that landed while the scan worker was still in its pre-flight sent
cancel_scan's stop_trigger before the worker's start_trigger. The trigger
and laser then ran on after Stop, the terminal fsync count was read
mid-run and named a lit frame (TERMINAL DARK CONTAMINATED on every
camera), and the app never saw trigger OFF ("trigger clock still open").
cancel_scan now sets _cancel_requested before stopping, and a new
_trigger_lock orders its stop against the worker's trigger start: the
worker skips start_trigger once a cancel has arrived, and a Stop that
races an in-flight start_trigger waits for it and then stops it.
Refs #318
Refs OpenwaterHealth/openmotion-bloodflow-app#726
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: boringethan <ethan@openwater.cc>
boringethan
force-pushed
the
feature/318-cancel-preflight-race
branch
from
October 14, 2026 20:49
d491963 to
60faa3e
Compare
Merged
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.
Summary
Pressing Stop right as a scan starts could land while the
ScanWorkflowworker was still in its pre-flight, andcancel_scan()'sstop_triggerthen reached the console before the worker'sstart_trigger. The window is about 0.3 s, roughly 2 s after Start in the app. The worker started the trigger anyway, so:TERMINAL DARK CONTAMINATEDon every camera and an empty session deleted (app#726);Root-cause write-up with the log evidence: OpenwaterHealth/openmotion-bloodflow-app#726 (comment)
Change
cancel_scansets_cancel_requestedbefore it stops the trigger._trigger_lockorders that stop against the worker's trigger start:start_triggeronce a cancel has arrived;start_triggerwaits for it, then stops the trigger.Tests
Two new unit tests in
tests/test_scan_workflow.py. Both fail on currentnext, where the console sees['stop', 'fsync', 'start', 'stop'](the order in the field logs), and pass with this change:test_stop_during_preflight_never_starts_the_triggertest_stop_while_the_trigger_starts_stops_it_afterwardsHardware-free modules run:
test_scan_workflow,test_pipeline/test_sources(minus the hardware smoke test),test_calibration_workflow,test_run_collection_scan,test_contact_quality_workflow,test_pipeline/test_packet_bufferandtest_pipeline/test_public_api. All 89 tests pass.Not yet verified on hardware. Bench check: in the app, press Stop about 2 s after Start (just as the scan begins). Expect:
TERMINAL DARKERROR lines;Closes #318
Refs OpenwaterHealth/openmotion-bloodflow-app#726
🤖 Generated with Claude Code