From adfb9720fe9ab0798d63f5d0f017ab0fa227ca41 Mon Sep 17 00:00:00 2001 From: abrichr Date: Tue, 24 Nov 2026 23:44:33 -0500 Subject: [PATCH 1/3] fix(quickstart): guard everyday local_state probes when installed openadapt-flow lacks new source types --- openadapt/quickstart/everyday.py | 8 +++++++- tests/test_everyday_quickstart.py | 31 ++++++++++++++++++++++++------- 2 files changed, 31 insertions(+), 8 deletions(-) diff --git a/openadapt/quickstart/everyday.py b/openadapt/quickstart/everyday.py index a45e3d9847..7305e29fb6 100644 --- a/openadapt/quickstart/everyday.py +++ b/openadapt/quickstart/everyday.py @@ -237,7 +237,13 @@ def _probe_baseline( f"local_state verifier unavailable in installed openadapt-flow: {exc}", ) - cfg = VerifyConfig.model_validate(verify_doc) + try: + cfg = VerifyConfig.model_validate(verify_doc) + except Exception as exc: + return ( + None, + f"local_state probe unsupported by installed openadapt-flow: {exc}", + ) sources = list(cfg.verifier.local_state or []) if verifier_factory is not None: verifier = verifier_factory(sources, platform=platform) diff --git a/tests/test_everyday_quickstart.py b/tests/test_everyday_quickstart.py index fe02c9e575..4c4bccb609 100644 --- a/tests/test_everyday_quickstart.py +++ b/tests/test_everyday_quickstart.py @@ -19,15 +19,32 @@ ) try: - from openadapt_flow.runtime.effects.local_state import LocalStateVerifier + from openadapt_flow.runtime.effects.local_state import ( + LocalStateVerifier, + MacOSCalendarEventSource, + MacOSNightShiftSource, + WindowsNightLightSource, + ) from openadapt_flow.verify_run import VerifyConfig -except ImportError: # launcher CI installs released openadapt-flow without local_state + + _HAS_EVERYDAY_PROBES = all( + cls is not None + for cls in ( + LocalStateVerifier, + MacOSCalendarEventSource, + MacOSNightShiftSource, + WindowsNightLightSource, + VerifyConfig, + ) + ) +except ImportError: # launcher CI installs released openadapt-flow without everyday probes LocalStateVerifier = None # type: ignore[assignment] VerifyConfig = None # type: ignore[assignment] + _HAS_EVERYDAY_PROBES = False _REQUIRES_LOCAL_STATE = pytest.mark.skipif( - LocalStateVerifier is None, - reason="openadapt_flow.runtime.effects.local_state not in installed openadapt-flow", + not _HAS_EVERYDAY_PROBES, + reason="everyday local_state probes not in installed openadapt-flow", ) @@ -41,7 +58,7 @@ def test_build_night_shift_contracts_macos_and_windows_with_revert() -> None: assert rev_mac["effects"][0]["value"] == "false" assert params_mac["target_enabled"] == "true" assert params_mac["restore_enabled"] == "false" - if LocalStateVerifier is not None and VerifyConfig is not None: + if _HAS_EVERYDAY_PROBES: VerifyConfig.model_validate(fwd_mac) VerifyConfig.model_validate(rev_mac) @@ -52,7 +69,7 @@ def test_build_night_shift_contracts_macos_and_windows_with_revert() -> None: assert fwd_win["effects"][0]["value"] == "false" assert rev_win is None assert params_win["revert"] is False - if LocalStateVerifier is not None and VerifyConfig is not None: + if _HAS_EVERYDAY_PROBES: VerifyConfig.model_validate(fwd_win) # Unreadable baseline (None) must NOT invent a revert baseline @@ -88,7 +105,7 @@ def test_build_calendar_block_contracts_parameterized_and_revert() -> None: assert params["end_iso"] == "2026-11-24T14:45:00" assert params["duration_minutes"] == 45 assert params["recurrence"] == "weekly" - if LocalStateVerifier is not None and VerifyConfig is not None: + if _HAS_EVERYDAY_PROBES: VerifyConfig.model_validate(fwd) VerifyConfig.model_validate(rev) From c05f87e3ed91b08f36a92b2317ab6f9663a1e660 Mon Sep 17 00:00:00 2001 From: abrichr Date: Tue, 24 Nov 2026 23:49:32 -0500 Subject: [PATCH 2/3] fix(quickstart): catch narrow pydantic ValidationError instead of Exception --- openadapt/quickstart/everyday.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/openadapt/quickstart/everyday.py b/openadapt/quickstart/everyday.py index 7305e29fb6..e76287e393 100644 --- a/openadapt/quickstart/everyday.py +++ b/openadapt/quickstart/everyday.py @@ -237,9 +237,11 @@ def _probe_baseline( f"local_state verifier unavailable in installed openadapt-flow: {exc}", ) + from pydantic import ValidationError + try: cfg = VerifyConfig.model_validate(verify_doc) - except Exception as exc: + except ValidationError as exc: return ( None, f"local_state probe unsupported by installed openadapt-flow: {exc}", From 3592c54280743a9bbd5b8f07c8f6b7c8496d2b19 Mon Sep 17 00:00:00 2001 From: abrichr Date: Wed, 25 Nov 2026 00:07:42 -0500 Subject: [PATCH 3/3] style: apply ruff format and lint fixes --- tests/test_everyday_quickstart.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/tests/test_everyday_quickstart.py b/tests/test_everyday_quickstart.py index 4c4bccb609..1010294515 100644 --- a/tests/test_everyday_quickstart.py +++ b/tests/test_everyday_quickstart.py @@ -37,7 +37,9 @@ VerifyConfig, ) ) -except ImportError: # launcher CI installs released openadapt-flow without everyday probes +except ( + ImportError +): # launcher CI installs released openadapt-flow without everyday probes LocalStateVerifier = None # type: ignore[assignment] VerifyConfig = None # type: ignore[assignment] _HAS_EVERYDAY_PROBES = False