Skip to content

Event handling and parser fixes for rumoca Base Modelica exports - #170

Draft
asinghvi17 wants to merge 56 commits into
SciML:mainfrom
asinghvi17:bm-events-and-parser-fixes
Draft

asinghvi17 wants to merge 56 commits into
SciML:mainfrom
asinghvi17:bm-events-and-parser-fixes

Conversation

@asinghvi17

Copy link
Copy Markdown

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

Fixes to event handling and the Julia parser, found while loading rumoca's Base Modelica (MCP-0031) exports of the Modelica Standard Library.

The event changes cover when/elsewhen priority, conditions that are already true at the start, start values of pre() at initialization, event iteration with shared pre() values, and saving. Each fix comes with a regression test that fails without it. When-conditions that cross on an algebraic unknown kept by the simplified system are now rejected with an UnsupportedFeatureError: they used to fire two to three times too often. The parser change makes relations with a signed right-hand side such as x > -1.0 parse correctly, where they used to hang. Building an ODEProblem for models with many when-equations is also much faster.

This is a draft while one known gap is fixed: a relation Boolean such as off = s < 0 on an algebraic signal, in a model that also has a when, fails at solve time with an internal UndefVarError (seen on the SimpleTriacCircuit fixture). The README has one stale sentence about this as well.

🤖 Generated with Claude Code

https://claude.ai/code/session_0169ywCKpcVsvfNd2TsEqVS7


🤖 Posted by an AI agent — harness: Claude 2.1.316 · model: claude-opus-5-5
Conversation: factory head co_7876400c on m_4242afb3ce622d22c2c40d9e9baf1f9a (no session URL)

asinghvi17 and others added 30 commits November 11, 2026 14:48
create_arithmetic_expression returned BaseModelicaUnaryMinus(first_term)
as soon as it saw a leading '-', discarding every following '+'/'-' term,
so der('v') = -'x' - 0.1*'v' became der('v') = -'x'. Apply the unary
operator to the first term and keep folding the remaining terms. A leading
'+' is now also accepted.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Anshul Singhvi <anshul.singhvi@juliahub.com>
Harness: claude
Model: claude-opus-5-5
Factory-Task: 5dc384ae-ead8-48f7-827a-67e17e039323
Agent-Harness: Claude 2.1.301
Agent-Model: claude-opus-5-5
Agent-Session: factory task 5dc384ae-ead8-48f7-827a-67e17e039323 on m_3e9b2709b53bf4c4dade6cc909217625 (no session URL)
ANTLR's default ConsoleErrorListener printed lexer/parser errors to
stderr and let the parser recover, so malformed input produced a partial
AST and a silently wrong model. Replace the default listeners on both the
lexer and the parser with one that collects errors, and throw a
BaseModelicaParseError listing every error with line/column and source
context for the first. parse_file_antlr prefixes the filename.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Anshul Singhvi <anshul.singhvi@juliahub.com>
Harness: claude
Model: claude-opus-5-5
Factory-Task: 5dc384ae-ead8-48f7-827a-67e17e039323
Agent-Harness: Claude 2.1.301
Agent-Model: claude-opus-5-5
Agent-Session: factory task 5dc384ae-ead8-48f7-827a-67e17e039323 on m_3e9b2709b53bf4c4dade6cc909217625 (no session URL)
spc only skipped whitespace, so a trailing '// comment' after an equation
or declaration made the parse fail; with NoCache, ParserCombinator then
backtracks through every alternative, which took minutes on real models.
Let spc also consume line and block comments. The regression test parses
in a subprocess with a timeout so a hang fails instead of blocking CI.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Anshul Singhvi <anshul.singhvi@juliahub.com>
Harness: claude
Model: claude-opus-5-5
Factory-Task: 5dc384ae-ead8-48f7-827a-67e17e039323
Agent-Harness: Claude 2.1.301
Agent-Model: claude-opus-5-5
Agent-Session: factory task 5dc384ae-ead8-48f7-827a-67e17e039323 on m_3e9b2709b53bf4c4dade6cc909217625 (no session URL)
visit_equation returned nothing for an equation without '=', so a
'reinit(v, -e*pre(v))' statement inside a when-equation vanished and the
bouncing ball fell through the floor while reporting success. Keep such
statements as a BaseModelicaSimpleEquation with an empty right-hand side,
as the :julia parser does, so the evaluator lowers or rejects them.

visit_whenEquation also put the bodies of all elsewhen branches into the
first branch; walk the children so each condition gets its own body.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Anshul Singhvi <anshul.singhvi@juliahub.com>
Harness: claude
Model: claude-opus-5-5
Factory-Task: 5dc384ae-ead8-48f7-827a-67e17e039323
Agent-Harness: Claude 2.1.301
Agent-Model: claude-opus-5-5
Agent-Session: factory task 5dc384ae-ead8-48f7-827a-67e17e039323 on m_3e9b2709b53bf4c4dade6cc909217625 (no session URL)
…tics

