System Design Atlas

Generation forecasts and energy balances

04 / 10Worked example

Interfaces

How does the Approve forecast contract distinguish a retry from new intent?

The load profile leads to the concrete command “Approve forecast”. Its payload includes interval, model version, input hash and forecast energy. An idempotency key recognises the same intent after a response is lost; an aggregate version protects the changing business state.

Starting point Interval corrections need a separate load profile.

Assumptions for the example case

A fictional example design for a generation facility using fixed 15-minute intervals and separate forecast and measurement versions. Each interval spans 900 seconds, inclusive at the start and exclusive at the end; a measurement at exactly 900 seconds belongs to the next interval. All figures and test targets are illustrative assumptions.

Commands, retries and current state

Command and historical result

Energy balance interfaceCompare forecast run P-33 with measurement revision M-33
Bilanzoberfläche → Prognose-APICheck content and expected version
Forecast APIAccept the command or recognise a replay
Prognose-API → ErgebnisjournalCommit the result before responding
Result journalFingerprint + stored record

Identical replay returns the stored record; changed content produces a conflict.

Approve forecast binds the interval, model version, input hash and forecast energy. The same key refers to the stored result; altered content produces a conflict.

Proposed API for this example

  1. POST/energieprognose/{id}/commands

    Approve the forecast

    Input
    Interval, model version, input hash and forecast energy; expected aggregate version, authorised role and stable command key.
    Result
    Durably stored business result and new version; version or content conflicts produce no partial effects. An accepted external request receives an open status.
    Retry behaviour
    The key is scoped to the actor, operation and business object. After authentication, first compare the existing result and canonical content: identical content returns the stored evidence; changed content produces a conflict. Only new keys trigger validation of the current version.
  2. GET/energieprognose/{id}

    Read the current business state and reason for investigation.

    Input
    Authorised identity and business object.
    Result
    Forecast run with its current version, evidence and reason for outstanding processing.
    Retry behaviour
    Repeating a read creates no business change; access is checked again.

Additional state changes

OperationInputResult and protection
Accept a measurement revisionFacility, interval, source revision, unit and valueThe newer revision becomes current; older revisions retain their historical provenance.
ComparisonApproved forecast and complete measurement revisionCreate a new comparison revision; reuse the result for identical inputs.
Complete the comparisonEnergy balance team, current comparison revision and validation resultverglichen → abgeschlossen; a later correction creates another comparison revision.

Accept a measurement revision

Input
Facility, interval, source revision, unit and value
Result and protection
The newer revision becomes current; older revisions retain their historical provenance.

Comparison

Input
Approved forecast and complete measurement revision
Result and protection
Create a new comparison revision; reuse the result for identical inputs.

Complete the comparison

Input
Energy balance team, current comparison revision and validation result
Result and protection
verglichen → abgeschlossen; a later correction creates another comparison revision.

Messages across the external boundary

Source contract
ENTSO-E distinguishes published generation, load and other energy data. The learning case uses its own intervals and its own comparative architecture.
System responsibility
Accept a new measurement revision durably, then start a new comparison calculation. A late job using an older measurement revision may update the current comparison reference only after a version check; otherwise its result remains historical.

Approval binds the model and input version

Approval binds the model and input version

Approval binds the model and input version.

Approve forecast may arrive again after a response is lost.

Interval, model version, input hash and forecast energy must remain identical on replay. The exercise specifies the input and expected result.

Alternative considered
A key stored only in volatile memory loses its evidence on restart.
Trade-off
The journal for Approve forecast requires durable retention and protected access.
Reassess
The documented retry window and journal volume determine the future archiving strategy.

Try it yourself

For Approve forecast, predict the outcomes of an identical retry, the same key with changed forecast energy, and a new key with a stale version.

A hint for your attempt

Retry identity and current state require separate checks.

Compare with a possible solution
Identical
The saved result for forecast run P-33 is returned; the effect is not repeated.
Changed
The same key with altered canonical content results in conflict.
New intent with a stale version
A new key with a stale version is rejected before any business change. The interface reloads the current state and asks the user to confirm the decision again.

Apply to your project

Which input fields make two change intentions different in your project?

Next, corrections extend the comparison history.