atlasbot: tighten metric fact matching

This commit is contained in:
Brad Stein 2026-02-04 13:51:12 -03:00
parent 8942b41527
commit 7aca249468

View File

@ -2264,7 +2264,11 @@ def _reply_matches_metric_facts(reply: str, metric_facts: list[str]) -> bool:
reply_numbers = set(re.findall(r"\d+(?:\\.\d+)?", reply))
if not reply_numbers:
return False
fact_numbers = set(re.findall(r"\d+(?:\\.\d+)?", " ".join(metric_facts)))
fact_numbers: set[str] = set()
value_pattern = re.compile(r"(?:>=|<=|=|:)\\s*(\\d+(?:\\.\\d+)?)")
for line in metric_facts:
for match in value_pattern.findall(line):
fact_numbers.add(match)
if not fact_numbers:
return True
return bool(reply_numbers & fact_numbers)