Rehearse a protocol exchange
Exercise local Control Measures and OpenADR peers and inspect the recorded outcomes.
Run a controller and a development MSB🔗
Install the separate developer executable from the repository root.
cargo install --locked --path tools/fms-lab
Use fms-lab for the live protocol exchange and fmsd to inspect its output. The built-in recorded investigation runs with the edge executable alone.
In a directory where you can write a new log, start the synthetic metering operator and run the controller. Give each process its own 24-hour TLS identity. The lab uses its bundled commissioning example.
fms-lab msb-identities --out .fms-msb-lab
fms-lab msb-peer --tls-dir .fms-msb-lab/msb &
peer=$!
Once the peer prints its listening address, run the controller in the same shell.
fms-lab dispatch-demo --tls-dir .fms-msb-lab/controller --evidence exchange.jsonl
kill "$peer"
The example asks for 5 kW at ems-1. Its two wallboxes have a combined protected floor of 7.56 kW, so the controller sends 7.56 kW to resource C1137355923. After a successful final response, it sends a separate release. The command and callback listeners default to 127.0.0.1:8791 and 127.0.0.1:8792. To change either port, pass the same --msb-port and --callback-port options to both commands.
The role directories contain a private key, a certificate, the trusted development CA and the opposite role’s public certificate. Keep the parent directory private to your OS account. Setup requires a new directory and discards the CA signing key. If interrupted during setup, generate a fresh pair in a new directory. To rotate, generate a new pair in another private directory and restart both processes with their corresponding role directories. The TLS listeners and destinations stay on IPv4 loopback.
The HTTP-only development profile remains available by omitting --tls-dir on both sides and setting the same FMS_MSB_DEMO_TOKEN in both environments. Selecting a TLS directory requires certificate authentication throughout that run.
| Peer option | Expected evidence | Controller exit |
|---|---|---|
--outcome success (default) | Final success for the limit and a separate final success for release | 0 |
--outcome refuse | Final refusal for the limit, with its reason code | 1 |
--outcome refuse-release | Limit succeeded, release refused | 1 |
--outcome preliminary-only | HTTP 202 and preliminary acceptance, then unresolved at the deadline | 1 |
Restart the peer with the chosen option and use a new evidence filename for each run. Set --timeout-seconds 3 on the controller for a short timeout exercise. The controller saves each observation as it happens and prints the final evidence head on both positive and negative runs.
printf 'Evidence SHA-256: '
read -r HEAD_FROM_CONTROLLER
export FMS_REVIEW_TOKEN="$(openssl rand -hex 32)"
fmsd serve --log exchange.jsonl --expect-head "$HEAD_FROM_CONTROLLER"
Paste the controller’s SHA-256 at the prompt. Open the printed desk address, choose Power limit for ems-1, and follow the Limit and Release links to their original receipts. HTTP 202 means the receiver accepted the request. The final callback reports the synthetic peer’s business outcome. Equipment power requires independent measurement. A log containing development receipts is ineligible for field reporting.
Open Mutual TLS · configured MSB certificate in a TLS investigation to compare the expected SHA-256 with the MSB leaf certificate. This pin is also present on a withheld limit or a failed connection. On an unresolved limit or release, the desk tells you whether the receiver returned HTTP 202. If acceptance is missing, check the listener, role certificates, pins and expiry. After acceptance, inspect the callback path and the order reference.
Rehearse a delayed grid result🔗
With the development MSB listening, run both cases from the same shell. The controller replays the two mixed-feeder measurements and decision ticks on a shifted clock. Both measurements are three seconds old when the EMS decision becomes available.
fms-lab dispatch-demo --tls-dir .fms-msb-lab/controller --grid-result-age 30 --evidence fresh.jsonl
fms-lab dispatch-demo --tls-dir .fms-msb-lab/controller --grid-result-age 301 --evidence withheld.jsonl
The first run issues the grid-derived limit and release. The second exits with status 1, records Limit withheld, and sends zero orders. Open its log with the printed head in the desk. Grid result available, First-issue check, and Decision age at check explain the outcome. The original receipt records the precise check time. Obtain a new grid determination before attempting another reduction.
The five-minute interval ends when the DSO initiates the reduction toward the MSB. The controller checks the unrounded clock immediately before sending, including time spent preparing the evidence. Exactly 300 seconds is eligible while the command is valid. Measurement freshness, command expiry and asynchronous peer response have separate clocks. The local controller applies the same conservative age bound to original operator limits. A release can still restore ordinary operation. VDE FNN recommendation 2g
Follow an automatic limit through recovery🔗
With the development MSB running in another terminal, use one of these scenarios. Each creates a new evidence file and prints its SHA-256 head.
fms-lab dispatch-demo --tls-dir .fms-msb-lab/controller --closed-loop restored --evidence restored.jsonl
fms-lab dispatch-demo --tls-dir .fms-msb-lab/controller --closed-loop missing --evidence missing.jsonl
Set a private FMS_REVIEW_TOKEN. Open the file with fmsd serve --log restored.jsonl --expect-head HASH, using the head from that run. Search Incidents for ems-1, open a power limit, and read Feeder response. Select a timestamp to inspect the meter tick, or a peer outcome to open the matching wire receipt. REST GET /api/v1/incidents/{id} and MCP get_incident expose the same sequence in feeder_response.
| What the operator sees | What happened |
|---|---|
| 25 kW, Above rating | Transformer T1 is rated at 18 kW. The engine sends a 7.56 kW ceiling for the commissioned EMS. The peer confirms it. The next transformer sample still reads 25 kW. |
| 4 kW, Within rating | Fresh readings give the engine room to restore. It raises the ceiling to 10.78, 12.39 and 13.195 kW before issuing a separate release. Every order has its own transaction and peer outcome. |
| Effect unknown in the missing scenario | The follow-up sample is absent. The engine records stale data, keeps the existing limit within its original validity and sends no release during the exercise. |

