codebaobab

All problemsData & Systems

Repair a Maintenance Connector

Repair a work order connector that mishandles vendor retries.

Python45 minutesData & Systems

Challenge brief

Read before you begin

Your mission · Connector repair

Repair the work-order connector so a canceled job never shows as open again.

Brightwell Property Services sent a technician to a hospital job that had already been canceled, wasting a $480 call-out, and the hospital escalated. Dispatchers also never hear when the vendor's data disagrees with itself. A review with the hospital network is set for December 4.

  • Target · all public checks
  • Defects · 3 modules
Skip to round setup

Your assignment

  1. Run the incident page and note what is wrong.
  2. Find the module that owns each wrong part.
  3. Repair the version rule, saved rows and checkpoint.
  4. Handle the new requirement when it arrives.
  5. Map each symptom to its module in NOTES.md.

The problem

Canceled job shown as open

WO-18 at a hospital campus was listed as open an hour after it was canceled.

Impact: A technician was sent to a canceled job, and the hospital escalated.

Conflicts pass silently

Twice last month the vendor sent two copies of one order version that disagreed.

Impact: Dispatchers were never told the data disagreed.

Context

Wasted call-out
$480
Field technicians
260
Hospital network review
Dec 4

Requirements

  • Ignore events at or before the saved checkpoint.
  • The highest version of each order wins.
  • A same-status copy is a retry and changes nothing.
  • Conflicting copies raise "conflicting version", apply nothing.
  • Keep canceled orders in orders.
  • Sort order ids as plain strings.
  • Checkpoint is the largest offset not ignored.
  • Check the whole request before applying anything.

System overview

Edit the components marked “Your work”. The other components show where your changes fit.

Building managersManage work orders
Vendor feedPaged work order events
Connector(Your work)Builds snapshot from feed
Snapshot fileCursor and rows together
Dispatch dashboardShows open orders
Read the connections
  • Building managers → Vendor feed: order changes
  • Vendor feed → Connector: one page
  • Connector → Snapshot file: read, then write
  • Snapshot file → Dispatch dashboard: open orders
  • Building managers: Open and cancel work orders in the vendor system.
  • Vendor feed: Pages of events. At least once; offsets out of order; pages may overlap.
  • Connector: sync_batch(request) in maintenance/sync/batch.py: feed adapter, reconciler, snapshot builder.
  • Snapshot file: Cursor and rows written together, one writer.
  • Dispatch dashboard: Shows openOrderIds to dispatchers.

Details

Full requirements

Functional

  1. Start from the saved orders, canceled ones included. Ignore every event at or before the saved checkpoint: overlapping pages are normal.
  2. For each order the highest version wins, whatever order or offsets the events arrive in. A copy of a known version with the same status is a retry and changes nothing.
  3. Two copies of one version of one order with different statuses (both in the page, or one of them the saved row) are a conflict, even when a higher version exists: raise ValueError containing "conflicting version" and apply nothing. The vendor wants those investigated before the cursor moves.
  4. Keep canceled orders in orders so an older opening cannot revive them. Sort orders by id as plain strings (WO-10 before WO-9); openOrderIds lists the opened rows in that order.
  5. The new checkpoint is the largest offset among the events not ignored, retries and older versions included, or the saved checkpoint when there are none.
  6. Check the whole request before applying anything, and keep the feed adapter's messages: checkpoint, order id, version, status, offset, duplicate.

Non-functional

  • Volume: about 9,000 order changes a day across 340 buildings, in pages of up to 500 events every 30 seconds. A page must apply in under 1 second; the checks include pages of tens of thousands of events.
  • Correctness over availability: a conflicting page stops the connector rather than publishing a guess. On-call is paged and the dashboard keeps the last good snapshot.
  • Atomicity: the cursor and the rows are published in one file write, so a crash never leaves a cursor that skips unapplied events.

Out of scope

  • Several writers. The connector runs as one process; serializing writers is a debrief topic.
  • Fetching pages from the vendor and paging on-call. The checks call the entry directly.
  • Kinds other than opened and canceled.
Data model

Saved order

FieldTypeNotes
idstringSuch as WO-18. Unique in the snapshot.
versioninteger >= 1The order's own history; higher is newer.
kind"opened" | "canceled"

Event

FieldTypeNotes
offsetinteger >= 1Delivery position. Unique in a page; says nothing about which change is newer.
id, version, kindAs for a saved order.

Snapshot

