Repository navigation
Description
Summary
record_finding reopens a closed finding whenever its fingerprint appears in the harvested rows. It never checks whether any of those occurrences happened after the issue was closed. On a run that harvests a window reaching back before the close, every finding closed in the meantime is reopened, even though nothing recurred. The reopen comment then reports last seen <run time>, which reads as a fresh occurrence.
What happened
specfuse-loop 0.33.0, specfuse monitor run against RestoManagerApp/Backend (production environment). The monitor had not run since about 2026-11-17. Its first run was at 2026-11-26 14:09Z.
- The run reopened 378 closed
monitoring-findingissues. - For 364 of them, the issue's own regenerated body shows the latest occurrence (
**Seen this run:** N, first X, last Y) before the issue's lastclosedevent:- 335 had been closed on 2026-11-17.
- 29 had been closed earlier on 2026-11-26, a few hours before the run.
- Example: Backend#1344. Body after the run:
Seen this run: 8, first 2026-11-06T23:47:04Z, last 2026-11-06T23:47:09Z. Closed 2026-11-26T14:10:35Z, reopened 2026-11-26T14:24:46Z withRecurred after close: occurrence 3, first seen 2026-11-06T23:47:04Z, last seen 2026-11-26T14:09:21Z.The "last seen" is the run timestamp, and the real last occurrence is 19 days before the close. - Only 14 of the 378 were genuine recurrences, with an occurrence after the close.
- The open finding count went from 72 to 405 in one run, and all 364 had to be closed again by hand.
Where
specfuse/monitor/issues.py, record_finding, the state == "CLOSED" branch (0.33.0):
if str(existing.get("state", "OPEN")).upper() == "CLOSED":
if ids and not unseen:
return number
occurrences = meta.occurrences + 1 if meta is not None else 1
runner(["gh", "issue", "reopen", number, "--repo", repo], check=True)
... f"Recurred after close: occurrence {occurrences}, "
f"first seen {_iso(first_seen)}, last seen {_iso(now)}."- Except for
dlqmessage ids, nothing compares the occurrences inseenwith the issue'sclosedAt.find_finding_issuealready fetchesclosedAt, but only to apply the 90-day lookup window. last_seen=nowis written both into the comment and into thefinding-metamarker, so the run time stands in for the latest occurrence.
Expected
A closed finding is reopened only when at least one harvested occurrence is later than the issue's closedAt. Otherwise it stays closed with no gh write, as a fully covered dlq issue already does.
Suggested fix
- In the closed branch, compute the latest occurrence from
seen(for example_seen_epoch(seen.last)). Compare it with the matched issue'sclosedAtfrom the samegh issue listrow, and return without writing when the occurrence is not later. Whenseencarries no timestamps, keep today's behaviour. - Write the latest occurrence, not
now, into the comment's "last seen" and intofinding-meta last_seen, keeping the harvest time out of it. - Add a regression test: a closed issue whose fingerprint shows up only in rows older than
closedAtstays closed with zeroghcalls, and the same fingerprint with one row newer thanclosedAtreopens it.
Contributing factor
The run harvested rows from 2026-11-06 although the previous run was around 11-17. The window question is separate, but it is what turned a latent bug into a mass reopen. Any run after a gap, or after a watermark is lost, will do the same.
🤖 Generated with Claude Code
Activity