The lab uses synthetic premises and transformer meters. The restoration interval and meter freshness window are both one second so the exercise finishes in seconds using the real wire clock. Transformer demand includes other loads. An individual appliance’s contribution requires a measurement at that appliance. Control Measures wire contract
Match orders at the receiving MSB🔗
Start with the development lab setup.
An integration reviewer can check which limits and releases reached a receiver. Start a fresh capture for one controller run. Use a new directory private to the receiver owner. In the peer terminal, run the following.
fms-lab msb-identities --out roles
fms-lab msb-peer --tls-dir roles/msb --transcript ingress.jsonl
Once the peer is listening, open another terminal in the same directory.
fms-lab dispatch-demo --closed-loop restored --tls-dir roles/controller --evidence controller.jsonl
Retain the controller's printed chain head. Stop the peer and have its owner retain the SHA-256 of the completed transcript. Inspect the pair locally, or supply both independently retained values for a handoff.
fmsd reconcile-ingress controller.jsonl ingress.jsonl
fmsd reconcile-ingress controller.jsonl ingress.jsonl --expect-head "$CONTROLLER_HEAD" --expect-sha256 "$TRANSCRIPT_SHA256" --json
Find the Order ID under the incident’s limit or release in the desk. The same UUID identifies the order in the report. Check the commissioned SR-ID and limit in watts against the receiver’s observation. A withheld limit should be absent from the capture. A business refusal can follow a successful match at ingress. For an unexpected UUID, check whether the capture includes another controller run. For a missing row, check the receiver’s capture interval and the controller’s submission stage.
An independent receiver can export the same version 1 JSONL format. Write one newline-terminated row per admission. Use whole watts for a limit and {"kind":"release"} for a release. The reader accepts up to 32,768 rows, 4,096 bytes per row and 8 MiB in total. The paired controller log can be up to 128 MiB.
{"version":1,"order_reference":"f62898e6-940f-4e5d-a32e-803282dd9fae","resource":"C1137355923","operation":{"kind":"limit","watts":7560},"received_at":"2026-11-24T08:01:02.123Z"}
The two timestamps belong to different observers. The controller reads its clock immediately before the issue check. The MSB reads its clock when the authenticated application admits the command, before it returns HTTP 202. A receiver more than --clock-tolerance-ms (default 1000) behind the controller is clock-reversed; within it, the order matches and the report keeps the measured difference and the tolerance. Use 0 only when both read one clock. A timing qualification needs observer clock uncertainty and agreed timestamp locations. Equipment response needs a downstream measurement. RFC 7679 §3.7
Rehearse partial delivery to two EMS targets🔗
Start with the development lab setup.
Two synthetic premises draw 35 kW through transformer T1, rated at 26 kW. The controller calculates separate ceilings for their commissioned resources. The development profile allows both targets to change in one tick so the MSB can refuse the first order while the second is still waiting. Each process uses its own generated TLS identity.
In a fresh directory, start the receiver.
fms-lab msb-identities --out roles
fms-lab msb-peer --tls-dir roles/msb --outcome refuse-first-target --transcript ingress.jsonl
In a second terminal in the same directory, run the controller.
fms-lab dispatch-demo --closed-loop two-target --tls-dir roles/controller --evidence feeder.jsonl| Target | Commissioned SR-ID | Protected floor and first ceiling | MSB reply |
|---|---|---|---|
| ems-1 · two wallboxes | C1137355923 | 7.56 kW | Refused |
| ems-2 · one wallbox | C1137355949 | 4.20 kW | Succeeded |
The simulated load applies only a ceiling with a positive final reply. On the second tick T1 reads 30.2 kW. The engine issues a fresh limit for ems-1 and holds ems-2. The controller finishes with exit 1 because a business order was refused. A transport or evidence-write failure instead stops submission. For a comparison, start a new peer with --outcome success and fresh filenames. Both limits succeed, T1 reads 23.76 kW, and the controller exits 0.
Stop the MSB, then run fmsd reconcile-ingress feeder.jsonl ingress.jsonl. All three admissions in the mixed run reconcile, including the two that subsequently received refusals. Open feeder.jsonl with the authenticated desk. In either power-limit incident, Feeder response shows one transformer sample per tick. Follow a target name to its intervention or a peer reply to the original evidence. The development MSB and household loads are simulated.
Review an OpenADR site cap🔗
cargo run --locked -p fms-lab -- openadr-site-cap > applied.json
cargo run --locked -p fms-lab -- openadr-site-cap --missed > missed.json
cargo run --locked -p fmsd -- serve --demo --port 0
Open the printed desk URL, choose OpenADR rehearsal and select applied.json. Find the event and receipt IDs. Read the two site meters before the cap, at its start and at expiry. During the one-hour window the dedicated charging site draws 7.56 kW, then returns to 14 kW at expiry. The comparison site draws 9 kW throughout. Select missed.json: the addressed site reports receipt, yet its meter stays at 14 kW while the cap applies. The desk reads the file in your browser. The timestamps and meters belong to the synthetic run.
The optional openadr feature on fms-adapters maps a currently valid, first-delivery EMS limit to one targeted OpenADR 3.1 IMPORT_CAPACITY_LIMIT interval in KW. The dedicated site's flexible load accounts for all import behind its meter. Commission that relationship explicitly. A household meter that also serves unrelated loads requires a different profile. The VTN verifies each VEN's target grants. This profile uses a private EVENT_STATUS report carrying EVENT_RECEIVED. The cap is fixed to the whole watt and written by flexibility's openadr::event in exact kW, so the receiving peer's openadr::limits reads back the same watts. OpenADR implementation and test suite
The receiving peer does not reuse FMS arithmetic. It decodes the event with flexibility, which reads the cap as exact watts and refuses missing KW units, a repeated payload or a fraction of a watt. The recording names that decoder in peer_decoder beside the OpenADR release of each side. The CLS.EEDI integration test maps the received Control Measures order to a control-box limit the same way.