Files
nousresearch--hermes-agent/tests/test_install_sh_install_method_stamp.py
wehub-resource-sync b4fbd6fe9f
Deploy Site / deploy-vercel (push) Has been skipped
Deploy Site / deploy-docs (push) Has been skipped
Build Skills Index / build-index (push) Has been skipped
CI / Deny unrelated histories (push) Has been skipped
CI / Detect affected areas (push) Successful in 27m35s
CI / OSV scan (push) Failing after 4s
CI / Build&Test Docker image (push) Successful in 9s
CI / Supply-chain scan (push) Has been skipped
CI / Lint Docker scripts (push) Failing after 5m13s
CI / Check contributors (push) Failing after 12m8s
CI / Docs Site (push) Failing after 12m8s
CI / TypeScript (push) Failing after 12m8s
CI / Python lints (push) Failing after 12m9s
CI / Python tests (push) Failing after 12m9s
CI / Check uv.lock (push) Failing after 23m22s
CI / CI timing report (push) Has been cancelled
Build Skills Index / trigger-deploy (push) Has been cancelled
CI / All required checks pass (push) Has been cancelled
chore: import upstream snapshot with attribution
2026-07-13 11:56:03 +08:00

41 lines
1.6 KiB
Python

"""Contract test: install.sh stamps the install method next to the code tree
($INSTALL_DIR), not into the shared $HERMES_HOME.
Background (shared-$HERMES_HOME bug)
------------------------------------
$HERMES_HOME is a data directory users frequently bind-mount into a Docker
gateway as well (``~/.hermes:/opt/data``). The published image stamps 'docker'
there on boot, so if install.sh had written its 'git' marker into the same
$HERMES_HOME the two installs would fight over one slot — and the container,
booting last, would win and wrongly make the host install look like 'docker'
(blocking ``hermes update``).
The fix: detect_install_method() reads a CODE-scoped stamp first, and the
installer writes ``git`` into $INSTALL_DIR (the git checkout, e.g.
``~/.hermes/hermes-agent``), which is unique to this install and immune to the
shared data dir.
"""
from __future__ import annotations
import re
from pathlib import Path
REPO_ROOT = Path(__file__).resolve().parent.parent
INSTALL_SH = REPO_ROOT / "scripts" / "install.sh"
def test_install_sh_stamps_code_tree_not_home() -> None:
text = INSTALL_SH.read_text()
# Stamps the code tree.
assert text.count('echo "git" > "$INSTALL_DIR/.install_method"') >= 1, (
"install.sh must stamp $INSTALL_DIR/.install_method (code-scoped)"
)
# Never stamps the shared data dir.
assert not re.search(r'>\s*"\$HERMES_HOME/\.install_method"', text), (
"install.sh must not stamp $HERMES_HOME/.install_method — that data "
"dir may be shared with a Docker gateway whose 'docker' stamp would "
"clobber it and block host-side `hermes update`"
)