diff --git a/monitor.py b/monitor.py index e240f40..9e9324b 100644 --- a/monitor.py +++ b/monitor.py @@ -10330,6 +10330,8 @@ class MessageMonitor: if freshness_score != -999.0: _ts_positions.append((idx, freshness_score)) + # ⭐ 记录通过继承获得新鲜度的消息(防止误判为"自身时间戳") + _inherited_fresh_set = set() # 第二遍:为无时间戳的消息分配最近时间戳的新鲜度 for idx, item in enumerate(texts): # 解包元组 (text, timestamp) @@ -10378,6 +10380,8 @@ class MessageMonitor: f"(pos {idx} <- ts pos {_actual_pos}): " f"{best_freshness:.1f}: {ts[:20]!r}") freshness_scores[ts] = best_freshness + # ⭐ 记录此消息通过继承获得新鲜度,第一关需排除 + _inherited_fresh_set.add(ts) # else: 整批无时间戳,保持-999.0 # === 所有消息都必须经过过滤器(不再跳过) === @@ -11102,11 +11106,16 @@ class MessageMonitor: # 第一关:有5分钟内新鲜时间戳(自身时间戳,不是继承的) # 第二关:没有新鲜时间戳 → 查库 _is_inherited_ts = isinstance(item, tuple) and len(item) == 2 and item[1] is not None + # ⭐ Task #1738: 额外检查是否通过第二遍继承获得新鲜度 + _is_inherited_fresh = cleaned_item in _inherited_fresh_set if _inherited_fresh_set else False + if _is_inherited_fresh: + logger.debug(f"[{platform}] 消息通过继承获得新鲜度,第一关不通过: {cleaned_item[:50]!r}") + # 第一关:检查是否有5分钟内的新鲜时间戳(自身时间戳) # freshness_score >= 5 表示时间戳在5分钟内 # 但必须是自身时间戳,不是继承的 - _has_fresh_own_ts = (freshness_score >= 5) and not _is_inherited_ts + _has_fresh_own_ts = (freshness_score >= 5) and not _is_inherited_ts and not _is_inherited_fresh if _has_fresh_own_ts: # 第一关通过:有5分钟内新鲜时间戳(自身时间戳) old_score = score