Fixes two silent/failing cases:
- reinit(x, expr) was dropped (bouncing ball reported Success at -29 m);
- 'n = pre(n) + 1' failed with 'Symbol n(t) is not present in the system'
  because discrete variables never received a start value.

when-equations are collected into backend-independent WhenClauses
(condition, discrete assignments, reinits) and lowered by a
DiscreteBackend. The built-in MTKEventsBackend emits one
SymbolicContinuousCallback per distinct zero-crossing (rising edge only)
or a periodic SymbolicDiscreteCallback for sample(). Affect equations
follow Modelica semantics: continuous variables read their pre-event
value via Pre, pre(v) is Pre(v), reinit assigns the state, and every
state that is not reinitialized is held with x ~ Pre(x). Without the
hold equations MTK solves the affect together with the observed
equations and treats unassigned states as free unknowns, corrupting them
(e.g. y = 2x + n shifted x by -0.5 when n changed).

Discrete variables get their start value (attribute, 'pre(v) = c'
initial equation, or Modelica default 0) as an initial condition.
Compound when-conditions, unknown functions and statements other than
reinit/assert in a when body now throw UnsupportedFeatureError instead
of being mis-converted.

parse_basemodelica/create_odeproblem gain discrete_backend (:auto, :mtk,
:synchtoolkit) and simplify (true, false, or a function such as
DyadInterface.simplify_model) keywords; simplify = false returns the
unsimplified System. The experiment annotation is attached to the System
as metadata (experiment_settings(sys)).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Anshul Singhvi <anshul.singhvi@juliahub.com>
Harness: claude
Model: claude-opus-5-5
Factory-Task: 5dc384ae-ead8-48f7-827a-67e17e039323
Agent-Harness: Claude 2.1.301
Agent-Model: claude-opus-5-5
Agent-Session: factory task 5dc384ae-ead8-48f7-827a-67e17e039323 on m_3e9b2709b53bf4c4dade6cc909217625 (no session URL)
The BaseModelicaWhenEquation constructor stored only the element right
after each 'then', so a when-branch with several equations lost all but
the first (e.g. a reinit followed by a counter update). Collect all
equations up to the next 'elsewhen'. Covered by the initial-algorithm
event test added with algorithm-section support.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Anshul Singhvi <anshul.singhvi@juliahub.com>
Harness: claude
Model: claude-opus-5-5
Factory-Task: 5dc384ae-ead8-48f7-827a-67e17e039323
Agent-Harness: Claude 2.1.301
Agent-Model: claude-opus-5-5
Agent-Session: factory task 5dc384ae-ead8-48f7-827a-67e17e039323 on m_3e9b2709b53bf4c4dade6cc909217625 (no session URL)
Parsing (both backends produce the same new AST nodes):
- algorithm sections and statements (:=, if, for; while/when/break/
  return/multi-output are kept as BaseModelicaUnsupportedStatement);
- {...} array constructors; [..] and comprehensions become
  BaseModelicaUnsupportedExpression.
:julia: statements tolerate indentation, 'algorithm' is no longer
accepted as a type name, 'function' prefixes parse, and array_arguments
had a precedence bug ('|' and '+' share a level in Julia) that made
every {...} require a for-index and backtrack for minutes.
:antlr: algorithm sections were ignored and {...} returned a 0.0
placeholder; function calls now keep their full dotted name.

Conversion:
- user functions are inlined symbolically: arguments are bound to the
  inputs and the algorithm runs on symbolic values (if -> ifelse or
  constant-folded, for over constant ranges unrolled), so calls need no
  registration and stay differentiable;
- scalar for-equations over constant ranges are unrolled;
- initial algorithm sections of assignments run sequentially with time
  bound to the experiment start time (used by SimpleTriacCircuit.bmo);
- array variables, multi-component clauses (previously all but the
  first component were dropped), algorithm sections in models and
  unknown expression nodes throw UnsupportedFeatureError instead of
  being dropped or mis-converted.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Anshul Singhvi <anshul.singhvi@juliahub.com>
