The Patriot's Drifting Clock — Python Bug Hunt

Inspired by the 1991 Patriot missile failure at Dhahran: the system clock counted tenths of a second, and converting ticks to seconds through binary…

  • Language: Python
  • Layer: Backend
  • Difficulty: Medium
  • Concepts: Floating Point, Time
  • Modelled on: Patriot missile · 1991
  • Visible tests: the window opens exactly on time; the window stays open afterwards; too early stays closed
  • Reward: 50 XP for a complete fix

Briefing

Inspired by the 1991 Patriot missile failure at Dhahran: the system clock counted tenths of a second, and converting ticks to seconds through binary floating point drifted ~0.34s after 100 hours — enough to miss an incoming Scud entirely.

intercept.py decides when the tracking window opens. Keep the math in ticks (integers); the shipped code converts to float seconds and compares with ==.

Bug report

BUG-DHAHRAN · Priority: Critical · Reported by: range safety

window_open(start_ticks, now_ticks, window_seconds) — ticks are tenths:

  • True once at least window_seconds have elapsed, forever after
  • exact integer arithmetic: (now - start) ticks vs window_seconds * 10

Observed: after 100 hours of uptime (3,600,000 ticks) the float conversion yields 360000.00000000006 seconds, the equality check misses, and the window NEVER opens.

Logs

[track] uptime=100h window=360000s open=False (forever)

The code as shipped

src/defense/intercept.py (editable)

# Opens the tracking window once enough time has elapsed.
# Ticks are tenths of a second.

def window_open(start_ticks, now_ticks, window_seconds):
    elapsed_seconds = (now_ticks - start_ticks) * 0.1
    return elapsed_seconds == window_seconds

Open the hunt to edit the files, run the visible tests and submit against the hidden ones. More Python bug hunts.