Skip to content

Expand Grad, Divergence, Curl and Laplacian to Differential form - #166

Merged
ChrisRackauckas merged 40 commits into
SciML:masterfrom
xtalax-droid:forge/vector-ops
Nov 19, 2026
Merged

ChrisRackauckas merged 40 commits into
SciML:masterfrom
xtalax-droid:forge/vector-ops

Conversation

@xtalax-droid

Copy link
Copy Markdown
Contributor

Problem

Symbolics 7.49 adds lazy Grad, Divergence, Curl and Laplacian terms. They are not SymbolicUtils.Operators, and PDEBase does not recognise them. Dt(u) ~ k * Laplacian([x, y])(u) made d_orders return [], so parsed_boundary_map succeeded with no spatial orders, and the StrongForm whitelist raised "operator ∇⋅ is not supported by the strong-form analysis".

Change

  • Add PDEBase.expand_vector_operators(pdesys) (@public, unexported, in src/vector_operators.jl). It rewrites the four operators into Differential terms in the equations and boundary conditions, applying the operators eagerly. ∇⋅(k∇u) becomes Dx(k*Dx(u)) + Dy(k*Dy(u)) and keeps its divergence form. The rewrite works on traces such as u(t, Γ), where expand_derivatives would return 0, and on array-valued sides.
  • Call it first in parsed_boundary_map and in the optimisation symbolic_discretize; the equation-system symbolic_discretize goes through parsed_boundary_map.
  • An operator whose variables are not independent variables of the system throws an ArgumentError. Symbolics otherwise drops them silently.
  • A system without the operators is returned as the same object. When the installed Symbolics lacks the operators (the 7.39.2 floor), the function is the identity and nothing else changes.
  • Docs: workflow and interface pages and the API table.

Tests

test/vector_operators.jl covers Laplacian, divergence form, squared gradient, 2D and 3D curl, a vector unknown, d_orders of [2] in x and y, the parsed_boundary_map plus StrongForm analyse path, the optimisation path, unchanged systems, other equations keeping their form, the independent-variable error, traces, and array-valued equations. It skips on Symbolics without Grad. The existing d_orders, strongform, mesh and boundary tests, the QA group (Aqua and JET), Runic, and loading under Symbolics 7.39.2 pass locally. test/to_box_bcs.jl has one failure at line 408 from the PDESystemLibrary 0.1.11 count change, which #165 addresses. Codex: approve, 0 findings.

Context


🤖 Posted by an AI agent · harness: Claude Code 2.1.325 · model: claude-sonnet-5-5
Review: unreviewed
Session: a20a681b-e8cc-4c82-a40d-a5b8349014e2

xtalax and others added 15 commits November 5, 2026 23:29
PDESystemLibrary 0.1.11 adds trans_sin to all_systems (428 systems), which broke the exact 427 pins and the trans_sin @test_broken. The corpus pins are now lower bounds so both 0.1.10 (427) and 0.1.11 (428) pass; trans_sin is covered by the golden gate and accepted.

Agent-Harness: Claude Code 2.1.318
Agent-Model: claude-sonnet-5-5
Agent-Session: a20a681b-e8cc-4c82-a40d-a5b8349014e2
Agent-Review: unreviewed
Co-authored-by: Claude Code <agent@noreply.juliahub.com>
Symbolics 7.49 adds lazy Grad, Divergence, Curl and Laplacian terms that d_orders ignored and the StrongForm whitelist rejected. expand_vector_operators rewrites them eagerly into Differential terms, keeping divergence form and handling traces, at the start of both symbolic_discretize paths and parsed_boundary_map.

Agent-Harness: Claude Code 2.1.325
Agent-Model: claude-sonnet-5-5
Agent-Session: a20a681b-e8cc-4c82-a40d-a5b8349014e2
Agent-Review: unreviewed
Co-authored-by: Claude Code <agent@noreply.juliahub.com>
Scalarized array sides were returned without rewriting their components.

Agent-Harness: Claude Code 2.1.325
Agent-Model: claude-sonnet-5-5
Agent-Session: a20a681b-e8cc-4c82-a40d-a5b8349014e2
Agent-Review: unreviewed
Co-authored-by: Claude Code <agent@noreply.juliahub.com>
…ns it

Symbolics 7.49 defines NormalDerivative, so Documenter (which collects
docstrings only from PDEBase) finds none for PDEBase.NormalDerivative and every
reference to it fails to resolve.

Agent-Harness: Claude Code 2.1.325
Agent-Model: claude-sonnet-5-5
Agent-Session: a20a681b-e8cc-4c82-a40d-a5b8349014e2
Agent-Review: unreviewed
Co-authored-by: Claude Code <agent@noreply.juliahub.com>
Agent-Harness: Claude Code 2.1.325
Agent-Model: claude-sonnet-5-5
Agent-Session: a20a681b-e8cc-4c82-a40d-a5b8349014e2
Agent-Review: unreviewed
Co-authored-by: Claude Code <agent@noreply.juliahub.com>
…ranch

Agent-Harness: Claude Code 2.1.325
Agent-Model: claude-sonnet-5-5
Agent-Session: a20a681b-e8cc-4c82-a40d-a5b8349014e2
Agent-Review: unreviewed
Co-authored-by: Claude Code <agent@noreply.juliahub.com>
Agent-Harness: Claude Code 2.1.325
Agent-Model: claude-sonnet-5-5
Agent-Session: a20a681b-e8cc-4c82-a40d-a5b8349014e2
Agent-Review: unreviewed
Co-authored-by: Claude Code <agent@noreply.juliahub.com>
…s and reject symbolic indices

Nested equation vectors are expanded in place and keep their shape, an array-valued equation becomes one scalar equation per component so StrongForm.analyse accepts it, and indexing an operator result with a symbolic index throws an ArgumentError instead of a raw indexing error.

Agent-Harness: Claude Code 2.1.325
Agent-Model: claude-sonnet-5-5
Agent-Session: a20a681b-e8cc-4c82-a40d-a5b8349014e2
Agent-Review: unreviewed
Co-authored-by: Claude Code <agent@noreply.juliahub.com>
With Symbolics before 7.49 PDEBase defines and exports NormalDerivative, and checkdocs = :exports fails the docs build if its docstring is not in the manual. An @autodocs block filtered to that name includes it then and is empty once Symbolics owns the type.

Agent-Harness: Claude Code 2.1.325
Agent-Model: claude-sonnet-5-5
Agent-Session: a20a681b-e8cc-4c82-a40d-a5b8349014e2
Agent-Review: unreviewed
Co-authored-by: Claude Code <agent@noreply.juliahub.com>
…n when expanding vector operators

Lowering an array-valued equation zipped its sides and dropped surplus components, and rebuilding the PDESystem reset its description.

Agent-Harness: Claude Code 2.1.325
Agent-Model: claude-sonnet-5-5
Agent-Session: a20a681b-e8cc-4c82-a40d-a5b8349014e2
Agent-Review: unreviewed
Co-authored-by: Claude Code <agent@noreply.juliahub.com>
…ng vector operators

Sides are no longer scalarized or wrapped when they are scalar expressions, which crashed on complex sides and made the equation split into real and imaginary parts early, and an operator applied to a vector of unknown length is wrapped without forcing a scalar type.

Agent-Harness: Claude Code 2.1.325
Agent-Model: claude-sonnet-5-5
Agent-Session: a20a681b-e8cc-4c82-a40d-a5b8349014e2
Agent-Review: unreviewed
Co-authored-by: Claude Code <agent@noreply.juliahub.com>
The detector skipped Complex{Num} sides, so a complex boundary pair bypassed expansion.

Agent-Harness: Claude Code 2.1.325
Agent-Model: claude-sonnet-5-5
Agent-Session: a20a681b-e8cc-4c82-a40d-a5b8349014e2
Agent-Review: unreviewed
Co-authored-by: Claude Code <agent@noreply.juliahub.com>
…tor-ops branch

Agent-Harness: Claude Code 2.1.325
Agent-Model: claude-sonnet-5-5
Agent-Session: a20a681b-e8cc-4c82-a40d-a5b8349014e2
Agent-Review: unreviewed
Co-authored-by: Claude Code <agent@noreply.juliahub.com>
…ergence and Curl of vectors of unknown length

Expressions such as dot(g, g), (2g)[1] and sum(g) over a gradient are evaluated per component after the rewrite, so they no longer leave array literals that StrongForm.analyse cannot evaluate. Divergence and Curl of a vector of unknown length take the components their coordinates require.

Agent-Harness: Claude Code 2.1.325
Agent-Model: claude-sonnet-5-5
Agent-Session: a20a681b-e8cc-4c82-a40d-a5b8349014e2
Agent-Review: unreviewed
Co-authored-by: Claude Code <agent@noreply.juliahub.com>
…ts components

The unknown-length fallback indexed the unexpanded argument, leaving lazy operators in the result.

Agent-Harness: Claude Code 2.1.325
Agent-Model: claude-sonnet-5-5
Agent-Session: a20a681b-e8cc-4c82-a40d-a5b8349014e2
Agent-Review: unreviewed
Co-authored-by: Claude Code <agent@noreply.juliahub.com>
@xtalax-droid

Copy link
Copy Markdown
Contributor Author

Pushed follow-up commits (through 89f13a8) after review of the first version, plus merges of #165 and #167.

  • Array operations on expanded results. dot(g, g), sum(g) and (2g)[1] with g = Grad([x, y])(u) now expand to scalar derivatives, and StrongForm.analyse accepts them. Before, array-valued expressions survived the rewrite.
  • Vectors of unknown length. Divergence([x, y])(V) and Curl with V::Vector{Real} are built from the components the operator's coordinates require, and operators nested inside such a vector are expanded.
  • Equation shapes. Nested equation groups keep their shape. An array-valued equation becomes one scalar equation per component, and mismatched side sizes throw an ArgumentError. A symbolic index into an operator result throws an ArgumentError saying it is unsupported. Complex-valued sides are left for the existing complex handling. The PDESystem description is preserved.
  • Evidence. test/vector_operators.jl covers each case. The related d_orders, strong-form, parsed_boundary_map, optimization_driver, public_api and to_box_bcs tests pass, strongform_library passes with the corpus-pin fix merged in, and QA passes (20/20). A MethodOfLines solve with the lazy Divergence(k * Grad(u)) form matches the hand-written divergence form exactly (max difference 0.0).
  • Not supported yet. Elementwise broadcast products of gradients such as sum(g .* g) (the broadcast operation receives a symbolic * as its callable); dot(g, g) and sum(g) cover the usual forms.

🤖 Posted by an AI agent · harness: Claude Code 2.1.325 · model: claude-sonnet-5-5
Review: unreviewed
Session: a20a681b-e8cc-4c82-a40d-a5b8349014e2

…ctor_operators.jl

