Skip to content

~95% on SimpleQA (e.g. Qwen3.6-27B on a 3090). Supports all local and cloud LLMs (llama.cpp, Ollama, Google, ...). 10+ search engines - arXiv, PubMed, your private documents. Everything Local & Encrypted.

fix(ci): accept terminal states in release alert history (#8196)

LearningCircuit473c704fd097
diff --git a/.github/scripts/check_code_scanning_alerts.py b/.github/scripts/check_code_scanning_alerts.py
index c4ea75dbea..b17670b3b0 100644
--- a/.github/scripts/check_code_scanning_alerts.py
+++ b/.github/scripts/check_code_scanning_alerts.py
@@ -136,7 +136,14 @@ def fetch_alerts(
timeout=60,
)
batch = json.loads(result.stdout)
- validate_alerts(batch, (state,))
+ # Fixed and dismissed queries form one historical union. API pages
+ # may contain either terminal state; open queries must remain strict.
+ states = (
+ ("fixed", "dismissed")
+ if state in {"fixed", "dismissed"}
+ else (state,)
+ )
+ validate_alerts(batch, states)
if not batch:
return alerts
alerts.extend(batch)
diff --git a/tests/ci/test_release_security_exceptions.py b/tests/ci/test_release_security_exceptions.py
index 1c95624920..cecde45bfa 100644
--- a/tests/ci/test_release_security_exceptions.py
+++ b/tests/ci/test_release_security_exceptions.py
@@ -9,6 +9,7 @@ import json
from pathlib import Path
import subprocess
import sys
+from urllib.parse import parse_qs, urlsplit
import pytest
import yaml
@@ -264,6 +265,48 @@ def test_all_pages_are_fetched_before_deciding(monkeypatch, alert, exceptions):
assert excepted == [alert]
[email protected]("state", ["fixed", "dismissed"])
+def test_history_accepts_both_terminal_states_on_every_page(
+ monkeypatch, alert, state
+):
+ fixed = {**deepcopy(alert), "state": "fixed"}
+ dismissed = {**deepcopy(alert), "number": 9008, "state": "dismissed"}
+ # A page with only the other terminal state must not end pagination.
+ pages = [dismissed, fixed] if state == "fixed" else [fixed, dismissed]
+ original = deepcopy(pages)
+ calls = _mock_pages(monkeypatch, [[pages[0]], [pages[1]], []])
+ result = gate.fetch_alerts(
+ REPOSITORY, state, ref="refs/heads/main", tool_name="Sample scanner"
+ )
+ assert result == pages == original
+ assert len(calls) == 3
+ for args in calls:
+ query = parse_qs(urlsplit(args[-1]).query)
+ assert query["state"] == [state]
+ assert query["ref"] == ["refs/heads/main"]
+ assert query["tool_name"] == ["Sample scanner"]
+
+
[email protected]("state", ["fixed", "dismissed"])
[email protected]("returned", ["open", "unknown", "closed", None])
+def test_history_rejects_nonterminal_or_unrecognized_records(
+ monkeypatch, alert, state, returned
+):
+ malformed = {**deepcopy(alert), "state": returned}
+ _mock_pages(monkeypatch, [[malformed]])
+ with pytest.raises(ValueError, match="Malformed"):
+ gate.fetch_alerts(REPOSITORY, state)
+
+
[email protected]("state", ["fixed", "dismissed"])
+def test_open_query_still_rejects_every_terminal_state(
+ monkeypatch, alert, state
+):
+ _mock_pages(monkeypatch, [[{**deepcopy(alert), "state": state}]])
+ with pytest.raises(ValueError, match="Malformed"):
+ gate.fetch_alerts(REPOSITORY)
+
+
@pytest.fixture
def cli(monkeypatch, tmp_path, policy):
class FrozenDateTime(datetime):
@@ -295,6 +338,51 @@ def cli(monkeypatch, tmp_path, policy):
return summary, output
[email protected]("historical_state", ["fixed", "dismissed"])
[email protected]("age_days,expected_exit", [(20, 1), (3, 0)])
+def test_cli_retains_original_age_across_terminal_history_states(
+ monkeypatch, cli, alert, historical_state, age_days, expected_exit
+):
+ current = {
+ **deepcopy(alert),
+ "number": 9008,
+ "created_at": "2026-09-26T00:00:00Z",
+ }
+ old = {
+ **deepcopy(current),
+ "number": 9009,
+ "state": historical_state,
+ "created_at": f"2026-09-{27 - age_days:02}T00:00:00Z",
+ }
+ opposite_query = "fixed" if historical_state == "dismissed" else "dismissed"
+ calls = []
+
+ def run(args, **kwargs):
+ assert args[:4] == ["gh", "api", "--method", "GET"]
+ assert kwargs["check"] is True
+ query = parse_qs(urlsplit(args[-1]).query)
+ state = query["state"][0]
+ calls.append((state, query["page"][0]))
+ rows = []
+ if query["page"] == ["1"]:
+ if state == "open":
+ rows = [current]
+ elif state == opposite_query:
+ rows = [old]
+ return subprocess.CompletedProcess(args, 0, stdout=json.dumps(rows))
+
+ monkeypatch.setattr(gate.subprocess, "run", run)
+ assert gate.main() == expected_exit
+ assert ("fixed", "1") in calls and ("dismissed", "1") in calls
+ if expected_exit:
+ assert not cli[1].exists()
+ assert "Release blocked: 1 alert(s)." in cli[0].read_text()
+ else:
+ assert "release_deadline=2026-10-08T00:00:00Z" in cli[1].read_text()
+ assert current["state"] == "open"
+ assert old["state"] == historical_state
+
+
def test_cli_reports_exception_without_claiming_no_alerts(
monkeypatch, cli, alert, capsys
):