Open lesson

Mission: show that the erased row existed

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

Reconstruct a row's creation, update, and deletion from CDC events without confusing current absence with never having existed.

Voss opens the current register: AUTH-9 is gone. Imani brings four messages from the CDC copy, and Mara asks you to explain the disappearance before the team drops the lead. In the fiction the case must move quickly; the exercise has no timer.

Your mission

  1. Order c, u, d, and tombstone for the same key.
  2. Reconstruct approved at each stage and final state.
  3. Explain the difference between operation d and the tombstone's null value.
  4. Give a check and a limit before attributing the change to a person.

How to check your work

  • 0/100, 0/120, 0/140, then tombstone.
  • False, true, absent; past existence shown in the copy.
  • Operation d documents deletion; tombstone supports compaction.
  • Source/LSN/access checked; human author not inferred.

Course example

events=[
 {"key":"AUTH-9","value":{"op":"c","lsn":"0/100","after":{"approved":False}}},
 {"key":"AUTH-9","value":{"op":"u","lsn":"0/120","before":{"approved":False},"after":{"approved":True}}},
 {"key":"AUTH-9","value":{"op":"d","lsn":"0/140","before":{"approved":True},"after":None}},
 {"key":"AUTH-9","value":None},
]
current={}
history=[]
for event in events:
    value=event["value"]
    if value is None:
        history.append("tombstone")
        continue
    op=value["op"]
    if op=="d":
        current.pop(event["key"],None)
    else:
        current[event["key"]]=value["after"]
    history.append(op+" "+value["lsn"])
print("events",history)
print("final_row",current.get("AUTH-9"))
print("delete_lsn",events[2]["value"]["lsn"])
print("tombstone_value",events[3]["value"])

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.

# Order c, u, d, and tombstone for the same key.
# Reconstruct `approved` at each stage and final state.
# Explain the difference between operation d and the tombstone's null value.
# Give a check and a limit before attributing the change to a person.

exemple.py

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

events=[
 {"key":"AUTH-9","value":{"op":"c","lsn":"0/100","after":{"approved":False}}},
 {"key":"AUTH-9","value":{"op":"u","lsn":"0/120","before":{"approved":False},"after":{"approved":True}}},
 {"key":"AUTH-9","value":{"op":"d","lsn":"0/140","before":{"approved":True},"after":None}},
 {"key":"AUTH-9","value":None},
]
current={}
history=[]
for event in events:
    value=event["value"]
    if value is None:
        history.append("tombstone")
        continue
    op=value["op"]
    if op=="d":
        current.pop(event["key"],None)
    else:
        current[event["key"]]=value["after"]
    history.append(op+" "+value["lsn"])
print("events",history)
print("final_row",current.get("AUTH-9"))
print("delete_lsn",events[2]["value"]["lsn"])
print("tombstone_value",events[3]["value"])