Most engines already have knock sensors. They're used to adjust fuel/air ratio and spark timing to just above/after where the engine starts to knock. A few engines adjust valve timing while running, which is also complex mechanically, but not as difficult as adjusting compression. Now there's another variable to tweak.
It may take a machine learning system to tune such an engine. All those interdependent variables to adjust make that a hard problem. Different values required based on engine speed, load, temperature, fuel consumption, and emissions outputs. All this is usually expressed as precomputed tables which are interpolated within the engine controller. Those tables have to be developed somehow.
- Will the ignition need to be cut off before the ratio change happens ?
- Will this apply the change to all the cylinders at the same time ?