Skip to content
Draft
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
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 0 additions & 1 deletion src/bmad_loop/plugins/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion src/bmad_loop/plugins/registry.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
6 changes: 3 additions & 3 deletions tests/test_plugin_trust.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand All @@ -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()
Expand All @@ -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()

Expand Down
4 changes: 2 additions & 2 deletions tests/test_plugin_workflows.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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") == []