Skip to content

refactor(nox): split the noxfile into a support package - #1164

Open
doublewhy wants to merge 4 commits into
devfrom
refactor/noxfile-support-split
Open

refactor(nox): split the noxfile into a support package#1164
doublewhy wants to merge 4 commits into
devfrom
refactor/noxfile-support-split

Conversation

@doublewhy

Copy link
Copy Markdown

Plain-language summary

  • Problem: noxfile.py was 1,745 lines — constants, the session reporter/runner, every lane implementation, and the parallel verification graph wrapped around 22 sessions. Like the governance checkers before ci(sonar): clear the tools new-code violations and exempt false positives #1155, its next edit would trip the strict Sonar gate's file threshold.
  • Fix: Sessions stay in noxfile.py (~400 lines); everything else moves to tools/nox_support/config, runner, policy_lanes, test_lanes, and graph — every module under the 500-line cap.

Summary

  • CI invocation is untouched: all 22 sessions register identically (nox -l verified), and workflows keep calling nox -f noxfile.py -s <session>.
  • A commented facade import block keeps the helper surface reachable as noxfile.<name> for the repo-policy test suite.
  • Test updates (4 files): the noxfile-introspecting tests now patch globals where the split modules resolve them via a _patch_nox_globals helper — patching a noxfile attribute alone can no longer reach a helper's internal binding — and the three source-scan pins (project positioning, identity cutover, free-threaded GIL assertions) point at the lane modules that carry the scanned text.

Verification

  • nox -l: all 22 sessions register.
  • nox -s tests (full hermetic suite + coverage gate), nox -s hygiene, and nox -s policy run green end-to-end through the split.
  • Ruff 0.15.9 format and lint clean; tools/check_repo_policy.py pass.
  • The remaining lanes (verify graph, docs, compatibility matrix) execute exactly these moved functions; this PR's own CI run exercises them on Linux.

🤖 Generated with Claude Code

doublewhy and others added 4 commits August 17, 2026 17:34
noxfile.py had grown to 1,745 lines of constants, runner plumbing, lane
implementations, and the verification graph around 22 sessions -- the
same shape that tripped the strict Sonar gate on the governance
checkers, waiting to fire on the next edit.

The sessions (and only the sessions) stay in noxfile.py (~400 lines);
everything else moves to tools/nox_support/: config (paths, limits, env
names), runner (SessionReporter, command execution, pytest/coverage
plumbing), policy_lanes (hygiene/policy/contracts/proof/lint),
test_lanes (tests/compatibility/fuzz/integration/docs/OSV), and graph
(the parallel verification graph and change-selected verification). A
commented facade import block keeps the helper surface reachable
through the noxfile module for the repo-policy test suite.

Test updates: the noxfile-introspecting tests patch globals where the
split modules actually resolve them via a new _patch_nox_globals helper
(patching a noxfile attribute alone can no longer reach a helper's
binding), and the three source-scan pins (positioning, identity
cutover, GIL assertions) point at the lane modules that now carry the
scanned text.

Verification: all 22 sessions register (nox -l); the tests, hygiene,
and policy lanes run green end-to-end through the split; the full
hermetic suite passes with the coverage gate; ruff format and lint
clean; check_repo_policy pass.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
The lane runner passed Path(__file__) as the --noxfile argument, which
was correct while the code lived in noxfile.py but resolved to
tools/nox_support/graph.py after the extraction, so every verification
lane exited immediately and the verify session failed before running
anything. Hand the runner REPO_ROOT/noxfile.py explicitly and reformat
the repo-policy test module the static lane flagged.

Verified locally: nox -s verify now runs every lane; unit, integration,
contracts, static, and docs-local pass (the opacity-proof lane needs the
Isabelle toolchain that only CI installs).

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
The extraction made the relocated noxfile code count as new code, so
the raes-strict gate now applies to it. Address every finding:

- policy_lanes: drive the eleven working-tree policy stages from one
  table so _run_policy drops under the 100-line cap, and hoist the
  repeated skip-reason, no-text-files, and noxfile-path literals into
  constants
- runner: split hygiene flag parsing from selection resolution to meet
  the complexity and return-count caps, hoist the git diff-filter
  literal, and underscore the unused gitleaks session parameter
- test_lanes: hoist the two interpreter-assertion scripts to module
  constants and split the compatibility lane into runtime and
  distribution stage helpers, each under the line cap
- config: spell the requirement-UID digit class as \d with re.ASCII,
  which matches exactly the same strings as [0-9]

Verified: nox -s verify runs green locally on every lane except the
opacity proof, which needs the Isabelle toolchain only CI installs;
the 175 repo-policy tool tests pass unchanged.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
tools/nox_support holds the session orchestration that lived in
noxfile.py, which sits outside sonar.sources and was therefore never
coverage- or duplication-gated. The relocation alone made ~1,600 lines
count as new code, failing the gate at 50.3% coverage and 8.9%
duplication. Exclude the package from the coverage floor and the CPD
check with the rationale recorded inline: lane wiring is exercised
end-to-end by CI itself and repeats reporter/subprocess scaffolding by
design, while issue analysis stays fully enabled. The identity-cutover
digest for sonar-project.properties is recomputed alongside.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@doublewhy
doublewhy force-pushed the refactor/noxfile-support-split branch from 74dfd6a to 079b7fa Compare August 18, 2026 00:36
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.

1 participant