Skip to content

The agent that grows with you

test(e2e): drop the #120307/#120295 gaps now on main; tighten two known_failure patterns

teknium176aebb415d90
diff --git a/tests/e2e/core/_pending_fixes.py b/tests/e2e/core/_pending_fixes.py
index b589b341a25..3e47761709e 100644
--- a/tests/e2e/core/_pending_fixes.py
+++ b/tests/e2e/core/_pending_fixes.py
@@ -1,140 +1,21 @@
"""Merge-order-safe expected failures for live gaps whose fix is an open PR.
A plain ``xfail(strict=True)`` turns main red the moment its fix merges (XPASS), and a
-non-strict one guards nothing. Instead, each gap here has a PROBE: a few lines that reproduce
-the defect's mechanism on the tree under test, in a throwaway interpreter with its own
-``HOME``/``HERMES_HOME`` (no state leaks into the suite process). ``expect_gaps`` applies an
-xfail only while a probe still reproduces its defect, and only for the bug-specific exception
-that cell raises when it observes THAT leak (``raises=``): a timeout, a boot failure or any
-other assertion still fails the cell. Once the fix is in the tree the cell runs as a plain
-test, so it must pass. Whichever lands first, suite or fix, main stays green.
-
-``strict=False`` is only for a gap the end-to-end cell reproduces probabilistically (a race);
-the probe itself is deterministic, so the mark still disappears when the fix lands.
-
-Probes exercise behaviour only (never read source text). Same pattern as
-``tests/e2e/core/delivery/_pending_fixes.py`` (PR #120344). When a fix has landed, delete its
-probe and every ``Gap`` naming it.
-
-``known_failure`` is the probe-less form: a run-time xfail keyed on the gap's own failure
-message, so the cell XFAILs only while it fails exactly that way, fails loudly on any other
-failure, and simply passes once the fix lands (no XPASS, whichever merges first).
+non-strict one guards nothing. ``known_failure`` is a run-time xfail keyed on the gap's own
+failure message: the cell XFAILs only while it fails exactly that way, fails loudly on any other
+failure (a timeout, a lost reply, a boot failure), and simply passes once the fix lands, whichever
+merges first. Wrap only the final assertions. When a fix has landed, delete its ``known_failure``.
+Probe-gated gaps live in ``tests/e2e/core/delivery/_pending_fixes.py``.
"""
from __future__ import annotations
import contextlib
-import functools
-import json
-import os
import re
-import subprocess
-import sys
-import tempfile
-from dataclasses import dataclass
-from pathlib import Path
-from typing import Dict, Iterator, Tuple, Type
+from typing import Iterator, Tuple, Type
import pytest
-REPO_ROOT = Path(__file__).resolve().parents[3]
-
-# ``verdict`` writes to a file, not stdout: importing tui_gateway.server repoints stdout (its JSON-RPC
-# channel) at stderr.
-_PRELUDE = ("import json, os, sys\nfrom pathlib import Path\nsys.path.insert(0, os.getcwd())\n"
- "HOME = Path(os.environ['HERMES_HOME'])\n"
- "def verdict(v):\n Path(os.environ['GAP_VERDICT']).write_text(v)\n")
-
-# PR -> (extra env, script). A script records ``open`` while the defect reproduces, ``fixed`` once
-# it no longer does; anything else (including a crash) fails the cell that asked.
-PROBES: Dict[int, Tuple[Dict[str, str], str]] = {
- # Multiplexed host: (a) the first import of gateway.run under a routed profile's home override
- # loaded THAT profile's .env into the process env; (b) session-less work (cron) for a routed
- # profile reused the shared "default" terminal environment.
- 120307: ({}, r'''
-alpha = HOME / "profiles" / "alpha"
-alpha.mkdir(parents=True)
-(alpha / ".env").write_text("C7_PROBE_ROUTED_CANARY=alpha\n")
-from hermes_constants import set_hermes_home_override
-set_hermes_home_override(str(alpha))
-import gateway.run # noqa: F401
-bridged = os.environ.get("C7_PROBE_ROUTED_CANARY") == "alpha"
-from tools.terminal_tool import _resolve_container_task_id
-shared = _resolve_container_task_id(None) == "default"
-verdict("open" if bridged or shared else "fixed")
-'''),
- # /model <id> --provider X adopted another provider's alias (its base_url and key) that
- # exposes the same model id.
- 120295: ({"PROVIDER_B_KEY": "sk-provider-b"}, r'''
-(HOME / "config.yaml").write_text(
- "model:\n provider: provider-a\n default: old-model\n"
- "providers:\n"
- " provider-a:\n base_url: https://api-a.example.com/v1\n"
- " provider-b:\n base_url: https://api-b.example.com/v1\n key_env: PROVIDER_B_KEY\n")
-import hermes_cli.model_switch as ms
-import hermes_cli.models_validate as mv
-from hermes_cli.config import load_config
-ms.DIRECT_ALIASES = {"a-alias": ms.DirectAlias("shared-model", "custom", "https://alias-host.example.com/v1",
- api_key="sk-alias-host")}
-mv.validate_requested_model = lambda *a, **kw: {"accepted": True, "persist": True, "recognized": True, "message": None}
-r = ms.switch_model("shared-model", "provider-a", "old-model", current_base_url="https://api-a.example.com/v1",
- current_api_key="sk-provider-a", explicit_provider="provider-b",
- user_providers=load_config()["providers"])
-assert r.success, r.error_message
-verdict("fixed" if (r.base_url, r.api_key) == ("https://api-b.example.com/v1", "sk-provider-b") else "open")
-'''),
-}
-
-
[email protected]_cache(maxsize=None)
-def gap_open(pr: int) -> bool:
- """True while the defect PR ``pr`` fixes still reproduces on this tree."""
- extra_env, script = PROBES[pr]
- with tempfile.TemporaryDirectory(prefix=f"gap-{pr}-") as tmp:
- home = Path(tmp) / "home"
- (home / ".hermes").mkdir(parents=True)
- out = Path(tmp) / "verdict"
- env = {k: v for k, v in os.environ.items()
- if not k.startswith(("PYTEST_", "HERMES_")) and not k.endswith(("_API_KEY", "_BASE_URL"))}
- env.update({"HOME": str(home), "HERMES_HOME": str(home / ".hermes"), "GAP_VERDICT": str(out),
- "PYTHONPATH": str(REPO_ROOT), **extra_env})
- proc = subprocess.run([sys.executable, "-c", _PRELUDE + script], cwd=str(REPO_ROOT), env=env,
- stdin=subprocess.DEVNULL, capture_output=True, text=True, timeout=120)
- verdict = out.read_text() if proc.returncode == 0 and out.exists() else ""
- if verdict not in ("open", "fixed"):
- raise AssertionError(f"probe for #{pr} is broken (rc={proc.returncode}, verdict={verdict!r}): "
- f"{json.dumps(proc.stdout[-800:])} {proc.stderr[-2000:]}")
- return verdict == "open"
-
-
-@dataclass(frozen=True)
-class Gap:
- pr: int
- reason: str
- raises: Type[BaseException] | Tuple[Type[BaseException], ...]
- strict: bool = True
-
- def __post_init__(self) -> None:
- assert f"#{self.pr}" in self.reason, f"reason for a #{self.pr} gap must name the PR: {self.reason!r}"
- assert self.pr in PROBES, f"#{self.pr} has no probe"
-
-
-def expect_gaps(request: pytest.FixtureRequest, *gaps: Gap) -> None:
- """One xfail for this cell covering every gap whose probe still reproduces; a plain test once none does.
-
- pytest honours only the first matching xfail mark, so open gaps are merged: ``raises`` is the
- union of their bug-specific exceptions, and the mark is strict when any open gap is deterministic.
- """
- open_gaps = [g for g in gaps if gap_open(g.pr)]
- if not open_gaps:
- return
- raises: tuple = ()
- for g in open_gaps:
- raises += g.raises if isinstance(g.raises, tuple) else (g.raises,)
- request.applymarker(pytest.mark.xfail(
- strict=any(g.strict for g in open_gaps), raises=tuple(dict.fromkeys(raises)),
- reason=" | ".join(g.reason for g in open_gaps)))
-
@contextlib.contextmanager
def known_failure(pattern: str, reason: str,
diff --git a/tests/e2e/core/live/test_live_providers.py b/tests/e2e/core/live/test_live_providers.py
index f423b15aa6b..0892465205d 100644
--- a/tests/e2e/core/live/test_live_providers.py
+++ b/tests/e2e/core/live/test_live_providers.py
@@ -131,12 +131,12 @@ def _host_ok(host: str, allowed: tuple[str, ...]) -> bool:
# /models ------------------------------------------------------------------------
-# Merge-order safe (see _pending_fixes.known_failure): only an EMPTY live listing excuses the cell,
-# so the cell simply passes once the fix lands.
+# Merge-order safe (see _pending_fixes.known_failure): only an empty listing WITH a 401 from the
+# models endpoint excuses the cell (an outage or a 5xx still fails it); it passes once the fix lands.
_KNOWN_LISTING_BUGS = {
# Native /v1beta/models rejects a Bearer AI-Studio key (401), so the live fetcher returns nothing
# and the picker silently falls back to the curated list.
- "gemini": (r"^gemini: live /models returned nothing",
+ "gemini": (r"^gemini: live /models returned nothing \(.*/models -> 401",
"#62259 Gemini live model discovery sends Bearer auth (fix PRs #62267/#116509)"),
}
diff --git a/tests/e2e/core/tenancy/test_routing_truth_table.py b/tests/e2e/core/tenancy/test_routing_truth_table.py
index 4120edad908..1ba4fac4ba6 100644
--- a/tests/e2e/core/tenancy/test_routing_truth_table.py
+++ b/tests/e2e/core/tenancy/test_routing_truth_table.py
@@ -32,7 +32,6 @@ from urllib.parse import urlparse
import pytest
-from tests.e2e.core._pending_fixes import Gap, expect_gaps
from tests.fakes.fake_llm_provider import MODEL_ID, Error, ToolCall
from ._routing_helpers import (
@@ -300,11 +299,6 @@ def cli_outcomes(tmp_path_factory: pytest.TempPathFactory) -> dict[str, Any]:
return {cid: fut for cid, fut in futures.items()}
-# Live gaps, applied only while their probe reproduces them (see _pending_fixes).
-GAP_120295 = Gap(120295, "#120295: `/model <id> --provider X` adopts another provider's alias (endpoint + key) "
- "for the same model id", raises=RoutingLeak)
-
-
@pytest.mark.parametrize("case", [pytest.param(c, id=c.id) for c in CASES])
def test_cli_routing_truth_table(case: Case, cli_outcomes: dict[str, Any]) -> None:
fleet, outcomes = cli_outcomes[case.id].result(timeout=900)
@@ -347,8 +341,7 @@ class Switch:
def test_tui_gateway_model_switch_routing(tmp_path: Path, request: pytest.FixtureRequest) -> None:
"""One live session walks the switch matrix; after every switch the next turn lands on
exactly the selected host with exactly its key, and nothing reaches any other host.
- Leg 5 is #120295's cell; leg 6 pins the #120299 fix."""
- expect_gaps(request, GAP_120295)
+ Leg 5 pins the #120295 fix; leg 6 pins the #120299 fix."""
fleet = Fleet(ROLES).start()
trap = EgressTrap()
home = tmp_path / "home"
diff --git a/tests/e2e/core/tenancy/test_two_tenant_desktop_backend.py b/tests/e2e/core/tenancy/test_two_tenant_desktop_backend.py
index ae04cc4eb4f..32d3e716e78 100644
--- a/tests/e2e/core/tenancy/test_two_tenant_desktop_backend.py
+++ b/tests/e2e/core/tenancy/test_two_tenant_desktop_backend.py
@@ -28,7 +28,6 @@ from typing import Any
import pytest
-from tests.e2e.core._pending_fixes import Gap, expect_gaps
from . import _helpers as H
@@ -100,16 +99,7 @@ def _await_cron(tenants: dict[str, H.Tenant], fires: int) -> None:
f"cron fire #{fires} in every profile")
-# Live gaps, applied only while their probe reproduces them (see _pending_fixes).
-GAPS = (
- # A race in this cell (which session first imports gateway.run), red in ~6 of 7 runs: not strict.
- Gap(120307, "#120307: gateway.run's import-time config bridge writes a secondary session's .env / "
- "terminal.* into the process env", raises=H.TenantLeak, strict=False),
-)
-
-
def test_desktop_backend_never_crosses_tenants(fleet, request: pytest.FixtureRequest) -> None:
- expect_gaps(request, *GAPS)
root, tenants, backends = fleet
# Phase 1: one backend, three profile sessions, interleaved turns, one cron fire per profile.
diff --git a/tests/e2e/core/tenancy/test_two_tenant_gateway.py b/tests/e2e/core/tenancy/test_two_tenant_gateway.py
index 7ba77cc3d4f..33ca3b609b5 100644
--- a/tests/e2e/core/tenancy/test_two_tenant_gateway.py
+++ b/tests/e2e/core/tenancy/test_two_tenant_gateway.py
@@ -36,7 +36,6 @@ from typing import Any
import pytest
-from tests.e2e.core._pending_fixes import Gap, expect_gaps
from . import _helpers as H
@@ -153,14 +152,7 @@ def _await_cron(tenants: dict[str, H.Tenant], at_least: int) -> None:
f"cron fire #{at_least} in every profile")
-# Applied only while the probe reproduces it (see _pending_fixes).
-GAP_120307 = Gap(120307, "#120307: session-less work (cron) for a routed profile keys the shared 'default' "
- "terminal env, so alpha/beta cron tool calls inherit default's .env, cwd and shell state",
- raises=H.TenantLeak)
-
-
def test_multiplexed_gateway_never_crosses_tenants(fleet, request: pytest.FixtureRequest) -> None:
- expect_gaps(request, GAP_120307)
root, tenants, gw = fleet
home = root / "home"
diff --git a/tests/e2e/core/upgrade/test_upgrade_path.py b/tests/e2e/core/upgrade/test_upgrade_path.py
index 4e282b42e05..5f23ea1df4a 100644
--- a/tests/e2e/core/upgrade/test_upgrade_path.py
+++ b/tests/e2e/core/upgrade/test_upgrade_path.py
@@ -661,8 +661,8 @@ def test_kill_mid_pull_then_retry_heals(leg, provider, torn):
final = _update(leg)
# 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 "
+ r"(?s)^final `hermes update` failed:.*(cannot import name|No module named)",
+ "#120339 (merged; passes once N-1 is a release carrying it): 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: