Complete worked example
python
def inspect_example(rows, watermark, lookback, upper):
if lookback < 0 or upper < watermark:
raise ValueError('invalid bounded window')
lower = watermark - lookback
selected = [r for r in rows if lower <= r['tick'] <= upper]
latest = {}
for row in selected + selected:
if row['id'] not in latest or row['version'] > latest[row['id']]['version']:
latest[row['id']] = dict(row)
return {'ids': sorted(latest), 'window': [lower, upper]}- Reasoning
- The baseline validates the window, selects records between lower and upper inclusive, and applies them twice through highest-version selection. The output identifies retained entities and reports the exact window. The second pass should leave current state unchanged because replay is part of the intended policy.