Open lesson

Mission: prove the timeline under failure

Command palette

This mission workspace keeps code and notes in this browser tab. Export them before closing it. Running code is practice, not an automatic grade for the mission.

Brief

Link source, event time, watermark, window, state, and checkpoint in a streaming stop-and-restart test.

Voss enters with a graph that omits OPEN-18. Mara starts the practice laboratory while Imani places the late message on the table. Explain each stage and how you would check the result if the engine stops halfway. The meeting is near in the story; the exercise has no timer.

Your mission

  1. Draw topic Kafka → event time → watermark → window → report.
  2. Put E1 and E2 in their windows and calculate the watermark when E2 arrives.
  3. Give a stop-and-restart test using a confirmed checkpoint and an uninterrupted comparison.
  4. Name what this lab cannot yet prove about the sink, clock, and SUPPLIER-SVC.

How to check your work

  • Source and calculation in the right order.
  • E1 in [21:00,21:10), E2 in [21:10,21:20), watermark 21:05 when E2 arrives.
  • Confirmed checkpoint, stop, restore, command and report comparison.
  • External sink, clock, and human identity still require verification.

Course example

from datetime import datetime, timedelta
def at(hm): return datetime.fromisoformat("2026-04-12T"+hm+":00+00:00")
events=[
 {"id":"E1","kind":"gate","command":"OPEN-17","at":at("21:05"),"received":at("21:07")},
 {"id":"CRASH","kind":"signal","command":None,"at":at("21:25"),"received":at("21:26")},
 {"id":"E2","kind":"gate","command":"OPEN-18","at":at("21:18"),"received":at("21:36")},
 {"id":"HEARTBEAT","kind":"progress","command":None,"at":at("21:45"),"received":at("21:46")},
]
seen=set()
buckets={}
max_event=None
for e in sorted(events,key=lambda row:row["received"]):
    max_event=e["at"] if max_event is None else max(max_event,e["at"])
    watermark=max_event-timedelta(minutes=20)
    if e["kind"]=="gate" and e["command"] not in seen:
        seen.add(e["command"])
        start=e["at"].replace(minute=(e["at"].minute//10)*10,second=0)
        buckets.setdefault(start,[]).append(e["command"])
    print(e["id"],"watermark",watermark.strftime("%H:%M"))
print("gate_windows",[(k.strftime("%H:%M"),v) for k,v in sorted(buckets.items())])
print("distinct_commands",len(seen))

Code

Use Tab to leave the editor. Ctrl+Enter runs the source. The lines beginning with # are task reminders. Python ignores them. Write your code beneath them.

Python console

Loading laboratory…

Explore Python or SQL here; this is not an operating-system shell.

This is a disposable browser experiment. The code run here is not recorded as a completed mission.

Each command starts a fresh disposable worker: it runs a captured copy of your current source, then your command with the lesson fixtures. Changes are discarded afterward. Commands never save source or award XP. Ctrl+Enter executes the command.

Virtual workspace files

Source and declarative assets are readable here without JavaScript. Python input files are created at runtime; SQL setup initializes the disposable database.

source.py

Current editor source. Inspection shows your current edits.

# Draw topic Kafka → event time → watermark → window → report.
# Put E1 and E2 in their windows and calculate the watermark when E2 arrives.
# Give a stop-and-restart test using a confirmed checkpoint and an uninterrupted comparison.
# Name what this lab cannot yet prove about the sink, clock, and SUPPLIER-SVC.

exemple.py

Declarative lesson asset; this is not a file created in the Python filesystem.

from datetime import datetime, timedelta
def at(hm): return datetime.fromisoformat("2026-04-12T"+hm+":00+00:00")
events=[
 {"id":"E1","kind":"gate","command":"OPEN-17","at":at("21:05"),"received":at("21:07")},
 {"id":"CRASH","kind":"signal","command":None,"at":at("21:25"),"received":at("21:26")},
 {"id":"E2","kind":"gate","command":"OPEN-18","at":at("21:18"),"received":at("21:36")},
 {"id":"HEARTBEAT","kind":"progress","command":None,"at":at("21:45"),"received":at("21:46")},
]
seen=set()
buckets={}
max_event=None
for e in sorted(events,key=lambda row:row["received"]):
    max_event=e["at"] if max_event is None else max(max_event,e["at"])
    watermark=max_event-timedelta(minutes=20)
    if e["kind"]=="gate" and e["command"] not in seen:
        seen.add(e["command"])
        start=e["at"].replace(minute=(e["at"].minute//10)*10,second=0)
        buckets.setdefault(start,[]).append(e["command"])
    print(e["id"],"watermark",watermark.strftime("%H:%M"))
print("gate_windows",[(k.strftime("%H:%M"),v) for k,v in sorted(buckets.items())])
print("distinct_commands",len(seen))