Michael Feathers' definition is blunt: legacy code is code without tests, and without tests you cannot tell whether a change improved the system or broke it Working Effectively with Legacy Code. That single sentence explains why agent guardrails matter more on brownfield code than on a greenfield project. On new code, a wrong change usually fails a test you just wrote. On a system that has run untouched for a decade, a wrong change may look correct, pass the thin test suite and surface as a settlement mismatch three weeks later.
Feathers' change algorithm is still the right spine for any agent task: identify the change points, find test points where behavior can be sensed, break dependencies carefully, cover the target code with characterization tests, then add functionality and refactor only inside the covered area. The BSSw summary is explicit that refactoring must not extend outside code that is sufficiently covered by tests Better Scientific Software. For an agent, that translates into a hard rule you can encode: the allowed diff scope equals the files the agent actually covered with tests in the same pull request.
The practical consequence is a decision rule you can apply in a minute. If the agent cannot get the target code into a test harness in the current task, its scope is read-only for that task. It may read, trace and explain, but it may not propose a patch. Everything else follows from that.



