> ## Documentation Index
> Fetch the complete documentation index at: https://playbook.smedleygroup.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Predicted Race History

> The engine's predicted remainder for every driver, overlaid on the real race-history gap chart.

## Overview

Predicted Race History takes the same gap-to-leader-average chart as the [Race History](/software/internal/watchparty/widgets/race-history) widget and adds one dashed, faded line per driver: the engine's predicted remainder of the race, joined onto that driver's actual trace at the playhead.

> [!NOTE]
>
> The engine models no traffic and no lapped cars. A predicted line can cross a real one; that is expected, not a bug.

***

## What It Shows

![Actual traces joined to the engine's predicted remainder at the playhead (Madrid 2026, lap 43)](https://mintcdn.com/smedley_group/zwm6wmhxgH8zyABx/images/watchparty/predicted-race-history.png?fit=max\&auto=format\&n=zwm6wmhxgH8zyABx\&q=85\&s=5c9c0579a116398797b3ec4a6dbe1d79)

The base chart (axes, gridlines, actual driver traces) is byte-identical to Race History, built by the same function, and it zooms the same way: right-drag a box to zoom both axes, right-click without moving for a **Reset zoom** menu, no sliders (see [Race History](/software/internal/watchparty/widgets/race-history)). Each predicted line:

* starts at the point where that driver's actual trace currently ends (the join point), so there is no visible gap between actual and predicted;
* carries the same styling an actual trace would: the driver's team colour, the per-team solid or dashed line type, an end-of-line driver tag, and a reduced opacity;
* stops drawing at the last lap the engine judged reachable, if any later lap in that driver's predicted series carries the engine's unreachable sentinel;
* is named by the driver alone, never "predicted", so the always-on legend can key off a real driver name.

**Before lights out.** When the playhead sits before lap 1 and the session carries a lap-0 pre-race snapshot, this chart draws the predicted curves **alone** against a constant reference that puts the predicted winner at zero seconds on the final lap, with a caption naming the loaded race data version. There is no actual trace to join yet. See [Pre-Race and What-If Studies](/software/internal/watchparty/strategy/pre-race-and-study-mode).

![The pre-race view: predicted curves alone, before any lap has been timed (Madrid 2026)](https://mintcdn.com/smedley_group/zwm6wmhxgH8zyABx/images/watchparty/predicted-race-history-prerace.png?fit=max\&auto=format\&n=zwm6wmhxgH8zyABx\&q=85\&s=563325b26ab8dbda02e2f3dc3a1bb72c)

The x-axis widens to the full race distance so a predicted point beyond the currently hydrated lap range is never clipped. A caption under the chart states the clear-air assumption plainly, and, when the underlying snapshot is stale, an as-of stamp: "Data as of lap N (playhead lap M)".

***

## Data Behind It

The predicted lines come from the latest `strategy_snapshot`'s `race_history` rows, at or before the playhead lap (the as-of rule). `model_id` `strategy_snapshot`, `model_version` the composite `engine_version+WRAPPER_VERSION`, over `vpw:v1:{session_key}:insight:strategy_snapshot`, hydrated via REST on session enter and rehydrate, then live.

Each predicted point is re-baselined into the same gap frame the actual traces use: `y(lap) = cumulative_time(lap) - sum(baseline over laps 1..lap)`, the identical transform (cumulative lap time minus a rolling baseline) the base Race History chart applies to real laps. Rows for a lap at or before the playhead are skipped: they are already covered by the actual trace up to the join point, and drawing them again would draw a predicted point backwards from it. A row at or above the engine's `1e300` unreachable threshold truncates that driver's predicted series at the last reachable lap; this is sentinel decoding, done once in the shared derivation layer, never smoothing.

***

## States

> **No snapshot, no as-of data at all**
>
> Shows the shared empty-state text: the exact-lap status gate and reasons where known, or a generic "No strategy data at lap N."

> **No completed laps yet**
>
> When an as-of snapshot exists but the race has not yet produced a completed lap to plot, shows "No completed laps yet." instead of an empty chart.

> **Laptimes missing**
>
> Mirrors the base Race History widget's own honest-empty state: one missing measured lap time anywhere would silently corrupt the running cumulative sum, so the whole widget shows "Laptimes missing" and plots nothing, actual or predicted.

> **Stale snapshot**
>
> The chart still renders, with an as-of stamp under it: "Data as of lap N (playhead lap M)".

> **Race-only**
>
> Outside a race, renders "Session is not a race"; the app never computes a strategy bundle for a non-race session.

***

## FAQ

> **Why does a predicted line cross a real driver's line?**
>
> The engine's remainder prediction assumes clear air: no traffic, no lapped cars. A predicted line crossing another driver's actual or predicted line is expected under that assumption, not an error.

> **Why does a driver's predicted line stop partway through the race?**
>
> The engine judged every later lap in that prediction unreachable from the current race state (its `DBL_MAX` sentinel). The line truncates at the last lap it could still complete.

***

## Next Steps

> **[Race Strategy Tool](/software/internal/watchparty/strategy/index)**
>
> The shared engine, derivation layer, and sentinel rule behind all six strategy widgets.

> **[Race History](/software/internal/watchparty/widgets/race-history)**
>
> The real, actual-only version of this chart.

> **[Predicted Pit Window and SC](/software/internal/watchparty/strategy/predicted-pit-window)**
>
> Each driver's next predicted stop, plus safety-car guidance.

> **[Strategy Status](/software/internal/watchparty/strategy/status)**
>
> The gate, reasons, and whole-race health strip that explains a blank or stale chart.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.