Files
hermes-agent/tests/pm/test_admission_members_locked.py
ethernet 3c08d16ba7 fix(pm): close runtime publication and updater audit gaps
Dependency publication now recovers interrupted config/facts changes before
activation and leases live generations during collection. Receipts retain
update correlation and failed steps across nested command boundaries.
Doctor and desktop surfaces report those failures through shared owners.

Move checkout updates out of the desktop facade. Stage a detached Windows
relaunch waiter before shutdown, with bounded handshake and process-birth
checks. Keep packaged lifecycle tests isolated from the installed app.

Native verification exposed two production races: cron maintenance imported
the interactive CLI and rewrote TERMINAL_CWD, and install-ID reads collided
with first publication. Use the existing owners and locks. Plugin checks
now run at startup and each due-gated housekeeping tick, not after 60 ticks.

Share updater-test mutation boundaries and remove collection-root fixtures.
Separate cold MCP startup from command latency and give the real HTTP drip
test enough time to reach body handling.

Root npm check passed, including packaging. The fixed-tree Windows Python
run reported 44557 passed, one failed, and 1404 skipped, plus one retry-only
HTTP test. Those final failures now pass in a 35-test bounded batch. A real
isolated gateway wrote startup and periodic plugin-check receipts.

Full final-tree CI, bundled Sandbox deployment, and actual App Installer
relaunch remain unverified. docs/pm-audit-status.md records these limits.
2026-09-06 11:45:41 -04:00

47 lines
1.7 KiB
Python

"""Admission includes profile changes committed before its install lock is acquired."""
from contextlib import contextmanager
import importlib
from types import SimpleNamespace
def test_admission_reads_other_profiles_after_taking_lock(tmp_path, monkeypatch):
from hermes_cli import plugins_admission as admission
from hermes_cli import runtime_state
import pm.paths as paths
ensure = importlib.import_module("pm.ensure")
monkeypatch.setenv("HERMES_HOME", str(tmp_path / "home"))
repo = tmp_path / "repo"
repo.mkdir()
monkeypatch.setattr(paths, "repo_root", lambda: repo)
monkeypatch.setattr(ensure, "lazy_installs_allowed", lambda: True)
monkeypatch.setattr(ensure, "_facts", lambda: {})
sibling = tmp_path / "sibling-plugin"
state = {"members": [], "inside": False}
real_lock = runtime_state.runtime_lock
@contextmanager
def after_competing_publication(project):
with real_lock(project):
state["members"] = [sibling]
state["inside"] = True
try:
yield
finally:
state["inside"] = False
def members(*args, **kwargs):
return list(state["members"])
def apply(extras, *, plugin_dirs):
assert state["inside"]
assert plugin_dirs == [sibling]
return {}
monkeypatch.setattr(runtime_state, "runtime_lock", after_competing_publication)
monkeypatch.setattr(admission, "candidate_member_dirs", members)
monkeypatch.setattr(ensure, "get_package", lambda _: SimpleNamespace(
expected_stamp=lambda *args, **kwargs: "new", apply=apply,
))
admission.admit_plugin_set_change({"requested"}, set())