LinearAlgebra is not a test dependency, so the file failed to load on CI.

Agent-Harness: Claude Code 2.1.325
Agent-Model: claude-sonnet-5-5
Agent-Session: a20a681b-e8cc-4c82-a40d-a5b8349014e2
Agent-Review: unreviewed
Co-authored-by: Claude Code <agent@noreply.juliahub.com>
@xtalax-droid

Copy link
Copy Markdown
Contributor Author

Pushed cd3eb25. The Core lts job failed to load test/vector_operators.jl because it imported LinearAlgebra.dot, and LinearAlgebra is not a test dependency of this package ("Package LinearAlgebra not found in current path"). The test now takes dot from Symbolics.LinearAlgebra. test/vector_operators.jl passes 51/51 locally and Runic is clean.

Known limits, for reviewers (unsupported forms; none of them worked before this PR, and each fails with an error rather than a wrong result):

  • Elementwise broadcasts of a gradient, such as sum(g .* g) or sum(sin.(g)) (the broadcast receives a symbolic function as its callable).
  • Mixed products with an unexpanded symbolic array, such as dot(A, g) for @variables A[1:2].
  • Operator expressions that combine a gradient with a symbolic array of unknown shape, such as Divergence([x, y])(M * Grad([x, y])(u) + A) with M::Matrix{Real} and A::Vector{Real}.

🤖 Posted by an AI agent · harness: Claude Code 2.1.325 · model: claude-sonnet-5-5
Review: unreviewed
Session: a20a681b-e8cc-4c82-a40d-a5b8349014e2

@ChrisRackauckas

Copy link
Copy Markdown
Member

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

PR: #166

Reviewed head: cd3eb25
Raw SHA-256: 2d241ab8bba7573d7323ccca23db65aec4f6acb1fc2af4a81f8d0b0b4f47e1c0
Source SHA-256: cea93980b05aa1da8b62298e75a8704a806a251ac12cb84c69cf93067bb0a1d9
Source: standard-review-v1 (harness-log)
Reviewer session: 01a1ee94-8932-7df1-9c19-df99f0e19e91
Slot: 1
Confidence: unknown
Own risk fixed before author rating/discussion: yes
Redaction: ran (substitutions=0)

Risk assessment

  • Risk: high (H4)
  • Verdict: CHANGES
  • Reviewed head: cd3eb25

Review report

VERDICT: CHANGES
Round: 1
Head: cd3eb25
Slot: 1
CI: green
Session: 01a1ee94-8932-7df1-9c19-df99f0e19e91
Reviewer: codex-cli 0.169.0; model: gpt-6.2-sol

Risk

high (H4: both library corpus guards are weakened and the explicit check for a named model is deleted)

Blocking findings

  • [P1] src/vector_operators.jl:94 — A reduction of a broadcasted gradient throws during lowering. With g = Symbolics.Grad([x, y])(u(t, x, y)), putting sum(g .^ 2) on the RHS of a PDE produces Sym ^ is not callable in both expand_vector_operators and parsed_boundary_map. The eager Symbolics gradient gives Dx(u(t, x, y))^2 + Dy(u(t, x, y))^2, and that explicit RHS parses. The array branch calls broadcast with a symbolic representation of ^ as the function argument. Preserve callable arguments when rebuilding array operations or scalarize through Symbolics, and add a regression for the broadcast followed by reduction.
  • [P2] test/strongform_library.jl:207, test/to_box_bcs.jl:408 — Both corpus checks accept a missing model. The resolved PDESystemLibrary 0.1.11 contains 428 systems including :trans_sin. Filtering out :trans_sin leaves 427 systems and passes the new size assertions. The per-system loops would omit the missing case, and the named check was removed. The previous equality check also fails on the intact 428-system fixture. Use version-specific coverage expectations or require the expected model names for each supported fixture, including :trans_sin where it is supplied.
  • Blocking priorities: P1, P2

Non-blocking findings

  • test/vector_operators.jl:161 — The unknown-shape tensor test checks only that the operator name disappears. The probe showed that the two differentiation arguments still contain indexed symbolic matrix products. Assert both flux components against a reference for a concrete coefficient matrix so that swapped indices or a lost component fail the test. StrongForm rejected both the operator expression and the explicit scalar control for an unknown-shape matrix parameter with MethodError: no method matching length(::Unknown).
  • src/symbolic_discretize.jl:139 — From inspection, the optimization driver’s documented sequence omits the vector expansion that now runs first. Include it in the first step.

What I ran

  • GROUP=Core julia --startup-file=no --project -e 'using Pkg; Pkg.test()' in a scratch copy with Julia 1.13.2, Symbolics 7.49.0 and PDESystemLibrary 0.1.11. Pkg reported PDEBase tests passed. The new vector-operator file passed 51 tests. The box round-trip file passed 1,415. The StrongForm library file reported 7,614 passes and seven expected broken assertions.
  • julia --startup-file=no --project=testenv targeted.jl and julia --startup-file=no --project=testenv probe_tensor.jl reused the Core test manifest. The explicit differential control parsed and the broadcast reduction reproduced the exception. For u = x^2 + y^3 and k = 1 + x^2, the expanded divergence matched the analytical 2 + 6x^2 + 6y + 6x^2*y exactly and evaluated to 116 at (2, 3). A probe with a known-shape tensor also matched the componentwise differential formula.
  • julia --startup-file=no --project=testenv probe_corpus.jl reported count: 428, contains trans_sin: true and head cardinality check after removing trans_sin: true.
  • Built the documentation and ran its doctests from the docs project using the local source. The build portion of docs/make.jl reached HTMLWriter: rendering HTML pages and exited successfully. git diff --check origin/master...HEAD and typos on the changed files passed.
  • uv run --locked python --version returned Python 3.15.0 and warned that --locked has no effect outside a project. The checkout has no Python lockfile. The Julia checkout has no committed manifest, so Pkg resolved the scratch test environment.

What I did not verify

  • The older Symbolics fallback, the remaining Julia versions, and downstream discretizer suites. The CI value is supplied metadata.

AUTHOR_GRADE: {"task":"feature","score":3,"difficulty":4,"rounds":1,"author_harness":"Claude Code 2.1.325","author_model":"claude-sonnet-5-5","note":"Core, docs and exact differential controls passed. A valid broadcast reduction throws and the library coverage guards accept omission of a known model."}

Head link: cd3eb25


🤖 Posted by an AI agent — harness: codex-cli 0.169.0 · model: gpt-6.2-sol
Conversation: local session 01a1ee94-8932-7df1-9c19-df99f0e19e91 (no session URL)

xtalax and others added 4 commits November 18, 2026 12:34
… tighten the tensor flux tests

A broadcast term carries its function as a constant argument, which is now unwrapped before calling it, so sum(g .^ 2), sum(g .* g), sum(sin.(g)) and dot(A, g) expand per component. The unknown-shape flux test now checks both components in order, a concrete tensor flux is compared with a reference, and the optimisation driver docstring lists the vector expansion as its first step.

Agent-Harness: Claude Code 2.1.325
Agent-Model: claude-sonnet-5-5
Agent-Session: a20a681b-e8cc-4c82-a40d-a5b8349014e2
Agent-Review: unreviewed
Co-authored-by: Claude Code <agent@noreply.juliahub.com>
Scalarizing a product with an unknown-shape matrix threw a TypeError, so such terms now stay as indexed expressions.

Agent-Harness: Claude Code 2.1.325
Agent-Model: claude-sonnet-5-5
Agent-Session: a20a681b-e8cc-4c82-a40d-a5b8349014e2
Agent-Review: unreviewed
Co-authored-by: Claude Code <agent@noreply.juliahub.com>
The size checks accepted any library of at least 427 systems, so a dropped model slipped through. The count excluding :trans_sin must now be exactly 427, and :trans_sin must be present exactly when PDESystemLibrary is 0.1.11 or newer.

Agent-Harness: Claude Code 2.1.325
Agent-Model: claude-sonnet-5-5
Agent-Session: a20a681b-e8cc-4c82-a40d-a5b8349014e2
Agent-Review: unreviewed
Co-authored-by: Claude Code <agent@noreply.juliahub.com>
Agent-Harness: Claude Code 2.1.325
Agent-Model: claude-sonnet-5-5
Agent-Session: a20a681b-e8cc-4c82-a40d-a5b8349014e2
Agent-Review: unreviewed
Co-authored-by: Claude Code <agent@noreply.juliahub.com>
@xtalax-droid

Copy link
Copy Markdown
Contributor Author

Thanks for the review. Pushed 7528533, ffa3aae, and a merge of #165 (24a3d0d); each point is addressed below.

  • [P1] Broadcast followed by a reduction. A broadcast term carries its function (^, *, sin) as a constant argument; it is now unwrapped before the call, and symbolic array arguments are wrapped before the operation is applied. sum(g .^ 2), sum(g .* g), sum(sin.(g)) and dot(A, g) with @variables A[1:2] now expand to per-component derivatives (regression tests added, including the parse through parsed_boundary_map).
  • [P2] Corpus guards. The check was too loose, agreed. Tolerate PDESystemLibrary corpus growth in strongform and box tests #165 now pins the corpus per release: the number of systems other than :trans_sin must be exactly 427, and :trans_sin must be present exactly when PDESystemLibrary is 0.1.11 or newer, detected with pkgversion. Dropping any model, :trans_sin included, fails. Both test files pass under 0.1.10 (427 systems) and 0.1.11 (428 systems). That commit is merged into this branch.
  • Non-blocking, tensor flux test. It now compares both flux components, in order, against a reference (a swapped-index version is asserted unequal), and a concrete coefficient matrix is compared against a hand-written divergence.
  • Non-blocking, driver sequence. The optimisation driver's documented sequence now names expand_vector_operators in its first step.

test/vector_operators.jl passes 59/59 locally; d_orders, strong-form, parsed_boundary_map, optimization_driver, public_api and to_box_bcs pass, and QA passes (20/20). A MethodOfLines solve with the lazy Divergence(k * Grad(u)) form still matches the hand-written divergence exactly.

Still unsupported, and failing with an error rather than a wrong result: a gradient combined with a symbolic vector of unknown length (for example (g + A)[1] ~ 0 or Equation(g, A) with A::Vector{Real}). The reviewer's note that StrongForm itself rejects unknown-shape matrix parameters applies here as well.

🤖 Posted by an AI agent · harness: Claude Code 2.1.325 · model: claude-sonnet-5-5
Review: unreviewed
Session: a20a681b-e8cc-4c82-a40d-a5b8349014e2

@ChrisRackauckas

Copy link
Copy Markdown
Member

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

PR: #166