FieldTypeNotes
checkpointinteger >= 0Largest offset applied.
ordersSaved order[]Every known order, sorted by id.
openOrderIdsstring[]Ids of opened rows, same order.
Files you are given · 5
  • samples/page-0415.json A later page as a full request: one event the checkpoint covers, a retry of a cancellation at a new offset, and two new orders whose ids sort as strings.
    {
      "checkpoint": 104,
      "orders": [
        {
          "id": "WO-18",
          "version": 2,
          "kind": "canceled"
        },
        {
          "id": "WO-42",
          "version": 1,
          "kind": "opened"
        },
        {
          "id": "WO-7",
          "version": 3,
          "kind": "opened"
        }
      ],
      "events": [
        {
          "offset": 103,
          "id": "WO-7",
          "version": 4,
          "kind": "canceled"
        },
        {
          "offset": 107,
          "id": "WO-9",
          "version": 1,
          "kind": "opened"
        },
        {
          "offset": 105,
          "id": "WO-42",
          "version": 2,
          "kind": "canceled"
        },
        {
          "offset": 108,
          "id": "WO-42",
          "version": 2,
          "kind": "canceled"
        },
        {
          "offset": 106,
          "id": "WO-10",
          "version": 1,
          "kind": "opened"
        }
      ]
    }
  • samples/snapshot-after-0415.json The snapshot the connector must publish for that page.
    {
      "checkpoint": 108,
      "orders": [
        {
          "id": "WO-10",
          "version": 1,
          "kind": "opened"
        },
        {
          "id": "WO-18",
          "version": 2,
          "kind": "canceled"
        },
        {
          "id": "WO-42",
          "version": 2,
          "kind": "canceled"
        },
        {
          "id": "WO-7",
          "version": 3,
          "kind": "opened"
        },
        {
          "id": "WO-9",
          "version": 1,
          "kind": "opened"
        }
      ],
      "openOrderIds": [
        "WO-10",
        "WO-7",
        "WO-9"
      ]
    }
  • samples/conflict-page.json Two copies of WO-9 version 2 that disagree, hidden behind a version 3. The connector must reject it with "conflicting version".
    {
      "checkpoint": 108,
      "orders": [
        {
          "id": "WO-9",
          "version": 1,
          "kind": "opened"
        }
      ],
      "events": [
        {
          "offset": 109,
          "id": "WO-9",
          "version": 2,
          "kind": "canceled"
        },
        {
          "offset": 110,
          "id": "WO-9",
          "version": 2,
          "kind": "opened"
        },
        {
          "offset": 111,
          "id": "WO-9",
          "version": 3,
          "kind": "canceled"
        }
      ]
    }
  • logs/connector-2026-11-18.log The incident morning: the published checkpoint going to 102, the next page rereading 103 and 104, and the call-out to WO-18.
    2026-11-18T07:00:02Z sync page=p-0411 checkpoint_in=100 events=3 offsets=103,104,102
    2026-11-18T07:00:02Z publish checkpoint=102 orders=2 open=WO-18,WO-42
    2026-11-18T07:00:32Z sync page=p-0412 checkpoint_in=102 events=3 offsets=103,104,105
    2026-11-18T08:04:51Z dispatch tech=T-117 order=WO-18 site=riverside-campus status=en_route
    2026-11-18T08:41:10Z dispatch tech=T-117 order=WO-18 result=job_canceled_on_arrival callout_usd=480
  • metrics/canceled-dispatches-2026.csv Technicians sent to canceled jobs per month, their call-out cost, and conflicting copies the vendor later confirmed.
    month,dispatches,dispatched_to_canceled,callout_cost_usd,conflicting_copies_seen
    2026-08,6840,3,1440,0
    2026-09,7112,5,2400,1
    2026-10,7305,9,4320,2
    2026-11 (to 18th),4410,6,2880,0
Tickets · 3
  • BUG-101 A canceled work order shows as open again after the vendor retried an event Reported by Marco (dispatch)

    Expected checkpoint 104, orders WO-18 version 2 canceled and WO-42 version 1 opened, openOrderIds ["WO-42"].

    Actual checkpoint 102, WO-18 back at version 1 and opened, no canceled rows kept, openOrderIds ["WO-18", "WO-42"].

  • BUG-102 Work orders disappear from the dashboard after a normal page Reported by Dana (product)

    Expected checkpoint 108, five orders, three open.

    Actual checkpoint 106, WO-18 and WO-42 missing from orders, openOrderIds ["WO-10", "WO-7", "WO-9"].

  • BUG-103 A page with conflicting versions wiped the dashboard Reported by Sam (on-call)

    Expected The conflict page raises ValueError containing "conflicting version" and publishes nothing. The incident gives checkpoint 104, and an empty page after it keeps 104 and the canceled WO-18.

    Actual The conflict page is accepted: checkpoint 111 with no orders at all. An empty page drops every canceled order from the file.

What you hand in
  • Repairs in the modules that own each rule, passing every public check and the replay test, and the follow-up when it arrives.
  • NOTES.md: each symptom from the incident, the module that caused it and the check that proves the repair.
  • Your answers to the interviewer's follow-up and the debrief questions.
How the work is judged
Breaking down the work
Separates the three rules (version, saved rows, checkpoint) and repairs each in the module that owns it instead of patching the coordinator.
Directing the assistant
Gives the assistant the vendor's statement that offsets say nothing about which change is newer, and the incident page with the expected snapshot.
Checking the work
Runs the incident, samples/page-0415.json and samples/conflict-page.json before and after, and runs the replay test through the service.
Judging the assistant
Rejects sorting events by offset, dropping canceled rows to keep the file small, or resolving a conflict by "last one wins".
Correct result
All checks pass, including the follow-up, with string ordering and error words exactly as specified, and large pages inside the time budget.
Explaining the work
Explains to the hospital's facilities director why WO-18 reopened and why a conflicting page now stops the feed.
Trade-offs to discuss
  • Stopping on a conflict protects dispatch from a guess, but halts every building until someone looks.
  • Keeping every canceled order forever versus pruning after a retention window, and what an old reopening could do after pruning.
  • One snapshot file with one writer versus a database transaction that compares the previous checkpoint.
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

A facilities customer says canceled jobs come back as open on their dispatch dashboard after the vendor retries or reorders events. Reproduce the incident first, then follow one event through the connector and repair what is wrong where it belongs. Use the AI assistant however you like, and show me why a replayed page is now harmless.

  • 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.
Debrief · 7 questions
  • 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?
  • What was wrong in the incident snapshot, and which module owned each part?
  • How did you check that replaying a page changes nothing?
  • In quarantine mode, why does the checkpoint stop where it does, and what happens on the next page?