From c0c6afbae13b29abddab7e52a7f6a1f649ef06a5 Mon Sep 17 00:00:00 2001 From: wes-johnson Date: Wed, 2 Dec 2026 00:56:20 +0000 Subject: [PATCH 01/10] [#665] Stop the TCK requiring a datatype in BIRTH messages SessionEstablishmentTest required the Metric datatype field in an NBIRTH and a DBIRTH, in two places. payloads-metric-datatype-req was scored by requiring every metric to carry it. That assertion contradicts topics-nbirth-no-metadata and topics-dbirth-no-metadata, which say a BIRTH MUST NOT convey a metric datatype because it is conveyed only in the META messages. Those two checks now score the no-metadata assertions instead, inverted to require that no metric carries the field, through setResultIfNotFail so one offending BIRTH is not erased by a later conforming one. Neither assertion had a test before this. topics-nbirth-metrics and topics-dbirth-metrics carried the same superseded rule a second time, failing a metric with no datatype. Their requirement text asks only that each metric include its current value and be identified by alias or name, so the datatype term is dropped. Without this the two checks would be mutually unsatisfiable and a conforming Edge Node would still fail, under a different assertion. The two new @SpecAssertion entries name PAYLOADS_DESC_NBIRTH and PAYLOADS_DESC_DBIRTH, the sections the audit actually places these assertions in. An earlier revision named the TOPICS_BIRTH_MESSAGE_* sections, which compile but do not bind, so the coverage report still reported both assertions as uncovered and listed the annotations as unmatched. The DBIRTH entry sits with the other DBIRTH assertions on checkDBirth rather than on checkNBirth. The specification side of this contradiction, including the removal of payloads-metric-datatype-req itself, is handled by the commits that follow. The broader Chapter 4 and Chapter 6 duplication stays with Verified by executing both predicates together against hand-built metrics: a conforming BIRTH metric now satisfies both assertions, one carrying a Metric datatype fails the no-metadata rule while still satisfying the metrics rule, and a metric with no value still fails the metrics rule. The coverage report now lists both assertions as covered and no longer lists the annotations as unmatched. --- .../test/edge/SessionEstablishmentTest.java | 43 +++++++++---------- 1 file changed, 21 insertions(+), 22 deletions(-) diff --git a/tck/src/main/java/org/eclipse/sparkplug/tck/test/edge/SessionEstablishmentTest.java b/tck/src/main/java/org/eclipse/sparkplug/tck/test/edge/SessionEstablishmentTest.java index 3193cc89..b96c1d49 100644 --- a/tck/src/main/java/org/eclipse/sparkplug/tck/test/edge/SessionEstablishmentTest.java +++ b/tck/src/main/java/org/eclipse/sparkplug/tck/test/edge/SessionEstablishmentTest.java @@ -108,7 +108,7 @@ public class SessionEstablishmentTest extends TCKTest { ID_MESSAGE_FLOW_DEVICE_BIRTH_PUBLISH_DBIRTH_MATCH_EDGE_NODE_TOPIC, ID_PAYLOADS_NBIRTH_BDSEQ_REPEAT, ID_PAYLOADS_NDATA_ORDER, ID_PAYLOADS_DDATA_ORDER, ID_PAYLOADS_ALIAS_UNIQUENESS, ID_TOPICS_NBIRTH_TOPIC, ID_TOPICS_DBIRTH_TOPIC, ID_CASE_SENSITIVITY_METRIC_NAMES, ID_PAYLOADS_NAME_BIRTH_DATA_REQUIREMENT, - ID_PAYLOADS_ALIAS_BIRTH_REQUIREMENT, ID_PAYLOADS_METRIC_DATATYPE_REQ); + ID_PAYLOADS_ALIAS_BIRTH_REQUIREMENT, ID_TOPICS_NBIRTH_NO_METADATA, ID_TOPICS_DBIRTH_NO_METADATA); private final @NotNull TCK theTCK; private @NotNull Utilities utilities = null; @@ -537,8 +537,8 @@ public Optional checkWillMessage(final @NotNull ConnectPacket section = Sections.PAYLOADS_P_NDEATH, id = ID_PAYLOADS_NDEATH_BDSEQ) @SpecAssertion( - section = Sections.PAYLOADS_P_METRIC, - id = ID_PAYLOADS_METRIC_DATATYPE_REQ) + section = Sections.PAYLOADS_DESC_NBIRTH, + id = ID_TOPICS_NBIRTH_NO_METADATA) @SpecAssertion( section = Sections.OPERATIONAL_BEHAVIOR_DATA_PUBLISH, id = ID_OPERATIONAL_BEHAVIOR_DATA_PUBLISH_NBIRTH_VALUES) @@ -648,7 +648,7 @@ public void checkNBirth(final @NotNull PublishPacket packet) { metric_names.add(name); } - if (!m.hasName() || !Utils.hasValue(m) || !m.hasDatatype()) { + if (!m.hasName() || !Utils.hasValue(m)) { testResults.put(ID_TOPICS_NBIRTH_METRICS, setResult(false, TOPICS_NBIRTH_METRICS)); } else if (testResults.get(ID_TOPICS_NBIRTH_METRICS) == null) { testResults.put(ID_TOPICS_NBIRTH_METRICS, setResult(true, TOPICS_NBIRTH_METRICS)); @@ -673,14 +673,12 @@ public void checkNBirth(final @NotNull PublishPacket packet) { testResults.put(ID_PAYLOADS_NBIRTH_BDSEQ_REPEAT, setResult(birthBdSeq == deathBdSeq, PAYLOADS_NBIRTH_BDSEQ_REPEAT)); - if (testResults.get(ID_PAYLOADS_METRIC_DATATYPE_REQ) == null - || testResults.get(ID_PAYLOADS_METRIC_DATATYPE_REQ).contains(Constants.PASS)) { - logger.debug( - "Check req: The datatype MUST be included with each metric definition in NBIRTH and DBIRTH messages."); - int hasDataTypeCnt = countDataType(metrics); - testResults.put(ID_PAYLOADS_METRIC_DATATYPE_REQ, - setResult(hasDataTypeCnt == metrics.size(), PAYLOADS_METRIC_DATATYPE_REQ)); - } + // A metric's datatype is conveyed in the NMETA and NMMETA, not the NBIRTH, so an NBIRTH + // carrying one violates topics-nbirth-no-metadata. + logger.debug( + "Check req: The NBIRTH MUST NOT be used to convey metric datatype, properties, or metadata."); + Utils.setResultIfNotFail(testResults, countDataType(metrics) == 0, ID_TOPICS_NBIRTH_NO_METADATA, + TOPICS_NBIRTH_NO_METADATA); logger.debug("Check Req: NBIRTH bdSeq must match bdSeq provided in Will Message payload of connect packet"); testResults.put(ID_PAYLOADS_NBIRTH_BDSEQ, setResult(birthBdSeq != -1, PAYLOADS_NBIRTH_BDSEQ)); testResults.put(ID_TOPICS_NBIRTH_BDSEQ_INCLUDED, setResult(birthBdSeq != -1, TOPICS_NBIRTH_BDSEQ_INCLUDED)); @@ -725,6 +723,9 @@ public void checkNBirth(final @NotNull PublishPacket packet) { @SpecAssertion( section = Sections.PAYLOADS_DESC_DBIRTH, id = ID_TOPICS_DBIRTH_METRICS) + @SpecAssertion( + section = Sections.PAYLOADS_DESC_DBIRTH, + id = ID_TOPICS_DBIRTH_NO_METADATA) @SpecAssertion( section = Sections.OPERATIONAL_BEHAVIOR_DATA_PUBLISH, id = ID_OPERATIONAL_BEHAVIOR_DATA_PUBLISH_DBIRTH_VALUES) @@ -872,15 +873,13 @@ public void checkDBirth(final @NotNull PublishPacket packet) { } } - if (testResults.get(ID_PAYLOADS_METRIC_DATATYPE_REQ) == null - || testResults.get(ID_PAYLOADS_METRIC_DATATYPE_REQ).contains(PASS)) { - logger.debug( - "Check req: The datatype MUST be included with each metric definition in NBIRTH and DBIRTH messages."); - List metrics = sparkplugPayload.getContent().getMetricsList(); - int hasDataTypeCnt = countDataType(metrics); - testResults.put(ID_PAYLOADS_METRIC_DATATYPE_REQ, - setResult(hasDataTypeCnt == metrics.size(), PAYLOADS_METRIC_DATATYPE_REQ)); - } + // A metric's datatype is conveyed in the DMETA and DMMETA, not the DBIRTH, so a DBIRTH + // carrying one violates topics-dbirth-no-metadata. + logger.debug( + "Check req: The DBIRTH MUST NOT be used to convey metric datatype, properties, or metadata."); + Utils.setResultIfNotFail(testResults, + countDataType(sparkplugPayload.getContent().getMetricsList()) == 0, + ID_TOPICS_DBIRTH_NO_METADATA, TOPICS_DBIRTH_NO_METADATA); checkPayloadsNameInDataRequirement(sparkplugPayload); checkPayloadsAliasAndNameRequirement(sparkplugPayload); @@ -888,7 +887,7 @@ public void checkDBirth(final @NotNull PublishPacket packet) { Set metric_names = new HashSet(); List metrics = sparkplugPayload.getContent().getMetricsList(); for (Metric m : metrics) { - if (!m.hasName() || !Utils.hasValue(m) || !m.hasDatatype()) { + if (!m.hasName() || !Utils.hasValue(m)) { testResults.put(ID_TOPICS_DBIRTH_METRICS, setResult(false, TOPICS_DBIRTH_METRICS)); } else if (testResults.get(ID_TOPICS_DBIRTH_METRICS) == null) { testResults.put(ID_TOPICS_DBIRTH_METRICS, setResult(true, TOPICS_DBIRTH_METRICS)); From 5d3596b0d7203543b0dd8bf662196220ad66165f Mon Sep 17 00:00:00 2001 From: wes-johnson Date: Wed, 2 Dec 2026 01:54:50 +0000 Subject: [PATCH 02/10] [#665] Make the Topics chapter canonical for the metric datatype rules Seven assertions in the Payloads chapter restated rules the Topics chapter already makes. Six of them were word for word identical to their Topics twin, and the seventh contradicted them. Removed, each replaced by a non-normative pointer to the Topics section that is normative for the message: payloads-nbirth-metrics = topics-nbirth-metrics payloads-nrebirth-metrics = topics-nrebirth-metrics payloads-dbirth-metrics = topics-dbirth-metrics payloads-drebirth-metrics = topics-drebirth-metrics payloads-nmeta-metric-defs = topics-nmeta-metrics payloads-dmeta-metric-defs = topics-dmeta-metrics The four BIRTH assertions also each carried a second copy of "The MUST NOT be used to convey metric datatype, properties, or metadata", which is topics-nbirth-no-metadata and its three siblings - the assertions the preceding commit points the TCK at. payloads-metric-datatype-req required the datatype in NBIRTH and DBIRTH messages, directly contradicting those four. The datatype is conveyed in the META messages, as topics-nmeta-metrics and topics-dmeta-metrics require, so the rule is dropped here and a non-normative comment on the Metric datatype field says where to find it. None of the seven had a TCK test. payloads-metric-datatype-req had the only one, and the preceding commit repointed it at the no-metadata assertions, so nothing scores them and nothing references the generated constants. The TCK still compiles. --- .../chapters/Sparkplug_6_Payloads.adoc | 44 +++++++++---------- 1 file changed, 20 insertions(+), 24 deletions(-) diff --git a/specification/src/main/asciidoc/chapters/Sparkplug_6_Payloads.adoc b/specification/src/main/asciidoc/chapters/Sparkplug_6_Payloads.adoc index 40193499..42d54a5a 100644 --- a/specification/src/main/asciidoc/chapters/Sparkplug_6_Payloads.adoc +++ b/specification/src/main/asciidoc/chapters/Sparkplug_6_Payloads.adoc @@ -817,8 +817,10 @@ link:#payloads_p_datatypes[valid Sparkplug Data Types].*# ** [tck-testable tck-id-payloads-metric-datatype-not-propertyset]#[yellow-background]*[tck-id-payloads-metric-datatype-not-propertyset] The datatype MUST NOT be PropertySet or PropertySetList, which are value types for a property rather than for a metric. A metric's properties are carried in its properties field.*# -** [tck-testable tck-id-payloads-metric-datatype-req]#[yellow-background]*[tck-id-payloads-metric-datatype-req] The -datatype MUST be included with each metric definition in NBIRTH and DBIRTH messages.*# +** Non-normative comment: a metric's datatype is carried in the messages that convey metric +definitions, which are the link:#payloads_desc_nmeta[NMETA] and +link:#payloads_desc_nmmeta[NMMETA] for an Edge Node and the link:#payloads_desc_dmeta[DMETA] +and link:#payloads_desc_dmmeta[DMMETA] for a Device. ** [tck-testable tck-id-payloads-metric-datatype-not-req]#[yellow-background]*[tck-id-payloads-metric-datatype-not-req] The Metric's own datatype field MUST NOT be included with a metric in NDATA or DDATA messages in the Google Protocol Buffers encoding. A metric's datatype is established by the message that defines @@ -1963,9 +1965,8 @@ messages MUST include a payload timestamp that denotes the time at which the mes * [tck-testable tck-id-payloads-nmeta-defid]#[yellow-background]*[tck-id-payloads-nmeta-defid] NMETA messages MUST include a definition_id equal to the content hash of the metric definitions they contain.*# -* [tck-testable tck-id-payloads-nmeta-metric-defs]#[yellow-background]*[tck-id-payloads-nmeta-metric-defs] For -each metric a full NMETA MUST include the metric name and datatype. The metric alias, properties, and -metadata MAY also be included. Aliases are optional.*# +* Non-normative comment: the metric definitions a full NMETA carries are required by the +link:#payloads_desc_nmeta[NMETA] section, which is normative for the NMETA message. * [tck-testable tck-id-payloads-nmeta-cmd-metrics]#[yellow-background]*[tck-id-payloads-nmeta-cmd-metrics] A full NMETA MUST include the definition of every Command-datatype metric the Edge Node exposes, including its command argument and result definitions, so that Host Applications can invoke it via @@ -1990,9 +1991,8 @@ messages MUST include a payload timestamp that denotes the time at which the mes * [tck-testable tck-id-payloads-dmeta-defid]#[yellow-background]*[tck-id-payloads-dmeta-defid] DMETA messages MUST include a definition_id equal to the content hash of the metric definitions they contain.*# -* [tck-testable tck-id-payloads-dmeta-metric-defs]#[yellow-background]*[tck-id-payloads-dmeta-metric-defs] For -each metric a full DMETA MUST include the metric name and datatype. The metric alias, properties, and -metadata MAY also be included. Aliases are optional.*# +* Non-normative comment: the metric definitions a full DMETA carries are required by the +link:#payloads_desc_dmeta[DMETA] section, which is normative for the DMETA message. * [tck-testable tck-id-payloads-dmeta-cmd-metrics]#[yellow-background]*[tck-id-payloads-dmeta-cmd-metrics] A full DMETA MUST include the definition of every Command-datatype metric the Device exposes, including its command argument and result definitions, so that Host Applications can invoke it via DCMD and @@ -2059,10 +2059,9 @@ Edge Node Descriptor in any Sparkplug infrastructure MUST be unique in the syste * [tck-testable tck-id-payloads-nbirth-defid]#[yellow-background]*[tck-id-payloads-nbirth-defid] Every NBIRTH message MUST include a definition_id equal to the content hash of the NMETA that describes this Edge Node, and MUST report values only for metrics defined in that NMETA.*# -* [tck-testable tck-id-payloads-nbirth-metrics]#[yellow-background]*[tck-id-payloads-nbirth-metrics] Each -metric in the NBIRTH MUST include its current value and MUST be identified either by its alias, if an -alias was assigned to it in the referenced NMETA, or otherwise by its metric name. The NBIRTH MUST -NOT be used to convey metric datatype, properties, or metadata.*# +* Non-normative comment: the metrics a NBIRTH carries, and how each one is identified, are +required by the link:#payloads_desc_nbirth[NBIRTH] section, which is normative +for the NBIRTH message. * [tck-testable tck-id-payloads-nbirth-seq]#[yellow-background]*[tck-id-payloads-nbirth-seq] Every NBIRTH message MUST include a sequence number. If no NMETA is published in the BIRTH sequence, the NBIRTH is the first message and its sequence number MUST be 0. If an NMETA is published (sequence @@ -2177,10 +2176,9 @@ Edge Node Descriptor in any Sparkplug infrastructure MUST be unique in the syste * [tck-testable tck-id-payloads-nrebirth-defid]#[yellow-background]*[tck-id-payloads-nrebirth-defid] Every NREBIRTH message MUST include a definition_id equal to the content hash of the NMETA that describes this Edge Node, and MUST report values only for metrics defined in that NMETA.*# -* [tck-testable tck-id-payloads-nrebirth-metrics]#[yellow-background]*[tck-id-payloads-nrebirth-metrics] Each -metric in the NREBIRTH MUST include its current value and MUST be identified either by its alias, if an -alias was assigned to it in the referenced NMETA, or otherwise by its metric name. The NREBIRTH MUST -NOT be used to convey metric datatype, properties, or metadata.*# +* Non-normative comment: the metrics a NREBIRTH carries, and how each one is identified, are +required by the link:#payloads_desc_nrebirth[NREBIRTH] section, which is normative +for the NREBIRTH message. * [tck-testable tck-id-payloads-nrebirth-seq-1]#[yellow-background]*[tck-id-payloads-nrebirth-seq-1] Every NREBIRTH message MUST include a sequence number and it MUST have a value between 0 and 9223372036854775807 (inclusive).*# @@ -2297,10 +2295,9 @@ published.*# * [tck-testable tck-id-payloads-dbirth-defid]#[yellow-background]*[tck-id-payloads-dbirth-defid] Every DBIRTH message MUST include a definition_id equal to the content hash of the DMETA that describes this Device, and MUST report values only for metrics defined in that DMETA.*# -* [tck-testable tck-id-payloads-dbirth-metrics]#[yellow-background]*[tck-id-payloads-dbirth-metrics] Each -metric in the DBIRTH MUST include its current value and MUST be identified either by its alias, if an -alias was assigned to it in the referenced DMETA, or otherwise by its metric name. The DBIRTH MUST -NOT be used to convey metric datatype, properties, or metadata.*# +* Non-normative comment: the metrics a DBIRTH carries, and how each one is identified, are +required by the link:#payloads_desc_dbirth[DBIRTH] section, which is normative +for the DBIRTH message. * [tck-testable tck-id-payloads-dbirth-seq]#[yellow-background]*[tck-id-payloads-dbirth-seq] Every DBIRTH message MUST include a sequence number.*# * [tck-testable tck-id-payloads-dbirth-seq-inc]#[yellow-background]*[tck-id-payloads-dbirth-seq-inc] Every @@ -2400,10 +2397,9 @@ published.*# * [tck-testable tck-id-payloads-drebirth-defid]#[yellow-background]*[tck-id-payloads-drebirth-defid] Every DREBIRTH message MUST include a definition_id equal to the content hash of the DMETA that describes this Device, and MUST report values only for metrics defined in that DMETA.*# -* [tck-testable tck-id-payloads-drebirth-metrics]#[yellow-background]*[tck-id-payloads-drebirth-metrics] Each -metric in the DREBIRTH MUST include its current value and MUST be identified either by its alias, if an -alias was assigned to it in the referenced DMETA, or otherwise by its metric name. The DREBIRTH MUST -NOT be used to convey metric datatype, properties, or metadata.*# +* Non-normative comment: the metrics a DREBIRTH carries, and how each one is identified, are +required by the link:#payloads_desc_drebirth[DREBIRTH] section, which is normative +for the DREBIRTH message. * [tck-testable tck-id-payloads-drebirth-seq]#[yellow-background]*[tck-id-payloads-drebirth-seq] Every DREBIRTH message MUST include a sequence number.*# * [tck-testable tck-id-payloads-drebirth-seq-inc]#[yellow-background]*[tck-id-payloads-drebirth-seq-inc] Every From d825ff58c49f5347808094ef3bde144922ddd6da Mon Sep 17 00:00:00 2001 From: wes-johnson Date: Wed, 2 Dec 2026 01:54:50 +0000 Subject: [PATCH 03/10] [#665] Retire the pre-separation datatype wording in Chapters 1 and 5 Two more places still describe a metric's datatype as travelling in the BIRTH, which it has not since the metadata separation moved it to the META messages. Chapter 1 said every Metric must include a Sparkplug Datatype in the NBIRTH or DBIRTH message; it is the NMETA or DMETA. operational-behavior-data-publish-node-metric-datatype and -device-metric-datatype required that the datatype of a metric "in an NBIRTH"/"in an DBIRTH" not change in subsequent NDATA/DDATA messages. Neither message carries the Metric datatype field any more, so as written the rule can never be evaluated. They now compare the datatype of the value carried in NDATA/DDATA against the datatype the NMETA or DMETA declares for that metric. The requirement that the Host Application request a rebirth on a mismatch is unchanged. --- .../asciidoc/chapters/Sparkplug_1_Introduction.adoc | 4 ++-- .../chapters/Sparkplug_5_Operational_Behavior.adoc | 12 ++++++------ 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/specification/src/main/asciidoc/chapters/Sparkplug_1_Introduction.adoc b/specification/src/main/asciidoc/chapters/Sparkplug_1_Introduction.adoc index 653199c7..7087b69e 100644 --- a/specification/src/main/asciidoc/chapters/Sparkplug_1_Introduction.adoc +++ b/specification/src/main/asciidoc/chapters/Sparkplug_1_Introduction.adoc @@ -426,8 +426,8 @@ is used to generate the code for each specific language. In addition to Protobuf datatypes and native programming language datatypes there are also 'Sparkplug datatypes'. These are defined in the link:#payloads_b_google_protocol_buffer_schema[Sparkplug Protobuf Schema]. These datatypes are those -that are used for Sparkplug Metrics. Every Metric must include a Sparkplug Datatype in the NBIRTH or -DBIRTH message depending on whether the Metric is a 'Node level' or 'Device level' metric. Each of +that are used for Sparkplug Metrics. Every Metric must include a Sparkplug Datatype in the NMETA or +DMETA message depending on whether the Metric is a 'Node level' or 'Device level' metric. Each of the Sparkplug Datatypes is then represented by a Google Protobuf datatype. [[introduction_normative_references]] diff --git a/specification/src/main/asciidoc/chapters/Sparkplug_5_Operational_Behavior.adoc b/specification/src/main/asciidoc/chapters/Sparkplug_5_Operational_Behavior.adoc index 6e93e2da..b9961cf8 100644 --- a/specification/src/main/asciidoc/chapters/Sparkplug_5_Operational_Behavior.adoc +++ b/specification/src/main/asciidoc/chapters/Sparkplug_5_Operational_Behavior.adoc @@ -1645,9 +1645,9 @@ long as they have different timestamps. all metrics where is_historical=false, NBIRTH and NDATA messages MUST keep metric values in chronological order in the list of metrics in the payload.*# * [tck-testable tck-id-operational-behavior-data-publish-node-metric-datatype]#[yellow-background]*[tck-id-operational-behavior-data-publish-node-metric-datatype] For -all metrics in an NBIRTH, the datatype and corresponding protobuf datatype MUST NOT change in -subsequent NDATA messages. If it does, the Host Application MUST send a rebirth request to the -offending Edge Node.*# +all metrics defined in an NMETA, the datatype of the value carried in subsequent NDATA messages +MUST match the datatype declared for that metric in the NMETA. If it does not, the Host Application +MUST send a rebirth request to the offending Edge Node.*# Rules for Device data (DBIRTH and DDATA) messages: @@ -1671,9 +1671,9 @@ long as they have different timestamps. all metrics where is_historical=false, DBIRTH and DDATA messages MUST keep metric values in chronological order in the list of metrics in the payload.*# * [tck-testable tck-id-operational-behavior-data-publish-device-metric-datatype]#[yellow-background]*[tck-id-operational-behavior-data-publish-device-metric-datatype] For -all metrics in an DBIRTH, the datatype and corresponding protobuf datatype MUST NOT change in -subsequent DDATA messages. If it does, the Host Application MUST send a rebirth request to the -offending Edge Node.*# +all metrics defined in a DMETA, the datatype of the value carried in subsequent DDATA messages +MUST match the datatype declared for that metric in the DMETA. If it does not, the Host Application +MUST send a rebirth request to the offending Edge Node.*# [[operational_behavior_commands]] === Commands From 08f7b79818d5fd35fb18797358f403f0ca6efc57 Mon Sep 17 00:00:00 2001 From: wes-johnson Date: Wed, 2 Dec 2026 02:37:49 +0000 Subject: [PATCH 04/10] [#665] Fix the cross-references the deduplication left behind Review of the preceding commit found three problems with the pointers that replaced the seven removed assertions. The pointer on the Metric datatype field sent readers to the NMMETA and DMMETA sections of the Topics chapter for the rule that an incremental metric definition carries a datatype. Those sections do not state it; payloads-mmeta-add does, in this chapter. The pointer now names the section that actually holds each rule, and the NMMETA/DMMETA half points here rather than at the Topics chapter. The six message pointers asserted that a Topics section "is normative for" a message. The specification defines normativity per statement, not per section - "All normative statements in this document are highlighted in yellow text" - and the claim was false where it stood, because the Payloads NBIRTH section still carries nine normative statements of its own. They now use the form already used elsewhere in this chapter, "as described in the link:#...[...] section", and name the target by its rendered title so a reader can see a chapter boundary is being crossed. The four message pointers also carried a bare "MUST NOT" outside a highlighted assertion, which reads as untagged normative prose - the problem #651 was raised about. Reworded to "does not convey". Also states the division of labour once, where the per-message sections begin, so the next editor has a rule to follow instead of inferring it from seven bullets, and corrects "a NBIRTH"/"a NREBIRTH" to "an", which the specification uses 19 to 3 and 5 to 1. --- .../chapters/Sparkplug_6_Payloads.adoc | 50 +++++++++++-------- 1 file changed, 28 insertions(+), 22 deletions(-) diff --git a/specification/src/main/asciidoc/chapters/Sparkplug_6_Payloads.adoc b/specification/src/main/asciidoc/chapters/Sparkplug_6_Payloads.adoc index 42d54a5a..66aa76de 100644 --- a/specification/src/main/asciidoc/chapters/Sparkplug_6_Payloads.adoc +++ b/specification/src/main/asciidoc/chapters/Sparkplug_6_Payloads.adoc @@ -818,9 +818,10 @@ link:#payloads_p_datatypes[valid Sparkplug Data Types].*# datatype MUST NOT be PropertySet or PropertySetList, which are value types for a property rather than for a metric. A metric's properties are carried in its properties field.*# ** Non-normative comment: a metric's datatype is carried in the messages that convey metric -definitions, which are the link:#payloads_desc_nmeta[NMETA] and -link:#payloads_desc_nmmeta[NMMETA] for an Edge Node and the link:#payloads_desc_dmeta[DMETA] -and link:#payloads_desc_dmmeta[DMMETA] for a Device. +definitions. For a full definition set that is the link:#payloads_desc_nmeta[Payload (NMETA)] +section for an Edge Node and the link:#payloads_desc_dmeta[Payload (DMETA)] section for a +Device; for an incremental change it is the link:#payloads_p_nmmeta[NMMETA and DMMETA] section +in this chapter. ** [tck-testable tck-id-payloads-metric-datatype-not-req]#[yellow-background]*[tck-id-payloads-metric-datatype-not-req] The Metric's own datatype field MUST NOT be included with a metric in NDATA or DDATA messages in the Google Protocol Buffers encoding. A metric's datatype is established by the message that defines @@ -1583,10 +1584,12 @@ datatype is _Command_. The same Command object is used in three roles which are which fields are populated: * *Command Definition* -** This is the declaration of a command's typed signature and is included in a BIRTH message, +** This is the declaration of a command's typed signature and is included in a META message, analogous to how a Template Definition supplies the structure of a complex datatype. *** [tck-testable tck-id-payloads-command-definition-birth]#[yellow-background]*[tck-id-payloads-command-definition-birth] A -Command Definition MUST only be included in NBIRTH or DBIRTH messages.*# +Command Definition MUST only be included in NMETA, NMMETA, DMETA, or DMMETA messages, as the +link:#payloads_desc_nmeta[Payload (NMETA)] and link:#payloads_desc_dmeta[Payload (DMETA)] sections +require.*# *** [tck-testable tck-id-payloads-command-definition-datatype]#[yellow-background]*[tck-id-payloads-command-definition-datatype] A Metric representing a Command MUST have its datatype set to Command.*# *** [tck-testable tck-id-payloads-command-definition-arguments]#[yellow-background]*[tck-id-payloads-command-definition-arguments] If @@ -1604,7 +1607,8 @@ Command Definition MUST omit the correlation_id and status fields.*# ** This is an invocation of a previously defined command and is carried in an NCMD or DCMD message. *** [tck-testable tck-id-payloads-command-request-arguments]#[yellow-background]*[tck-id-payloads-command-request-arguments] A Command Request MUST supply argument values that are datatype compatible with the corresponding -Command Definition included in the immediately previous BIRTH for the Edge Node or Device.*# +Command Definition carried in the NMETA or DMETA that the Edge Node or Device currently +references.*# *** [tck-testable tck-id-payloads-command-request-correlation]#[yellow-background]*[tck-id-payloads-command-request-correlation] A Command Request MUST include a correlation_id.*# *** [tck-testable tck-id-payloads-command-request-no-status]#[yellow-background]*[tck-id-payloads-command-request-no-status] A @@ -1949,6 +1953,12 @@ definition, or to any Template definition MUST result in a different definition consumer MUST be able to recompute the definition identifier from the assembled metadata and obtain a value identical to the one published by the Edge Node.*# +The sections that follow describe the payload of each message type. The per-message requirements +themselves are stated once, in the 'Payload (X)' section of the +link:#topics[Topics] chapter; where a section below restates nothing, it refers to that section +rather than repeating it. What remains here describes the payload components a message is built +from. + [[payloads_p_nmeta]] ==== NMETA @@ -1965,8 +1975,8 @@ messages MUST include a payload timestamp that denotes the time at which the mes * [tck-testable tck-id-payloads-nmeta-defid]#[yellow-background]*[tck-id-payloads-nmeta-defid] NMETA messages MUST include a definition_id equal to the content hash of the metric definitions they contain.*# -* Non-normative comment: the metric definitions a full NMETA carries are required by the -link:#payloads_desc_nmeta[NMETA] section, which is normative for the NMETA message. +* The metric definitions a full NMETA carries are as described in the +link:#payloads_desc_nmeta[Payload (NMETA)] section. * [tck-testable tck-id-payloads-nmeta-cmd-metrics]#[yellow-background]*[tck-id-payloads-nmeta-cmd-metrics] A full NMETA MUST include the definition of every Command-datatype metric the Edge Node exposes, including its command argument and result definitions, so that Host Applications can invoke it via @@ -1991,8 +2001,8 @@ messages MUST include a payload timestamp that denotes the time at which the mes * [tck-testable tck-id-payloads-dmeta-defid]#[yellow-background]*[tck-id-payloads-dmeta-defid] DMETA messages MUST include a definition_id equal to the content hash of the metric definitions they contain.*# -* Non-normative comment: the metric definitions a full DMETA carries are required by the -link:#payloads_desc_dmeta[DMETA] section, which is normative for the DMETA message. +* The metric definitions a full DMETA carries are as described in the +link:#payloads_desc_dmeta[Payload (DMETA)] section. * [tck-testable tck-id-payloads-dmeta-cmd-metrics]#[yellow-background]*[tck-id-payloads-dmeta-cmd-metrics] A full DMETA MUST include the definition of every Command-datatype metric the Device exposes, including its command argument and result definitions, so that Host Applications can invoke it via DCMD and @@ -2059,9 +2069,8 @@ Edge Node Descriptor in any Sparkplug infrastructure MUST be unique in the syste * [tck-testable tck-id-payloads-nbirth-defid]#[yellow-background]*[tck-id-payloads-nbirth-defid] Every NBIRTH message MUST include a definition_id equal to the content hash of the NMETA that describes this Edge Node, and MUST report values only for metrics defined in that NMETA.*# -* Non-normative comment: the metrics a NBIRTH carries, and how each one is identified, are -required by the link:#payloads_desc_nbirth[NBIRTH] section, which is normative -for the NBIRTH message. +* The metrics an NBIRTH carries, how each one is identified, and the metric structure it does not +convey, are as described in the link:#payloads_desc_nbirth[Payload (NBIRTH)] section. * [tck-testable tck-id-payloads-nbirth-seq]#[yellow-background]*[tck-id-payloads-nbirth-seq] Every NBIRTH message MUST include a sequence number. If no NMETA is published in the BIRTH sequence, the NBIRTH is the first message and its sequence number MUST be 0. If an NMETA is published (sequence @@ -2176,9 +2185,8 @@ Edge Node Descriptor in any Sparkplug infrastructure MUST be unique in the syste * [tck-testable tck-id-payloads-nrebirth-defid]#[yellow-background]*[tck-id-payloads-nrebirth-defid] Every NREBIRTH message MUST include a definition_id equal to the content hash of the NMETA that describes this Edge Node, and MUST report values only for metrics defined in that NMETA.*# -* Non-normative comment: the metrics a NREBIRTH carries, and how each one is identified, are -required by the link:#payloads_desc_nrebirth[NREBIRTH] section, which is normative -for the NREBIRTH message. +* The metrics an NREBIRTH carries, how each one is identified, and the metric structure it does not +convey, are as described in the link:#payloads_desc_nrebirth[Payload (NREBIRTH)] section. * [tck-testable tck-id-payloads-nrebirth-seq-1]#[yellow-background]*[tck-id-payloads-nrebirth-seq-1] Every NREBIRTH message MUST include a sequence number and it MUST have a value between 0 and 9223372036854775807 (inclusive).*# @@ -2295,9 +2303,8 @@ published.*# * [tck-testable tck-id-payloads-dbirth-defid]#[yellow-background]*[tck-id-payloads-dbirth-defid] Every DBIRTH message MUST include a definition_id equal to the content hash of the DMETA that describes this Device, and MUST report values only for metrics defined in that DMETA.*# -* Non-normative comment: the metrics a DBIRTH carries, and how each one is identified, are -required by the link:#payloads_desc_dbirth[DBIRTH] section, which is normative -for the DBIRTH message. +* The metrics a DBIRTH carries, how each one is identified, and the metric structure it does not +convey, are as described in the link:#payloads_desc_dbirth[Payload (DBIRTH)] section. * [tck-testable tck-id-payloads-dbirth-seq]#[yellow-background]*[tck-id-payloads-dbirth-seq] Every DBIRTH message MUST include a sequence number.*# * [tck-testable tck-id-payloads-dbirth-seq-inc]#[yellow-background]*[tck-id-payloads-dbirth-seq-inc] Every @@ -2397,9 +2404,8 @@ published.*# * [tck-testable tck-id-payloads-drebirth-defid]#[yellow-background]*[tck-id-payloads-drebirth-defid] Every DREBIRTH message MUST include a definition_id equal to the content hash of the DMETA that describes this Device, and MUST report values only for metrics defined in that DMETA.*# -* Non-normative comment: the metrics a DREBIRTH carries, and how each one is identified, are -required by the link:#payloads_desc_drebirth[DREBIRTH] section, which is normative -for the DREBIRTH message. +* The metrics a DREBIRTH carries, how each one is identified, and the metric structure it does not +convey, are as described in the link:#payloads_desc_drebirth[Payload (DREBIRTH)] section. * [tck-testable tck-id-payloads-drebirth-seq]#[yellow-background]*[tck-id-payloads-drebirth-seq] Every DREBIRTH message MUST include a sequence number.*# * [tck-testable tck-id-payloads-drebirth-seq-inc]#[yellow-background]*[tck-id-payloads-drebirth-seq-inc] Every From 78810f893f1611cf7b8601ee5291ea3f5f3e9d4a Mon Sep 17 00:00:00 2001 From: wes-johnson Date: Wed, 2 Dec 2026 02:37:58 +0000 Subject: [PATCH 05/10] [#665] Move Command Definitions to the META messages Review found a second instance of the contradiction this issue is about, in the Command Definition rules, which the earlier commits did not touch. payloads-command-definition-birth required that a Command Definition "MUST only be included in NBIRTH or DBIRTH messages", while topics-nmeta-cmd-metrics and topics-dmeta-cmd-metrics require a full NMETA or DMETA to include the definition of every Command-datatype metric. Those cannot both be satisfied. payloads-command-definition- datatype compounded it: a Command Definition must set the Metric datatype to Command, which topics-nbirth-no-metadata forbids a BIRTH from carrying. A Command Definition is a metric definition, so it belongs with the other metric definitions in the META. The rule now names the NMETA, NMMETA, DMETA and DMMETA, matching what the Topics chapter already required, and payloads-command-definition-datatype becomes consistent without changing because the META is where a datatype is carried. The two rules that resolved a Command Request or Response against "the corresponding BIRTH Command Definition" follow it to the NMETA or DMETA. --- .../Sparkplug_5_Operational_Behavior.adoc | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/specification/src/main/asciidoc/chapters/Sparkplug_5_Operational_Behavior.adoc b/specification/src/main/asciidoc/chapters/Sparkplug_5_Operational_Behavior.adoc index b9961cf8..9a27648e 100644 --- a/specification/src/main/asciidoc/chapters/Sparkplug_5_Operational_Behavior.adoc +++ b/specification/src/main/asciidoc/chapters/Sparkplug_5_Operational_Behavior.adoc @@ -1647,7 +1647,8 @@ chronological order in the list of metrics in the payload.*# * [tck-testable tck-id-operational-behavior-data-publish-node-metric-datatype]#[yellow-background]*[tck-id-operational-behavior-data-publish-node-metric-datatype] For all metrics defined in an NMETA, the datatype of the value carried in subsequent NDATA messages MUST match the datatype declared for that metric in the NMETA. If it does not, the Host Application -MUST send a rebirth request to the offending Edge Node.*# +MUST send a rebirth request to the offending Edge Node, following the rules in the +link:#operational_behavior_rebirth[Rebirth Requests] section.*# Rules for Device data (DBIRTH and DDATA) messages: @@ -1673,7 +1674,13 @@ chronological order in the list of metrics in the payload.*# * [tck-testable tck-id-operational-behavior-data-publish-device-metric-datatype]#[yellow-background]*[tck-id-operational-behavior-data-publish-device-metric-datatype] For all metrics defined in a DMETA, the datatype of the value carried in subsequent DDATA messages MUST match the datatype declared for that metric in the DMETA. If it does not, the Host Application -MUST send a rebirth request to the offending Edge Node.*# +MUST send a rebirth request to the offending Edge Node, following the rules in the +link:#operational_behavior_rebirth[Rebirth Requests] section.*# +** Non-normative comment: a mismatch is evaluated against the declaration in the NMETA or DMETA, +which a rebirth does not change, so an Edge Node that keeps publishing the same mismatched value +will keep mismatching after the rebirth it triggered. A Host Application is expected to apply the +rate limiting described in the Rebirth Requests section rather than to request a rebirth for every +offending message. [[operational_behavior_commands]] === Commands @@ -1814,7 +1821,8 @@ NCMD or DCMD message.*# that each response can be unambiguously matched to its request. * [tck-testable tck-id-operational-behavior-command-request-arg-datatype]#[yellow-background]*[tck-id-operational-behavior-command-request-arg-datatype] A Host Application that invokes a command MUST supply argument values whose datatypes are compatible -with the argument definitions supplied in the corresponding BIRTH Command Definition.*# +with the argument definitions supplied in the corresponding Command Definition in the NMETA or +DMETA.*# * [tck-testable tck-id-operational-behavior-command-response-verb]#[yellow-background]*[tck-id-operational-behavior-command-response-verb] On receiving a command, an Edge Node MUST publish a command response using the NRESP Sparkplug verb for Edge Node level commands and the DRESP Sparkplug verb for Device level commands.*# @@ -1823,7 +1831,8 @@ command response MUST include the same correlation_id that was included in the c produced it.*# * [tck-testable tck-id-operational-behavior-command-response-results]#[yellow-background]*[tck-id-operational-behavior-command-response-results] On successful execution of a command that defines results, the command response MUST include a result -value for every result that was included in the corresponding BIRTH Command Definition.*# +value for every result that was included in the corresponding Command Definition in the NMETA or +DMETA.*# * [tck-testable tck-id-operational-behavior-command-error-status]#[yellow-background]*[tck-id-operational-behavior-command-error-status] If a command cannot be executed because it is unknown, its arguments are incompatible, or its execution fails, the Edge Node MUST publish a command response with a non-zero status code rather than silently From 54683cc170251f9fc7f484883eb0ce9197c3557a Mon Sep 17 00:00:00 2001 From: wes-johnson Date: Wed, 2 Dec 2026 02:38:21 +0000 Subject: [PATCH 06/10] [#665] Score the whole no-metadata rule, and stop failing Command metrics Two defects review found in the TCK change at the head of this branch. countDataType counted only metrics carrying a Metric datatype, but topics-nbirth-no-metadata and topics-dbirth-no-metadata forbid datatype, properties and metadata. A BIRTH whose metrics carried a properties or metadata submessage scored PASS. That is worse than no test, because the assertion is now reported as covered, so the two thirds of the rule that were unchecked were hidden rather than listed as uncovered. Renamed to countMetadata and extended to all three fields. Utils.hasValue(Metric) recognised a Command metric only through the guard hasDatatype() && getDatatype() == Command, then fell through to the TypedValue at field 13. A Command carries field 14. Now that a message conveying no metric structure carries no Metric datatype to read, a conforming Command metric would score as having no value and fail topics-nbirth-metrics and operational-behavior-data-publish-nbirth-values - the same class of false failure this branch set out to remove. The command field is now tested first and on its own, and a metric that declares the Command datatype without carrying one is reported as having no value. --- .../sparkplug/tck/test/common/Utils.java | 9 +++++++-- .../test/edge/SessionEstablishmentTest.java | 18 +++++++++++------- 2 files changed, 18 insertions(+), 9 deletions(-) diff --git a/tck/src/main/java/org/eclipse/sparkplug/tck/test/common/Utils.java b/tck/src/main/java/org/eclipse/sparkplug/tck/test/common/Utils.java index 79962c91..7397bbae 100644 --- a/tck/src/main/java/org/eclipse/sparkplug/tck/test/common/Utils.java +++ b/tck/src/main/java/org/eclipse/sparkplug/tck/test/common/Utils.java @@ -293,9 +293,14 @@ public static boolean hasValue(Metric m) { // A null value is valid return true; } + if (m.hasCommand()) { + // A Command metric's payload is the command field. The Metric datatype is not consulted, + // because a message that conveys no metric structure carries no Metric datatype to read. + return true; + } if (m.hasDatatype() && m.getDatatype() == DataType.Command) { - // A Command metric's payload is the command field - return m.hasCommand(); + // Declared a Command but carries no command field + return false; } return m.hasValue() && m.getValue().getValueCase() != Payload.TypedValue.ValueCase.VALUE_NOT_SET; diff --git a/tck/src/main/java/org/eclipse/sparkplug/tck/test/edge/SessionEstablishmentTest.java b/tck/src/main/java/org/eclipse/sparkplug/tck/test/edge/SessionEstablishmentTest.java index b96c1d49..91b11995 100644 --- a/tck/src/main/java/org/eclipse/sparkplug/tck/test/edge/SessionEstablishmentTest.java +++ b/tck/src/main/java/org/eclipse/sparkplug/tck/test/edge/SessionEstablishmentTest.java @@ -677,7 +677,7 @@ public void checkNBirth(final @NotNull PublishPacket packet) { // carrying one violates topics-nbirth-no-metadata. logger.debug( "Check req: The NBIRTH MUST NOT be used to convey metric datatype, properties, or metadata."); - Utils.setResultIfNotFail(testResults, countDataType(metrics) == 0, ID_TOPICS_NBIRTH_NO_METADATA, + Utils.setResultIfNotFail(testResults, countMetadata(metrics) == 0, ID_TOPICS_NBIRTH_NO_METADATA, TOPICS_NBIRTH_NO_METADATA); logger.debug("Check Req: NBIRTH bdSeq must match bdSeq provided in Will Message payload of connect packet"); testResults.put(ID_PAYLOADS_NBIRTH_BDSEQ, setResult(birthBdSeq != -1, PAYLOADS_NBIRTH_BDSEQ)); @@ -878,7 +878,7 @@ public void checkDBirth(final @NotNull PublishPacket packet) { logger.debug( "Check req: The DBIRTH MUST NOT be used to convey metric datatype, properties, or metadata."); Utils.setResultIfNotFail(testResults, - countDataType(sparkplugPayload.getContent().getMetricsList()) == 0, + countMetadata(sparkplugPayload.getContent().getMetricsList()) == 0, ID_TOPICS_DBIRTH_NO_METADATA, TOPICS_DBIRTH_NO_METADATA); checkPayloadsNameInDataRequirement(sparkplugPayload); @@ -935,15 +935,19 @@ public void checkDBirth(final @NotNull PublishPacket packet) { } } - private int countDataType(List metrics) { + /** + * Counts the metrics carrying metric structure, which a BIRTH must not convey. The rule names + * datatype, properties and metadata, so all three are counted rather than the datatype alone. + */ + private int countMetadata(List metrics) { if (metrics != null) { - final AtomicInteger hasDataTypeCnt = new AtomicInteger(); + final AtomicInteger metadataCnt = new AtomicInteger(); metrics.forEach(m -> { - if (m.hasDatatype()) { - hasDataTypeCnt.incrementAndGet(); + if (m.hasDatatype() || m.hasProperties() || m.hasMetadata()) { + metadataCnt.incrementAndGet(); } }); - return hasDataTypeCnt.get(); + return metadataCnt.get(); } return 0; } From 80b5f5d3816c43237598afbb3bf6470f7ecd9c91 Mon Sep 17 00:00:00 2001 From: wes-johnson Date: Wed, 2 Dec 2026 02:52:37 +0000 Subject: [PATCH 07/10] [#665] Finish moving Command Definitions off the BIRTH The preceding commit moved the Command Definition rules in the Payloads chapter to the META messages but left the rest of the Command family behind, which replaced one contradiction with another. operational-behavior-command-definition-birth still required that an Edge Node "MUST include every command it supports as a Command metric in the NBIRTH or DBIRTH", directly against the rule the preceding commit had just rewritten. It now names the NMETA and DMETA, and is renamed to operational-behavior-command-definition-meta so the identifier stops naming a message the rule no longer mentions. payloads-command-definition-birth is renamed to -meta for the same reason. Neither id is referenced by the TCK. Also repointed, all of which still described Command metrics as travelling in a BIRTH: - the Commands section opening, where custom command endpoints were "declared in an NBIRTH or DBIRTH message"; - the Typed Commands introduction, "includes as Command metrics in its BIRTH"; - the NCMD and DCMD sections, which invoked a Command "included in the NBIRTH" and "supplied in the DBIRTH"; - the inline schema comments on Command.arguments, Command.results and Metric.command. A sweep for a Command rule still tied to a BIRTH now returns nothing. --- .../chapters/Sparkplug_5_Operational_Behavior.adoc | 12 ++++++------ .../main/asciidoc/chapters/Sparkplug_6_Payloads.adoc | 12 ++++++------ 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/specification/src/main/asciidoc/chapters/Sparkplug_5_Operational_Behavior.adoc b/specification/src/main/asciidoc/chapters/Sparkplug_5_Operational_Behavior.adoc index 9a27648e..0fd09dcf 100644 --- a/specification/src/main/asciidoc/chapters/Sparkplug_5_Operational_Behavior.adoc +++ b/specification/src/main/asciidoc/chapters/Sparkplug_5_Operational_Behavior.adoc @@ -1687,8 +1687,8 @@ offending message. Commands are used in Sparkplug to allow Sparkplug Host Applications to send data to Sparkplug Edge Nodes. Examples include writing to outputs of Sparkplug Edge Nodes and Devices or to call 'Node -Control' or 'Device Control' commands. Custom command endpoints can be declared in an NBIRTH or -DBIRTH message by an Edge Node or Device that may support functionality such as rebooting an Edge +Control' or 'Device Control' commands. Custom command endpoints can be declared in an NMETA or +DMETA message by an Edge Node or Device that may support functionality such as rebooting an Edge Node or Device. This is up to the Sparkplug implementor to define what functionality can be exposed. Security and access is an important aspect of commands. It may be the case that not all Sparkplug @@ -1800,7 +1800,7 @@ DCMD message MUST include a compatible metric value for the metric name that it ==== Typed Commands and Command Responses In addition to writing to output metrics, a Host Application can invoke strongly typed commands that -an Edge Node or Device includes as Command metrics in its BIRTH. A command is a callable function +an Edge Node or Device includes as Command metrics in its META. A command is a callable function with a typed signature: it declares the inputs it accepts and the outputs it returns. Invoking a command follows a correlated request/response pattern so that the result, including any returned data or error code, can be reliably matched back to the request that produced it. The structure of a @@ -1811,9 +1811,9 @@ includes the argument values and a correlation_id. The Edge Node executes the co Node publishes an NRESP or DRESP that echoes the correlation_id and carries the execution status and any results. -* [tck-testable tck-id-operational-behavior-command-definition-birth]#[yellow-background]*[tck-id-operational-behavior-command-definition-birth] An -Edge Node MUST include every command it supports as a Command metric in the NBIRTH (for Edge Node -level commands) or DBIRTH (for Device level commands).*# +* [tck-testable tck-id-operational-behavior-command-definition-meta]#[yellow-background]*[tck-id-operational-behavior-command-definition-meta] An +Edge Node MUST include every command it supports as a Command metric in the NMETA (for Edge Node +level commands) or DMETA (for Device level commands).*# * [tck-testable tck-id-operational-behavior-command-request-correlation]#[yellow-background]*[tck-id-operational-behavior-command-request-correlation] A Host Application that invokes a command MUST include a correlation_id in the Command object of the NCMD or DCMD message.*# diff --git a/specification/src/main/asciidoc/chapters/Sparkplug_6_Payloads.adoc b/specification/src/main/asciidoc/chapters/Sparkplug_6_Payloads.adoc index 66aa76de..d79a641d 100644 --- a/specification/src/main/asciidoc/chapters/Sparkplug_6_Payloads.adoc +++ b/specification/src/main/asciidoc/chapters/Sparkplug_6_Payloads.adoc @@ -245,8 +245,8 @@ message Payload { } message Command { - repeated Metric arguments = 1; // Input argument definitions (NBIRTH/DBIRTH) or supplied argument values (NCMD/DCMD) - omitted for commands that accept no inputs - repeated Metric results = 2; // Result/output argument definitions (NBIRTH/DBIRTH) or returned result values (NRESP/DRESP) - omitted for commands that return no outputs + repeated Metric arguments = 1; // Input argument definitions (NMETA/DMETA) or supplied argument values (NCMD/DCMD) - omitted for commands that accept no inputs + repeated Metric results = 2; // Result/output argument definitions (NMETA/DMETA) or returned result values (NRESP/DRESP) - omitted for commands that return no outputs string correlation_id = 3; // Set on an NCMD/DCMD request and echoed unchanged in the corresponding NRESP/DRESP response Status status = 4; // Execution status - present in NRESP/DRESP responses, omitted in BIRTH definitions and CMD requests } @@ -326,7 +326,7 @@ message Payload { MetaData metadata = 11; // Metadata for the Metric PropertySet properties = 12; // Properties of the Metric TypedValue value = 13; - Command command = 14; // Command definition (BIRTH), invocation (CMD), or response (RESP) - present when datatype == Command instead of 'value' + Command command = 14; // Command definition (META), invocation (CMD), or response (RESP) - present when datatype == Command instead of 'value' MetricOperation operation = 15; // Only in NMMETA/DMMETA: ADD, UPDATE, or DELETE } @@ -1586,7 +1586,7 @@ which fields are populated: * *Command Definition* ** This is the declaration of a command's typed signature and is included in a META message, analogous to how a Template Definition supplies the structure of a complex datatype. -*** [tck-testable tck-id-payloads-command-definition-birth]#[yellow-background]*[tck-id-payloads-command-definition-birth] A +*** [tck-testable tck-id-payloads-command-definition-meta]#[yellow-background]*[tck-id-payloads-command-definition-meta] A Command Definition MUST only be included in NMETA, NMMETA, DMETA, or DMMETA messages, as the link:#payloads_desc_nmeta[Payload (NMETA)] and link:#payloads_desc_dmeta[Payload (DMETA)] sections require.*# @@ -2728,7 +2728,7 @@ The NCMD payload tells the Edge Node to write true to the 'DIGITAL_OUT_1' metric DIGITAL_OUT_1 alue should turn true and result in a NDATA message back to the MQTT Server after the DIGITAL_OUT_1 is successfully set to true. -An NCMD message MAY also invoke a strongly typed Command that was included in the NBIRTH. In this +An NCMD message MAY also invoke a strongly typed Command that was included in the NMETA. In this case the metric datatype is Command and the metric carries a Command object with the supplied argument values and a correlation_id. See the link:#payloads_p_command[Command Section] for the full Command Request rules. @@ -2828,7 +2828,7 @@ The DCMD payload tells the Edge Node to start the attached Filler's motor and se As a result, the Filler should begin running and result in a DDATA message back to the MQTT Server after the motor is successfully started. -A DCMD message MAY also invoke a strongly typed Command that was supplied in the DBIRTH, following +A DCMD message MAY also invoke a strongly typed Command that was supplied in the DMETA, following the same Command Request rules as NCMD. See the link:#payloads_p_command[Command Section]. * [tck-testable tck-id-payloads-dcmd-command-correlation]#[yellow-background]*[tck-id-payloads-dcmd-command-correlation] A From 90f8d9166087d09429fbb6045bd2fac793c9fbac Mon Sep 17 00:00:00 2001 From: wes-johnson Date: Wed, 2 Dec 2026 03:09:29 +0000 Subject: [PATCH 08/10] [#665] State the alias rules against the META, not the BIRTH payloads-alias-birth-requirement required that "NBIRTH and DBIRTH messages MUST include both a metric name and alias". That is wrong, and it contradicted topics-nbirth-metrics and topics-dbirth-metrics, which identify a metric either by its alias, if the referenced NMETA assigned one, or otherwise by its metric name. It is the alias twin of the datatype contradiction this issue was raised about. The alias to name binding is established in the NMETA or DMETA that defines the metric. Aliases are optional and are assigned per metric. If an alias was assigned, the messages that report that metric identify it by the alias and omit the name; if none was assigned, they identify it by the name. The four rules in this block now say that: - payloads-alias-uniqueness scoped to the NMETA and DMETA, which is where an alias is assigned, rather than to the NBIRTH and DBIRTH; - payloads-alias-birth-requirement states the assigned case, for every message that reports the metric rather than for the BIRTH alone; - payloads-alias-data-cmd-requirement states the complementary unassigned case, likewise for every message rather than for NDATA, DDATA, NCMD and DCMD alone; - payloads-name-requirement conditions the name on whether the META assigned an alias, instead of on whether "aliases are being used". The alias field description and its non-normative comments follow. In the TCK, the NBIRTH and DBIRTH check rejected a metric carrying an alias without a name, which the corrected rule requires, so it would have failed every conforming Edge Node. It now requires exactly one identifier, rejecting both and neither. Two log lines that quoted the superseded wording are updated. The TCK cannot yet check the rule faithfully, because it has no NMETA or DMETA handling and so cannot know which metrics were assigned an alias. --- .../chapters/Sparkplug_6_Payloads.adoc | 27 +++++++++++-------- .../tck/test/edge/SendComplexDataTest.java | 2 +- .../test/edge/SessionEstablishmentTest.java | 6 +++-- 3 files changed, 21 insertions(+), 14 deletions(-) diff --git a/specification/src/main/asciidoc/chapters/Sparkplug_6_Payloads.adoc b/specification/src/main/asciidoc/chapters/Sparkplug_6_Payloads.adoc index d79a641d..bd8817e6 100644 --- a/specification/src/main/asciidoc/chapters/Sparkplug_6_Payloads.adoc +++ b/specification/src/main/asciidoc/chapters/Sparkplug_6_Payloads.adoc @@ -753,7 +753,8 @@ data structures. For example, ‘outputs/A’ would be a metric with a unique id ‘outputs’ folder. There is no limit to the number of folders. However, across the infrastructure of MQTT publishers a defined folder should always remain a folder. ** [tck-testable tck-id-payloads-name-requirement]#[yellow-background]*[tck-id-payloads-name-requirement] The -name MUST be included with every metric unless aliases are being used.*# +name MUST be included with every metric unless an alias was assigned to that metric in the NMETA +or DMETA.*# ** All UTF-8 characters are allowed in the metric name. However, special characters including but not limited to the following SHOULD NOT be used: . , \ @ # $ % ^ & * ( ) [ ] { } | ! ` ~ : ; ' " < > ?. Many Sparkplug Host Applications may have issues handling these characters. In addition, leading and @@ -761,20 +762,24 @@ trailing whitespace characters and control characters such as NULL (0x00) SHOULD metric names. * *alias* -** This is an unsigned 64-bit integer representing an optional alias for a Sparkplug B payload. -Aliases are optional and not required. *If aliases are used, the following rules apply.* +** This is an unsigned 64-bit integer representing an optional alias for a metric. An alias is +assigned to a metric in the NMETA or DMETA that defines it, and that assignment is what binds the +alias to the metric name. Aliases are optional and are assigned per metric. *If an alias is +assigned, the following rules apply.* *** [tck-testable tck-id-payloads-alias-uniqueness]#[yellow-background]*[tck-id-payloads-alias-uniqueness] If -supplied in an NBIRTH or DBIRTH it MUST be a unique number across this Edge Node's entire set of +supplied in an NMETA or DMETA it MUST be a unique number across this Edge Node's entire set of metrics.*# -**** Non-normative comment: no two metrics for the same Edge Node can have the same alias. Upon being -defined in the NBIRTH or DBIRTH, subsequent messages can supply only the alias instead of the metric -friendly name to reduce overall message size. +**** Non-normative comment: no two metrics for the same Edge Node can have the same alias. Once +assigned in the NMETA or DMETA, the messages that report the metric supply only the alias instead of +the metric friendly name, which reduces overall message size. **** Non-normative comment: In effect, this means a metric alias, when used, must be unique across the entire Edge Node and all of its Sparkplug Devices. -*** [tck-testable tck-id-payloads-alias-birth-requirement]#[yellow-background]*[tck-id-payloads-alias-birth-requirement] NBIRTH -and DBIRTH messages MUST include both a metric name and alias.*# -*** [tck-testable tck-id-payloads-alias-data-cmd-requirement]#[yellow-background]*[tck-id-payloads-alias-data-cmd-requirement] NDATA, -DDATA, NCMD, and DCMD messages MUST only include an alias and the metric name MUST be excluded.*# +*** [tck-testable tck-id-payloads-alias-birth-requirement]#[yellow-background]*[tck-id-payloads-alias-birth-requirement] If +an alias was assigned to a metric in the NMETA or DMETA, every subsequent message that reports +that metric MUST identify it by its alias and MUST omit its metric name.*# +*** [tck-testable tck-id-payloads-alias-data-cmd-requirement]#[yellow-background]*[tck-id-payloads-alias-data-cmd-requirement] If +no alias was assigned to a metric in the NMETA or DMETA, every subsequent message that reports +that metric MUST identify it by its metric name.*# * *timestamp* ** This is the timestamp in the form of a signed 64-bit integer representing the number of nanoseconds since epoch (Jan 1, 1970). diff --git a/tck/src/main/java/org/eclipse/sparkplug/tck/test/edge/SendComplexDataTest.java b/tck/src/main/java/org/eclipse/sparkplug/tck/test/edge/SendComplexDataTest.java index 82755d77..7c154033 100644 --- a/tck/src/main/java/org/eclipse/sparkplug/tck/test/edge/SendComplexDataTest.java +++ b/tck/src/main/java/org/eclipse/sparkplug/tck/test/edge/SendComplexDataTest.java @@ -464,7 +464,7 @@ public void checkPropertiesValidType(final @NotNull PublishPacket packet, String id = ID_PAYLOADS_ALIAS_DATA_CMD_REQUIREMENT) public void checkAliasInData(final @NotNull PayloadOrBuilder sparkplugPayload, String topic) { logger.debug( - "Check Req: NDATA, DDATA, NCMD, and DCMD messages MUST only include an alias and the metric name MUST be excluded."); + "Check Req: a metric is identified by its alias if the META assigned one, otherwise by its name."); boolean isValid = false; if (topic.contains(TOPIC_PATH_NDATA) || topic.contains(TOPIC_PATH_DDATA) || topic.contains(TOPIC_PATH_NCMD) diff --git a/tck/src/main/java/org/eclipse/sparkplug/tck/test/edge/SessionEstablishmentTest.java b/tck/src/main/java/org/eclipse/sparkplug/tck/test/edge/SessionEstablishmentTest.java index 91b11995..3f92d494 100644 --- a/tck/src/main/java/org/eclipse/sparkplug/tck/test/edge/SessionEstablishmentTest.java +++ b/tck/src/main/java/org/eclipse/sparkplug/tck/test/edge/SessionEstablishmentTest.java @@ -400,14 +400,16 @@ public void checkPayloadsNameInDataRequirement(final @NotNull PayloadOrBuilder s id = ID_PAYLOADS_ALIAS_UNIQUENESS) public void checkPayloadsAliasAndNameRequirement(final @NotNull PayloadOrBuilder sparkplugPayload) { logger.debug("Check Req: " - + "if alias is included, NBIRTH and DBIRTH messages MUST include both a metric name and alias."); + + "a metric is identified by its alias if the META assigned one, otherwise by its name."); boolean isValid = true; List metrics = sparkplugPayload.getContent().getMetricsList(); ListIterator metricIterator = metrics.listIterator(); while (metricIterator.hasNext()) { Metric current = metricIterator.next(); - if (current.hasAlias() && !current.hasName()) { + // Exactly one identifier: the alias when the META assigned one, otherwise the name. + // Carrying both, or neither, identifies the metric ambiguously. + if (current.hasAlias() == current.hasName()) { isValid = false; break; } From 96a5b3ccf76c42088aaff3bdaed8ca2ef2d1ebc3 Mon Sep 17 00:00:00 2001 From: wes-johnson Date: Wed, 2 Dec 2026 03:26:25 +0000 Subject: [PATCH 09/10] [#665] Keep the alias rules out of the META, and rename them for it Review of the preceding commit found it overreached. "Every subsequent message that reports that metric MUST identify it by its alias and MUST omit its metric name" also covers the NMETA, NMMETA, DMETA and DMMETA, which is where the name must always appear, because the name is what the alias is bound to. As written it contradicted topics-nmeta-metrics and topics-dmeta-metrics, which require a full META to include the metric name, and payloads-mmeta-add, which requires an ADD metric to include it. payloads-name-requirement had the same defect from the other direction: it let a META omit the name whenever an alias was assigned. All three now scope the condition to a value-carrying message, the term the specification already uses for the NBIRTH, NREBIRTH, DBIRTH, DREBIRTH, NDATA and DDATA, and payloads-name-requirement states the definition-carrying case explicitly. Both ids named a message type their rule no longer mentions, so they are renamed to say which case they state: payloads-alias-birth-requirement -> payloads-alias-assigned payloads-alias-data-cmd-requirement -> payloads-alias-not-assigned Their TCK references follow. Also corrects the two inline schema comments on Metric.name and Metric.alias, which still described the name as "Required in BIRTH messages" and the alias as "tied to name on BIRTH and included in all later DATA messages". --- .../asciidoc/chapters/Sparkplug_6_Payloads.adoc | 17 +++++++++-------- .../tck/test/edge/SendComplexDataTest.java | 12 ++++++------ .../tck/test/edge/SessionEstablishmentTest.java | 6 +++--- 3 files changed, 18 insertions(+), 17 deletions(-) diff --git a/specification/src/main/asciidoc/chapters/Sparkplug_6_Payloads.adoc b/specification/src/main/asciidoc/chapters/Sparkplug_6_Payloads.adoc index bd8817e6..9e3cea8e 100644 --- a/specification/src/main/asciidoc/chapters/Sparkplug_6_Payloads.adoc +++ b/specification/src/main/asciidoc/chapters/Sparkplug_6_Payloads.adoc @@ -313,8 +313,8 @@ message Payload { message Metric { - string name = 1; // Metric name - Required in BIRTH messages, optional in DATA messages if using aliases - uint64 alias = 2; // Metric alias - tied to name on BIRTH and included in all later DATA messages + string name = 1; // Metric name - Required wherever the metric is not identified by an alias assigned in the META + uint64 alias = 2; // Metric alias - tied to the name in the META and used in place of it in value-carrying messages int64 timestamp = 3; // Metric value change time - the time this metric's value last changed - if omitted, the overall payload timestamp is assumed as the metric value change time DataType datatype = 4; // DataType of the metric/tag value uint32 quality = 5; // Quality code of the metric/tag value - severity in bits 30-31 @@ -753,8 +753,9 @@ data structures. For example, ‘outputs/A’ would be a metric with a unique id ‘outputs’ folder. There is no limit to the number of folders. However, across the infrastructure of MQTT publishers a defined folder should always remain a folder. ** [tck-testable tck-id-payloads-name-requirement]#[yellow-background]*[tck-id-payloads-name-requirement] The -name MUST be included with every metric unless an alias was assigned to that metric in the NMETA -or DMETA.*# +name MUST be included with every metric in a message that conveys metric definitions. In a +value-carrying message the name MUST be included unless an alias was assigned to that metric in the +NMETA or DMETA.*# ** All UTF-8 characters are allowed in the metric name. However, special characters including but not limited to the following SHOULD NOT be used: . , \ @ # $ % ^ & * ( ) [ ] { } | ! ` ~ : ; ' " < > ?. Many Sparkplug Host Applications may have issues handling these characters. In addition, leading and @@ -774,11 +775,11 @@ assigned in the NMETA or DMETA, the messages that report the metric supply only the metric friendly name, which reduces overall message size. **** Non-normative comment: In effect, this means a metric alias, when used, must be unique across the entire Edge Node and all of its Sparkplug Devices. -*** [tck-testable tck-id-payloads-alias-birth-requirement]#[yellow-background]*[tck-id-payloads-alias-birth-requirement] If -an alias was assigned to a metric in the NMETA or DMETA, every subsequent message that reports +*** [tck-testable tck-id-payloads-alias-assigned]#[yellow-background]*[tck-id-payloads-alias-assigned] If +an alias was assigned to a metric in the NMETA or DMETA, a value-carrying message that reports that metric MUST identify it by its alias and MUST omit its metric name.*# -*** [tck-testable tck-id-payloads-alias-data-cmd-requirement]#[yellow-background]*[tck-id-payloads-alias-data-cmd-requirement] If -no alias was assigned to a metric in the NMETA or DMETA, every subsequent message that reports +*** [tck-testable tck-id-payloads-alias-not-assigned]#[yellow-background]*[tck-id-payloads-alias-not-assigned] If +no alias was assigned to a metric in the NMETA or DMETA, a value-carrying message that reports that metric MUST identify it by its metric name.*# * *timestamp* ** This is the timestamp in the form of a signed 64-bit integer representing the number of diff --git a/tck/src/main/java/org/eclipse/sparkplug/tck/test/edge/SendComplexDataTest.java b/tck/src/main/java/org/eclipse/sparkplug/tck/test/edge/SendComplexDataTest.java index 7c154033..715b0277 100644 --- a/tck/src/main/java/org/eclipse/sparkplug/tck/test/edge/SendComplexDataTest.java +++ b/tck/src/main/java/org/eclipse/sparkplug/tck/test/edge/SendComplexDataTest.java @@ -21,7 +21,7 @@ import static org.eclipse.sparkplug.tck.test.common.Constants.TOPIC_PATH_NDATA; import static org.eclipse.sparkplug.tck.test.common.Constants.TOPIC_PATH_NDEATH; import static org.eclipse.sparkplug.tck.test.common.Constants.TOPIC_ROOT_SP_BV_1_0; -import static org.eclipse.sparkplug.tck.test.common.Requirements.ID_PAYLOADS_ALIAS_DATA_CMD_REQUIREMENT; +import static org.eclipse.sparkplug.tck.test.common.Requirements.ID_PAYLOADS_ALIAS_NOT_ASSIGNED; import static org.eclipse.sparkplug.tck.test.common.Requirements.ID_PAYLOADS_METRIC_DATATYPE_NOT_REQ; import static org.eclipse.sparkplug.tck.test.common.Requirements.ID_PAYLOADS_METRIC_DATATYPE_VALUE; import static org.eclipse.sparkplug.tck.test.common.Requirements.ID_PAYLOADS_METRIC_DATATYPE_VALUE_TYPE; @@ -48,7 +48,7 @@ import static org.eclipse.sparkplug.tck.test.common.Requirements.ID_PAYLOADS_TEMPLATE_REF_DEFINITION; import static org.eclipse.sparkplug.tck.test.common.Requirements.ID_PAYLOADS_TEMPLATE_REF_INSTANCE; import static org.eclipse.sparkplug.tck.test.common.Requirements.ID_PAYLOADS_TEMPLATE_VERSION; -import static org.eclipse.sparkplug.tck.test.common.Requirements.PAYLOADS_ALIAS_DATA_CMD_REQUIREMENT; +import static org.eclipse.sparkplug.tck.test.common.Requirements.PAYLOADS_ALIAS_NOT_ASSIGNED; import static org.eclipse.sparkplug.tck.test.common.Requirements.PAYLOADS_METRIC_DATATYPE_NOT_REQ; import static org.eclipse.sparkplug.tck.test.common.Requirements.PAYLOADS_METRIC_DATATYPE_VALUE; import static org.eclipse.sparkplug.tck.test.common.Requirements.PAYLOADS_METRIC_DATATYPE_VALUE_TYPE; @@ -124,7 +124,7 @@ public class SendComplexDataTest extends TCKTest { ID_PAYLOADS_METRIC_DATATYPE_VALUE_TYPE, ID_PAYLOADS_METRIC_DATATYPE_VALUE, ID_PAYLOADS_PROPERTYSET_KEYS_ARRAY_SIZE, ID_PAYLOADS_PROPERTYSET_VALUES_ARRAY_SIZE, ID_PAYLOADS_METRIC_PROPERTYVALUE_TYPE_TYPE, ID_PAYLOADS_METRIC_PROPERTYVALUE_TYPE_VALUE, - ID_PAYLOADS_METRIC_PROPERTYVALUE_TYPE_REQ, ID_PAYLOADS_ALIAS_DATA_CMD_REQUIREMENT, + ID_PAYLOADS_METRIC_PROPERTYVALUE_TYPE_REQ, ID_PAYLOADS_ALIAS_NOT_ASSIGNED, ID_PAYLOADS_METRIC_DATATYPE_NOT_REQ, ID_PAYLOADS_NAME_BIRTH_DATA_REQUIREMENT, ID_PAYLOADS_NAME_REQUIREMENT, ID_PAYLOADS_TEMPLATE_IS_DEFINITION, ID_PAYLOADS_TEMPLATE_DEFINITION_IS_DEFINITION, ID_PAYLOADS_TEMPLATE_INSTANCE_IS_DEFINITION, ID_PAYLOADS_TEMPLATE_DEFINITION_REF, @@ -461,7 +461,7 @@ public void checkPropertiesValidType(final @NotNull PublishPacket packet, String @SpecAssertion( section = Sections.PAYLOADS_P_METRIC, - id = ID_PAYLOADS_ALIAS_DATA_CMD_REQUIREMENT) + id = ID_PAYLOADS_ALIAS_NOT_ASSIGNED) public void checkAliasInData(final @NotNull PayloadOrBuilder sparkplugPayload, String topic) { logger.debug( "Check Req: a metric is identified by its alias if the META assigned one, otherwise by its name."); @@ -475,8 +475,8 @@ public void checkAliasInData(final @NotNull PayloadOrBuilder sparkplugPayload, S isValid = true; break; } - testResults.put(ID_PAYLOADS_ALIAS_DATA_CMD_REQUIREMENT, - setResult(isValid, PAYLOADS_ALIAS_DATA_CMD_REQUIREMENT)); + testResults.put(ID_PAYLOADS_ALIAS_NOT_ASSIGNED, + setResult(isValid, PAYLOADS_ALIAS_NOT_ASSIGNED)); } } diff --git a/tck/src/main/java/org/eclipse/sparkplug/tck/test/edge/SessionEstablishmentTest.java b/tck/src/main/java/org/eclipse/sparkplug/tck/test/edge/SessionEstablishmentTest.java index 3f92d494..754b9d5f 100644 --- a/tck/src/main/java/org/eclipse/sparkplug/tck/test/edge/SessionEstablishmentTest.java +++ b/tck/src/main/java/org/eclipse/sparkplug/tck/test/edge/SessionEstablishmentTest.java @@ -108,7 +108,7 @@ public class SessionEstablishmentTest extends TCKTest { ID_MESSAGE_FLOW_DEVICE_BIRTH_PUBLISH_DBIRTH_MATCH_EDGE_NODE_TOPIC, ID_PAYLOADS_NBIRTH_BDSEQ_REPEAT, ID_PAYLOADS_NDATA_ORDER, ID_PAYLOADS_DDATA_ORDER, ID_PAYLOADS_ALIAS_UNIQUENESS, ID_TOPICS_NBIRTH_TOPIC, ID_TOPICS_DBIRTH_TOPIC, ID_CASE_SENSITIVITY_METRIC_NAMES, ID_PAYLOADS_NAME_BIRTH_DATA_REQUIREMENT, - ID_PAYLOADS_ALIAS_BIRTH_REQUIREMENT, ID_TOPICS_NBIRTH_NO_METADATA, ID_TOPICS_DBIRTH_NO_METADATA); + ID_PAYLOADS_ALIAS_ASSIGNED, ID_TOPICS_NBIRTH_NO_METADATA, ID_TOPICS_DBIRTH_NO_METADATA); private final @NotNull TCK theTCK; private @NotNull Utilities utilities = null; @@ -394,7 +394,7 @@ public void checkPayloadsNameInDataRequirement(final @NotNull PayloadOrBuilder s @SpecAssertion( section = Sections.PAYLOADS_P_METRIC, - id = ID_PAYLOADS_ALIAS_BIRTH_REQUIREMENT) + id = ID_PAYLOADS_ALIAS_ASSIGNED) @SpecAssertion( section = Sections.PAYLOADS_P_METRIC, id = ID_PAYLOADS_ALIAS_UNIQUENESS) @@ -420,7 +420,7 @@ public void checkPayloadsAliasAndNameRequirement(final @NotNull PayloadOrBuilder aliases.add(alias); } } - testResults.put(ID_PAYLOADS_ALIAS_BIRTH_REQUIREMENT, setResult(isValid, PAYLOADS_ALIAS_BIRTH_REQUIREMENT)); + testResults.put(ID_PAYLOADS_ALIAS_ASSIGNED, setResult(isValid, PAYLOADS_ALIAS_ASSIGNED)); } @SpecAssertion( From a0226a9a9078c90366a29594c0ec76d80d4196eb Mon Sep 17 00:00:00 2001 From: wes-johnson Date: Fri, 4 Dec 2026 16:37:15 +0000 Subject: [PATCH 10/10] [#665] Address review: aliased BIRTHs, MMETA names, and CMD identification Review found the alias rewrite had two unsatisfiable pairs and had narrowed a rule that should not have narrowed. The TCK BIRTH metric checks still required a name, so an Edge Node that uses aliases failed either topics-nbirth-metrics, by omitting the name the corrected rules require it to omit, or payloads-alias-assigned, by including it. Both call sites now accept either identifier. payloads-name-requirement required a name on every metric of a message that conveys metric definitions, which includes the NMMETA and DMMETA, against payloads-mmeta-update and payloads-mmeta-delete, which identify those metrics by their existing alias when one was assigned. It now names the full NMETA or DMETA and the ADD operation specifically. payloads-alias-assigned and payloads-alias-not-assigned were scoped to a value-carrying message, which the specification uses for the BIRTH, REBIRTH and DATA messages only. That silently dropped NCMD and DCMD, which the rule they replaced covered, and never reached NRESP or DRESP. Both now apply to any message other than an NMETA, NMMETA, DMETA, or DMMETA, which is the set that identifies a metric rather than defining it. Also from review: - The node and device data-publish rules said a value's datatype "MUST match the datatype declared". A protobuf NDATA carries no Metric datatype and Int8, Int16 and Int32 share int32_value, so that cannot be evaluated from the wire. They now require the value to use the TypedValue field the declared datatype maps to. - The non-normative rebirth comment pointed at rate limiting in the Rebirth Requests section, which does not describe any. It now states the expectation directly, pending #663. - Three more places still placed Command metrics in a BIRTH: the Command.status schema comment, the Sparkplug Command component description, and operational-behavior-commands-ncmd-metric-name and its DCMD twin, which asked for a metric name "included in the associated NBIRTH". With alias-only BIRTHs the name is in the META. SendComplexDataTest.checkAliasInData scored only the first metric, because of an unconditional break, and could be erased by a later conforming message. It now checks every metric through setResultIfNotFail. It still tests only that exactly one identifier is present, because the TCK has no META handling and so cannot know which metrics were assigned an alias. --- .../chapters/Sparkplug_3_Components.adoc | 7 ++-- .../Sparkplug_5_Operational_Behavior.adoc | 37 +++++++++---------- .../chapters/Sparkplug_6_Payloads.adoc | 19 +++++----- .../tck/test/edge/SendComplexDataTest.java | 18 +++++---- .../test/edge/SessionEstablishmentTest.java | 8 +++- 5 files changed, 49 insertions(+), 40 deletions(-) diff --git a/specification/src/main/asciidoc/chapters/Sparkplug_3_Components.adoc b/specification/src/main/asciidoc/chapters/Sparkplug_3_Components.adoc index c2e27975..94de3abe 100644 --- a/specification/src/main/asciidoc/chapters/Sparkplug_3_Components.adoc +++ b/specification/src/main/asciidoc/chapters/Sparkplug_3_Components.adoc @@ -59,9 +59,10 @@ Sparkplug Edge Node. A Sparkplug Command is a strongly typed, callable function exposed by a Sparkplug Edge Node or Device. A command declares a typed signature consisting of the input arguments it accepts and the -output results it returns, and it is included in the BIRTH certificate alongside the Edge Node's -or Device's other metrics. A Host Application invokes a command using a correlated request/response -exchange so that returned data and error codes can be reliably matched back to the request. Commands +output results it returns, and it is included in the NMETA or DMETA alongside the Edge Node's +or Device's other metric definitions. A Host Application invokes a command using a correlated +request/response exchange so that returned data and error codes can be reliably matched back to the +request. Commands are optional. An Edge Node or Device may expose no commands at all. The structure and behavior of commands are defined in the link:#payloads_p_command[Command Section] and the link:#operational_behavior_commands_typed[Typed Commands and Command Responses Section]. diff --git a/specification/src/main/asciidoc/chapters/Sparkplug_5_Operational_Behavior.adoc b/specification/src/main/asciidoc/chapters/Sparkplug_5_Operational_Behavior.adoc index 0fd09dcf..2d214d30 100644 --- a/specification/src/main/asciidoc/chapters/Sparkplug_5_Operational_Behavior.adoc +++ b/specification/src/main/asciidoc/chapters/Sparkplug_5_Operational_Behavior.adoc @@ -1645,10 +1645,10 @@ long as they have different timestamps. all metrics where is_historical=false, NBIRTH and NDATA messages MUST keep metric values in chronological order in the list of metrics in the payload.*# * [tck-testable tck-id-operational-behavior-data-publish-node-metric-datatype]#[yellow-background]*[tck-id-operational-behavior-data-publish-node-metric-datatype] For -all metrics defined in an NMETA, the datatype of the value carried in subsequent NDATA messages -MUST match the datatype declared for that metric in the NMETA. If it does not, the Host Application -MUST send a rebirth request to the offending Edge Node, following the rules in the -link:#operational_behavior_rebirth[Rebirth Requests] section.*# +all metrics defined in an NMETA, the value carried in subsequent NDATA messages MUST use the +TypedValue field that the datatype declared for that metric in the NMETA maps to. If it does not, +the Host Application MUST send a rebirth request to the offending Edge Node, following the rules in +the link:#operational_behavior_rebirth[Rebirth Requests] section.*# Rules for Device data (DBIRTH and DDATA) messages: @@ -1672,15 +1672,15 @@ long as they have different timestamps. all metrics where is_historical=false, DBIRTH and DDATA messages MUST keep metric values in chronological order in the list of metrics in the payload.*# * [tck-testable tck-id-operational-behavior-data-publish-device-metric-datatype]#[yellow-background]*[tck-id-operational-behavior-data-publish-device-metric-datatype] For -all metrics defined in a DMETA, the datatype of the value carried in subsequent DDATA messages -MUST match the datatype declared for that metric in the DMETA. If it does not, the Host Application -MUST send a rebirth request to the offending Edge Node, following the rules in the -link:#operational_behavior_rebirth[Rebirth Requests] section.*# +all metrics defined in a DMETA, the value carried in subsequent DDATA messages MUST use the +TypedValue field that the datatype declared for that metric in the DMETA maps to. If it does not, +the Host Application MUST send a rebirth request to the offending Edge Node, following the rules in +the link:#operational_behavior_rebirth[Rebirth Requests] section.*# ** Non-normative comment: a mismatch is evaluated against the declaration in the NMETA or DMETA, which a rebirth does not change, so an Edge Node that keeps publishing the same mismatched value -will keep mismatching after the rebirth it triggered. A Host Application is expected to apply the -rate limiting described in the Rebirth Requests section rather than to request a rebirth for every -offending message. +will keep mismatching after the rebirth it triggered. A Host Application is expected to limit the +rate at which it requests rebirths for this condition rather than to request one for every offending +message. [[operational_behavior_commands]] === Commands @@ -1775,10 +1775,10 @@ For Edge Node level commands, the following rules must be followed. * [tck-testable tck-id-operational-behavior-commands-ncmd-verb]#[yellow-background]*[tck-id-operational-behavior-commands-ncmd-verb] An Edge Node level command MUST use the NCMD Sparkplug verb.*# * [tck-testable tck-id-operational-behavior-commands-ncmd-metric-name]#[yellow-background]*[tck-id-operational-behavior-commands-ncmd-metric-name] An -NCMD message SHOULD include a metric name that was included in the associated NBIRTH message for the -Edge Node.*# -** Sparkplug Edge Node Applications should be resilient to receiving metrics names that were not -included in the NBIRTH message. +NCMD message SHOULD identify a metric that was defined in the associated NMETA for the Edge +Node.*# +** Sparkplug Edge Node Applications should be resilient to receiving metrics that were not defined +in the NMETA. * [tck-testable tck-id-operational-behavior-commands-ncmd-metric-value]#[yellow-background]*[tck-id-operational-behavior-commands-ncmd-metric-value] An NCMD message MUST include a compatible metric value for the metric name that it is writing to.*# ** In other words, if the metric has a datatype of a boolean the value must be true or false. @@ -1788,10 +1788,9 @@ For Device level commands, the following rules must be followed. * [tck-testable tck-id-operational-behavior-commands-dcmd-verb]#[yellow-background]*[tck-id-operational-behavior-commands-dcmd-verb] A Device level command MUST use the DCMD Sparkplug verb.*# * [tck-testable tck-id-operational-behavior-commands-dcmd-metric-name]#[yellow-background]*[tck-id-operational-behavior-commands-dcmd-metric-name] A -DCMD message SHOULD include a metric name that was included in the associated DBIRTH message for the -Device.*# -** Sparkplug Edge Node Applications should be resilient to receiving metrics names that were not -included in the DBIRTH message. +DCMD message SHOULD identify a metric that was defined in the associated DMETA for the Device.*# +** Sparkplug Edge Node Applications should be resilient to receiving metrics that were not defined +in the DMETA. * [tck-testable tck-id-operational-behavior-commands-dcmd-metric-value]#[yellow-background]*[tck-id-operational-behavior-commands-dcmd-metric-value] A DCMD message MUST include a compatible metric value for the metric name that it is writing to.*# ** In other words, if the metric has a datatype of a boolean the value must be true or false. diff --git a/specification/src/main/asciidoc/chapters/Sparkplug_6_Payloads.adoc b/specification/src/main/asciidoc/chapters/Sparkplug_6_Payloads.adoc index 9e3cea8e..b8646058 100644 --- a/specification/src/main/asciidoc/chapters/Sparkplug_6_Payloads.adoc +++ b/specification/src/main/asciidoc/chapters/Sparkplug_6_Payloads.adoc @@ -248,7 +248,7 @@ message Payload { repeated Metric arguments = 1; // Input argument definitions (NMETA/DMETA) or supplied argument values (NCMD/DCMD) - omitted for commands that accept no inputs repeated Metric results = 2; // Result/output argument definitions (NMETA/DMETA) or returned result values (NRESP/DRESP) - omitted for commands that return no outputs string correlation_id = 3; // Set on an NCMD/DCMD request and echoed unchanged in the corresponding NRESP/DRESP response - Status status = 4; // Execution status - present in NRESP/DRESP responses, omitted in BIRTH definitions and CMD requests + Status status = 4; // Execution status - present in NRESP/DRESP responses, omitted in META definitions and CMD requests } // An array of scalar values of one type, used both by the array DataTypes and by @@ -314,7 +314,7 @@ message Payload { message Metric { string name = 1; // Metric name - Required wherever the metric is not identified by an alias assigned in the META - uint64 alias = 2; // Metric alias - tied to the name in the META and used in place of it in value-carrying messages + uint64 alias = 2; // Metric alias - tied to the name in the META and used in place of it wherever the metric is reported int64 timestamp = 3; // Metric value change time - the time this metric's value last changed - if omitted, the overall payload timestamp is assumed as the metric value change time DataType datatype = 4; // DataType of the metric/tag value uint32 quality = 5; // Quality code of the metric/tag value - severity in bits 30-31 @@ -753,9 +753,9 @@ data structures. For example, ‘outputs/A’ would be a metric with a unique id ‘outputs’ folder. There is no limit to the number of folders. However, across the infrastructure of MQTT publishers a defined folder should always remain a folder. ** [tck-testable tck-id-payloads-name-requirement]#[yellow-background]*[tck-id-payloads-name-requirement] The -name MUST be included with every metric in a message that conveys metric definitions. In a -value-carrying message the name MUST be included unless an alias was assigned to that metric in the -NMETA or DMETA.*# +name MUST be included with every metric in a full NMETA or DMETA and with every ADD metric in an +NMMETA or DMMETA. In any other message the name MUST be included unless an alias was assigned to +that metric in the NMETA or DMETA.*# ** All UTF-8 characters are allowed in the metric name. However, special characters including but not limited to the following SHOULD NOT be used: . , \ @ # $ % ^ & * ( ) [ ] { } | ! ` ~ : ; ' " < > ?. Many Sparkplug Host Applications may have issues handling these characters. In addition, leading and @@ -776,11 +776,12 @@ the metric friendly name, which reduces overall message size. **** Non-normative comment: In effect, this means a metric alias, when used, must be unique across the entire Edge Node and all of its Sparkplug Devices. *** [tck-testable tck-id-payloads-alias-assigned]#[yellow-background]*[tck-id-payloads-alias-assigned] If -an alias was assigned to a metric in the NMETA or DMETA, a value-carrying message that reports -that metric MUST identify it by its alias and MUST omit its metric name.*# +an alias was assigned to a metric in the NMETA or DMETA, any message other than an NMETA, NMMETA, +DMETA, or DMMETA that reports or targets that metric MUST identify it by its alias and MUST omit its +metric name.*# *** [tck-testable tck-id-payloads-alias-not-assigned]#[yellow-background]*[tck-id-payloads-alias-not-assigned] If -no alias was assigned to a metric in the NMETA or DMETA, a value-carrying message that reports -that metric MUST identify it by its metric name.*# +no alias was assigned to a metric in the NMETA or DMETA, any message other than an NMETA, NMMETA, +DMETA, or DMMETA that reports or targets that metric MUST identify it by its metric name.*# * *timestamp* ** This is the timestamp in the form of a signed 64-bit integer representing the number of nanoseconds since epoch (Jan 1, 1970). diff --git a/tck/src/main/java/org/eclipse/sparkplug/tck/test/edge/SendComplexDataTest.java b/tck/src/main/java/org/eclipse/sparkplug/tck/test/edge/SendComplexDataTest.java index 715b0277..c859db6b 100644 --- a/tck/src/main/java/org/eclipse/sparkplug/tck/test/edge/SendComplexDataTest.java +++ b/tck/src/main/java/org/eclipse/sparkplug/tck/test/edge/SendComplexDataTest.java @@ -466,17 +466,21 @@ public void checkAliasInData(final @NotNull PayloadOrBuilder sparkplugPayload, S logger.debug( "Check Req: a metric is identified by its alias if the META assigned one, otherwise by its name."); - boolean isValid = false; + boolean isValid = true; if (topic.contains(TOPIC_PATH_NDATA) || topic.contains(TOPIC_PATH_DDATA) || topic.contains(TOPIC_PATH_NCMD) || topic.contains(TOPIC_PATH_DCMD)) { + // Every metric must carry exactly one identifier. Which one is correct depends on + // whether the META assigned an alias, which this test cannot see, so this is the + // closest check available until the TCK handles the META messages. for (Metric m : sparkplugPayload.getContent().getMetricsList()) { - if (!m.getIsNull() && ((m.hasAlias() && (!m.hasName() || m.getName().length() == 0)) - || (!m.hasAlias() && (m.hasName() || m.getName().length() > 0)))) - isValid = true; - break; + final boolean hasName = m.hasName() && m.getName().length() > 0; + if (hasName == m.hasAlias()) { + isValid = false; + break; + } } - testResults.put(ID_PAYLOADS_ALIAS_NOT_ASSIGNED, - setResult(isValid, PAYLOADS_ALIAS_NOT_ASSIGNED)); + Utils.setResultIfNotFail(testResults, isValid, ID_PAYLOADS_ALIAS_NOT_ASSIGNED, + PAYLOADS_ALIAS_NOT_ASSIGNED); } } diff --git a/tck/src/main/java/org/eclipse/sparkplug/tck/test/edge/SessionEstablishmentTest.java b/tck/src/main/java/org/eclipse/sparkplug/tck/test/edge/SessionEstablishmentTest.java index 754b9d5f..5409e49a 100644 --- a/tck/src/main/java/org/eclipse/sparkplug/tck/test/edge/SessionEstablishmentTest.java +++ b/tck/src/main/java/org/eclipse/sparkplug/tck/test/edge/SessionEstablishmentTest.java @@ -650,7 +650,9 @@ public void checkNBirth(final @NotNull PublishPacket packet) { metric_names.add(name); } - if (!m.hasName() || !Utils.hasValue(m)) { + // Identified by alias when the META assigned one, otherwise by name, so either + // identifier satisfies this; requiring the name would fail every aliased Edge Node. + if (!(m.hasAlias() || m.hasName()) || !Utils.hasValue(m)) { testResults.put(ID_TOPICS_NBIRTH_METRICS, setResult(false, TOPICS_NBIRTH_METRICS)); } else if (testResults.get(ID_TOPICS_NBIRTH_METRICS) == null) { testResults.put(ID_TOPICS_NBIRTH_METRICS, setResult(true, TOPICS_NBIRTH_METRICS)); @@ -889,7 +891,9 @@ public void checkDBirth(final @NotNull PublishPacket packet) { Set metric_names = new HashSet(); List metrics = sparkplugPayload.getContent().getMetricsList(); for (Metric m : metrics) { - if (!m.hasName() || !Utils.hasValue(m)) { + // Identified by alias when the META assigned one, otherwise by name, so either + // identifier satisfies this; requiring the name would fail every aliased Edge Node. + if (!(m.hasAlias() || m.hasName()) || !Utils.hasValue(m)) { testResults.put(ID_TOPICS_DBIRTH_METRICS, setResult(false, TOPICS_DBIRTH_METRICS)); } else if (testResults.get(ID_TOPICS_DBIRTH_METRICS) == null) { testResults.put(ID_TOPICS_DBIRTH_METRICS, setResult(true, TOPICS_DBIRTH_METRICS));