The bank locked the account
The bank upload was tried five times; the bank locks after four failed logins.
Impact: The account stayed locked until morning.
FDE interview labData & Systems
Write tests that pin a job scheduler to its contract and fix what they find.
Your mission · Test writing
Fernhill Payroll's nightly scheduler locked the company out of its bank and then stopped on a false stuck error, which forced an on-call fix at 04:30. The incident review found almost no tests guarding it. Year-end payroll and W-2 runs begin December 15, and changes must stay safe.
The bank upload was tried five times; the bank locks after four failed logins.
Impact: The account stayed locked until morning.
The run raised "stuck" instead of finishing the jobs that could still run.
Impact: On-call cleared it by hand at 04:30.
Retries, backoff, priority and skipping have no test.
Impact: All six broken builds pass the current suite.
Edit the components marked “Your work”. The other components show where your changes fit.
| Field | Type | Notes |
|---|---|---|
id | string | Unique in the graph. |
state | string | waiting, done, failed or skipped. |
max_retries, priority | integer | Retries after the first run; higher priority runs first. |
depends_on | tuple of ids | Added before this job. |
runs, retries, ready_at | integer | Calls so far, retries given, earliest time of the next run. |
| Field | Type | Notes |
|---|---|---|
jobs | [{id, fails, max_retries, priority, depends_on}] | fails is a count of failing runs, or "always". |
steps | list | "tick", "idle" or {advance: seconds}. Missing means run until idle. |
result | {states, runs, log, time} | log is [time, job id, "ok" or "fail"] per run. |
samples/requests-nightly.json Three run requests for handle: the bank upload failing every time, a failed upload with two jobs downstream, and a timesheet pull that fails once ahead of two priority-5 jobs.[
{
"op": "run",
"base_delay": 2,
"jobs": [
{
"id": "upload-bank-file",
"fails": "always",
"max_retries": 3
}
]
},
{
"op": "run",
"jobs": [
{
"id": "upload-bank-file",
"fails": "always"
},
{
"id": "confirm-deposits",
"depends_on": [
"upload-bank-file"
]
},
{
"id": "email-payslips",
"depends_on": [
"confirm-deposits"
]
}
]
},
{
"op": "run",
"jobs": [
{
"id": "pull-timesheets",
"fails": 1,
"max_retries": 2
},
{
"id": "compute-payroll-us",
"depends_on": [
"pull-timesheets"
],
"priority": 5
},
{
"id": "audit-snapshot",
"priority": 1
},
{
"id": "compute-payroll-ca",
"depends_on": [
"pull-timesheets"
],
"priority": 5
}
]
}
]samples/expected-nightly.json What the contract says each request returns, in the same order. Every value can be traced to a numbered rule.[
{
"states": {
"upload-bank-file": "failed"
},
"runs": {
"upload-bank-file": 4
},
"log": [
[
0,
"upload-bank-file",
"fail"
],
[
2,
"upload-bank-file",
"fail"
],
[
6,
"upload-bank-file",
"fail"
],
[
14,
"upload-bank-file",
"fail"
]
],
"time": 14
},
{
"states": {
"upload-bank-file": "failed",
"confirm-deposits": "skipped",
"email-payslips": "skipped"
},
"runs": {
"upload-bank-file": 1,
"confirm-deposits": 0,
"email-payslips": 0
},
"log": [
[
0,
"upload-bank-file",
"fail"
]
],
"time": 0
},
{
"states": {
"pull-timesheets": "done",
"compute-payroll-us": "done",
"audit-snapshot": "done",
"compute-payroll-ca": "done"
},
"runs": {
"pull-timesheets": 2,
"compute-payroll-us": 1,
"audit-snapshot": 1,
"compute-payroll-ca": 1
},
"log": [
[
0,
"audit-snapshot",
"ok"
],
[
0,
"pull-timesheets",
"fail"
],
[
2,
"pull-timesheets",
"ok"
],
[
2,
"compute-payroll-us",
"ok"
],
[
2,
"compute-payroll-ca",
"ok"
]
],
"time": 2
}
]config/nightly-jobs.yaml The part of the production job graph these samples come from, with the retry limit the bank imposes.# Part of the November job graph. base_delay is 2 seconds in tests; production uses 30.
base_delay_seconds: 30
jobs:
- id: pull-timesheets
max_retries: 2
- id: audit-snapshot
priority: 1
- id: compute-payroll-us
priority: 5
depends_on: [pull-timesheets]
- id: compute-payroll-ca
priority: 5
depends_on: [pull-timesheets]
- id: upload-bank-file
max_retries: 3 # the bank locks the account after 4 failed logins
depends_on: [compute-payroll-us, compute-payroll-ca]
- id: confirm-deposits
depends_on: [upload-bank-file]
- id: email-payslips
depends_on: [confirm-deposits]logs/nightly-2026-11-14.log The incident night: five attempts against the bank, then the run stopping with "stuck" until on-call cleared it.2026-11-14T01:52:10Z scheduler run job=upload-bank-file attempt=1 result=fail reason="sftp: connection reset" 2026-11-14T01:52:40Z scheduler run job=upload-bank-file attempt=2 result=fail reason="sftp: connection reset" 2026-11-14T01:53:40Z scheduler run job=upload-bank-file attempt=3 result=fail reason="sftp: connection reset" 2026-11-14T01:55:40Z scheduler run job=upload-bank-file attempt=4 result=fail reason="sftp: auth failed" 2026-11-14T01:59:40Z scheduler run job=upload-bank-file attempt=5 result=fail reason="sftp: account locked" 2026-11-14T02:10:41Z scheduler error RuntimeError: stuck: jobs are waiting and nothing can ever run waiting=212 2026-11-14T04:30:02Z oncall action=manual-clear run=nightly-2026-11-14 by=k.mensah
TASK-201 Turn each contract rule into at least one test Reported by Rachel (Batch Platform lead)
Expected At least one test_ function per numbered rule, with expected values written from the rule.
Actual The report shows 3 tests: one job runs, one job without retries fails, one dependent job runs. Retries, backoff, priority and skipping have no test.
TASK-202 Make the suite fail on every broken build Reported by Rachel (Batch Platform lead)
Expected suite is "fail" on all six broken builds and "pass" on "scheduler".
Actual suite is "pass" on all six broken builds, so every "Suite: fails on ..." check fails.
TASK-203 When a contract test fails on the scheduler, fix the scheduler Reported by Kofi (on-call, Nov 14)
Expected The bank upload runs 4 times, at 0, 2, 6 and 14 seconds. In the chain, confirm-deposits and email-payslips are skipped and the run ends at time 0.
Actual The bank upload runs 5 times, the last at 30 seconds. The chain raises RuntimeError "stuck: jobs are waiting and nothing can ever run".
Scores use evidence from your session. A short or incomplete session may not provide enough evidence for every skill. See a sample scorecard
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.