Harness: claude
Model: claude-opus-5-5
Factory-Task: 5dc384ae-ead8-48f7-827a-67e17e039323
Agent-Harness: Claude 2.1.301
Agent-Model: claude-opus-5-5
Agent-Session: factory task 5dc384ae-ead8-48f7-827a-67e17e039323 on m_3e9b2709b53bf4c4dade6cc909217625 (no session URL)
BaseModelicaSynchToolkitExt (weak dependency on SynchToolkit, which is
only in the private DyadRegistry) implements the DiscreteBackend
interface with SynchToolkit clocked partitions:
  when c then v = e   -> ZeroCrossing(c; down=false) + EventClock, v(k) ~ e
  sample(s, dt)       -> Clock(dt; phase=s)
  pre(v)              -> v(k-1), v(k-1) ~ start as initialization equation
  discrete in cont.   -> Hold(v);   continuous in clocked -> Sample(clock)(x)
  reinit(x, e)        -> Impulsive()(x) ~ e on the clause's clock
Clauses with only reinits stay plain MTK callbacks (affects on a callback
linked to an EventClock are replaced by the synchronous step). The system
is compiled with additional_passes = [SynchToolkit.compile_lustre];
DyadInterface.simplify_model adds that pass on its own.

Opt-in via discrete_backend = :synchtoolkit; :auto keeps the MTK backend.
Against SynchToolkit 0.4.8 (the version installable here) counters tick
correctly, but Hold(v) shows the post-tick value before the first tick,
constant assignments record NaN and Impulsive on an event clock fails
inside SynchToolkit; see outputs/scripts/synchtoolkit_probe.log.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Anshul Singhvi <anshul.singhvi@juliahub.com>
Harness: claude
Model: claude-opus-5-5
Factory-Task: 5dc384ae-ead8-48f7-827a-67e17e039323
Agent-Harness: Claude 2.1.301
Agent-Model: claude-opus-5-5
Agent-Session: factory task 5dc384ae-ead8-48f7-827a-67e17e039323 on m_3e9b2709b53bf4c4dade6cc909217625 (no session URL)
…script

README: replace the stale support note (no events/functions) with the
current feature list, the UnsupportedFeatureError behaviour, the
experimental SynchToolkit backend and the simplify = false /
DyadInterface.simplify_model path. outputs/scripts/dyad_pipeline.jl runs
.bmo -> unsimplified System -> DyadInterface.simplify_model ->
ODEProblem -> Tsit5 and TransientAnalysis; its log is alongside.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Anshul Singhvi <anshul.singhvi@juliahub.com>
Harness: claude
Model: claude-opus-5-5
Factory-Task: 5dc384ae-ead8-48f7-827a-67e17e039323
Agent-Harness: Claude 2.1.301
Agent-Model: claude-opus-5-5
Agent-Session: factory task 5dc384ae-ead8-48f7-827a-67e17e039323 on m_3e9b2709b53bf4c4dade6cc909217625 (no session URL)
On 0.5.2 / SynchJulia 0.8.6 the clocked lowering gives correct results
for elsewhen branches, constant assignments and Impulsive reinit plus a
counter on one EventClock (BouncingBallCounter: 6 bounces at the right
times), and the Dyad pipeline matches the MTK backend. A continuous
observable reading Hold(v) before v's first tick still errors ('Cannot
access discrete variable ... before initial save'), so :auto keeps the
MTK backend. Update the extension notes, the report and the logs
(0.4.8 log kept for reference).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Anshul Singhvi <anshul.singhvi@juliahub.com>
Harness: claude
Model: claude-opus-5-5
Factory-Task: 5dc384ae-ead8-48f7-827a-67e17e039323
Agent-Harness: Claude 2.1.301
Agent-Model: claude-opus-5-5
Agent-Session: factory task 5dc384ae-ead8-48f7-827a-67e17e039323 on m_3e9b2709b53bf4c4dade6cc909217625 (no session URL)
…weakdep

Replace the in-tree SynchToolkit package extension with a public API for
registering discrete backends, with tests and documentation. Remove the
bundled outputs/ directory.

Co-Authored-By: Anshul Singhvi <anshul.singhvi@juliahub.com>
Co-Authored-By: Claude <noreply@anthropic.com>
Harness: claude
Model: claude-sonnet-5-5
Factory-Task: df9c73f7-a80b-438e-a7b9-4dad797d72fc
Agent-Harness: Claude 2.1.301
Agent-Model: claude-sonnet-5-5
Agent-Session: factory task df9c73f7-a80b-438e-a7b9-4dad797d72fc on m_3e9b2709b53bf4c4dade6cc909217625 (no session URL)
The ANTLR visitor parsed a component's annotation and dropped it; the
ParserCombinator parser joined a string comment and an annotation into
one garbled string. A component declaration's comment is now its
BaseModelicaAnnotation when it has one, so the evaluator can read
annotation(Evaluate = true).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Anshul Singhvi <anshul.singhvi@juliahub.com>
Harness: claude
Model: claude-opus-5-5
Factory-Task: bb056ebf-f8d9-4825-93de-b7f7ac6f4c77
Agent-Harness: Claude 2.1.301
Agent-Model: claude-opus-5-5
Agent-Session: factory task bb056ebf-f8d9-4825-93de-b7f7ac6f4c77 on m_3e9b2709b53bf4c4dade6cc909217625 (no session URL)
…ameters

