The agent that grows with you
Python aiai-agentai-agentsanthropicchatgptclaudeclaude-codecodexhermeshermes-agentllmnous-researchopenai
fix(pm): pm update pins only BtbN month-end ffmpeg builds
kshitijk4poor7546680ff801
diff --git a/pm/packages.py b/pm/packages.pyindex d352af0e0d5..0938012788a 100644--- a/pm/packages.py+++ b/pm/packages.py@@ -689,7 +689,7 @@ class Ffmpeg(_BionicDebArm, BinaryPackage, DebPackage):it baked into the payload; every `hermes update` and `hermes pm install`re-ensures it from the new lockfile before the venv sync(pm.client.ensure_tools_for_sync), so a pin bump lands. Windows + Linux:- BtbN/FFmpeg-Builds (dated autobuild tag; ships ffprobe too).+ BtbN/FFmpeg-Builds (month-end autobuild tag, kept two years; ships ffprobe too).macOS: ffmpeg.martin-riedl.de (uniform ZIP, published sha256;single-binary — no ffprobe).diff --git a/pm/update.py b/pm/update.pyindex f653b75e8d6..63413160fe9 100644--- a/pm/update.py+++ b/pm/update.py@@ -401,40 +401,60 @@ def martin_riedl_versions(target: str) -> list[str]:return list((martin_riedl_index().get(target) or {}).keys())+_BTBN_TAG = re.compile(r"autobuild-(\d{4})-(\d{2})-\d{2}-\d{2}-\d{2}")++def btbn_index() -> dict[str, dict[str, tuple[str, str]]]:- """Newest static GPL asset per target/version, as (tag, name).+ """Newest retained (month-end) static GPL asset per target/version, as (tag, name).++ BtbN keeps only its 14 newest autobuild tags (about two weeks of+ dailies) plus the last build of each month for two years+ (util/prunetags.sh), so a pin on a daily tag 404s two weeks later. The+ current month's newest tag is still a daily the next build displaces,+ so the newest eligible tag is last month's final build.Releases also contain macOS, shared and LGPL builds. Retain targetidentity here so discovery and pinning select the same artifact."""- out: dict[str, dict[str, tuple[str, str]]] = {}+ releases: list[dict] = []for page in range(1, 4):data = _get_json(f"https://api.github.com/repos/BtbN/FFmpeg-Builds/releases?per_page=30&page={page}")if not data:break- for release in data:- if release.get("draft") or release.get("prerelease"):- continue- tag = release.get("tag_name", "")- if tag == "latest":- continue- for asset in release.get("assets", []):- name = asset.get("name", "")- # Windows ships .zip, Linux .tar.xz. `gpl-shared`/`lgpl` differ- # in the segment after the arch, so requiring "-gpl-<ver>" right- # after it excludes both.- m = re.fullmatch(- r"ffmpeg-n(\d+\.\d+\.\d+)-.+-"- r"(win|linux)(64|arm64)-gpl-\d+\.\d+\.(?:zip|tar\.xz)",- name,- )- if m:- version, osname, arch = m.groups()- os_key = "win32" if osname == "win" else "linux"- target = f"{os_key}-{'x64' if arch == '64' else 'arm64'}"- out.setdefault(target, {}).setdefault(version, (tag, name))+ releases.extend(data)if len(data) < 30:break+ out: dict[str, dict[str, tuple[str, str]]] = {}+ newest_month = None+ months_seen: set[tuple[str, str]] = set()+ for release in sorted(releases, key=lambda r: r.get("tag_name", ""), reverse=True):+ if release.get("draft") or release.get("prerelease"):+ continue+ tag = release.get("tag_name", "")+ dated = _BTBN_TAG.fullmatch(tag)+ if not dated: # `latest` floats+ continue+ month = dated.groups()+ if newest_month is None:+ newest_month = month+ if month == newest_month or month in months_seen:+ continue+ months_seen.add(month)+ for asset in release.get("assets", []):+ name = asset.get("name", "")+ # Windows ships .zip, Linux .tar.xz. `gpl-shared`/`lgpl` differ+ # in the segment after the arch, so requiring "-gpl-<ver>" right+ # after it excludes both.+ m = re.fullmatch(+ r"ffmpeg-n(\d+\.\d+\.\d+)-.+-"+ r"(win|linux)(64|arm64)-gpl-\d+\.\d+\.(?:zip|tar\.xz)",+ name,+ )+ if m:+ version, osname, arch = m.groups()+ os_key = "win32" if osname == "win" else "linux"+ target = f"{os_key}-{'x64' if arch == '64' else 'arm64'}"+ out.setdefault(target, {}).setdefault(version, (tag, name))return outdiff --git a/tests/pm/test_ffmpeg_resolution.py b/tests/pm/test_ffmpeg_resolution.pyindex d18a52d6ec1..14d7b54977e 100644--- a/tests/pm/test_ffmpeg_resolution.py+++ b/tests/pm/test_ffmpeg_resolution.py@@ -10,7 +10,7 @@ from pm.packages import Ffmpeg@pytest.fixturedef indexes(monkeypatch):- tag = "autobuild-2026-09-01-12-00"+ tag = "autobuild-2026-09-30-12-00" # last September build: the only retained tagversion = "9.1.2"assets = [f"ffmpeg-n{version}-1-gabcdef-linux64-gpl-9.1.tar.xz",@@ -22,8 +22,17 @@ def indexes(monkeypatch):f"ffmpeg-n{version}-1-gabcdef-win64-gpl-9.1.zip",f"ffmpeg-n{version}-1-gabcdef-winarm64-gpl-9.1.zip",]++ def release(release_version, tag_date):+ name = f"ffmpeg-n{release_version}-1-gabcdef-win64-gpl-9.1.zip"+ return {"tag_name": f"autobuild-{tag_date}", "assets": [{"name": name}]}+monkeypatch.setattr(update, "_get_json", lambda url: [+ # The current month's newest tag and an older daily in a finished+ # month are both deleted by BtbN within two weeks.+ release("9.1.3", "2026-10-02-12-00"),{"tag_name": tag, "assets": [{"name": name} for name in assets]},+ release("9.1.1", "2026-09-10-12-00"),])paths = {f"{osname}-{arch}": f"{source_os}/{source_arch}/1788300000_{version}/ffmpeg.zip"@@ -60,3 +69,10 @@ def test_resolved_version_fetches_its_exact_target_asset(indexes, target):def test_unadvertised_version_refuses_instead_of_relabelling_old_bytes(indexes, target):with pytest.raises(InstallError, match="9.9.9"):Ffmpeg().fetch_url("9.9.9", target)+++def test_only_retained_month_end_builds_are_pinned(indexes):+ versions = Ffmpeg().latest_versions("win32-x64")+ assert "9.1.2" in versions+ assert "9.1.3" not in versions # current month: still a daily+ assert "9.1.1" not in versions # older daily in a finished monthdiff --git a/tests/pm/test_update_request_reuse.py b/tests/pm/test_update_request_reuse.pyindex cd370ddea2a..6f3d01de703 100644--- a/tests/pm/test_update_request_reuse.py+++ b/tests/pm/test_update_request_reuse.py@@ -104,9 +104,12 @@ def test_resolution_reuses_successful_responses_but_refreshes_next_operation(ups# Linux comes from BtbN too (Windows .zip, Linux .tar.xz).btbn_assets.append({"name": f"ffmpeg-n{version}-1-gabcdef-linux{arch}-gpl-9.1.tar.xz"})- payloads["/repos/BtbN/FFmpeg-Builds/releases?per_page=30&page=1"] = [{- "tag_name": f"autobuild-{generation}", "assets": btbn_assets,- }]+ btbn_tag = f"autobuild-2026-{generation:02d}-28-12-00"+ payloads["/repos/BtbN/FFmpeg-Builds/releases?per_page=30&page=1"] = [+ # Newest tag is the in-progress month's daily, never pinned.+ {"tag_name": "autobuild-2026-12-01-12-00", "assets": []},+ {"tag_name": btbn_tag, "assets": btbn_assets},+ ]RangeHandler.payloads = {path: (value if isinstance(value, str) else json.dumps(value)).encode()for path, value in payloads.items()}# A failed transfer still retries; only the eventual success is reusable.@@ -118,7 +121,7 @@ def test_resolution_reuses_successful_responses_but_refreshes_next_operation(upsassert decision.changedif name == "ffmpeg":assert set(decision.artifact_updates) == set(expected_targets)- assert all(f"/{generation}_{version}/" in urls[0] or f"/autobuild-{generation}/" in urls[0]+ assert all(f"/{generation}_{version}/" in urls[0] or f"/{btbn_tag}/" in urls[0]for urls in decision.artifact_updates.values())expected = Counter(dict.fromkeys(payloads, 1))expected[retry_path] += 1