Skip to content
Ameen Abozaid
SRC-014

Data integrity

  • 7 Lessons
  • 4 h practice (estimate)
On this page 9 topics

Overview

Topics

  • Cross-service invariants
  • reconciliation
  • exactly-once effects vs guarantees

Learn first

4 h of practice (estimate)

Learning outcomes

  1. Identify invariants that span services and decide how each is protected or detected.
  2. Explain the difference between exactly-once delivery (unavailable) and exactly-once effects (designable).
  3. Build reconciliation jobs that detect and repair drift between services and external systems (e.g., payment provider).
  4. Design audit trails for financially significant data.

Lessons

  1. 01Invariants across boundaries
  2. 02Exactly-once effects
  3. 03Prevent, detect, repair
  4. 04Reconciliation design
  5. 05Audit trails
  6. 06Demo: reconciling orders against the payment provider
  7. 07Demo: tracing a double charge to its root cause

Lab and exercises

Lab

SRC-014-LAB1 · Money matches

Outcomes: 1–4 · Time: ~4 h Build a daily reconciliation between orders, payments, and the payment provider's settlement file. Plant three discrepancy types (for example charge without order, order without charge, amount mismatch). Detect and repair them, with audit rows for every repair. Acceptance: report with counts, repairs logged and auditable.

Exercises (assessment: invariant analysis of an unseen workflow)

IDOutcomeTask
SRC-014-EX011List five invariants spanning orders, inventory, and payments, and state prevent, detect, or repair for each.
SRC-014-EX022Explain to a product manager why "exactly-once delivery" is not offered, and what the team builds instead.
SRC-014-EX032Design an idempotent payment call, including key generation, storage, and behavior on timeout.
SRC-014-EX043Write the reconciliation algorithm and the repair rules for the three planted discrepancy types.
SRC-014-EX054Design the audit schema for refunds and write which events must be recorded.
SRC-014-EX061Case (unseen): a workflow with order, stock reservation, payment, shipment. Identify where invariants can break on partial failure.
Show solutions
  • EX01 Examples: payment captured implies order (detect by reconciliation, repair by refund or order creation); stock not negative (prevent with conditional update); order total equals line sum (prevent with a constraint or domain rule); event published implies row committed (prevent with outbox); refund at most captured (prevent in code, detect).
  • EX02 Networks can drop messages or acknowledgments, so senders retry. We make operations idempotent so repeats have one effect.
  • EX03 Key derived from order ID and attempt, persisted before the call; on timeout, retry with the same key or query the provider; store the provider response per key.
  • EX04 Join by provider reference; charge without order: create or refund after review; order without charge: mark unpaid or retry capture; amount mismatch: flag and adjust per policy. All repairs write audit rows and the job is re-runnable.
  • EX05 Columns: actor, time, entity, before and after, reason, correlation ID; append-only; record refund request, approval, provider call, and result.
  • EX06 Partial failures: payment captured but reservation failed; stock reserved but payment failed (release); shipment created but payment reversed. Each needs prevention (saga, outbox) and detection.
  • Outcome 3 is also covered by the lab report and Q06-Q08.

Workplace evidence: a reconciliation or integrity check you introduced and what it found.

Quiz

Outcomes: O1 cross-service invariants · O2 exactly-once effects · O3 reconciliation · O4 audit trails.

A self-check for you: nothing is graded, saved or sent anywhere. Choose an answer, then check it. You can try again as often as you like.

  1. 1An invariant is:O1
  2. 2Cross-service invariants need design because:O1
  3. 3Exactly-once delivery over a network is:O2
  4. 4The practical way to get exactly-once effects is:O2
  5. 5A payment retry after timeout should use:O2
  6. 6Reconciliation compares:O3
  7. 7Comparing only totals is risky because:O3
  8. 8A reconciliation repair should:O3
  9. 9An audit trail should be:O4
  10. 10Messaging guarantees remove the need for reconciliation:O1

Practical part

Invariant analysis of an unseen workflow (SRC-014 assessment), plus the SRC-014-LAB1 reconciliation report. Pass: at least 8/10 on the quiz, invariants identified with a control for each, and repairs that are audited.

Common mistakes

Assuming messaging guarantees remove the need for reconciliation; repairs without audit.

Assessment

Invariant analysis of an unseen workflow.

Workplace evidence

A reconciliation or integrity check you introduced and what it found.

Career relevance

Data governance (ARC-030) and compliance (SRA-009).

Type to search levels, phases, modules and lessons.