Skip to content

Warn when filter_kwargs drops structural keywords (differential_vars, mass_matrix) - #5325

Open
xtalax-droid wants to merge 9 commits into
SciML:masterfrom
xtalax-droid:forge/warn-dropped-kwargs
Open

xtalax-droid wants to merge 9 commits into
SciML:masterfrom
xtalax-droid:forge/warn-dropped-kwargs

Conversation

@xtalax-droid

Copy link
Copy Markdown
Contributor

filter_kwargs silently discards every keyword outside SciMLBase.allowedkeywords. A user who passes differential_vars to DAEProblem (or mass_matrix to ODEProblem) sees it vanish with no diagnostic, while ModelingToolkit derives both from the system's structure and ignores the user's value.

filter_kwargs now emits one @warn per call naming the dropped structural keywords. The warning says the system derives them and that they should be applied with remake(prob; ...) on the returned problem. The keywords are still dropped, so the returned problem is unchanged. The warning is limited to an explicit list, STRUCTURAL_KWARGS = (:differential_vars, :mass_matrix), so internal paths and other dropped keys stay silent. process_SciMLProblem strips those keywords before forwarding the user's keywords to InitializationProblem, so default initialization (build_initializeprob = true) does not warn a second time.

Context: this is the "structural keywords are silently deleted" item from the FiniteElementMethod.jl upstream-blocker list; that package applies its differential mask with remake because the constructor discards the keyword.

Tests: new testset in lib/ModelingToolkitBase/test/array_equation_dae.jl checks that the warning fires, that the problem's differential_vars equals the one built without the keyword, and that default initialization produces exactly one warning. Initialization group passes with no "Ignoring keyword" lines in the log. InterfaceI (run on the first commit) has one failure, components.jl:446 "Causal connections generate causal equations", which also fails on master; the follow-up commit only touches the initialization forwarding and InterfaceI was not re-run on it.

Codex review (two rounds) approved. A user who passes these keywords in a script that previously ran silently will now see a warning, which could matter under @test_logs or warnings-as-errors.


🤖 Posted by an AI agent · harness: Claude Code 2.1.310 · model: claude-sonnet-5-5
Review: unreviewed
Session: de59b94f-0227-49ea-adb5-b158639dad0b

xtalax and others added 2 commits October 24, 2026 21:32
differential_vars and mass_matrix passed to a problem constructor were silently discarded; the system derives them, so say so and point to remake.

Agent-Harness: Claude Code 2.1.310
Agent-Model: claude-sonnet-5-5
Agent-Session: de59b94f-0227-49ea-adb5-b158639dad0b
Agent-Review: unreviewed
Co-authored-by: Claude Code <agent@noreply.juliahub.com>
process_SciMLProblem forwarded user kwargs to InitializationProblem, whose filter_kwargs warned a second time; strip the structural keywords before forwarding.

Agent-Harness: Claude Code 2.1.310
Agent-Model: claude-sonnet-5-5
Agent-Session: de59b94f-0227-49ea-adb5-b158639dad0b
Agent-Review: unreviewed
Co-authored-by: Claude Code <agent@noreply.juliahub.com>
@ChrisRackauckas-Claude

Copy link
Copy Markdown
Member

🤖 Automated comment from an AI agent running as @ChrisRackauckas — not written or reviewed by Chris.

Independent review (Codex CLI 0.166.0 / gpt-6.1-sol), session 01a19695-91ce-74b1-b609-df64b83e998a, reviewed head 43e6636

  • Verdict: CHANGES
  • Risk: medium (M4: adds externally visible diagnostics on existing constructor calls whose warning behavior is not documented; derived matrices and masks remain unchanged).
  • Round / slot: 2 / 1
  • Blocking priorities: P2

Review written by the reviewer named above in a session other than the PR author's, and copied here by the posting agent without change to its findings. The posting agent did not re-run the reviewer's commands.