- `constant` components are inlined. MTK's @constants is only
  tunable=false metadata, which remake can still change.
- Parameters with annotation(Evaluate = true) become tunable=false, with a
  description saying they were evaluated at translation; their bindings
  are evaluated to numbers. MTK has no metadata that makes remake/setp
  reject a parameter, so loading warns once per model, listing them.
- Loading warns once per model about parameters that no equation,
  binding, start value or other attribute references: they were most
  likely consumed at translation without an Evaluate marker.
- A parameter whose binding refers to other parameters (r = p*q) keeps it
  as a symbolic default, which MTK 11 turns into a binding: remake(p)
  now recomputes r. Previously the binding was resolved to a number at
  load, so r went stale.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Anshul Singhvi <anshul.singhvi@juliahub.com>
Harness: claude
Model: claude-opus-5-5
Factory-Task: bb056ebf-f8d9-4825-93de-b7f7ac6f4c77
Agent-Harness: Claude 2.1.301
Agent-Model: claude-opus-5-5
Agent-Session: factory task bb056ebf-f8d9-4825-93de-b7f7ac6f4c77 on m_3e9b2709b53bf4c4dade6cc909217625 (no session URL)
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Anshul Singhvi <anshul.singhvi@juliahub.com>
Harness: claude
Model: claude-opus-5-5
Factory-Task: bb056ebf-f8d9-4825-93de-b7f7ac6f4c77
Agent-Harness: Claude 2.1.301
Agent-Model: claude-opus-5-5
Agent-Session: factory task bb056ebf-f8d9-4825-93de-b7f7ac6f4c77 on m_3e9b2709b53bf4c4dade6cc909217625 (no session URL)
…eads

The conversion keeps its state in module-level globals (variable_map,
parameter_val_map, ...) that every conversion empties first. Two conversions
running at once on different threads overwrote each other's state:
references resolved to `nothing`, bindings lost the parameters they refer
to (KeyError, `-(::Nothing, ::Nothing)`), nondeterministically. Conversions
are now serialized by a lock. The ANTLR parser calls Python, which crashes
the process (signal 11) off the main thread; it now throws an ArgumentError
there instead, pointing to `parser = :julia`.

Parameters, free-parameter bindings, Pass 3.5 and state priorities iterated
`variable_map`, a Dict keyed by Symbols whose order depends on what was
parsed before in the session. They now follow declaration order, so the
system handed to ModelingToolkit depends only on the file.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Anshul Singhvi <anshul.singhvi@juliahub.com>
Harness: claude
Model: claude-opus-5-5
Factory-Task: 18a1bb4b-a3de-43b3-8530-08a9af5694a1
Agent-Harness: Claude 2.1.301
Agent-Model: claude-opus-5-5
Agent-Session: factory task 18a1bb4b-a3de-43b3-8530-08a9af5694a1 on m_3e9b2709b53bf4c4dade6cc909217625 (no session URL)
…m at events

A Boolean defined by an equation, such as `off = s < 0`, was a Bool discrete
initialized to its `start` value. When that contradicted the relation (an
ideal diode starting reverse-biased with start = true, ...) the wrong branch
stayed selected until the relation crossed zero, possibly forever, and the
solve still reported Success. Definitions that were not a single relation
(hysteresis `y = pre(y) and u < a or u < b`, `b = time >= t0 and ...`) were
silently dropped, so the Boolean never changed. Declaration equations
(`Boolean b = expr`) were dropped too.

Each such Boolean is now a 0/1 Real discrete (equations see `b > 0.5`):
- initialization solves it with the unknowns it depends on
  (`b => missing`, `b ~ ifelse(definition, 1, 0)`, pre(b) = start), and
  remake with new initial values solves it again;
- each continuously varying relation of a definition gets a zero-crossing
  callback whose crossing direction gives the relation's new value (at the
  root it may evaluate either way), then all Booleans are iterated to a
  fixed point;
- a discrete callback re-evaluates them after any step at which one
  disagrees with its definition, e.g. after a reinit jumps across zero.
`when b` for such a Boolean triggers on its relation.

The Boolean and `when` callbacks share root finding and reinitialization so
ModelingToolkit puts them in one vector callback and coincident roots fire
together; separate classes lost one of the two events. A Boolean crossing is
(a - b)/2 so it never equals a `when` condition: identical conditions of one
vector callback re-fire forever at a shared downward root.

