Data & Systems50 minutes

Scheduler Under Test

Write tests that pin a job scheduler to its contract and fix what they find.

Python

Task

A small job scheduler runs jobs on ticks, with retries, priorities and dependencies. It has a written contract and three shallow tests. The same file holds six broken builds, each of which breaks one rule of the contract. Write tests that pass on the scheduler and fail on every broken build. When a test you trust fails on the scheduler itself, fix the scheduler.

Requirements

  1. handle(request) answers one request and does not change it. {op: "suite", build} runs every test_ function in the file against that build and returns {build, suite}, where suite is "pass" or "fail". {op: "run", jobs, steps} runs a small script on the scheduler and returns {states, runs, log, time}. An unknown op raises ValueError containing op, and an unknown build raises ValueError containing build.
  2. Order and dependencies: tick() runs every job that can start now, once each, highest priority first, ties in the order the jobs were added. A job can start when it is waiting, every dependency is done, and the clock has reached its retry time. add() rejects a duplicate id (ValueError containing duplicate) and a dependency that was not added first (ValueError containing dependency).
  3. Retries: an action that returns True succeeds. Anything else, or an exception, is a failure. A failed job is retried at most max_retries times, so it runs at most 1 + max_retries times, and then it is failed. Retry number n starts no sooner than base_delay * 2^(n - 1) seconds after the failure before it.
  4. Skipping: a job with a dependency that failed or was skipped is skipped and never runs. This covers direct and indirect dependents. run_until_idle() ticks until no job is waiting, and moves the clock to the next retry time when nothing can run now.
  5. Your suite must pass on the scheduler and fail on each of the six broken builds. Tests use the fake clock, not real time. Do not edit the broken builds.
How you are graded
  • Decomposition 15%
  • Prompting the assistant 15%
  • Verification 20%
  • Judgment about AI output 15%
  • Correctness 25%
  • Communication 10%

Scores use evidence from your session. A short or incomplete session may not provide enough evidence for every skill. See a sample scorecard

Interview guidance

This job scheduler has three shallow tests and a written contract. The same file has six broken builds, and each breaks one rule. Write tests that pass on the scheduler and fail on every broken build, and fix whatever your tests find. Use the AI assistant however you like. Start by telling me which contract rules the three existing tests leave open.

  • AI is allowed and expected: your own Claude, OpenAI or Gemini key, or the free in-browser model.
  • You are graded on how you drive and check the AI, not on how much you prompt.
  • Run the checks; read what fails.
  • A new requirement will arrive partway through.
  • Too little AI use is reported as “not enough to grade”, never as a fail.
You will answer 7 debrief questions at the end
  • What did you delegate to the AI, and why?
  • Name one AI suggestion you rejected or changed, and why.
  • Choose one block the AI helped write. Explain what each line does and which test verifies it.
  • What is still risky, and what would you test or ship next?
  • Which test first failed on the scheduler itself, and how did you decide whether the test or the scheduler was wrong?
  • Pick one test the assistant wrote that you changed or threw away. What was wrong with it?
  • What does your suite still not cover, and which broken build would you add next to prove it?