Skip to content

Restore ProblemTypeCtx as the discretization metadata key - #99

Merged
ChrisRackauckas merged 2 commits into
SciML:masterfrom
ChrisRackauckas-Claude:agent/restore-problemtypectx
Jul 29, 2026
Merged

ChrisRackauckas merged 2 commits into
SciML:masterfrom
ChrisRackauckas-Claude:agent/restore-problemtypectx

Conversation

@ChrisRackauckas-Claude

Copy link
Copy Markdown
Member

Follow-up to #98, which merged before this fix landed on its branch.

Problem

#98 replaced ModelingToolkitBase.ProblemTypeCtx with a PDEBase-local PDEBaseMetadataCtx in src/discretization_state.jl. That was done to clear a QA ignore — ProblemTypeCtx is a non-public ModelingToolkitBase name, and master's old test/qa/qa.jl listed it under both all_explicit_imports_via_owners and all_explicit_imports_are_public.

ProblemTypeCtx is not a private helper that can be substituted. It is a documented protocol key with behavior attached in two packages:

  • ModelingToolkitBase/src/systems/system.jl:1210 — "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", read at problems/odeproblem.jl:133 and problems/nonlinearproblem.jl:127.
  • SciMLBase/src/solutions/basic_solutions.jl:195 — wrap_sol(sol) reads problem_type(prob) and, per solutions/pde_solutions.jl:160, routes an AbstractDiscretizationMetadata to PDETimeSeriesSolution / PDENoTimeSolution. Anything else falls through to wrap_sol(sol, _) = sol.

PDEBase writes that key so SciMLBase wraps the solve result. With a different key the metadata never reaches problem_type, and a raw ODESolution comes back — with no error at discretize or solve time.

Measured on Julia 1.12.6, same heat-equation script, only PDEBase swapped:

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

MethodOfLines also reads the old key directly at MOL_discretization.jl:117 and staggered_discretize.jl:10/:17.

Fix

Import ProblemTypeCtx from ModelingToolkitBase — the owner — instead of through the ModelingToolkit re-export. That satisfies the owner check by itself. The publicness check needs the upstream declaration in SciML/ModelingToolkit.jl#4842, so test/qa/qa.jl keeps exactly one narrow ignore pointing at it; everything else stays strict. Once #4842 releases, that ignore can be deleted.

Validation

  • GROUP=Core Pkg.test() on 1.12.6 against this branch: 12 + 18 + 46 pass.
  • MethodOfLines Sol_Interface (12/12) and Burgers pass against this branch with MOL compat locally widened.
  • Runic clean.

Note on downstream

Downstream is red on master independently of this PR: master is now 0.2.0 and MethodOfLines pins PDEBase = "0.1.29", so every downstream job dies at resolution. That needs a MethodOfLines PR — compat "0.1.29, 0.2", plus using DomainSets: Interval and import SciMLBase.symbolic_discretize, since PDEBase no longer re-exports either (a hard load error on the Julia LTS, only a warning on 1.11+). Tracked separately from this fix.

Ignore until reviewed by @ChrisRackauckas.

🤖 Generated with Claude Code

https://claude.ai/code/session_0117aJvytDT3y2jMi5Ng6Q5m

Substituting a PDEBase-owned metadata key for `ProblemTypeCtx` silently
broke the MethodOfLines solution interface. `ProblemTypeCtx` is not a
private helper that can be reproduced locally: ModelingToolkitBase reads
it to populate `prob.problem_type`, and SciMLBase's `wrap_sol` dispatches
on that value to build a `PDETimeSeriesSolution`. With a different key the
metadata never reaches `problem_type`, `wrap_sol` falls through to the
identity method, and a raw `ODESolution` comes back with no error at
discretize or solve time, so `sol[u(t,x)]` fails.

Import it from ModelingToolkitBase, the owner, rather than through the
ModelingToolkit re-export. That satisfies the owner check; the remaining
publicness check needs the upstream `public` declaration in
SciML/ModelingToolkit.jl#4842, so keep one narrow
QA ignore until that ships.

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
`ProblemTypeCtx` is public as of ModelingToolkitBase 1.58.0
(SciML/ModelingToolkit.jl#4842), so PDEBase can
import it from its owner with no exception. QA is now fully strict.

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

Pushed c3d18b3. ModelingToolkitBase 1.58.0 is registered (JuliaRegistries/General#162639), so the temporary QA ignore is gone — test/qa/qa.jl is back to a bare run_qa(PDEBase) with zero ignores, and Project.toml now requires ModelingToolkitBase = "1.58".

This completes the intent of #98 without the workaround: ProblemTypeCtx is imported from its owner, and it is public there rather than being substituted with a PDEBase-local key.

Verified against the registered 1.58.0 (not a dev checkout) on Julia 1.12.6:

resolved ModelingToolkitBase = 1.58.0
Base.ispublic(ModelingToolkitBase, :ProblemTypeCtx) = true

Test Summary: | Pass  Total     Time
QA/qa.jl      |   20     20  1m42.0s
     Testing PDEBase tests passed

Core/alloc_tests.jl             | 12  12
Core/discrete_initialization.jl | 18  18
Core/public_api.jl              | 46  46
     Testing PDEBase tests passed

Runic --check clean.

Two things remain outside this PR:

Ignore until reviewed by @ChrisRackauckas.

@ChrisRackauckas
ChrisRackauckas marked this pull request as ready for review July 29, 2026 11:34
@ChrisRackauckas
ChrisRackauckas merged commit 1cf0ae2 into SciML:master Jul 29, 2026
6 of 20 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