The agent that grows with you
Python aiai-agentai-agentsanthropicchatgptclaudeclaude-codecodexhermeshermes-agentllmnous-researchopenai
test(e2e): drop the probes for merged fixes; message-gate the remaining static xfails
teknium1b47b787c1f65
diff --git a/tests/e2e/core/_pending_fixes.py b/tests/e2e/core/_pending_fixes.pyindex 5d2241167b4..b589b341a25 100644--- a/tests/e2e/core/_pending_fixes.py+++ b/tests/e2e/core/_pending_fixes.py@@ -12,21 +12,28 @@ 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.-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.+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)."""from __future__ import annotations+import contextlibimport functoolsimport jsonimport os+import reimport subprocessimport sysimport tempfilefrom dataclasses import dataclassfrom pathlib import Path-from typing import Dict, Tuple, Type+from typing import Dict, Iterator, Tuple, Typeimport pytest@@ -41,17 +48,6 @@ _PRELUDE = ("import json, os, sys\nfrom pathlib import Path\nsys.path.insert(0,# 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]] = {- # Desktop backend: a secondary profile's session.create / lazy session info reported (and- # stored) the LAUNCH profile's configured model.- 120319: ({}, r'''-(HOME / "config.yaml").write_text("model:\n default: launch-model\n")-alpha = HOME / "profiles" / "alpha"-alpha.mkdir(parents=True)-(alpha / "config.yaml").write_text("model:\n default: alpha-model\n")-from tui_gateway import server-model = server._lazy_resume_info(str(HOME), profile="alpha")["model"]-verdict({"launch-model": "open", "alpha-model": "fixed"}.get(model, f"unexpected model {model!r}"))-'''),# 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.@@ -66,25 +62,6 @@ bridged = os.environ.get("C7_PROBE_ROUTED_CANARY") == "alpha"from tools.terminal_tool import _resolve_container_task_idshared = _resolve_container_task_id(None) == "default"verdict("open" if bridged or shared else "fixed")-'''),- # Credential routing: (a) with no OpenRouter key, the OpenRouter resolver fell back to an- # OPENAI_API_KEY that OPENAI_BASE_URL binds to another host; (b) the pre-request Anthropic- # credential refresh ran for provider 'anthropic' on a foreign (alias) host.- 120299: ({"OPENAI_API_KEY": "sk-probe-bound-elsewhere", "OPENAI_BASE_URL": "http://127.0.0.1:9/v1"}, r'''-(HOME / "config.yaml").write_text("model:\n provider: custom\n default: m\n")-from hermes_cli.runtime_provider_backends import _resolve_openrouter_runtime-openrouter_leak = _resolve_openrouter_runtime(requested_provider="openrouter").get("api_key") == "sk-probe-bound-elsewhere"-from types import SimpleNamespace-from unittest.mock import MagicMock-import agent.anthropic_credentials as creds-from agent.client_lifecycle import ClientLifecycleMixin-creds.resolve_anthropic_token = lambda **_kw: "sk-ant-probe-refreshed"-agent = SimpleNamespace(api_mode="anthropic_messages", provider="anthropic", model="claude-probe",- _anthropic_api_key="", _anthropic_base_url="http://127.0.0.1:9",- _anthropic_client=MagicMock(), _build_direct_anthropic_client=lambda *a: MagicMock(),- _anthropic_oauth_flag=lambda _t: False)-refresh_leak = ClientLifecycleMixin._try_refresh_anthropic_client_credentials(agent) is True-verdict("open" if openrouter_leak or refresh_leak else "fixed")'''),# /model <id> --provider X adopted another provider's alias (its base_url and key) that# exposes the same model id.@@ -105,17 +82,6 @@ r = ms.switch_model("shared-model", "provider-a", "old-model", current_base_url=user_providers=load_config()["providers"])assert r.success, r.error_messageverdict("fixed" if (r.base_url, r.api_key) == ("https://api-b.example.com/v1", "sk-provider-b") else "open")-'''),- # tui_gateway: when the approval wait had already ended by the time the settle hook was- # attached (answered by RPC, resolved on another surface), the sent request was never- # withdrawn and stayed in open_requests.- 120374: ({}, r'''-from tui_gateway import server, server_requests-settled = []-server_requests.send_async = lambda method, sid, params, on_result: settled.append-server._sessions["probe"] = {"session_key": "probe-key"}-server._emit_approval_request("probe", {"request_id": "already-resolved", "description": "probe"})-verdict("fixed" if settled else "open")'''),}@@ -168,3 +134,18 @@ def expect_gaps(request: pytest.FixtureRequest, *gaps: Gap) -> None: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)))+++def known_failure(pattern: str, reason: str,+ raises: Type[BaseException] | Tuple[Type[BaseException], ...] = AssertionError) -> Iterator[None]:+ """Run-time xfail for a live gap: an exception of type ``raises`` raised inside the block whose+ message matches ``pattern`` (``re.search``) XFAILs the cell; any other failure propagates, and a+ clean pass stays a pass. Wrap only the final assertions, after every wait has settled, so a lost+ reply, a failed boot or a timeout can never be mistaken for the gap."""+ try:+ yield+ except raises as exc:+ if not re.search(pattern, str(exc)):+ raise+ pytest.xfail(f"{reason} [observed: {str(exc).splitlines()[0][:240]}]")diff --git a/tests/e2e/core/live/test_live_providers.py b/tests/e2e/core/live/test_live_providers.pyindex 71a11b4083d..f423b15aa6b 100644--- a/tests/e2e/core/live/test_live_providers.py+++ b/tests/e2e/core/live/test_live_providers.py@@ -13,11 +13,13 @@ per-test token + dollar guard. Usage and estimated cost are printed per testfrom __future__ import annotations+import contextlibfrom pathlib import Pathfrom urllib.parse import urlparseimport pytest+from tests.e2e.core._pending_fixes import known_failurefrom tests.e2e.core.live._helpers import (LISTING_PROVIDERS,LIVE_CASES,@@ -129,18 +131,17 @@ 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._KNOWN_LISTING_BUGS = {- # Native /v1beta/models rejects a Bearer AI-Studio key (401) and the picker silently- # falls back to the curated list. strict: flips red once the fix lands (drop the entry).- "gemini": "#62259 Gemini live model discovery sends Bearer auth (fix PRs #62267/#116509)",+ # 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",+ "#62259 Gemini live model discovery sends Bearer auth (fix PRs #62267/#116509)"),}[email protected]("provider", [- pytest.param(p, marks=pytest.mark.xfail(reason=_KNOWN_LISTING_BUGS[p], strict=True))- if p in _KNOWN_LISTING_BUGS else p- for p in sorted(LISTING_PROVIDERS)-])[email protected]("provider", sorted(LISTING_PROVIDERS))def test_models_listing_parses(provider: str, live_home: Path, monkeypatch: pytest.MonkeyPatch) -> None:key_env = LISTING_PROVIDERS[provider]secret = live_key(key_env)@@ -154,7 +155,9 @@ def test_models_listing_parses(provider: str, live_home: Path, monkeypatch: pyteassert _host_ok(urlparse(runtime["base_url"]).hostname or "", case.hosts), runtime["base_url"]models = [_normalize_id(str(m)) for m in _live_listing(provider, runtime)]- assert models, f"{provider}: live /models returned nothing ({wire.describe(wire.records)})"+ known = _KNOWN_LISTING_BUGS.get(provider)+ with known_failure(*known) if known else contextlib.nullcontext():+ assert models, f"{provider}: live /models returned nothing ({wire.describe(wire.records)})"assert all(isinstance(m, str) and m.strip() for m in models)wanted = {pref for c in LIVE_CASES if c.provider == provider for pref in c.model_prefs}assert wanted & set(models), f"{provider}: none of the canary models {sorted(wanted)} are listed"diff --git a/tests/e2e/core/tenancy/test_routing_truth_table.py b/tests/e2e/core/tenancy/test_routing_truth_table.pyindex cac700b778d..4120edad908 100644--- a/tests/e2e/core/tenancy/test_routing_truth_table.py+++ b/tests/e2e/core/tenancy/test_routing_truth_table.py@@ -301,17 +301,12 @@ def cli_outcomes(tmp_path_factory: pytest.TempPathFactory) -> dict[str, Any]:# Live gaps, applied only while their probe reproduces them (see _pending_fixes).-GAP_120299 = Gap(120299, "#120299: bare `provider: custom` with no endpoint falls through to OpenRouter and ships the "- "OPENAI_BASE_URL-bound OPENAI_API_KEY there; the pre-request Anthropic credential refresh "- "puts ANTHROPIC_API_KEY on an alias's foreign host", raises=RoutingLeak)GAP_120295 = Gap(120295, "#120295: `/model <id> --provider X` adopts another provider's alias (endpoint + key) ""for the same model id", raises=RoutingLeak)-KNOWN_GAPS = {"bare_custom_without_base_url_fails_fast": (GAP_120299,)}@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], request: pytest.FixtureRequest) -> None:- expect_gaps(request, *KNOWN_GAPS.get(case.id, ()))+def test_cli_routing_truth_table(case: Case, cli_outcomes: dict[str, Any]) -> None:fleet, outcomes = cli_outcomes[case.id].result(timeout=900)for i, out in enumerate(outcomes):leg, run = out.leg, out.run@@ -352,8 +347,8 @@ 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 onexactly the selected host with exactly its key, and nothing reaches any other host.- Leg 5 is #120295's cell, leg 6 #120299's."""- expect_gaps(request, GAP_120295, GAP_120299)+ Leg 5 is #120295's cell; leg 6 pins the #120299 fix."""+ expect_gaps(request, GAP_120295)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.pyindex 0c4a7fe85dd..ae04cc4eb4f 100644--- a/tests/e2e/core/tenancy/test_two_tenant_desktop_backend.py+++ b/tests/e2e/core/tenancy/test_two_tenant_desktop_backend.py@@ -102,8 +102,6 @@ def _await_cron(tenants: dict[str, H.Tenant], fires: int) -> None:# Live gaps, applied only while their probe reproduces them (see _pending_fixes).GAPS = (- Gap(120319, "#120319: session.create / the first state.db row use the launch profile's model and "- "model.save_key writes the launch profile's .env", raises=H.LaunchProfileBleed),# 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),diff --git a/tests/e2e/core/terminal/test_interactive_roundtrip.py b/tests/e2e/core/terminal/test_interactive_roundtrip.pyindex 72dbbe4fbf0..830bb3f45bb 100644--- a/tests/e2e/core/terminal/test_interactive_roundtrip.py+++ b/tests/e2e/core/terminal/test_interactive_roundtrip.py@@ -29,7 +29,6 @@ import threadingimport pytest-from tests.e2e.core._pending_fixes import Gap, expect_gapsfrom tests.e2e.core.terminal._gateway_client import Backend, WSClient, etype, poll_untilfrom tests.fakes.fake_llm_provider import Text, ToolCall@@ -214,22 +213,10 @@ CASES = []-# Applied only while the probe reproduces it (see _pending_fixes). A race in this cell, so not strict: the RPC-# answer can end the approval wait before the gateway attaches the hook that withdraws the sent request, which-# then stays in ``open_requests`` (red in about 1 in 4 loaded runs). Only ``PromptLeftPending`` is excused.-GAPS = {("approval_deny", "rpc"): Gap(- 120374, "#120374: an approval answered by RPC before the settle hook attaches stays in open_requests",- raises=PromptLeftPending, strict=False)}--@pytest.mark.parametrize(("kind", "how"), [pytest.param(k, h, id=f"{k}-{h}") for k, h in CASES])-def test_interactive_roundtrip(backend: Backend, script: Script, kind: str, how: str,- request: pytest.FixtureRequest) -> None:- if gap := GAPS.get((kind, how)):- expect_gaps(request, gap)+def test_interactive_roundtrip(backend: Backend, script: Script, kind: str, how: str) -> None:tag = f"{kind}_{how}".lower()try:_drive(backend, script, kind, how, tag)except AssertionError as exc:- # Keep the class: the gap's xfail excuses only PromptLeftPending.raise type(exc)(f"{kind}/{how}: {exc}\n{backend.logs(25)}") from Nonediff --git a/tests/e2e/core/terminal/test_terminal_transcript_pty.py b/tests/e2e/core/terminal/test_terminal_transcript_pty.pyindex 7e8532ca802..80e0f5669e6 100644--- a/tests/e2e/core/terminal/test_terminal_transcript_pty.py+++ b/tests/e2e/core/terminal/test_terminal_transcript_pty.py@@ -18,12 +18,14 @@ Invariants, checked on the settled final frame of every scenario:The ``resize`` scenarios change the terminal width while a long reply is streaming (SIGWINCH viathe PTY), the recurring "history re-appended on resize" shape. ``resize_scrollback`` replays it on-a normal 24-row classic-CLI terminal, where earlier turns already sit in scrollback: that case is a-strict xfail for the open live bug #95375 and turns red (XPASS) once it is fixed.+a normal 24-row classic-CLI terminal, where earlier turns already sit in scrollback: while the live+bug #95375 (fix PR #120321) duplicates them, that cell XFAILs on exactly that duplication and on+nothing else, and passes as a plain test once the fix lands."""from __future__ import annotations+import contextlibimport osimport shutilimport sys@@ -32,6 +34,7 @@ from pathlib import Pathimport pytest+from tests.e2e.core._pending_fixes import known_failurefrom tests.e2e.core.terminal._pty import REPO_ROOT, PtyHermes, canonfrom tests.fakes.fake_llm_provider import FakeLLMServer, Text, ToolCall@@ -126,15 +129,17 @@ SURFACES = {MATRIX = [("cli", "turns"),("cli", "resize"),- pytest.param("cli", "resize_scrollback", marks=pytest.mark.xfail(- strict=True, raises=DuplicateRender,- reason="LIVE BUG #95375 (open): a width-changing resize clears only the visible screen "- "(CSI 2J) and replays the last 200 output lines, so turns already in scrollback "- "are printed again. strict: this XPASSes (and fails) once it is fixed.")),+ ("cli", "resize_scrollback"),("tui", "turns"),("tui", "resize"),]+# Merge-order safe (see _pending_fixes.known_failure): only a turn rendered MORE than once excuses the cell.+KNOWN = {("cli", "resize_scrollback"): (+ r"(?:rendered|echoed) (?:[2-9]|\d{2,})x",+ "LIVE BUG #95375 (fix PR #120321): a width-changing resize clears only the visible screen (CSI 2J) and "+ "replays the last 200 output lines, so turns already in scrollback are printed again")}+@pytest.mark.parametrize(("surface", "scenario"), MATRIX)def test_terminal_transcript_integrity(surface: str, scenario: str, tmp_path: Path) -> None:@@ -168,23 +173,26 @@ def test_terminal_transcript_integrity(surface: str, scenario: str, tmp_path: Padump = "\n".join(final[-120:])positions = []- for turn in spec.turns:- n_reply = text.count(canon(turn.reply))- if n_reply != 1:- raise DuplicateRender(- f"[{surface}/{scenario}] assistant reply rendered {n_reply}x (want exactly 1, verbatim): "- f"{turn.reply[:60]!r}\n{dump}")- n_prompt = text.count(canon(turn.prompt))- if n_prompt != 1:- raise DuplicateRender(- f"[{surface}/{scenario}] user prompt echoed {n_prompt}x (want 1): {turn.prompt!r}\n{dump}")- positions += [text.index(canon(turn.prompt)), text.index(canon(turn.reply))]- if turn.tool_command:- n_cmd = text.count(canon(turn.tool_command))- assert n_cmd == 1, f"[{surface}/{scenario}] tool call rendered {n_cmd}x\n{dump}"- if turn.reasoning:- n_reason = text.count(canon(turn.reasoning))- assert n_reason <= 1, f"[{surface}/{scenario}] reasoning rendered {n_reason}x\n{dump}"+ known = KNOWN.get((surface, scenario))+ gate = known_failure(*known, raises=DuplicateRender) if known else contextlib.nullcontext()+ with gate:+ for turn in spec.turns:+ n_reply = text.count(canon(turn.reply))+ if n_reply != 1:+ raise DuplicateRender(+ f"[{surface}/{scenario}] assistant reply rendered {n_reply}x (want exactly 1, verbatim): "+ f"{turn.reply[:60]!r}\n{dump}")+ n_prompt = text.count(canon(turn.prompt))+ if n_prompt != 1:+ raise DuplicateRender(+ f"[{surface}/{scenario}] user prompt echoed {n_prompt}x (want 1): {turn.prompt!r}\n{dump}")+ positions += [text.index(canon(turn.prompt)), text.index(canon(turn.reply))]+ if turn.tool_command:+ n_cmd = text.count(canon(turn.tool_command))+ assert n_cmd == 1, f"[{surface}/{scenario}] tool call rendered {n_cmd}x\n{dump}"+ if turn.reasoning:+ n_reason = text.count(canon(turn.reasoning))+ assert n_reason <= 1, f"[{surface}/{scenario}] reasoning rendered {n_reason}x\n{dump}"assert positions == sorted(positions), (f"[{surface}/{scenario}] transcript out of conversation order\n{dump}")