Data and states
Which data sets must be considered together when replacing R-3?
A-17 moves from draft through submitted and reviewing to approved, rejected or withdrawn. Tasks are separate entities. A new revision atomically replaces the active revision and cancels old open tasks. New revisions and withdrawals are allowed only before terminal completion. After approved, rejected or withdrawn, new demand starts a new request.
Starting point Step 4 established R-3 as the expected revision and v7 as the expected request version for a decision command.
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.
A-17, R-3, Tasks and U-17 as a Data Model
Authoritative datastore · Request A-17 and revision R-3 have separate lifecycles
- Aggregate and tasks
- Versioned datastore
- Target reference
R-3 stays readable after R-4 replaces it. The revision change atomically marks old open tasks cancelled.
Permitted transitions
| Entity | Transition | Condition |
|---|---|---|
| A-17 | draft → submitted → reviewing | The submission command fixes the revision and rule, creates the first business review task and commits reviewing. In this example, submitted is an internal transition within that transaction. |
| F-17 / G-17 | open → approved | rejected | The current assigned role, absence of self-approval, active revision and expected request version all match. A budget task is created only after business approval. |
| A-17 | reviewing → approved | Specialist task approved; from inclusive 5,000 euros additional budget task approved. U-17 pending is created in the same commit. |
| A-17 | reviewing → rejected | An active task is rejected. Other open tasks are cancelled; there is no handover. |
| A-17 | reviewing → withdrawn | The applicant withdraws before completion using a valid request version; open tasks are cancelled and no handover occurs. |
| Open tasks | open → cancelled | A new active revision, rejection or withdrawal of the request; completed decisions remain historical facts. |
| R-3 | active → superseded | Only during reviewing: save R-4 with its fixed rule version and new business review task, switch the active reference, cancel old open tasks and increment the request version. |
| U-17 | pending → acknowledged | Target confirms new or already known acceptance of the same U-17. Timeout allows pending to persist; repetition does not reset acknowledged. |
A-17
- Transition
- draft → submitted → reviewing
- Condition
- The submission command fixes the revision and rule, creates the first business review task and commits reviewing. In this example, submitted is an internal transition within that transaction.
F-17 / G-17
- Transition
- open → approved | rejected
- Condition
- The current assigned role, absence of self-approval, active revision and expected request version all match. A budget task is created only after business approval.
A-17
- Transition
- reviewing → approved
- Condition
- Specialist task approved; from inclusive 5,000 euros additional budget task approved. U-17 pending is created in the same commit.
A-17
- Transition
- reviewing → rejected
- Condition
- An active task is rejected. Other open tasks are cancelled; there is no handover.
A-17
- Transition
- reviewing → withdrawn
- Condition
- The applicant withdraws before completion using a valid request version; open tasks are cancelled and no handover occurs.
Open tasks
- Transition
- open → cancelled
- Condition
- A new active revision, rejection or withdrawal of the request; completed decisions remain historical facts.
R-3
- Transition
- active → superseded
- Condition
- Only during reviewing: save R-4 with its fixed rule version and new business review task, switch the active reference, cancel old open tasks and increment the request version.
U-17
- Transition
- pending → acknowledged
- Condition
- Target confirms new or already known acceptance of the same U-17. Timeout allows pending to persist; repetition does not reset acknowledged.
Authoritative datastore and transaction
Authoritative relational SQL datastore
A decision must check and write the request, active revision, tasks, rule version and outbox together.
- Trade-off
- Queries and history need appropriate indices and retention rules.
- Reassess
- For measured conflicts or separate reading requirements.
P-2 fixed upon submission
A decision must identify the rule used to evaluate R-3.
- Trade-off
- New rules do not silently affect ongoing cases.
- Reassess
- With an explicit, auditable migration plan.
Atomic changes and access patterns
- Protecting conflicts
- Decision, submission and withdrawal compare the request version in the same transaction and increment it on success. Roles and task status are also checked against the current state. A conditional write or request lock prevents two winners on v7.
- Read access
- Worklists filter by assigned person and open, history by request and revision, and the worker by due pending handovers. Suitable indexes support these queries; a unique command key binds the payload to its stored result.
- Preserve rule provenance
- P-2 remains fixed for R-3. Explicit migration would preserve the original assignment and write a separate migration record with the target version. This operation remains deferred in the initial design.
Terms in this step
- Active revision
- The revision against which new tasks and decisions are checked for the current request.
- Outbox
- A follow-up order stored in the same commit, which a worker later repeatably transfers to an external system.
- Transaction, Commit and Rollback
- A transaction groups related changes: switching to R-4 updates the active reference, tasks and request version together. Commit makes all changes durable; rollback discards them all on error.
Try it yourself
Note the transaction for filing R-4 and complete a negative test for F-17.
A hint for your attempt
R-3 may remain legible but may no longer be active or decidable.
Compare with a possible solution
- Change of version
- Transaction: check expected R-3/v7 and applicant; create R-4 with a fixed rule version; switch the active reference to R-4; mark open R-3 tasks cancelled; create business review task F-R-4; save v8 and the command record together. Roll back everything on error. Test: either the complete old state or the complete new state exists.
- Delayed decision
- An F-17/R-3/v7 decision arrives after the revision change and receives 409. A-17 remains reviewing on R-4/v8; U-17 is absent. Also test the opposite winner order: F-17 writes G-17 and v8; the stale R-4 submission receives 409.
Apply to your project
Which dependent open entities must you explicitly close or migrate when changing versions in your design?