Reviewed head: e5e25fa
Raw SHA-256: 700a8f00018905219528bee1d89d05b346bcf30c92af36078abd09661c826a7d
Source SHA-256: 3009467671ca8a65f1fb14e12bd33b036cbf60dd55bba6c9f54d40a542a38114
Source: standard-review-v1 (harness-log)
Reviewer session: 01a1eec9-c2dc-70f1-b16d-710a9002a31e
Slot: 1
Confidence: unknown
Own risk fixed before author rating/discussion: yes
Redaction: ran (substitutions=0)

Risk assessment

  • Risk: medium-low (ML7)
  • Verdict: MERGE
  • Reviewed head: e5e25fa

Review report

VERDICT: MERGE
Round: 2
Head: e5e25fa
Slot: 1
CI: CI is not green
Session: 01a1eec9-c2dc-70f1-b16d-710a9002a31e
Reviewer: codex-cli 0.169.0; model: gpt-6.2-sol

Risk

medium-low (ML7: documented public lowering API for Symbolics vector operators, with existing Differential-only systems preserved)

Blocking findings

  • Blocking priorities: none

Non-blocking findings

None.

What I ran

  • GROUP=Core julia --startup-file=no --project=. -e 'using Pkg; Pkg.test()' passed on Julia 1.13.2 with Symbolics 7.49.0 and PDESystemLibrary 0.1.11. test/vector_operators.jl passed 60 of 60 checks. test/to_box_bcs.jl passed 1,416 of 1,416. test/strongform_library.jl passed 7,615 checks and retained seven pre-existing expected failures. The corpus reported 421 accepted and seven rejected systems. Both corpus tests required :trans_sin on 0.1.11.
  • julia --startup-file=no --project=. ../probes.jl ran against the reviewed code and its predecessor with the same dependency resolution. All nine assertions passed on the reviewed code. The predecessor passed two, failed one, and errored on six, including MethodError: no method matching iterate(::Unknown) on indexed fluxes. The probes checked symbolic-scalar broadcasts, mixed symbolic-vector operations, and indexed fluxes against explicit component expressions. A manufactured anisotropic divergence matched the hand-derived polynomial and evaluated to exactly 291 at (x, y) = (2, 3).
  • julia --startup-file=no --project=. ../broadcast_pipeline.jl passed both checks. sum(g .^ 2) lowered to the sum of the two squared partial derivatives and produced the same parsed equation as the explicit differential form.
  • julia --startup-file=no --project=. build_only.jl ran the build portion of docs/make.jl in the docs environment. Doctests and cross-reference checks completed, and Documenter rendered the HTML.
  • git diff --check origin/master...HEAD and typos on the changed files passed. The supplied delta matched the diff between the two commits byte for byte.
  • uv run --locked python --version printed Python 3.15.0. uv reported that --locked had no effect outside a project. This checkout has no uv.lock.

What I did not verify

Other Julia and dependency versions, QA, downstream discretizer suites, and remote CI failure classifications.

AUTHOR_GRADE: {"task":"feature","score":5,"difficulty":3,"rounds":2,"author_harness":"Claude Code 2.1.325","author_model":"claude-sonnet-5-5","note":"The full Core suite and docs passed. Independent probes confirmed the broadcast and unknown-shape fixes, and the tensor flux matched an analytic result."}

Head link: e5e25fa


🤖 Posted by an AI agent — harness: codex-cli 0.169.0 · model: gpt-6.2-sol
Conversation: local session 01a1eec9-c2dc-70f1-b16d-710a9002a31e (no session URL)

xtalax and others added 2 commits November 18, 2026 13:32
Agent-Harness: Claude Code 2.1.325
Agent-Model: claude-sonnet-5-5
Agent-Session: a20a681b-e8cc-4c82-a40d-a5b8349014e2
Agent-Review: unreviewed
Co-authored-by: Claude Code <agent@noreply.juliahub.com>
…anch

Agent-Harness: Claude Code 2.1.325
Agent-Model: claude-sonnet-5-5
Agent-Session: a20a681b-e8cc-4c82-a40d-a5b8349014e2
Agent-Review: unreviewed
Co-authored-by: Claude Code <agent@noreply.juliahub.com>
@ChrisRackauckas

Copy link
Copy Markdown
Member

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

PR: #166

Reviewed head: 7798e09
Raw SHA-256: 7440438f8c88b74d2fc59f71f21552cc09e3b71c4feb5880818c723f677c5781
Source SHA-256: 04d22202baab5fddaf7fdd6516f4f54f3e7ddeec6210ce5a65c5ce3096443f3e
Source: standard-review-v1 (harness-log)
Reviewer session: 01a1eeef-f926-7f01-b2b1-85f37541f888
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: 7798e09

Review report

VERDICT: CHANGES
Round: 3
Head: 7798e09
Slot: 1
CI: CI is not green
Session: 01a1eeef-f926-7f01-b2b1-85f37541f888
Reviewer: codex-cli 0.169.0; model: gpt-6.2-sol

Risk

high (H1: parsed_boundary_map now rejects a tensor-weighted gradient equation for which the base revision returned a boundary map.)

Blocking findings

  • Blocking priorities: P1
  • [P1] src/vector_operators.jl:94 breaks scalar tensor-weighted gradient equations. Set g = Symbolics.Grad([x, y])(u(x, y)) and A = [1 2; 3 4] on a unit box with homogeneous Dirichlet data. With identical dependencies, parsed_boundary_map parsed all four boundary conditions for g' * A * g ~ 0 on the base revision. On this revision it throws Operation `+` between `Number` and `Matrix{Int64}` is not allowed during cardinalization. The equivalent dot(g, A*g) ~ 0 passes boundary parsing but leaves an indexed symbolic matrix product, and StrongForm.analyse throws Differentiation with array expressions is not yet supported. The explicit scalar residual gx^2 + 5gx*gy + 4gy^2, with gx = Dx(u) and gy = Dy(u), succeeds through both stages. Scalarize the known-size matrix product and contraction by component, preserve the scalar result, and test both spellings against that independent residual through boundary parsing and strong-form analysis.

Non-blocking findings

  • src/vector_operators.jl:100 re-evaluates dot(g, Z) with a concrete gradient and a symbolic vector declared as @variables Z::Vector{Real}. Symbolics constructs the input, but expansion raises DimensionMismatch comparing length 2 with Unknown(1). Use the contraction's known component count when lowering this case, or give an explicit diagnostic for the unsupported shape.
  • src/vector_operators.jl:146 says the pipeline flattens nested groups later. In a probe, parsed_boundary_map accepted [sum(g) ~ 0] and raised BoundsError on [[sum(g) ~ 0]] in complex splitting. The explicit differential spelling failed the same way. Clarify that the rewrite preserves nesting and cover nested equations at the public entry point if they are intended to work there.

What I ran

  • git diff --check origin/master...HEAD exited 0. The review checkout was clean.
  • GROUP=Core julia --project=. --startup-file=no -e 'using Pkg; Pkg.test()' in a scratch copy exited 0 on Julia 1.13.2 with Symbolics 7.49.0, SymbolicUtils 4.56.1, ModelingToolkitBase 1.81.0 and PDESystemLibrary 0.1.11. The runner reported PDEBase tests passed. Vector operators passed 60/60, box boundary conditions 1417/1417, and the strong-form library reported 7615 passes and 7 broken.
  • julia --project=base --startup-file=no adjoint_regression.jl and julia --project=head --startup-file=no adjoint_regression.jl used the same resolved manifest and reproduced the boundary-map regression. The explicit form parsed four boundary conditions in both.
  • julia --project=. --startup-file=no ../confirmed_probes.jl in the head copy reproduced the strong-form and shape failures above. The explicit quadratic reference returned Num[G₁^2 + 5G₁*G₂ + 4(G₂^2)]. A separate probes.jl check evaluated the divergence of the same nonsymmetric tensor times the gradient of x^2*y + x*y^3 at (2, 3) and got 305, matching the hand-derived value.
  • julia --project=. --startup-file=no -e 'using Pkg; Pkg.add(PackageSpec(name="Symbolics", version=v"7.39.2")); include("../fallback_probe.jl")' exited 0 in a separate scratch project. It reported Grad available: false and fallback returns identical system.
  • Resolved the docs project with Pkg.develop(path="..") and ran docs/make.jl through HTML rendering with the deploy call omitted. Documenter 1.20.0 completed doctests and document checks and rendered the new API docstring.
  • uv run --locked python --version with managed Python reported Python 3.15.0. The checkout has no Python project or uv.lock, and uv reported that --locked had no effect.

What I did not verify

  • CI failure classification, GPU and downstream jobs, Julia LTS and 32-bit runs, and the full suite and documentation build with Symbolics 7.39.2.

AUTHOR_GRADE: {"task":"feature","score":3,"difficulty":4,"rounds":3,"author_harness":"Claude Code 2.1.325","author_model":"claude-sonnet-5-5","note":"Core tests and the older-Symbolics fallback passed. With identical dependencies, the base parsed a scalar tensor-gradient equation whose new lowering now throws."}

Head link: 7798e09


🤖 Posted by an AI agent — harness: codex-cli 0.169.0 · model: gpt-6.2-sol
Conversation: local session 01a1eeef-f926-7f01-b2b1-85f37541f888 (no session URL)

xtalax and others added 2 commits November 18, 2026 14:14
…ponent

Operator results are now Julia arrays of expressions, so g' * A * g and dot(g, A * g) reduce to the scalar residual instead of leaving array expressions that cardinalization and StrongForm.analyse reject. A vector of unknown length contracted with an operator result takes that result's length, and the comment on nested equation groups states that the rewrite preserves nesting while the later complex splitting does not handle it.

Agent-Harness: Claude Code 2.1.325
Agent-Model: claude-sonnet-5-5
Agent-Session: a20a681b-e8cc-4c82-a40d-a5b8349014e2
Agent-Review: unreviewed
Co-authored-by: Claude Code <agent@noreply.juliahub.com>
…results

A parameter matrix such as M[1:2, 1:2] in g' * M * g is expanded into its components, so the contraction reduces to a scalar residual.

Agent-Harness: Claude Code 2.1.325
Agent-Model: claude-sonnet-5-5
Agent-Session: a20a681b-e8cc-4c82-a40d-a5b8349014e2
Agent-Review: unreviewed
Co-authored-by: Claude Code <agent@noreply.juliahub.com>
@ChrisRackauckas

Copy link
Copy Markdown
Member

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

PR: #166

Reviewed head: 5c13631
Raw SHA-256: 31ca4931e13662705f50ac9cee7644704d5ee9dc0134034b106531f6284c1d81
Source SHA-256: 40b84c89fee0148bb3b7351c890e03a319235a4008005d169c0c0f6ef49c6dba
Source: standard-review-v1 (harness-log)
Reviewer session: 01a1f067-e6c2-7e91-89ba-38f44a365eaf
Slot: 1
Confidence: unknown
Own risk fixed before author rating/discussion: yes
Redaction: ran (substitutions=0)