Systems without states: ModelingToolkit evaluates a single-condition
continuous callback into the empty state buffer (BoundsError). Such
callbacks get a second condition that never crosses zero.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Anshul Singhvi <anshul.singhvi@juliahub.com>
Harness: claude
Model: claude-opus-5-5
Factory-Task: 18a1bb4b-a3de-43b3-8530-08a9af5694a1
Agent-Harness: Claude 2.1.301
Agent-Model: claude-opus-5-5
Agent-Session: factory task 18a1bb4b-a3de-43b3-8530-08a9af5694a1 on m_3e9b2709b53bf4c4dade6cc909217625 (no session URL)
…less models

create_odeproblem collected the times of `if time < c` conditions but never
passed them on. The instants are now stored as `tstops` on the System, so
ModelingToolkit hands them to every ODEProblem built from it, including
DyadInterface's TransientAnalysis. They are collected from if-expressions as
well as if-equations, and may be expressions of parameters (`time <
startTime`), which follow remake. (A scalar System tstop is a period in
ModelingToolkit, so they are stored as one vector.)

Without differential states the error estimate is zero and one step can
span the whole simulation, missing events between its sample points (21 of
50 rising edges of a 50 Hz signal over 1 s, with Success). create_odeproblem
now sets dtmax to the experiment Interval, or a 500th of the time span, for
such models; explicit keyword arguments still take precedence.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Anshul Singhvi <anshul.singhvi@juliahub.com>
Harness: claude
Model: claude-opus-5-5
Factory-Task: 18a1bb4b-a3de-43b3-8530-08a9af5694a1
Agent-Harness: Claude 2.1.301
Agent-Model: claude-opus-5-5
Agent-Session: factory task 18a1bb4b-a3de-43b3-8530-08a9af5694a1 on m_3e9b2709b53bf4c4dade6cc909217625 (no session URL)
`assert` in an `initial algorithm` was rejected as an unsupported
statement. Assertions are now evaluated in sequence with the assignments
and checked once the model is initialized, by the initialize affect of a
discrete callback that never fires: it sees the initialized state and the
current parameters (also after remake). A failed assertion throws from
solve, or logs a warning for AssertionLevel.warning. One that fails
whatever the parameters is rejected when the model is loaded.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Anshul Singhvi <anshul.singhvi@juliahub.com>
Harness: claude
Model: claude-opus-5-5
Factory-Task: 18a1bb4b-a3de-43b3-8530-08a9af5694a1
Agent-Harness: Claude 2.1.301
Agent-Model: claude-opus-5-5
Agent-Session: factory task 18a1bb4b-a3de-43b3-8530-08a9af5694a1 on m_3e9b2709b53bf4c4dade6cc909217625 (no session URL)
…ead behaviour

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Anshul Singhvi <anshul.singhvi@juliahub.com>
Harness: claude
Model: claude-opus-5-5
Factory-Task: 18a1bb4b-a3de-43b3-8530-08a9af5694a1
Agent-Harness: Claude 2.1.301
Agent-Model: claude-opus-5-5
Agent-Session: factory task 18a1bb4b-a3de-43b3-8530-08a9af5694a1 on m_3e9b2709b53bf4c4dade6cc909217625 (no session URL)
Array components are expanded into scalar components named x[1], A[1,2]
before translation; references evaluate to Julia arrays of the element
symbols, so subscripts, slices, end, elementwise and matrix operators,
array constructors {..}, [..; ..], comprehensions and reductions work on
symbolic scalars, and array equations become one equation per element.
Array sizes and fill() sizes may refer to parameters with constant
values. User functions accept and return arrays. Both parsers keep
subscripts on component references and (expr)[subscripts].

sample(start, interval) and for-ranges accept parameter arguments,
evaluated with their values at load.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Anshul Singhvi <anshul.singhvi@juliahub.com>
Harness: claude
Model: claude-opus-5-5
Factory-Task: a677e921-6b87-42b6-9e91-e2a295a363cf
Agent-Harness: Claude 2.1.301
Agent-Model: claude-opus-5-5
Agent-Session: factory task a677e921-6b87-42b6-9e91-e2a295a363cf on m_3e9b2709b53bf4c4dade6cc909217625 (no session URL)
`x[1, :]` failed to match and the parser backtracked for minutes.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Anshul Singhvi <anshul.singhvi@juliahub.com>
Harness: claude
Model: claude-opus-5-5
Factory-Task: a677e921-6b87-42b6-9e91-e2a295a363cf
Agent-Harness: Claude 2.1.301
Agent-Model: claude-opus-5-5
Agent-Session: factory task a677e921-6b87-42b6-9e91-e2a295a363cf on m_3e9b2709b53bf4c4dade6cc909217625 (no session URL)
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Anshul Singhvi <anshul.singhvi@juliahub.com>
Harness: claude
Model: claude-opus-5-5
Factory-Task: a677e921-6b87-42b6-9e91-e2a295a363cf
Agent-Harness: Claude 2.1.301
Agent-Model: claude-opus-5-5
Agent-Session: factory task a677e921-6b87-42b6-9e91-e2a295a363cf on m_3e9b2709b53bf4c4dade6cc909217625 (no session URL)
…test expectation

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Anshul Singhvi <anshul.singhvi@juliahub.com>
Harness: claude
Model: claude-opus-5-5
Factory-Task: a677e921-6b87-42b6-9e91-e2a295a363cf
Agent-Harness: Claude 2.1.301
Agent-Model: claude-opus-5-5
Agent-Session: factory task a677e921-6b87-42b6-9e91-e2a295a363cf on m_3e9b2709b53bf4c4dade6cc909217625 (no session URL)
Preserve when-chain identity and branch priority, select simultaneous roots and
clocks together, and execute Boolean-triggered bodies during event iteration.
Keep pre-values across callbacks for the same instant and include the initial
sample tick on the absolute sample grid.

