Data and states
Which changes to the change order must take effect together, and what stays protected after completion?
The contracts require an authoritative datastore for change order N-32. The example comprises 20 units at 25000 cents, totalling 500000 cents: exactly the internal review threshold. A document hash binds the stored bytes; a URL alone may later point to a different drawing revision. The state is stored with its command result so the same command remains recognisable after a restart.
Starting point Approval specifies three concrete content references.
Assumptions for the example case
Original fictional design: an internal approval workflow for a change order with frozen drawings and costs. The illustrative internal threshold is 500000 cents. Up to and including this amount, one approver is sufficient; above it, this case requires a second approver. All figures and test targets are illustrative assumptions.
Authoritative data and permitted state transitions
Entities and life cycle
Approval binds the drawing revision, scope of work and cost revision.
Domain entities and relationships
| Entity | Authoritative attributes | Relationship |
|---|---|---|
| Change order | N-32; business identity and status | Has immutable submitted revisions. |
| Drawing revision | P-32; drawing hash and archive reference | Many change orders may reference the same drawing revision. |
| Cost revision | K-32; quantity, unit price and total | Approval references the same cost content. |
| Approval record | Person, role, content references and timestamp | Above the threshold, two distinct authorised approvers are required. |
Change order
- Authoritative attributes
- N-32; business identity and status
- Relationship
- Has immutable submitted revisions.
Drawing revision
- Authoritative attributes
- P-32; drawing hash and archive reference
- Relationship
- Many change orders may reference the same drawing revision.
Cost revision
- Authoritative attributes
- K-32; quantity, unit price and total
- Relationship
- Approval references the same cost content.
Approval record
- Authoritative attributes
- Person, role, content references and timestamp
- Relationship
- Above the threshold, two distinct authorised approvers are required.
Permitted state transitions
| Starting point | Target | Precondition |
|---|---|---|
| entwurf | eingereicht | Drawing, scope of work and amount in cents are frozen. |
| eingereicht | eingereicht | A new revision before approval increments the version and invalidates consent to the old content. |
| eingereicht | freigegeben | All required approvals bind the same content. |
| eingereicht | abgelehnt | Approvers record the reason for rejection. |
| freigegeben | abgeschlossen | Construction management confirms documented implementation of the approved scope. |
| abgelehnt or abgeschlossen | terminal | Changes require a new change order. |
entwurf
- Target
- eingereicht
- Precondition
- Drawing, scope of work and amount in cents are frozen.
eingereicht
- Target
- eingereicht
- Precondition
- A new revision before approval increments the version and invalidates consent to the old content.
eingereicht
- Target
- freigegeben
- Precondition
- All required approvals bind the same content.
eingereicht
- Target
- abgelehnt
- Precondition
- Approvers record the reason for rejection.
freigegeben
- Target
- abgeschlossen
- Precondition
- Construction management confirms documented implementation of the approved scope.
abgelehnt or abgeschlossen
- Target
- terminal
- Precondition
- Changes require a new change order.
Atomic changes and versions
- Content reference
- The example comprises 20 units at 25000 cents, totalling 500000 cents: exactly the internal review threshold. A document hash binds the stored bytes; a URL alone may later point to a different drawing revision.
- Shared commit
- The change order API validates the change-order version, drawing hash, scope hash, cost revision and amount in cents. It writes the business change, command result and any pending work in one transaction. Commit makes these changes durably visible together. Before commit, rollback ends the attempt without partial effects.
- Concurrency
- A new drawing revision and approval both expect version 6. If the drawing change wins, the old approval request is invalidated. If approval wins, it binds the old scope; the new drawing creates a new change order requiring review and leaves the approval unchanged.
- Terminal completion
- Completed change orders receive no cost changes; rejected change orders are resubmitted under a new identity.
Cover the full scope of the case
- Concrete rule
- At 499999 and 500000 cents, this fictional workflow requires one authorised approver; at 500001 cents, it requires two distinct approvers. The same person approving twice does not satisfy the rule. Each consent binds the same drawing, scope and cost revision.
Derive storage needs from access patterns
- Authoritative relational datastore
- A change order has immutable submitted revisions, and several change orders may reference the same drawing revision. The design therefore uses a relational metadata store with uniqueness constraints and short transactions. Historical versions remain referenceable; a rebuildable read model must not overwrite authoritative state.
- Large content and measurement series
- Immutable files reside in a separate artifact or document store; their hash references become available for approval only after the files are fully stored.
A drawing change creates a new revision requiring review
A drawing change creates a new revision requiring review.
A new drawing revision and approval both expect version 6. If the drawing change wins, the old approval request is invalidated. If approval wins, it binds the old scope; the new drawing creates a new change order requiring review and leaves the approval unchanged.
Completed change orders receive no cost changes; rejected change orders are resubmitted under a new identity. The exercise specifies the input and expected result.
- Alternative considered
- Separate unversioned changes allow an older state to overwrite the newer one.
- Trade-off
- Changes to change order N-32 are serialised briefly.
- Reassess
- Measurable waits for two approvals and one drawing change on the same change order call for a review of transaction duration.
Try it yourself
Explain the two possible winner orders in the case contract. Also determine the behaviour after terminal completion.
A hint for your attempt
Content revision and aggregate version have different tasks.
Compare with a possible solution
- Concurrency
- A new drawing revision and approval both expect version 6. If the drawing change wins, the old approval request is invalidated. If approval wins, it binds the old scope; the new drawing creates a new change order requiring review and leaves the approval unchanged.
- Completion
- Completed change orders receive no cost changes; rejected change orders are resubmitted under a new identity.
Apply to your project
Which states must remain protected in your model against late replay?