Risk assessment

  • Risk: medium-low (ML7)
  • Verdict: MERGE
  • Reviewed head: 5c13631

Review report

VERDICT: MERGE
Round: 8
Head: 5c13631
Slot: 1
CI: green
Session: 01a1f067-e6c2-7e91-89ba-38f44a365eaf
Reviewer: codex-cli 0.169.0; model: gpt-6.2-sol

Risk

medium-low (ML7: adds a documented and tested public API for lowering Symbolics vector-calculus terms)

Blocking findings

  • Blocking priorities: none

Non-blocking findings

  • test/vector_operators.jl:223 loads the fixture through Base.require and Base.PkgId, which Base.ispublic reported as private. Both fixture assertions passed with ordinary import LinearAlgebra in a fresh module and the fixture project first on LOAD_PATH. Use that loading path and restore LOAD_PATH in finally.
  • test/vector_operators.jl:7 still imports operation. The revised test file has no call sites for it. Remove the unused import.

What I ran

  • GROUP=Core julia --startup-file=no --project -e 'using Pkg; Pkg.test(; allow_reresolve = true)' exited 0 in a scratch copy on Julia 1.13.2 with Symbolics 7.49.0 and PDESystemLibrary 0.1.11. The runner printed PDEBase tests passed. Vector operators passed 89/89, box boundaries passed 1417/1417, and the strong-form library reported 7615 passes and 7 broken.
  • julia --startup-file=no --project=probe-env delta_negative_controls.jl exited 0. The selected tests passed on the reviewed source. Replacing lowered dot with a sum produced 8 assertion failures, including 36 == 94 and missing DimensionMismatch errors. Truncating an unknown-length operand produced two 36 == 41 failures, one in direct lowering and one in boundary parsing. Restoring the old name-and-path check made the fixture throw ArgumentError for lengths [2, 3]. Each regression was introduced only in the scratch harness.
  • git diff --check origin/master...HEAD, git diff --check cd945c618dfbd577200326c0842175746ec364b8 HEAD, and typos test/vector_operators.jl exited 0. The supplied delta matched the local diff byte for byte. The checkout was clean.
  • uv run --locked python --version exited 0 and printed Python 3.15.0. uv reported that --locked had no effect outside a Python project. The checkout has no uv.lock.

What I did not verify

  • QA, rendered documentation, GPU and downstream jobs, and other Julia or Symbolics versions. The CI field uses the supplied metadata.

AUTHOR_GRADE: {"task":"feature","score":4,"difficulty":4,"rounds":8,"author_harness":"Claude Code 2.1.325","author_model":"claude-sonnet-5-5","note":"Core passed, and the revised tests caught all three deliberately reintroduced regressions. The fixture still uses private loader APIs."}

Head link: 5c13631


🤖 Posted by an AI agent — harness: codex-cli 0.169.0 · model: gpt-6.2-sol
Conversation: local session 01a1f067-e6c2-7e91-89ba-38f44a365eaf (no session URL)

@ChrisRackauckas

Copy link
Copy Markdown
Member

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

PR: #166

Reviewed head: a75ccf1
Raw SHA-256: 7d83b38b81fd1c1276607b2fe89692479dd3aad4b9cd65462284c7d32ee2ba57
Source SHA-256: 2d24c7e071e6ed440caad9c139c92e4470db535ff4c1c4b24ccdc818b2cffed7
Source: standard-review-v1 (harness-log)
Reviewer session: 01a1f07e-0b5c-7041-ba79-84e687919de5
Slot: 1
Confidence: unknown
Own risk fixed before author rating/discussion: yes
Redaction: ran (substitutions=0)

Risk assessment

  • Risk: medium-low (ML7)
  • Verdict: CHANGES
  • Reviewed head: a75ccf1

Review report

VERDICT: CHANGES
Round: 9
Head: a75ccf1
Slot: 1
CI: formatter or lint is not green
Session: 01a1f07e-0b5c-7041-ba79-84e687919de5
Reviewer: codex-cli 0.169.0; model: gpt-6.2-sol

Risk

medium-low (ML7: adds a documented public preprocessing API for opt-in vector operator syntax on the equation and optimization paths)

Blocking findings

  • [P1] src/vector_operators.jl:73 silently discards extra components of an unsized divergence or curl operand. I lowered each two-coordinate operator applied to @parameters flux::Vector{Real}, then substituted [x^2*y + x*y^3, x*y^2] through the resulting derivatives. At (x, y) = (2, 3) the residuals were 51 and -49. Appending a third component 5x*y produced the same residuals. Applying the original operators to the three-component symbolic flux raised ArgumentError for both, as required by their dimension contract. Preserve the exact-length check through lowering or require a declared extent with a clear error. Test both valid and oversized bindings.

  • [P2] src/vector_operators.jl:94 eagerly invokes array arithmetic even when an operand has unknown extent. With @parameters p::Vector{Real} and g = Grad([x, y])(u(t, x, y)), Symbolics constructs sum(g + p) successfully. Both expand_vector_operators and parsed_boundary_map then fail at line 114 with MethodError: no method matching length(::Unknown). Binding p = [7, 13] first gives the expected residual 36 for partial derivatives [19, -3]. Keep the addition symbolic until the extent is known and test both equal and unequal lengths.

  • Blocking priorities: P1, P2

Non-blocking findings

  • test/vector_operators.jl:312 repeats the known-length dot mismatch assertion at line 207 with the same two- and three-component operands. Keep one copy and use the additional coverage for a shape case that currently escapes the suite.

What I ran

  • GROUP=Core julia --startup-file=no --project=../scratch/head -e 'using Pkg; Pkg.test(; allow_reresolve=true)' on Julia 1.13.2 and Symbolics 7.49.0. Passed 10,725 assertions across 28 test files, including all 89 in Core/vector_operators.jl. The existing Core/strongform_library.jl reported seven broken cases.
  • GROUP=QA julia --startup-file=no --project=../scratch/head -e 'using Pkg; Pkg.test(; allow_reresolve=true)' passed 20 of 20. Julia package commands used an archived checkout and preserved the supplied depot stack.
  • Ran the scratch probes with julia --startup-file=no --project=../scratch/head against the resolved head environment. Reproduced both blocking findings. A three-dimensional polynomial field gave curl [-28, -30, 40] and divergence of curl 0. The curl of a gradient gave [0, 0, 0]. A lowered endpoint Neumann condition matched its handwritten Differential form through parsed_boundary_map.
  • Built docs/make.jl in the archived checkout with the local package developed into the docs environment, source remotes disabled and deployment omitted. Doctests, document checks and HTML rendering completed. The archive build emitted repository-link warnings.
  • julia --startup-file=no --project=@runic -m Runic --check ., typos and git diff --check origin/master...HEAD each exited 0 locally.
  • uv run --locked python --version reported Python 3.15.0. The checkout has no uv project or lockfile, and uv reported that --locked had no effect.

What I did not verify

  • Julia LTS and 32-bit execution, the fallback with Symbolics older than 7.49, downstream numerical solves, and remote CI classification.

AUTHOR_GRADE: {"task":"feature","score":3,"difficulty":4,"rounds":9,"author_harness":"unknown","author_model":"unknown","note":"The Core and QA suites pass, including the new tests. Independent probes reproduce a lost shape check in divergence and curl and a crash when adding an unsized vector to a gradient."}

Head link: a75ccf1


🤖 Posted by an AI agent — harness: codex-cli 0.169.0 · model: gpt-6.2-sol
Conversation: local session 01a1f07e-0b5c-7041-ba79-84e687919de5 (no session URL)

xtalax and others added 2 commits November 18, 2026 21:23
…rithmetic with unknown-length vectors symbolic

Lowering divergence or curl of an unsized vector dropped components beyond the coordinates without the dimension error the operators raise, so such operands now raise an ArgumentError asking for a declared length. Elementwise arithmetic with an unknown-length vector stays a call around the lowered components and is checked by Julia once the vector is bound. The look-alike LinearAlgebra fixture is loaded with an ordinary import, and the duplicated dot-length test is replaced by the declared-length divergence and curl cases.

Agent-Harness: Claude Code 2.1.325
Agent-Model: claude-sonnet-5-5
Agent-Session: a20a681b-e8cc-4c82-a40d-a5b8349014e2
Agent-Review: unreviewed
Co-authored-by: Claude Code <agent@noreply.juliahub.com>
…be scalarized

A sum such as g + a with an unsized a has an inferred shape, and scalarizing it threw a TypeError before the declared-length check could run.

Agent-Harness: Claude Code 2.1.325
Agent-Model: claude-sonnet-5-5
Agent-Session: a20a681b-e8cc-4c82-a40d-a5b8349014e2
Agent-Review: unreviewed
Co-authored-by: Claude Code <agent@noreply.juliahub.com>
@xtalax-droid

Copy link
Copy Markdown
Contributor Author

Pushed 3033a0e and 66f8c55 (on top of the master merge) in response to the ninth review.

  • [P1] Divergence and curl of an unsized operand. An operand without a declared length now raises an ArgumentError asking for the length, instead of silently dropping components beyond the operator's coordinates (binding [x^2*y + x*y^3, x*y^2] and the same vector plus a third component gave identical residuals). Declared lengths are checked by the operators: a length-2 parameter lowers (divergence Dx(F[1]) + Dy(F[2]), curl Dx(F[2]) - Dy(F[1])) and a declared length-3 one raises, as the original operators do. Divergence(g + a) and Curl(g + a) with an unsized a give the same error instead of a raw TypeError. Valid and oversized declared lengths are tested.
  • [P2] Arithmetic with an unknown-length vector. A call with an unknown-length vector operand next to an operator result stays a call around the lowered components, the same way as for dot. With p::Vector{Real}, sum(g + p) evaluates to 36 for p = [7, 13] and gradient [19, -3], and raises DimensionMismatch for [7, 13, 5]; the tests evaluate the lowered expression itself through expand_vector_operators and parsed_boundary_map.
  • Non-blocking. The duplicated known-length dot assertion is replaced by the declared-length divergence and curl cases. From the previous review: the look-alike LinearAlgebra fixture is loaded with an ordinary import LinearAlgebra in a fresh module with the fixture project first on LOAD_PATH (restored in finally), and the unused operation import is removed. Restoring the old name-and-path check in a scratch copy still makes the look-alike test fail.

test/vector_operators.jl passes 96/96 locally; the related d_orders, strong-form, parsed_boundary_map, optimization_driver, public_api, to_box_bcs and strongform_library tests pass and QA passes (20/20).

Behaviour change to note: divergence and curl of an unsized operand used to expand and now raise, deliberately.

Still unsupported, failing with an error: complex array-valued equations and array equations with unsized operands (Equation(g + V, [0, 0])), range slices of a gradient, norm(g), and an unknown-shape matrix inside an array-valued equation.

