Skip to content

Commit 3a51d4e

Browse files
authored
fix(operator-trend): use any() for rererestore freshness signal flag (T3-2 phase 5b) (#81)
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.
1 parent f3d4aaf commit 3a51d4e

2 files changed

Lines changed: 10 additions & 18 deletions

File tree

src/operator_trend_closure_forecast_reset_controls.py

Lines changed: 7 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -4671,19 +4671,6 @@ def closure_forecast_reset_reentry_rebuild_reentry_restore_rererestore_freshness
46714671
weighted_rererestore_evidence_count,
46724672
1.0,
46734673
)
4674-
aligned_recent_event_count = sum(
4675-
1
4676-
for event in relevant_events[
4677-
:class_reset_reentry_rebuild_reentry_restore_rererestore_freshness_window_runs
4678-
][:2]
4679-
if (
4680-
closure_forecast_reset_reentry_rebuild_reentry_restore_rererestore_side_from_event(
4681-
event
4682-
)
4683-
== current_side
4684-
and current_side != "none"
4685-
)
4686-
)
46874674
return {
46884675
"closure_forecast_reset_reentry_rebuild_reentry_restore_rererestore_freshness_status": freshness_status,
46894676
"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
47144701
weighted_clearance_like,
47154702
recent_window_weight_share,
47164703
),
4717-
"has_fresh_aligned_recent_evidence": (
4718-
freshness_status == "fresh" and aligned_recent_event_count >= 2
4704+
"has_fresh_aligned_recent_evidence": any(
4705+
closure_forecast_reset_reentry_rebuild_reentry_restore_rererestore_side_from_event(
4706+
event
4707+
)
4708+
== current_side
4709+
and current_side != "none"
4710+
for event in relevant_events[:2]
47194711
),
47204712
}
47214713

tests/golden/composer_contract.golden.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -723,7 +723,7 @@
723723
"closure_forecast_reset_reentry_rebuild_reentry_restore_rererestore_memory_weight": 1.0,
724724
"decayed_rererestored_rebuild_reentry_clearance_rate": 0.0,
725725
"decayed_rererestored_rebuild_reentry_confirmation_rate": 1.0,
726-
"has_fresh_aligned_recent_evidence": false,
726+
"has_fresh_aligned_recent_evidence": true,
727727
"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."
728728
},
729729
"clearance-hold": {
@@ -759,7 +759,7 @@
759759
"closure_forecast_reset_reentry_rebuild_reentry_restore_rererestore_memory_weight": 1.0,
760760
"decayed_rererestored_rebuild_reentry_clearance_rate": 0.0,
761761
"decayed_rererestored_rebuild_reentry_confirmation_rate": 1.0,
762-
"has_fresh_aligned_recent_evidence": false,
762+
"has_fresh_aligned_recent_evidence": true,
763763
"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."
764764
},
765765
"sparse": {
@@ -768,7 +768,7 @@
768768
"closure_forecast_reset_reentry_rebuild_reentry_restore_rererestore_memory_weight": 1.0,
769769
"decayed_rererestored_rebuild_reentry_clearance_rate": 0.0,
770770
"decayed_rererestored_rebuild_reentry_confirmation_rate": 1.0,
771-
"has_fresh_aligned_recent_evidence": false,
771+
"has_fresh_aligned_recent_evidence": true,
772772
"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."
773773
},
774774
"sustained-confirmation": {

0 commit comments

Comments
 (0)