From ac9059a33871d96cc6fb1d2ad5cef7589ec4a670 Mon Sep 17 00:00:00 2001 From: Guillermo Montero Date: Thu, 17 Sep 2026 15:16:36 +0200 Subject: [PATCH] chore(plugins): remove the unused trusted field from LoadedPlugin --- CHANGELOG.md | 6 ++++++ src/bmad_loop/plugins/model.py | 1 - src/bmad_loop/plugins/registry.py | 2 +- tests/test_plugin_trust.py | 6 +++--- tests/test_plugin_workflows.py | 4 ++-- 5 files changed, 12 insertions(+), 7 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 5259aee07..2d979b017 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -351,6 +351,12 @@ breaking changes may land in a minor release. bundled `plugin.toml` or default trips it, but this is a compatibility break on previously-loading config. +### Removed + +- Remove the unused `trusted` field from `LoadedPlugin` and the `trusted=False` kwarg + passed at its one write site in `registry.py`, since nothing reads it anywhere in the + plugins package. + ### Fixed - Adopt the current bundle's deferred-work ids before writing a reset sweep task's diff --git a/src/bmad_loop/plugins/model.py b/src/bmad_loop/plugins/model.py index 35697fb9c..bb1b6bee0 100644 --- a/src/bmad_loop/plugins/model.py +++ b/src/bmad_loop/plugins/model.py @@ -264,7 +264,6 @@ class LoadedPlugin: manifest: PluginManifest instance: Plugin | None = None - trusted: bool = True disabled: bool = False error: str = "" # the plugin's resolved settings: manifest defaults overlaid by the diff --git a/src/bmad_loop/plugins/registry.py b/src/bmad_loop/plugins/registry.py index 850af6264..3bd37bec0 100644 --- a/src/bmad_loop/plugins/registry.py +++ b/src/bmad_loop/plugins/registry.py @@ -105,7 +105,7 @@ def _resolve(manifest: PluginManifest, policy, journal) -> LoadedPlugin: plugin=manifest.name, reason="[python] module requires [plugins] enabled", ) - return LoadedPlugin(manifest=manifest, trusted=False, settings=settings) + return LoadedPlugin(manifest=manifest, settings=settings) try: instance = _instantiate(manifest, settings) diff --git a/tests/test_plugin_trust.py b/tests/test_plugin_trust.py index dc6928046..994980d07 100644 --- a/tests/test_plugin_trust.py +++ b/tests/test_plugin_trust.py @@ -100,7 +100,7 @@ def test_untrusted_python_module_is_never_imported(tmp_path): reg = PluginRegistry.build(tmp_path, policy=Policy(), journal=journal) # not enabled lp = reg.get("spy") assert lp is not None - assert lp.instance is None and lp.trusted is False + assert lp.instance is None and lp.manifest.python is not None # the smoking gun: the module's import-time side effect never happened assert not (pdir / "IMPORTED").exists() assert "plugin-untrusted" in journal.kinds() @@ -112,7 +112,7 @@ def test_enabled_python_module_is_constructed(tmp_path): journal = FakeJournal() reg = PluginRegistry.build(tmp_path, policy=enable("trusted"), journal=journal) lp = reg.get("trusted") - assert lp.instance is not None and lp.trusted and not lp.disabled + assert lp.instance is not None and not lp.disabled assert lp.instance.name == "trusted" assert (pdir / "IMPORTED").exists() # now it ran assert "plugin-loaded" in journal.kinds() @@ -128,7 +128,7 @@ def test_dataonly_plugin_loads_without_enable(tmp_path): journal = FakeJournal() reg = PluginRegistry.build(tmp_path, policy=Policy(), journal=journal) lp = reg.get("decl") - assert lp.instance is None and lp.trusted # trusted-but-codeless + assert lp.instance is None and lp.manifest.python is None # data-only, no code to trust assert [h.stage for _, h in reg.hooks_for("pre_run")] == ["pre_run"] assert "plugin-loaded" in journal.kinds() diff --git a/tests/test_plugin_workflows.py b/tests/test_plugin_workflows.py index cf0c34784..37ff5f352 100644 --- a/tests/test_plugin_workflows.py +++ b/tests/test_plugin_workflows.py @@ -122,7 +122,7 @@ def test_unenabled_python_workflow_is_inert(): # a [python] plugin that wasn't enabled has instance=None: its module never # ran, so its workflow must not inject a session either. m = wf_manifest("gated", python=True) - reg = PluginRegistry([LoadedPlugin(manifest=m, trusted=False)]) + reg = PluginRegistry([LoadedPlugin(manifest=m)]) assert reg.workflow_stages() == frozenset({"post_dev_phase"}) # declared... assert reg.workflows_for("post_dev_phase") == [] # ...but not active @@ -631,6 +631,6 @@ def test_example_plugin_inert_until_enabled(project): project.project, Policy(gates=GatesPolicy(mode="none"), notify=QUIET) ) gr = reg.get("guardrails") - assert gr is not None and gr.instance is None and gr.trusted is False + assert gr is not None and gr.instance is None and gr.manifest.python is not None # its workflow is declared but inert (the plugin is not active) assert reg.workflows_for("post_dev_phase") == []