Skip to content

Raise a clear ArgumentError converting an SCCNonlinearProblem to NonlinearProblem - #1614

Merged
ChrisRackauckas-Claude merged 4 commits into
SciML:masterfrom
ChrisRackauckas-Claude:fix/scc-nonlinearproblem-identity
Oct 22, 2026
Merged

ChrisRackauckas-Claude merged 4 commits into
SciML:masterfrom
ChrisRackauckas-Claude:fix/scc-nonlinearproblem-identity

Conversation

@ChrisRackauckas-Claude

@ChrisRackauckas-Claude ChrisRackauckas-Claude commented Sep 23, 2026 •

Copy link
Copy Markdown
Member

Please ignore until reviewed by @ChrisRackauckas.

What changed and why

GROUP=SymbolicIndexingInterface is (or was) red on master (CI run https://github.com/SciML/SciMLBase.jl/actions/runs/35839187919): init(ssprob, DynamicSS(Tsit5())) on an MTK-lowered SCC steady-state problem throws FieldError: type SCCNonlinearProblem has no field u0.

Root cause: NonlinearProblem(prob::AbstractNonlinearProblem) = NonlinearProblem{isinplace(prob)}(prob.f, prob.u0, prob.p) assumes every AbstractNonlinearProblem subtype has a u0 field. SCCNonlinearProblem never has one (its state is the concatenation of its sub-problems' states), so calling NonlinearProblem(x) on an SCCNonlinearProblem has always thrown this FieldError, standalone, with no other package involved:

using SciMLBase
f1 = NonlinearFunction((du, u, p) -> (du .= u .^ 2 .- p))
prob1 = NonlinearProblem(f1, [1.0], 4.0)
sccprob = SciMLBase.SCCNonlinearProblem((prob1,), (Returns(nothing),))
NonlinearProblem(sccprob)   # FieldError on master

Revision history on this PR

An earlier version of this PR made NonlinearProblem(prob::SCCNonlinearProblem) an identity (= prob), matching how a stored NonlinearProblem/LinearProblem lowered_problem is already handled verbatim elsewhere ("stored problem is used verbatim" in test/problem_building_test.jl). Review caught two problems with that:

  1. It doesn't fix the reported CI failure at all — the real cause is SteadyStateDiffEq.jl having no __init for DynamicSS/SICNM, which is fixed independently and sufficiently in Add __init for DynamicSS/SICNM so init() doesn't fall through to NonlinearSolve's default SteadyStateDiffEq.jl#173 (confirmed: that fix alone, against today's unmodified SciMLBase, resolves the reported failure).
  2. Worse, the identity is itself a footgun and a hazard: a NonlinearProblem constructor returning something that is not a NonlinearProblem breaks any caller that assumes .u0/.lb/.ub/etc., and it is exactly what let NonlinearSolve.jl's default-algorithm converter (src/default.jl, which does nlprob = NonlinearProblem(prob); return __init(nlprob, nothing, args...)) recurse forever instead of terminating, once it received nlprob === prob. Reproduced:
    Warning: detected a stack overflow; program state may be corrupted, so further execution might be unreliable.
    ERROR: LoadError: StackOverflowError:
     [1] __init(prob::SCCNonlinearProblem{...}, ::Nothing, args::DynamicSS{...}; ...) (repeats 39992 times)
    

What this PR does now

SCCNonlinearProblem solves as an ordered sequence of block solves (see SciMLBase.solve(::SCCNonlinearProblem, ::Union{DynamicSS,SICNM}, ...) and SSRootfind's handling in SteadyStateDiffEq.jl), not a single residual — there is no faithful NonlinearProblem to construct from it. So NonlinearProblem(prob::SCCNonlinearProblem) now raises a clear ArgumentError:

ArgumentError: an SCCNonlinearProblem cannot be converted to a NonlinearProblem; solve it directly or use its component problems.

An error cannot recurse, so this also removes the recursion hazard above without needing a companion guard in NonlinearSolve.jl (the earlier companion PR, SciML/NonlinearSolve.jl#1327, has been closed as unnecessary: NonlinearProblem(prob) never returns prob itself now, so the nlprob === prob case it guarded against cannot occur).

Verification

Standalone reproducer, fail-before/pass-after:

Before (unmodified master):

Caught: FieldError -- FieldError: type SCCNonlinearProblem has no field `u0`, available fields: `probs`, `explicitfuns!`, `f`, `p`, `parameters_alias`

After (this PR):

Caught: ArgumentError -- ArgumentError: an SCCNonlinearProblem cannot be converted to a NonlinearProblem; solve it directly or use its component problems.

Regression test updated to @test_throws ArgumentError NonlinearProblem(sccprob) in test/problem_building_test.jl (still discriminates: throws FieldError on unmodified master, so @test_throws ArgumentError fails there and passes here).

GROUP=Core passes locally in full, including the updated test (Problem building tests | 182 182):

     Testing SciMLBase tests passed

Runic --check and typos are clean on both changed files.

What I did not verify

  • Did not run the actual downstream GROUP=SymbolicIndexingInterface test in isolation against this PR — see Add __init for DynamicSS/SICNM so init() doesn't fall through to NonlinearSolve's default SteadyStateDiffEq.jl#173 body for why that test doesn't need this PR at all (it is fixed independently there).
  • Did not run GROUP=QA locally (PythonCall/CondaPkg fails to start on this machine, unrelated to this change).
  • Did not audit every existing caller of NonlinearProblem on an AbstractSteadyStateProblem-typed value for reliance on the old identity behavior; grepped SteadyStateDiffEq.jl's source and test suite (including its new tests in PR Add a page describing the init and solve interfaces #173) and found none that call NonlinearProblem directly on an already-built SCCNonlinearProblem — all existing callers only convert a SteadyStateProblem (which correctly returns the stored SCCNonlinearProblem verbatim; that path is untouched by this change).

Links

🤖 Generated with Claude Code

https://claude.ai/code/session_01NB3oFTNzGW79UtDt8AyjsM

Risk assessment

  • Risk: low
  • Blast radius: Only code that calls NonlinearProblem(::SCCNonlinearProblem). That call already failed on master with FieldError: type SCCNonlinearProblem has no field u0. With this PR it fails with an ArgumentError instead, so nothing that works today stops working. The one downstream path it touches is the MTK steady-state init(ssprob, DynamicSS(...)) route through NonlinearSolve's src/default.jl. That path fails before and after; only the error type changes. The PR adds one 4-line method, NonlinearProblem(prob::SCCNonlinearProblem), in src/problems/nonlinear_problems.jl, plus one @test_throws ArgumentError in test/problem_building_test.jl. It uses no non-public internals of dependencies. There's no SemVer concern, since the only change is which exception is thrown for an input that was never supported. No tests are weakened or skipped.
  • Evidence: The head commit is 7a57389 (CI ran 2026-09-24). It is 13 commits behind master and was branched from b7076b5. I compared all 8 failing checks with master runs, and every one is pre-existing:
    • tests / SymbolicIndexingInterface (julia 1, lts): pre-existing. These fail on every master "Run Tests" run from 2026-09-23 to 2026-10-03, including 37100169960 on master head 432e985, and on the merge base (35923456549). It's the same testset, "Symbol and integer based indexing of interpolated solutions". On master it throws the FieldError; on this PR it throws the new ArgumentError. So the PR changes the message but doesn't fix the test.
    • tests / QA (julia 1): pre-existing at the base. ExplicitImports flags Base.Callable at nonlinear_problems.jl:256, a line this PR doesn't touch. QA also failed on the merge base (35923456549) and on master 36036224472. Master fixed it later in Use the local Callable alias instead of non-public Base.Callable #1608, so it should clear after a rebase.
    • SciMLSensitivity.jl/Core1, Core6, Core7: pre-existing. The same testsets fail on master IntegrationTest 37100169941 (2026-10-03) and 36518786705: "Mooncake with MooncakeAdjoint", "Complex Matrix FiniteDiff Adjoint" and "Fully Out of Place adjoint sensitivity".
    • SciMLSensitivity.jl/Core8: pre-existing at the base. "Enzyme/Mooncake through init" in desauty_dae_mwe.jl also fails on master 36518786705 and 36447374379. It passes on current master since Un-break Mooncake DAE initialization observable AD test (fixes #1568) #1576, so it needs a rebase to confirm.
    • Catalyst/All/1 (ReleaseTest): pre-existing. It fails on master 37100169405 with the same infrastructure error: SystemError: opening .../Catalyst/.../test/extensions/Project.toml: Permission denied.
    • All other checks pass, including Core on julia 1, lts and x86, the Downstream groups, every ModelingToolkit and NonlinearSolve downstream group, Runic, typos and docs.
  • Independent review: Devin CLI / fusion-claude-opus-5-5-high-sidekick-swe-2-medium rated it low, high confidence: the change swaps one exception for a clearer one on a call that always failed, and every failing check also fails on master or at the merge base.
  • Merge: needs human review. No regressions, but these points need a person:
    1. The PR doesn't fix the CI failure it was opened for. SymbolicIndexingInterface stays red, and the real fix, Add __init for DynamicSS/SICNM so init() doesn't fall through to NonlinearSolve's default SteadyStateDiffEq.jl#173, is still open and unmerged. The description says this.
    2. It's a design decision that overlaps with the still-open Route SCC-lowered SteadyStateProblems through the default init/solve NonlinearSolve.jl#1319, which another approach to the same error (a maintainer, SebastianM-C, pointed to it on the PR). It also commits SciMLBase to "an SCC problem can never be converted to a NonlinearProblem", and a maintainer should confirm that's the intended contract.
    3. The body opens with "Please ignore until reviewed by @ChrisRackauckas", and no review has been done.
    4. CI is stale: the head is 13 commits behind master, and the QA and Core8 failures were fixed on master after the branch point. It should be rebased and CI re-run before merging.
    5. Small things: 4 of the 6 added test lines are a comment, the branch name fix/scc-nonlinearproblem-identity describes the earlier identity-returning approach, and the PR body lacks the standard agent-attribution banner and footer. The description is otherwise complete. It says QA wasn't run locally and SymbolicIndexingInterface wasn't run against this PR.

🤖 Risk assessment posted by an AI agent (fleet master) — harness: Devin CLI / fusion-claude-opus-5-5-high-sidekick-swe-2-medium; dispatched by Devin CLI 3000.11.3 fleet-master caretaker, model Fusion (claude-opus-5-5 medium + swe-2 medium)
Conversation: local transcript (no session URL)

🤖 Automated review section from an AI agent running as Chris Rackauckas's account — not written or reviewed by Chris.

Risk assessment (independent review, Codex CLI (gpt-6.1-sol), local job oss-reviews-2026-10-22-SciML-SciMLBase-jl-1614-codex-22e8a0f (no session URL), head 22e8a0f)

  • Verdict: MERGE
  • Risk: low (L6)
  • Summary: MERGE (low (L6)) at head 22e8a0f
  • Merge: ready to merge

Executed review notes (head 22e8a0f):

Review of #1614 (head 22e8a0f)

  • Reviewed risk note: Risk: low**
    Public API: Adds a specific rejection for NonlinearProblem(::SCCNonlinearProblem), which already throws FieldError on master. No successful conversion is removed; a major version bump is not warranted for this diagnostic fix. The SteadyStateProblem lowering constructor remains separate and unchanged.
    Numerics/algorithms: No residual evaluation, block ordering, solver selection, or numerical algorithm changes.
    Dependencies/compat: No dependency, license, or compatibility changes.
    Tests changed or missing: Adds one discriminating exception assertion; independently observed it fail on master and pass at head. No skipped assertions, weakened expectations, or tolerance changes. Diagnostic wording is not asserted.
    Performance/GPU/AD paths: Only the unsupported conversion path changes; successful construction and execution paths are untouched. No performance-sensitive implementation changes.
    Downstream reach: Restricted to callers attempting this already-invalid SCC conversion. This improves the error; it does not make a downstream solve that attempts the conversion succeed.

Findings

  1. test/problem_building_test.jl:357; nit; The new assertion checks only ArgumentError, although the stated benefit is a clear diagnostic. Consider asserting a distinctive message fragment such as "cannot be converted to a NonlinearProblem" as well. The existing assertion adequately distinguishes master from this fix, so this is not a merge blocker.

No blocking correctness findings. The specialized method avoids reading the nonexistent u0 field and does not return an SCC object into code expecting an ordinary residual problem. Its dispatch does not intercept the distinct SteadyStateProblem constructor or ordinary nonlinear conversions.

What I ran
All Julia commands used JULIA_NUM_THREADS=4 JULIA_NUM_PRECOMPILE_TASKS=4 and timeout 3600. The +release channel resolved to Julia 1.13.2. Scratch environments and source copies are under ./tmp; ./repo's tracked files were not modified.

  1. git -C repo diff master HEAD --stat; git -C repo rev-parse master; git -C repo status --short
    Confirmed head 22e8a0f differs from local master 365283c only by the supplied 17 added lines in two files. Working tree clean.

  2. julia +release --project=@runic -m Runic --check repo/src/problems/nonlinear_problems.jl repo/test/problem_building_test.jl
    Exit 0; no formatting diagnostics. Log: tmp/runic.log.

  3. typos pr.diff
    Exit 0; no spelling diagnostics.

  4. git -C repo diff --check master HEAD
    Exit 0; no whitespace diagnostics.

  5. julia +release --startup-file=no --project=tmp/testenv -e 'using Pkg; Pkg.develop(path="repo"); Pkg.add(["StaticArrays", "Accessors", "ConstructionBase", "SymbolicIndexingInterface", "SafeTestsets", "SciMLTesting"]); using Test; @testset "problem_building_test.jl" begin include("repo/test/problem_building_test.jl") end'
    Exit 0; 188/188 assertions passed, including the new exception assertion. Log: tmp/problem-tests.log.

  6. Created scratch source copies using git -C repo archive HEAD and git -C repo archive master, extracted into tmp/head and tmp/base respectively.
    julia +release --startup-file=no --project=tmp/baseenv -e 'using Pkg; Pkg.develop(path="tmp/base"); Pkg.add(["StaticArrays", "Accessors", "ConstructionBase", "SymbolicIndexingInterface"]); using Test; @testset "head tests against master" begin include("repo/test/problem_building_test.jl") end'
    Exit 1; 187 passed, exactly 1 failed. The new assertion at line 357 expected ArgumentError and received FieldError: type SCCNonlinearProblem has no field u0. All other assertions passed. This is the intended regression demonstration, not an additional master failure. Log: tmp/base-tests.log.

  7. GROUP=QA julia +release --startup-file=no --project=tmp/testenv -e 'include("tmp/head/test/runtests.jl")'
    Exit 1 before QA assertions: after group-environment activation, SafeTestsets was unavailable in the active environment. Log: tmp/qa.log.

  8. GROUP=QA julia +release --startup-file=no --project=tmp/testenv -e 'push!(LOAD_PATH, abspath("tmp/testenv")); include("tmp/head/test/runtests.jl")'
    Exit 0; QA 123/123 assertions passed. The explicit fallback load path supplies the test harness after group-environment activation; no test assertions or repository files were changed. Log: tmp/qa-retry.log.

Not verified
Did not run the entire Core group, docs build, other Julia versions, downstream integration suites, GPU execution, AD workloads, or benchmarks. Ran the entire affected test file and the repository QA entry point instead.

The supplied CI snapshot includes six failures: Catalyst/All/1, SciMLSensitivity Core4 and Core8, Reactant, and SymbolicIndexingInterface on Julia 1 and lts. Their failure logs and matching master runs were not supplied or independently fetched, so I cannot establish whether those failures are pre-existing. I do not attribute them to this PR or certify CI as regression-free. The PR body's older CI assessment is not independent evidence for the current head.

No GitHub access, posting, commits, or pushes were attempted.


Independent review by an AI agent — harness: codex-cli 0.162.1 · model: gpt-6.1-sol · Codex exec session 01a14a0c-50bb-7e51-8e28-b329d6e0c6dd · 2026-10-17 13:34 UTC. Not posted to GitHub.


🤖 Posted by an AI agent — harness: Codex CLI · model: gpt-6.1-sol (independent reviewer; appended by Antigravity CLI · model: gemini-4-argon-high)
Conversation: local job oss-reviews-2026-10-22-SciML-SciMLBase-jl-1614-codex-22e8a0f (no session URL)

NonlinearProblem(prob::AbstractNonlinearProblem) generically rebuilds
prob via prob.f, prob.u0, prob.p, but SCCNonlinearProblem has no u0
field (its state is the concatenation of its sub-problems' states).
Calling NonlinearProblem on an SCCNonlinearProblem therefore threw a
FieldError instead of returning the (already valid) problem unchanged.

This was latent until ModelingToolkit.jl started storing an
SCCNonlinearProblem in SteadyStateProblem's lowered_problem field:
NonlinearProblem(::SteadyStateProblem) correctly returns that stored
problem verbatim, but a downstream caller normalizing the result via
NonlinearProblem() again hit the generic fallback.

Add an identity method for SCCNonlinearProblem alongside a regression
test.

Co-Authored-By: Chris Rackauckas <[email protected]>
Co-Authored-By: Claude Sonnet <[email protected]>
Agent-Harness: Claude Code 2.1.251 (subagent)
Agent-Model: claude-sonnet
Agent-Session: https://claude.ai/code/session_01NB3oFTNzGW79UtDt8AyjsM
@SebastianM-C

Copy link
Copy Markdown
Member

SciML/NonlinearSolve.jl#1319 is also related to the same error

…inearProblem

NonlinearProblem(prob::AbstractNonlinearProblem) rebuilds via prob.f/prob.u0/
prob.p, but SCCNonlinearProblem has no u0 field, so this threw an opaque
FieldError. Returning prob unchanged (an earlier version of this fix) is its
own footgun: a NonlinearProblem constructor returning something that isn't a
NonlinearProblem breaks any caller assuming .u0/.lb/.ub, and it is exactly
what let a caller that re-normalizes its result (NonlinearSolve.jl's
default-algorithm converter) recurse forever instead of terminating.

An SCCNonlinearProblem solves as an ordered sequence of block solves, not a
single residual, so there is no faithful NonlinearProblem to construct here.
Raise a clear ArgumentError instead, naming what to do (solve it directly or
use its component problems).

Co-Authored-By: Chris Rackauckas <[email protected]>
Co-Authored-By: Claude Sonnet <[email protected]>
Agent-Harness: Claude Code 2.1.251 (subagent)
Agent-Model: claude-sonnet
Agent-Session: https://claude.ai/code/session_01NB3oFTNzGW79UtDt8AyjsM
@ChrisRackauckas-Claude ChrisRackauckas-Claude changed the title Fix FieldError normalizing an SCCNonlinearProblem via NonlinearProblem Raise a clear ArgumentError converting an SCCNonlinearProblem to NonlinearProblem Sep 24, 2026
Keep the source comment to the why; the recursion-hazard and review history
belong in the PR body, not the code.

Co-Authored-By: Chris Rackauckas <[email protected]>
Co-Authored-By: Claude Sonnet <[email protected]>
Agent-Harness: Claude Code 2.1.251 (subagent)
Agent-Model: claude-sonnet
Agent-Session: https://claude.ai/code/session_01NB3oFTNzGW79UtDt8AyjsM
ChrisRackauckas-Claude pushed a commit to ChrisRackauckas-Claude/SteadyStateDiffEq.jl that referenced this pull request Oct 7, 2026
…inearSolve

DynamicSS and SICNM only had __solve; init(ssprob, DynamicSS(...)) had no
matching __init here, so it fell through to NonlinearSolveBase's generic
fallback, which treats "no algorithm-specific __init exists" the same as "no
algorithm given" and rewrites the call to NonlinearSolve's default-algorithm
converter with ::Nothing in place of the algorithm - silently discarding
DynamicSS/SICNM. For a plain SteadyStateProblem that converter still finds a
NonlinearProblem to solve, so init() "worked" but ignored the requested
algorithm; for a SteadyStateProblem whose lowered_problem is an
SCCNonlinearProblem, the converter's NonlinearProblem(prob) call hits a
FieldError (SCCNonlinearProblem has no u0 field) - the reported CI failure,
init(ssprob, DynamicSS(Tsit5())) in SciMLBase.jl's downstream
SymbolicIndexingInterface test group.

Add SciMLBase.__init(prob::AbstractSteadyStateProblem, alg::DynamicSS/SICNM,
...), mirroring the existing __solve methods (extracted into shared
__dynamicss_ode_setup/__sicnm_ode_setup helpers): for a plain problem it
returns the live ODE/DAE integrator so init/solve!/step! compose normally; for
an SCC lowering there is no single integrator to hand back (blocks solve
sequentially), so it eagerly solves via the existing __solve_scc_lowering and
returns the finished solution, matching how a stored NonlinearProblem/
LinearProblem lowering is already handled verbatim elsewhere in this file.

Being a more specific method than NonlinearSolveBase's generic fallback, this
is picked by ordinary dispatch and the buggy conversion path is never reached
for these two algorithms - independent of SciML/SciMLBase.jl#1614 (the
generic converter itself is fixed separately there and in
SciML/NonlinearSolve.jl#1327).

Co-Authored-By: Chris Rackauckas <[email protected]>
Co-Authored-By: Claude Sonnet <[email protected]>
Agent-Harness: Claude Code 2.1.251 (subagent)
Agent-Model: claude-sonnet
Agent-Session: https://claude.ai/code/session_01NB3oFTNzGW79UtDt8AyjsM
ChrisRackauckas-Claude pushed a commit to ChrisRackauckas-Claude/SteadyStateDiffEq.jl that referenced this pull request Oct 21, 2026
…inearSolve

DynamicSS and SICNM only had __solve; init(ssprob, DynamicSS(...)) had no
matching __init here, so it fell through to NonlinearSolveBase's generic
fallback, which treats "no algorithm-specific __init exists" the same as "no
algorithm given" and rewrites the call to NonlinearSolve's default-algorithm
converter with ::Nothing in place of the algorithm - silently discarding
DynamicSS/SICNM. For a plain SteadyStateProblem that converter still finds a
NonlinearProblem to solve, so init() "worked" but ignored the requested
algorithm; for a SteadyStateProblem whose lowered_problem is an
SCCNonlinearProblem, the converter's NonlinearProblem(prob) call hits a
FieldError (SCCNonlinearProblem has no u0 field) - the reported CI failure,
init(ssprob, DynamicSS(Tsit5())) in SciMLBase.jl's downstream
SymbolicIndexingInterface test group.

Add SciMLBase.__init(prob::AbstractSteadyStateProblem, alg::DynamicSS/SICNM,
...), mirroring the existing __solve methods (extracted into shared
__dynamicss_ode_setup/__sicnm_ode_setup helpers): for a plain problem it
returns the live ODE/DAE integrator so init/solve!/step! compose normally; for
an SCC lowering there is no single integrator to hand back (blocks solve
sequentially), so it eagerly solves via the existing __solve_scc_lowering and
returns the finished solution, matching how a stored NonlinearProblem/
LinearProblem lowering is already handled verbatim elsewhere in this file.

Being a more specific method than NonlinearSolveBase's generic fallback, this
is picked by ordinary dispatch and the buggy conversion path is never reached
for these two algorithms - independent of SciML/SciMLBase.jl#1614 (the
generic converter itself is fixed separately there and in
SciML/NonlinearSolve.jl#1327).

Co-Authored-By: Chris Rackauckas <[email protected]>
Co-Authored-By: Claude Sonnet <[email protected]>
Agent-Harness: Claude Code 2.1.251 (subagent)
Agent-Model: claude-sonnet
Agent-Session: https://claude.ai/code/session_01NB3oFTNzGW79UtDt8AyjsM
@ChrisRackauckas-Claude
ChrisRackauckas-Claude marked this pull request as ready for review October 22, 2026 07:12
@ChrisRackauckas-Claude
ChrisRackauckas-Claude merged commit 1b025bb into SciML:master Oct 22, 2026
67 of 73 checks passed
ChrisRackauckas added a commit to SciML/SteadyStateDiffEq.jl that referenced this pull request Oct 31, 2026
…inearSolve's default (#173)

* Add __init for DynamicSS/SICNM so init() doesn't fall through to NonlinearSolve

DynamicSS and SICNM only had __solve; init(ssprob, DynamicSS(...)) had no
matching __init here, so it fell through to NonlinearSolveBase's generic
fallback, which treats "no algorithm-specific __init exists" the same as "no
algorithm given" and rewrites the call to NonlinearSolve's default-algorithm
converter with ::Nothing in place of the algorithm - silently discarding
DynamicSS/SICNM. For a plain SteadyStateProblem that converter still finds a
NonlinearProblem to solve, so init() "worked" but ignored the requested
algorithm; for a SteadyStateProblem whose lowered_problem is an
SCCNonlinearProblem, the converter's NonlinearProblem(prob) call hits a
FieldError (SCCNonlinearProblem has no u0 field) - the reported CI failure,
init(ssprob, DynamicSS(Tsit5())) in SciMLBase.jl's downstream
SymbolicIndexingInterface test group.

Add SciMLBase.__init(prob::AbstractSteadyStateProblem, alg::DynamicSS/SICNM,
...), mirroring the existing __solve methods (extracted into shared
__dynamicss_ode_setup/__sicnm_ode_setup helpers): for a plain problem it
returns the live ODE/DAE integrator so init/solve!/step! compose normally; for
an SCC lowering there is no single integrator to hand back (blocks solve
sequentially), so it eagerly solves via the existing __solve_scc_lowering and
returns the finished solution, matching how a stored NonlinearProblem/
LinearProblem lowering is already handled verbatim elsewhere in this file.

Being a more specific method than NonlinearSolveBase's generic fallback, this
is picked by ordinary dispatch and the buggy conversion path is never reached
for these two algorithms - independent of SciML/SciMLBase.jl#1614 (the
generic converter itself is fixed separately there and in
SciML/NonlinearSolve.jl#1327).

Co-Authored-By: Chris Rackauckas <[email protected]>
Co-Authored-By: Claude Sonnet <[email protected]>
Agent-Harness: Claude Code 2.1.251 (subagent)
Agent-Model: claude-sonnet
Agent-Session: https://claude.ai/code/session_01NB3oFTNzGW79UtDt8AyjsM

* Update test comment to match SciMLBase's final ArgumentError behavior

The comment still described SciMLBase's NonlinearProblem(::SCCNonlinearProblem)
conversion as an identity that could recurse forever; it now raises an
ArgumentError, and this repo's new __init methods are more specific than the
default path anyway, so it is never reached.

Co-Authored-By: Chris Rackauckas <[email protected]>
Co-Authored-By: Claude Sonnet <[email protected]>
Agent-Harness: Claude Code 2.1.251 (subagent)
Agent-Model: claude-sonnet
Agent-Session: https://claude.ai/code/session_01NB3oFTNzGW79UtDt8AyjsM

* Forward save_idxs in DynamicSS/SICNM init; trim comments

Co-Authored-By: Chris Rackauckas <[email protected]>
Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
Agent-Harness: Claude Code (subagent of ci-green head)
Agent-Model: claude-opus-5-5[1m]
Agent-Session: https://claude.ai/code/session_011aK5Xvp9NpdkzKuEwtiMGd

* Return steady-state caches from DynamicSS/SICNM init

`init(prob, ::DynamicSS/SICNM)` returned the raw ODE integrator, so
`solve!` skipped the termination-condition finalization of `solve`:
finite-time nonconvergence reported Success and a protective safe
termination reported Terminated instead of Unstable. For SCC lowerings
`init` returned a finished solution that `solve!` could not accept.

`init` now returns a `SteadyStateODECache` (ODE integrator plus the
setup holding the termination cache) or a `SteadyStateSCCCache`; `solve!`
on either runs the same finalization as `__solve`, and `step!` advances
the ODE integrator. Documents the init/solve! contract, including
SICNM's extended `[y; z]` integrator state.

Co-Authored-By: Chris Rackauckas <[email protected]>
Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
Agent-Harness: Claude Code (subagent of ci-green head)
Agent-Model: claude-opus-5-5[1m]
Agent-Session: https://claude.ai/code/session_011aK5Xvp9NpdkzKuEwtiMGd

* Restore steady-state cache indexing and reinitialization

Expose symbolic state access and current parameters on DynamicSS/SICNM caches.
Rebuild the integration and termination setup on reinitialization so SICNM
uses the updated parameters and consistent Newton direction. Cover cache
access, repeated solves, termination modes, and solution slicing in Core.

Co-Authored-By: Chris Rackauckas <[email protected]>
Co-Authored-By: Codex <[email protected]>
Agent-Harness: Codex CLI 0.163.0
Agent-Model: gpt-6.1-sol
Agent-Session: local session 01a157c8-4f1a-7691-afcc-019806096637 (no session URL)

* Allow type-changing steady-state cache reset options

Install rebuilt cache state in one assignment so slicing, ODE-option and
termination-mode overrides can change concrete types. Preserve cache identity
and retain the previous state when initialization fails. Add regressions for
option transitions, retained data, failed rebuilds and subsequent reuse.

Co-Authored-By: Chris Rackauckas <[email protected]>
Co-Authored-By: Codex <[email protected]>
Agent-Harness: Codex CLI 0.163.0
Agent-Model: gpt-6.1-sol
Agent-Session: local session 01a157c8-4f1a-7691-afcc-019806096637 (no session URL)

* Document that step!/reinit!/indexing apply only to the ODE integrator cache

Review (Grok, grok-4.7): clarify that step!, reinit!, and symbolic indexing
are defined only on SteadyStateODECache; calling any of them on a
SteadyStateSCCCache (the SCC-lowering case) throws MethodError, since only
solve! is supported on it. Confirmed by running both calls directly.

Co-Authored-By: Chris Rackauckas <[email protected]>
Co-Authored-By: Claude Sonnet <[email protected]>
Agent-Harness: Claude Code 2.1.251 (subagent)
Agent-Model: claude-sonnet
Agent-Session: https://claude.ai/code/session_01NB3oFTNzGW79UtDt8AyjsM

* Restore cache.ps and symbolic state assignment on SteadyStateODECache

init caches forwarded :ps to a NamedTuple and had getindex without setindex!,
so cache.ps[:a] and cache[:x] = value failed after the wrapper was introduced.
Expose the parameter proxy, assign states through setu, and keep SICNM's
residual and Newton direction consistent with live parameters after mutation.

Co-Authored-By: Chris Rackauckas <[email protected]>
Co-Authored-By: Cursor Agent <[email protected]>
Agent-Harness: Cursor Agent CLI
Agent-Model: auto
Agent-Session: local fixer job SciML__SteadyStateDiffEq.jl__173 (no session URL)

* Accept u0 as a keyword in SteadyStateODECache reinit!

reinit!(cache; u0 = ..., p = ...) forwarded the keyword u0 through
kwargs to the ODE initializer instead of remake. SICNM then saw an
initial state half the extended [y; z] length and threw
IncompatibleMassMatrixError, while DynamicSS stored u0 among the
persistent initialization options so a later positional reset restarted
from the stale keyword value. Consume the keyword through remake and
keep it out of the stored ODE options.

Fail-before (unfixed head, keyword-then-positional reset probe):
  DynamicSS keyword reset state=[-3.0]
  DynamicSS positional reset state=[-3.0]   (expected [7.0])
  SICNM keyword reset ERROR IncompatibleMassMatrixError
Pass-after:
  DynamicSS keyword reset state=[-3.0]
  DynamicSS positional reset state=[7.0]
  SICNM keyword reset state=[-3.0]
  SICNM positional reset state=[7.0]
  keyword then positional cache reset | Pass 4  Total 4

The new "keyword u0 cache reset" testset in test/cache_interface.jl
covers both algorithms, iip and oop: it fails 22 and errors 4 on the
unfixed source and passes after. GROUP=Core and GROUP=QA pass.

Co-Authored-By: Chris Rackauckas <[email protected]>
Co-Authored-By: Devin <[email protected]>
Agent-Harness: Devin CLI 3000.11.228
Agent-Model: swe-2-high
Agent-Session: local fixer job SciML__SteadyStateDiffEq.jl__173 (no session URL)

* Defer SICNM direction refresh until batched state writes complete

Track pending direction synchronization in the steady-state cache. Refresh
on state/integrator reads and before stepping or solving, and clear the
flag after synchronization or reinitialization. Integrator notification
uses the public mutation interface.

Add coupled-domain regressions for batched symbolic and direct SII setters,
plus scalar changes after stepping. Document deferred synchronization.

Co-Authored-By: Chris Rackauckas <[email protected]>
Co-Authored-By: Codex <[email protected]>
Agent-Harness: Codex CLI 0.164.0
Agent-Model: gpt-6.1-sol
Agent-Session: local job 20261028T065010Z-codex-gpt-6.1-sol (no session URL)

---------

Co-authored-by: ChrisRackauckas-Claude <[email protected]>
Co-authored-by: Claude Sonnet <[email protected]>
Co-authored-by: Codex <[email protected]>
Co-authored-by: Cursor Agent <[email protected]>
Co-authored-by: Devin <[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.

3 participants