System Design Atlas

Laboratory samples with a complete chain of custody

07 / 10Worked example

Critical flow

The winning commit decides the custodian. What conditions ensure the result?

Two scanners send against version 2.

Starting point Store raw data immutably and associate it by hash.

Assumptions for the example case

Fictitious training laboratory with an aqueous control sample. The draft documents custody changes and results; diagnostic interpretation and clinical decisions are outside the case. All quantities, thresholds and operational objectives of this design are illustrative assumptions.

Two receipt attempts

Two receipt attempts

Both are expecting version 2.

Scanner A
Laboratory API
Sample data store
Scanner B
  1. 01 Scanner A → Laboratory APIReceipt A expected2
  2. 02 Laboratory API → Sample data storeCommit custodian A
  3. 03 Laboratory API · Local processingResponse lost
  4. 04 Scanner A → Laboratory APIReplay A
  5. 05 Scanner B → Laboratory APIReceipt B expected2
  6. 06 Laboratory API → Scanner BVersion conflict

Result: Exactly one confirmed custodian.

The winning commit and its retries preserve exactly one custodian.

Two scanners → API → data store; winning commit, lost response, retry; the loser receives a conflict.

Commit, response loss and resumption

Competing takeover
Two laboratory members scan P-40 against the same custodian version status. The version comparison and receipt are jointly committed.
Response loss
The winner’s response is lost; its transferKey retrieves the same receipt. The other receipt attempt still conflicts.
Incomplete measurement
The device adapter acknowledges only durable acceptance. Raw data without an unambiguous sample association remains blocked; the authorised reviewer receives no releasable result revision.

The winning commit determines the custodian.

The winning commit determines the custodian.

Write the version check and receipt atomically.

Two scanners send against version 2.

The first successful commit wins; the second receives conflict and does not change a custodian. Replay of the winner reads the confirmed handover. Before commit, a new attempt would be allowed, after commit it remains at an effect.

Alternative considered
Last write access wins would overwrite the first receipt.
Trade-off
The second scanner must read and clarify.
Reassess
New transfer types require new permitted state transitions.

Try it yourself

Predict the result for A before B and B before A; then lose the winning answer.

A hint for your attempt

Two scanners send against version 2.

Compare with a possible solution
Both orders
The first successful commit wins; the second receives conflict and does not change a custodian.
Response loss
A retry of the winning command returns the confirmed handover. Before commit, another attempt is permitted; after commit, the effect remains singular.

Apply to your project

What is the equivalent of "The winning commit decides the custodian." in your own project?

Step 8: Unassigned data is a domain workflow bottleneck. What conditions ensure the result?