imsys

Events and erasure

Receive signed read outcomes from the GWA desk, bind gateways to their households and erase a household on request.

The desk tells other platforms what happened to each read, and forgets a household when it is asked to. Events are CloudEvents 1.0 in structured JSON, signed with Standard Webhooks. Every event is about a household's meter, so each one carries dataclassification: confidential, dataregulation: GDPR and datacategory: standard.

The catalogue

  • de.imsys.gateway.read.completed: a read's readings are committed. Schema v1 · example
  • de.imsys.gateway.read.failed: the gateway could not read its meter. Schema v1 · example
  • de.imsys.gateway.read.superseded: a pending read was replaced by a successor. Schema v1 · example
  • de.imsys.metering-point.erased: the desk erased a household. Contract erasure@1 (urn:open-utility-stack:erasure:1) · example
  • de.imsys.erasure.confirmed: the desk answered another platform's erasure. Contract erasure@1 confirmation (urn:open-utility-stack:erasure:1#/$defs/Confirmation) · example

Route on dataschema, never on type. The schemas are closed: a property the schema does not list is invalid, and an additive change keeps the URI. Deduplicate on source and id. An id names the fact (read-42-completed), so a redelivery always has the same one. subject repeats the client_reference the submitter gave the read through the REST API. partitionkey is the metering point, or gateway:<recipient> while none is bound. Values are exact decimals in Wh, as strings. Rust consumers can name the types through the gwa-events crate.

Bind a gateway to its household

A read event names the metering point bound when the read was submitted. Bind it before the first read, together with the controllable units behind the gateway that other platforms know (an EMS target, for example):

gwad installation set 0e5453540000000001 --metering-point DE0001234567890123456789012345678 --unit hp-1
gwad installation get 0e5453540000000001

A metering point or unit belongs to one gateway. Running set again replaces the binding. Readings taken under the old binding keep the old metering point.

Deliver events

Add an events section to the provisioning policy and restart gwad ui:

"events": {
  "source": "https://gwa.example/tenants/lab/imsys",
  "inbound": "127.0.0.1:8471",
  "senders": [{ "name": "esales", "keys": ["keys/esales.whsec"] }],
  "subscribers": [{ "name": "meterstore", "url": "https://meterstore.example/events",
                    "key": "keys/meterstore.whsec" }]
}

source names your deployment and tenant. Key files hold one whsec_ secret each and sit beside the policy. A sender can list two keys while you rotate. A subscriber URL must use HTTPS, or HTTP to a loopback address. Add "ca_file" to trust a private CA, which then becomes the only trust anchor for that subscriber.

Each event is written in the same transaction as the read or erasure it reports. The desk posts it as application/cloudevents+json with webhook-id set to the event id. A 2xx answer acknowledges it. Until then, later events for that subscriber wait, and the desk retries with a backoff of one second up to one minute. Events every subscriber has acknowledged are deleted after seven days.

gwad events list            # each event with the subscribers it reached and those still pending
gwad events show read-42-completed

Erase a household

From the desk, by metering point, by unit or by gateway (device, the 18-digit recipient):

gwad erase metering-point DE0001234567890123456789012345678 --basis request --client-reference dsar-2026-11-0173

In one transaction, the desk deletes every reading taken for that metering point and its read events, removes the metering point from each read and deletes the binding. It then sends erasure@1 to its subscribers, naming the metering point and listing in also_known_as its units and the gateway it was bound to (device, the recipient in lower-case hex, as read events carry it). A gateway outlives its households: a consumer erases what it filed under these references up to erased_at, not what a later household brought. A read still in flight stores nothing. The dispatch history stays, because it names only the gateway and the employee; without the binding, nothing in the desk links it to the household any more. The read page says "The readings were erased".

Another platform erases through the inbound listener: POST /events with a signed erasure@1 event. The desk finds the household by subject and also_known_as (kinds metering-point, unit and device, the gateway recipient in hex), erases it as above and sends erasure.confirmed with causationid set to the request's id. The confirmation's outcome is anonymised: the readings and the binding are gone, and the dispatch history the desk keeps links to the household only through the metering point operator's own mapping, as erasure@1 defines it. The listener answers 202 with {"outcome":"anonymised"}, "none-held", "duplicate" for a repeat of the same source and id, or "ignored" for another dataschema. An unsigned, wrongly signed or stale request gets 401, one without a known dataclassification 400, and a body over 64 KiB 413. Confirmations go only to configured subscribers. The desk never posts to confirm_to.

Bind the inbound listener to loopback and put your gateway or mesh in front of it. The signature identifies the sender. The listener changes nothing for a request it cannot verify.

Check your consumer

uv run xtask/check-events.py captured.json validates a JSON array of the events you received against their schemas, and the erasure@1 ones against the umbrella profile.