From 1cc3aff2f3012d72f84008170a25dc7b21a556a2 Mon Sep 17 00:00:00 2001 From: saagpatel Date: Sat, 20 Jun 2026 00:21:10 -0700 Subject: [PATCH] fix(operator-trend): use any() for rererestore freshness signal flag (T3-2 phase 5b) The rererestore freshness builder computed `has_fresh_aligned_recent_evidence` as `freshness_status == "fresh" and aligned_recent_event_count >= 2` -- a count threshold plus a global-freshness gate. Every one of its sibling freshness builders (reset_reentry, reset_reentry_rebuild, reacquisition, rebuild_reentry, rebuild_reentry_restore, rebuild_reentry_restore_rerestore) uses an `any(...)` existential over the first two recent events instead. rererestore was the lone outlier, and the flag is load-bearing (gates churn_status / persistence decisions across 49 read sites). Convert it to the sibling `any(...)` form over rererestore's own aligned predicate and drop the now-dead aligned_recent_event_count sum(). The flag now fires on any recent aligned event like its siblings (previously required both of the first two AND overall freshness == "fresh"). Caught and pinned by the phase-4 composer golden: a 3-line diff (the flag flips false -> true in 3 scenarios). No existing test pinned the old value -- the path was uncharacterized, which is why the drift survived. Full suite 2539 passed, ruff + mypy clean. --- ...r_trend_closure_forecast_reset_controls.py | 22 ++++++------------- tests/golden/composer_contract.golden.json | 6 ++--- 2 files changed, 10 insertions(+), 18 deletions(-) diff --git a/src/operator_trend_closure_forecast_reset_controls.py b/src/operator_trend_closure_forecast_reset_controls.py index d4dd7c7..7ed10b0 100644 --- a/src/operator_trend_closure_forecast_reset_controls.py +++ b/src/operator_trend_closure_forecast_reset_controls.py @@ -4671,19 +4671,6 @@ def closure_forecast_reset_reentry_rebuild_reentry_restore_rererestore_freshness weighted_rererestore_evidence_count, 1.0, ) - aligned_recent_event_count = sum( - 1 - for event in relevant_events[ - :class_reset_reentry_rebuild_reentry_restore_rererestore_freshness_window_runs - ][:2] - if ( - closure_forecast_reset_reentry_rebuild_reentry_restore_rererestore_side_from_event( - event - ) - == current_side - and current_side != "none" - ) - ) return { "closure_forecast_reset_reentry_rebuild_reentry_restore_rererestore_freshness_status": freshness_status, "closure_forecast_reset_reentry_rebuild_reentry_restore_rererestore_freshness_reason": _rererestore_freshness_reason( @@ -4714,8 +4701,13 @@ def closure_forecast_reset_reentry_rebuild_reentry_restore_rererestore_freshness weighted_clearance_like, recent_window_weight_share, ), - "has_fresh_aligned_recent_evidence": ( - freshness_status == "fresh" and aligned_recent_event_count >= 2 + "has_fresh_aligned_recent_evidence": any( + closure_forecast_reset_reentry_rebuild_reentry_restore_rererestore_side_from_event( + event + ) + == current_side + and current_side != "none" + for event in relevant_events[:2] ), } diff --git a/tests/golden/composer_contract.golden.json b/tests/golden/composer_contract.golden.json index 4c6c298..0772bbe 100644 --- a/tests/golden/composer_contract.golden.json +++ b/tests/golden/composer_contract.golden.json @@ -723,7 +723,7 @@ "closure_forecast_reset_reentry_rebuild_reentry_restore_rererestore_memory_weight": 1.0, "decayed_rererestored_rebuild_reentry_clearance_rate": 0.0, "decayed_rererestored_rebuild_reentry_confirmation_rate": 1.0, - "has_fresh_aligned_recent_evidence": false, + "has_fresh_aligned_recent_evidence": true, "recent_reset_reentry_rebuild_reentry_restore_rererestore_signal_mix": "1.00 weighted re-re-restored run(s) with 1.00 confirmation-like, 0.00 clearance-like, and 100% of the signal from the freshest runs." }, "clearance-hold": { @@ -759,7 +759,7 @@ "closure_forecast_reset_reentry_rebuild_reentry_restore_rererestore_memory_weight": 1.0, "decayed_rererestored_rebuild_reentry_clearance_rate": 0.0, "decayed_rererestored_rebuild_reentry_confirmation_rate": 1.0, - "has_fresh_aligned_recent_evidence": false, + "has_fresh_aligned_recent_evidence": true, "recent_reset_reentry_rebuild_reentry_restore_rererestore_signal_mix": "1.00 weighted re-re-restored run(s) with 1.00 confirmation-like, 0.00 clearance-like, and 100% of the signal from the freshest runs." }, "sparse": { @@ -768,7 +768,7 @@ "closure_forecast_reset_reentry_rebuild_reentry_restore_rererestore_memory_weight": 1.0, "decayed_rererestored_rebuild_reentry_clearance_rate": 0.0, "decayed_rererestored_rebuild_reentry_confirmation_rate": 1.0, - "has_fresh_aligned_recent_evidence": false, + "has_fresh_aligned_recent_evidence": true, "recent_reset_reentry_rebuild_reentry_restore_rererestore_signal_mix": "1.00 weighted re-re-restored run(s) with 1.00 confirmation-like, 0.00 clearance-like, and 100% of the signal from the freshest runs." }, "sustained-confirmation": {