Repository navigation
ci: ratchet python one-function-per-file to max_lines = 16 - #1040
Merged
Merged
Conversation
…ease_globs its own module Splits four functions out of the two files that held more than one substantial function each, so the one-function-per-file gate can be tightened: - preflight/invocation.py -- the argv/cwd builder, with package_root and e2e_flags, leaving gate.py holding run. - preflight/prepare.py -- the per-python-root drift guards. - preflight/discovery.py -- discovered() and sources(), which had to move together to keep the dependency on matrix.py one-way. - release_globs/precheck.py -- unprechecked(). Tests move with the code they cover rather than being duplicated. release_globs/gate.py also switches its absolute import of decide to a relative one.
internals/checks, packages/python, and the root config's [python] table (which internals/distcheck reads). The [typescript] tables stay at 24 until the packages/ts split lands; the embeddings plugin is clean at 16 but is left for a separate change.
This was referenced Sep 4, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Part of #1037 (part 1 of 2 — the
internals/checksscan root; #1039 is thepackages/tshalf).unit one-function-per-filefires when one file holds two module-scope functions and one of them runs longer thanmax_lines. At 16,internals/checks/srchad exactly four violations:Every one is fixed by moving a function into its own module with its tests. No exemption (the count for this gate is zero and stays there), no golfing a function under the limit.
The four splits
preflight/invocation.pyinvocation, pluspackage_root/e2e_flags/ theInvocationrecord and theCLI/LAUNCHERStables it builds fromgate.pykeepsrunpreflight/prepare.pypreparepreflight/discovery.pydiscoveredandsourcesmatrix.pykeepsparse_gate_matrix,named,read_text,pairsand the modelrelease_globs/precheck.pyunprecheckeddecide.pykeepsglob_problemsTwo of these are shaped by constraints rather than taste, so they are worth naming:
gate.pykeepsrun, andinvocationis what moved. #1037 sketched extractingrunandprepare.invocationis itself 24 lines, so it needs its own file either way, and all ninechecks/*packages usegate.pyfor the orchestration entry point — apreflight/run.pywould be the only one. Keepingruningate.pyalso leavespreflight/cli.py'sfrom .gate import default_runner, read_e2e, rununtouched.sourceshad to move withdiscovered.discoveredneedsparse_gate_matrix/NoGateMatrix/REUSABLEfrommatrix.py, so leaving its only caller behind would have made the two modules import each other. Movingsourcestoo keeps the dependency one-way (discovery→matrix). That does changepreflight/cli.py's import site, which is the one call-site edit in the PR.REUSABLEstays inmatrix.py, sodiscovered'sNoGateMatrixmessage still points contributors at the right file;discovery_test.pynow asserts the fullpreflight/matrix.pypath rather than the barematrix.pythe old test matched.release_globs/gate.pyalso switchesfrom checks.release_globs.decide import ...to a relative import, per AGENTS.md.Config
max_lines = 16in the three python roots this PR clears:internals/checks/testing-conventions.toml(clean after the splits)testing-conventions.toml's[python]table — the fileinternals/distcheckreads, already clean at 16packages/python/testing-conventions.toml, already clean at 16Left for #1039: the root file's
[typescript]table andpackages/ts/testing-conventions.tomlstay at 24.plugins/dirsql-plugin-embeddings/testing-conventions.tomlalso stays at 24 — it is clean at 16 but is neither PR's lane, so it wants its own change.Neither half carries a closing keyword, since either one alone would close #1037 early. The issue is done once both land.
Tests
Relocations, not duplications.
gate_test.py(339 lines) split three ways along the code it covers,matrix_test.pytwo ways,decide_test.pytwo ways. Three assertions are new rather than moved:prepare_test.pypins both drift guards to the repo root (cwd == "."), which nothing asserted before.release_globs/gate_test.pypins the summary line's problem count when the failure comes from the precheck half, so the two halves are not interchangeable there.discovery_test.pypins thematrix.pypath in the "no caller found" fix message, as above.Red/green does not apply: this is a behaviour-preserving move plus a config tightening, so the suite stayed green throughout.
Gate verification
just preflight(the full derived matrix, all 8 scan roots): 0 failing pair(s), 3 skipped — the three skips arepackaging, which needs a built artifact.The two diff-scoped gates that judge the move, run against the pushed commits:
uv run python -m pytest -qininternals/checks: 465 passed.Manual exercise
The changed code is
just preflightanddirsql-checks release-globs, so both were run for real:just preflight— derived the matrix through the moveddiscovery.sources, built every argv through the movedinvocation, and ran the drift guards through the movedprepare.dirsql-checks preflight --conventions nope.yml→preflight: --conventions nope.yml: no such workflow. …(exit 1), and the same command from/tmp→preflight: no .github/workflows directory here. …(exit 1). Those arenamedanddiscovered's error paths.dirsql-checks release-globs→ok release-globs: putitoutthere.toml and .github/workflows/release-ci.yml agree on what ships.(exit 0).packages/rust/**glob and a!packages/rust/tests/**precheck exclusion → both annotations, including the movedunprechecked's (exit 1).E2E Verification
packages/pythonsource changeinternals/checks/e2e-attestations/claude-tackle-1037-checks16.jsonreceipt written (just e2e-attest-internals-checks)uv run python -m pytest tests/e2e -x -qininternals/checksWorth correcting for the next agent on this ratchet:
internals/checksdoes owe an e2e receipt. Its lane declarese2e-verifywith--scope internals/checks/src, so any source change there stales the attestation —just preflightfailed exactly one pair until the receipt was written.Changelog / Migrations
changelog_gate/decide.pyrather than assumed._ROOTS = ("packages", "plugins"), sointernals/checks/**is outside every package the gate knows about. The one file this PR touches underpackages/ispackages/python/testing-conventions.toml, which_is_exemptwaives by name ({pkg}/testing-conventions\.toml— gate config ships in no artifact). The roottesting-conventions.tomlis not under a package root at all.No
PARITY.mdchange: no SDK public API is touched.