Declare a unit contract for measurement (static unitPolicy + CONTRACT.md) #1
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Gap
measurementdoes not declare astatic unitPolicyon its specificClass, andCONTRACT.mddoes not document unit semantics for the value flowing through the node. Every other domain node in EVOLV (pumpingStation,machineGroupControl,rotatingMachine, …) declares one viaUnitPolicy.declare({ canonical, output, requireUnitForTypes }).Where
src/specificClass.js:12— class declares onlystatic name = 'measurement';. Nostatic unitPolicy = …block.CONTRACT.md— documentsmsg.topiccommand surface but has no canonical/output unit table.Why this matters
Without a declared contract:
pumpingStation,rotatingMachine) infer the unit fromassetType+ variant context instead of validating against a contract. That is exactly the class of mismatch that caused theassetType: "flow"vs"flow-electromagnetic"integration bug previously logged in project memory.What other nodes do (reference)
Definition of done
static unitPolicydeclared onMeasurementinsrc/specificClass.js. Covers at minimum the assetTypesmeasurementactually supports today (flow, pressure, level, volume, power, temperature, …).requireUnitForTypeschoice justified —measurementis the source node so strictness usually lives at the parent, but the policy should still be explicit.CONTRACT.mdextended with a "Units" section: canonical vs. output unit per type, and the contract a parent can rely on when consuming ameasurementvalue.test/basic/exercising the unit policy (canonical conversion, reject-on-missing-unit ifrequireUnitForTypesincludes the type).pumpingStation/rotatingMachine/monster/dashboardAPIconsumers — does any of them currently do unit guesswork that becomes redundant oncemeasurementdeclares its policy? Remove the guesswork in the same PR.Context
Surfaced during the 2026-05-19 fix for pumpingStation level-based control sending
%to MGC'shandleInput(which expects canonical m³/s). The MGC fix added an explicitsetDemand(value, unit)entry point as the single source of truth for unit resolution at that boundary; the equivalent contract on themeasurementsource side is still missing.