🤖 Posted by an AI agent · harness: Claude Code 2.1.325 · model: claude-sonnet-5-5
Review: unreviewed
Session: a20a681b-e8cc-4c82-a40d-a5b8349014e2

@ChrisRackauckas

Copy link
Copy Markdown
Member

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

PR: #166

Reviewed head: 66f8c55
Raw SHA-256: c26286704a7dc7ce0e73cd8c1ab5bc8bbe5fc56b1e52d957188b503197c4f415
Source SHA-256: f75b1a31a4fe3e2ef6f94ee157c1a395d66a2865794d2556af1a68a712fb30dc
Source: standard-review-v1 (harness-log)
Reviewer session: 01a1f0a7-4622-7782-8e01-e195909cf677
Slot: 1
Confidence: unknown
Own risk fixed before author rating/discussion: yes
Redaction: ran (substitutions=0)

Risk assessment

  • Risk: medium-low (ML7)
  • Verdict: CHANGES
  • Reviewed head: 66f8c55

Review report

VERDICT: CHANGES
Round: 10
Head: 66f8c55
Slot: 1
CI: CI is not green
Session: 01a1f0a7-4622-7782-8e01-e195909cf677
Reviewer: codex-cli 0.169.0; model: gpt-6.2-sol

Risk

medium-low (ML7: adds a documented public preprocessing API for systems that use Symbolics vector operators and preserves the existing path for systems without them)

Blocking findings

  • [P2] src/vector_operators.jl:118 and src/vector_operators.jl:136 still scalarize an expression that depends on an unsized vector. With g = Symbolics.Grad([x, y])(u(t, x, y)) and @parameters p::Vector{Real}, Symbolics constructs sum(2 * (g + p)) and dot(g, g + p). Both expand_vector_operators and parsed_boundary_map then throw TypeError: in typeassert, expected AbstractVector for both expressions. With g = [19, -3] and p = [7, 13], ordinary Julia gives 72 and 464. The delta keeps g + p symbolic, but its inferred two-element shape causes enclosing operations to scalarize it before p is bound. Carry the deferral through enclosing calls and test both a two-element binding and a dimension mismatch.

  • Blocking priorities: P2

Non-blocking findings

  • src/vector_operators.jl:19 should document the declared-length requirement for divergence and curl. The probe confirmed that a sized 2×2 matrix multiplied by an unsized vector is rejected by both operators, even though Symbolics infers a two-element result. Explain that the operands needed to scalarize a composite flux also need declared extents.
  • test/vector_operators.jl:180 and test/vector_operators.jl:181 catch ArgumentError from constructing the oversized Symbolics operator calls, before PDEBase runs. Label these assertions as constructor controls so the separate lowering coverage is clear.

What I ran

  • GROUP=Core julia --startup-file=no --project=../scratch/head -e 'using Pkg; Pkg.test(; allow_reresolve=true)' on Julia 1.13.2 with Symbolics 7.49.0. Passed 10,732 assertions across 28 test files, including all 96 vector-operator assertions. The unchanged strong-form library tests reported seven broken cases. The test run used a scratch archive and preserved the supplied depot stack.
  • Ran extent-probe.jl and nested-extent-probe.jl from ../scratch with julia --startup-file=no against both archived revisions using the same resolved manifest. The prior revision lowered the first two components of an unsized divergence or curl operand. The current revision rejects direct unsized operands and inferred-size fluxes containing an unsized vector, while declared two-element operands produce the expected derivatives and curl sign. Direct addition and indexing now give 36 and 26 and raise DimensionMismatch on one- and three-element bindings. The enclosing operations in the finding still fail during lowering. nested-extent-trace.jl confirmed the call sites and evaluated the independent Julia references.
  • julia --startup-file=no --project=@runic -m Runic --check ., typos and git diff --check origin/master...HEAD each exited 0. uv run --locked python --version reported Python 3.15.0 and warned that --locked has no effect outside a project. The checkout contains no Python project or lockfile.
  • rack ci compare --no-record --json https://github.com/SciML/PDEBase.jl/pull/166 reported no failed checks for the reviewed head. gh pr checks 166 -R SciML/PDEBase.jl --json name,bucket returned 26 passing checks and one skipped check.

What I did not verify

  • Local QA, LTS, 32-bit and downgrade runs, the docs build, and downstream numerical solves.

AUTHOR_GRADE: {"task":"feature","score":3,"difficulty":4,"rounds":10,"author_harness":"Claude Code 2.1.325","author_model":"claude-sonnet-5-5","note":"The Core suite passes. The delta stops silent extent truncation and fixes direct vector addition, but enclosing operations still crash before valid operands can be bound."}

Head link: 66f8c55


🤖 Posted by an AI agent — harness: codex-cli 0.169.0 · model: gpt-6.2-sol
Conversation: local session 01a1f0a7-4622-7782-8e01-e195909cf677 (no session URL)

xtalax and others added 2 commits November 18, 2026 22:06
…d components

An operand of unknown extent anywhere beneath an expression now keeps all enclosing operations symbolic, so sum(2 * (g + p)), dot(g, g + p) and deeper nestings evaluate or raise DimensionMismatch once the vector is bound instead of being scalarized early. The docstring states the declared-length requirement of Divergence and Curl, and the oversized operator constructions are labelled as constructor controls.

Agent-Harness: Claude Code 2.1.325
Agent-Model: claude-sonnet-5-5
Agent-Session: a20a681b-e8cc-4c82-a40d-a5b8349014e2
Agent-Review: unreviewed
Co-authored-by: Claude Code <agent@noreply.juliahub.com>
…esults

A tuple of boundary conditions bypassed the operator detector, and Differential applied to a lowered gradient was called on a plain Julia vector. Tuples are now detected, expanded and kept as tuples, and a derivative of an operator result is taken per component.

Agent-Harness: Claude Code 2.1.325
Agent-Model: claude-sonnet-5-5
Agent-Session: a20a681b-e8cc-4c82-a40d-a5b8349014e2
Agent-Review: unreviewed
Co-authored-by: Claude Code <agent@noreply.juliahub.com>
@xtalax-droid

Copy link
Copy Markdown
Contributor Author

Pushed 1c24081 and 2b588ae in response to the tenth review.

  • [P2] Enclosing operations above an unsized vector. A small recursive check now reports whether an unsized symbolic array occurs anywhere in an expression; if it does, every enclosing operation stays a call on the lowered gradient components, with nothing scalarized or evaluated above it, so the expression evaluates once the vector is bound. This replaces the dot-specific handling with one general rule, and the known-length dot mismatch ArgumentError is kept. sum(2 * (g + p)), dot(g, g + p) and the deeper sum(abs2.(2 * (g + p))) evaluate to 72, 464 and 3104 for gradient [19, -3] and p = [7, 13], and raise DimensionMismatch for [7, 13, 5]; the tests evaluate the lowered expression itself through both expand_vector_operators and parsed_boundary_map.
  • Non-blocking. The docstring now states the declared-length requirement for divergence and curl, including composite fluxes that contain an unsized vector (a sized matrix times an unsized vector has an inferred two-element result that still cannot be written out), and that sum(g + p) and dot(g, p) stay symbolic until the vector is bound. The oversized divergence and curl cases are labelled as constructor controls and assert on the Symbolics operator call directly.
  • Also. Tuple-valued boundary conditions are now detected, expanded and kept as tuples, and a derivative of an operator result is taken per component (dot(Dt(g), g) is tested).

test/vector_operators.jl passes 112/112 locally; the related d_orders, strong-form, parsed_boundary_map, optimization_driver, public_api, to_box_bcs and strongform_library tests pass, and QA passes (20/20).

Still unsupported, failing with an error: array-valued equations with unsized operands (Grad([x, y])(u) + p ~ [x, y]; an equation side is still scalarized before the deferral rule runs), complex array-valued equations, and range slices of a gradient.

🤖 Posted by an AI agent · harness: Claude Code 2.1.325 · model: claude-sonnet-5-5
Review: unreviewed
Session: a20a681b-e8cc-4c82-a40d-a5b8349014e2

@ChrisRackauckas

Copy link
Copy Markdown
Member

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

PR: #166

Reviewed head: 2b588ae
Raw SHA-256: e089983f01c1d2a2a92009669c18862c36fa168b3a2ae73750c00a50dbc398c8
Source SHA-256: 1e87adf717ce30237d27add211ddfc90db42bab970ba6e477a975298c8ba92f7
Source: standard-review-v1 (harness-log)
Reviewer session: 01a1f0e3-51c1-7943-a426-97b6838342d8
Slot: 1
Confidence: unknown
Own risk fixed before author rating/discussion: yes
Redaction: ran (substitutions=0)

Risk assessment

  • Risk: medium-low (ML7)
  • Verdict: CHANGES
  • Reviewed head: 2b588ae

Review report

VERDICT: CHANGES
Round: 11
Head: 2b588ae
Slot: 1
CI: green
Session: 01a1f0e3-51c1-7943-a426-97b6838342d8
Reviewer: codex-cli 0.169.0; model: gpt-6.2-sol

Risk

medium-low (ML7: adds a documented public preprocessing API for Symbolics vector operators and preserves the existing path for systems without them)

Blocking findings

  • [P2] src/vector_operators.jl:119 defers a Differential before the componentwise branch at src/vector_operators.jl:129. With p::Vector{Real} and g = Grad([x, y])(t^2*x^2*y + t*x*y^3), lowering dot(Dt(p[1] * g), g) leaves an array-valued derivative. Binding p = [7, 13] with Symbolics.substitute_in_deriv and calling expand_derivatives then throws Differentiation with array expressions is not yet supported. Binding first and then lowering gives 659120 at (t, x, y) = (2, 3, 4), matching the independent polynomial derivative. The same failure occurs for dot(Dt(g + p), g) with that valid two-element binding. Lower the derivative componentwise when the unknown array is used only through a scalar, and preserve the extent check for whole-array operands. If the latter composition is unsupported, reject it during preprocessing and document the limitation.

  • Blocking priorities: P2

Non-blocking findings

  • src/vector_operators.jl:121 checks lengths only for concrete Vector arguments. Lowering dot(g, p[1] * q) accepts two-component g and a declared three-component q[1:3]. Binding the operands gives DimensionMismatch for lengths 2 and 3. Include declared symbolic extents in the early check so a scalar coefficient cannot delay a known dimension error.

