Skip to content

ci: split internals/checks so one_function_per_file is clean at 9 - #1058

Merged
thekevinscott merged 3 commits into
mainfrom
claude/1054-checks-ofpf9
Sep 5, 2026
Merged

thekevinscott merged 3 commits into
mainfrom
claude/1054-checks-ofpf9

Conversation

@thekevinbot

Copy link
Copy Markdown
Collaborator

Fixes #1054. Step under #1053 (census/plan) and #1020 (tracker); lane C, the rung after #1042 / PR #1051 (16 -> 12).

Makes internals/checks/src clean at one_function_per_file max_lines = 9 by splitting files only.

No config change. internals/checks/testing-conventions.toml still reads max_lines = 15. Per invariant 1 in #1053, split PRs never touch a max_lines line -- the ceiling drops in its own PR once every lane is clean at 9, so five concurrent lanes never contend for the same config line.

Work list, measured

Throwaway shallow clone of origin/main at b2c4651, internals/checks/testing-conventions.toml rewritten to max_lines = 9, nothing committed. npx -y testing-conventions@0.0.111 because npm latest is what the reusable workflow runs; the PyPI CLI is a separately versioned distribution (0.0.104) and does not reproduce the gate.

$ npx -y testing-conventions@0.0.111 unit one-function-per-file \
    --language python --config internals/checks/testing-conventions.toml internals/checks/src
artifact_completeness/gate.py:92:    `run` runs 20 lines, and `missing` already holds this file
declared_deps/gate.py:129:           `run` runs 20 lines, and `undeclared` already holds this file
platforms_mirror/decide.py:108:      `field_problems` runs 12 lines, and `missing_rows` already holds this file
platforms_mirror/decide.py:124:      `problems` runs 10 lines, and `missing_rows` already holds this file
platforms_mirror/python_table.py:48: `_table_elements` runs 10 lines, and `_dataclass_fields` already holds this file
error: 5 function(s) sharing a file with another function over the 9-line threshold

Five, matching #1053's ladder. With this branch and the same temporary max_lines = 9 the run is silent.

Moves

Function From To
run artifact_completeness/gate.py artifact_completeness/run.py
run declared_deps/gate.py declared_deps/run.py
field_problems platforms_mirror/decide.py platforms_mirror/field_problems.py
problems platforms_mirror/decide.py platforms_mirror/problems.py
_table_elements -> table_elements platforms_mirror/python_table.py platforms_mirror/table_elements.py

Colocated unit tests move with the code they cover rather than being duplicated. Call sites switch through relative imports: cli.py in both check packages, and platforms_mirror/gate.py (from .decide import problems -> from .problems import problems). Two integration tests that drove the check through gate.run now import from run.

Two notes on the last row. _table_elements takes its only caller _assigned_names with it -- leaving that helper in python_table.py would have made the two modules import each other, the cycle hazard #1053 calls out. And it loses its leading underscore, since a module existing only to hold a private function reads badly and the package already names modules after their function (python_table, row, typescript_table).

No constant moved, so none of #1053's relocated-constant mutation survivors apply. wheel_extension_load -> npm_binary_extension_load, the tree's one cross-package import, is untouched at this threshold.

Red/green

Does not apply. These are pure moves with no behavior change: no new observable behavior to capture in a red test, and the tests that cover the moved functions move with them and stay green throughout. Section "Removals are exempt" in AGENTS.md is the nearest analogue; the pushed-RED-CI gate has nothing to assert here.

Gates

just preflight -- 0 failing pairs, 3 skipped (the three packaging pairs, which need a built artifact). Notable results in the internals-checks lane:

  • one-function-per-file clean at the committed ceiling, and clean at 9 with the config temporarily rewritten.
  • unit-coverage 100%, unchanged.
  • unit mutation: 63 mutants tested, no survivors.
  • colocated-test (including the PR-only co-change check) clean.
  • unit lint isolation clean -- every new test file imports exactly one source module, the invariant the package already held.
  • internals/checks integration suite: 43 passed. E2E suite: 24 passed.

Manual run

Exercised all three affected CLIs against the real repo, output unchanged from main:

  • dirsql-checks platforms-mirror -> ok platforms-mirror: ... mirrors the shared fields ... across 5 published target(s)., exit 0
  • dirsql-checks declared-deps internals/checks/src -> silent, exit 0
  • dirsql-checks artifact-completeness --dist-dir <scratch dist with one staged target> --config putitoutthere.toml -> the skip line for dirsql-py, four incomplete artifact -- lines, the summary naming the likely cause, exit 1

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: N/A -- no packages/rust change
  • internals/checks/e2e-attestations/claude-1054-checks-ofpf9.json receipt written (just e2e-attest-internals-checks); git show --stat on the attest commit confirms it adds one file and deletes no sibling receipt (e2e attest silently deletes other branches' attestation receipts #1041)
  • Command(s) run: just test-e2e-internals-checks, just test-integration-internals-checks, just e2e-attest-internals-checks, just preflight
  • Result summary: e2e 24 passed, integration 43 passed, preflight 0 failing / 3 skipped

Changelog / Migrations

Neither is required. changelog_gate/decide.py's _ROOTS = ("packages", "plugins") puts internals/** outside the gate; no public API changes, so no migration fragment and no PARITY.md change.

Five module-scope functions shared a file with another function over the
9-line threshold. Each moves to its own module, with its colocated unit
tests:

  artifact_completeness/gate.py::run   -> artifact_completeness/run.py
  declared_deps/gate.py::run           -> declared_deps/run.py
  platforms_mirror/decide.py::field_problems -> platforms_mirror/field_problems.py
  platforms_mirror/decide.py::problems       -> platforms_mirror/problems.py
  platforms_mirror/python_table.py::_table_elements -> platforms_mirror/table_elements.py

`_table_elements` takes its only caller `_assigned_names` with it: leaving
that helper behind would have made python_table.py and the new module import
each other. It loses its underscore to match the module-per-function naming
the package already uses (`python_table`, `row`).

No config change -- the ceiling stays at 15 here and drops in a separate PR
once every lane is clean at 9.
The two CLI tests mock `run` at its import site and say so in their
docstrings; that site moved. The platforms-mirror gate test's isolation note
now covers the verdict module it runs through for real.
@thekevinscott
thekevinscott merged commit e0b13eb into main Sep 5, 2026
10 checks passed
@thekevinscott
thekevinscott deleted the claude/1054-checks-ofpf9 branch September 5, 2026 01:41
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.

ci: split internals/checks to clean one_function_per_file at 9

2 participants