Skip to content

Make ProblemTypeCtx public API - #4842

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

Make ProblemTypeCtx public API#4842
ChrisRackauckas merged 2 commits into
SciML:masterfrom
ChrisRackauckas-Claude:agent/public-problemtypectx

Conversation

@ChrisRackauckas-Claude

Copy link
Copy Markdown
Member

Summary

Marks ModelingToolkitBase.ProblemTypeCtx as @public and adds it to the rendered docs.

ProblemTypeCtx is already documented in lib/ModelingToolkitBase/src/systems/system.jl as the metadata key controlling problem_type:

Metadata key for systems containing the problem_type to be passed to the problem constructor, where applicable. For example, if getmetadata(sys, ProblemTypeCtx, nothing) is CustomType() then ODEProblem(sys, ...).problem_type will be CustomType() instead of StandardODEProblem.

It is read at lib/ModelingToolkitBase/src/problems/odeproblem.jl:133 and problems/nonlinearproblem.jl:127, and the resulting prob.problem_type is what SciMLBase.wrap_sol dispatches on (SciMLBase/src/solutions/basic_solutions.jl:195solutions/pde_solutions.jl:160) to wrap a solve result in PDETimeSeriesSolution / PDENoTimeSolution.

So it is a cross-package protocol key: PDE discretization stacks have to write it for their solutions to be wrapped correctly. But it was neither exported nor public, so there was no non-internal way to reach it. MTKVariableTypeCtx is already @public, so this just gives the same treatment to the other metadata context type.

Motivation

Found while reviewing SciML/PDEBase.jl#98. A strict-QA pass there flagged ProblemTypeCtx as a non-public name and the workaround was to substitute a PDEBase-local key. That silently broke the MethodOfLines solution interface: prob.problem_type fell back to StandardODEProblem, wrap_sol stopped producing a PDETimeSeriesSolution, and sol[u(t,x)] failed with ArgumentError: Symbol u(t, x) is not present in the system — with no error at discretize or solve time. Making the key public removes the incentive to work around it.

Validation

Verified locally on Julia 1.12.6:

ispublic(ProblemTypeCtx) = true
has docstring           = true

Runic --check clean on the changed source file. Version bumped 1.57.01.58.0 (additive public API).

Ignore until reviewed by @ChrisRackauckas.

🤖 Generated with Claude Code

https://claude.ai/code/session_0117aJvytDT3y2jMi5Ng6Q5m

`ProblemTypeCtx` is the documented metadata key that controls
`prob.problem_type`, read by `ODEProblem` and `NonlinearProblem`
construction. SciMLBase's `wrap_sol` dispatches on that value, so PDE
discretization packages must set it to have their solutions wrapped in
`PDETimeSeriesSolution` / `PDENoTimeSolution`. It is a cross-package
protocol key, but was neither exported nor `public`, so downstream users
had no non-internal way to reach it.

Mark it `@public` and add it to the rendered docs. `MTKVariableTypeCtx`
is already public, so this follows the existing treatment of metadata
context types.

Co-Authored-By: Chris Rackauckas <accounts@chrisrackauckas.com>
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_0117aJvytDT3y2jMi5Ng6Q5m
ChrisRackauckas-Claude pushed a commit to ChrisRackauckas-Claude/PDEBase.jl that referenced this pull request Jul 29, 2026
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 <accounts@chrisrackauckas.com>
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_0117aJvytDT3y2jMi5Ng6Q5m
@ChrisRackauckas
ChrisRackauckas marked this pull request as ready for review July 29, 2026 10:40
@ChrisRackauckas
ChrisRackauckas merged commit cdb7ad5 into SciML:master Jul 29, 2026
81 of 93 checks passed
ChrisRackauckas-Claude pushed a commit to ChrisRackauckas-Claude/PDEBase.jl that referenced this pull request Jul 29, 2026
`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 <accounts@chrisrackauckas.com>
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_0117aJvytDT3y2jMi5Ng6Q5m
ChrisRackauckas added a commit to SciML/PDEBase.jl that referenced this pull request Jul 29, 2026
* Revert PDEBaseMetadataCtx back to ProblemTypeCtx

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 <accounts@chrisrackauckas.com>
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_0117aJvytDT3y2jMi5Ng6Q5m

* Require ModelingToolkitBase 1.58 and drop the last QA ignore

`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 <accounts@chrisrackauckas.com>
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_0117aJvytDT3y2jMi5Ng6Q5m

---------

Co-authored-by: ChrisRackauckas-Claude <accounts@chrisrackauckas.com>
Co-authored-by: Claude Opus 5 (1M context) <noreply@anthropic.com>
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