Requirements checklist
- Four modes: run-at, run-after, run-every, run-after-tasks. Executor is a GIVEN pool — say the boundary back.
- Inject the clock — every claim testable with a fake clock (the question interviewers listen for).
- Recurring overlap (run takes 6, interval is 5): skip / queue-one / concurrent — choose and defend.
- Dependencies: all parents SUCCEED; parent failure → descendants skipped, visibly; cycles rejected at submission.
- Missed fires: skip, run the next future one. Cancel by id in scope.
The model
min-heap on next-fire -> ONE dispatcher thread sleep until top's deadline OR an insert wakes it on wake: RE-CHECK top vs clock (never trust the wakeup) due -> pop -> submit to the given pool (never execute inline) recurrence: reinsert on completion (skip-overlap falls out free) dependencies: indegree counters; 0 -> ready (topological, no sorts) cancel: mark + lazy discard on pop
Invariants (say them)
- Every non-running task lives in exactly one place: heap or dependency-wait set.
- The dispatcher never runs task code.
- A recurring task has at most one heap entry.
- Indegree always equals unfinished parents; skipped/cancelled are terminal and observable.
Complexity facts
- Schedule / reinsert / pop: O(log n); cancel O(1) marked; propagation O(children).
- The claim that matters: wakeups = due fires + earlier inserts — no polling tick.
- Drift: next = scheduled + interval (aligned) vs now + interval (sliding) — pick knowingly.
What earns points, per report dimension
- Requirements & interface — asked the clock question unprompted; surfaced overlap and parent-failure semantics before designing.
- Core design & invariants — found the heap-and-one-dispatcher shape; stated the invariants; refused per-task threads and polling.
- Extension probe — locate the new demand at a seam; narrate what changes and what provably doesn't; volunteer the cost.
- Complexity honesty — wakeup accounting, not just big-O; the drift decision defended.
- Communication — boundaries said back; decisions narrated as choices, not defaults.
Ready? Sit the live mock → — the interviewer will run a twist this chapter deliberately hasn't shown you.