A flight reaches its gate at 16:40. An external data feed publishes an initial arrival record at 17:05. A system processes that record at 17:07. Then, at 17:40, a correction arrives.
The following morning, a historical export contains one clean final record.
If we build a test from that final record, it might pass perfectly. But at 17:07, our software did not have the information that would arrive at 17:40.
That is an easy way to write a test that passes for the wrong reason.
This is a hypothetical timeline, but the underlying problem is very real for products like LayoverGuard. We are building software that makes automated decisions based on flight operations. We can control our application, our test data, and our clocks. We cannot control when an aircraft reaches its gate, when another system reports that fact, or whether the report is later corrected.
Engineers building logistics, IoT, trading, and other event-driven systems face similar problems. The world does not wait for a test runner, and it does not promise to deliver events in a convenient order.
So how do we test a system whose most important inputs happen outside our control?
A snapshot is not a timeline
A unit test built around a completed flight record is useful. Give a function a scheduled time, an observed time, and a few other inputs, then verify the result. We can test boundary values and invalid combinations without waiting for a real flight.
But production rarely hands us one complete, final record at the moment an event occurs.
We may see an estimate, then a partial update, then a long silence. A later response may change a value we previously received. Two sources may publish different information about the same event. Some updates may never arrive.
A single response can be valid while the sequence of responses exposes a defect. For example, a handler might work correctly with either version of a record in isolation but mishandle the correction when it follows the first version.
That is why testing inputs and testing timelines are different jobs. The first asks whether a piece of logic handles a value. The second asks whether the system behaves correctly as the information available to it changes.
I wrote previously about the difficulty of defining what a flight delay actually means in A Flight Delay Is Not a Boolean. Even after the definition is precise, we still have to test what happens while the evidence is arriving.
One event, several clocks
The opening example has at least three important times.
Event time is when the aircraft actually reached its gate: 16:40.
Availability time is when the initial record became accessible through an external feed: 17:05.
Processing time is when our hypothetical system consumed the record: 17:07.
There may also be a separate decision time if evaluation happens later, as well as timestamps for corrections and subsequent observations.
These clocks answer different questions. Event time tells us something about the physical world. Availability time tells us what an external system could have supplied. Processing and decision times tell us what our software could actually have acted on.
If the arrival record is corrected at 17:40, the correction does not move the aircraft through time. It changes our knowledge of an event that has already occurred.
In a test, it is surprisingly easy to collapse all of these into one timestamp because the final dataset only exposes the event's eventual value. But code running at 17:07 cannot read information that will first become available at 17:40.
That limitation should be part of the test, not something we discover only in production.
A backtest can accidentally know the future
Historical data is extremely useful. It lets us examine large numbers of real events, including patterns that would be hard to invent by hand. Historical simulation has been an important part of our work on LayoverGuard.
But there is a distinction between evaluating a rule against final outcomes and replaying the information flow that a live system would have experienced.
Suppose we take the corrected arrival record from the next morning and run the decision logic against it. That can answer a perfectly legitimate question: what result does this rule produce for the event as we now understand it?
It does not, by itself, answer: what result could the running system have produced at 17:07?
If a test gives the system the corrected record at the earlier time, it introduces look-ahead bias. The test may produce the right final answer using information that was not yet available.
This is not a reason to stop backtesting. A study of historical event frequencies may reasonably use finalized records. The problem is treating that study as proof that the live decision process will behave correctly when data is delayed, revised, or incomplete.
A chronological replay can get closer to that second question, but only if the underlying data preserves enough history. A final-state export often does not tell us when an intermediate value appeared, how long it remained available, or whether it was ever visible to a particular consumer.
When that evidence is missing, we can model possible update sequences and test the software against them. We should not present the modeled sequence as a faithful reconstruction of production history.
Move the clock, not the calendar
Even with the right events, a practical testing problem remains: real processes take time.
A test involving a schedule change several days before departure and a later operational correction cannot take several days to complete. It also should not depend on the current date or the speed of a CI worker.
One useful technique is to make application time an explicit dependency. Instead of calling the system clock from every part of the code, time-dependent logic can read an injected clock that a test controls.
A simplified test might look like this:
clock.advanceTo("17:05")
deliver(initial_update)
clock.advanceTo("17:07")
process_pending_work()
clock.advanceTo("17:40")
deliver(corrected_update)
process_pending_work()
verify_expected_history()
This is illustrative pseudocode, not LayoverGuard's implementation.
The test can now exercise the same sequence repeatedly, or move the correction to a different point and observe what changes. It can complete in seconds without pretending that the aircraft itself was under our control.
An injected clock is not a magic solution. Database timestamps, scheduled jobs, queues, external services, and timeouts may all use different clocks. A fully realistic replay needs to be deliberate about which time sources it controls and which parts of the system remain asynchronous.
Still, a controllable clock creates something valuable: a repeatable experiment. We cannot make the real world perform an event twice, but we can make our software consume the same sequence twice.
Deliberately make the sequence worse
A clean chronological replay is a good starting point. The more revealing tests are often the ones where we break it.
Start with an event sequence that behaves as expected. Then deliver an update twice. Delay another. Drop one entirely. Send a correction after an earlier version has already been processed. Restart a worker between receiving a message and saving the result.
The important question is not whether every variation produces exactly the same output. Sometimes changing when information becomes available should change what the system knows at a particular moment. A late correction is not equivalent to an early correction.
Instead, we can define properties that must hold despite certain variations. Duplicate delivery should not create duplicate effects where only one is intended. A process restart should not silently erase a required record of what was received. A correction should remain distinguishable from a new, unrelated event.
These are examples of testing properties, not a disclosure of LayoverGuard's decision rules.
This way of testing is more useful than generating random disorder and hoping nothing breaks. Each mutation represents a failure mode we might reasonably encounter, and each assertion says exactly which behavior we expect to remain reliable.
The goal is not to make messy input look neat. It is to find out which kinds of mess the software can handle.
The missing records may be the important ones
A dataset can contain millions of genuine flight events and still be a poor test of what happens when operations are under stress.
Consider a widespread disruption. Flights are delayed, but the systems reporting them may also be slower or less complete. Some updates arrive late; others may never appear in the data available to a consumer at the time. A finalized historical export might eventually contain accurate outcomes without showing those reporting gaps.
If a test pipeline excludes records with missing timestamps, it may discard exactly the cases where the software had the least information. The test can look representative by flight count while missing the conditions we most need to understand.
That is a different limitation from accidentally giving a backtest knowledge of the future. Here the question is which situations are represented at all, and whether missing information is related to the disruptions we are trying to handle.
We can examine reporting gaps, especially during difficult periods, and complement historical records with constructed failure scenarios: delayed feeds, absent updates, conflicting observations, and interrupted processing.
Historical data gives us breadth across recorded outcomes. Deliberately difficult scenarios help us test the conditions under which those outcomes may have been hard to observe.
Can we reproduce the decision tomorrow?
There is one question I like as a test of the testing strategy itself: if a result looks wrong tomorrow, can we reconstruct why the system reached it today?
Running the newest code against the newest version of a record might produce a sensible result. It does not necessarily reproduce the original execution.
To investigate that execution, we may need to know which input versions were available, when they were received, which software or configuration version was active, and what decision was recorded at the time.
There is a balance to strike. Keeping every response forever would create storage, privacy, and operational costs. The goal is not indiscriminate logging. It is preserving enough evidence to explain an automated outcome without depending entirely on what an external source says now.
If we can reconstruct the relevant inputs and execution conditions, an unexpected decision becomes something we can investigate with a repeatable test rather than an argument about what probably happened.
That is a more demanding definition of observability than simply knowing that a request returned successfully.
Different tests answer different questions
None of these techniques proves that a system will behave perfectly in the real world.
Unit tests tell us whether individual rules handle known inputs. Controlled timelines help us examine behavior as information arrives. Historical backtests help us evaluate patterns in recorded outcomes. Failure injection tests what happens when dependencies or processing steps misbehave. Eventually, observation against live events supplies evidence that a controlled test environment cannot.
Those forms of evidence overlap, but they are not interchangeable.
A backtest that matches historical outcomes does not prove a consumer will receive timely updates. A passing integration test does not prove that a historical dataset represents difficult operating days well. And a long stretch without reported errors does not prove that an unusual correction sequence has been handled correctly.
The more useful question is not just, are the tests green? It is, which uncertainties have these tests actually reduced?
That is the question I want us to keep asking as we build LayoverGuard.
We cannot stage the flight
We cannot tell an airline to delay an aircraft, change its schedule, publish an incomplete update, and repeat the whole sequence tomorrow so that a test can run again.
What we can do is recreate the conditions our software has to respond to. We can move clocks, replay available histories, inject corrections, and deliberately test the gaps between an event happening and information about it arriving.
And we can be careful not to confuse the final record of what happened with a record of what could have been known at the time.
There is no staging environment for the real world. But we can build a much better one for the software that has to operate in it.