System Design Atlas

Multi-stage request approval

02 / 10Worked example

Requirements

Which conditions must hold within the same transaction for the F-17 decision to take effect?

Only the assigned business reviewer may decide F-17. Applicants may not approve their own tasks. After business approval, 6,000 euros triggers G-17 because the inclusive threshold is 5,000 euros. Every business change also increments the request version, initially v7. This detects concurrent commands even when both still refer to R-3.

Starting point The system boundary has separated the applicant, the reviewer and the immutable R-3.

Assumptions for the example case

Illustrative design: an internal procurement request for 6,000 euros undergoes business review followed by budget review. The inclusive budget threshold is 5,000 euros. These figures are assumptions rather than operational measurements. Ordering, payment, contract law and automatic decisions are outside the scope.

Check function, protection rule and quality objective separately

A-17 · Check function, invariant and operational objective separately

Function

Maintain the active revisionR-3 and P-2 are immutably linked at submission.
Test ideaAttempt: change revision after submission; result: new R-4.

Invariant

Protecting decisionsApplicants cannot approve their own tasks. Atomically check revision, request version, role and open status.
Test ideaNegative test: own or superseded tasks produce no effect.

Quality objective

Handle peak decision trafficTarget assumption: 95 % of responses ≤ 500 ms; technical errors not exceeding 1 %.
Test idea15 minutes with 20 decision attempts/s; measure conflict and technical errors separately.
  • Performance
  • Protection rule
  • Measurement

A short response time does not establish approval correctness. Version and role checks require separate evidence.

The business invariant is proven independently of load and response time.

Business requirements (functional)

Further reading
RuleExampleNegative test
Revision activeOnly R-3 can justify F-17.Decision on an obsolete or aborted version delivers 409.
Separation of rolesApplicants do not decide their own tasks.Their own F-17 decision has no effect.
ThresholdAmount ≥ 5,000 euros needs G-17.5,000 creates G-17; 4,999 does not.
Application versionThe decision and revision submission both expect R-3/v7.The first commit writes v8; the second command on v7 gets 409.

Revision active

Example
Only R-3 can justify F-17.
Negative test
Decision on an obsolete or aborted version delivers 409.

Separation of roles

Example
Applicants do not decide their own tasks.
Negative test
Their own F-17 decision has no effect.

Threshold

Example
Amount ≥ 5,000 euros needs G-17.
Negative test
5,000 creates G-17; 4,999 does not.

Application version

Example
The decision and revision submission both expect R-3/v7.
Negative test
The first commit writes v8; the second command on v7 gets 409.

Quality goals (non-functional)

Further reading
Illustrative response-time target
Design assumption: 95% of decision responses arrive within 500 ms, measured from authenticated API entry to response including the SQL commit. A 15-minute test sends 20 decision attempts/s. Successes, business conflicts and technical errors are evaluated separately; technical errors must account for at most 1%. These values are assumptions to agree before operation, rather than measurements.
Conflict assessment
Two clients also send a decision and a new revision against the same state v7. Expect exactly one successful business commit, one 409 and no partial state. This paired test is separate from the throughput test.

Terms in this step

Invariant
A rule that must hold in every valid business state.
Server-side authorization
The server checks permission for each request and object; the interface cannot replace that check.
SLO
A service level objective is an agreed, measurable operational target. Here, response time, measurement boundary, error rate and test duration are initially set as design assumptions.

Try it yourself

Formulate three checks for POST /tasks/F-17/decision and one test at exactly 5,000 euros.

A hint for your attempt

Check the role, timing and revision together; all are part of the business rule.

Compare with a possible solution
Active revision
F-17.revisionId must match the active revision of A-17; expectedVersion must also match the current request version. Test: R-4 becomes active at v8 before the decision; the old command against R-3/v7 receives 409.
Task and role
F-17 must be open and the acting person must be assigned as well as different from the applicant. Test: Repetition or self-approval does not change anything.
Threshold
At 5,000 euros, amount ≥ threshold is true. Test: G-17 is created after F-17 is approved.

Apply to your project

Which role or object rule must your design check directly in the write command?

The rules determine which magnitude and which test peaks are considered step 3.