Repository navigation
Fix JET typo-mode findings in ModelingToolkitBase - #5065
ChrisRackauckas merged 2 commits into
Conversation
`JET.report_package(ModelingToolkitBase; mode = :typo)` flags a number of genuine problems in hand-written code (the rest of its reports come from Moshi's `@match` codegen and are addressed upstream): - `Shift(steps)` called `new` from an outer constructor. - `_all_ts_idxs!(…, sym::Symbol)` referenced `s` instead of `sym`. - `BandedAMatrixWrapper(::Expr, nr, bands)` referenced `sz` instead of `nr`. - `compile_functional_affect`'s duplicate-alias warning interpolated `expr` instead of `exp`, and `search_variables!(vars, ::ImperativeAffect)` recursed on `v` instead of `var`. - `define_params` threw an undefined `ModelingtoolkitizeParametersNotSupportedError`; define it. - `extend` on systems of different types called the removed `convert_system`; throw an `ArgumentError` instead. - The `Substituter` method for `AffectSystem` still used the removed `parameter_dependencies`/`defaults` fields; substitute the current fields (including `observed`, where the compiled affect equations live). - `throw_invalid_operator` left `optext` undefined for non-`Differential` operators, and `fractional_to_ordinary` left `coeff` undefined for α == 1. - Locals bound only on some branches (`ic`, `subidx`, `source_visitor`, `source_info`, `mass_matrix`) and locals captured by closures after being reassigned (`dsti`, `buffer`, `newbuf`) are restructured so they are defined on every path. Co-Authored-By: Chris Rackauckas <[email protected]> Co-Authored-By: Claude Fable 5.1 <[email protected]> Agent-Harness: Claude Code 2.1.259 Agent-Model: claude-fable-5-1 Agent-Session: https://claude.ai/code/session_01FeJYXni9MkJhPFA9yxYvfn
The two testsets added for the JET fixes call `unwrap` unqualified. Symbolics 7.37.0, the compat floor used by the downgrade lanes, does not export `unwrap` (7.39.0 does), so those lanes errored with `UndefVarError: unwrap not defined`. Co-Authored-By: Chris Rackauckas <[email protected]> Co-Authored-By: Claude Fable 5.1 <[email protected]> Agent-Harness: Claude Code 2.1.259 Agent-Model: claude-fable-5-1 Agent-Session: https://claude.ai/code/session_01FeJYXni9MkJhPFA9yxYvfn
CI triage for the red checks on this PROnly the two downgrade InterfaceI lanes were broken by this PR. Everything else is red on
What changed
VerificationJulia 1.10.11 with Julia 1.12.7, latest deps, same file with the fix:
Not run locally: the full 🤖 Generated with Claude Code (model: claude-fable-5-1) |
|
The current base reproduces this failure independently of the copied-binding change in #5073. Full native QA on clean source e76112c gives the same 234 Moshi-generated-local reports on Julia 1.12.7 / JET 0.12.1. I then ran the same native QA command on a separate checkout of that base with the existing Moshi fix ChrisRackauckas-Claude/Moshi.jl@7b5ef92. It passes. No ModelingToolkit source or test changes, JET suppression, or mode changes were made. Both runs used this command from TMPDIR="$PWD/../../.validation/tmp" JULIA_NUM_PRECOMPILE_TASKS=1 GROUP=QA timeout 14400 /home/crackauc/.juliaup/bin/julia +1.12.7 --startup-file=no --project=. -e 'import Pkg; Pkg.test(;coverage=true, julia_args=["--check-bounds=auto", "--compiled-modules=yes", "--depwarn=yes"], force_latest_compatible_version=false, allow_reresolve=true)' > ../../.validation/qa-native.log 2>&1Baseline terminal output, exit 1: With the existing Moshi fix, exit 0: The package, QA, and actual This validates the existing investigation and fix; it does not submit or publish the Moshi change upstream. No new bisect or duplicate fix was created. This run covered native ModelingToolkitBase QA, not its other groups or the Moshi test suite. AI involvement: Codex CLI 0.153.4; model: gpt-6-astra; local session ID: 01a071a0-abb2-7eb2-8e39-9cab28110384 (parent local session: 01a0598f-11b9-72d1-91d9-b2fbb186557d). |
What changed and why
JET.report_package(ModelingToolkitBase; target_modules = (ModelingToolkitBase,), mode = :typo)(the checkrun_qaruns in the ModelingToolkitBase QA group, red on master since #4832 — see #5063) reports 263 problems. 234 of them are spuriousmay be undefinedreports on Moshi@matchtemporaries (tracked in the issue; fix is upstream in Moshi). This PR fixes the other 29, which are genuine:Shift(steps)callednewfrom an outer constructor (UndefVarErrorforShift(2))._all_ts_idxs!(…, sym::Symbol)usedsinstead ofsym(unreachable branch, no test).BandedAMatrixWrapper(::Expr, nr, bands)usedszinstead ofnr.compile_functional_affect's duplicate-alias@warninterpolatedexprinstead ofexp;search_variables!(vars, ::ImperativeAffect)recursed onvinstead ofvar.define_paramsfallback threw the undefinedModelingtoolkitizeParametersNotSupportedError; the type is now defined with ashowerror.extendon systems of different types called the removedconvert_system; it now throws anArgumentError.Substitutermethod forAffectSystemused the removedparameter_dependencies/defaultsfields; it now substituteseqs,observed(where the compiled affect equations live),bindings,initial_conditions,guesses,unknowns,ps.throw_invalid_operatorleftoptextundefined for non-Differentialoperators;fractional_to_ordinaryleftcoeffundefined forα == 1(now anArgumentError; previously anInexactErrorfromfloor(Int, -Inf)further down).ic,subidx,source_visitor,source_info,mass_matrix) and locals captured by closures after reassignment (dsti,buffer,newbuf— these wereCore.Boxed) are restructured so they are defined on every path. No behaviour change.Verification
JET on this branch, Julia 1.12.7 / JET 0.12.1 / Moshi 0.3.12, same call as
run_qa:NREPORTS=263(1036 s)NREPORTS=234(1020 s); the remaining reports are all##And#N#…/##Call#N#…Moshi temporariesNREPORTS=0(330 s)The QA group itself therefore still fails on this PR until Moshi is fixed; I am not changing the test.
New tests (
test/discrete_system.jl,test/code_generation.jl,test/modelingtoolkitize.jl,test/abstractsystem.jl,test/basic_transformations.jl,test/symbolic_events.jl), run as one script against master and against this branch:Test groups run locally with
GROUP=<group> julia +1.12 --project=. -e 'using Pkg; Pkg.test()'inlib/ModelingToolkitBase:InterfaceIInterfaceIIOptimal Control + Constraints Tests31 passed, 2 broken (same as master)SymbolicIndexingInterface(The 9 extra
InterfaceIpasses are the new tests; the broken counts are pre-existing@test_brokens.)Runic (
julia -m Runic --check --diffon the changed files) reports only a pre-existing hunk insrc/systems/parameter_buffer.jl:120that is identical on master;typoson the diff is clean.Not verified
!ArrayInterface.ismutable(oldbuf)path inremake_buffer(restore_static_buffers) is a pure extraction of the existing closures; I did not find a test that exercises it.Things to push back on
extendwith mismatched system types now throwsArgumentErrorrather than trying (and failing) to convert.fractional_to_ordinarywithα == 1now throwsArgumentErrorup front.🤖 Generated with Claude Code 2.1.259 (model: claude-fable-5-1)
Session: https://claude.ai/code/session_01FeJYXni9MkJhPFA9yxYvfn