Look-ahead prevention as a unit test, not a promise

"We were careful" is not a control. Perturb the future and assert the present does not move — a direct, mechanical check for look-ahead that keeps working as the codebase changes.

A promise you can’t audit

Every backtest claims it doesn’t peek at the future. The claim is usually unfalsifiable — buried in indexing, shifts, and joins that are easy to get subtly wrong and hard to inspect after the fact. “We were careful” is not a control; it is a hope.

Make it fail loudly

Turn the promise into a test. Take the input series and artificially double every future return — every bar after the decision point. Recompute the signals. If the strategy uses no future information, the signals must come out bit-for-bit identical to before: the future changed and the present did not notice. If a single signal moves, something downstream is reading forward, and the test fails.

Why it works

A look-ahead leak — a “future function,” in the trading-platform sense of an indicator that quietly repaints on data it shouldn’t have — is precisely a dependence of present output on future input. Perturbing the future and asserting invariance of the present is the direct, mechanical check for that dependence. No code review required, and it keeps catching regressions as the codebase changes.

In practice

Wire it as a standard unit test in CI, next to the shift/lag logic it guards. Pair it with an explicit, separate shift(1) step so the lag lives in one visible place rather than smeared across the pipeline. The principle is the one that runs through the rest of this work: a control you can run beats a control you merely assert.