Listening to Alex's answers on spec2 on the Clojure Stream on modeling relationships between functions' inputs and outputs, have you considered using a relational language? E.g. datalog?
First I heard of it, do you have a link @ben.sless?
https://podcasts.apple.com/us/podcast/e86-2022-in-review-datomic-and-clojure-with-jaret/id1461500416?i=1000590958632