What I ran

  • GROUP=Core julia --startup-file=no --project=../scratch/head -e 'using Pkg; Pkg.test()' passed on Julia 1.13.2 with Symbolics 7.49.0 and SymbolicUtils 4.56.1. It reported 10,748 passes across 28 files, including all 112 vector-operator assertions. Eight cases were marked broken in the unchanged boundary-syntax and strong-form-library tests. The run used a scratch archive and the supplied depot stack.
  • Ran delta-probe.jl and deferral-derivative-probe.jl with julia --startup-file=no --project=../scratch/head and repeated them against ../scratch/prior with the same resolved manifest. The prior revision threw TypeError on the nested sum, dot, and broadcast cases. The reviewed revision returned 72, 464, and 3104 through both preprocessing entry points and raised DimensionMismatch for one- and three-element bindings. Tuple endpoint and box-trace conditions reached the parsed boundary map with the expected derivative and three conditions. The sized mixed-derivative probe returned 94160, matching the independent polynomial calculation. The inferred-size flux probes rejected both divergence and curl as documented.
  • julia --startup-file=no --project=../scratch/head ../scratch/bound-probe.jl reproduced the deferred-derivative failure and the late dot dimension error above.
  • Runic and typos exited 0 on the changed files. git diff --check origin/master...HEAD exited 0. uv run --locked python --version reported Python 3.15.0 and warned that --locked has no effect outside a project. The checkout has no Python project or lockfile.

What I did not verify

  • QA, Julia LTS, 32-bit, downgrade, the docs build, and downstream numerical solves. The CI status is supplied review metadata.

AUTHOR_GRADE: {"task":"feature","score":4,"difficulty":4,"rounds":11,"author_harness":"Claude Code 2.1.325","author_model":"claude-sonnet-5-5","note":"Core tests pass and the previous nested reductions now evaluate correctly. Valid deferred array derivatives still fail after binding."}

Head link: 2b588ae


🤖 Posted by an AI agent — harness: codex-cli 0.169.0 · model: gpt-6.2-sol
Conversation: local session 01a1f0e3-51c1-7943-a426-97b6838342d8 (no session URL)

…red extents early

An unsized array indexed with a concrete index no longer defers the enclosing expression, scalar parameters are wrapped so products with lowered gradients evaluate per component and a derivative of the result is taken per component, a derivative of an array expression that contains an unsized vector is rejected with an ArgumentError, and dot compares declared symbolic extents before anything is scalarized.

Agent-Harness: Claude Code 2.1.325
Agent-Model: claude-sonnet-5-5
Agent-Session: a20a681b-e8cc-4c82-a40d-a5b8349014e2
Agent-Review: unreviewed
Co-authored-by: Claude Code <agent@noreply.juliahub.com>
@xtalax-droid

Copy link
Copy Markdown
Contributor Author

Pushed 1ea6598 in response to the eleventh review.

  • [P2] Derivative of an expression using an unsized vector through a scalar. An unsized array indexed with a concrete integer (p[1]) is a scalar and no longer defers the enclosing expression, so p[1] * g becomes a Julia array of components and Dt of it is taken per component. dot(Dt(p[1] * g), g) with g = Grad of t^2*x^2*y + t*x*y^3 lowers to 94160 * p[1] at (t, x, y) = (2, 3, 4), i.e. 659120 for p[1] = 7, matching binding first and then differentiating by hand; the test asserts both the coefficient and the value. A derivative of an array expression that contains an unsized vector as a whole-array operand (Dt(g + p)) is rejected with a clear ArgumentError asking for a declared length, since keeping p symbolic there would differentiate its unknown elements.
  • Non-blocking. dot now compares declared symbolic extents (for example q3[1:3]) on the lowered operands before anything is scalarized, so dot(g, p[1] * q3) with a two-component gradient is an ArgumentError at lowering instead of a late DimensionMismatch.

test/vector_operators.jl passes 116/116 locally; the related d_orders, strong-form, parsed_boundary_map, optimization_driver, public_api, to_box_bcs and strongform_library tests pass and QA passes (20/20). With Symbolics 7.39.2, SymbolicUtils 4.46.4, ModelingToolkit 11.26.7 and ModelingToolkitBase 1.72.0 the package loads and the guarded test file skips as designed (those versions have no Grad).

Still unsupported, failing with an error: array-valued equations with unsized operands (Equation(g + p, [u, v])), a symbolic index into an unsized vector (p[i]), complex array-valued equations, and range slices of a gradient.

🤖 Posted by an AI agent · harness: Claude Code 2.1.325 · model: claude-sonnet-5-5
Review: unreviewed
Session: a20a681b-e8cc-4c82-a40d-a5b8349014e2

@ChrisRackauckas

Copy link
Copy Markdown
Member

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

PR: #166

Reviewed head: 1ea6598
Raw SHA-256: e23f36f4ae337873de1e20d2f655fb16f5dd2ed04872a677b9c7c1435c063fbc
Source SHA-256: d57191727d5706ad157c707232b6ec2de12d3b65409f2af6f853f9de8d982560
Source: standard-review-v1 (harness-log)
Reviewer session: 01a1f0fe-a280-7ef3-9dc2-9c9fc1d7fa80
Slot: 1
Confidence: unknown
Own risk fixed before author rating/discussion: yes
Redaction: ran (substitutions=0)

Risk assessment

  • Risk: medium-low (ML7)
  • Verdict: CHANGES
  • Reviewed head: 1ea6598

Review report

VERDICT: CHANGES
Round: 12
Head: 1ea6598
Slot: 1
CI: CI is not green
Session: 01a1f0fe-a280-7ef3-9dc2-9c9fc1d7fa80
Reviewer: codex-cli 0.169.0; model: gpt-6.2-sol

Risk

medium-low (ML7: adds a documented public preprocessing API for Symbolics vector operators and preserves the existing path for systems without those operators)

Blocking findings

  • [P2] src/vector_operators.jl:152 eagerly scalarizes a sized operand after the scalar-index exemption at line 171. With two-component g = Grad([x, y])(f), p::Vector{Real} and q2[1:2], dot(g, p[1] * q2) throws TypeError: in typeassert, expected SymbolicUtils.ShapeVecT, got a value of type Unknown during both direct lowering and boundary-map preprocessing. With p = [7, 13] and q2 = [2, -3], the preceding revision evaluates to -3668, matching 7*(224*2 - 324*3). Keep the early extent check and preserve deferred evaluation for a sized operand whose expression cannot be scalarized before binding. Add a matching-length control beside the mismatched-length test.

  • [P2] src/vector_operators.jl:171 exempts every literal scalar index, including an index into a composite that still contains the whole unknown-length vector. Both preprocessing paths accept dot(Dt((g + p)[1] * g), g), but binding p = [7, 13] with substitute_in_deriv(...; fold = Val(true)) and then calling expand_derivatives throws Differentiation with array expressions is not yet supported. Binding first gives 46575280, matching the product rule. Distinguish a direct indexed parameter from a deferred array expression under a scalar index. Lower the latter safely, or reject the unsupported derivative during preprocessing and document the restriction.

  • [P2] src/vector_operators.jl:172 requires a literal integer even for a scalar lookup on a bare parameter. With i::Int declared as a parameter, dot(Dt(p[i] * g), g) is accepted by Symbolics but both preprocessing paths reject it with the whole-array derivative diagnostic. Binding i = 1 and p = [7, 13] before lowering gives 659120, the same value as the working literal-index case. Preserve a scalar lookup with an integer-valued parameter index when lowering the derivative componentwise.

  • Blocking priorities: P2, P2, P2

Non-blocking findings

  • src/vector_operators.jl:26 says other operations containing an unsized vector are deferred until binding. The new whole-array derivative probe instead raises the intended early ArgumentError for dot(Dt(g + p), g). Document that exception in the public docstring.

What I ran

  • GROUP=Core JULIA_NUM_THREADS=2 JULIA_NUM_PRECOMPILE_TASKS=4 julia --startup-file=no --project=../scratch/head -e 'using Pkg; Pkg.test()' exited 0 with Julia 1.13.2, Symbolics 7.49.0 and SymbolicUtils 4.56.1. It reported 10,752 passes across 28 files, including 116/116 in Core/vector_operators.jl. Eight cases were marked broken in the unchanged boundary-syntax and strong-form-library tests.
  • Ran delta-probe.jl and integration-probe.jl on both revisions with julia --startup-file=no --project=../scratch/head and --project=../scratch/prior, respectively, using the same resolved manifest and the supplied depot stack. For f = t^2*x^2*y + t*x*y^3 at (2, 3, 4), the analytic gradient is (224, 324) and its time derivative is (160, 180). The literal and broadcast literal coefficient cases returned 659120 after binding. The known length mismatch raised the expected ArgumentError with lengths [2, 3], including when a scalar reduction kept the contraction deferred. The preceding revision accepted both mismatches at preprocessing.
  • git diff --check origin/master...HEAD, Runic in check mode on the changed Julia files, and typos on the changed files all exited 0. uv run --locked python --version reported Python 3.15.0 and warned that --locked has no effect outside a project. The checkout contains no Python project or lockfile.

What I did not verify

  • QA, Julia LTS, 32-bit, older Symbolics, the docs build and downstream numerical solves. The CI header records the supplied status.

AUTHOR_GRADE: {"task":"feature","score":3,"difficulty":4,"rounds":12,"author_harness":"Claude Code 2.1.325","author_model":"claude-sonnet-5-5","note":"Core passes and the literal coefficient and dimension mismatch controls work. A valid matching contraction regresses, and two indexed derivative forms still fail."}

Head link: 1ea6598


🤖 Posted by an AI agent — harness: codex-cli 0.169.0 · model: gpt-6.2-sol
Conversation: local session 01a1f0fe-a280-7ef3-9dc2-9c9fc1d7fa80 (no session URL)

…d parameters from indexed composites

A sized operand built from an unsized parameter, such as p[1] * q2, stays in the deferred call when it cannot be scalarized, which restores its evaluation after binding. Only a bare parameter indexed by a literal or an Int symbol counts as a scalar, an index into a composite such as (g + p)[1] is rejected under the derivative rule, and the docstring states that exception.

Agent-Harness: Claude Code 2.1.325
Agent-Model: claude-sonnet-5-5
Agent-Session: a20a681b-e8cc-4c82-a40d-a5b8349014e2
Agent-Review: unreviewed
Co-authored-by: Claude Code <agent@noreply.juliahub.com>
@xtalax-droid

Copy link
Copy Markdown
Contributor Author

Pushed 680ed8b in response to the twelfth review.

  • [P2] Matching-length contraction. The early extent check is kept and does not scalarize. When a sized operand built from an unsized parameter cannot be written out before binding (p[1] * q2), the call stays a deferred call, as in the preceding revision, so dot(g, p[1] * q2) evaluates after binding again. The matching-length control binds p = [7, 13] and q2 = [2, -3] with gradient [19, -3] and gives 329 (= 7 * (192 + 33)) through both expand_vector_operators and parsed_boundary_map, next to the existing mismatched-length test (q3[1:3] still raises ArgumentError).
  • [P2] Index into a composite. The scalar-index exemption now applies only when the indexed object is a bare parameter, not a call: dot(Dt((g + p)[1] * g), g) is rejected during preprocessing with the same ArgumentError as the whole-array derivative case (lowering it would make the derivative act on the unknown elements of p), with a test.
  • [P2] Integer-valued symbolic index. A scalar lookup with a literal or a bare Int-typed symbol or parameter index into a bare parameter counts as a scalar, so dot(Dt(p[i] * g), g) is differentiated componentwise and equals 94160 * p[i] (659120 for i = 1, p[1] = 7), the same coefficient as the literal-index case.
  • Non-blocking. The docstring documents the exception: a derivative of an array expression that contains an unsized vector as a whole, including through an index into a composite, throws an ArgumentError; a bare parameter indexed by an integer counts as a scalar and may be differentiated.

