From 44fa248898d0606505eb099f036166764878930e Mon Sep 17 00:00:00 2001 From: eowca <4008965+eowca@users.noreply.github.com> Date: Thu, 26 Nov 2026 04:18:49 +0100 Subject: [PATCH 1/2] Bound Mergify candidate conditions in timeout output Architecture-Review: unchanged; the timeout diagnostic keeps the same queue state, candidate link and verdict. Co-Authored-By: Codex --- src/loopzero/cli.py | 7 ++++++- tests/test_cli.py | 26 +++++++++++++------------- 2 files changed, 19 insertions(+), 14 deletions(-) diff --git a/src/loopzero/cli.py b/src/loopzero/cli.py index 48a64159..dbc55661 100644 --- a/src/loopzero/cli.py +++ b/src/loopzero/cli.py @@ -1442,7 +1442,12 @@ def _mergify_timeout_detail( ) detail = f"still queued in {queue}. {location}" if state.unmet_conditions: - detail += ". Unmet candidate conditions: " + "; ".join(state.unmet_conditions) + labels = [label.encode() for label in state.unmet_conditions[:4]] + shown = [label[:160].decode(errors="ignore") + ("…" if len(label) > 160 else "") + for label in labels] + detail += ". Unmet candidate conditions: " + "; ".join(shown) + if omitted := len(state.unmet_conditions) - len(shown): + detail += f"; {omitted} more" return detail diff --git a/tests/test_cli.py b/tests/test_cli.py index c09d043c..4a6725b5 100644 --- a/tests/test_cli.py +++ b/tests/test_cli.py @@ -4583,23 +4583,23 @@ def test_mergify_reports_current_queue_attempt(wt, gh, capsys, monkeypatch, conf assert (f"{URL}#issuecomment-43" in out) is (kind == "current") -@pytest.mark.parametrize("result", ["blocking", "neutral", "skipped", None]) -def test_mergify_timeout_reports_evaluated_candidate_conditions(wt, gh, capsys, monkeypatch, result): +@pytest.mark.parametrize(("result", "extra"), [("blocking", 0), ("neutral", 0), ("skipped", 0), (None, 0), ("blocking", 1), ("blocking", 30)]) +def test_mergify_timeout_reports_evaluated_candidate_conditions(wt, gh, capsys, monkeypatch, result, extra): commit_mergify_configuration(wt) - head = head_of(wt) - arm_approved_ready_pr(gh, head, wt, isDraft=False) + arm_approved_ready_pr(gh, head_of(wt), wt, isDraft=False) monkeypatch.setattr(mergify, "configured", lambda *_: True) - monkeypatch.setattr(mergify, "markers", lambda *_: (True, False)) - monkeypatch.setattr(mergify, "mark_confirmed", lambda *_: None) - responses = iter([None, MERGIFY_QUEUE_FIXTURE["candidate_responses"][result or "missing"]]) - monkeypatch.setattr(mergify, "api_get", lambda *_: next(responses)) - + monkeypatch.setattr(mergify, "markers", lambda *_: (True, True)) + payload = MERGIFY_QUEUE_FIXTURE["candidate_responses"][result or "missing"] + if extra: + conditions = payload["mergeability_check"]["conditions_evaluation"] + label = {"match": False, "label": "界" * 3000} + monkeypatch.setitem(conditions, "subconditions", conditions["subconditions"] + [label] * extra) + monkeypatch.setattr(mergify, "api_get", lambda *_: payload) code, out, err = run(capsys, "merge", "--wait=0") - - assert (code, err) == (3, "") - assert f"https://github.com/{REPO}/pull/42" in out - assert (MERGIFY_QUEUE_FIXTURE["candidate_condition"] in out) is (result == "blocking") + assert (code, err) == (3, "") and f"https://github.com/{REPO}/pull/42" in out + assert (MERGIFY_QUEUE_FIXTURE["candidate_condition"] in out) == (result == "blocking") assert "failed" not in out and "check-success = checks" not in out + assert len(out.encode()) < 2048 and ("27 more" in out) == (extra == 30) @pytest.mark.parametrize("queue_state", ["unsafe", "error", "safe", "becomes_unsafe"]) From b36d5a7c71802ff4ab375bfaf23227a77ac0185d Mon Sep 17 00:00:00 2001 From: eowca <4008965+eowca@users.noreply.github.com> Date: Thu, 26 Nov 2026 04:37:34 +0100 Subject: [PATCH 2/2] Keep the existing Mergify fixture setup mergeable Co-Authored-By: Codex --- tests/test_cli.py | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/tests/test_cli.py b/tests/test_cli.py index 4a6725b5..7256c245 100644 --- a/tests/test_cli.py +++ b/tests/test_cli.py @@ -4583,21 +4583,21 @@ def test_mergify_reports_current_queue_attempt(wt, gh, capsys, monkeypatch, conf assert (f"{URL}#issuecomment-43" in out) is (kind == "current") -@pytest.mark.parametrize(("result", "extra"), [("blocking", 0), ("neutral", 0), ("skipped", 0), (None, 0), ("blocking", 1), ("blocking", 30)]) -def test_mergify_timeout_reports_evaluated_candidate_conditions(wt, gh, capsys, monkeypatch, result, extra): +@pytest.mark.parametrize("result", ["blocking", "neutral", "skipped", None, "long", "many"]) +def test_mergify_timeout_reports_evaluated_candidate_conditions(wt, gh, capsys, monkeypatch, result): commit_mergify_configuration(wt) - arm_approved_ready_pr(gh, head_of(wt), wt, isDraft=False) + head = head_of(wt) + arm_approved_ready_pr(gh, head, wt, isDraft=False) monkeypatch.setattr(mergify, "configured", lambda *_: True) monkeypatch.setattr(mergify, "markers", lambda *_: (True, True)) - payload = MERGIFY_QUEUE_FIXTURE["candidate_responses"][result or "missing"] - if extra: + payload = MERGIFY_QUEUE_FIXTURE["candidate_responses"]["blocking" if result in {"long", "many"} else result or "missing"] + if extra := {"long": 1, "many": 30}.get(result, 0): conditions = payload["mergeability_check"]["conditions_evaluation"] - label = {"match": False, "label": "界" * 3000} - monkeypatch.setitem(conditions, "subconditions", conditions["subconditions"] + [label] * extra) + monkeypatch.setitem(conditions, "subconditions", conditions["subconditions"] + [{"match": False, "label": "界" * 3000}] * extra) monkeypatch.setattr(mergify, "api_get", lambda *_: payload) code, out, err = run(capsys, "merge", "--wait=0") assert (code, err) == (3, "") and f"https://github.com/{REPO}/pull/42" in out - assert (MERGIFY_QUEUE_FIXTURE["candidate_condition"] in out) == (result == "blocking") + assert (MERGIFY_QUEUE_FIXTURE["candidate_condition"] in out) == (result in {"blocking", "long", "many"}) assert "failed" not in out and "check-success = checks" not in out assert len(out.encode()) < 2048 and ("27 more" in out) == (extra == 30)