From fe387c940563571b9fa8f5d9791a1956d606f91d Mon Sep 17 00:00:00 2001 From: Pigbibi <20649888+Pigbibi@users.noreply.github.com> Date: Tue, 1 Sep 2026 21:46:04 +0800 Subject: [PATCH] fix: skip execution heartbeat for reconcile-only targets Co-Authored-By: Codex --- pyproject.toml | 4 ++-- qsl.toml | 2 +- scripts/runtime_heartbeat_policy.py | 15 +++++++++++++-- tests/test_runtime_heartbeat_policy.py | 22 ++++++++++++++++++++++ uv.lock | 6 +++--- 5 files changed, 41 insertions(+), 8 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index 229a6d9..3132843 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -18,7 +18,7 @@ dependencies = [ "pytest", "pytz", "requests", - "quant-platform-kit @ git+https://github.com/QuantStrategyLab/QuantPlatformKit.git@3b74a445b370745fcb7bc380b4f37e9bf2f7cf56", + "quant-platform-kit @ git+https://github.com/QuantStrategyLab/QuantPlatformKit.git@66cbce0d89d15e4c372b690363c24ea350cc9314", "us-equity-strategies @ git+https://github.com/QuantStrategyLab/UsEquityStrategies.git@271358eea934f731d8f92b1b4ca8e596425ca364", ] license = "MIT" @@ -82,5 +82,5 @@ show_missing = true [tool.uv] override-dependencies = [ - "quant-platform-kit @ git+https://github.com/QuantStrategyLab/QuantPlatformKit.git@3b74a445b370745fcb7bc380b4f37e9bf2f7cf56", + "quant-platform-kit @ git+https://github.com/QuantStrategyLab/QuantPlatformKit.git@66cbce0d89d15e4c372b690363c24ea350cc9314", ] diff --git a/qsl.toml b/qsl.toml index 8cd55c3..702bb67 100644 --- a/qsl.toml +++ b/qsl.toml @@ -5,7 +5,7 @@ upgrade_ring = "ring_d" allow_legacy = false [qsl.requires] -quant_platform_kit = "3b74a445b370745fcb7bc380b4f37e9bf2f7cf56" +quant_platform_kit = "66cbce0d89d15e4c372b690363c24ea350cc9314" us_equity_strategies = "271358eea934f731d8f92b1b4ca8e596425ca364" [qsl.compat] diff --git a/scripts/runtime_heartbeat_policy.py b/scripts/runtime_heartbeat_policy.py index 4baf3cb..d2c1703 100644 --- a/scripts/runtime_heartbeat_policy.py +++ b/scripts/runtime_heartbeat_policy.py @@ -49,6 +49,14 @@ def _enabled(value: Any, *, default: bool = True) -> bool: return str(value).strip().lower() not in {"0", "false", "no", "n", "off"} +def runtime_target_permits_standard_execution(runtime_target: Mapping[str, Any]) -> bool: + """Return whether the generic execution heartbeat should require a receipt.""" + + continuity = _mapping(runtime_target.get("live_continuity")) + state = str(continuity.get("state") or "").strip().upper() + return not state or state in {"ACTIVE_LKG", "ROLLBACK_LKG"} + + def _mapping(value: Any) -> Mapping[str, Any]: return value if isinstance(value, Mapping) else {} @@ -317,7 +325,7 @@ def runtime_target_configuration_has_enabled_targets( ) if enabled_value is None: enabled_value = runtime_target.get("runtime_target_enabled") - if _enabled(enabled_value): + if _enabled(enabled_value) and runtime_target_permits_standard_execution(runtime_target): return True return False @@ -342,7 +350,10 @@ def load_runtime_targets( ) if enabled_value is None: enabled_value = runtime_target.get("runtime_target_enabled") - enabled = _enabled(enabled_value) + enabled = ( + _enabled(enabled_value) + and runtime_target_permits_standard_execution(runtime_target) + ) if not enabled and not include_disabled: continue target_scope = _first_value( diff --git a/tests/test_runtime_heartbeat_policy.py b/tests/test_runtime_heartbeat_policy.py index 6e14a88..1e93239 100644 --- a/tests/test_runtime_heartbeat_policy.py +++ b/tests/test_runtime_heartbeat_policy.py @@ -408,6 +408,28 @@ def test_target_defaults_and_scheduler_aliases_are_normalized() -> None: } +def test_reconcile_only_target_is_not_an_execution_heartbeat_target() -> None: + environ = { + "CLOUD_RUN_SERVICE_TARGETS_JSON": json.dumps( + { + "targets": [ + { + "service": "reconcile-only-service", + "runtime_target": { + "service_name": "reconcile-only-service", + "strategy_profile": "strategy-a", + "live_continuity": {"state": "RECONCILE_ONLY"}, + }, + } + ] + } + ) + } + + assert load_runtime_targets(environ) == [] + assert runtime_target_configuration_present(environ) is True + + def test_strategy_profile_resolver_canonicalizes_aliases() -> None: targets = load_runtime_targets( { diff --git a/uv.lock b/uv.lock index 991aa7d..2e3db5e 100644 --- a/uv.lock +++ b/uv.lock @@ -17,7 +17,7 @@ resolution-markers = [ ] [manifest] -overrides = [{ name = "quant-platform-kit", git = "https://github.com/QuantStrategyLab/QuantPlatformKit.git?rev=3b74a445b370745fcb7bc380b4f37e9bf2f7cf56" }] +overrides = [{ name = "quant-platform-kit", git = "https://github.com/QuantStrategyLab/QuantPlatformKit.git?rev=66cbce0d89d15e4c372b690363c24ea350cc9314" }] [[package]] name = "blinker" @@ -446,7 +446,7 @@ requires-dist = [ { name = "pytest", marker = "extra == 'test'" }, { name = "pytest-cov", marker = "extra == 'test'" }, { name = "pytz" }, - { name = "quant-platform-kit", git = "https://github.com/QuantStrategyLab/QuantPlatformKit.git?rev=3b74a445b370745fcb7bc380b4f37e9bf2f7cf56" }, + { name = "quant-platform-kit", git = "https://github.com/QuantStrategyLab/QuantPlatformKit.git?rev=66cbce0d89d15e4c372b690363c24ea350cc9314" }, { name = "requests" }, { name = "ruff", marker = "extra == 'test'" }, { name = "us-equity-strategies", git = "https://github.com/QuantStrategyLab/UsEquityStrategies.git?rev=271358eea934f731d8f92b1b4ca8e596425ca364" }, @@ -1102,7 +1102,7 @@ wheels = [ [[package]] name = "quant-platform-kit" version = "0.10.0" -source = { git = "https://github.com/QuantStrategyLab/QuantPlatformKit.git?rev=3b74a445b370745fcb7bc380b4f37e9bf2f7cf56#3b74a445b370745fcb7bc380b4f37e9bf2f7cf56" } +source = { git = "https://github.com/QuantStrategyLab/QuantPlatformKit.git?rev=66cbce0d89d15e4c372b690363c24ea350cc9314#66cbce0d89d15e4c372b690363c24ea350cc9314" } [[package]] name = "requests"