Respect scalar array targets when detecting discretes, read prior local array
writes in initial algorithms, and retain parameter-dependent Boolean starts.
Declare constants non-tunable through public metadata instead of toconstant.

Add both-parser regressions and an independent public discrete-backend solve.
Validation: Pkg.test() 823/823; QA/ExplicitImports 20/20 (clean_sources=false for
the read-only dependency depot).

Co-Authored-By: Anshul Singhvi <anshul.singhvi@juliahub.com>
Co-Authored-By: Codex <noreply@openai.com>
Harness: codex
Model: gpt-6.1-sol
Factory-Task: 23179837-fb43-4a06-a124-79e20fa53c18
Agent-Harness: Codex 0.164.0
Agent-Model: gpt-6.1-sol
Agent-Session: factory task 23179837-fb43-4a06-a124-79e20fa53c18 on m_3e9b2709b53bf4c4dade6cc909217625 (no session URL)
Address review findings A-E with regressions: seed initial edge history, preserve parameter-valued Boolean pre starts, iterate compiled callbacks, and advance discrete pre inputs while holding completed bodies. Preserve coincident elsewhen priority, restore the legacy WhenBlock constructor, and document Boolean edge handling for backends.

Co-Authored-By: Anshul Singhvi <anshul.singhvi@juliahub.com>
Co-Authored-By: Codex <noreply@openai.com>
Harness: codex
Model: gpt-6.1-sol
Factory-Task: ba56c437-18ea-4c44-9aa4-498776a41568
Agent-Harness: Codex 0.164.0
Agent-Model: gpt-6.1-sol
Agent-Session: factory task ba56c437-18ea-4c44-9aa4-498776a41568 on m_3e9b2709b53bf4c4dade6cc909217625 (no session URL)
Harness: codex
Model: gpt-6.1-sol
Factory-Task: 46e6dbc0-a3c9-4273-aeb3-0e91c613b63e
Harness: codex
Model: gpt-6.1-sol
Factory-Task: 46e6dbc0-a3c9-4273-aeb3-0e91c613b63e
Harness: codex
Model: gpt-6.1-sol
Factory-Task: d80e8cbe-a8b0-473e-a9be-1483f52b0d98
…ions