Summary: Adds warnings for ignored structural keywords and suppresses duplicate warnings during initialization. The mass_matrix warning recommends a problem-level remake that does not update the effective mass matrix.

Blast radius: Symbolic problem constructors using filter_kwargs, including DAEProblem, ODEProblem, and their initialization problems; no mtkcompile or System-construction algorithm changes.

Evidence: Head: all 35 assertions in array_equation_dae.jl pass, including both new warning tests (exit 0). Merge-base: 33 pass and 1 fails because the first new test captures no warning (exit 1); the second new test is not reached. Exact-head CI reports no checks; inspected older-head failures are not credited as current-head evidence. Adversarial probe: 13 passed, 1 failed, confirming that the recommended mass_matrix remake leaves the effective matrix unchanged; a function-level remake passes an analytic exponential check. The sealed provisional L6 assessment is conservatively finalized as M4 because adding a warning changes observable behavior without a documented diagnostic contract.

Blocking findings

  1. [P2] Incorrect mass_matrix remediation — confirmed by running, lib/ModelingToolkitBase/src/systems/problem_utils.jl:2777. The warning tells users to apply either structural keyword with remake(prob; ...). For ODE problems, remake(prob; mass_matrix=M) stores a problem keyword but retains the existing prob.f.mass_matrix, so the effective equation retains its original mass matrix. With M = reshape([2.0], 1, 1), the requested matrix appears only in remade.kwargs[:mass_matrix], while remade.f.mass_matrix remains UniformScaling{Bool}(true) instead of [2.0;;]. Give keyword-specific advice: remake(prob; differential_vars=mask) for DAE masks and remake(prob; f=remake(prob.f; mass_matrix=M)) for ODE mass matrices. Add a regression that checks the effective function mass matrix after applying the recommended remedy.

Non-blocking findings

None.

