The agent that grows with you
Python aiai-agentai-agentsanthropicchatgptclaudeclaude-codecodexhermeshermes-agentllmnous-researchopenai
fix(pm): plugins may move transitive core packages again (revert #137110 overreach)
Teknium562fda904c1a
diff --git a/plugin-catalog/README.md b/plugin-catalog/README.mdindex 0917736a8a7..c55587cf2e3 100644--- a/plugin-catalog/README.md+++ b/plugin-catalog/README.md@@ -72,9 +72,8 @@ meaningful:10. **Dependency security policy is the plugin's.** Hermes's 3-day`exclude-newer` release-age check covers Hermes's own dependencies only, atthe time Hermes locks them; a plugin's `python_dependencies` /- `pyproject.toml` install under the plugin's policy (no age check). Packages- Hermes itself locks stay at Hermes's locked versions, so a plugin cannot- require a different version of one. Reviewers read the+ `pyproject.toml` install under the plugin's policy (no age check), inside+ Hermes's core constraints: Hermes's exact pins cannot move. Reviewers read thedependency list at the pinned SHA: bare floors (`>=X` with no upper bound)and floors on the newest release get a request for the oldestAPI-compatible floor plus an upper bound, and authors are stronglydiff --git a/pm/AGENTS.md b/pm/AGENTS.mdindex ce6b3503003..17b7c2ed198 100644--- a/pm/AGENTS.md+++ b/pm/AGENTS.md@@ -20,9 +20,10 @@ Nix's declarative uv2nix builds and unrelated user projects remain independentlyThe `[tool.uv] exclude-newer = "3 days"` release-age check covers **Hermes's own dependenciesonly**, exact pins included, with no per-package exemptions, and it runs when Hermes LOCKS-(`hermes pm lock`, CI's lock check), never on users' machines. When PM generates the plugin workspace-(`pm/workspace.py::_trust_core_lock`) it drops the cutoff and constrains every core-locked package to-its locked version: users trust the vetted lock, so a mirror without upload times cannot break an-install (#135589), and a plugin cannot move a core package. Plugin `python_dependencies` follow the-plugin's own policy. Teknium's rulings: "plugins dont have to abide by our 14 day rule … Only hermes'+(`hermes pm lock`, CI's lock check), never on users' machines: every generated workspace drops the+cutoff (`pm/workspace.py::_without_release_age`), so a mirror without upload times cannot break an+install (#135589). Plugin resolution is unchanged by this: core's exact pins stay put, and a plugin+may move a transitive core package within core's declared ranges+(`tests/pm/test_workspace_build_inputs.py::test_plugin_can_move_compatible_transitive_but_not_exact_requirement`).+Plugin `python_dependencies` follow the plugin's own policy. Teknium's rulings: "plugins dont have to abide by our 14 day rule … Only hermes'dependencies themselves have to"; dates are checked by us, not users; pinned deps need >3 days.diff --git a/pm/workspace.py b/pm/workspace.pyindex cffff0ce461..37f462c8ec8 100644--- a/pm/workspace.py+++ b/pm/workspace.py@@ -129,8 +129,11 @@ def _generate_pyproject(plugin_dirs: list[Path] | Mapping[Path, Path], root: Patimport tomli_wdocument = tomllib.loads(core_text)- _trust_core_lock(document, source / "uv.lock")- document.setdefault("tool", {}).setdefault("uv", {})["workspace"] = {"members": sorted(members)}+ uv_policy = document.setdefault("tool", {}).setdefault("uv", {})+ # Release age is checked when Hermes locks; users trust that lock (#135589).+ uv_policy.pop("exclude-newer", None)+ uv_policy.pop("exclude-newer-package", None)+ uv_policy["workspace"] = {"members": sorted(members)}text = tomli_w.dumps(document)else:# A member-less generation syncs frozen against core's own lock.@@ -154,34 +157,6 @@ def _without_release_age(text: str) -> str:return re.sub(r"(?m)^exclude-newer\s*=.*\n", "", text)-def _trust_core_lock(document: dict, core_lock: Path) -> None:- """Hold core's packages at the versions core's lock already vetted.-- Release age is checked when Hermes locks (``exclude-newer`` in pyproject.toml, which- CI's lock check enforces), not on the user's machine: many package mirrors publish no- upload times, and uv rejects a file it cannot date ("X==V has no publish time",- #135589). So the generated root drops the cutoff and constrains every core-locked- registry package to its locked version instead; a plugin cannot drag one to an- unvetted release, and plugin-only packages follow the plugin's own policy. A package- the lock forks by platform (psutil: PyPI everywhere, git on Android) is left to the- resolver, which the seed lock already steers.- """- import tomllib- from collections import defaultdict-- settings = document.setdefault("tool", {}).setdefault("uv", {})- settings.pop("exclude-newer", None)- settings.pop("exclude-newer-package", None)- if not core_lock.is_file():- return # nothing vetted to hold; the resolver keeps core's declared ranges- entries = defaultdict(list)- for package in tomllib.loads(core_lock.read_text(encoding="utf-8-sig")).get("package", []):- entries[package["name"]].append(package)- pins = [f"{name}=={rows[0]['version']}" for name, rows in sorted(entries.items())- if len(rows) == 1 and "registry" in rows[0].get("source", {})]- settings["constraint-dependencies"] = [*settings.get("constraint-dependencies", []), *pins]--def _is_member_candidate(plugin_dir: Path) -> bool:return read_python_declaration(plugin_dir).is_memberdiff --git a/tests/pm/test_workspace.py b/tests/pm/test_workspace.pyindex 00e69797bf3..a3e1499b4c6 100644--- a/tests/pm/test_workspace.py+++ b/tests/pm/test_workspace.py@@ -64,8 +64,8 @@ def test_plugin_workspace_trusts_core_lock_instead_of_rechecking_release_age(lay"""Release age is checked when Hermes locks, never on the user's machine (#135589).The generated root carries no ``exclude-newer`` (a mirror without upload times makes- uv reject every file it cannot date) and instead holds each core-locked package at its- locked version, so a plugin cannot move one; plugin-only packages stay free (#120076).+ uv reject every file it cannot date) and adds no constraints of its own: core's ranges+ still bound what a plugin may move, and plugin-only packages stay free (#120076)."""import tomllib@@ -86,7 +86,7 @@ def test_plugin_workspace_trusts_core_lock_instead_of_rechecking_release_age(laypolicy = tomllib.loads((root / "pyproject.toml").read_text())["tool"]["uv"]assert "exclude-newer" not in policy and "exclude-newer-package" not in policy- assert sorted(policy["constraint-dependencies"]) == sorted(f"{n}=={v}" for n, v in core_packages.items())+ assert "constraint-dependencies" not in policylocked = {p["name"] for p in tomllib.loads((root / "uv.lock").read_text())["package"]}assert "member-dep" in lockeddiff --git a/tests/pm/test_workspace_build_inputs.py b/tests/pm/test_workspace_build_inputs.pyindex d42e02ad696..51122a036fc 100644--- a/tests/pm/test_workspace_build_inputs.py+++ b/tests/pm/test_workspace_build_inputs.py@@ -193,13 +193,8 @@ def test_legacy_member_is_generated_only_inside_workspace(tmp_path, monkeypatch)@pytest.mark.parametrize("exact", [False, True])-def test_plugin_cannot_move_any_core_locked_package(tmp_path, monkeypatch, exact):- """Core's lock is the vetted set: a plugin moves neither a core pin nor a transitive one.-- Release age is checked when Hermes locks, so a version core's lock never held was never- age-checked; a user's machine cannot check it either, since mirrors may serve no upload- times (#135589). Before, a transitive core package could move within core's ranges.- """+def test_plugin_can_move_compatible_transitive_but_not_exact_requirement(tmp_path, monkeypatch, exact):+ import osimport tomllibcore = tmp_path / "core"@@ -221,9 +216,8 @@ def test_plugin_cannot_move_any_core_locked_package(tmp_path, monkeypatch, exactbaseline, first_env = tmp_path / "baseline", tmp_path / "first-env"workspace.lock_and_sync([], [], root=baseline, source=core, seed_lock=None,environment=managed_environment(first_env))- (core / "uv.lock").write_bytes((baseline / "uv.lock").read_bytes())- assert next(p["version"] for p in tomllib.loads((core / "uv.lock").read_text())["package"]- if p["name"] == "pkgb") == "1.2"+ first_lock = (baseline / "uv.lock").read_bytes()+ assert next(p["version"] for p in tomllib.loads(first_lock.decode())["package"] if p["name"] == "pkgb") == "1.2"_fixtures._wheel(wheels, "pkgb", "1.3")plugin = tmp_path / "plugin"plugin.mkdir()@@ -231,9 +225,21 @@ def test_plugin_cannot_move_any_core_locked_package(tmp_path, monkeypatch, exact'[project]\nname="plugin-proof"\nversion="1"\nrequires-python=">=3.11"\ndependencies=["pkgb==1.3"]\n',encoding="utf-8",)- with pytest.raises(workspace.ResolutionConflict):- workspace.lock_and_sync([plugin], [], root=tmp_path / "extended", source=core,- seed_lock=core / "uv.lock", environment=managed_environment(tmp_path / "candidate"))+ extended, candidate = tmp_path / "extended", tmp_path / "candidate"+ if exact:+ with pytest.raises(workspace.ResolutionConflict):+ workspace.lock_and_sync([plugin], [], root=extended, source=core, seed_lock=baseline / "uv.lock",+ environment=managed_environment(candidate))+ else:+ workspace.lock_and_sync([plugin], [], root=extended, source=core, seed_lock=baseline / "uv.lock",+ environment=managed_environment(candidate))+ installed = tomllib.loads((extended / "uv.lock").read_text(encoding="utf-8"))["package"]+ assert next(p["version"] for p in installed if p["name"] == "pkgb") == "1.3"+ python = candidate / ("Scripts/python.exe" if os.name == "nt" else "bin/python")+ result = subprocess.run([str(python), "-c", "import pkga, pkgb; print(pkga.__version__, pkgb.__version__)"],+ capture_output=True, text=True, check=True, timeout=30)+ assert result.stdout.strip() == "1.0 1.3"+ assert (baseline / "uv.lock").read_bytes() == first_lockdef test_member_uv_lock_travels_with_its_member(tmp_path):diff --git a/website/docs/developer-guide/plugins/catalog-submission.md b/website/docs/developer-guide/plugins/catalog-submission.mdindex df43fb33213..61864aa0d79 100644--- a/website/docs/developer-guide/plugins/catalog-submission.md+++ b/website/docs/developer-guide/plugins/catalog-submission.md@@ -130,9 +130,8 @@ the gallery. There is no separate listing to maintain.10. **Dependency security policy is the plugin's.** Hermes's 3-day`exclude-newer` release-age check covers Hermes's own dependencies only, atthe time Hermes locks them; a plugin's `python_dependencies` /- `pyproject.toml` install under the plugin's policy (no age check). Packages- Hermes itself locks stay at Hermes's locked versions, so a plugin cannot- require a different version of one. Reviewers read the+ `pyproject.toml` install under the plugin's policy (no age check), inside+ Hermes's core constraints: Hermes's exact pins cannot move. Reviewers read thedependency list at the pinned SHA: bare floors (`>=X` with no upper bound)and floors on the newest release get a request for the oldestAPI-compatible floor plus an upper bound, and authors are stronglydiff --git a/website/docs/developer-guide/plugins/index.md b/website/docs/developer-guide/plugins/index.mdindex c122b174a98..e21dc01aae7 100644--- a/website/docs/developer-guide/plugins/index.md+++ b/website/docs/developer-guide/plugins/index.md@@ -531,11 +531,12 @@ Hermes checks the age of **its own** dependencies when it locks them: the checko`[tool.uv] exclude-newer = "3 days"` keeps any release younger than three days out of `uv.lock`,so a hijacked upload has time to be caught upstream before it reaches users. Users install fromthat vetted lock; their machines never re-check dates. **The check does not apply to your-plugin's dependencies.** When Hermes resolves your plugin into its environment, the packages-Hermes itself locks stay at their locked versions and everything else follows your-requirements, so a plugin can floor on a release published yesterday and install today. The-plugin's author, not Hermes, is responsible for what that pulls in. A plugin that requires a-different version of a package Hermes itself locks fails to install until Hermes's lock moves.+plugin's dependencies.** When Hermes resolves your plugin into its environment, Hermes's exact+pins stay put, other packages Hermes uses may move within the ranges Hermes declares, and+everything else follows your requirements, so a plugin can floor on a release published+yesterday and install today. The plugin's author, not Hermes, is responsible for what that pulls+in. A plugin that requires a different version of a package Hermes pins exactly fails to install+until Hermes's pin moves.Set your own policy and hold yourself to it. Strongly recommended:diff --git a/website/docs/reference/package-management.md b/website/docs/reference/package-management.mdindex 7f3c2d7f107..1a2e7d33361 100644--- a/website/docs/reference/package-management.md+++ b/website/docs/reference/package-management.md@@ -584,9 +584,8 @@ remain under uv and npm's own retry policies.Every Python package Hermes itself depends on must be at least three days oldwhen Hermes locks it (uv's `exclude-newer`, enforced by CI's lock check), so afreshly published, possibly compromised release cannot reach `uv.lock`. Users-install from that lock. Installing or enabling a plugin keeps every package-Hermes locks at its locked version and never re-checks dates, so package mirrors-that publish no upload times work. Set a mirror with `index-url` in `pip.conf`,+install from that lock, and installing or enabling a plugin never re-checks+dates, so package mirrors that publish no upload times work. Set a mirror with `index-url` in `pip.conf`,which Hermes passes to uv, or with `UV_INDEX_URL`.`hermes pm lock` is the one step that applies the check. Run against a mirror