From c6054951995447ac3363125c8d42c147c51a999e Mon Sep 17 00:00:00 2001 From: lmoresi Date: Thu, 8 Oct 2026 08:35:17 +1100 Subject: [PATCH] The sympy.diff census guards the flux laws too test_no_solver_differentiates_with_plain_sympy_diff (#830) scans petsc_generic_snes_solvers.pyx and systems/*.py. It does not scan constitutive_models.py, which is where its own stated risk is authored: the docstring says a plain sympy.diff site "would pass every other test here until a law put an Abs or a sign of a field in its flux", and a law is written in constitutive_models.py, not in the solvers. Nothing is wrong today -- that file has no sympy.diff( or sympy.derive_by_array( call, only three comments that mention the name without a paren, which the census already discriminates correctly. The gap is that tomorrow's law is unguarded. Shown to fail: appending a commented-out `sympy.diff(_probe, _probe)` call to constitutive_models.py turns the test red, and it is green again once removed. Underworld development team with AI support from Claude Code --- tests/test_0023_field_realness_and_derivatives.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/tests/test_0023_field_realness_and_derivatives.py b/tests/test_0023_field_realness_and_derivatives.py index 7626f20ee..3a1401816 100644 --- a/tests/test_0023_field_realness_and_derivatives.py +++ b/tests/test_0023_field_realness_and_derivatives.py @@ -164,6 +164,10 @@ def test_no_solver_differentiates_with_plain_sympy_diff(): every other test here until a law put an Abs or a sign of a field in its flux.""" src = pathlib.Path(__file__).parents[1] / "src" / "underworld3" sources = [src / "cython" / "petsc_generic_snes_solvers.pyx", + # The flux laws, which is where this test's own stated risk gets + # written: a law that puts an Abs or a sign of a field in its + # flux is authored here, not in the solvers. + src / "constitutive_models.py", *sorted((src / "systems").glob("*.py"))] for path in sources: text = path.read_text()