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.
50 lines
1.5 KiB
Python
50 lines
1.5 KiB
Python
"""Background worktree maintenance must not initialize the interactive CLI."""
|
|
|
|
import os
|
|
from pathlib import Path
|
|
import subprocess
|
|
import sys
|
|
|
|
|
|
def test_cold_worktree_maintenance_preserves_terminal_cwd(tmp_path):
|
|
repo = tmp_path / "repo"
|
|
repo.mkdir()
|
|
subprocess.run(["git", "init", "--initial-branch=main", str(repo)], check=True,
|
|
capture_output=True, timeout=15)
|
|
(repo / ".worktrees").mkdir()
|
|
workspace = tmp_path / "workspace"
|
|
workspace.mkdir()
|
|
env = dict(os.environ, PYTHONPATH=str(Path(__file__).resolve().parents[2]),
|
|
TERMINAL_CWD=str(workspace))
|
|
script = """
|
|
import os
|
|
import sys
|
|
import threading
|
|
from cron import scheduler
|
|
from hermes_cli import worktree_ops
|
|
|
|
assert 'cli' not in sys.modules, 'requires a cold CLI import'
|
|
before = os.environ['TERMINAL_CWD']
|
|
finished = threading.Event()
|
|
errors = []
|
|
prune = worktree_ops._prune_stale_worktrees
|
|
|
|
def observed_prune(repo):
|
|
try:
|
|
prune(repo)
|
|
except Exception as exc:
|
|
errors.append(exc)
|
|
finally:
|
|
finished.set()
|
|
|
|
worktree_ops._prune_stale_worktrees = observed_prune
|
|
scheduler._worktree_maintenance_repos = lambda: [sys.argv[1]]
|
|
scheduler._maybe_run_worktree_maintenance()
|
|
assert finished.wait(30), 'maintenance did not finish'
|
|
assert not errors, errors
|
|
assert os.environ['TERMINAL_CWD'] == before
|
|
"""
|
|
result = subprocess.run([sys.executable, "-c", script, str(repo)], env=env,
|
|
cwd=tmp_path, capture_output=True, text=True, timeout=45)
|
|
assert result.returncode == 0, result.stdout + result.stderr
|