The agent that grows with you
Python aiai-agentai-agentsanthropicchatgptclaudeclaude-codecodexhermeshermes-agentllmnous-researchopenai
fix(pm): a retry fingerprint covers the enabled plugins beside the retried one
Teknium1d258cc6c23b
diff --git a/pm/plugin_eviction.py b/pm/plugin_eviction.pyindex 29ba4c1f02b..c73007d44ad 100644--- a/pm/plugin_eviction.py+++ b/pm/plugin_eviction.py@@ -301,6 +301,7 @@ class _EvictingUpdate:self.explicit, self.configs, self.entries, self.reasons = explicit, configs, entries, reasonsself.retrying = list(recorded)self.tried: dict[Path, str] = {}+ self.verdicts: list[Path] = [] # disabled on a verdict about the plugin: fingerprinted at commitself.base = _target_selection(package, fact, inputs={"plugin_dirs": []}, repair=False, **selection)[0]def fits(plugin_dir: Path) -> bool:@@ -309,23 +310,28 @@ class _EvictingUpdate:self.kept = list(dict.fromkeys(plugin_dir for _plugins_dir, _name, plugin_dir in entriesif fits(plugin_dir) and _is_member_candidate(plugin_dir)))# A plugin with nothing to build rejoins on its static verdict; one with dependencies is- # due only when core's inputs or its own changed since the attempt that failed.+ # due only when core's inputs, its own or the enabled plugins beside it changed since the+ # attempt that failed.self.joined = [entry for entry in recorded if fits(entry[2]) and not _is_member_candidate(entry[2])]# Those whose last failure was no verdict on the plugin (a download failure, a static# misfit since fixed) go first: they fitted beside the rest before.self.due = sorted((entry for entry, record in recorded.items()if fits(entry[2]) and _is_member_candidate(entry[2])- and record.get("tried") != self.fingerprint(entry[2])),+ and record.get("tried") != self.fingerprint(entry[2], self.kept)),key=lambda entry: "tried" in recorded[entry])- def fingerprint(self, plugin_dir: Path) -> str:- return self.package.expected_stamp(self.base, plugin_dirs=[plugin_dir])+ def fingerprint(self, plugin_dir: Path, beside: list[Path]) -> str:+ """What a retry of *plugin_dir* would build: core, the plugin and the enabled plugins."""+ return self.package.expected_stamp(self.base, plugin_dirs=[*beside, plugin_dir])def commit(self, members: list[Path]) -> None:from pm import receiptfrom pm.install import _commit_selection, _runtime_state_matches, _target_selection- enabled, stamp, inputs = _target_selection(self.package, self.fact, inputs={"plugin_dirs": list(dict.fromkeys(members))},+ members = list(dict.fromkeys(members))+ # Fingerprinted against the members this update leaves enabled: the next update compares there.+ self.tried = {member.resolve(): self.fingerprint(member, members) for member in self.verdicts}+ enabled, stamp, inputs = _target_selection(self.package, self.fact, inputs={"plugin_dirs": members},repair=False, **self.selection)receipt.record_feature_list(enabled)edit = None@@ -368,7 +374,7 @@ class _EvictingUpdate:return Trueself.reasons[member.resolve()] = verdict[0]if verdict[1]:- self.tried[member.resolve()] = self.fingerprint(member)+ self.verdicts.append(member)return Falsedef evict_enabled(self, failure: InstallError) -> None:diff --git a/tests/pm/test_plugin_survival_contract.py b/tests/pm/test_plugin_survival_contract.pyindex 6eadd70e552..c10b5cfbc39 100644--- a/tests/pm/test_plugin_survival_contract.py+++ b/tests/pm/test_plugin_survival_contract.py@@ -465,15 +465,16 @@ def test_provider_only_record_is_retried_only_while_it_is_still_the_provider(adm@pytest.mark.skipif(not _uv_available(), reason="uv not on PATH")def test_recorded_plugin_is_retried_only_when_changed_and_never_displaces_an_enabled_one(admission_env, monkeypatch):- """A plugin an update disabled on a resolver verdict is not built again while neither it nor- core changed. Once it changed, it is tried only on top of the enabled plugins, so even a- download failure hitting an enabled plugin in that update can never swap the two."""+ """A plugin an update disabled on a resolver verdict is not built again while neither it, core+ nor the enabled plugins beside it changed. Once it changed, it is tried only on top of the+ enabled plugins, so even a download failure hitting an enabled plugin in that update can never+ swap the two; once only the plugin it conflicted with changes, it comes back."""from pm.install import sync_venv, venv_is_currentfrom pm.package import InstallErrorfrom pm.packages import Venvtmp_path, home = admission_env- _plug_a, plug_b, _, _ = _local_conflict_members(home)+ plug_a, plug_b, _, _ = _local_conflict_members(home)_write_enabled(home, ["plug-a", "plug-b"])sync_venv(explicit=True, evict_incompatible_plugins=True)@@ -505,6 +506,14 @@ def test_recorded_plugin_is_retried_only_when_changed_and_never_displaces_an_enaassert plugins["enabled"] == ["plug-a"] and plugins["disabled"] == ["plug-b"]assert venv_is_current(project_root=tmp_path / "core") is True+ # Only the enabled plugin it conflicted with changes, and the conflict is gone: it comes back.+ manifest = plug_a / "pyproject.toml"+ manifest.write_text(manifest.read_text(encoding="utf-8").replace('"sharedlib==1.0.0"', '"sharedlib>=1"').replace(+ "sharedlib-v1", "sharedlib-v2"), encoding="utf-8")+ sync_venv(explicit=True, evict_incompatible_plugins=True)+ plugins = yaml.safe_load((home / "config.yaml").read_text(encoding="utf-8"))["plugins"]+ assert plugins["enabled"] == ["plug-a", "plug-b"] and not plugins.get("disabled")+@pytest.mark.skipif(not _uv_available(), reason="uv not on PATH")def test_update_sync_disables_later_plugin_of_unresolvable_union(admission_env):