Your question is Refactoring for Stability. Take a moment with it on the right.
Talk me through your thinking if you like. When you're confident, submit your answer and I'll grade it like a real screen (7/10 or better passes).
Describe a time when you had to refactor a legacy codebase. What was your strategy for ensuring system stability? Explain how you assessed the risks, selected the refactoring sequence, and validated that existing behavior was preserved. Include how you communicated trade-offs, handled unexpected issues, and measured the outcome.