I think we're seeing lots of progress for relating verification and specs with actual code: there are a number of good projects for Rust + Lean
I think this problem is functionally a subset of same the issue that FP has with modelling stuff at it's boundaries like IO
The work around algebraic effects and handlers is some of the more relevant prior art here