Status of node-graph: while adding tests for multiplication, I found a bug that appears to exist in every previous iteration of the code. Oops.
Basically, multiplying certain arrangements of terms results in dropping a minus sign from the result. Sort of disturbing that this code sort of worked, given that kind of issue. I'm also looking at the constructors, and I'm not seeing some code in here that I remember thinking I wanted, so I think there are more bugs lurking in here. However, when I try to trigger this bug, I can't get it to happen. On further inspection, this actually is handled, it's just that this code is so bonkers that I forgot how I did it. This logic should probably be moved out of where it is, and to a more common codepath. ... Except that trying to do that proved incredibly confusing. I opted to add a precondition to one of the utility functions instead.
Anyway, the next bit of functionality to address would be partial derivatives, but writing tests for this code has made me realize that the ergonomics for it are... bad. I'm implementing the basic math things visible at the top level as methods on or taking an "Environment" object. The purpose of the environment object is to act as a limited-lifetime cache of node objects, in order to keep graphs from containing duplicate nodes. I believe some form of this idea is necessary, but that other implementations are possible.
Going through the constraints I want to put on this: Nodes need a reference to their cache; Therefore cache keys must be weak references; Therefore I need some kind of weak-referenceable wrapper type.
I think I've got the beginnings of this worked out... Okay, I've switched the caches around to using weak references, and put a reference to the top-level cache into every node. From there, I can cut down on Environment params, and I should eventually be able to turn the basic arithmetic operations into dunder-methods. Get all that working, and a lot of visual noise falls away.
I'll have to try putting this into practice later. Good night.