Skip to content

QA: load Plots so the PlotsExt extension is actually scanned - #239

Merged
ChrisRackauckas merged 2 commits into
SciML:mainfrom
ChrisRackauckas-Claude:qa-check-extensions
Aug 1, 2026
Merged

ChrisRackauckas merged 2 commits into
SciML:mainfrom
ChrisRackauckas-Claude:qa-check-extensions

Conversation

@ChrisRackauckas-Claude

@ChrisRackauckas-Claude ChrisRackauckas-Claude commented Aug 1, 2026 •

Copy link
Copy Markdown
Member

This is a QA-infrastructure change opened for review, not a merge request. RootedTrees.jl is primarily maintained by @ranocha outside SciML, so this is offered as a suggestion — please treat it as a proposal to comment on rather than something to merge as-is. Please ignore until reviewed by @ChrisRackauckas.

Problem

SciMLTesting.run_qa runs ExplicitImports' checks on the package module. ExplicitImports does know about extensions — it reads the [extensions] table out of Project.toml and adds each extension to the set of checked modules — but only when the extension module actually exists:

ext_mod = Base.get_extension(mod, Symbol(ext))
ext_mod === nothing && continue

An extension module only exists once its trigger weakdep has been loaded. The QA environment (test/qa/Project.toml) did not depend on Plots, so PlotsExt was never scanned by QA.

This is invisible in the test summary: each ExplicitImports check folds all submodules into a single @test, so the QA output is byte-identical whether or not the extension is covered.

Change

  • test/qa/Project.toml: add Plots under [deps] (same UUID as the root [weakdeps] entry) and a [compat] entry mirroring the root Plots = "1.39" bound. Test is added alongside it for the load guard below.
  • test/qa/qa.jl: using Plots before run_qa, with a comment explaining why.
  • test/qa/qa.jl: a load guard asserting the extension really materialized (see below).

Coverage

Extension Status
PlotsExt now scanned

Nothing is left out — Plots is the only weakdep, and it resolves and loads fine in the QA environment.

Proof that PlotsExt is actually scanned

Run from the QA environment (ExplicitImports stacked in from a scratch env so it does not pollute test/qa/Project.toml):

With Plots loaded (this PR):

get_extension(RootedTrees, :PlotsExt) => PlotsExt
explicit_imports modules => Module[RootedTrees, PlotsExt]

Without Plots loaded (main today):

get_extension(RootedTrees, :PlotsExt) => nothing
explicit_imports modules => Module[RootedTrees]

Independently corroborated by the fact that adding using Plots immediately produced a new ExplicitImports failure that main never reported (below).

Load guard: keeping the coverage from silently regressing

The ext_mod === nothing && continue above is a silent skip. If someone later breaks PlotsExt's precompilation, or the weakdep drops out of the QA environment, Base.get_extension returns nothing, ExplicitImports quietly checks fewer modules, and run_qa still reports a completely green summary — coverage falls back to zero with nothing failing. Merely adding the dependency is therefore not self-defending.

So the PR also asserts the extension exists, rather than trusting a green run_qa:

# ExplicitImports silently skips an extension that fails to load, so assert the
# extension modules actually exist rather than trusting a green run_qa.
@testset "Extensions loaded" begin
    @test Base.get_extension(RootedTrees, :PlotsExt) !== nothing
end

This is the one assertion in the file whose failure unambiguously means "the extension is no longer being scanned."

Finding surfaced, and the one ignore entry added

Once PlotsExt was in scope, all_qualified_accesses_are_public errored:

Module `PlotsExt` has explicit imports of names from modules in which they are not public:
- `_distinguishable_colors` is not public in `RootedTrees` but it was imported from
  `RootedTrees` at ext/PlotsExt.jl:7:13

Justification for ignoring: RootedTrees._distinguishable_colors is RootedTrees' own internal hook — it exists specifically so PlotsExt can define a method for it (RootedTrees._distinguishable_colors(n) = Plots.distinguishable_colors(n)). An extension filling in its parent package's internal hook is exactly the intended design; ExplicitImports simply does not classify an extension module as internal to its parent, so it flags the access. There is no public spelling to switch to, and promoting an underscore-prefixed implementation hook to public API (which would also require documenting it, and would make it subject to SemVer) would be the wrong fix. So it is ignored, with a comment naming the owner and the reason:

ei_kwargs = (;
    all_qualified_accesses_are_public = (;
        # RootedTrees: `_distinguishable_colors` is RootedTrees' own internal hook,
        # defined precisely so that `PlotsExt` can fill it in. ExplicitImports does
        # not treat an extension as internal to its parent package, so the access
        # has to be ignored here.
        ignore = (:_distinguishable_colors,),
    ),
)

No check is disabled, nothing is marked @test_broken, and no extension source needed fixing — ext/PlotsExt.jl is already clean (using Plots: Plots, using RootedTrees: RootedTrees) and is untouched by this PR.

Local result

GROUP=QA julia --project=. -e 'using Pkg; Pkg.test()' on this branch:

Test Summary: | Pass  Total     Time
QA/qa.jl      |   21     21  1m23.0s
     Testing RootedTrees tests passed

21 rather than 20 because of the added load-guard @test. For contrast, the intermediate state (Plots loaded, no ignore entry) gave 19 passed, 0 failed, 1 errored — which is the evidence that the extension genuinely entered the scan.

test/qa/Manifest.toml is a local build artifact and is not committed (**/Manifest.toml is already gitignored).

ExplicitImports only adds an extension module to the set of checked
modules when `Base.get_extension` returns non-`nothing`, which requires
the trigger package to be loaded. The QA environment did not load Plots,
so `PlotsExt` was never scanned.

Add Plots to `test/qa/Project.toml` and load it in `qa.jl`. The one
finding this surfaces is `PlotsExt` accessing `RootedTrees._distinguishable_colors`,
which is RootedTrees' own internal hook that the extension exists to fill
in; it is ignored with a comment rather than promoted to public API.

Co-Authored-By: Chris Rackauckas <accounts@chrisrackauckas.com>
`Base.get_extension` returning `nothing` makes ExplicitImports silently
skip the extension and still report a clean pass, so a future
precompilation break in `PlotsExt` would drop QA coverage back to zero
without failing anything. Guard against that explicitly.

Co-Authored-By: Chris Rackauckas <accounts@chrisrackauckas.com>
@ChrisRackauckas
ChrisRackauckas marked this pull request as ready for review August 1, 2026 08:39
@ChrisRackauckas
ChrisRackauckas merged commit a574e43 into SciML:main Aug 1, 2026
10 checks passed
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