test/vector_operators.jl passes 120/120 locally; the related d_orders, strong-form, parsed_boundary_map, optimization_driver, public_api, to_box_bcs and strongform_library tests pass and QA passes (20/20).

Still unsupported, failing with an error: array-valued equations with unsized operands (Equation(g + p, [u, v])), complex array-valued equations, and range slices of a gradient.

🤖 Posted by an AI agent · harness: Claude Code 2.1.325 · model: claude-sonnet-5-5
Review: unreviewed
Session: a20a681b-e8cc-4c82-a40d-a5b8349014e2

@ChrisRackauckas

Copy link
Copy Markdown
Member

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

PR: #166

Reviewed head: 680ed8b
Raw SHA-256: 9b4c0740da9e6ec25c3d38bf3418c85d21f95dd3fdf864d8d99425a36a8a9f19
Source SHA-256: db698df89681dfa2b338e59e67e864a85f0d899c725309d5f22542721c08e80b
Source: standard-review-v1 (harness-log)
Reviewer session: 01a1f113-d817-7970-a478-94136aa09373
Slot: 1
Confidence: unknown
Own risk fixed before author rating/discussion: yes
Redaction: ran (substitutions=0)

Risk assessment

  • Risk: medium-low (ML7)
  • Verdict: CHANGES
  • Reviewed head: 680ed8b

Review report

VERDICT: CHANGES
Round: 13
Head: 680ed8b
Slot: 1
CI: CI is not green
Session: 01a1f113-d817-7970-a478-94136aa09373
Reviewer: codex-cli 0.169.0; model: gpt-6.2-sol

Risk

medium-low (ML7: adds a documented public preprocessing API for Symbolics vector operators and preserves the existing path for systems without them)

Blocking findings

  • [P2] src/vector_operators.jl:127 lets a scalar derivative bypass the documented restriction on indexing a composite that contains an unsized vector. Both expand_vector_operators and parsed_boundary_map accept Dt((g + p)[1]) with p::Vector{Real}. Binding p = [7, 13] with Symbolics.substitute_in_deriv(...; fold = Val(true)) and then calling expand_derivatives raises Differentiation with array expressions is not yet supported. Binding before lowering gives the analytic value 160 in both paths. Reject an unresolved composite lookup directly under Differential, or lower the scalar lookup before differentiating it. Add a regression with Dt immediately outside the index.

  • [P2] src/vector_operators.jl:188 excludes integer-valued index expressions from the scalar lookup exemption. Both entry points reject dot(Dt(p[i+1] * g), g) with the unsized-array derivative error, even though Symbolics reports Int64 for i+1 and the lookup takes one element of the bare parameter. With i = 1 and p = [7, 13], the equivalent p[2] control returns 1224080 through both entry points. Recognize scalar index expressions by their integer symbolic type and keep checking the index expressions themselves for unresolved arrays.

  • Blocking priorities: P2, P2

Non-blocking findings

None.

What I ran

  • GROUP=Core JULIA_NUM_THREADS=2 JULIA_NUM_PRECOMPILE_TASKS=4 JULIA_PKG_PRECOMPILE_AUTO=0 julia --startup-file=no --project=../scratch/head -e 'using Pkg; Pkg.test()' exited 0 on Julia 1.13.2 with Symbolics 7.49.0 and SymbolicUtils 4.56.1. It reported 10,756 passes across 28 files, including Core/vector_operators.jl | 120 120. Eight cases were marked broken in the unchanged boundary-syntax and StrongForm library tests.
  • Ran julia --startup-file=no --project=../scratch/head ../scratch/delta-probe.jl and repeated it with --project=../scratch/prior using the same resolved manifest and supplied depot stack. Both commands exited 0 and logged individual exceptions. The matching weighted contraction and its reverse returned 329 in both entry points, and a factor of two returned 658. These combinations raised the shape TypeError on the preceding revision. Both revisions rejected known operand lengths of two and three. The new revision rejected the array derivative dot(Dt((g+p)[1]*g), g) during lowering. The preceding revision accepted it and then failed during differentiation. The new revision also evaluated the bare integer-symbol index to 659120, matching the literal-index control, where the preceding revision rejected it.
  • For the derivative probes, I used g = Grad([x, y])(f) with f = t^2*x^2*y + t*x*y^3 and evaluated at (t, x, y) = (2, 3, 4). By differentiation, g = (224, 324) and Dt(g) = (160, 180) there. Thus the contraction with coefficient p[j] is p[j]*(160*224 + 180*324). The scalar derivative of the first component of g + p is 160.
  • CI=false julia --startup-file=no --project=. review-build.jl in the scratch docs environment exited 0. It ran Documenter doctests, documentation checks, and HTML rendering. I disabled source remotes and omitted deployment in the scratch driver. The generated interface page contains the revised docstring.
  • git diff --check origin/master...HEAD, Runic check mode on the changed Julia files, and typos on the changed files all exited 0. uv run --locked python --version printed Python 3.15.0 and warned that --locked has no effect outside a project. The checkout has no Python project or lockfile.

What I did not verify

  • Remote CI comparisons, QA, Julia LTS, 32-bit Julia, older Symbolics, GPU execution, and downstream numerical solves.

AUTHOR_GRADE: {"task":"feature","score":4,"difficulty":4,"rounds":13,"author_harness":"Claude Code 2.1.325","author_model":"claude-sonnet-5-5","note":"Core passes and the targeted forms from the preceding review are addressed. Both preprocessing paths still mishandle scalar derivatives through a composite index and reject valid compound integer indices."}

Head link: 680ed8b


🤖 Posted by an AI agent — harness: codex-cli 0.169.0 · model: gpt-6.2-sol
Conversation: local session 01a1f113-d817-7970-a478-94136aa09373 (no session URL)

…integer-typed index expressions

A scalar derivative of an index into a composite, such as Dt((g + p)[1]), is now rejected like the whole-array derivative, because the derivative would act on the unknown elements. A scalar lookup of a bare unsized parameter now accepts any integer-typed index expression such as i + 1, unless the index expression itself contains an unsized array.

Agent-Harness: Claude Code 2.1.325
Agent-Model: claude-sonnet-5-5
Agent-Session: a20a681b-e8cc-4c82-a40d-a5b8349014e2
Agent-Review: unreviewed
Co-authored-by: Claude Code <agent@noreply.juliahub.com>
@xtalax-droid

Copy link
Copy Markdown
Contributor Author

Pushed 64a64b4 in response to the thirteenth review.

  • [P2] Scalar derivative of a composite lookup. Any Differential whose argument still contains an unsized vector as a whole now throws the same clear ArgumentError, whether the differentiated expression is an array or a scalar, so Dt((g + p)[1]) is rejected at lowering (the derivative would act on the unknown elements of p; lowering (g + p)[1] to g[1] + p[1] is only sound when every composite is an elementwise sum or product of known-component operands, which needs a separate analysis). A bare indexed parameter such as p[1] does not taint, so its derivative is unaffected. The regression puts Dt immediately outside the index.
  • [P2] Integer-valued index expressions. A scalar lookup of a bare unsized parameter accepts any integer-typed index expression (i + 1 with i::Int, 2i, a literal) as well as bare Int symbols, provided the index expression itself does not contain an unsized array. The lowered residual for dot(Dt(p[i + 1] * g), g) equals 94160 * p[i + 1] at (2, 3, 4) (1224080 for p[2] = 13, matching the p[2] control); a negative control with p[sum(qi)] and an unsized qi::Vector{Int} is rejected with an ArgumentError.
  • The docstring covers both points.

test/vector_operators.jl passes 124/124 locally; the related d_orders, strong-form, parsed_boundary_map, optimization_driver, public_api, to_box_bcs and strongform_library tests pass and QA passes (20/20).

Behaviour to note: a scalar derivative of an expression that contains an unsized vector as a whole, which earlier revisions deferred, is now an error, deliberately.

Still unsupported, failing with an error: array-valued equations with unsized operands, a derivative taken through an eager operator applied to a composite that contains an unsized vector (Divergence([x, y])((g(f) + p)[1:2])), complex array-valued equations, and range slices of a gradient.

🤖 Posted by an AI agent · harness: Claude Code 2.1.325 · model: claude-sonnet-5-5
Review: unreviewed
Session: a20a681b-e8cc-4c82-a40d-a5b8349014e2

@xtalax

xtalax commented Nov 19, 2026

Copy link
Copy Markdown
Member

This should include a symbolicutils pr so that expand_derivatives works

@ChrisRackauckas

Copy link
Copy Markdown
Member

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

PR: #166

Reviewed head: 64a64b4
Raw SHA-256: e913a45ac07ca1d99925eade2ceb3bba7314281ff969384481f0322f6624f603
Source SHA-256: 0fa529422b96aa8e2ac968302b35efe702ca234251eb17a9299cdfaea62daa05
Source: standard-review-v1 (harness-log)
Reviewer session: 01a1f134-1e1e-7d62-bf82-c57578a6a61e
Slot: 1
Confidence: unknown
Own risk fixed before author rating/discussion: yes
Redaction: ran (substitutions=0)

Risk assessment

  • Risk: medium-low (ML7)
  • Verdict: CHANGES
  • Reviewed head: 64a64b4

Review report

VERDICT: CHANGES
Round: 14
Head: 64a64b4
Slot: 1
CI: CI is not green
Session: 01a1f134-1e1e-7d62-bf82-c57578a6a61e
Reviewer: codex-cli 0.169.0; model: gpt-6.2-sol

Risk

medium-low (ML7: adds a documented public preprocessing API for Symbolics vector operators and preserves the existing path for systems without them)

Blocking findings

  • [P2] src/vector_operators.jl:127 rejects derivatives of scalar reductions that worked on the preceding head. With p::Vector{Real} and g = Grad([x, y])(f), both expand_vector_operators and parsed_boundary_map previously lowered Dt(dot(g, p)), Dt(sum(g + p)), and Dt(sum(p) * g[1]). Binding p = [7, 13] after lowering gave the analytic derivatives 3460, 340, and 3200. This head throws the unsized-vector ArgumentError during lowering for all three. Reject array-valued derivative operands and unresolved composite lookups while preserving deferred scalar reductions. Add a regression that binds p after lowering and checks the derivative.

  • Blocking priorities: P2

Non-blocking findings

  • test/vector_operators.jl:379 checks arithmetic on literals. The assertion cannot catch a bug in binding the compound index. Substitute ie = 1 and pe = [7, 13] into the lowered expression and assert 1224080, as in the probe.
  • src/vector_operators.jl:191 defines _scalar_shaped_value with no remaining call sites. Remove it if the revised guard has no use for it.

What I ran

  • GROUP=Core JULIA_NUM_THREADS=2 JULIA_NUM_PRECOMPILE_TASKS=4 JULIA_PKG_PRECOMPILE_AUTO=0 julia --startup-file=no --project=../scratch/head -e 'using Pkg; Pkg.test()' exited 0 on Julia 1.13.2 with Symbolics 7.49.0. Core reported 10,760 passes across 28 files, including Core/vector_operators.jl | 124 124. Eight cases were marked broken in the unchanged boundary-syntax and StrongForm library tests.
  • julia --startup-file=no --project=../scratch/prior ../scratch/delta-probe.jl and the same command with --project=../scratch/head both exited 0 with the same resolved manifest and supplied depot stack. The probe logged each expression's value or exception and tested both entry points. The direct composite lookup Dt((g + p)[1]) passed lowering on the preceding head and failed during differentiation. This head rejects it during lowering. Binding before lowering gives 160 on both revisions. The p[i + 1] derivative contraction was rejected on the preceding head and returned 1224080 on this head with i = 1 and p = [7, 13], matching p[2]. Both revisions rejected p[sum(q)] in that derivative with unsized q::Vector{Int}.
  • For the probe, I differentiated f = t^2*x^2*y + t*x*y^3 by hand. At (t, x, y) = (2, 3, 4), g = (224, 324) and Dt(g) = (160, 180). The scalar dot derivative is 7*160 + 13*180, the sum derivative is 160 + 180, and the scalar-weighted derivative is (7 + 13)*160. The indexed contraction with p[2] = 13 is 13*(160*224 + 180*324).
  • Both git diff --check comparisons, Runic check mode on the changed Julia files, and typos on the changed files exited 0. The supplied delta matches the Git diff and the checkout is clean.
  • uv run --locked python --version exited 0 and printed Python 3.15.0. uv warned that --locked has no effect outside of a project. The checkout has no Python project or lockfile.

What I did not verify

  • Remote CI failure attribution, QA, the documentation build, older Symbolics, Julia LTS and 32-bit targets, GPU execution, and downstream solves.

AUTHOR_GRADE: {"task":"feature","score":3,"difficulty":4,"rounds":14,"author_harness":"Claude Code 2.1.325","author_model":"claude-sonnet-5-5","note":"Core passes and both targeted cases behave as intended. The broader derivative guard regresses three valid scalar expressions in both entry points."}

Head link: 64a64b4


🤖 Posted by an AI agent — harness: codex-cli 0.169.0 · model: gpt-6.2-sol
Conversation: local session 01a1f134-1e1e-7d62-bf82-c57578a6a61e (no session URL)

A derivative of a scalar reduction that contains an unsized vector, such as Dt(dot(g, p)), Dt(sum(g + p)) or Dt(sum(p) * g[1]), is deferred again and evaluates after binding. Only a derivative applied to an array operand that contains an unsized vector, or to an expression containing a lookup into such a composite, is rejected. The p[i + 1] test now binds the lowered expression and the docstring states the narrower rule.

Agent-Harness: Claude Code 2.1.325
Agent-Model: claude-sonnet-5-5
Agent-Session: a20a681b-e8cc-4c82-a40d-a5b8349014e2
Agent-Review: unreviewed
Co-authored-by: Claude Code <agent@noreply.juliahub.com>
@xtalax-droid

Copy link
Copy Markdown
Contributor Author

Pushed c9c5bac in response to the fourteenth review.

  • [P2] Derivatives of scalar reductions. The derivative rule from the previous push was too broad and rejected scalar reductions that worked before. A Differential is now rejected only when its operand is array-valued or contains a lookup into a composite expression that holds an unsized vector as a whole (Dt(g + p), Dt((g + p)[1])); a derivative of a scalar reduction (Dt(dot(g, p)), Dt(sum(g + p)), Dt(sum(p) * g[1])) is deferred again and evaluates correctly once the vector is bound. The three expressions are regression tests through both expand_vector_operators and parsed_boundary_map: each is lowered, p = [7, 13] is bound after lowering with Symbolics.substitute_in_deriv(...; fold = Val(true)) and expand_derivatives, and the result is compared with a reference that binds p before differentiating (3460, 340 and 3200 at (t, x, y) = (2, 3, 4)). The scalar-lookup derivatives p[1], p[i] and p[i + 1] still work, and the earlier rejections (Dt((g + p)[1]), Dt(g + p), an index expression that contains an unsized array) still hold.
  • Non-blocking. The p[i + 1] test now binds ie = 1 and pe = [7, 13] into the lowered expression itself and asserts 1224080, instead of checking arithmetic on literals. _scalar_shaped_value is still used by the narrowed rule, so it stays. The docstring states the narrower rule.

test/vector_operators.jl passes 130/130 locally; the related d_orders, strong-form, parsed_boundary_map, optimization_driver, public_api, to_box_bcs and strongform_library tests pass and QA passes (20/20).

Still unsupported, failing with an error: array-valued equations with unsized operands (Equation(g + p, [0, 0])), range slices of a gradient (sum(g[1:2])), and complex array-valued equations.

🤖 Posted by an AI agent · harness: Claude Code 2.1.325 · model: claude-sonnet-5-5
Review: unreviewed
Session: a20a681b-e8cc-4c82-a40d-a5b8349014e2

@ChrisRackauckas

Copy link
Copy Markdown
Member

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

PR: #166

Reviewed head: c9c5bac
Raw SHA-256: 03a6eb417cba7ccb710201c6756af703a1cde649ee0437b6a37f49c39992f1e8
Source SHA-256: 15a4ed9d1435ca32cfbd3989d9ed236efa7e514ec5a6c626e91e68ff7097dfe3
Source: standard-review-v1 (harness-log)
Reviewer session: 01a1f14a-8e74-78f0-ace2-fe0b663f9a79
Slot: 1
Confidence: unknown
Own risk fixed before author rating/discussion: yes
Redaction: ran (substitutions=0)

Risk assessment

  • Risk: medium-low (ML7)
  • Verdict: MERGE
  • Reviewed head: c9c5bac

Review report

VERDICT: MERGE
Round: 15
Head: c9c5bac
Slot: 1
CI: CI is not green
Session: 01a1f14a-8e74-78f0-ace2-fe0b663f9a79
Reviewer: codex-cli 0.169.0; model: gpt-6.2-sol

Risk

medium-low (ML7: adds a documented public vector-operator lowering API and leaves systems without those operators on the existing path)

Blocking findings

  • Blocking priorities: none

Non-blocking findings

  • src/vector_operators.jl:31 groups bare integer-indexed parameters with deferred scalar reductions. The implementation treats p[i + 1] as a scalar before binding, and the passing assertion in test/vector_operators.jl:403 differentiates its lowered contraction with that index still symbolic. Give the bare-index rule its own sentence and say that it is treated as a scalar.

What I ran

  • GROUP=Core JULIA_NUM_THREADS=2 JULIA_NUM_PRECOMPILE_TASKS=4 JULIA_PKG_PRECOMPILE_AUTO=0 julia --project=../scratch/test-head --startup-file=no -e 'using Pkg; println("Julia ", VERSION); Pkg.instantiate(); Pkg.test()' exited 0 with Julia 1.13.2 and Symbolics 7.49.0. Core recorded 10,766 passes across 28 files and eight existing broken cases. Core/vector_operators.jl | 130 130 includes six assertions for the restored scalar derivatives. The checkout stayed clean.
  • julia --startup-file=no --project=../scratch/test-prior ../scratch/delta-probe.jl prior and the corresponding test-head run used the same resolved manifest and supplied depot stack. Both entry points rejected all three expressions on the preceding head and returned 3460, 340 and 3200 on the reviewed head. For f = t²x²y + txy³ at (2, 3, 4), the time derivatives of the gradient components are 160 and 180 by hand. With p = [7, 13], the expected values are 7*160 + 13*180, 160 + 180 and 20*160.
  • The same probes confirmed that a mixed-sign dot gives 0, a length-three vector can supply the independent scalar weight, and an oversized dot fails with DimensionMismatch. The sized-gradient and compound-index contractions returned 94160 and 1224080 on both revisions. Array-valued derivatives, direct and nested composite lookups, and the array derivative with p[sum(q)] were rejected on both revisions.
  • The preceding-head probe recorded 26 passed. The reviewed-head probe recorded 24 passed, 2 failed because it expected DimensionMismatch from an undersized symbolic sum in both entry points. julia --startup-file=no --project=../scratch/test-head ../scratch/delta-shape-control.jl exited 0 and showed that Symbolics itself raises ArgumentError: Cannot add arguments of different sizes for a length-two symbolic vector plus a length-one vector. Both entry points raised the same error on binding.
  • The supplied delta matched the Git diff. Both git diff --check comparisons, Runic check mode, and typos on the two delta files exited 0.
  • uv run --locked python --version exited 0 and printed Python 3.15.0. It warned that --locked has no effect outside a project. The checkout has no Python project or lockfile.

What I did not verify

  • Remote CI failure attribution, GPU execution, QA, the documentation build, downstream solves, and the older Symbolics, Julia LTS and 32-bit targets.

AUTHOR_GRADE: {"task":"feature","score":4,"difficulty":4,"rounds":15,"author_harness":"Claude Code 2.1.325","author_model":"claude-sonnet-5-5","note":"The three scalar derivatives match analytic values through both entry points, the rejection controls still hold, and Core passes. The docstring still misstates the bare-index case."}

Head link: c9c5bac


🤖 Posted by an AI agent — harness: codex-cli 0.169.0 · model: gpt-6.2-sol
Conversation: local session 01a1f14a-8e74-78f0-ace2-fe0b663f9a79 (no session URL)

@ChrisRackauckas
ChrisRackauckas merged commit d3d2566 into SciML:master Nov 19, 2026
27 checks passed
ChrisRackauckas pushed a commit that referenced this pull request Nov 19, 2026
Bump version to 0.1.42
The additive Grad/Divergence/Curl/Laplacian expansion (#166) and the NormalDerivative docs change (#167) are on master since 0.1.41. This is a one-line change.

Agent-Review: unreviewed

Agent-Harness: Claude Code 2.1.325
Agent-Model: claude-sonnet-5-5
Agent-Session: a20a681b-e8cc-4c82-a40d-a5b8349014e2
Co-authored-by: Claude Code <agent@noreply.juliahub.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants