From f19d224dd07a6e207c79c5b6f90b51b3f6efac68 Mon Sep 17 00:00:00 2001 From: Kevin Veen-Birkenbach Date: Wed, 2 Sep 2026 02:07:41 +0200 Subject: [PATCH] fix(ci-trigger): never resume at a row the priority line takes A retrigger by role hands the priority line a bare role name so the rotation can pick fresh axes, and the matrix then drops that role from the regular query entirely. The resume offset was computed against a ranking discovered without the priority line, so it could name one of exactly those rows, and the run it was handed to had already guaranteed the row would not be there. Chunk 0 of sweep 77 died on it before deploying anything: offset 'web-app-nextcloud#11' names no row of the regular line and with it every other chunk of the run. The priority line of that run promoted 27 roles whole, nextcloud among them; its regular line held no nextcloud row at all. Give resume_offset the priority pins and let it skip what they claim, by the same two rules the matrix applies: a variant-less pin takes its whole role, a pinned one takes those variants. The walk continues past a claimed row rather than stopping, so a promoted role in the middle of the green window does not truncate the resume point, and a window that is claimed end to end yields no offset and starts at the head. The ranking itself still discovers without the priority line, so an unresolvable token there still cannot abort the helper. Co-Authored-By: Claude Opus 5 (1M context) --- cli/administration/deploy/ci/selections.py | 28 +++++++++-- .../deploy/ci/trigger/__main__.py | 6 ++- .../deploy/ci/test_selections.py | 50 +++++++++++++++++++ 3 files changed, 78 insertions(+), 6 deletions(-) diff --git a/cli/administration/deploy/ci/selections.py b/cli/administration/deploy/ci/selections.py index aeef2dbe18..31099f129a 100644 --- a/cli/administration/deploy/ci/selections.py +++ b/cli/administration/deploy/ci/selections.py @@ -208,7 +208,11 @@ def unrun_selections(regular: list[dict[str, str]], deployed: set[str]) -> list[ ) -def resume_offset(regular: list[dict[str, str]], passed: set[str]) -> str: +def resume_offset( + regular: list[dict[str, str]], + passed: set[str], + leading: Iterable[selection.Pin] = (), +) -> str: """Where a retrigger should pick the regular line up again. The source run deployed a window of the ranking and stopped at its budget. @@ -222,16 +226,26 @@ def resume_offset(regular: list[dict[str, str]], passed: set[str]) -> str: resuming past it would drop every other combination of that row and everything the run never reached behind it. + A row the priority line claims is never the answer. ``regular`` is + discovered without the priority line (see the retrigger's ``_ranking``), so + it still holds rows the run will hand to that line instead + (:func:`cli.meta.ci.matrix.candidates`): a variant-less pin takes its whole + role, a pinned one takes those variants. Naming such a row would emit an + offset that resolves against nothing once the run applies the priority + line, and abort the discovery of every chunk. + Args: regular: the regular line of the retrigger's own discovery, in ranking order. passed: tokens the source run deployed green (:func:`passed_selections`). + leading: the retrigger's priority pins, whose rows leave the regular + line. Returns: the ``role#variant`` token to resume at, or ``''`` when the source run - got nothing of this line green -- then the retrigger starts at the - head, as it would without an offset. + got nothing skippable of this line green -- then the retrigger starts + at the head, as it would without an offset. The returned token names a place in the ranking, so it carries no axes. Membership is still tested on the full deploy token, because that is @@ -241,6 +255,9 @@ def resume_offset(regular: list[dict[str, str]], passed: set[str]) -> str: reproduce the source run's combination, and abort the discovery of every chunk in all the others. """ + pins = tuple(leading) + claimed_apps = {pin.app for pin in pins if not pin.variants} + claimed_rows = {(pin.app, variant) for pin in pins for variant in pin.variants} resume = "" for entry in regular: if row_selection(entry) not in passed: @@ -248,5 +265,8 @@ def resume_offset(regular: list[dict[str, str]], passed: set[str]) -> str: variants = tuple( int(part) for part in str(entry.get("variant", "")).split(",") if part ) - resume = selection.describe(selection.Pin(entry["apps"], variants)) + app = entry["apps"] + if app in claimed_apps or any((app, v) in claimed_rows for v in variants): + continue + resume = selection.describe(selection.Pin(app, variants)) return resume diff --git a/cli/administration/deploy/ci/trigger/__main__.py b/cli/administration/deploy/ci/trigger/__main__.py index a27451d4da..bf81b0ff6c 100644 --- a/cli/administration/deploy/ci/trigger/__main__.py +++ b/cli/administration/deploy/ci/trigger/__main__.py @@ -18,7 +18,7 @@ import sys from cli.administration.deploy.ci import gh, runs, selections from cli.meta.ci import matrix, query -from utils.github.variant import pools, tor +from utils.github.variant import pools, selection, tor _WORKFLOW = "entry-manual-steer.yml" _ALL = "__ALL__" @@ -211,7 +211,9 @@ def main(argv: list[str] | None = None) -> int: return 0 priority = " ".join(sorted(priority_entries)) config["offset"] = selections.resume_offset( - ranking, selections.passed_selections(source["jobs"]) + ranking, + selections.passed_selections(source["jobs"]), + selection.parse_list(priority), ) if config["offset"]: print(f"Regular line resumes at: {config['offset']}") diff --git a/tests/unit/python/cli/administration/deploy/ci/test_selections.py b/tests/unit/python/cli/administration/deploy/ci/test_selections.py index 3cb7e41013..235edd651c 100644 --- a/tests/unit/python/cli/administration/deploy/ci/test_selections.py +++ b/tests/unit/python/cli/administration/deploy/ci/test_selections.py @@ -84,6 +84,56 @@ class TestResumeOffset(unittest.TestCase): } self.assertEqual(selections.resume_offset(self._REGULAR, passed), "web-app-c#0") + _ALL_PASSED: ClassVar[set[str]] = { + "web-app-a#0@compose+clearnet" + _AXES, + "web-app-b#1@swarm+tor" + _AXES, + "web-app-c#0@host+clearnet" + _AXES, + } + + def test_a_role_the_priority_line_takes_whole_is_never_the_offset(self) -> None: + """A variant-less pin blacklists its whole role from the regular query, + so an offset naming one of its rows resolves against nothing.""" + self.assertEqual( + selections.resume_offset( + self._REGULAR, self._ALL_PASSED, selection.parse_list("web-app-c") + ), + "web-app-b#1", + ) + + def test_a_variant_the_priority_line_pins_is_never_the_offset(self) -> None: + self.assertEqual( + selections.resume_offset( + self._REGULAR, self._ALL_PASSED, selection.parse_list("web-app-c#0") + ), + "web-app-b#1", + ) + + def test_a_pin_on_another_variant_leaves_the_row_offsettable(self) -> None: + self.assertEqual( + selections.resume_offset( + self._REGULAR, self._ALL_PASSED, selection.parse_list("web-app-c#4") + ), + "web-app-c#0", + ) + + def test_a_claimed_row_mid_line_does_not_stop_the_scan(self) -> None: + self.assertEqual( + selections.resume_offset( + self._REGULAR, self._ALL_PASSED, selection.parse_list("web-app-b") + ), + "web-app-c#0", + ) + + def test_every_green_row_claimed_starts_at_the_head(self) -> None: + self.assertEqual( + selections.resume_offset( + self._REGULAR, + self._ALL_PASSED, + selection.parse_list("web-app-a web-app-b web-app-c"), + ), + "", + ) + def test_the_verdict_does_not_matter_only_that_the_row_ran(self) -> None: jobs = [ _job(deploy_job_name("swarm", "web-app-b", "1", tor=True), "failure"),