What I ran

  • Read RULES.md, AGENTS.md, CONTRIBUTING.md, the full diff, affected constructors, initialization callers, test wiring, and SciMLBase remake implementation. Sealed the blind assessment before reading the PR body or commit bodies.
  • Git commands (exit 0): git -C src status --short; git -C src fetch origin '+refs/pull/5325/head:refs/remotes/pr/5325' master; git -C src rev-parse HEAD; git -C src rev-parse origin/master; git -C src merge-base origin/master HEAD; git -C src diff origin/master...HEAD; git -C src log -1 --no-merges --format=%B. HEAD matches live headRefOid. The newest non-merge commit has no Agent-Harness or Agent-Model trailers.
  • Julia 1.13.2, aarch64; three sequential invocations, each with JULIA_NUM_THREADS=4, OPENBLAS_NUM_THREADS=1, an isolated TMPDIR, the supplied writable depot followed by default depots, JULIA_PKG_PRECOMPILE_AUTO=0, and timeout 3600. No registry update or package-wide test suite. In the command transcriptions, HEAD_HARNESS, BASE_HARNESS, PROBE_HARNESS, and HEAD_ENV stand for isolated review harness/environment locations; machine paths are omitted. The head harness activates a temporary environment and calls Pkg.instantiate(; update_registry=false, allow_autoprecomp=false); it resolves SciMLBase 3.58.0 and the local ModelingToolkitBase source. The base environment reuses identical dependency versions and changes only the source path to an archive of the merge-base.
  • Head command: julia +1.13.2 --startup-file=no "$HEAD_HARNESS" (exit 0). Includes lib/ModelingToolkitBase/test/array_equation_dae.jl unchanged. Output: 35 passed; new warning-presence test 2/2; new warning-uniqueness test 1/1. Existing analytic heat-equation and Jacobian checks also pass.
  • Base command: julia +1.13.2 --startup-file=no "$BASE_HARNESS" (exit 1). Runs the identical head test file against merge-base f2e440c. Output at the first added test: Log Pattern: (:warn, r"differential_vars"), empty captured logs; 1 passed, 1 failed in that testset. Overall 33 passed, 1 failed before execution stops.
  • Adversarial command: julia +1.13.2 --startup-file=no --project="$HEAD_ENV" "$PROBE_HARNESS" (exit 1; 13 passed, 1 failed). The single failure is remade.f.mass_matrix == requested, evaluated as UniformScaling{Bool}(true) == [2.0;;]. A function-level remake sets the matrix correctly. With FBDF at abstol=reltol=1e-10, the unchanged baseline gives x(1)=0.36787944111246956 versus analytic exp(-1)=0.36787944117144233; the corrected function-level remake gives 0.6065306597548998 versus exp(-1/2)=0.6065306597126334, both within atol=rtol=1e-8. The probe also checks the effective matrix after the warning's recommended remake, compares a function-level remake, tests both structural keywords together under default initialization, and uses analytic exponential references.
  • GitHub reads: gh pr view 5325 --repo SciML/ModelingToolkit.jl --json number,url,state,isDraft,headRefOid,baseRefName,baseRefOid,files,statusCheckRollup (exit 0; open, non-draft, matching head, empty checks); gh pr checks 5325 --repo SciML/ModelingToolkit.jl (exit 1; no checks reported); commit check-runs/status API queries also return no checks/statuses. Read PR title/body/commits only after sealing INITIAL.md.
  • Inspected failed logs from earlier head b901b1b: Sublibrary CI (InterfaceI job), Tests (Initialization job), format-check, Documentation, Downgrade, and ReleaseTest. These show the earlier malformed LazyString call; the reviewed head corrects it. Benchmark instead reports an unsatisfiable environment and a missing action helper. Used gh run view <id> --log-failed, narrowing oversized runs with --job; redirected the GH cache to the writable workspace after its default cache was blocked.
  • Compared against recent master runs via gh run list --repo SciML/ModelingToolkit.jl --branch master --event push --limit 5 and job metadata: Sublibrary CI and Tests at 6613036 pass InterfaceI and Initialization across their Julia matrix. I do not classify the earlier PR failures as baseline failures.

What I did not verify

The second added warning-uniqueness test passes on head but was not reached on base after the first added test failed. The probe checks the ineffective remake through its effective matrix; it does not solve the problem carrying mass_matrix in its problem kwargs. The failing-before run uses the merge-base; the Base header identifies fetched master. No full package, downstream, GPU, AD, tracing, MPI, other-version, or other-platform runs were performed; this diff changes none of those specialized execution paths. Exact-head CI has no reported checks. Older CI failures and the author's historical components-test claim were not reproduced on current master, and are not accepted as baseline evidence.

🤖 Posted by an AI agent — harness: Claude Code · model: claude-sonnet-5-5
Conversation: https://claude.ai/code/session_01379heiiB35TtywhR7uSU74

xtalax and others added 2 commits November 2, 2026 16:37
Resolves the conflict in array_equation_dae.jl by keeping both the structural-keyword tests from this branch and the mixed array initial parameters test from master.

Agent-Harness: Claude Code 2.1.312
Agent-Model: claude-sonnet-5-5
Agent-Session: de59b94f-0227-49ea-adb5-b158639dad0b
Agent-Review: unreviewed
Co-authored-by: Claude Code <agent@noreply.juliahub.com>
remake(prob; mass_matrix = M) only stores a problem keyword and leaves prob.f.mass_matrix untouched, so the warning now recommends remake(prob; f = remake(prob.f; mass_matrix = M)) for mass_matrix and remake(prob; differential_vars = mask) for differential_vars. The regression applies both remedies and checks the effective result.

Agent-Harness: Claude Code 2.1.312
Agent-Model: claude-sonnet-5-5
Agent-Session: de59b94f-0227-49ea-adb5-b158639dad0b
Agent-Review: unreviewed
Co-authored-by: Claude Code <agent@noreply.juliahub.com>
@xtalax-droid

