Skip to content

The agent that grows with you

test(plugins): verify sidecar survival and reject masked preservation failures

ethernetcb34ece61d54
diff --git a/tests/install/README.md b/tests/install/README.md
index 74f77c1b688..cfa2bddfa9c 100644
--- a/tests/install/README.md
+++ b/tests/install/README.md
@@ -102,10 +102,9 @@ contract and not exercised.
profile plugin tree, and the externally-owned sidecar witness outside the
home — no pyproject anywhere in the scanned root, nothing downloaded) and
snapshots; after the update lands it verifies and fails the leg on any
- violation. Seeding is not a clobber: a populated wrapper without the
- expected marker aborts the leg. The Windows driver carries the same
- fixtures and hooks inline (`Seed-PreservationFixtures`,
- `Invoke-PreserveSnapshot`, `Invoke-PreserveVerify`).
+ violation. Both shell and Windows hooks call the same Python `seed`
+ command. Existing fixtures or snapshots abort rather than masking damage
+ by reseeding. Windows uses a junction without requiring symlink privilege.
- Unit tests live at `tests/scripts/test_verify_plugin_preservation.py` and
exercise the verifier against a real temp filesystem (real files, real
symlinks; junction fallback on Windows).
diff --git a/tests/install/e2e-assets/preserve-plugins.sh b/tests/install/e2e-assets/preserve-plugins.sh
index 7b0d7747d97..ee97c51c3b5 100644
--- a/tests/install/e2e-assets/preserve-plugins.sh
+++ b/tests/install/e2e-assets/preserve-plugins.sh
@@ -35,57 +35,19 @@ _preserve_python() {
}
seed_plugin_preservation_fixtures() {
- # NOT a clobbering seeder: if the wrapper is already populated the fixture
- # state is left untouched, so a re-entered leg cannot erase a regression
- # the earlier phase recorded. Only a matching marker may be pre-existing.
- local home="$1" external="$2"
- local wrapper="$home/plugins/mnemosyne-wrapper"
- local marker="$wrapper/mnemosyne-wrapper.json"
- if [ -d "$wrapper" ] && [ -n "$(ls -A "$wrapper" 2>/dev/null)" ]; then
- grep -qF '"marker": "mnemosyne-wrapper"' "$marker" 2>/dev/null \
- || fail "refusing to reseed preservation fixtures: $wrapper already populated without the expected marker"
- ok "preservation fixtures already present; left untouched"
- else
- mkdir -p "$wrapper"
- printf '{"wrapper": true, "marker": "mnemosyne-wrapper", "owner": "e2e-preservation"}\n' \
- > "$marker"
- printf '#!/usr/bin/env python3\n# directory wrapper fixture: no dependencies\nPLUGIN = "mnemosyne-wrapper"\n' \
- > "$wrapper/plugin.py"
- if [ ! -e "$wrapper/runtime" ] && [ ! -L "$wrapper/runtime" ]; then
- ln -s "$external" "$wrapper/runtime" \
- || fail "could not create the runtime link at $wrapper/runtime; the preservation contract cannot be exercised"
- fi
- fi
- mkdir -p "$external" "$home/profiles/e2e-preserve/plugins/second-plugin"
- [ -e "$external/sidecar-witness.txt" ] \
- || printf 'external-sidecar-witness-v1\n' > "$external/sidecar-witness.txt"
- [ -e "$external/engine.bin" ] \
- || printf '\x00\x01\x02external-engine\n' > "$external/engine.bin"
- [ -e "$home/profiles/e2e-preserve/plugins/second-plugin/marker.json" ] \
- || printf '{"plugin": "second-plugin", "profile": "e2e-preserve"}\n' \
- > "$home/profiles/e2e-preserve/plugins/second-plugin/marker.json"
- [ -e "$home/profiles/e2e-preserve/plugins/second-plugin/data.bin" ] \
- || printf 'profile-plugin-bytes\n' \
- > "$home/profiles/e2e-preserve/plugins/second-plugin/data.bin"
- ok "seeded preservation fixtures: $wrapper (marker + runtime link) + profile tree; external witness at $external"
+ "$(_preserve_python)" "$REPO_ROOT/tests/install/e2e-assets/verify-plugin-preservation.py" \
+ seed --home "$1" --external "$2" || fail "could not seed fresh preservation fixtures"
}
preserve_before_upgrade() {
step "plugin preservation: seeding fixtures and snapshotting pre-upgrade state"
+ [ ! -e "$PRESERVE_SNAPSHOT" ] || fail "refusing to overwrite an existing preservation snapshot"
seed_plugin_preservation_fixtures "$HERMES_HOME" "$PRESERVE_EXTERNAL"
local py; py="$(_preserve_python)"
"$py" "$REPO_ROOT/tests/install/e2e-assets/verify-plugin-preservation.py" \
snapshot --home "$HERMES_HOME" --out "$PRESERVE_SNAPSHOT" 2>&1 | ts_prefix \
|| fail "plugin preservation snapshot failed"
- # An empty snapshot proves nothing; refuse to build the leg's claim on it.
- "$py" - "$PRESERVE_SNAPSHOT" <<'PYEOF' || fail "plugin preservation snapshot is EMPTY: no plugin entries recorded, cannot verify preservation"
-import json, sys
-with open(sys.argv[1], encoding="utf-8") as fh:
- snap = json.load(fh)
-n = len(snap.get("entries", {}))
-print(f"snapshot entries: {n}")
-raise SystemExit(0 if n else 3)
-PYEOF
+
ok "pre-upgrade plugin snapshot at $PRESERVE_SNAPSHOT"
}
diff --git a/tests/install/e2e-assets/verify-plugin-preservation.py b/tests/install/e2e-assets/verify-plugin-preservation.py
index 30ef618d6ce..95a5fe8f2a2 100644
--- a/tests/install/e2e-assets/verify-plugin-preservation.py
+++ b/tests/install/e2e-assets/verify-plugin-preservation.py
@@ -1,7 +1,8 @@
#!/usr/bin/env python3
"""Plugin upgrade-preservation verifier (Hermes release-harness hook).
-Standalone, stdlib-only, READ-ONLY against the scanned home. Two modes:
+Standalone and stdlib-only. Snapshot/verify are read-only against the home;
+the explicit seed command creates controlled fixtures in a disposable home.
snapshot walk every plugin tree of a HERMES_HOME (the active home's
``plugins/**`` plus each ``profiles/<name>/plugins/**`` tree,
@@ -33,6 +34,7 @@ import json
import os
import stat
import sys
+from pathlib import Path
SCHEMA_VERSION = 2
PROFILES_DIR = "profiles"
@@ -76,7 +78,7 @@ def _lstat_exists(path: str) -> bool:
try:
os.lstat(path)
return True
- except OSError:
+ except FileNotFoundError:
return False
@@ -168,6 +170,7 @@ def snapshot_home(home: str, profiles_dir: str | None = None) -> dict:
abs_path = os.path.join(dirpath, name)
rel = os.path.relpath(abs_path, home).replace(os.sep, "/")
entries[rel] = _entry_record(abs_path)
+ dirnames[:] = [name for name in dirnames if not _is_link(os.path.join(dirpath, name))]
return {
"schema": SCHEMA_VERSION,
"home": home,
@@ -204,10 +207,37 @@ def verify_home(home: str, snap: dict) -> dict:
}
+def seed_fixtures(home: Path, external: Path) -> None:
+ """Only create fresh fixtures; retries must not repair damaged witnesses."""
+ wrapper = home / "plugins/mnemosyne-wrapper"
+ profile = home / "profiles/e2e-preserve/plugins/second-plugin"
+ for path in (wrapper, profile, external):
+ if os.path.lexists(path):
+ raise FileExistsError(f"refusing to replace preservation fixture: {path}")
+ for path in (wrapper, profile, external):
+ path.mkdir(parents=True)
+ (wrapper / "mnemosyne-wrapper.json").write_text(
+ '{"wrapper":true,"marker":"mnemosyne-wrapper","owner":"e2e-preservation"}\n', encoding="utf-8")
+ (wrapper / "plugin.py").write_text('# directory wrapper fixture: no dependencies\n', encoding="utf-8")
+ (profile / "marker.json").write_text('{"plugin":"second-plugin"}\n', encoding="utf-8")
+ (profile / "data.bin").write_bytes(b"profile-plugin-bytes\n")
+ (external / "sidecar-witness.txt").write_text("external-sidecar-witness-v1\n", encoding="utf-8")
+ (external / "engine.bin").write_bytes(b"\x00\x01\x02external-engine\n")
+ if os.name == "nt":
+ import _winapi
+ _winapi.CreateJunction(str(external.resolve()), str(wrapper / "runtime"))
+ else:
+ (wrapper / "runtime").symlink_to(external.resolve(), target_is_directory=True)
+
+
def main(argv: list[str] | None = None) -> int:
ap = argparse.ArgumentParser(description=__doc__.splitlines()[0])
sub = ap.add_subparsers(dest="mode", required=True)
+ p_seed = sub.add_parser("seed", help="create fresh controlled fixtures in a disposable home")
+ p_seed.add_argument("--home", required=True)
+ p_seed.add_argument("--external", required=True)
+
p_snap = sub.add_parser("snapshot", help="record plugin-tree state to JSON")
p_snap.add_argument("--home", required=True)
p_snap.add_argument("--out", required=True)
@@ -222,6 +252,10 @@ def main(argv: list[str] | None = None) -> int:
args = ap.parse_args(argv)
+ if args.mode == "seed":
+ seed_fixtures(Path(args.home), Path(args.external))
+ return 0
+
if not os.path.isdir(os.path.abspath(args.home)):
print(f"error: --home is not a directory: {args.home}", file=sys.stderr)
return 2
@@ -232,6 +266,9 @@ def main(argv: list[str] | None = None) -> int:
except (OSError, ScanError) as exc:
print(f"snapshot failed: {exc}", file=sys.stderr)
return 2
+ if not snap["entries"]:
+ print("snapshot INCONCLUSIVE: ZERO entries", file=sys.stderr)
+ return 3
if args.profiles_dir:
snap["_profiles_dir"] = args.profiles_dir
with open(args.out, "w", encoding="utf-8") as fh:
@@ -240,16 +277,12 @@ def main(argv: list[str] | None = None) -> int:
f"snapshot: {len(snap['entries'])} entries across "
f"{len(snap['roots'])} plugin root(s) -> {args.out}"
)
- if not snap["entries"]:
- print(
- "WARNING: snapshot recorded ZERO entries -- an empty snapshot "
- "proves nothing; the E2E driver must treat this as a failure.",
- file=sys.stderr,
- )
return 0
with open(args.snapshot, "r", encoding="utf-8") as fh:
snap = json.load(fh)
+ if args.profiles_dir:
+ snap["_profiles_dir"] = args.profiles_dir
try:
report = verify_home(args.home, snap)
except (OSError, ScanError) as exc:
diff --git a/tests/install/installer-script-e2e.sh b/tests/install/installer-script-e2e.sh
index 60ed93d662d..2283e7df451 100755
--- a/tests/install/installer-script-e2e.sh
+++ b/tests/install/installer-script-e2e.sh
@@ -129,7 +129,7 @@ if [ -z "$INSTALL_REF" ]; then
fi
OLD_SHA="$(git -C "$REPO_ROOT" rev-parse "${INSTALL_REF}^{commit}")"
HEAD_SHA="$(git -C "$REPO_ROOT" rev-parse HEAD)"
-[ "$OLD_SHA" != "$HEAD_SHA" ] || fail "OLD ($INSTALL_REF) IS HEAD; no update would be available"
+
# The update target defaults to HEAD; --update-ref selects any other ref so
# a stable-to-stable leg can target the next release tag instead of the tip.
# Only call this leg stable-to-stable when BOTH refs are release tags.
diff --git a/tests/install/macos-desktop-e2e.sh b/tests/install/macos-desktop-e2e.sh
index 9d9da9bd111..872ef418de6 100755
--- a/tests/install/macos-desktop-e2e.sh
+++ b/tests/install/macos-desktop-e2e.sh
@@ -185,7 +185,7 @@ phase_stage() {
local old_sha head_sha target_sha target_label
old_sha="$(git -C "$REPO_ROOT" rev-parse "${old_ref}^{commit}")"
head_sha="$(git -C "$REPO_ROOT" rev-parse HEAD)"
- [ "$old_sha" != "$head_sha" ] || fail "OLD ($old_ref) IS HEAD; no update would be available"
+
# The update target defaults to HEAD; --update-ref selects any other ref
# so a stable-to-stable leg can target the next release tag instead of
# the tip. Only call this leg stable-to-stable when BOTH refs are tags.
diff --git a/tests/install/windows-e2e.ps1 b/tests/install/windows-e2e.ps1
index 4ef0caf2e5e..047afa40964 100644
--- a/tests/install/windows-e2e.ps1
+++ b/tests/install/windows-e2e.ps1
@@ -550,7 +550,7 @@ function Invoke-PhaseStage {
# bare-clone below (and everything after) sees the redirect file.
Set-GitRedirect
- $current = Invoke-Git @("-C", $RepoRoot, "rev-parse", $UpdateRef)
+ $current = Invoke-Git @("-C", $RepoRoot, "rev-parse", "${UpdateRef}^{commit}")
$targetLabel = if ($UpdateRef -eq "HEAD") { "HEAD" } else { $UpdateRef }
Write-Host " HEAD (update target): $current"
@@ -901,55 +901,18 @@ function Invoke-GuiUpdateDesktopRoute([string]$TargetSha) {
# pyproject in the scanned root, nothing downloaded). Snapshot is taken
# after install, verified after update.
function Seed-PreservationFixtures {
- $wrapper = Join-Path $HermesHome "plugins\mnemosyne-wrapper"
$external = Join-Path $WorkRoot "external-mnemosyne-runtime"
- $marker = Join-Path $wrapper "mnemosyne-wrapper.json"
- # NOT a clobbering seeder: pre-existing populated wrapper is left
- # untouched so a retried leg cannot erase a recorded regression.
- if (Test-Path -LiteralPath $wrapper) {
- $existing = @(Get-ChildItem -LiteralPath $wrapper -ErrorAction SilentlyContinue)
- if ($existing.Count -gt 0) {
- $markerOk = (Test-Path -LiteralPath $marker) -and
- ((Get-Content -LiteralPath $marker -Raw) -match "mnemosyne-wrapper")
- if (-not $markerOk) {
- throw "refusing to reseed preservation fixtures: $wrapper already populated without the expected marker"
- }
- Write-Host " preservation fixtures already present; left untouched"
- return
- }
- }
- New-Item -ItemType Directory -Path $wrapper, $external, `
- (Join-Path $HermesHome "profiles\e2e-preserve\plugins\second-plugin") -Force | Out-Null
- Set-Content -LiteralPath (Join-Path $wrapper "mnemosyne-wrapper.json") `
- -Value '{"wrapper": true, "marker": "mnemosyne-wrapper", "owner": "e2e-preservation"}' -Encoding UTF8
- Set-Content -LiteralPath (Join-Path $wrapper "plugin.py") `
- -Value '# directory wrapper fixture: no dependencies' + [Environment]::NewLine + 'PLUGIN = "mnemosyne-wrapper"' -Encoding UTF8
- if (-not (Test-Path -LiteralPath (Join-Path $wrapper "runtime"))) {
- try {
- New-Item -ItemType SymbolicLink -Path (Join-Path $wrapper "runtime") -Target $external -ErrorAction Stop | Out-Null
- } catch {
- Write-Host " (symlink unavailable: $($_.Exception.Message); runtime link omitted from fixtures)"
- }
- }
- Set-Content -LiteralPath (Join-Path $external "sidecar-witness.txt") -Value "external-sidecar-witness-v1" -Encoding UTF8
- Set-Content -LiteralPath (Join-Path $external "engine.bin") -Value "external-engine" -Encoding UTF8
- Set-Content -LiteralPath (Join-Path $HermesHome "profiles\e2e-preserve\plugins\second-plugin\marker.json") `
- -Value '{"plugin": "second-plugin", "profile": "e2e-preserve"}' -Encoding UTF8
- Set-Content -LiteralPath (Join-Path $HermesHome "profiles\e2e-preserve\plugins\second-plugin\data.bin") `
- -Value "profile-plugin-bytes" -Encoding UTF8
- Write-Host " preservation fixtures seeded (wrapper + profile tree; external witness at $external)"
+ & python (Join-Path $AssetsDir "verify-plugin-preservation.py") seed --home $HermesHome --external $external
+ if ($LASTEXITCODE -ne 0) { throw "could not seed fresh preservation fixtures (exit $LASTEXITCODE)" }
}
function Invoke-PreserveSnapshot {
- Seed-PreservationFixtures
$out = Join-Path $WorkRoot "plugin-preservation-snapshot.json"
+ if (Test-Path -LiteralPath $out) { throw "refusing to overwrite an existing preservation snapshot" }
+ Seed-PreservationFixtures
& python (Join-Path $AssetsDir "verify-plugin-preservation.py") snapshot --home $HermesHome --out $out
if ($LASTEXITCODE -ne 0) { throw "plugin preservation snapshot failed (exit $LASTEXITCODE)" }
- # An empty snapshot proves nothing; refuse to build the leg's claim on it.
- $snap = Get-Content -LiteralPath $out -Raw | ConvertFrom-Json
- if (@($snap.entries.PSObject.Properties).Count -eq 0) {
- throw "plugin preservation snapshot is EMPTY: no plugin entries recorded, cannot verify preservation"
- }
+
Write-Host " pre-upgrade plugin snapshot: $out"
}
diff --git a/tests/pm/test_plugin_survival_contract.py b/tests/pm/test_plugin_survival_contract.py
index 77937d5327d..e5a541abc4b 100644
--- a/tests/pm/test_plugin_survival_contract.py
+++ b/tests/pm/test_plugin_survival_contract.py
@@ -18,15 +18,9 @@ resolves offline local path-source fixtures):
reason, and a machine-readable pm receipt records the failure.
The retry path — re-admitting only the resolvable candidate —
commits through the same public function.
-3. GAP, documented honestly in pm/plugins_state.py: pm has NO
- automatic bisect/disable decision today, so "prefer the active
- memory provider over ordinary plugins" is not implemented anywhere.
- When such a decision exists it must keep the memory provider.
-4. Active-home propagation. The active CONTEXT home
+3. Active-home propagation. The active CONTEXT home
(hermes_constants.set_hermes_home_override) is what wrapper/sidecar
- subprocess launches must inherit: the detached respawn spec exports
- the active home as HERMES_HOME, and a child process launched with
- that overlay observes it.
+ subprocess launches must inherit through build_subprocess_env.
"""
from __future__ import annotations
@@ -173,7 +167,7 @@ def admission_env(tmp_path, monkeypatch):
monkeypatch.setattr(pm.paths, "repo_root", lambda: core)
monkeypatch.setattr(ws.paths, "repo_root", lambda: core)
monkeypatch.setattr(ensure, "lazy_installs_allowed", lambda: True)
- monkeypatch.setattr(ensure, "_facts", lambda: {})
+ monkeypatch.setenv("HERMES_RUNTIME_DIR", str(tmp_path / "tools"))
# pm's store uv realization is a package-manager concern; the store
# is empty under tmp, so pin the resolution to the PATH uv (same
# precedence _uv_binary applies on dev machines).
@@ -182,9 +176,10 @@ def admission_env(tmp_path, monkeypatch):
def _latest_receipt(home: Path) -> dict:
- receipts = sorted((home / "logs" / "update_receipts").glob("*.json"))
- assert receipts, "no pm receipt written"
- return json.loads(receipts[-1].read_text(encoding="utf-8-sig"))
+ from pm.receipt import latest
+ receipt = latest()
+ assert receipt is not None, f"no pm receipt written for {home}"
+ return receipt
@pytest.mark.skipif(not _uv_available(), reason="uv not on PATH")
@@ -197,6 +192,10 @@ def test_conflicting_candidate_refused_unenabled_and_unimported(admission_env):
tmp_path, home = admission_env
plug_a, plug_b, *_ = _local_conflict_members(home)
+ _write_enabled(home, [], provider="plug-a")
+ admission.admit_plugin_set_change(set(), set(), active_plugins_dir=home / "plugins")
+ from hermes_cli.runtime_paths import selected_venv
+ working = selected_venv(tmp_path / "core")
config_before = (home / "config.yaml").read_bytes()
tree_before = {p: sorted(str(f) for f in p.rglob("*")) for p in (plug_a, plug_b)}
@@ -219,6 +218,8 @@ def test_conflicting_candidate_refused_unenabled_and_unimported(admission_env):
"a refused candidate must stay unenabled — config published a set that never resolved"
)
assert (home / "config.yaml").read_bytes() == config_before
+ assert cfg["memory"]["provider"] == "plug-a"
+ assert selected_venv(tmp_path / "core") == working
# no plugin tree was deleted or mutated by the failed resolution
for plug, listing in tree_before.items():
@@ -244,6 +245,14 @@ def test_retry_after_conflict_enables_resolvable_candidate(admission_env):
tmp_path, home = admission_env
plug_a, plug_b, *_ = _local_conflict_members(home)
+ wrapper = home / "plugins/mnemosyne-wrapper"
+ wrapper.mkdir()
+ marker = wrapper / "mnemosyne-wrapper.json"
+ marker.write_bytes(b'{"wrapper":true}\n')
+ sidecar = tmp_path / "external-sidecar"
+ subprocess.run([shutil.which("uv"), "venv", "--python", sys.executable, str(sidecar)], check=True, capture_output=True, timeout=60)
+ sidecar_python = sidecar / ("Scripts/python.exe" if os.name == "nt" else "bin/python")
+ before = marker.read_bytes()
with pytest.raises(admission.AdmissionRefused):
admission.admit_plugin_set_change(
{"plug-a", "plug-b"}, set(), active_plugins_dir=home / "plugins"
@@ -260,6 +269,19 @@ def test_retry_after_conflict_enables_resolvable_candidate(admission_env):
assert "plug-b" not in cfg["plugins"]["enabled"], (
"the conflicting candidate must remain unenabled after the retry"
)
+ assert marker.read_bytes() == before
+ child = subprocess.run([str(sidecar_python), "-c", "import sys; print(sys.prefix)"], check=True, capture_output=True, text=True, timeout=30)
+ assert Path(child.stdout.strip()) == sidecar
+ from hermes_cli.runtime_paths import selected_venv
+ selected = selected_venv(tmp_path / "core")
+ assert selected.is_dir() and selected != sidecar
+ # A declared version range remains a member across the next managed rebuild.
+ project = plug_a / "pyproject.toml"
+ project.write_text(project.read_text(encoding="utf-8").replace("sharedlib==1.0.0", "sharedlib>=1,<2"), encoding="utf-8")
+ admission.admit_plugin_set_change({"plug-a"}, set(), active_plugins_dir=home / "plugins")
+ assert selected_venv(tmp_path / "core") != selected
+ assert marker.read_bytes() == before
+ subprocess.run([str(sidecar_python), "-c", "import sys; assert sys.prefix != sys.base_prefix"], check=True, timeout=30)
# ---------------------------------------------------------------------------
diff --git a/tests/scripts/test_verify_plugin_preservation.py b/tests/scripts/test_verify_plugin_preservation.py
index c5c54b1539e..0420c2da60c 100644
--- a/tests/scripts/test_verify_plugin_preservation.py
+++ b/tests/scripts/test_verify_plugin_preservation.py
@@ -16,6 +16,7 @@ from __future__ import annotations
import importlib.util
import json
import os
+import shutil
import subprocess
import sys
@@ -33,8 +34,10 @@ _spec.loader.exec_module(vpp)
def _make_link(target, link):
try:
- os.symlink(str(target), str(link))
+ os.symlink(str(target), str(link), target_is_directory=True)
except OSError:
+ if os.name != "nt":
+ raise
# Windows without symlink privilege: same reparse-point shape.
import _winapi
@@ -131,12 +134,7 @@ def test_catches_plugin_file_deletion(home, tmp_path):
def test_catches_whole_plugin_root_deletion(home, tmp_path):
snap = _snapshot(home, tmp_path / "snap.json")
- for root, dirs, files in os.walk(home / "plugins", topdown=False):
- for name in files:
- os.remove(os.path.join(root, name))
- for name in dirs:
- os.rmdir(os.path.join(root, name))
- os.rmdir(home / "plugins")
+ shutil.rmtree(home / "plugins")
report = _verify(home, snap)
assert report["ok"] is False
assert report["counts"]["deleted"] > 0
@@ -225,7 +223,6 @@ def test_verifier_is_read_only_against_home(home, tmp_path):
def test_catches_empty_dir_deletion(home, tmp_path):
# A plugin directory emptied (or an empty dir removed) must be caught:
# directories themselves are recorded, not skipped.
- snap = _snapshot(home, tmp_path / "snap.json")
empty = home / "plugins" / "wrapper-b" / "empty-cache"
empty.mkdir(parents=True)
snap2 = _snapshot(home, tmp_path / "snap2.json")
@@ -247,8 +244,9 @@ def test_empty_snapshot_is_inconclusive(home, tmp_path):
"--out", str(snap_file)],
capture_output=True, text=True,
)
- assert r1.returncode == 0
+ assert r1.returncode == 3
assert "ZERO entries" in r1.stderr
+ snap_file.write_text(json.dumps(vpp.snapshot_home(str(empty_home))), encoding="utf-8")
r2 = subprocess.run(
[sys.executable, VERIFIER, "verify", "--home", str(empty_home),
"--snapshot", str(snap_file)],
@@ -258,18 +256,18 @@ def test_empty_snapshot_is_inconclusive(home, tmp_path):
assert "INCONCLUSIVE" in r2.stderr
def test_unreadable_path_is_hard_error(home, tmp_path):
# A scanner that cannot see a path must fail loudly, not skip silently.
# Skip where chmod-based unreadability is not enforceable (Windows).
- if os.name != "posix":
- pytest.skip("chmod-based unreadability is POSIX-only")
- snap = _snapshot(home, tmp_path / "snap.json")
+ if os.geteuid() == 0:
+ pytest.skip("root can read chmod-000 directories")
secret = home / "plugins" / "mnemosyne-wrapper" / "locked"
secret.mkdir()
(secret / "x.txt").write_text("data", encoding="utf-8")
os.chmod(secret, 0o000)
try:
- with pytest.raises(OSError):
+ with pytest.raises((OSError, vpp.ScanError)):
_snapshot(home, tmp_path / "snap2.json")
finally:
os.chmod(secret, 0o755)
@@ -304,3 +302,19 @@ def test_cli_roundtrip_end_to_end(home, tmp_path):
)
assert r3.returncode == 1
assert "PLUGIN PRESERVATION FAILED" in r3.stderr
+
+
+def test_release_fixture_seed_is_shared_and_never_repairs_damage(tmp_path):
+ home, external = tmp_path / "home", tmp_path / "external"
+ args = [sys.executable, VERIFIER, "seed", "--home", str(home), "--external", str(external)]
+ result = subprocess.run(args, capture_output=True, text=True, timeout=30)
+ assert result.returncode == 0, result.stderr
+ snap = vpp.snapshot_home(str(home))
+ runtime = snap["entries"]["plugins/mnemosyne-wrapper/runtime"]
+ assert runtime["target_tree"]["engine.bin"]["kind"] == "file"
+ witness = external / "sidecar-witness.txt"
+ witness.unlink()
+ retry = subprocess.run(args, capture_output=True, text=True, timeout=30)
+ assert retry.returncode != 0
+ assert not witness.exists()
+ assert not vpp.verify_home(str(home), snap)["ok"]
diff --git a/tests/test_powershell_script_syntax.py b/tests/test_powershell_script_syntax.py
index 90f19f08850..e5119cf75db 100644
--- a/tests/test_powershell_script_syntax.py
+++ b/tests/test_powershell_script_syntax.py
@@ -27,6 +27,7 @@ REPO_ROOT = Path(__file__).resolve().parent.parent
# not hardcoded: a new script in scripts/ gets gated automatically.
PS1_SCRIPTS = sorted(
list(REPO_ROOT.glob("scripts/*.ps1"))
+ + list(REPO_ROOT.glob("tests/install/*.ps1"))
+ list(REPO_ROOT.glob("*.ps1")) # repo-root scripts (setup-hermes.ps1, activate.ps1)
)