Confirm the enclosure permit before serving requests after boot - #642
Merged
Conversation
Boot used to start the permit monitor task and immediately serve requests, so a start_run/start_procedure preflight landing in the first few seconds after a restart could pass on a stale permit_status left over from before the outage. enclosure_permit_monitor_lifespan now waits, bounded, for every configured enclosure's first settled observation, then drains the enclosure projection once, since the wait alone only proves an event was appended and permit_status is a denormalized column the ProjectionWorker catches up to separately. A PV or a slow drain that never settles does not block or fail boot past its timeout; the existing reading stands, gated the same as any other stale reading. Item 1 of the 2-BM coverage-window commissioning ladder. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Coverage reportClick to see where and how coverage changed
This report was generated by python-coverage-comment-action |
||||||||||||||||||||||||||||||||||||
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
start_run/start_procedurepreflight landing in the first few seconds after a restart could pass on a stalepermit_statusleft over from before the outage.enclosure_permit_monitor_lifespannow waits, bounded (default 8.0s, matchingEpicsCaControlPort's own connect timeout plus headroom), for every configured enclosure's first settled observation before yielding, then drains the enclosure projection once, since the wait alone only proves anEnclosurePermitObservedevent was appended andpermit_statusis a denormalized column theProjectionWorkercatches up to on its own poll cadence.No migration, no aggregate/decider/event change. New
Settings.enclosure_permit_monitor_startup_timeout_secondsfield (default 8.0), all new function parameters keyword-only and optional so no existing caller signature broke.Test plan
uv run pyrightclean on all changed filesuv run ruff check/ruff format --checkcleantests/integration/test_enclosure_permit_monitor.py(5 new unit tests plus 2 added during review: a cancellation-during-startup-wait regression test verified against a standalone repro of the pre-fix structure, and a drain-timeout-degrades-gracefully test)test_lifespan_drains_projection_before_yielding(integration, needs Postgres) not run locally — no Docker daemon in the dev sandbox; will run in CI🤖 Generated with Claude Code