Skip to content

QA: scan the package extensions with ExplicitImports - #51

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

ChrisRackauckas merged 1 commit into
SciML:mainfrom
ChrisRackauckas-Claude:qa-check-extensions

Conversation

@ChrisRackauckas-Claude

Copy link
Copy Markdown
Member

Please ignore this PR until it has been reviewed by @ChrisRackauckas.

Why

SciMLTesting.run_qa runs ExplicitImports' checks on the package module.
ExplicitImports does know about package extensions — it reads the [extensions]
table out of Project.toml — but it skips any extension whose module does not
exist, and an extension module only comes into existence once its trigger
(weak)dependency is loaded:

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

test/qa/Project.toml did not depend on any of this package's weakdeps, so none
of the five extensions were being scanned by QA at all
. Verified on the base
branch (main), from the unmodified QA environment:

BandedMatricesExt => nothing
BlockBandedMatricesExt => nothing
FastAlmostBandedMatricesExt => nothing
SpecialMatricesExt => nothing
ToeplitzMatricesExt => nothing
SCANNED: SparseMatrixIdentification

This was a real gap, not an incidental one — no test dependency was pulling any of
the weakdeps in transitively.

What changed

  • test/qa/Project.toml: added BandedMatrices, BlockBandedMatrices,
    FastAlmostBandedMatrices, SpecialMatrices, ToeplitzMatrices under [deps]
    (same UUIDs as the root [weakdeps]) with [compat] entries mirroring the root
    Project.toml bounds.
  • test/qa/qa.jl: using all five so the extension modules exist by the time
    run_qa runs.

Same probe on this branch:

BandedMatricesExt => BandedMatricesExt
BlockBandedMatricesExt => BlockBandedMatricesExt
FastAlmostBandedMatricesExt => FastAlmostBandedMatricesExt
SpecialMatricesExt => SpecialMatricesExt
ToeplitzMatricesExt => ToeplitzMatricesExt
SemiseparableMatricesExt => nothing
SCANNED: FastAlmostBandedMatricesExt
SCANNED: SparseMatrixIdentification
SCANNED: BlockBandedMatricesExt
SCANNED: BandedMatricesExt
SCANNED: SpecialMatricesExt
SCANNED: ToeplitzMatricesExt

Coverage

All 5 declared extensions are now scanned. Nothing was left out for
hardware/system-library reasons — every weakdep here is pure Julia.

SemiseparableMatrices is declared under [weakdeps] and [compat] in the root
Project.toml but has no [extensions] entry and no ext/ file, so there is
no extension module for ExplicitImports to scan. It is a dangling weakdep; adding
it to the QA environment would achieve nothing, so it was left out. Worth removing
from [weakdeps]/[compat] (or growing the extension it was presumably meant to
trigger) in a separate PR.

Findings the new coverage produced, and how each was handled

Fixed in the extension sources (no_implicit_imports)

Every extension did using SomePackage and then used names from it implicitly.
Replaced with explicit imports:

file before after
ext/BandedMatricesExt.jl using SparseMatrixIdentification, using BandedMatrices using SparseMatrixIdentification: SparseMatrixIdentification, using BandedMatrices: BandedMatrix
ext/BlockBandedMatricesExt.jl + using BlockBandedMatrices, using BandedMatrices using BlockBandedMatrices: BlockBandedMatrix (the BandedMatrices using was dropped — nothing from it was used; it remains a declared trigger in [extensions])
ext/FastAlmostBandedMatricesExt.jl + using FastAlmostBandedMatrices, using BandedMatrices using FastAlmostBandedMatrices: AlmostBandedMatrix, using BandedMatrices: BandedMatrix
ext/SpecialMatricesExt.jl + using SpecialMatrices using SpecialMatrices: Cauchy, Hilbert, Strang, Vandermonde
ext/ToeplitzMatricesExt.jl + using ToeplitzMatrices using ToeplitzMatrices: Toeplitz

No behavior change; GROUP=Core still passes (see below).

Ignored, with justification (all_qualified_accesses_are_public)

18 findings, and all 18 have SparseMatrixIdentification itself as the owner —
they are the extensions reaching into their own parent package, which is the only
way an extension can hook into it. One ignore group was added in test/qa/qa.jl
with a comment naming the owner and the reason:

  • try_almostbanded, try_banded, try_blockbanded, try_special_matrices,
    try_toeplitz — the stub functions each extension adds methods to.
  • _bandedmatrices_loaded, _blockbandedmatrices_loaded,
    _fastalmostbandedmatrices_loaded, _specialmatrices_loaded,
    _toeplitzmatrices_loaded — the Ref{Bool} flags each extension's __init__
    flips.
  • detect_block_size, is_almost_banded, is_banded, is_cauchy, is_hilbert,
    is_strang, is_toeplitz, is_vandermonde — the structure-detection predicates
    the extensions dispatch on.

None of these are declared public/exported, and there is no public spelling to
use instead, so there is nothing to "fix" in the extension source. No check was
disabled and no @test_broken was added.

Follow-up worth considering (deliberately not done here to keep this PR
reviewable): the five try_* functions are already documented in
docs/src/api.md under "Extension Point Functions", i.e. they are de-facto public
API that has never been declared public. Declaring them public (a minor
version bump) would let five of the eighteen ignores be dropped.

Local results

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

Test Summary: | Pass  Total     Time
QA/qa.jl      |   21     21  1m15.2s
     Testing SparseMatrixIdentification tests passed

Before this PR, the same command on this branch's test/qa content but without
the source fixes errored with no_implicit_imports and
all_qualified_accesses_are_public — i.e. the newly-scanned extensions did
produce real findings, which is the point.

GROUP=Core julia --project=. -e 'using Pkg; Pkg.test()' also passes with the
extension source changes (Testing SparseMatrixIdentification tests passed, all
12 test files green).

test/qa/Manifest.toml is a local build artifact and is not committed.

`run_qa` -> ExplicitImports skips any extension whose module does not exist, and
an extension module only exists once its trigger weakdep is loaded. The QA
environment loaded none of them, so all five extensions were unscanned.

Add the weakdeps to `test/qa/Project.toml` (with compat mirroring the root
Project.toml) and `using` them in `test/qa/qa.jl`.

The newly-scanned extensions produced two real findings:

* `no_implicit_imports` -- every extension did `using SomePackage` and then used
  names from it implicitly. Fixed at the source with explicit imports.
* `all_qualified_accesses_are_public` -- 18 accesses, all of them an extension
  reaching into its own parent package (the `try_*` stubs it adds methods to,
  the `_*_loaded` flags its `__init__` sets, and the `is_*`/`detect_*`
  predicates it dispatches on). None have a public spelling, so they are
  ignored as one commented group.

`SemiseparableMatrices` is a weakdep with no `[extensions]` entry, so it has no
extension module to scan and is not added to the QA environment.

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