Skip to content
This repository was archived by the owner on Aug 3, 2026. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions tests/test_recipe_version.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
from validator.github_bot import _version_for


def test_patch_within_active_series():
assert _version_for((0, 3, 5), "0.3") == "recipe-v0.3.6"


def test_cutover_opens_new_minor_line():
assert _version_for((0, 2, 22), "0.3") == "recipe-v0.3.0"


def test_continues_old_series_if_unbumped():
assert _version_for((0, 2, 22), "0.2") == "recipe-v0.2.23"


def test_major_reset():
assert _version_for((0, 9, 4), "1.0") == "recipe-v1.0.0"
23 changes: 19 additions & 4 deletions validator/github_bot.py
Original file line number Diff line number Diff line change
Expand Up @@ -236,11 +236,26 @@ def _latest_recipe_tag(token: str, repo: str = RECIPE_REPO) -> tuple[int, int, i
return best


# Canonical recipe series (MAJOR.MINOR). PATCH auto-increments per king crowning
# within the series; bump this on a measurement/canonical CUTOVER (container_
# measurement changes and miners must rebuild) to open a fresh minor line. v0.2
# ran from #553; v0.3 opens at the --data-base-dir pin cutover (measurement
# 69d0c098...). MAJOR is reserved for a full protocol reset.
_RECIPE_SERIES = "0.3"


def _version_for(latest: tuple[int, int, int], series: str) -> str:
"""Pure policy: PATCH within the active series, .0 when the series advances
(a cutover the owner declared by bumping _RECIPE_SERIES)."""
major, minor, patch = latest
want_major, want_minor = (int(x) for x in series.split("."))
if (major, minor) != (want_major, want_minor):
return f"recipe-v{want_major}.{want_minor}.0"
return f"recipe-v{want_major}.{want_minor}.{patch + 1}"


def _next_recipe_version(token: str, repo: str = RECIPE_REPO) -> str:
major, minor, patch = _latest_recipe_tag(token, repo)
if (major, minor, patch) == (0, 0, 0):
return "recipe-v0.1.0"
return f"recipe-v{major}.{minor}.{patch + 1}"
return _version_for(_latest_recipe_tag(token, repo), _RECIPE_SERIES)


@dataclass
Expand Down
Loading