fix(tui): fingerprint report revisions by history length instead of second-resolution timestamp

This commit is contained in:
Ahmed Allam
2026-09-09 14:43:40 +00:00
parent 725516b474
commit 774c888ca8
2 changed files with 23 additions and 6 deletions

View File

@@ -49,6 +49,11 @@ if TYPE_CHECKING:
logger = logging.getLogger(__name__)
def _revision_count(report: dict[str, Any]) -> int:
history = report.get("update_history")
return len(history) if isinstance(history, list) else 0
class GoTuiPreActivationError(RuntimeError):
"""A sidecar failure raised before the Go TUI activates."""
@@ -339,7 +344,7 @@ class GoTuiRuntime:
if self.report_state is not None:
usage = dict(self.report_state.get_total_llm_usage())
vulnerabilities = [
(report.get("id", index), report.get("updated_at"))
(report.get("id", index), _revision_count(report))
if isinstance(report, dict)
else index
for index, report in enumerate(self.report_state.vulnerability_reports)

View File

@@ -1036,9 +1036,21 @@ def test_sync_fingerprint_tracks_report_revisions(tmp_path: Path) -> None:
runtime.report_state.vulnerability_reports = [{"id": "vuln-0001", "title": "Old title"}]
runtime.report_state.get_run_dir = lambda: tmp_path # type: ignore[method-assign]
before = runtime._runtime_sync_fingerprint()
runtime.report_state.vulnerability_reports[0].update(
{"title": "New title", "updated_at": "2026-09-09T10:00:00+00:00"}
)
report = runtime.report_state.vulnerability_reports[0]
timestamp = "2026-09-09 10:00:00 UTC"
assert runtime._runtime_sync_fingerprint() != before
before = runtime._runtime_sync_fingerprint()
report.update(
{
"title": "New title",
"updated_at": timestamp,
"update_history": [{"timestamp": timestamp, "fields": ["title"]}],
}
)
first_revision = runtime._runtime_sync_fingerprint()
assert first_revision != before
report["title"] = "Newer title"
report["update_history"].append({"timestamp": timestamp, "fields": ["title"]})
assert runtime._runtime_sync_fingerprint() != first_revision