mirror of
https://github.com/NousResearch/hermes-agent.git
synced 2026-11-16 19:36:54 +00:00
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.
68 lines
2.1 KiB
Python
68 lines
2.1 KiB
Python
"""Tests for read_raw_config_readonly() — the no-deepcopy raw config read.
|
|
|
|
The readonly variant exists for per-turn policy checks (e.g. the
|
|
shared-metrics gate) that were paying a full config deepcopy on every call.
|
|
Contract under test:
|
|
|
|
1. identity invariant — repeat calls return the SAME cached object,
|
|
including across the very first (cache-miss) call;
|
|
2. freshness — an edited config.yaml (mtime/size change) is picked up;
|
|
3. parity — content equals read_raw_config()'s result;
|
|
4. missing/broken config degrades to {} exactly like read_raw_config().
|
|
"""
|
|
|
|
import os
|
|
import time
|
|
|
|
import pytest
|
|
import hermes_yaml as yaml
|
|
|
|
|
|
@pytest.fixture()
|
|
def isolated_hermes_home():
|
|
"""Per-test HERMES_HOME dir (already redirected by the autouse conftest
|
|
fixture) as a Path, with the raw-config cache cleared around the test."""
|
|
from pathlib import Path
|
|
|
|
import hermes_cli.config as config_mod
|
|
|
|
home = Path(os.environ["HERMES_HOME"])
|
|
home.mkdir(parents=True, exist_ok=True)
|
|
config_mod._RAW_CONFIG_CACHE.clear()
|
|
yield home
|
|
config_mod._RAW_CONFIG_CACHE.clear()
|
|
|
|
|
|
def _write_config(home, data):
|
|
cfg = home / "config.yaml"
|
|
cfg.write_text(yaml.safe_dump(data), encoding="utf-8")
|
|
return cfg
|
|
|
|
|
|
|
|
|
|
def test_freshness_after_config_edit(isolated_hermes_home):
|
|
from hermes_cli.config import read_raw_config_readonly
|
|
|
|
cfg = _write_config(isolated_hermes_home, {"display": {"ephemeral_system_ttl": 1}})
|
|
first = read_raw_config_readonly()
|
|
assert first["display"]["ephemeral_system_ttl"] == 1
|
|
|
|
_write_config(isolated_hermes_home, {"display": {"ephemeral_system_ttl": 7}})
|
|
# Force a distinct mtime_ns even on coarse-timestamp filesystems.
|
|
st = cfg.stat()
|
|
os.utime(cfg, ns=(st.st_atime_ns, st.st_mtime_ns + 1_000_000))
|
|
|
|
second = read_raw_config_readonly()
|
|
assert second["display"]["ephemeral_system_ttl"] == 7
|
|
|
|
|
|
def test_missing_config_returns_empty(isolated_hermes_home):
|
|
from hermes_cli.config import read_raw_config_readonly
|
|
|
|
cfg = isolated_hermes_home / "config.yaml"
|
|
if cfg.exists():
|
|
cfg.unlink()
|
|
assert read_raw_config_readonly() == {}
|
|
|
|
|