The agent that grows with you
Python aiai-agentai-agentsanthropicchatgptclaudeclaude-codecodexhermeshermes-agentllmnous-researchopenai
test(upgrade): cells whose config bug main fixed are plain tests; the rest are message-gated
teknium1daafeb5dbbd2
diff --git a/tests/e2e/core/upgrade/test_config_roundtrip_properties.py b/tests/e2e/core/upgrade/test_config_roundtrip_properties.pyindex 4ccded0f1fb..9693397aeb7 100644--- a/tests/e2e/core/upgrade/test_config_roundtrip_properties.py+++ b/tests/e2e/core/upgrade/test_config_roundtrip_properties.py@@ -22,8 +22,9 @@ A seeded property / matrix layer over every surface that writes ``config.yaml``Generators are ``random.Random(seed)`` over a fixed seed list (hypothesis is not a dependency);every assertion message carries the seed / case so a failure is reproducible with ``-k``.-Known-red cells on the current base are ``xfail(strict=True)`` with the issue they reproduce, so-the suite is green today and flips red the moment the bug is fixed (drop the marker then).+Cells for a live gap are merge-order safe: they XFAIL only while they fail with that gap's own+message (``tests/e2e/core/_pending_fixes.known_failure``), fail loudly on anything else, and pass as+plain tests once the fix lands."""from __future__ import annotations@@ -48,6 +49,7 @@ from typing import Any, Callable, Iterableimport pytestimport yaml+from tests.e2e.core._pending_fixes import known_failurefrom tests.e2e.core.upgrade._helpers import WORKTREE, isolated_envimport hermes_cli.config as C@@ -411,11 +413,6 @@ class ReadFaults:P1_SEEDS = list(range(101, 113))P1_LONG_SEEDS = [201, 202, 203, 204]-_XFAIL_119844 = pytest.mark.xfail(- strict=True,- reason="#119844 (open): ruamel round-trip writer has no `width`, so every save re-folds long "- "scalars (untouched keys change bytes) and a fold after a backslash inserts a space into "- "the stored value. Fix: `yaml_rt.width = 2**31 - 1` in utils._roundtrip_load.")def _noop_save_roundtrip(case: Case, monkeypatch) -> None:@@ -435,26 +432,19 @@ def _noop_save_roundtrip(case: Case, monkeypatch) -> None:assert secret not in after, f"[seed={case.seed}] expanded ${{{name}}} leaked into config.yaml"-_XFAIL_NULL_STRIP = pytest.mark.xfail(- strict=True,- reason="NEW: save_config's _strip_default_values uses None as its 'drop me' sentinel, so an explicit "- "`key: null` is deleted on every save even when preserved as user-set (display.skin: null "- "silently becomes 'default'), and a section emptied that way takes its comments with it.")--@pytest.mark.parametrize("seed", P1_SEEDS)def test_p1_noop_save_is_byte_identical(seed, home, monkeypatch):_noop_save_roundtrip(gen_case(seed, null_leaves=False), monkeypatch)[email protected]("seed", [pytest.param(s, marks=_XFAIL_NULL_STRIP) for s in (101, 102)])[email protected]("seed", [101, 102])def test_p1_explicit_null_leaves_survive_a_noop_save(seed, home, monkeypatch):case = gen_case(seed)assert any(v is None for v in _leaves(case.tree).values()), f"seed {seed} generated no null leaf"_noop_save_roundtrip(case, monkeypatch)[email protected]("seed", [pytest.param(s, marks=_XFAIL_119844) for s in P1_LONG_SEEDS])[email protected]("seed", P1_LONG_SEEDS)def test_p1_long_scalars_survive_a_noop_save(seed, home, monkeypatch):_noop_save_roundtrip(gen_case(seed, long=True, null_leaves=False), monkeypatch)@@ -632,14 +622,7 @@ def test_p2_real_cli_env_setting_changes_exactly_one_env_line_and_no_config_byteassert "TELEGRAM_HOME_CHANNEL=4242" in _read(env_file).splitlines()-_XFAIL_119928 = pytest.mark.xfail(- strict=True,- reason="#119928 (open): when the managed-scope .env pins a key, `hermes config set` prints the "- "refusal, then '✓ Set', exits 0 — and the credential route still rewrites config.yaml.")--[email protected]("key", [pytest.param("DEEPSEEK_API_KEY", marks=_XFAIL_119928),- pytest.param("TELEGRAM_HOME_CHANNEL", marks=_XFAIL_119928)])[email protected]("key", ["DEEPSEEK_API_KEY", "TELEGRAM_HOME_CHANNEL"])def test_p2_env_lock_refusal_is_not_reported_as_success(key, tmp_path):"""exit 0 ⇔ the write happened; a refused key leaves .env AND config.yaml byte-identical."""managed = tmp_path / "managed"@@ -653,10 +636,13 @@ def test_p2_env_lock_refusal_is_not_reported_as_success(key, tmp_path):env_before = _read(hh / ".env")r = _cli(env, "config", "set", key, "c18-new")wrote = _read(hh / ".env") != env_before- assert (r.returncode == 0) == wrote, (- f"`config set {key}` exit={r.returncode} but .env {'changed' if wrote else 'unchanged'}:\n{r.stdout}{r.stderr}")- if not wrote:- assert _read(hh / "config.yaml") == cfg_text, "a refused env write still rewrote config.yaml"+ with known_failure(r"^`config set \w+` exit=0 but \.env unchanged|^a refused env write still rewrote config\.yaml",+ "#119928 (fix PR #119929): when the managed-scope .env pins a key, `hermes config set` "+ "prints the refusal, then '✓ Set', exits 0, and the credential route still rewrites config.yaml"):+ assert (r.returncode == 0) == wrote, (+ f"`config set {key}` exit={r.returncode} but .env {'changed' if wrote else 'unchanged'}:\n{r.stdout}{r.stderr}")+ if not wrote:+ assert _read(hh / "config.yaml") == cfg_text, "a refused env write still rewrote config.yaml"# ── real tui_gateway stdio JSON-RPC process ──────────────────────────────────@@ -791,10 +777,6 @@ def test_p2_dashboard_get_put_roundtrip_and_partial_put(seed, web_app, home, mon_dashboard_roundtrip(gen_case(seed, null_leaves=False), web_app, monkeypatch)[email protected](strict=True, reason=(- "NEW: save_config -> _normalize_max_turns_config always sets config['agent'] (even to {}), so "- "any save of a sparse raw document lacking `agent:` (Desktop partial PUT, every migration "- "persist) appends a phantom `agent: {}` section to config.yaml."))def test_p2_dashboard_partial_put_adds_no_phantom_section(web_app, home, monkeypatch):case = gen_case(606, null_leaves=False, exclude_top={"agent", "display"})cfg = _install(case, monkeypatch)@@ -805,7 +787,7 @@ def test_p2_dashboard_partial_put_adds_no_phantom_section(web_app, home, monkeypf"PUT display.skin added sections {sorted(set(got) - set(case.tree) - {'display'})}:\n{_udiff(case.text, _read(cfg))}")[email protected]("seed", [pytest.param(605, marks=_XFAIL_NULL_STRIP)])[email protected]("seed", [607])def test_p2_dashboard_noop_put_keeps_explicit_nulls(seed, web_app, home, monkeypatch):case = gen_case(seed)assert any(v is None for v in _leaves(case.tree).values())@@ -814,9 +796,6 @@ def test_p2_dashboard_noop_put_keeps_explicit_nulls(seed, web_app, home, monkeypdef _dashboard_roundtrip(case: Case, web_app, monkeypatch) -> None:seed = case.seed- if "agent" not in case.tree: # see test_p2_dashboard_partial_put_adds_no_phantom_section- text = _before_version(case.text, "agent:\n verify_on_stop: false\n")- case = Case(seed, text, yaml.safe_load(text), case.leaf_lines, case.env)cfg = _install(case, monkeypatch)client = _client(web_app)body = client.get("/api/config").json()@@ -886,16 +865,6 @@ _P3_OPS: dict[str, tuple[Callable[[dict], None], set]] = {"migrate": (_op_migrate, {("_config_version",), ("delegation", "max_iterations")}),}-_XFAIL_TRANSIENT = {- "tui_rpc": "NEW (#113301 class, TUI/Desktop surface): tui_gateway.server._load_cfg_raw swallows any "- "read exception into {} and _write_config_key saves that through the full-document "- "writer, which deletes every section the caller never saw.",- "dashboard_put": "NEW (#113301 class, dashboard/Desktop surface): PUT /api/config merges the body "- "over read_raw_config(), whose swallowed-error path returns {}; Desktop PUTs "- "single-key bodies, so one transient read error collapses config.yaml to that key.",-}--def _p3_case(seed: int) -> Case:case = gen_case(seed, null_leaves=False, exclude_top={"display", "delegation", "agent"})text = _before_version(case.text, "display:\n skin: mono\n compact: true\ndelegation:\n max_iterations: 50\n"@@ -934,15 +903,7 @@ def _p3_check(label: str, before_text: str, after_text: str, targets: set, outcoreturn None-def _p3_params():- out = []- for op in _P3_OPS:- marks = [pytest.mark.xfail(strict=True, reason=_XFAIL_TRANSIENT[op])] if op in _XFAIL_TRANSIENT else []- out.append(pytest.param(op, marks=marks, id=op))- return out--[email protected]("op_name", _p3_params())[email protected]("op_name", list(_P3_OPS))def test_p3_a_transient_error_on_any_single_read_never_clobbers(op_name, web_app, home, monkeypatch):"""Dry-run the operation to count its config reads R, then for k in 1..R fail exactly read k."""case = _p3_case(700)@@ -1226,10 +1187,7 @@ _TOP_LEVEL = [k for k in DEFAULT_CONFIG if k != "_config_version"]def _p6_setup(section: str, monkeypatch) -> tuple[str, dict, Path, int]:case = gen_case(1000 + _TOP_LEVEL.index(section), n_sections=(3, 5), null_leaves=False,exclude_top={section, "display", "agent"})- block = f"{section}: null\n"- if section != "agent": # keep the separately-xfailed phantom `agent: {}` out of these cells- block = "agent:\n verify_on_stop: false\n" + block- text = _before_version(case.text, block)+ text = _before_version(case.text, f"{section}: null\n")for k, v in case.env.items():monkeypatch.setenv(k, v)cfg = _cfg_path()@@ -1270,8 +1228,6 @@ def test_p6_null_section_survives_every_surface(section, web_app, home, monkeypaassert touched <= {null_line} and len(inserted) <= 1, f"[{ctx}] save touched other lines:\n{_udiff(text, after)}"_assert_no_duplicate_top_level(after, ctx)- # (section,) itself is allowed to change here: dropping `section: null` on a save is the- # separately-xfailed null-strip bug (test_p1_explicit_null_leaves_survive_a_noop_save).writers = {"cli_set": (lambda: C.set_config_value("terminal.timeout", "4242"), ("terminal", "timeout")),"tui_rpc": (lambda: server._methods["config.set"](1, {"key": "skin", "value": "ares"}), ("display", "skin")),@@ -1288,6 +1244,7 @@ def test_p6_null_section_survives_every_surface(section, web_app, home, monkeypaassert res.status_code == 200, f"[{ctx}] PUT /api/config: {res.text}"got = yaml.safe_load(_read(cfg))assert _get(got, target) not in (_MISSING, None), f"[{ctx}] {name} did not write {target}"+ # (section,) itself may change: a writer may normalise `section: null` to an empty mapping.stray = {p for p in _changed_paths(tree, got) if not _under(p, {target, (section,)})}assert not stray, f"[{ctx}] {name} changed untargeted paths {sorted(stray, key=str)}:\n{_udiff(text, _read(cfg))}"@@ -1321,20 +1278,7 @@ def test_p6_all_sections_null_at_once_through_gateway_loader_and_migration(home,load_gateway_config()-def _p6_effective_params():- out = []- for k in _TOP_LEVEL:- d = DEFAULT_CONFIG[k]- marks = []- if not isinstance(d, dict) and d is not None:- marks = [pytest.mark.xfail(strict=True, reason=(- "NEW (null-strip): `key: null` for a key with a non-null default loads as None but "- "save_config deletes it, so after any save the default silently takes effect."))]- out.append(pytest.param(k, marks=marks, id=k))- return out--[email protected]("section", _p6_effective_params())[email protected]("section", _TOP_LEVEL)def test_p6_noop_save_keeps_the_effective_value_of_a_null_section(section, home, monkeypatch):_p6_setup(section, monkeypatch)effective = C.load_config()diff --git a/tests/e2e/core/upgrade/test_fresh_process_entrypoints.py b/tests/e2e/core/upgrade/test_fresh_process_entrypoints.pyindex 3f1497e78d4..39caac9c3be 100644--- a/tests/e2e/core/upgrade/test_fresh_process_entrypoints.py+++ b/tests/e2e/core/upgrade/test_fresh_process_entrypoints.py@@ -626,13 +626,6 @@ _ENTRIES = {"hermes-acp-help": Entry("hermes-acp", ("--help",), frozenset({0})),"hermes-agent-help": Entry("hermes-agent", ("--help",), frozenset({0})),}-_XFAIL = {- "hermes-agent-help": "LIVE BUG #54648 (open): the hermes-agent console script calls run_agent.main() "- "with no arguments, ignoring argv (fire only parses it under __main__), so "- "`hermes-agent --help` runs a real model turn with a hard-coded query",-}--def _run_on_tty(argv: list[str], *, env: dict[str, str], cwd: Path, writable: list[Path],timeout: float) -> subprocess.CompletedProcess:"""Run ``argv`` on a pty; once it has drawn anything, send EOF every second until it exits.@@ -688,10 +681,7 @@ def _db_rows(db: Path, sql: str) -> list[tuple]:conn.close()[email protected]("case", [- pytest.param(k, marks=pytest.mark.xfail(strict=True, reason=_XFAIL[k])) if k in _XFAIL else k- for k in _ENTRIES-])[email protected]("case", list(_ENTRIES))def test_entrypoint_in_a_fresh_process(case, tmp_path):_sandbox_or_skip()entry = _ENTRIES[case]diff --git a/tests/e2e/core/upgrade/test_upgrade_path.py b/tests/e2e/core/upgrade/test_upgrade_path.pyindex 0ae70b4ff54..4e282b42e05 100644--- a/tests/e2e/core/upgrade/test_upgrade_path.py+++ b/tests/e2e/core/upgrade/test_upgrade_path.py@@ -16,7 +16,8 @@ Class C6 (bricked installs, stale code, lost state after `hermes update`). EachLegs: ``clean``; ``autostash`` (local edits + an orphan update autostash from an earlier run);``kill_mid_pull`` (SIGKILL while the fast-forward holds ``index.lock``, then the user retries-later; ``torn-tree`` variant: half the changed files already swapped, a strict xfail); ``kill_before_deps``+later; ``torn-tree`` variant: half the changed files already swapped, merge-order-safe xfail for the+live gap fixed by #120339); ``kill_before_deps``(SIGKILL after the code swap, when the dependency sync starts: new code on the old venv);``offline`` (origin unreachable: must fail loudly and leave N-1 working).@@ -28,7 +29,7 @@ pre-existing messages (also after HEAD's first real use of the DB); the cron jobvenv satisfies HEAD's dependency set; config.yaml of both profiles equals exactly what HEAD's ownnon-interactive ``migrate_config`` produces from the pre-update bytes (so the updater neverrewrites anything beyond documented migrations), user values and comments survive independently-of that oracle, and (strict xfail, #119844) long-value lines survive verbatim; no+of that oracle, and long-value lines survive verbatim (#119844); noservice-manager restart was attempted against anything outside the sandbox.The install's origin is the official URL rewritten (``url.<store>.insteadOf``) to the local@@ -41,6 +42,7 @@ live gateway on the host.from __future__ import annotations+import contextlibimport functoolsimport hashlibimport json@@ -56,6 +58,7 @@ from typing import NamedTupleimport pytestimport yaml+from tests.e2e.core._pending_fixes import known_failurefrom tests.e2e.core.upgrade import _helpers as Hfrom tests.fakes.fake_llm_provider import FakeLLMServer@@ -224,12 +227,12 @@ def user_config(base_url: str, version: int) -> str:)-def _base_config_version() -> int:- src = _git("show", f"{_refs().base}:hermes_cli/config_defaults.py", cwd=H.WORKTREE)- for line in src.splitlines():- if '"_config_version"' in line:- return int(line.split(":", 1)[1].split(",", 1)[0].strip())- raise AssertionError("could not read the N-1 _config_version")+def _base_config_version(leg: Leg) -> int:+ """The N-1 schema version, as N-1's own code reports it (imported in the N-1 install's venv)."""+ cp = leg.run("-c", "from hermes_cli.config_defaults import DEFAULT_CONFIG; print(DEFAULT_CONFIG['_config_version'])",+ argv0=leg.python)+ assert cp.returncode == 0, "could not import the N-1 DEFAULT_CONFIG:\n" + H.describe(cp)+ return int(cp.stdout.strip().splitlines()[-1])# ---------------------------------------------------------------------------@@ -522,7 +525,7 @@ def provider():def template_home(tmp_path_factory, provider) -> Path:"""HERMES_HOME populated by the N-1 CLI itself (sessions, profile, cron, config)."""seed = make_leg(tmp_path_factory.mktemp("seed"), None)- version = _base_config_version()+ version = _base_config_version(seed)cfg = user_config(provider.base_url, version)(seed.hermes_home / "config.yaml").write_text(cfg, encoding="utf-8")(seed.hermes_home / ".env").write_text("OPENAI_API_KEY=sk-fake-e2e\n", encoding="utf-8")@@ -600,7 +603,6 @@ def test_clean_update(clean_leg, provider):assert _git("status", "--porcelain", "--untracked-files=no", cwd=leg.install) == "", "update left a dirty tree"[email protected](strict=True, reason="#119844: ruamel re-folds long scalars when the updater's migration saves config.yaml")def test_clean_update_keeps_long_scalar_lines_verbatim(clean_leg):leg, final = clean_legassert final.returncode == 0, H.describe(final)@@ -642,10 +644,7 @@ def test_update_with_local_edits_and_orphan_autostash(leg, provider):@pytest.mark.parametrize("torn", [pytest.param(False, id="lock-only"),- pytest.param(True, id="torn-tree", marks=pytest.mark.xfail(strict=True, reason=(- "NEW: a fast-forward killed half-way leaves a prefix of the changed files at HEAD while HEAD "- "still names N-1; every entry point, including `hermes update`, then dies at import "- "(cannot import name ... from 'utils'), so nothing can heal the install without manual git"))),+ pytest.param(True, id="torn-tree"),])def test_kill_mid_pull_then_retry_heals(leg, provider, torn):changed = sorted(_git("diff", "--name-only", "--no-renames", "--diff-filter=AM", _refs().base, _refs().head,@@ -660,7 +659,14 @@ def test_kill_mid_pull_then_retry_heals(leg, provider, torn):assert (leg.install / ".git" / "index.lock").exists()_age_git_locks(leg.install)final = _update(leg)- assert_healthy_at_head(leg, provider, final)+ # Merge-order safe (see _pending_fixes.known_failure): only the import-time death excuses torn-tree.+ gate = known_failure(+ r"(?s)^final `hermes update` failed:.*cannot import name",+ "#120339 (open fix PR): a fast-forward killed half-way leaves a prefix of the changed files at HEAD while "+ "HEAD still names N-1; every entry point, including `hermes update`, then dies at import (cannot import "+ "name ... from 'utils'), so nothing can heal the install without manual git") if torn else contextlib.nullcontext()+ with gate:+ assert_healthy_at_head(leg, provider, final)def test_kill_before_deps_then_retry_heals(leg, provider):