Skip to content

refactor: split diagnose out of the two extension-load probe gates - #1046

Merged
thekevinscott merged 3 commits into
mainfrom
claude/tackle-1042-b1-extload
Sep 5, 2026
Merged

thekevinscott merged 3 commits into
mainfrom
claude/tackle-1042-b1-extload

Conversation

@thekevinbot

Copy link
Copy Markdown
Collaborator

Part of #1042.

PR B1 of the one-function-per-file ratchet toward Kevin's chosen target of max_lines = 12. Pure refactor of two internals/checks probe packages; no testing-conventions.toml is touched — a separate PR sets the ceilings once every split has landed.

What moved

Both extension-load probes carry two functions over the threshold, so the gate flags run — the second function in the file — even though run is the orchestration entry point every checks/* package exposes and every caller imports. Per #1040, the fix is to move the holder instead:

Package New module Moved
internals/checks/src/checks/npm_binary_extension_load/ diagnose.py + diagnose_test.py diagnose, STATIC_MARKER
internals/checks/src/checks/wheel_extension_load/ diagnose.py + diagnose_test.py diagnose, STATIC_MARKER

STATIC_MARKER rides along because diagnose is its only consumer. gate.py picks the function back up with a relative from .diagnose import diagnose, so run is now first in each file and the callers (cli.py) are unchanged. The describe_diagnose cases were relocated out of each gate_test.py, not duplicated.

Second commit: unit lint reads a unit test's import of a sibling source module as an unmocked collaborator, so each gate_test.py now patches diagnose by string and asserts on the probe result handed to it. The rendered wording is asserted in the new diagnose_test.py files, which also gained one case pinning the literal SQLite error text ("Dynamic loading not supported") rather than routing the fixture through the constant.

Verification

internals/checks/src at max_lines = 12, testing-conventions@0.0.111 pinned, config copied to /tmp with the ceiling lowered (the repo config is deliberately untouched):

$ npx -y testing-conventions@0.0.111 unit one-function-per-file --language python --config /tmp/tc-12.toml internals/checks/src
internals/checks/src/checks/platforms_mirror/parse.py:96: `_row` runs 13 lines ...
internals/checks/src/checks/platforms_mirror/parse.py:139: `typescript_table` runs 15 lines ...
internals/checks/src/checks/preflight/matrix.py:118: `named` runs 14 lines ...
error: 3 function(s) sharing a file with another function over the 12-line threshold

Both files in this PR's scope report zero. The three remaining are PR B2's scope.

just preflight (full matrix, 47 pairs): 0 failing, 3 skipped (packaging, which needs a built artifact). unit mutation on the changed lines: no surviving mutants. Zero exemptions added.

Manual run

Ran both CLIs against an empty dist dir (skip path, exit 0), then the npm probe against a fake dirsql that writes the real SQLite error to stderr, which exercises the moved diagnose through run end to end:

$ dirsql-checks npm-binary-extension-load --dist-dir /tmp/fake
npm-binary-extension-load: the npm bundled-cli `dirsql` binary cannot load SQLite extensions
('Dynamic loading not supported'): it is statically linked (static-pie) ... See dirsql#762.
stdout=''
stderr='Error: Dynamic loading not supported\n'

Red/green

Does not apply — this is a behavior-preserving move, so there is no new behavior to turn a test red. The suite stayed green throughout (400 unit, 43 integration, 24 e2e).

E2E Verification

  • Ran e2e suites locally for every affected SDK
  • Python SDK e2e: N/A — no packages/python change
  • TypeScript SDK e2e: N/A — no packages/ts change
  • Rust core e2e (if applicable): N/A — no packages/rust change
  • internals/checks/e2e-attestations/claude-tackle-1042-b1-extload.json receipt written (just e2e-attest-internals-checks)
  • Command(s) run: cd internals/checks && uv run python -m pytest tests/e2e -x -q
  • Result summary: 24 passed. The attest commit adds exactly one file and deletes none (checked per e2e attest silently deletes other branches' attestation receipts #1041).

Changelog / Migrations

  • Not required — changelog_gate/decide.py scopes the gate to _ROOTS = ("packages", "plugins"), so internals/checks/** is outside it.
  • Migration fragment not required — behavior-preserving, and every moved symbol is package-internal.

PARITY

No change. Neither function is part of any SDK's public surface; internals/checks is repo tooling and appears nowhere in PARITY.md.

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.
`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.
@thekevinscott
thekevinscott merged commit ae7a6c0 into main Sep 5, 2026
9 checks passed
@thekevinscott
thekevinscott deleted the claude/tackle-1042-b1-extload branch September 5, 2026 00:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants