Skip to content

Refactor ODE analyses through ODESemantics in catlog, catlog-wasm, and frontend - #1364

Draft
tim-at-topos wants to merge 7 commits into
mainfrom
tim/refactor-wasm-analyses
Draft

Refactor ODE analyses through ODESemantics in catlog, catlog-wasm, and frontend#1364
tim-at-topos wants to merge 7 commits into
mainfrom
tim/refactor-wasm-analyses

Conversation

@tim-at-topos

@tim-at-topos tim-at-topos commented Aug 1, 2026

Copy link
Copy Markdown
Contributor

For some arcane GitHub reason, #1251 was automatically closed and I cannot reopen it. Then #1363 was a clone with #1319 merged in, but the automatic rebase that GitHub did with its new stacked PR feature messed everything up and broke all the tests. This is a third-time-lucky PR. I'll repeat most of the original PR descriptions below for the sake of the reader.

✨ Brand new features in this mega-merged PR, not previously appearing in any other PR ✨

  • Migration from v0 to v1 ODE analyses, to hopefully not break any old documents
  • So much more documentation and helpful comments
  • Tests for things both old and new

PR 1: ODE semantics via contributions

This PR includes a massive redesign of the way that we handle ODE semantics, which has the bonus of introducing some new capabilities (#1177) as well as (hopefully) making adding new ODE semantics in the future considerably simpler.

p.s. I know this PR adds quite a lot of code for something called a "refactor", but (a) I added a lot of documentation and some new tests, and (b) subsequent PRs focussing on the front-end parts should now be possible, allowing for much more code removal.


PR 2: LaTeX things and front-end refactors

Now that more ODE analyses have LaTeX equations, we should be stricter about the use of fmt::Display only for debugging.

This PR introduces some new types and traits (Latex, ToLatex, ToLatexWithMap) for dealing with LaTeX expressions and rendering object/morphism names nicely in the frontend. It also includes a bunch of tests for ODE semantics in the wasm layer. Finally, as a bonus, it removes a lot of repetitive code from catlog-wasm::src::analyses by defining ode_semantics_simulation and ode_semantics_equations, enabled by #1251, as well as removing some unnecessary types introduced there (such as LotkaVolterraEquationsData, which is just null).

Again, this refactor adds a lot of lines, but that's almost entirely due to how many nice new tests it adds 👼

As a bonus, this PR fixes the following issues:


Although further refactoring is possible (e.g. lotka_volterra.tsx and linear_ode.tsx share a lot of code, and maybe we should do mass-action for stock-flow diagrams by simply migrating them to Petri nets), I think that the "correct" solution to this would be to start looking at generating that code from the definitions of the analyses rather than manually refactoring it. But this is now a much larger, rather separate project, so I think it's a bit out of scope.

With that in mind, I would suggest that this PR finally completes the last item in #1177 , and thus closes the RFC-0001 parent issue #1098.

Comment thread packages/catlog/src/stdlib/analyses/ode/ode_semantics.rs Outdated
@tim-at-topos
tim-at-topos force-pushed the tim/refactor-wasm-analyses branch from ce33979 to 7e98d1e Compare August 19, 2026 13:43
@tim-at-topos
tim-at-topos marked this pull request as draft August 19, 2026 15:33
@tim-at-topos
tim-at-topos force-pushed the tim/refactor-wasm-analyses branch 18 times, most recently from d33d598 to 19c604d Compare August 25, 2026 18:54
@tim-at-topos
tim-at-topos force-pushed the tim/refactor-wasm-analyses branch 5 times, most recently from b3c7272 to b38972e Compare August 25, 2026 19:27
@tim-at-topos

tim-at-topos commented Aug 25, 2026

Copy link
Copy Markdown
Contributor Author

@epatters Apart from actually implementing the migrations (catlog::src::stdlib::analyses::ode::v1::migrate) into (I assume, but suggestions and advice also welcome) frontend/src/analysis/document.ts :: migrateAnalysis, this is ready for review. Let me know if you would like anything from me that would make this easier to read!

I haven't actually marked it as ready for review because it's failing one check for solid(reactivity) but I'm going to chat with Kaspar about this, because the warning suggests that something that does indeed work when I test it should not be working, so it might be a case of an over-eager linter. But the point is that any changes needed to fix any problems should all be far away from the main content of this PR.

@tim-at-topos
tim-at-topos force-pushed the tim/refactor-wasm-analyses branch from b38972e to b9d81ce Compare August 25, 2026 19:30
WIP: Rethinking traits

WIP: Some tests only half failing

WIP: Tests passing; time to tidy

ENH: Build derived model of th_signed_polynomial_ode_system in mass_action

ENH: Mass-action for stock-flow; DEL: Mass-action for signed stock-flow

ENH: struct for transition / flow interfaces

WIP: Starting on Lotka-Volterra

WIP: Failing tests

FIX: Lotka-Volterra tests passing

FIX: Working analysis (frontend)

ENH: Lotka-Volterra equations

ENH: Linear ODE refactor

ENH: Linear ODE equations

WIP: Starting on ODESemantics

WIP: lotka_volterra_semantics()

WIP: build_system_from_ode_semantics

WIP: DblModelForODESemantics

WIP: ODESemanticsAnalysis and ODESemanticsProblemData

WIP: ODESemantics trait

WIP: Documentation

WIP: ODESemantics for mass-action

WIP: Cleaning up types, but mass-action still frustrating

WIP: Big reshuffle (moving functions out from a struct)

WIP: Fixing mass-action again

WIP: terrible code

WIP: Changed from ObGen to Ob

WIP: Stock-flow mass-action

FIX: Passing catlog tests

Rename LinearODE -> LCC

FIX: Documentation

TODO: Redesign

WIP: Removing the pretend declarative migration; starting again

WIP: Starting to meet in the middle [skip-ci]

WIP: tests running (but failing, of course)

WIP: Fixed Lotka-Volterra and LCC

WIP: More documentation [skip-ci]

WIP: mass-action for Petri nets [skip-ci]

WIP: Fix all tests! [no-ci]

ENH: Documentation

WIP: LaTeX traits

ENH: Documentation

WIP: Failing tests (but in a good way, I promise)

WIP: Passing catlog tests; failing catlog-wasm tests (expected behaviour)

WIP: Thoughts [skip-ci]

WIP: ToLatexWithMap (all tests passing!)

ENH: Combined latex_ob_names and latex_mor_names

Documentation

WIP: More latex frontend tests

WIP: Refactor catlog-wasm/src/analyses

WIP: More tests for frontend ODE analyses Latex

WIP: Failing tests (but, again, that's good and intended I promise)

WIP: Simplify some of the repetition while we're here

WIP: Deleting lots of (now) redundant code

FIX: Move front-end ODE equation tests to analyses.rs

ENH: Documentation

WIP: Tests revealing error in latex_names() for objects that are lists

FIX: Passing all Latex tests

WIP: Fix frontend

FIX: Fix (??) frontend

WIP: Here's the problem

FIX: Working reusable mass-action config form

ENH: Add (failing) test for polynomial ODE; simplify some types

WIP: Namespace problems

FIX: Passing all Rust tests

merge main

FIX: Single ode_semantics_equations.tsx; fix reactivity in mass_action_config_form.tsx

FIX: Errant bad rebase line

FIX: Dynamically load ODESemanticsEquationsDisplay

one question answered

TODO

WIP: What a mess
@tim-at-topos
tim-at-topos force-pushed the tim/refactor-wasm-analyses branch from b9d81ce to b59c62c Compare August 25, 2026 19:32
@tim-at-topos
tim-at-topos force-pushed the tim/refactor-wasm-analyses branch from b59c62c to af83c7e Compare August 25, 2026 19:32
@tim-at-topos
tim-at-topos force-pushed the tim/refactor-wasm-analyses branch from 5a25141 to 99124b3 Compare August 25, 2026 19:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

2 participants