Harness: codex
Model: gpt-6.1-sol
Factory-Task: d80e8cbe-a8b0-473e-a9be-1483f52b0d98
Harness: codex
Model: gpt-6.1-sol
Factory-Task: 1ccceae5-342c-4983-994c-4ca4e39eaa15
Harness: codex
Model: gpt-6.1-sol
Factory-Task: 1ccceae5-342c-4983-994c-4ca4e39eaa15
Harness: codex
Model: gpt-6.1-sol
Factory-Task: 99fee907-9cd3-45a5-b049-848ee639638a
Harness: codex
Model: gpt-6.1-sol
Factory-Task: 73c3d70c-7b7a-4105-ba9d-bcd74ae57fda
Harness: codex
Model: gpt-6.1-sol
Factory-Task: 85fd8417-16d9-4ecb-ab83-528c926413bb
Harness: codex
Model: gpt-6.1-sol
Factory-Task: 545e77a7-53de-45c4-b3d3-0efc3d39c2f6
Harness: codex
Model: gpt-6.1-sol
Factory-Task: b6d6a37d-ffc1-4cbd-b7e8-42edbd520375
Harness: codex
Model: gpt-6.1-sol
Factory-Task: f5700ff2-5e00-4d55-9da5-d11d61171de2
Harness: codex
Model: gpt-6.1-sol
Factory-Task: a15aec33-adb0-437a-8491-f68229fe4006
Harness: codex
Model: gpt-6.1-sol
Factory-Task: 0e9dbbd2-ce8d-4211-9ac7-4cd88fa3905b
Harness: codex
Model: gpt-6.1-sol
Factory-Task: a9823b90-c8c1-4b7d-8b28-9fc17c0c847d
Harness: codex
Model: gpt-6.1-sol
Factory-Task: 8a24431b-406f-45ff-b8b1-42703ccfb5d8
Harness: codex
Model: gpt-6.1-sol
Factory-Task: a3fe1e5e-cc4a-4348-812d-0fb8a6fb748d
Harness: codex
Model: gpt-6.1-sol
Factory-Task: 378bc910-3025-4e79-8d51-e88031adb949
Harness: codex
Model: gpt-6.1-sol
Factory-Task: 35256f54-279e-4aa0-850b-b5d480705c66
Harness: codex
Model: gpt-6.1-sol
Factory-Task: 35256f54-279e-4aa0-850b-b5d480705c66
Harness: codex
Model: gpt-6.1-sol
Factory-Task: 35256f54-279e-4aa0-850b-b5d480705c66
Harness: codex
Model: gpt-6.1-sol
Factory-Task: 35256f54-279e-4aa0-850b-b5d480705c66
Harness: codex
Model: gpt-6.1-sol
Factory-Task: 94295093-de00-4663-b1e8-9ef79ed31a37
Harness: codex
Model: gpt-6.1-sol
Factory-Task: 94295093-de00-4663-b1e8-9ef79ed31a37
Harness: codex
Model: gpt-6.1-sol
Factory-Task: 94295093-de00-4663-b1e8-9ef79ed31a37
Harness: codex
Model: gpt-6.1-sol
Factory-Task: 94295093-de00-4663-b1e8-9ef79ed31a37
Harness: codex
Model: gpt-6.1-sol
Factory-Task: 36344aaa-655c-490f-a14f-a27e08e00c14
Harness: codex
Model: gpt-6.1-sol
Factory-Task: 36344aaa-655c-490f-a14f-a27e08e00c14
@ChrisRackauckas

Copy link
Copy Markdown
Member

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

PR: #170

Reviewed head: 319bfd5
Raw SHA-256: 833e19502a9d713bec4f1f787062e81cf856e5f625a6c00e01326de6f7f93725
Source SHA-256: 8871a2e3789c1e1965b8e419e2a9483d30aa2c3a81fd0d8122765b4264dd2ee2
Source: standard-review-v1 (harness-log)
Reviewer session: 01a1f9e8-e7f0-70d0-a468-54d7bdf89087
Slot: 1
Confidence: unknown
Own risk fixed before author rating/discussion: yes
Redaction: ran (substitutions=0)

Risk assessment

  • Risk: high (H1)
  • Verdict: CHANGES
  • Reviewed head: 319bfd5

Review report

VERDICT: CHANGES
Round: 1
Head: 319bfd5
Slot: 1
CI: CI unreadable; review only; merge gates unchanged
Session: 01a1f9e8-e7f0-70d0-a468-54d7bdf89087
Reviewer: codex-cli 0.169.0; model: gpt-6.2-astra

Risk

high (H1: a dependent parameter that callers could override through remake on the base revision now rejects the same call)

Blocking findings

  • [P1] src/relation_booleans.jl:155 freezes an entire Boolean expression when any operand is near its root. I solved b = (x > 0) or (time > 0.5) with x(0) = y(0) = 0, der(x) = if time > 0.8 then 1 else 0, and der(y) = if b then 1 else 0. Both parsers returned Success with b(0.6) = 0 and y(1) = 0.1999999956805129. The time comparison alone fixes b(0.6) = true and the integral is 0.5. Preserve an ambiguous operand's event history and reevaluate the enclosing expression when another operand changes.
  • [P1] src/evaluator.jl:755 substitutes the annotation start time, or zero, into initial algorithm assignments during translation. For initial algorithm x := time; and der(x) = 0, I built two problems from the same system with start times 0 and 5. Both parsers returned Success and x(t0) = 0 in both problems. The second initial value must be 5. Bind time during problem initialization so changing the time span also updates the initial state.
  • [P1] src/antlr_parser.jl:1304 drops named arguments before src/functions.jl:120 applies defaults. With input Real gain = 2 and a function returning gain, der(x) = f(gain=9) from x(0) = 0 solved to x(1) = 1.9999999999999953 using ANTLR. The Julia parser reported two inputs for the same call. Preserve and bind the argument name in both parsers, or explicitly reject named arguments before applying defaults.
  • [P1] src/functions.jl:229 discards every function-body assert. My function checked assert(u > 0, "positive input required") and then returned 7. Both parsers inlined a call with u = -1, and both solves returned Success with x(1) ≈ 7. Enforce the assertion on the executed branch, or reject this statement until the inliner can preserve it.
  • [P1] src/julia_parser.jl:487 loses the parentheses of a call with no explicit arguments. For the same function with default gain = 2, parse_basemodelica(...; parser=:julia, simplify=false) translated der(x) = f() into Equation[]. ANTLR produced Differential(t, 1)(x(t)) ~ 2.0. Emit an empty argument list for () so the call and its enclosing equation survive.
  • [P1] src/maps.jl:90 uses Julia's fill for an array-valued Modelica argument. Both parsers translated der(x) = size(fill({10.0,20.0},3),2) to der(x) = 1. Three copies of a length-two vector form a 3×2 Modelica array, so the derivative is 2. Preserve the argument's dimensions after the repetition dimensions.
  • [P2] src/functions.jl:224 deletes the previous binding of a loop index. For a function with input i = 8, output s = 0, and loop for i in 1:2 loop s := s+i; end for;, a final s := s+i must produce 11. Calling it with an explicit 8 produced MethodError: no method matching +(::Float64, ::Nothing) on both parsers. Restore the outer binding when leaving the loop.
  • [P2] src/maps.jl:104 calls one-argument permutedims for transpose. Both parsers raised MethodError: no method matching permutedims(::Array{Float64, 3}) on size(transpose(zeros(2,3,4)),1). Swap dimensions 1 and 2 and retain the remaining dimensions. The expected result is 3.
  • [P2] src/antlr_parser.jl:175 accepts the parse tree without checking for end of input. Appending model 'Unexpected' this trailing declaration is incomplete after a valid package produced the original equation and no syntax error. The Julia parser also accepted the input. Require complete consumption after the package terminator and add a trailing-token regression.
  • [P2] Project.toml:4 declares 1.11.0 despite a reproduced compatibility break. For p = 3, r = 2*p, and der(x) = r, remake(prob; p=[sys.r => 9.0]) gave r = 9.0 on the base revision. The head throws an AssertionError reporting a missing Initial parameter for r. Preserve the override contract or ship the binding change as a major release with migration guidance.
  • Blocking priorities: P1, P1, P1, P1, P1, P1, P2, P2, P2, P2

Non-blocking findings

  • src/events.jl:1227 locates the generated callback through cb.affect!.user_affect and assumes the preceding callbacks belong to it. This depends on the layout and ordering of compiled ModelingToolkit callbacks. Use a documented grouping or identification API, or request one upstream. This is a source-inspection finding.

What I ran

  • git rev-parse HEAD matched the header. I reviewed git diff origin/main...HEAD and tested a git archive HEAD copy in scratch with the supplied Julia depot. The checkout has no root AGENTS.md, CLAUDE.md, Julia manifest, or uv.lock.
  • Julia reported 1.13.2. uv run --locked python --version printed Python 3.15.0 and warned that --locked has no effect outside a project. PythonCall reported Python 3.13.18 from the CondaPkg environment used for the ANTLR probes.
  • GROUP=All julia --startup-file=no --project=. -e 'using Pkg; Pkg.test()' exited 0. All 2,215 checks across 14 test sets passed, including 828 event-step regression checks. GROUP=QA julia --startup-file=no --project=. -e 'using Pkg; Pkg.test()' also exited 0 with 20/20 QA checks passing.
  • I ran standalone scratch probes with julia --compiled-modules=existing --project=. against the head and with --project=../test-env against a copy of the resolved package test environment. They exercised both parsers, unsimplified equations, ODEProblem, solve(..., Tsit5()), and a base-versus-head remake on the same Julia dependencies. The blocking findings give the inputs and observed results.

What I did not verify

I did not test other Julia versions, third-party discrete backends, or the documentation build. This run supplied a native Codex session ID. A Devin session name was unavailable.

AUTHOR_GRADE: {"task":"feature","score":2,"difficulty":5,"rounds":1,"author_harness":"unknown","author_model":"unknown","note":"The event and parser tests cover many examples. Independent probes found successful solves with incorrect Boolean transitions, initial states, and function results, and a previously accepted parameter override now fails."}

Head link: 319bfd5


🤖 Posted by an AI agent — harness: codex-cli 0.169.0 · model: gpt-6.2-astra
Conversation: local session 01a1f9e8-e7f0-70d0-a468-54d7bdf89087 (no session URL)

Harness: codex
Model: gpt-6.1-sol
Factory-Task: 36344aaa-655c-490f-a14f-a27e08e00c14
Harness: codex
Model: gpt-6.1-sol
Factory-Task: a0e4edf5-f436-400e-a54f-a91e44cc9808
Harness: codex
Model: gpt-6.1-sol
Factory-Task: fbb532fb-fae9-45eb-aa67-3eba40cfec17

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.

2 participants