Design Worksheet โ Before You Type
advanced10 min readLesson 203 of 204
Decide the invariants first: who owns the window, what reset means, and why the report is a total order โ then implement once.
Decisions to lock before implementing
- Window ownership. Where does "current window" live? (Hint: a single
timestamp comparison in
admitโ not a timer, not a thread.) - Reset semantics. A window rolls on the first admit at a new timestamp: clear usage and ordinals together, or nothing.
- Reject paths are ordered too. Unknown tag and exhausted tag are both rejections โ one counter, two reasons, same discipline.
- The report is a total order. Timestamp asc, then code severity
(REJECT < ADMIT), then stable insertion โ which makes
snapshot()deterministic even for equal-timestamp evidence. - Provenance.
Admission.ordinalmust survive the roll (restart at 1) โ learners who store ordinals globally fail the acceptance battery.
Write your answers as comments above each method, then implement. The acceptance battery below is the grader, in the practice and again โ harder โ in the checkpoint.