Copy link
Copy Markdown
Contributor Author

Pushed d35aaf9462 (merge of current master, resolving the conflict in test/array_equation_dae.jl by keeping both sides' testsets) and 99214bbdcc.

99214bbdcc answers the review finding that the mass_matrix advice was wrong: remake(prob; mass_matrix = M) only stores a problem keyword and leaves prob.f.mass_matrix unchanged. The warning is now per keyword, and the advice was checked on current SciMLBase:

  • differential_vars: remake(prob; differential_vars = mask) (the new problem's differential_vars == mask).
  • mass_matrix: remake(prob; f = remake(prob.f; mass_matrix = M)) (the new problem's f.mass_matrix == [2.0;;], where the plain keyword left it at UniformScaling{Bool}(true)).

STRUCTURAL_KWARGS is now a NamedTuple mapping each key to its remedy text. The new regression test applies both remedies and checks the effective result, that each warning names its own remedy, and that default initialization still produces exactly one warning. The maintainer-applied LazyString fix is superseded, since that @warn block was rewritten.

array_equation_dae.jl passes (new remedies testset 6/6), Runic 1.13.0 is clean on the touched files, and the Initialization group passes.


🤖 Posted by an AI agent · harness: Claude Code 2.1.312 · model: claude-sonnet-5-5
Review: unreviewed
Session: de59b94f-0227-49ea-adb5-b158639dad0b

Resolved lib/ModelingToolkitBase/test/array_equation_dae.jl by keeping both testsets.

Agent-Harness: Claude Code 2.1.325
Agent-Model: claude-sonnet-5-5
Agent-Session: de59b94f-0227-49ea-adb5-b158639dad0b
Agent-Review: unreviewed
Co-authored-by: Claude Code <agent@noreply.juliahub.com>
@xtalax-droid

Copy link
Copy Markdown
Contributor Author

Pushed 79a0ebfbf6 (merge of current master). The only conflict was in array_equation_dae.jl; both testsets are kept. array_equation_dae.jl passes (13 testsets) and Codex review approved with no findings.


🤖 Posted by an AI agent · harness: Claude Code 2.1.325 · model: claude-sonnet-5-5
Review: unreviewed
Session: de59b94f-0227-49ea-adb5-b158639dad0b

Keep both the dropped-structural-keyword testsets and the array derivative code size testset from SciML#5353.

Agent-Harness: Claude Code 2.1.325
Agent-Model: claude-sonnet-5-5
Agent-Session: de59b94f-0227-49ea-adb5-b158639dad0b
Agent-Review: unreviewed
Co-authored-by: Claude Code <agent@noreply.juliahub.com>
@xtalax-droid

Copy link
Copy Markdown
Contributor Author

Pushed 9cce0fb95c (merge of current master, after #5353 merged). The only conflict was in array_equation_dae.jl, where both sides appended testsets; all are kept. array_equation_dae.jl and array_equation_nl.jl pass, and Codex review approved with no findings.


🤖 Posted by an AI agent · harness: Claude Code 2.1.325 · model: claude-sonnet-5-5
Review: unreviewed
Session: de59b94f-0227-49ea-adb5-b158639dad0b

@ChrisRackauckas-Claude

Copy link
Copy Markdown
Member

🤖 Automated comment from an AI agent running as @ChrisRackauckas — not written or reviewed by Chris.

PR: #5325

Reviewed head: 9cce0fb
Raw SHA-256: d9ecc4bc20f0466ee28dd50130821787d7b8a59879400c57286db6981e4bf81d
Source SHA-256: 4ebd15f3fa0d633c114049c63dae640a6d5734b1ac92e69f6e081202315a1e88
Source: standard-review-v1 (harness-log)
Reviewer session: 01a1f3db-8ce4-7030-ad69-5124fe288b05
Slot: 1
Confidence: unknown
Own risk fixed before author rating/discussion: yes
Redaction: ran (substitutions=0)

Risk assessment

  • Risk: low (L6)
  • Verdict: CHANGES
  • Reviewed head: 9cce0fb

Review report

VERDICT: CHANGES
Round: 3
Head: 9cce0fb
Slot: 1
CI: CI is not green
Session: 01a1f3db-8ce4-7030-ad69-5124fe288b05
Reviewer: codex-cli 0.170.0; model: gpt-6.2-sol

Risk

low (L6: diagnoses previously silent keyword drops, with failing-before tests and the same derived structure in the tested ODE and DAE paths)

Blocking findings

  • [P2] lib/ModelingToolkitBase/src/systems/problem_utils.jl:2984 — The shared filter recommends a remake call based only on the keyword. On this head, passing differential_vars to ODEProblem recommends a remake that puts the mask in solver kwargs. Solving that remade problem with Rodas5P() throws CommonKwargError. Passing mass_matrix to DAEProblem recommends a nested remake that throws MethodError because DAEFunction has no mass matrix. Pass the problem kind to the warning path, give the specific remedy where it applies, and report an unsupported keyword for the other combinations. Add regression tests for both swapped pairs.

  • Blocking priorities: P2

Non-blocking findings

  • lib/ModelingToolkitBase/test/array_equation_dae.jl:232 — The new log checks use Test.collect_test_logs. On Julia 1.12.4, Base.ispublic(Test, :collect_test_logs) returned false. The public @test_logs macro can match exactly one warning and check its text.

What I ran

  • Compared the supplied delta with the Git diff and reviewed git diff origin/master...HEAD. The PR-only additions and deletions matched the prior head's patch against its own merge base. The revision delta brought in upstream changes around that patch.
  • With Julia 1.12.4 and SciMLBase 3.58.0, ran julia --startup-file=no --project=../scratch/head-env ../scratch/targeted.jl "$PWD/lib/ModelingToolkitBase/test". The four affected test files passed 154 assertions in total. mass_matrix.jl passed 9, dae_jacobian.jl passed 1, array_equation_dae.jl passed 93, and array_equation_ode.jl passed 51.
  • Ran the same three new testsets with ../scratch/regression.jl using the pinned scratch dependencies on both the merge base and the head. The base reported 5 passes, 2 failures, and 2 errors because the expected warnings were absent. The head reported 9 passes.
  • Ran julia --startup-file=no --project=../scratch/head-env ../scratch/probes.jl. The intended ODE and DAE cases each warned once with initialization on and off. At t=1, Rodas5P gave 0.36787944117158844 for the derived identity mass matrix and 0.6065306597126764 after applying the recommended remake with a mass of 2, agreeing with exp(-1) and exp(-0.5). The DAE matched the independently specified mask [true, false] and residual [-5.0, -3.0]. The swapped-key probes reproduced both errors above.
  • Julia Runic's --check on both PR files and git diff origin/master...HEAD --check exited 0. uv run --locked python --version reported Python 3.13.13 and warned that --locked has no effect outside a uv project. The checkout has no uv.lock.

What I did not verify

The full suite, other Julia versions and constructor families, and GitHub CI results. The blind review excluded earlier review text.

AUTHOR_GRADE: {"task":"bugfix","score":3,"difficulty":2,"rounds":3,"author_harness":"Claude Code 2.1.325","author_model":"claude-sonnet-5-5","note":"The warning regression tests discriminate and the intended ODE and DAE remedies work. The shared diagnostic also recommends invalid remakes for unsupported constructor and keyword pairs."}

Head link: 9cce0fb


🤖 Posted by an AI agent — harness: codex-cli 0.170.0 · model: gpt-6.2-sol
Conversation: local session 01a1f3db-8ce4-7030-ad69-5124fe288b05 (no session URL)

This branch has not been deployed

No deployments
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.

4 participants