From bcc2619326fd71f389b3cfded25855589161bf10 Mon Sep 17 00:00:00 2001 From: Agent Zero Date: Sun, 22 Nov 2026 16:28:40 +0000 Subject: [PATCH 1/6] fix(tests): publisher-discord httpx shim stops shadowing an installed httpx Root cause of main's red python-tests (43 flute-gateway failures since 2026-11-21): test_formatting.py ran `sys.modules.setdefault("httpx", SimpleNamespace(AsyncClient=...))` at import. setdefault only checks "already imported", not "installed", so in the shared "Run all service tests" pytest session it replaced the real httpx for every later test file. google-genai 3.x (unpinned by the CI union) reads `httpx.Client` at import, so flute-gateway's import chain died on the SimpleNamespace. The shim now applies only when httpx is not installed (channel-monitor's pattern). #3353 separately pins google-genai in the CI union, which removes the trigger; this removes the trap for the next importer. Evidence: - new test_shim_isolation.py fails on the old shim (AssertionError: SimpleNamespace), passes on the fix - google-genai 3.6.1 venv: main's test_formatting.py then `from google import genai` -> AttributeError 'SimpleNamespace' ... 'Client' (CI's exact error); fixed file -> import OK - publisher-discord 7/7; flute-gateway local failures identical with and without publisher-discord in the session (local numpy.long, env-only) Also carries this lane's register CLAIM row. Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_016aNs4qEbP262ySna8x9izc --- pmoves/docs/AGENTS/AGNOTE4482PHI.t1.md | 1 + .../tests/test_formatting.py | 9 +++- .../tests/test_shim_isolation.py | 50 +++++++++++++++++++ 3 files changed, 59 insertions(+), 1 deletion(-) create mode 100644 pmoves/services/publisher-discord/tests/test_shim_isolation.py diff --git a/pmoves/docs/AGENTS/AGNOTE4482PHI.t1.md b/pmoves/docs/AGENTS/AGNOTE4482PHI.t1.md index 7aa4614ac4..83cc7df8d3 100644 --- a/pmoves/docs/AGENTS/AGNOTE4482PHI.t1.md +++ b/pmoves/docs/AGENTS/AGNOTE4482PHI.t1.md @@ -3675,3 +3675,4 @@ VILLAGE RULE: delivery delegated to a delivery-agent body; control and memory ar - `2026-11-22T03:25:38Z` NOTE `5090-CLAUDE` branch: `feat/pmoves-launcher-generator` · scope: Correction to the 2026-09-22T16:25:00Z RELEASE of feat/pmoves-launcher-generator (line 3112): on origin/main the PowerShell twin mavis_sdk_env.ps1 carries NO audit-log append and no bash/ps1 twin audit-log ratchet exists. Both were in branch commit 4c7316d653c but were deleted by merge 0a033c59b62 (2026-09-28, conflict resolution inside #3184, which merged 3 s before GitHub auto-marked #3149 MERGED). Bash audit log and pmoves/tools/mavis_sdk_audit.py did land. Restored by lane fix/mavis-sdk-ps1-audit-and-twin-ratchet-2026-11-21. - `2026-11-22T04:27:57Z` RELEASE `5090-CLAUDE` · scope: All-lanes closeout of 5090-CLAUDE after verifying delivered content on origin/main (not PR state). Delivered via merged PRs: docs/5090-runbook-surfaces-2026-11-06 (#3462), fix/fork-sync-utf8-decode-and-pipecat-provenance (#3429), fix/mcp-inventory-endpoint-ratchet (#3428), fix/ratchet-upstream-matrix-and-shim-origin (#3427), docs/cipher-capacity-profiles (#3355), docs/overlay-anti-pattern-reviewer-gate (#3347), fix/cipher-mcp-streamable-roster (#3339), feat/test-ratchet-kilo-minimax (#3095), feat/pmoves-cipher-cli-and-mcp (#3093), fix/mavis-sdk-ps1-audit-and-twin-ratchet-2026-11-21 (#3513, merge 0d981049ddb). Mavis SDK lanes: feat/pmoves-mavis-sdk-env (two rows) and feat/pmoves-launcher-env-parity-rerun landed through #3092 and #3149 under feat/pmoves-launcher-generator; feat/mavis-launcher-parity-crush and feat/mavis-sdk-audit-log landed partially through #3149 and were completed by #3513, which restored the PowerShell audit append and bash/ps1 twin ratchet dropped by merge 0a033c59b62, and fixed the restored block so it writes a line under PowerShell 5.1 and 7 (format-string braces, -AsUTC), with a behavioural test. See the NOTE correcting line 3112. CHIT trail unsigned on this host. - `2026-11-22T05:19:01Z` NOTE `5090-CLAUDE` · scope: ACK for the 2026-11-22T04:27:57Z all-lanes RELEASE row (5090-CLAUDE). Handoff fields: graphiti_mark: sitrep.5090-claude.2026-11-22T04:27Z; branch: fix/mavis-sdk-ps1-audit-and-twin-ratchet-2026-11-21 plus the nine delivered lanes and four Mavis SDK rows named in the RELEASE; pr_numbers: #3513 (merge 0d981049ddb, mergedAt 2026-11-22T04:27:08Z), #3462 #3429 #3428 #3427 #3355 #3347 #3339 #3095 #3093, #3092/#3149 for the Mavis SDK rows; scope: delivered content verified on origin/main (ToUniversalTime, doubled -f braces, log_parent, matches_across_twins, MavisSdkEnvPs1AuditTest, test_mavis_sdk_env_audit.ps1 all present at 0d981049ddb); risks: the ps1 audit block had never written a line before #3513, so any audit-log consumer assuming PowerShell history before 2026-11-22 has none; next_actions: operator decides the node main checkout catch-up (177 behind, inventory presented 2026-11-21) and the fork v* tag; chit_artifact_path: CHIT trail SIGNED via make sign-trail (HMAC-SHA256, kid chit-signing-v01, hmac EtnZSkXJvFq4gpYOb46TWpqvwDyxjfBrWIJd9xXsD9E=), which corrects the RELEASE row's 'unsigned on this host' line; agent_signature: ACK::5090-CLAUDE::ALL-LANES-RELEASE-2026-11-22. Filed on PR 3514 for codex P1 thread PRRT_kwDOPkuAKM66gUPB. +- `2026-11-22T16:25:01Z` CLAIM `spark-claude` branch: `fix/httpx-stub-test-pollution` · **TTL 24h (expires `2026-11-23T16:25:01Z`)** · scope: Main python-tests red: 43 flute-gateway failures (SimpleNamespace has no Client/ConnectError), also failing #3490/#3388. Suspect module-level sys.modules httpx stubs in other services tests leaking across the session. Scope httpx stubs per-test; tests only, no service code. diff --git a/pmoves/services/publisher-discord/tests/test_formatting.py b/pmoves/services/publisher-discord/tests/test_formatting.py index ea670f658d..41f7e3a68a 100644 --- a/pmoves/services/publisher-discord/tests/test_formatting.py +++ b/pmoves/services/publisher-discord/tests/test_formatting.py @@ -1,3 +1,4 @@ +import importlib.util import sys from pathlib import Path from types import ModuleType, SimpleNamespace @@ -14,7 +15,13 @@ async def __aexit__(self, exc_type, exc, tb): return False -sys.modules.setdefault("httpx", SimpleNamespace(AsyncClient=_DummyAsyncClient)) +# Stub httpx ONLY when it is not installed. A bare setdefault() also fired when +# httpx was installed but not yet imported, replacing it for the whole pytest +# session and breaking later importers (google-genai 3.x reads httpx.Client at +# import; 43 flute-gateway failures on main, 2026-11-21). See +# test_shim_isolation.py. +if importlib.util.find_spec("httpx") is None: + sys.modules.setdefault("httpx", SimpleNamespace(AsyncClient=_DummyAsyncClient)) class _DummyFastAPI: diff --git a/pmoves/services/publisher-discord/tests/test_shim_isolation.py b/pmoves/services/publisher-discord/tests/test_shim_isolation.py new file mode 100644 index 0000000000..92c8ef0f3f --- /dev/null +++ b/pmoves/services/publisher-discord/tests/test_shim_isolation.py @@ -0,0 +1,50 @@ +"""The formatting tests' import shims must not shadow an installed httpx. + +test_formatting.py runs in the same pytest session as other services' tests +(python-tests.yml "Run all service tests"). A module-level +``sys.modules.setdefault("httpx", SimpleNamespace(...))`` replaced httpx for +the WHOLE session whenever nothing had imported the real one yet, so any later +import that reads ``httpx.`` at import time broke -- google-genai 3.x's +``HttpxClient = httpx.Client`` failed 43 flute-gateway tests on main +(2026-11-21). The shim is for minimal environments where httpx is absent. +""" + +import importlib.util +import os +import subprocess +import sys +from pathlib import Path + +import pytest + +TEST_FILE = Path(__file__).with_name("test_formatting.py") + + +@pytest.mark.skipif( + importlib.util.find_spec("httpx") is None, + reason="httpx not installed: the shim is supposed to apply", +) +def test_formatting_shim_leaves_installed_httpx_alone(): + # Fresh interpreter, so the real httpx has NOT been imported yet -- the + # exact state in which setdefault() used to install the stub. + probe = ( + "import importlib.util, sys\n" + f"spec = importlib.util.spec_from_file_location('tf', {str(TEST_FILE)!r})\n" + "mod = importlib.util.module_from_spec(spec)\n" + "spec.loader.exec_module(mod)\n" + "import httpx\n" + "assert hasattr(httpx, 'Client'), type(httpx).__name__\n" + ) + pmoves_dir = TEST_FILE.parents[3] # tests -> publisher-discord -> services -> pmoves + env = dict(os.environ) + env["PYTHONPATH"] = os.pathsep.join( + p for p in (str(pmoves_dir), env.get("PYTHONPATH", "")) if p + ) + result = subprocess.run( + [sys.executable, "-c", probe], + capture_output=True, + text=True, + cwd=pmoves_dir, + env=env, + ) + assert result.returncode == 0, result.stderr[-2000:] From 0e003f07683061db857a55f38b653ced022d1570 Mon Sep 17 00:00:00 2001 From: POWERFULMOVES <142271328+POWERFULMOVES@users.noreply.github.com> Date: Wed, 25 Nov 2026 01:24:37 -0500 Subject: [PATCH 2/6] docs(register): 5090-CLAUDE takes the httpx-shim lane by baton from spark-claude (TTL expired 2026-11-23) spark-claude's 24h CLAIM on fix/httpx-stub-test-pollution expired with no renewal, RELEASE, or push after bcc2619; PR #3517 sat DIRTY against main. Operator assigned the open lane to 5090 on 2026-11-25. Baton RELEASE then CLAIM, per the register tool's handoff grammar. Co-Authored-By: Claude Fable 5.1 Claude-Session: https://claude.ai/code/session_016aNs4q8tajdg1rcgaacrWS --- pmoves/docs/AGENTS/AGNOTE4482PHI.t1.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/pmoves/docs/AGENTS/AGNOTE4482PHI.t1.md b/pmoves/docs/AGENTS/AGNOTE4482PHI.t1.md index 83cc7df8d3..6700c1b24d 100644 --- a/pmoves/docs/AGENTS/AGNOTE4482PHI.t1.md +++ b/pmoves/docs/AGENTS/AGNOTE4482PHI.t1.md @@ -3676,3 +3676,5 @@ VILLAGE RULE: delivery delegated to a delivery-agent body; control and memory ar - `2026-11-22T04:27:57Z` RELEASE `5090-CLAUDE` · scope: All-lanes closeout of 5090-CLAUDE after verifying delivered content on origin/main (not PR state). Delivered via merged PRs: docs/5090-runbook-surfaces-2026-11-06 (#3462), fix/fork-sync-utf8-decode-and-pipecat-provenance (#3429), fix/mcp-inventory-endpoint-ratchet (#3428), fix/ratchet-upstream-matrix-and-shim-origin (#3427), docs/cipher-capacity-profiles (#3355), docs/overlay-anti-pattern-reviewer-gate (#3347), fix/cipher-mcp-streamable-roster (#3339), feat/test-ratchet-kilo-minimax (#3095), feat/pmoves-cipher-cli-and-mcp (#3093), fix/mavis-sdk-ps1-audit-and-twin-ratchet-2026-11-21 (#3513, merge 0d981049ddb). Mavis SDK lanes: feat/pmoves-mavis-sdk-env (two rows) and feat/pmoves-launcher-env-parity-rerun landed through #3092 and #3149 under feat/pmoves-launcher-generator; feat/mavis-launcher-parity-crush and feat/mavis-sdk-audit-log landed partially through #3149 and were completed by #3513, which restored the PowerShell audit append and bash/ps1 twin ratchet dropped by merge 0a033c59b62, and fixed the restored block so it writes a line under PowerShell 5.1 and 7 (format-string braces, -AsUTC), with a behavioural test. See the NOTE correcting line 3112. CHIT trail unsigned on this host. - `2026-11-22T05:19:01Z` NOTE `5090-CLAUDE` · scope: ACK for the 2026-11-22T04:27:57Z all-lanes RELEASE row (5090-CLAUDE). Handoff fields: graphiti_mark: sitrep.5090-claude.2026-11-22T04:27Z; branch: fix/mavis-sdk-ps1-audit-and-twin-ratchet-2026-11-21 plus the nine delivered lanes and four Mavis SDK rows named in the RELEASE; pr_numbers: #3513 (merge 0d981049ddb, mergedAt 2026-11-22T04:27:08Z), #3462 #3429 #3428 #3427 #3355 #3347 #3339 #3095 #3093, #3092/#3149 for the Mavis SDK rows; scope: delivered content verified on origin/main (ToUniversalTime, doubled -f braces, log_parent, matches_across_twins, MavisSdkEnvPs1AuditTest, test_mavis_sdk_env_audit.ps1 all present at 0d981049ddb); risks: the ps1 audit block had never written a line before #3513, so any audit-log consumer assuming PowerShell history before 2026-11-22 has none; next_actions: operator decides the node main checkout catch-up (177 behind, inventory presented 2026-11-21) and the fork v* tag; chit_artifact_path: CHIT trail SIGNED via make sign-trail (HMAC-SHA256, kid chit-signing-v01, hmac EtnZSkXJvFq4gpYOb46TWpqvwDyxjfBrWIJd9xXsD9E=), which corrects the RELEASE row's 'unsigned on this host' line; agent_signature: ACK::5090-CLAUDE::ALL-LANES-RELEASE-2026-11-22. Filed on PR 3514 for codex P1 thread PRRT_kwDOPkuAKM66gUPB. - `2026-11-22T16:25:01Z` CLAIM `spark-claude` branch: `fix/httpx-stub-test-pollution` · **TTL 24h (expires `2026-11-23T16:25:01Z`)** · scope: Main python-tests red: 43 flute-gateway failures (SimpleNamespace has no Client/ConnectError), also failing #3490/#3388. Suspect module-level sys.modules httpx stubs in other services tests leaking across the session. Scope httpx stubs per-test; tests only, no service code. +- `2026-11-25T06:23:51Z` RELEASE `5090-CLAUDE` branch: `fix/httpx-stub-test-pollution` · baton-from: `spark-claude` · scope: Baton: spark-claude opened this lane 2026-11-22T16:25:01Z with TTL 24h; it expired 2026-11-23T16:25:01Z with no renewal, no RELEASE, and no push after bcc2619, and PR #3517 sat DIRTY against main. The operator assigned the open lane to 5090 on 2026-11-25. Closing the holder row so 5090-CLAUDE can re-claim; the fix itself (test_formatting.py httpx shim gated on find_spec, test_shim_isolation.py) is carried forward unchanged. +- `2026-11-25T06:23:56Z` CLAIM `5090-CLAUDE` branch: `fix/httpx-stub-test-pollution` · **TTL 72h (expires `2026-11-28T06:23:56Z`)** · scope: Adopt PR #3517 (closes #3510). Re-anchor on main by merge; drop the 11 semantic-cache entries the Merge Gate ratchet reported STALE at bcc2619 (140 findings, 0 new, 11 no longer fail: the httpx shim was breaking those too); land so the standing tests (3.11) advisory waivers (#3368, #3498, #3521 pending) stop. Tests and ratchet baseline only, no service code. From b4ba68051a20945b34df549b78369c4838d80440 Mon Sep 17 00:00:00 2001 From: POWERFULMOVES <142271328+POWERFULMOVES@users.noreply.github.com> Date: Wed, 25 Nov 2026 02:25:13 -0500 Subject: [PATCH 3/6] fix(ratchet): a pytest INTERNALERROR no longer reads as a green chunk; the TTS CLI skips under pytest The python-tests ratchet trusted any JUnit report that existed. pytest writes one even when the session aborts with INTERNALERROR (exit 3), holding only what was collected before the abort, so every later test in the chunk was read as "no failures here". Measured 2026-11-25 on Merge Gate run 45044058125: pmoves/tools/ test_all_tts_engines.py is a CLI against a live TTS Studio whose name matches test_*.py, and it called sys.exit(1) at import when gradio_client is absent. That aborted chunk `pmoves [4]` on every run on record (19 files, zero test results, 3 sso-auth collection errors recorded before the abort). When this branch added a test file earlier in the sort order, the chunk boundary moved, 11 baselined semantic-cache errors landed in the aborted chunk, and the gate reported them STALE -- fixed -- and told the author to drop them. - pytest_ratchet.py: exit 3 is a LOST chunk like a timeout. The partial report is not returned as the result; the chunk is isolated per file, and the file that aborts is recorded as an `ERROR||` finding so it is visible and ratchetable instead of silently passing. - test_all_tts_engines.py: under pytest, a missing gradio_client is a module-level skip that says what the file is. As a CLI it still prints the install hint and exits 1. - test_pytest_ratchet.py: six cases for the abort path (partial report not trusted, aborting file keyed as a finding, siblings keep results, single-file abort, abort vs hang in one chunk, detail cap). 49 pass. Chunk `pmoves [4]` re-run locally with the ratchet's options after this change: no INTERNALERROR, the CLI skipped, and the 11 test_cache errors are present -- they patch `pmoves.services.semantic_cache.*`, an alias the services shim does not define, and were never httpx-related. The baseline is unchanged here; what the measured chunk surfaces in CI is recorded in the next commit with a note. Co-Authored-By: Claude Fable 5.1 Claude-Session: https://claude.ai/code/session_016aNs4q8tajdg1rcgaacrWS --- pmoves/tests/tools/test_pytest_ratchet.py | 84 ++++++++++++++++++++++- pmoves/tools/pytest_ratchet.py | 73 +++++++++++++++++--- pmoves/tools/test_all_tts_engines.py | 14 ++++ 3 files changed, 158 insertions(+), 13 deletions(-) diff --git a/pmoves/tests/tools/test_pytest_ratchet.py b/pmoves/tests/tools/test_pytest_ratchet.py index 1c61da453c..fbe83b6732 100644 --- a/pmoves/tests/tools/test_pytest_ratchet.py +++ b/pmoves/tests/tools/test_pytest_ratchet.py @@ -510,22 +510,34 @@ def test_a_prose_line_outside_the_block_is_not_reported(self): # that actually hang. class _FakeRun: - """Stands in for run_pytest: writes a report for every file except the hangs.""" + """Stands in for run_pytest: writes a report for every file except the hangs. - def __init__(self, hangs, chunk_times_out=True): + `aborts` names files that make pytest exit 3 (INTERNALERROR). Like the real + thing, an aborting run still WRITES a report -- partial -- which is the + whole trap: a chunk containing one abort returns 3 with a report present. + """ + + def __init__(self, hangs, chunk_times_out=True, aborts=()): self.hangs = set(hangs) + self.aborts = set(aborts) self.chunk_times_out = chunk_times_out self.calls = [] def __call__(self, files, junit, timeout=None): self.calls.append(([str(f) for f in files], timeout)) if len(files) > 1: + if any(str(f) in self.aborts for f in files): + junit.write_text("", encoding="utf-8") + return 3, "INTERNALERROR> SystemExit: 1" if self.chunk_times_out: return -1, "TIMEOUT" junit.write_text("", encoding="utf-8") return 0, "" if str(files[0]) in self.hangs: return -1, "TIMEOUT" + if str(files[0]) in self.aborts: + junit.write_text("", encoding="utf-8") + return 3, "INTERNALERROR> SystemExit: 1" junit.write_text("", encoding="utf-8") return 0, "" @@ -613,3 +625,71 @@ def test_budget_exhaustion_reports_the_rest_as_unmeasured(monkeypatch, tmp_path) findings, dead = _run_fallback(monkeypatch, tmp_path, ["a.py", "b.py"], fake) assert set(dead) == {"a.py", "b.py"} assert len(fake.calls) == 1 # chunk only; no file ever ran + + +# ── a chunk aborted by pytest INTERNALERROR (exit 3) ──────────────────────── +# +# Unlike a timeout, an aborted session still writes its JUnit report, holding +# only what was collected before the abort. Measured 2026-11-25 (Merge Gate +# python-tests, run 45044058125): pmoves/tools/test_all_tts_engines.py called +# sys.exit(1) at import, chunk `pmoves [4]` returned 3 with a report of 3 +# collection errors, and the other 19 files read as having no failures. When a +# new test file shifted the chunk boundary, 11 baselined errors moved into that +# chunk and were reported STALE -- "fixed". A partial report is not a report. + +def _internal_errors(findings): + return [f for f in findings if f["name"] == ""] + + +def test_partial_report_after_an_abort_is_not_trusted(monkeypatch, tmp_path): + """The trap: exit 3 WITH a report present. The chunk must still be isolated.""" + fake = _FakeRun(hangs=[], aborts=["abort.py"]) + findings, dead = _run_fallback(monkeypatch, tmp_path, ["a.py", "abort.py", "c.py"], fake) + assert len(fake.calls) == 1 + 3 # chunk, then one per file + assert dead == [] # nothing is unmeasured: we know what aborted + + +def test_the_aborting_file_is_a_finding_keyed_on_the_file(monkeypatch, tmp_path): + fake = _FakeRun(hangs=[], aborts=["abort.py"]) + findings, _ = _run_fallback(monkeypatch, tmp_path, ["a.py", "abort.py", "c.py"], fake) + errs = _internal_errors(findings) + assert [f["where"] for f in errs] == ["abort.py"] + assert errs[0]["kind"] == "ERROR" + assert pytest_ratchet._key(errs[0]) == "ERROR|abort.py|" + assert "SystemExit" in errs[0]["detail"] + + +def test_siblings_of_an_aborting_file_keep_their_results(monkeypatch, tmp_path): + """The point of isolating: one sys.exit must not cost 19 files their results.""" + fake = _FakeRun(hangs=[], aborts=["abort.py"]) + finding = {"kind": "FAIL", "where": "x", "name": "y", "detail": ""} + findings, dead = _run_fallback(monkeypatch, tmp_path, ["a.py", "abort.py"], fake, + parsed=[finding]) + # a.py reports its finding; abort.py reports its (partial) report AND the abort + assert findings.count(finding) == 2 + assert len(_internal_errors(findings)) == 1 + assert dead == [] + + +def test_single_file_abort_is_recorded_not_dead(monkeypatch, tmp_path): + fake = _FakeRun(hangs=[], aborts=["only.py"]) + findings, dead = _run_fallback(monkeypatch, tmp_path, ["only.py"], fake) + assert dead == [] + assert [f["where"] for f in _internal_errors(findings)] == ["only.py"] + assert len(fake.calls) == 1 + + +def test_abort_and_hang_in_one_chunk_are_told_apart(monkeypatch, tmp_path): + fake = _FakeRun(hangs=["hang.py"], aborts=["abort.py"]) + findings, dead = _run_fallback(monkeypatch, tmp_path, ["a.py", "abort.py", "hang.py"], fake) + assert dead == ["hang.py"] + assert [f["where"] for f in _internal_errors(findings)] == ["abort.py"] + + +def test_internal_error_detail_is_the_last_output_line_capped(monkeypatch, tmp_path): + out = "junk\nINTERNALERROR> " + "x" * 400 + "\n\n" + f = pytest_ratchet._internal_error_finding(Path("abort.py"), out) + assert f["detail"].startswith("INTERNALERROR>") + assert len(f["detail"]) == 160 + assert pytest_ratchet._internal_error_finding(Path("abort.py"), "")["detail"] \ + == "pytest exited 3 (INTERNALERROR)" diff --git a/pmoves/tools/pytest_ratchet.py b/pmoves/tools/pytest_ratchet.py index fc4e55a77f..4b97d92fb0 100644 --- a/pmoves/tools/pytest_ratchet.py +++ b/pmoves/tools/pytest_ratchet.py @@ -444,17 +444,51 @@ def write_baseline(findings: List[dict]) -> None: BASELINE.write_text("\n".join(lines) + "\n", encoding="utf-8") +# pytest's ExitCode.INTERNAL_ERROR. Raised for an exception that escapes the +# session itself -- the one that matters here is SystemExit during COLLECTION: +# a `test_*.py` that is really a CLI script and calls `sys.exit(1)` at import +# when a dependency is missing. `--continue-on-collection-errors` does not cover +# it (it is not a collection error, it is the interpreter being told to stop). +# pytest still writes the JUnit report on the way out, holding ONLY what was +# collected before the abort, so the report is partial and looks complete. +# +# MEASURED 2026-11-25 (Merge Gate python-tests, run 45044058125): +# pmoves/tools/test_all_tts_engines.py did exactly this to chunk `pmoves [4]`. +# Every test in that 20-file chunk was unmeasured on every run on record, and +# when a new test file elsewhere shifted the chunk boundary, 11 baselined +# semantic-cache errors moved INTO the aborted chunk and this tool reported +# them as STALE -- "fixed" -- with the recommended remedy being to drop them. +# A partial report after exit 3 is therefore never taken at face value. +PYTEST_INTERNAL_ERROR = 3 + + +def _internal_error_finding(path: Path, output: str) -> dict: + """The abort itself, as a finding: visible, keyed on the file, ratchetable.""" + lines = [ln for ln in output.strip().splitlines() if ln.strip()] + detail = lines[-1].strip() if lines else "pytest exited 3 (INTERNALERROR)" + return { + "kind": "ERROR", + "where": str(path).replace(chr(92), "/"), + "name": "", + "detail": detail[:160], + } + + def run_chunk_with_fallback(group: str, gfiles: List[Path], tmp: Path, index: int) -> tuple[List[dict], List[str]]: - """Run a group; if it times out, re-run it one file at a time. + """Run a group; if it is lost, re-run it one file at a time. Returns (findings, dead_labels). `dead_labels` names whatever stayed unmeasured -- the whole group if the fallback could not run, or the specific files that hang. - A timed-out chunk is killed before pytest writes its JUnit report, so - treating the timeout as one opaque "no report" discards every result in the - chunk. Isolating per file narrows the loss to the file that actually hangs. + A chunk is LOST two ways. A timed-out chunk is killed before pytest writes + its JUnit report, so treating the timeout as one opaque "no report" discards + every result in the chunk. A chunk that pytest aborts with INTERNALERROR + (exit 3) DOES get a report, but a partial one, and reading it as complete + turns every uncollected test into a silent pass. Isolating per file narrows + either loss to the file that actually hangs or aborts; an aborting file is + recorded as an `` finding rather than as nothing. The per-file budget is FALLBACK_FILE_TIMEOUT plus the file's own declared allowance, so a file that is merely SLOW is measured in the isolation pass @@ -462,12 +496,19 @@ def run_chunk_with_fallback(group: str, gfiles: List[Path], tmp: Path, """ junit = tmp / f"report-{index}.xml" rc, output = run_pytest(gfiles, junit) - if junit.is_file(): + if junit.is_file() and rc != PYTEST_INTERNAL_ERROR: return parse_junit(junit), [] - if rc != -1 or len(gfiles) <= 1: - # Not a timeout (unimportable conftest, usage error, crash), or nothing - # left to split. Per-file isolation cannot help either case. + if rc == PYTEST_INTERNAL_ERROR and len(gfiles) <= 1: + # Nothing left to split. Keep whatever the partial report holds and + # record the abort against the file, so it cannot read as passing. + sys.stderr.write("--- %s aborted pytest (exit 3) ---%s%s%s" % ( + group, chr(10), output[-1500:], chr(10))) + return parse_junit(junit) + [_internal_error_finding(gfiles[0], output)], [] + + if rc not in (-1, PYTEST_INTERNAL_ERROR) or len(gfiles) <= 1: + # Not a timeout or an abort (unimportable conftest, usage error, crash), + # or nothing left to split. Per-file isolation cannot help either case. sys.stderr.write("--- no report for %s (exit %d) ---%s%s%s" % ( group, rc, chr(10), output[-1500:], chr(10))) return [], [group] @@ -476,9 +517,10 @@ def run_chunk_with_fallback(group: str, gfiles: List[Path], tmp: Path, # declared-slow file can consume more than the flat default on its own, # so the pass must be able to afford it. pass_budget = fallback_budget_seconds(gfiles) + reason = "timed out" if rc == -1 else "aborted pytest (exit 3)" sys.stderr.write( - "--- %s timed out; isolating %d files (budget %ds) ---%s" % ( - group, len(gfiles), pass_budget, chr(10))) + "--- %s %s; isolating %d files (budget %ds) ---%s" % ( + group, reason, len(gfiles), pass_budget, chr(10))) findings: List[dict] = [] dead: List[str] = [] @@ -497,10 +539,19 @@ def run_chunk_with_fallback(group: str, gfiles: List[Path], tmp: Path, start = time.monotonic() frc, foutput = run_pytest([f], sub, timeout=file_timeout_seconds(f)) spent += time.monotonic() - start + label = str(f).replace(chr(92), "/") if sub.is_file(): findings.extend(parse_junit(sub)) + if frc == PYTEST_INTERNAL_ERROR: + # The report (if any) holds what was collected before the abort; + # the abort itself is the finding. Not a dead label: we know + # exactly which file did it and why. + sys.stderr.write("--- %s aborted pytest (exit 3) ---%s%s%s" % ( + label, chr(10), foutput[-600:], chr(10))) + findings.append(_internal_error_finding(f, foutput)) + continue + if sub.is_file(): continue - label = str(f).replace(chr(92), "/") sys.stderr.write("--- no report for %s (exit %d) ---%s%s%s" % ( label, frc, chr(10), foutput[-600:], chr(10))) dead.append(label) diff --git a/pmoves/tools/test_all_tts_engines.py b/pmoves/tools/test_all_tts_engines.py index de5406f99e..ca28854093 100644 --- a/pmoves/tools/test_all_tts_engines.py +++ b/pmoves/tools/test_all_tts_engines.py @@ -55,6 +55,20 @@ try: from gradio_client import Client except ImportError: + if "pytest" in sys.modules: + # This is a CLI against a live TTS Studio, not a pytest suite, but its + # name matches `test_*.py`, so the python-tests ratchet collects it. + # Under pytest, `sys.exit(1)` here is an INTERNALERROR during + # collection: it aborted the whole 20-file chunk this file sat in and + # pytest wrote a partial report that read as "no failures" for every + # other file in the chunk (measured 2026-11-25, Merge Gate run + # 45044058125). A module-level skip says what happened instead. + import pytest + + pytest.skip( + "CLI script, not a test module; gradio_client is not installed", + allow_module_level=True, + ) print("ERROR: gradio_client required. Install with: pip install gradio_client") sys.exit(1) From 5e63a25978f82cfead5c73607b3a1ae6f94f75a0 Mon Sep 17 00:00:00 2001 From: POWERFULMOVES <142271328+POWERFULMOVES@users.noreply.github.com> Date: Wed, 25 Nov 2026 02:25:14 -0500 Subject: [PATCH 4/6] docs(register): 5090-CLAUDE NOTE -- scope correction for the httpx-shim lane (STALE entries were an aborted chunk, not fixes) Co-Authored-By: Claude Fable 5.1 Claude-Session: https://claude.ai/code/session_016aNs4q8tajdg1rcgaacrWS --- pmoves/docs/AGENTS/AGNOTE4482PHI.t1.md | 1 + 1 file changed, 1 insertion(+) diff --git a/pmoves/docs/AGENTS/AGNOTE4482PHI.t1.md b/pmoves/docs/AGENTS/AGNOTE4482PHI.t1.md index 5d0eed7f1e..f698b4c834 100644 --- a/pmoves/docs/AGENTS/AGNOTE4482PHI.t1.md +++ b/pmoves/docs/AGENTS/AGNOTE4482PHI.t1.md @@ -3693,3 +3693,4 @@ VILLAGE RULE: delivery delegated to a delivery-agent body; control and memory ar - `2026-11-23T20:45:43Z` CLAIM `pmoves-hermes-elder` branch: `docs/register-wave-zero-1106` - **TTL 48h (expires `2026-11-25T20:45:43Z`)** - scope: WAVE-ZERO lane renewal - campaign concluded 2026-11-20 (board #462 final wrap), lane disposition idle; manual renewal after cron cadence stall (last cron renewal c3c33173c); register maintenance standing duty - `2026-11-23T21:02:58Z` NOTE `pmoves-hermes-elder` branch: `docs/register-wave-zero-1106` · scope: ERRATUM to CLAIM 2026-11-23T20:45:43Z (commit 75af5f8bc): its commit-message wording "cadence stall detected" is WRONG — register-renew-cron (job 22bbf1bc530b) healthy (720m cadence, guard renews only at expiry-6h; 2026-11-23T13:16:48Z run SKIPped correctly, ~10.9h margin); manual renewal pre-empted a PROJECTED ~71min lapse gap (prior expiry 2026-11-24T00:05:45Z; projected next fire ~2026-11-24T01:16Z lands post-expiry); no stall existed; structural: 6h guard threshold < 12h fire cadence guarantees a lapse window every 48h cycle (cron receipts flagged it 4 consecutive runs) — threshold/cadence fix proposed to operator, pending word - `2026-11-24T13:36:51Z` RELEASE `5090-CLAUDE` branch: `fix/openroom-root-redirect-2026-11-23` · scope: DELIVERED PR #3527: PMOVES-OpenRoom gitlink 9233894 -> aec292e (fork #19 merged: absolute_redirect off). Root cause: nginx absolute redirects carried the CONTAINER port 3000 through the 5173:3000 publish mapping, so the operator's bare-root URL landed on the wrong host service. Reviewed APPROVE by code-review body with live nginx A/B on the Dockerfile image; two nits taken (topology trimmed from public comment, PR body records the implicit directory-redirect fix); lint-and-build green. 5090 rebuilt via build-svc + recreate-svc: GET / -> 301 Location: /webuiapps/ -> 200, same via the tailnet name. Awaiting checks + Control ACK + closeout merge. +- `2026-11-25T07:20:02Z` NOTE `5090-CLAUDE` branch: `fix/httpx-stub-test-pollution` · scope: Scope correction for the 06:23:56Z CLAIM: the 11 semantic-cache entries the Merge Gate reported STALE at bcc2619 are NOT fixed and will NOT be dropped. Measured locally with the ratchet chunking (pytest 9.2.0, 20-file chunks of the pmoves group): the new test file shifts chunk boundaries, moving test_cache.py into chunk [4], and pmoves/tools/test_all_tts_engines.py calls sys.exit(1) at import when gradio_client is absent, so chunk [4] aborts with INTERNALERROR during collection and pytest writes a partial junit (3 sso-auth collection errors, nothing else). The ratchet reads absence as fixed. On main that chunk has never produced a test result (19 files unmeasured every run). Lane now also: guard that script so it skips under pytest, make the ratchet treat pytest exit 3 as a lost chunk (isolate per file, record an finding), and baseline what CI then surfaces, with a header note. The test_cache errors themselves are an alias gap (pmoves.services.semantic_cache is not in the services shim), separate issue to follow. From 7948cfd4987fb900a40c60558114da05aa669971 Mon Sep 17 00:00:00 2001 From: POWERFULMOVES <142271328+POWERFULMOVES@users.noreply.github.com> Date: Wed, 25 Nov 2026 02:49:32 -0500 Subject: [PATCH 5/6] test(ratchet): record the 17 failures chunk `pmoves [4]` surfaced once it ran; drop the stale internal-error entry (151 -> 167) CI run 45567996955 on this branch, the first Merge Gate run in which chunk `pmoves [4]` reached its tests: 17 NEW findings, all semantic-cache, all the same undefined `pmoves.services.semantic_cache` alias as the 11 baselined test_cache entries (#3529): 9 FAIL in test_cipher_layer, 8 ERROR in test_proxy. One STALE: `ERROR|pytest|internal`, pytest's own junit record of the abort, which no longer happens because the CLI now skips under pytest. Entries copied from the run log, not from --write-baseline (off CI it would record this machine). Header note says what the silence contained, same shape as the 2026-08-19 timeout-fallback note. Co-Authored-By: Claude Fable 5.1 Claude-Session: https://claude.ai/code/session_016aNs4q8tajdg1rcgaacrWS --- .../pytest_ratchet/_known_failures.yaml | 36 ++++++++++++++++++- 1 file changed, 35 insertions(+), 1 deletion(-) diff --git a/pmoves/configs/pytest_ratchet/_known_failures.yaml b/pmoves/configs/pytest_ratchet/_known_failures.yaml index 3439bbd3ca..b9616b1a19 100644 --- a/pmoves/configs/pytest_ratchet/_known_failures.yaml +++ b/pmoves/configs/pytest_ratchet/_known_failures.yaml @@ -14,6 +14,24 @@ # goal; adding one should require saying why in the PR. A fixed test that is # still listed here fails the gate as a STALE entry, so the count only goes down. # +# 2026-11-25 -- 151 -> 167 (+17, -1). Chunk `pmoves [4]` of the gate had never +# produced a test result: pmoves/tools/test_all_tts_engines.py (a CLI whose name +# matches test_*.py) called sys.exit(1) at import, pytest aborted the session +# with INTERNALERROR during collection and still wrote a report holding only +# what it had collected so far, and the ratchet took that partial report as +# complete. The abort itself was the one entry `ERROR|pytest|internal` (pytest's +# junit record of an internal error); every test the chunk should have measured +# read as passing. When a new test file shifted the chunk boundary, 11 baselined +# test_cache entries moved into the aborted chunk and the gate called them STALE. +# #3517 makes the CLI skip under pytest and teaches the ratchet that exit 3 is a +# lost chunk (isolate per file, record the aborting file), so the chunk ran for +# the first time and surfaced 17 real failures: 9 FAIL in semantic-cache +# test_cipher_layer and 8 ERROR in test_proxy, the same undefined +# `pmoves.services.semantic_cache` alias as the 11 test_cache entries (#3529). +# Recorded from that CI run's log (run 45567996955); the stale +# `ERROR|pytest|internal` dropped. The baseline recorded the silence again; +# this is what it contained. +# # 2026-08-16 — 182 -> 125. Adding `python-multipart` to # .github/requirements-tests.txt fixed 57 entries at once. flute-gateway/main.py # declares a fastapi Form() endpoint, and FastAPI raises at route-definition time @@ -148,7 +166,6 @@ known_failures: - "ERROR|docs.PMOVES.AI PLANS.PMOVES.yt.test_integration|test_youtube_info" - "ERROR|docs.PMOVES.AI PLANS.PMOVES.yt.test_n8n_workflow|test_workflow" - "ERROR|pmoves/tests/integration/test_voice_relay_e2e.py|" - - "ERROR|pytest|internal" - "ERROR|services.channel-monitor.tests.test_monitor|" - "ERROR|services.clap-embed.tests.test_app|" - "ERROR|services.clap-embed.tests.test_embedder|" @@ -181,6 +198,14 @@ known_failures: - "ERROR|services.semantic-cache.tests.test_cache.TestCacheStore|test_store_failure_is_non_blocking" - "ERROR|services.semantic-cache.tests.test_cache.TestCacheStore|test_store_new_entry" - "ERROR|services.semantic-cache.tests.test_cache.TestCacheTTL|test_ttl_expired_entries_not_returned" + - "ERROR|services.semantic-cache.tests.test_proxy.TestHealthEndpoint|test_health_endpoint" + - "ERROR|services.semantic-cache.tests.test_proxy.TestMetricsEndpoint|test_metrics_endpoint" + - "ERROR|services.semantic-cache.tests.test_proxy.TestPassthroughNonCacheable|test_passthrough_more_than_three_messages" + - "ERROR|services.semantic-cache.tests.test_proxy.TestPassthroughNonCacheable|test_passthrough_tools" + - "ERROR|services.semantic-cache.tests.test_proxy.TestPassthroughNonCacheable|test_passthrough_high_temperature" + - "ERROR|services.semantic-cache.tests.test_proxy.TestCacheHit|test_cache_hit_cipher_l0" + - "ERROR|services.semantic-cache.tests.test_proxy.TestCacheHit|test_cache_hit_pgvector_l1" + - "ERROR|services.semantic-cache.tests.test_proxy.TestCacheMissForward|test_cache_miss_forwards_to_tensorzero" - "ERROR|services.sso-auth.tests.test_jwt_verify|" - "ERROR|services.sso-auth.tests.test_login|" - "ERROR|services.sso-auth.tests.test_oidc|" @@ -205,6 +230,15 @@ known_failures: - "FAIL|services.deepresearch.tests.test_parsing|test_prepare_result_normalises_sources[sources1-expected_urls1]" - "FAIL|services.nats_event_bus.tests.test_app|test_read_events_limit_is_respected" - "FAIL|services.nats_event_bus.tests.test_app|test_subscriber_disabled_when_nats_url_empty" + - "FAIL|services.semantic-cache.tests.test_cipher_layer.TestCipherSearch|test_search_hit" + - "FAIL|services.semantic-cache.tests.test_cipher_layer.TestCipherSearch|test_search_miss" + - "FAIL|services.semantic-cache.tests.test_cipher_layer.TestCipherSearch|test_search_disabled" + - "FAIL|services.semantic-cache.tests.test_cipher_layer.TestCipherSearch|test_search_http_error_fail_open" + - "FAIL|services.semantic-cache.tests.test_cipher_layer.TestCipherStore|test_store" + - "FAIL|services.semantic-cache.tests.test_cipher_layer.TestCipherStore|test_store_failure_is_non_blocking" + - "FAIL|services.semantic-cache.tests.test_cipher_layer.TestCipherStore|test_store_network_exception_fail_open" + - "FAIL|services.semantic-cache.tests.test_cipher_layer.TestCipherLifecycle|test_init" + - "FAIL|services.semantic-cache.tests.test_cipher_layer.TestCipherLifecycle|test_close" - "FAIL|tests.a2ui.test_bridge.TestMetricsEndpoint|test_metrics_returns_prometheus_format" - "FAIL|tests.fresh_start.test_chit_integration.TestCHITManifestV2|test_manifest_entries_have_tier" - "FAIL|tests.fresh_start.test_env_layout.TestCHITManifestV2|test_manifest_v2_entries_have_tier" From a071494a8bd3c7f815a2bffd9d977764fb75ee6a Mon Sep 17 00:00:00 2001 From: POWERFULMOVES <142271328+POWERFULMOVES@users.noreply.github.com> Date: Wed, 25 Nov 2026 02:56:51 -0500 Subject: [PATCH 6/6] fix(tests): shim probes httpx via PathFinder (never raises on a sibling's stub); a session-wide abort is one dead group Two review findings on the previous push, both P2: - importlib.util.find_spec("httpx") consults sys.modules first and RAISES ValueError when the entry there has no __spec__ -- which is what a sibling suite's stub looks like. channel-monitor/tests/test_monitor.py installs a bare ModuleType("httpx") and sorts before publisher-discord in the same ratchet chunk, so in the minimal environment the shim exists for, both publisher-discord modules would have become collection errors. importlib.machinery.PathFinder.find_spec ignores sys.modules, answers only "is the package on sys.path", and never raises. Measured: with a spec-less stub in sys.modules, util.find_spec raises "httpx.__spec__ is None"; PathFinder returns None. - The ratchet isolated every exit-3 chunk per file. A session-wide INTERNALERROR (a conftest or plugin hook raising) aborts identically for every file and would have produced N `` findings keying one breakage N ways. When every file in a chunk aborts alone, the group is now reported once as dead, the same way an unimportable conftest is. Three more ratchet tests cover the abort-with-no-report branches (per-file and single-file) and the all-abort collapse. 52 pass. Co-Authored-By: Claude Fable 5.1 Claude-Session: https://claude.ai/code/session_016aNs4q8tajdg1rcgaacrWS --- .../tests/test_formatting.py | 11 ++++- .../tests/test_shim_isolation.py | 6 ++- pmoves/tests/tools/test_pytest_ratchet.py | 44 ++++++++++++++++--- pmoves/tools/pytest_ratchet.py | 11 +++++ 4 files changed, 63 insertions(+), 9 deletions(-) diff --git a/pmoves/services/publisher-discord/tests/test_formatting.py b/pmoves/services/publisher-discord/tests/test_formatting.py index 41f7e3a68a..d8845dbebf 100644 --- a/pmoves/services/publisher-discord/tests/test_formatting.py +++ b/pmoves/services/publisher-discord/tests/test_formatting.py @@ -1,4 +1,4 @@ -import importlib.util +import importlib.machinery import sys from pathlib import Path from types import ModuleType, SimpleNamespace @@ -20,7 +20,14 @@ async def __aexit__(self, exc_type, exc, tb): # session and breaking later importers (google-genai 3.x reads httpx.Client at # import; 43 flute-gateway failures on main, 2026-11-21). See # test_shim_isolation.py. -if importlib.util.find_spec("httpx") is None: +# +# PathFinder, not importlib.util.find_spec: the latter consults sys.modules +# first and RAISES ValueError when the entry there has no __spec__, which is +# exactly what a sibling suite's stub looks like (channel-monitor's +# test_monitor.py installs a bare ModuleType("httpx") and sorts before this +# file in the same ratchet chunk). PathFinder answers the only question asked +# here -- is the package on sys.path -- and never raises. +if importlib.machinery.PathFinder.find_spec("httpx") is None: sys.modules.setdefault("httpx", SimpleNamespace(AsyncClient=_DummyAsyncClient)) diff --git a/pmoves/services/publisher-discord/tests/test_shim_isolation.py b/pmoves/services/publisher-discord/tests/test_shim_isolation.py index 92c8ef0f3f..ba2661a108 100644 --- a/pmoves/services/publisher-discord/tests/test_shim_isolation.py +++ b/pmoves/services/publisher-discord/tests/test_shim_isolation.py @@ -9,7 +9,7 @@ (2026-11-21). The shim is for minimal environments where httpx is absent. """ -import importlib.util +import importlib.machinery import os import subprocess import sys @@ -21,7 +21,9 @@ @pytest.mark.skipif( - importlib.util.find_spec("httpx") is None, + # PathFinder ignores sys.modules, so a sibling suite's spec-less httpx stub + # cannot make this raise at collection (importlib.util.find_spec would). + importlib.machinery.PathFinder.find_spec("httpx") is None, reason="httpx not installed: the shim is supposed to apply", ) def test_formatting_shim_leaves_installed_httpx_alone(): diff --git a/pmoves/tests/tools/test_pytest_ratchet.py b/pmoves/tests/tools/test_pytest_ratchet.py index fbe83b6732..9c65ab3aa9 100644 --- a/pmoves/tests/tools/test_pytest_ratchet.py +++ b/pmoves/tests/tools/test_pytest_ratchet.py @@ -517,18 +517,23 @@ class _FakeRun: whole trap: a chunk containing one abort returns 3 with a report present. """ - def __init__(self, hangs, chunk_times_out=True, aborts=()): + def __init__(self, hangs, chunk_times_out=True, aborts=(), abort_writes_report=True): self.hangs = set(hangs) self.aborts = set(aborts) self.chunk_times_out = chunk_times_out + self.abort_writes_report = abort_writes_report self.calls = [] + def _abort(self, junit): + if self.abort_writes_report: + junit.write_text("", encoding="utf-8") + return 3, "INTERNALERROR> SystemExit: 1" + def __call__(self, files, junit, timeout=None): self.calls.append(([str(f) for f in files], timeout)) if len(files) > 1: if any(str(f) in self.aborts for f in files): - junit.write_text("", encoding="utf-8") - return 3, "INTERNALERROR> SystemExit: 1" + return self._abort(junit) if self.chunk_times_out: return -1, "TIMEOUT" junit.write_text("", encoding="utf-8") @@ -536,8 +541,7 @@ def __call__(self, files, junit, timeout=None): if str(files[0]) in self.hangs: return -1, "TIMEOUT" if str(files[0]) in self.aborts: - junit.write_text("", encoding="utf-8") - return 3, "INTERNALERROR> SystemExit: 1" + return self._abort(junit) junit.write_text("", encoding="utf-8") return 0, "" @@ -686,6 +690,36 @@ def test_abort_and_hang_in_one_chunk_are_told_apart(monkeypatch, tmp_path): assert [f["where"] for f in _internal_errors(findings)] == ["abort.py"] +def test_abort_without_any_report_is_still_a_finding(monkeypatch, tmp_path): + """pytest usually writes a partial report on INTERNALERROR; when it does not + (killed harder, or junitxml itself is what broke), the abort is still keyed + on the file rather than lost.""" + fake = _FakeRun(hangs=[], aborts=["abort.py"], abort_writes_report=False) + finding = {"kind": "FAIL", "where": "x", "name": "y", "detail": ""} + findings, dead = _run_fallback(monkeypatch, tmp_path, ["a.py", "abort.py"], fake, + parsed=[finding]) + assert dead == [] + assert findings.count(finding) == 1 # a.py only; abort.py had no report + assert [f["where"] for f in _internal_errors(findings)] == ["abort.py"] + + +def test_single_file_abort_without_a_report_is_recorded_not_dead(monkeypatch, tmp_path): + fake = _FakeRun(hangs=[], aborts=["only.py"], abort_writes_report=False) + findings, dead = _run_fallback(monkeypatch, tmp_path, ["only.py"], fake) + assert dead == [] + assert [f["where"] for f in _internal_errors(findings)] == ["only.py"] + + +def test_every_file_aborting_alone_is_one_dead_group_not_n_findings(monkeypatch, tmp_path): + """A conftest or plugin hook raising fails identically for every file. That is + the session, not a file; N per-file findings would key one breakage N ways.""" + fake = _FakeRun(hangs=[], aborts=["a.py", "b.py", "c.py"]) + findings, dead = _run_fallback(monkeypatch, tmp_path, ["a.py", "b.py", "c.py"], fake) + assert dead == ["grp"] + assert findings == [] + assert len(fake.calls) == 1 + 3 # it still had to look, per file + + def test_internal_error_detail_is_the_last_output_line_capped(monkeypatch, tmp_path): out = "junk\nINTERNALERROR> " + "x" * 400 + "\n\n" f = pytest_ratchet._internal_error_finding(Path("abort.py"), out) diff --git a/pmoves/tools/pytest_ratchet.py b/pmoves/tools/pytest_ratchet.py index 4b97d92fb0..d8da5cf161 100644 --- a/pmoves/tools/pytest_ratchet.py +++ b/pmoves/tools/pytest_ratchet.py @@ -524,6 +524,7 @@ def run_chunk_with_fallback(group: str, gfiles: List[Path], tmp: Path, findings: List[dict] = [] dead: List[str] = [] + aborted: List[str] = [] spent = 0.0 for j, f in enumerate(gfiles): if spent >= pass_budget: @@ -549,12 +550,22 @@ def run_chunk_with_fallback(group: str, gfiles: List[Path], tmp: Path, sys.stderr.write("--- %s aborted pytest (exit 3) ---%s%s%s" % ( label, chr(10), foutput[-600:], chr(10))) findings.append(_internal_error_finding(f, foutput)) + aborted.append(label) continue if sub.is_file(): continue sys.stderr.write("--- no report for %s (exit %d) ---%s%s%s" % ( label, frc, chr(10), foutput[-600:], chr(10))) dead.append(label) + if len(gfiles) > 1 and len(aborted) == len(gfiles): + # EVERY file aborts alone: that is not one file's sys.exit, it is the + # session itself (a conftest or plugin hook raising). Per-file findings + # would key the same breakage N ways and churn the baseline; the group + # is reported once, the same way an unimportable conftest is. + sys.stderr.write( + "--- every file in %s aborts pytest alone; reporting the group ---%s" % ( + group, chr(10))) + return [], [group] return findings, dead