Repository navigation
CI: a module-cycle ratchet that stops the top-level module cycle absorbing more modules - #387
Merged
Merged
Conversation
…rbing more modules 44 of the app crate's 56 top-level modules sit on one strongly connected component (~98% of the code): a few thin upward references (ui -> screens/app, gfx/text -> ui, plex -> route) close it. Untangling that is separate work; this stops it getting worse. ci/check-module-cycle.py builds the module graph from production code only (the module tree walked from lib.rs, so files reached through #[cfg(test)] mods are never read; comments and string contents blanked; #[cfg(test)] items blanked by brace matching, not "everything after the first cfg(test)"), computes SCCs and compares with ci/module-cycle-baseline.json. A module that newly joins a cycle, or a new module that lands inside it, fails with the file:line references that close the path; a member leaving the cycle prints a notice. It holds membership, not edges: a further reference between two modules already on the cycle is not caught. --update-baseline accepts a change, --report is the hand-off work list (thin back-edges with file:line, layer breaks), --dot emits graphviz. Runs in make check-python (CI host-python), ~1.4 s; ci/test_module_cycle.py covers it against a synthetic crate. Co-Authored-By: Claude Sonnet 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01PUkd69QzFciCfQucbfiyKv
GLinnik21
added a commit
that referenced
this pull request
Oct 2, 2026
… cycle (#389) spki imported the base64 helper from keymanager, and keymanager sits on the large top-level module cycle, so the spki -> keymanager reference pulled spki onto it (net -> spki closes it) and tripped the module-cycle ratchet added in #387. The helper references no other crate module, so it now lives in its own leaf module, crate::b64, with its behaviour and test unchanged. keymanager and spki both import it from there; spki and b64 stay outside the cycle and the ratchet baseline is untouched. Claude-Session: https://claude.ai/code/session_01PUkd69QzFciCfQucbfiyKv Co-authored-by: Claude Sonnet 5.5 <[email protected]>
GLinnik21
added a commit
that referenced
this pull request
Oct 26, 2026
…1053) Merging was done with ad-hoc `gh` calls, and twice it went wrong: #387 merged RED because `gh pr merge` was chained after a watcher that read "run completed" mid-run, and #924 read `gh run list` as success while checks were still running. `tools/pr-land.py` is now the one place that judges a PR's checks and merges it. - `pr-land.py gate N [--sha S]`: one verdict, one exit code. 0 green, 1 red, 3 refused (not OPEN, wrong base, BEHIND/DIRTY/HAS_HOOKS, a required check skipping or unknown, an unlisted merge state), 4 not yet (running, missing required check, empty or unstable list), 5 the head moved off S. Required checks come from the base branch's ruleset; a base that requires nothing needs a stable check list over two polls. Green requires `mergeStateStatus == CLEAN`. - `pr-land.py wait N --sha S [--timeout]`: the same judgment, polled. - `pr-land.py merge N --sha S --subject T (--body-file F | --body-from-pr)`: waits, then `gh pr merge N --squash --match-head-commit S`, with the SHA that was gated (never re-read), no `--admin`, `--auto` or branch deletion. A head race re-gates and retries only with the same SHA, otherwise exit 5. The squash message is scanned against the repo's private-value list through `outbound-guard.py` (fails closed), and what was scanned is byte-identical to what is sent. Afterwards it fetches `main` and checks the squash commit is an ancestor; a verify failure says the merge went through. - UNSTABLE (required checks pass, a non-required one such as CodeQL is still running or failed) is judged by its rows: a failed row is red and named, a pending row is "not yet", never green until CLEAN. Stage 1a of the automation series. `restack`, the `land-pr` skill and the outbound-guard refusal of a raw `gh pr merge` follow in their own changes. One independent review of the combined diff found no path to `gh pr merge` without green checks and the gated head, one MAJOR (UNSTABLE refused by name) and four MINOR; all fixed with the new cases red first. `python3 tools/test_pr_land.py`: 69 tests OK (fake `gh`, injected clock, temp dirs).
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.
What
A ratchet that stops the app crate's top-level module cycle absorbing more modules. This PR does not untangle anything. It holds the cycle's membership, not its edges: another upward reference between two modules already on the cycle (a sixth
ui -> screens) does not fail it (ci/check-deps.shand review still own that).ci/check-module-cycle.pybuilds the top-level module graph from production code only, computes strongly connected components and compares them with the committedci/module-cycle-baseline.json.crate::xreference, a new top-level module that lands inside the cycle, or two cycles merging). It prints the module and thefile:linereferences that close the path.--update-baselineto lock in the gain.--update-baselinerewrites the JSON;--reportis the hand-off list for the refactoring session;--dotemits graphviz.Graph construction: the real module tree is walked from
lib.rs(mod x;,#[path], literalinclude!), so files reached only through#[cfg(test)]modules are never read. Comments and string contents are blanked, then#[cfg(test)]items are blanked by brace matching (not "everything after the first#[cfg(test)]", which is what hidff -> hlsin the earlier regex scan). Limitations (textual matching,super::, macros, glob re-exports) are in the script docstring.Runs in
make check-python(CIhost-python), about 1.4 s.ci/test_module_cycle.pycovers it against a synthetic crate: layered graph passes, an upward edge namesfile:line, test-only edges are ignored, a new module inside the cycle fails, shrink notices,--update-baselineround-trips. Red on the real tree was shown in a scratch copy by adding acrate::uireference topaths.rs.--reportsummary (this tree)hlsandkeymanageroutside; they are inside:ff -> hls -> plex -> ... -> ff, and plex calls keymanager.)screens <-> ui(1413 / 5),app <-> ui(488 / 1),player <-> route(322 / 131),app <-> player(223 / 6),plex <-> route(1 / 211).file:linelist in--report):plex -> route(1):plex/session.rs:3914ui -> app(1):ui/more_menu.rs:655ui -> screens(5):ui/player_hud.rs:655, 737, 1839,ui/chapters_panel.rs:260, 313player -> app(6):player/pump.rs:389,player/preview.rs:777-778,player/machine.rs:38, 63text -> ui(11):text.rs:81, 576, 1473, ...gfx -> ui(43)webos -> ui,pms -> ui,plex -> ui,route -> ui,ui -> dev,ui -> lab,ui -> browse,ui -> metadata, ...) are listed by--reporttoo.Verification
make check(run on the first commit; the amend changed only prose and the script docstring):test result: ok. 5454 passed; 0 failed; 7 ignored,test result: ok. 102 passed; 0 failed,test result: ok. 5534 passed; 0 failed; 7 ignored, exit 0.make check-pythonexit 0 (ci/test_module_cycle.py: Ran 18 tests, OK;module-cycle: ok (44 modules on the cycle, baseline 44; 12 outside)).🤖 Generated with Claude Code
https://claude.ai/code/session_01PUkd69QzFciCfQucbfiyKv