Data and states
Which changes to a return must commit together, and what remains protected after completion?
The contracts require an authoritative store for return E-37. For 150000 cents, the fictional model calculates (150000−100000)×0.10=5000 cents. Exactly 100000 cents produces zero. This deliberately simple formula tests the architecture and describes no German tax law. State and command result are stored together so the same intent remains traceable after restart.
Starting point Approval binds the tax return and document hash.
Assumptions for the example case
A fictional administrative workflow using an invented calculation model to bind return year, rule revision and draft assessment notice. The model uses an allowance of 100000 cents; only the excess is charged at 10 % and rounded to whole cents using round-half-up. All figures and test targets are illustrative assumptions.
Authoritative data and permitted state transitions
Data and states
Approval binds exactly one return revision and one rule revision from the same model year.
Domain entities and relationships
| Entity | Authoritative attributes | Relationship |
|---|---|---|
| Return revision | E-37; model year and immutable data | Correction creates a new version. |
| Rule revision | R-37; invented formula and rounding | Each calculation uses exactly one rule revision from the same model year. |
| Draft assessment notice | B-37; return, rule, result and document hash | Release applies exclusively to this content. |
| Transmission order | Document hash, recipient and technical receipt | Technical completion makes no claim of legally effective notification. |
Return revision
- Authoritative attributes
- E-37; model year and immutable data
- Relationship
- Correction creates a new version.
Rule revision
- Authoritative attributes
- R-37; invented formula and rounding
- Relationship
- Each calculation uses exactly one rule revision from the same model year.
Draft assessment notice
- Authoritative attributes
- B-37; return, rule, result and document hash
- Relationship
- Release applies exclusively to this content.
Transmission order
- Authoritative attributes
- Document hash, recipient and technical receipt
- Relationship
- Technical completion makes no claim of legally effective notification.
Permitted state transitions
| Starting point | Target | Precondition |
|---|---|---|
| eingereicht | in_prüfung | Caseworkers take responsibility for this specific revision. |
| in_prüfung | nachforderung | Missing evidence is named. |
| nachforderung | in_prüfung | Required proof is available as a new documented supplement. |
| in_prüfung | freigabebereit | Calculation and evidence have been reviewed. |
| freigabebereit | freigegeben | Approvers confirm this exact draft. |
| freigegeben | übermittelt | Delivery service acknowledges the same document hash. |
| übermittelt | technisch_abgeschlossen | Caseworkers complete the bounded transmission workflow. |
| eingereicht or in_prüfung or nachforderung or freigabebereit | in_prüfung | Authorised amendment with a new return revision and current version; the old calculation and draft review remain historical and do not apply to the new revision. |
| technisch_abgeschlossen | terminal | Correction and legal follow-up processes receive their own linked processes. |
eingereicht
- Target
- in_prüfung
- Precondition
- Caseworkers take responsibility for this specific revision.
in_prüfung
- Target
- nachforderung
- Precondition
- Missing evidence is named.
nachforderung
- Target
- in_prüfung
- Precondition
- Required proof is available as a new documented supplement.
in_prüfung
- Target
- freigabebereit
- Precondition
- Calculation and evidence have been reviewed.
freigabebereit
- Target
- freigegeben
- Precondition
- Approvers confirm this exact draft.
freigegeben
- Target
- übermittelt
- Precondition
- Delivery service acknowledges the same document hash.
übermittelt
- Target
- technisch_abgeschlossen
- Precondition
- Caseworkers complete the bounded transmission workflow.
eingereicht or in_prüfung or nachforderung or freigabebereit
- Target
- in_prüfung
- Precondition
- Authorised amendment with a new return revision and current version; the old calculation and draft review remain historical and do not apply to the new revision.
technisch_abgeschlossen
- Target
- terminal
- Precondition
- Correction and legal follow-up processes receive their own linked processes.
Atomic changes and versions
- Content reference
- For 150000 cents, the invented model (150000−100000)×0.10=5000 cents is calculated. Exactly 100000 cents is zero. This deliberately simple formula serves exclusively for the architectural test and does not describe any German tax law.
- Shared commit
- The assessment API checks return revision, model year, rule revision, calculation result and document hash, then writes the domain change, command result and any pending work in one transaction. Commit makes the changes durably visible together. Before commit, rollback ends the attempt without a partial effect.
- Concurrency
- Amendment and approval both expect version 5. Amendment first prevents approval of the old draft. Approval first preserves the old version; after a fresh read, amendment opens a linked follow-up review.
- Terminal completion
- After technical completion, an amendment changes neither the old document hash nor the calculation result; it creates a linked follow-up review.
Cover the full scope of the case
- Concrete rule
- For whole-cent inputs, the fictional calculation is round_half_up(max(0, assessment base − 100000) × 1/10). 99999, 100000 and 100001 cents each produce 0 cents; 100005 cents produces 1 cent. This tests the allowance boundary separately from the rounding boundary.
Derive storage needs from access patterns
- Authoritative relational datastore
- An amendment creates a new version. Each calculation uses exactly one rule revision from the same model year. The design therefore uses a relational metadata store with uniqueness constraints and short transactions. Historical revisions remain referenceable; a rebuildable read view 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.
Draft assessment notices remain immutable versions
Draft assessment notices remain immutable versions.
Amendment and approval both expect version 5. Amendment first prevents approval of the old draft. Approval first preserves the old version; after a fresh read, amendment opens a linked follow-up review.
After technical completion, an amendment changes neither the old document hash nor the calculation result; it creates a linked follow-up review. Your test defines the input and expected result.
- Alternative considered
- Separate unversioned changes allow an older state to overwrite the newer one.
- Trade-off
- Changes to Declaration E-37 are briefly serialized.
- Reassess
- Measured waiting times during concurrent amendment and approval justify reviewing transaction duration.
Test the correction path
- Input and expected result
- An authorised amendment with a new return revision and current aggregate version moves eingereicht, in_prüfung, nachforderung or freigabebereit → in_prüfung. The old calculation and draft review remain historical and are invalid for the new revision. Approval must bind the current return revision, rule revision and new document hash. After freigegeben, only a linked follow-up review is created. The data-state diagram and model show the return path before approval. Test: freigabebereit, version 5; amendment wins → in_prüfung, version 6, old draft approval invalid; approval with version 5 → conflict. Reverse order: approval wins → immutable approved revision; amendment after a fresh read → separate follow-up review.
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
- Amendment and approval both expect version 5. Amendment first prevents approval of the old draft. Approval first preserves the old version; after a fresh read, amendment opens a linked follow-up review.
- Completion
- After technical completion, an amendment changes neither the old document hash nor the calculation result; it creates a linked follow-up review.
Apply to your project
Which states must remain protected in your model against late replay?