We've built something similar, but in Rust.

https://github.com/railyard-dev/railguard