Activation reaches plugin discovery before the application dependencies exist. Give PM its own locked Python project and runtime so it can install or repair the application without importing that dependency tree. Keep PM outside the application workspace. A shared uv workspace resolves the application graph and cannot provide this isolation. Route mutations through an isolated worker and preserve transaction callbacks, cancellation, custom package registrations, and correlated receipts. Use the same runtime builder for source installs and packaged payloads. Keep offline wheelhouse support in that builder. Nix builds the independent PM lock as a separate derivation. Refuse lazy-disabled bootstrap before installing tools or dependencies. Move first-party YAML readers and writers to ruamel. Keep the application lock's transitive PyYAML requirements for third-party packages. Verification: - Focused canonical Python suite: 177 passed, 1 host-gated skip. - Electron backend probes: 12 passed. Electron typecheck passed. - Both uv locks, scoped lint, Bash syntax, and whitespace checks passed. - Cold activation, corrupt-app repair, offline staging, and relocation ran. - Built and exercised the Nix PM runtime and standalone YAML merge script. Six broader caller test files retain the same 24 failing test IDs as an archive of HEAD. The existing real-home guard blocks those tests before they can exercise the affected paths. No full-suite pass is claimed. Native Windows signing and full Bionic package execution remain unverified.
53 lines
1.7 KiB
Python
53 lines
1.7 KiB
Python
"""Behavior-contract compatibility tests for native Hermes plugins."""
|
|
|
|
from pathlib import Path
|
|
import shutil
|
|
|
|
import hermes_yaml as yaml
|
|
|
|
from hermes_cli.plugins import PluginManager
|
|
|
|
|
|
LEGACY_PLUGIN = Path(__file__).parent / "fixtures" / "plugin_compat_legacy"
|
|
|
|
|
|
def test_legacy_plugin_loads_and_ignores_additive_hook_and_manifest_fields(
|
|
tmp_path, monkeypatch
|
|
):
|
|
"""A frozen plugin keeps working as manifests and hook payloads grow."""
|
|
hermes_home = tmp_path / "hermes-home"
|
|
plugins_dir = hermes_home / "plugins"
|
|
plugins_dir.mkdir(parents=True)
|
|
shutil.copytree(LEGACY_PLUGIN, plugins_dir / "legacy-contract-fixture")
|
|
(hermes_home / "config.yaml").write_text(
|
|
yaml.safe_dump(
|
|
{"plugins": {"enabled": ["legacy-contract-fixture"]}}
|
|
),
|
|
encoding="utf-8",
|
|
)
|
|
empty_bundled = tmp_path / "bundled-plugins"
|
|
empty_bundled.mkdir()
|
|
monkeypatch.setenv("HOME", str(tmp_path / "os-home"))
|
|
monkeypatch.setenv("HERMES_HOME", str(hermes_home))
|
|
monkeypatch.setenv("HERMES_BUNDLED_PLUGINS", str(empty_bundled))
|
|
|
|
manager = PluginManager()
|
|
manager.discover_and_load()
|
|
|
|
loaded = manager._plugins["legacy-contract-fixture"]
|
|
assert loaded.enabled is True
|
|
assert loaded.error is None
|
|
assert loaded.module is not None
|
|
assert loaded.manifest.version == "0.1.0"
|
|
assert "on_session_start" in loaded.hooks_registered
|
|
|
|
results = manager.invoke_hook(
|
|
"on_session_start",
|
|
session_id="legacy-session",
|
|
resumed=True,
|
|
future_additive_field={"nested": "value"},
|
|
)
|
|
|
|
assert results == [{"legacy_session_id": "legacy-session"}]
|
|
assert loaded.module.received_sessions == ["legacy-session"]
|