Learning from Failures: a Lightweight Approach to Run-Time Behavioural Adaptation