Question
When can a previous validation result be reused after an implementation change?
Short answer
A previous validation result can be reused after an implementation change only when nothing the result depended on has changed, directly or through intermediate parts, in a way that could make the result false. Those dependencies include the code and data the check used, the tools and settings that built and ran that code, and every number the check assumed, such as a time bound. Results that the change can reach are redone; every other result is kept with a written reason. Nearness in the source tree decides nothing.
Terms in the question
Validation result: a recorded conclusion that a part of a system has a stated property, together with the evidence for it. A passed test suite, a proof, a timing analysis and a set of measurements are validation results.
Implementation change: an edit to how a part is built or how it works, such as its source code, its build settings, the tools that compile it or the data it reads, whether or not the edit was meant to change what the part does.
Reuse: accepting the earlier result as evidence about the changed system without doing the work again. Repeating only the checks that a change could affect, and reusing the rest, is called incremental validation §10.42.
Dependency: a result depends on an item when a change to the item could change the result, or could make false something the result assumed. A transitive dependency §10.43 runs through intermediate parts: a timing analysis of a task depends on every function the task calls, and on every function those functions call.
Contract: everything a part promises to the parts that use it: the output for each input, the errors it reports, its effects on shared data, and its bounds on time and memory.
Full answer
A validation result is a conditional statement. It says that a property held for this code, built with these tools and settings, run in this environment, on these inputs, with these numbers assumed rather than measured. The result remains true for the changed system exactly when every one of those conditions still holds, or has changed in a way shown not to alter the conclusion. The size of the edit is therefore not the question. The question is whether the edit reaches any condition of the result. Five steps answer it.
Describe the change by its effect on contracts. For each changed part, list what a user of the part could observe differently: outputs, errors, effects on shared data, execution time §9.32, memory use, data formats and generated files. The lines edited are a poor guide. A one-line edit can raise a time bound, and a large reorganization of the code can leave every contract as it was.
Write down the dependencies of each result. For every existing result, list the code it ran, the data it read, the tools and settings that produced the code it checked, the environment it ran in, and each number it assumed instead of measuring.
Find every result the change can reach. Start from the changed items. Add every item that uses one of them, then every item that uses one of those, and repeat until no new item appears. The final set is the transitive closure of the change: the set that the adding rule no longer enlarges.
Redo or justify each result inside that set. An affected result is either repeated or kept with an argument that covers exactly how the result uses the changed item. A functional result is usually redone by rerunning its regression tests §10.4, the tests kept to detect behavior that a change has broken. An argument can replace the rerun: a result that assumed a time of at most 2 ms stays valid if the new time is at most 1 ms, because the assumption is an upper bound and still holds.
Keep every result outside the set, with its reason. Record for each kept result which dependencies were examined and why they are unchanged, so that a reviewer can check the decision.
The boundary between redone and kept results is sound when no kept result depends, directly or transitively, on a changed item. A boundary that is too wide wastes work but stays safe. A boundary that is too narrow accepts evidence about a system that no longer exists. Repeating every check is always sound; only a dependency argument justifies doing less.
Some dependencies are easy to miss.
Contract items other than outputs. A change that keeps every output can still change execution time or memory use, and with it every analysis that assumed the old bound.
Shared code. A change to a common parser, encoder or memory allocator reaches every part that uses it.
Lifetime and layout. Changing when an object is freed, or where it lies in memory, can break code that never calls the edited function.
Generated inputs. Code or tables produced by a generator change when the generator or its input changes, even if no hand-written file did.
Build and environment. A new compiler version, compiler option §12.3 or library produces a different program from the one that was tested.
The converse matters as much. Sharing a directory or a naming pattern with the changed part is not a dependency. A dataset measured on a component that never uses the changed part, directly or through other parts, stays valid even when it is stored next to the changed file.
When the dependencies are not known, the boundary cannot be shown sound, and the check must be repeated. Build tools such as Bazel skip a test whose declared inputs have not changed and reuse its cached result. That shortcut is correct only for a hermetic build §13.7, one in which every input is declared and nothing undeclared is read.
Worked example
A device runs two tasks on one processor under fixed-priority preemptive scheduling §6.37: whenever a task of higher priority becomes ready, it interrupts a task of lower priority. Task , of high priority, is released (made ready to run) every ms and runs for at most ms. Task , of low priority, is released every 20 ms and must finish within 12 ms of its release. Its own code takes at most 4 ms, and it calls a checksum §4.32 helper once. The validation record holds four results:
(a) the unit tests §10.1 of , which check its outputs;
(b) a response-time analysis showing that finishes within 12 ms;
(c) the same analysis for ;
(d) a dataset of radio measurements taken with a component that never calls the helper.
The helper is changed to compute the same checksum without a 1,024-byte lookup table. The change saves memory, but the worst-case execution time §9.33 of the helper, the longest time it can take, rises from 2 ms to 5 ms.
Result (a) is kept. Both versions compute the same mathematical function, which a review of the code established and differential testing §10.6 supports; differential testing runs both versions on the same inputs and compares the outputs. The unit tests of use the helper only through its outputs and errors, and neither changed. The record states this reason.
Result (b) assumed that the helper takes at most 2 ms, so the change reaches it. Response-time analysis computes the worst-case response time of , the longest time from its release to its finish, as the smallest solution of where is the execution time of including the helper, and means rounded up to a whole number. The term counts the releases of that can fall within a window of length . The solution is found by starting with and recomputing until the value stops changing.
Before the change, ms. Then , and . The value stops at ms, within the 12 ms deadline.
After the change, ms. Then , next , and . The value stops at ms, which exceeds the deadline by ms.
The old result is now false. The bound of the helper rose by ms, yet the response time rose by ms, because the longer run of leaves room for one more run of . A change can move a dependent result by more than its own size.
Result (c) is kept. Nothing has higher priority than , so its response time is its own execution time, 2 ms, and the helper does not appear in it. That reason holds only if never waits for something that holds. If the two tasks shared a lock and held it while running the helper, could wait for as long as holds the lock, which now includes up to 5 ms of helper time, and result (c) would depend on the helper too. Result (d) is kept: the measured component does not call the helper, directly or through other functions, although its data sit in the same directory as the source file of the helper.
Follow-up questions and limits
Is it enough to rerun the tests of the files that changed? No. A result about an unchanged file can depend on the changed one, as result (b) shows. Dependency follows use, not location.
Does a change that only lowers a number keep every result? Only when the result uses that number as an upper bound. The analysis above assumed only that the helper takes at most 2 ms, so a helper that takes at most 1 ms keeps result (b) as it is. Some systems do not behave that way. Ronald Graham showed in 1969 that when tasks are scheduled on several processors, shortening tasks can delay the moment at which all tasks have finished [485]. Such cases are called scheduling anomalies, and an analysis of such a system must be redone even after a speed-up.
What if the dependencies cannot be determined? Then reuse is not justified. Repeat the check, or first make the dependencies explicit, for example by making the build hermetic.
Is reuse worth arguing for every result? No. Reuse saves effort, and the effort matters for expensive results such as long measurement campaigns, timing analyses or proofs. Rerunning a fast suite of unit tests is simpler and safer than arguing that it need not run.
This answer does not cover how to extract dependencies from code automatically, or how many repeated measurements a redone timing result needs.
Fullest treatment: Incremental validation (§10.42).
Related entries: Transitive dependency (§10.43), Regression test (§10.4), Source closure (§13.6), Evidence eligibility (§13.14), Fixed-priority response-time analysis (§19.4.7), Hermetic build (§13.7), Differential testing (§10.6). Further reading: [89, 485].