From 67a86f923d2133e768448e81cd6d28f52f1ec477 Mon Sep 17 00:00:00 2001 From: thekevinbot <248217931+thekevinbot@users.noreply.github.com> Date: Fri, 4 Sep 2026 19:35:36 -0400 Subject: [PATCH 1/3] refactor: give each extension-load probe's diagnose its own module Both `checks/*_extension_load/gate.py` files hold two functions over the one-function-per-file threshold the #1042 ratchet is heading for, so the gate flags `run` -- the second one in each file -- even though `run` is the orchestration entry point every `checks/*` package exposes. Move the holder instead: `diagnose` and the `STATIC_MARKER` it is the only consumer of go to a sibling `diagnose.py` in each package, leaving `run` first in `gate.py` where its callers expect it. Behavior is unchanged; the diagnose cases move to the new colocated test files rather than being duplicated. Part of #1042. --- .../npm_binary_extension_load/diagnose.py | 23 +++++++++++++++ .../diagnose_test.py | 28 +++++++++++++++++++ .../checks/npm_binary_extension_load/gate.py | 21 ++------------ .../npm_binary_extension_load/gate_test.py | 18 +----------- .../checks/wheel_extension_load/diagnose.py | 22 +++++++++++++++ .../wheel_extension_load/diagnose_test.py | 27 ++++++++++++++++++ .../src/checks/wheel_extension_load/gate.py | 20 ++----------- .../checks/wheel_extension_load/gate_test.py | 17 +---------- 8 files changed, 106 insertions(+), 70 deletions(-) create mode 100644 internals/checks/src/checks/npm_binary_extension_load/diagnose.py create mode 100644 internals/checks/src/checks/npm_binary_extension_load/diagnose_test.py create mode 100644 internals/checks/src/checks/wheel_extension_load/diagnose.py create mode 100644 internals/checks/src/checks/wheel_extension_load/diagnose_test.py diff --git a/internals/checks/src/checks/npm_binary_extension_load/diagnose.py b/internals/checks/src/checks/npm_binary_extension_load/diagnose.py new file mode 100644 index 000000000..9d556675b --- /dev/null +++ b/internals/checks/src/checks/npm_binary_extension_load/diagnose.py @@ -0,0 +1,23 @@ +"""The human-readable diagnosis for a failed npm bundled-cli extension-load probe (#762).""" + +from __future__ import annotations + +STATIC_MARKER = "Dynamic loading not supported" + + +def diagnose(result) -> str: + output = f"stdout={result.stdout!r}\nstderr={result.stderr!r}" + if STATIC_MARKER in result.stderr: + return ( + f"the npm bundled-cli `dirsql` binary cannot load SQLite " + f"extensions ({STATIC_MARKER!r}): it is statically linked " + "(static-pie), and a static binary cannot dlopen. The release " + "pipeline (putitoutthere `_matrix.yml`) compiles npm bundle_cli " + "Linux binaries via cargo-zigbuild against the declared gnu " + "triple at a pinned glibc floor since putitoutthere#605; a " + "static binary here means that lane regressed (or the `@v0` " + "tag resolves to a pre-#605 revision). Fix the pipeline, not " + "this probe. See dirsql#762.\n" + f"{output}" + ) + return f"`dirsql query` against the bundled binary failed.\n{output}" diff --git a/internals/checks/src/checks/npm_binary_extension_load/diagnose_test.py b/internals/checks/src/checks/npm_binary_extension_load/diagnose_test.py new file mode 100644 index 000000000..d69f66174 --- /dev/null +++ b/internals/checks/src/checks/npm_binary_extension_load/diagnose_test.py @@ -0,0 +1,28 @@ +"""Colocated unit tests for the npm bundled-cli probe's failure diagnosis (#762).""" + +from unittest import mock + +from checks.npm_binary_extension_load.diagnose import STATIC_MARKER, diagnose + + +def _result(returncode=0, stdout="", stderr=""): + return mock.Mock(returncode=returncode, stdout=stdout, stderr=stderr) + + +def describe_diagnose(): + def static_binary_gets_the_dlopen_diagnosis(): + message = diagnose(_result(1, stdout="", stderr=f"boom: {STATIC_MARKER}")) + assert "statically linked" in message + assert "dirsql#762" in message + assert "putitoutthere#605" in message + assert STATIC_MARKER in message + + def the_marker_matches_sqlites_literal_wording(): + message = diagnose(_result(1, stderr="Error: Dynamic loading not supported")) + assert "statically linked" in message + + def other_failures_get_a_generic_message(): + message = diagnose(_result(1, stdout="out", stderr="bad flag")) + assert message.startswith("`dirsql query` against the bundled binary failed.") + assert "'bad flag'" in message + assert "'out'" in message diff --git a/internals/checks/src/checks/npm_binary_extension_load/gate.py b/internals/checks/src/checks/npm_binary_extension_load/gate.py index 21385bc4d..a6c840f93 100644 --- a/internals/checks/src/checks/npm_binary_extension_load/gate.py +++ b/internals/checks/src/checks/npm_binary_extension_load/gate.py @@ -35,9 +35,10 @@ write_text, ) +from .diagnose import diagnose + PROBE_SQL = "SELECT vec_version() AS v" ENTRYPOINT = "sqlite3_vec_init" -STATIC_MARKER = "Dynamic loading not supported" BIN_NAME = "dirsql" @@ -57,24 +58,6 @@ def find_binaries(dist_dir: str, walker=os.walk) -> list[str]: ) -def diagnose(result) -> str: - output = f"stdout={result.stdout!r}\nstderr={result.stderr!r}" - if STATIC_MARKER in result.stderr: - return ( - f"the npm bundled-cli `dirsql` binary cannot load SQLite " - f"extensions ({STATIC_MARKER!r}): it is statically linked " - "(static-pie), and a static binary cannot dlopen. The release " - "pipeline (putitoutthere `_matrix.yml`) compiles npm bundle_cli " - "Linux binaries via cargo-zigbuild against the declared gnu " - "triple at a pinned glibc floor since putitoutthere#605; a " - "static binary here means that lane regressed (or the `@v0` " - "tag resolves to a pre-#605 revision). Fix the pipeline, not " - "this probe. See dirsql#762.\n" - f"{output}" - ) - return f"`dirsql query` against the bundled binary failed.\n{output}" - - def run( dist_dir: str, runner=subprocess.run, diff --git a/internals/checks/src/checks/npm_binary_extension_load/gate_test.py b/internals/checks/src/checks/npm_binary_extension_load/gate_test.py index f9805437c..290b49cb6 100644 --- a/internals/checks/src/checks/npm_binary_extension_load/gate_test.py +++ b/internals/checks/src/checks/npm_binary_extension_load/gate_test.py @@ -4,14 +4,13 @@ import pytest +from checks.npm_binary_extension_load.diagnose import STATIC_MARKER from checks.npm_binary_extension_load.gate import ( BIN_NAME, ENTRYPOINT, PROBE_SQL, - STATIC_MARKER, ProbeError, config_for, - diagnose, find_binaries, run, ) @@ -63,21 +62,6 @@ def declares_the_library_and_entrypoint(): ) -def describe_diagnose(): - def static_binary_gets_the_dlopen_diagnosis(): - message = diagnose(_result(1, stdout="", stderr=f"boom: {STATIC_MARKER}")) - assert "statically linked" in message - assert "dirsql#762" in message - assert "putitoutthere#605" in message - assert STATIC_MARKER in message - - def other_failures_get_a_generic_message(): - message = diagnose(_result(1, stdout="out", stderr="bad flag")) - assert message.startswith("`dirsql query` against the bundled binary failed.") - assert "'bad flag'" in message - assert "'out'" in message - - def describe_run(): def skips_cleanly_when_no_binary(capsys): runner = mock.Mock() diff --git a/internals/checks/src/checks/wheel_extension_load/diagnose.py b/internals/checks/src/checks/wheel_extension_load/diagnose.py new file mode 100644 index 000000000..6093a750d --- /dev/null +++ b/internals/checks/src/checks/wheel_extension_load/diagnose.py @@ -0,0 +1,22 @@ +"""The human-readable diagnosis for a failed wheel extension-load probe (#755).""" + +from __future__ import annotations + +STATIC_MARKER = "Dynamic loading not supported" + + +def diagnose(result) -> str: + output = f"stdout={result.stdout!r}\nstderr={result.stderr!r}" + if STATIC_MARKER in result.stderr: + return ( + f"the bundled `dirsql` binary in this wheel cannot load SQLite " + f"extensions ({STATIC_MARKER!r}): it is statically linked " + "(static-pie), and a static binary cannot dlopen. The release " + "pipeline (putitoutthere `_matrix.yml`, #381) compiles the pypi " + "bundle_cli binary against the musl-mapped triple; the fix is to " + "build the wheel's bundled binary against the declared " + "*-linux-gnu triple (the wheel's manylinux tag already gates the " + "glibc floor), not to change this probe. See dirsql#755.\n" + f"{output}" + ) + return f"`dirsql query` against the installed wheel failed.\n{output}" diff --git a/internals/checks/src/checks/wheel_extension_load/diagnose_test.py b/internals/checks/src/checks/wheel_extension_load/diagnose_test.py new file mode 100644 index 000000000..2fa7a8ca3 --- /dev/null +++ b/internals/checks/src/checks/wheel_extension_load/diagnose_test.py @@ -0,0 +1,27 @@ +"""Colocated unit tests for the wheel probe's failure diagnosis (#755).""" + +from unittest import mock + +from checks.wheel_extension_load.diagnose import STATIC_MARKER, diagnose + + +def _result(returncode=0, stdout="", stderr=""): + return mock.Mock(returncode=returncode, stdout=stdout, stderr=stderr) + + +def describe_diagnose(): + def static_binary_gets_the_dlopen_diagnosis(): + message = diagnose(_result(1, stdout="", stderr=f"boom: {STATIC_MARKER}")) + assert "statically linked" in message + assert "dirsql#755" in message + assert STATIC_MARKER in message + + def the_marker_matches_sqlites_literal_wording(): + message = diagnose(_result(1, stderr="Error: Dynamic loading not supported")) + assert "statically linked" in message + + def other_failures_get_a_generic_message(): + message = diagnose(_result(1, stdout="out", stderr="config missing")) + assert message.startswith("`dirsql query` against the installed wheel failed.") + assert "'config missing'" in message + assert "'out'" in message diff --git a/internals/checks/src/checks/wheel_extension_load/gate.py b/internals/checks/src/checks/wheel_extension_load/gate.py index 093599dbe..ac73c9a34 100644 --- a/internals/checks/src/checks/wheel_extension_load/gate.py +++ b/internals/checks/src/checks/wheel_extension_load/gate.py @@ -20,9 +20,10 @@ import sys import tempfile +from .diagnose import diagnose + PROBE_SQL = "SELECT vec_version() AS v" CONFIG = '[[dirsql.extension]]\npath = "sqlite_vec"\nentrypoint = "sqlite3_vec_init"\n' -STATIC_MARKER = "Dynamic loading not supported" class ProbeError(RuntimeError): @@ -54,23 +55,6 @@ def write_text(path: str, content: str) -> None: handle.write(content) -def diagnose(result) -> str: - output = f"stdout={result.stdout!r}\nstderr={result.stderr!r}" - if STATIC_MARKER in result.stderr: - return ( - f"the bundled `dirsql` binary in this wheel cannot load SQLite " - f"extensions ({STATIC_MARKER!r}): it is statically linked " - "(static-pie), and a static binary cannot dlopen. The release " - "pipeline (putitoutthere `_matrix.yml`, #381) compiles the pypi " - "bundle_cli binary against the musl-mapped triple; the fix is to " - "build the wheel's bundled binary against the declared " - "*-linux-gnu triple (the wheel's manylinux tag already gates the " - "glibc floor), not to change this probe. See dirsql#755.\n" - f"{output}" - ) - return f"`dirsql query` against the installed wheel failed.\n{output}" - - def run( dist_dir: str, runner=subprocess.run, diff --git a/internals/checks/src/checks/wheel_extension_load/gate_test.py b/internals/checks/src/checks/wheel_extension_load/gate_test.py index 08f52ecd2..6e37c606b 100644 --- a/internals/checks/src/checks/wheel_extension_load/gate_test.py +++ b/internals/checks/src/checks/wheel_extension_load/gate_test.py @@ -4,14 +4,13 @@ import pytest +from checks.wheel_extension_load.diagnose import STATIC_MARKER from checks.wheel_extension_load.gate import ( CONFIG, PROBE_SQL, - STATIC_MARKER, ProbeError, _require_zero, bin_subdir, - diagnose, list_names, run, wheel_names, @@ -71,20 +70,6 @@ def writes_the_content(tmp_path): assert handle.read() == "content" -def describe_diagnose(): - def static_binary_gets_the_dlopen_diagnosis(): - message = diagnose(_result(1, stdout="", stderr=f"boom: {STATIC_MARKER}")) - assert "statically linked" in message - assert "dirsql#755" in message - assert STATIC_MARKER in message - - def other_failures_get_a_generic_message(): - message = diagnose(_result(1, stdout="out", stderr="config missing")) - assert message.startswith("`dirsql query` against the installed wheel failed.") - assert "'config missing'" in message - assert "'out'" in message - - def describe_run(): def skips_cleanly_when_no_wheel(capsys): runner = mock.Mock() From 4be6d991b581c4940685c9a5009037fd36e6f93f Mon Sep 17 00:00:00 2001 From: thekevinbot <248217931+thekevinbot@users.noreply.github.com> Date: Fri, 4 Sep 2026 19:37:06 -0400 Subject: [PATCH 2/3] test: mock the extracted diagnose in the gate unit tests `unit lint` reads an import of a sibling source module as an unmocked collaborator, so the gate tests patch `diagnose` by string and assert on the probe result handed to it instead of on its rendered wording. The wording itself is asserted in diagnose_test.py. --- .../npm_binary_extension_load/gate_test.py | 20 +++++++------ .../checks/wheel_extension_load/gate_test.py | 28 ++++++++----------- 2 files changed, 22 insertions(+), 26 deletions(-) diff --git a/internals/checks/src/checks/npm_binary_extension_load/gate_test.py b/internals/checks/src/checks/npm_binary_extension_load/gate_test.py index 290b49cb6..aaf536862 100644 --- a/internals/checks/src/checks/npm_binary_extension_load/gate_test.py +++ b/internals/checks/src/checks/npm_binary_extension_load/gate_test.py @@ -4,7 +4,6 @@ import pytest -from checks.npm_binary_extension_load.diagnose import STATIC_MARKER from checks.npm_binary_extension_load.gate import ( BIN_NAME, ENTRYPOINT, @@ -16,6 +15,8 @@ ) from checks.wheel_extension_load.gate import bin_subdir +DIAGNOSE = "checks.npm_binary_extension_load.gate.diagnose" + def _result(returncode=0, stdout="", stderr=""): return mock.Mock(returncode=returncode, stdout=stdout, stderr=stderr) @@ -188,12 +189,13 @@ def failing_probe_raises_the_diagnosis(): _result(0), _result(0), _result(0, stdout="/v/vec0\n"), - _result(1, stderr=f"failed to load extension: {STATIC_MARKER}"), + _result(1, stderr="load failed"), ] ) - with pytest.raises(ProbeError) as exc_info: - _run_with(runner) - assert "statically linked" in str(exc_info.value) + with mock.patch(DIAGNOSE, return_value="the diagnosis") as diagnose: + with pytest.raises(ProbeError, match="the diagnosis"): + _run_with(runner) + assert diagnose.call_args.args[0].stderr == "load failed" def signal_killed_probe_raises_the_diagnosis(): runner = mock.Mock( @@ -201,12 +203,12 @@ def signal_killed_probe_raises_the_diagnosis(): _result(0), _result(0), _result(0, stdout="/v/vec0\n"), - _result(-6, stderr=f"failed to load extension: {STATIC_MARKER}"), + _result(-6, stderr="load failed"), ] ) - with pytest.raises(ProbeError) as exc_info: - _run_with(runner) - assert "statically linked" in str(exc_info.value) + with mock.patch(DIAGNOSE, return_value="the diagnosis"): + with pytest.raises(ProbeError, match="the diagnosis"): + _run_with(runner) def rowless_probe_output_raises(): runner = mock.Mock( diff --git a/internals/checks/src/checks/wheel_extension_load/gate_test.py b/internals/checks/src/checks/wheel_extension_load/gate_test.py index 6e37c606b..4cb3b3afa 100644 --- a/internals/checks/src/checks/wheel_extension_load/gate_test.py +++ b/internals/checks/src/checks/wheel_extension_load/gate_test.py @@ -4,7 +4,6 @@ import pytest -from checks.wheel_extension_load.diagnose import STATIC_MARKER from checks.wheel_extension_load.gate import ( CONFIG, PROBE_SQL, @@ -17,6 +16,8 @@ write_text, ) +DIAGNOSE = "checks.wheel_extension_load.gate.diagnose" + def _result(returncode=0, stdout="", stderr=""): return mock.Mock(returncode=returncode, stdout=stdout, stderr=stderr) @@ -167,27 +168,20 @@ def install_failure_raises(): def failing_probe_raises_the_diagnosis(): runner = mock.Mock( - side_effect=[ - _result(0), - _result(0), - _result(1, stderr=f"failed to load extension: {STATIC_MARKER}"), - ] + side_effect=[_result(0), _result(0), _result(1, stderr="load failed")] ) - with pytest.raises(ProbeError) as exc_info: - _run_with(runner) - assert "statically linked" in str(exc_info.value) + with mock.patch(DIAGNOSE, return_value="the diagnosis") as diagnose: + with pytest.raises(ProbeError, match="the diagnosis"): + _run_with(runner) + assert diagnose.call_args.args[0].stderr == "load failed" def signal_killed_probe_raises_the_diagnosis(): runner = mock.Mock( - side_effect=[ - _result(0), - _result(0), - _result(-6, stderr=f"failed to load extension: {STATIC_MARKER}"), - ] + side_effect=[_result(0), _result(0), _result(-6, stderr="load failed")] ) - with pytest.raises(ProbeError) as exc_info: - _run_with(runner) - assert "statically linked" in str(exc_info.value) + with mock.patch(DIAGNOSE, return_value="the diagnosis"): + with pytest.raises(ProbeError, match="the diagnosis"): + _run_with(runner) def rowless_probe_output_raises(): runner = mock.Mock(side_effect=[_result(0), _result(0), _result(0, stdout="[]")]) From 598b292aa614de3943203487eec31c3b26c0b28c Mon Sep 17 00:00:00 2001 From: thekevinbot <248217931+thekevinbot@users.noreply.github.com> Date: Fri, 4 Sep 2026 19:38:02 -0400 Subject: [PATCH 3/3] e2e attestation for claude/tackle-1042-b1-extload --- .../e2e-attestations/claude-tackle-1042-b1-extload.json | 7 +++++++ 1 file changed, 7 insertions(+) create mode 100644 internals/checks/e2e-attestations/claude-tackle-1042-b1-extload.json diff --git a/internals/checks/e2e-attestations/claude-tackle-1042-b1-extload.json b/internals/checks/e2e-attestations/claude-tackle-1042-b1-extload.json new file mode 100644 index 000000000..aa4479646 --- /dev/null +++ b/internals/checks/e2e-attestations/claude-tackle-1042-b1-extload.json @@ -0,0 +1,7 @@ +{ + "command": "uv run python -m pytest tests/e2e -x -q", + "ran_at": 1788565082, + "exit_code": 0, + "commit": "4be6d991b581c4940685c9a5009037fd36e6f93f", + "branch": "claude/tackle-1042-b1-extload" +}