Repository navigation
[#449] A Metric's datatype belongs in META, not alongside a value - #662
wes-johnson wants to merge 1 commit into
Conversation
ckienle
left a comment
There was a problem hiding this comment.
Making it a MUST NOT is fine; three things need to line up with the rest of v4 first.
Required (not in the diff, so here): the NCMD and DCMD examples and prose still contradict the new MUST NOT. NCMD example carries "datatype": "Boolean" (Payloads.adoc:2726) and "datatype": "Command" (:2757), and the prose at :2738 says that for a Command invocation "the metric datatype is Command". DCMD example carries "Boolean" and "Int32" (:2821, :2826). Only the DDATA example was corrected. (The Command argument datatypes, e.g. :2762, are argument values, not the metric datatype, so they stay.)
Optional (not in the diff):
operational-behavior-data-publish-node-metric-datatype/-device-metric-datatype(Operational_Behavior.adoc:1647, :1673) already say a datatype change in NDATA/DDATA means the Host MUST send a Rebirth Request.metric-datatype-data-mismatch-rebirthis a second testable id for the same behaviour; cross-reference or merge them. Those two also still say "NBIRTH".- A publisher that keeps sending a mismatching datatype triggers a Rebirth per DATA message. One line on whether rebirth requests should be rate-limited would help (same shape as the invalid-UTF-8 case in #646).
| datatype MUST be included with each metric definition in NBIRTH and DBIRTH messages.*# | ||
| ** [tck-testable tck-id-payloads-metric-datatype-not-req]#[yellow-background]*[tck-id-payloads-metric-datatype-not-req] The | ||
| datatype SHOULD NOT be included with metric definitions in NDATA, NCMD, DDATA, and DCMD messages.*# | ||
| datatype MUST NOT be included with metric definitions in NDATA, NCMD, DDATA, and DCMD messages. A |
There was a problem hiding this comment.
Required: this cites the v3 model. In v4, BIRTH MUST NOT carry a datatype at all - tck-id-topics-nbirth-no-metadata (Topics.adoc:446) and tck-id-topics-dbirth-no-metadata (:879): datatype is conveyed "only in the NMETA and NMMETA" (DMETA/DMMETA for Devices), and none of the v4 BIRTH examples carry one. So "established by the NBIRTH or DBIRTH that defined it" and "a change of datatype is published as an amended BIRTH" should refer to NMETA/DMETA and NMMETA/DMMETA, here and in the two new receiver rules below. metric-datatype-req just above (:820, "MUST be included ... in NBIRTH and DBIRTH") has the same problem; pre-existing, but worth fixing in the same pass.
There was a problem hiding this comment.
You're right, and this was the premise the whole change rested on. Rewritten in 61faf0c, and the branch squashed to one commit since the earlier three described the wrong model.
payloads-metric-datatype-req now requires the datatype in NMETA and DMETA, and in an NMMETA or DMMETA that adds or updates a definition — so it no longer contradicts topics-nbirth-no-metadata and topics-dbirth-no-metadata. That contradiction predated this PR, as you noted; it is fixed here rather than left.
-not-req is a MUST NOT over NBIRTH, DBIRTH, NDATA and DDATA, and the three receiver rules refer to the META-established datatype throughout.
One distinction that turned out to be load-bearing. These govern a Metric's own datatype field, not the TypedValue's. The TypedValue's selects which field the value occupies, so it is structural rather than metadata and has to stay. In Protocol Buffers they are separate fields and only the Metric's is omitted — but in JSON the flattening in payloads-json-typedvalue-flat merges them into one datatype key, so a metric carrying a value still has that key.
Without stating that, the rule is unsatisfiable in JSON: the key you would have to omit is the one that makes the value readable. There is now a non-normative comment saying which datatype the key represents in these messages.
It is also why the DDATA example keeps "datatype": "Float". An earlier revision of this PR removed it, which was wrong — that key is the flattened TypedValue's and -json-typedvalue-flat makes it mandatory.
| the datatype established for that metric by the NBIRTH or DBIRTH that defined it, and MUST NOT | ||
| apply any metric value from that message.*# | ||
| ** [tck-testable tck-id-payloads-metric-datatype-data-mismatch-rebirth]#[yellow-background]*[tck-id-payloads-metric-datatype-data-mismatch-rebirth] Having | ||
| rejected such a message, a consuming application MUST send a Rebirth Request to the Edge Node, as |
There was a problem hiding this comment.
Required: for NCMD and DCMD the "consuming application" is the Edge Node, and it cannot send itself a Rebirth Request. Suggest scoping this rule to a Host Application receiving NDATA/DDATA, and saying what an Edge Node does with a mismatching datatype in an NCMD/DCMD (reject it, presumably nothing more).
There was a problem hiding this comment.
Agreed, and the fix went further than scoping. NCMD and DCMD are now out of scope throughout, not just for the Rebirth rule.
A Command invocation is identified by a metric datatype of Command — the schema says the command field is "present when datatype == Command instead of 'value'", and the prose at :2738 says "the metric datatype is Command". A MUST NOT over CMD would make a Command invocation unidentifiable, so the previous revision was unsound for CMD rather than merely awkward.
That also answers your required finding about the NCMD and DCMD examples: they keep their datatypes, because the rule no longer reaches those messages. The "datatype": "Command" at :2757 is exactly the case that makes the exclusion necessary.
The three receiver rules are now stated for a Sparkplug Host Application, which is the party that can request a Rebirth, and the TCK check moves from NDATA/DDATA/NCMD/DCMD to NBIRTH/DBIRTH/NDATA/DDATA.
84d3b2f to
61faf0c
Compare
|
Rewritten in 61faf0c and squashed to one commit, since the earlier three described a model the specification had already moved past. Your required findings, and what happened to each: BIRTH does not carry a datatype in v4. Correct, and it invalidated the premise of the whole change — including the decision recorded for #449, which predates the metadata separation. The Rebirth rule was incoherent for CMD. Correct, and the fix is wider than scoping: NCMD and DCMD are out of scope throughout. A Command invocation is identified by a metric datatype of The NCMD and DCMD examples contradict the rule. They no longer do, because the rule no longer reaches those messages. The Working through this surfaced one thing neither of us had raised: the rule had to be scoped to a Metric's own datatype field, not the Your two optional items are not addressed here, deliberately:
|
61faf0c to
3547f45
Compare
|
Both taken, one here and one separately. The Chapter 5 duplicates are folded into this PR. You were right that they describe the same behaviour, and the stale "NBIRTH" wording made them describe something that cannot happen: the datatype must not change "in subsequent NDATA messages", when NDATA carries no Metric datatype at all under the corrected model. Both now state the publisher rule in terms of the META — the datatype of a defined metric changes only in an NMMETA or DMMETA — and refer to the Payloads chapter for the Host Application's response rather than stating it a second time. The ids are kept, so nothing conformance-visible is removed, and neither is implemented in the TCK today so no coverage moves. "an DBIRTH" is fixed with them. Rate-limiting is #663. It generalises past this rule — the reordering timeout has the same exposure, and the invalid-UTF-8 case you raised on #646 is the same shape — so putting it inside any one of them would leave the others unaddressed and state it in several places. The issue notes the case most likely to bite: between sending a Rebirth Request and receiving the BIRTH, every further DATA message still mismatches and would trigger another. |
…gside a value The 4.0.0 features document recorded "MUST be included in BIRTH and MUST NOT in DATA", and the chapter said SHOULD NOT, so the decision and the text had been out of step since it was taken. Both predate the metadata separation, which moved a metric's datatype out of the BIRTH altogether: the Topics chapter says the datatype is conveyed only in the NMETA and NMMETA, or the DMETA and DMMETA for a Device, and says it for the BIRTH and REBIRTH of each. payloads-metric-datatype-req therefore contradicted those, by requiring the datatype in NBIRTH and DBIRTH. It now requires it in NMETA and DMETA, and in an NMMETA or DMMETA that adds or updates a definition. payloads-metric-datatype-not-req becomes a MUST NOT, scoped to NDATA and DDATA, which are the message types the Topics chapter does not already cover. The BIRTH and REBIRTH cases are cross-referenced rather than restated. This governs a Metric's own datatype field and not the datatype of the TypedValue carrying the value, which selects the field the value occupies and is structural rather than metadata. In the Google Protocol Buffers encoding the two are separate fields and only the Metric's is omitted. In the JSON encoding a Metric's TypedValue is flattened, so a metric carrying a value still has a datatype key, and in these messages that key is the TypedValue's. payloads-json-typedvalue-carries-both required a converting application to set both the Metric field and the TypedValue field from that single key, which would have produced a Protocol Buffers payload breaking the rule the JSON payload was keeping. It now sets the TypedValue field only where a Metric datatype is not permitted. Three receiver rules follow, over every message that carries values rather than definitions, and stated for a Sparkplug Host Application because it is the party that can request a Rebirth. A Metric datatype field equal to the one established in the META is a harmless redundancy and MUST be ignored. One that differs is a disagreement about the metric's type, so the message MUST be rejected with none of its metric values applied, and a Rebirth Request MUST follow - the same response the specification already gives to an unresolved sequence gap. NCMD and DCMD are out of scope throughout: a Command invocation is identified by a metric datatype of Command, so the field is load bearing there. operational-behavior-data-publish-node-metric-datatype and -device-metric-datatype described the same scenario in the v3 model, requiring that the datatype not change "in subsequent NDATA messages", which cannot happen now that NDATA carries no Metric datatype at all. They now state the publisher rule in terms of the META and refer to the Payloads chapter for the Host Application's response. On the TCK side the check moves from NDATA/DDATA/NCMD/DCMD to NBIRTH/DBIRTH/NDATA/DDATA, is scored as a MUST rather than through setShouldResult, and its log text no longer says SHOULD NOT.
3547f45 to
533811d
Compare
|
Swept the chapters for anything else contradicting the corrected model, and found two more. Both fixed in 533811d.
NREBIRTH and DREBIRTH were uncovered, and BIRTH was stated twice. The Topics chapter already forbids a metric datatype in NBIRTH, NREBIRTH, DBIRTH and DREBIRTH. My
After that, the statements across the three chapters divide cleanly with no overlap:
One thing worth noting for anyone writing a cross-reference in future: spelling the referenced assertion ids out in prose broke the exactly-twice rule, since the audit counts every occurrence of the literal text. The reference names the message types instead. |
|
Closing in favour of #664, which carries the part of this that stands on its own. A
The pattern across two rewrites is that each fix exposed another seam in the META model, so the right split is:
The receiver rules are not carried forward anywhere yet. They need the rebirth loop bounded and the JSON question answered first: in the JSON encoding the single Thank you for the review on this one — the first finding is what unpicked the whole premise, and the rest followed from it. |
Addresses #449. A metric's datatype belongs in the META, not alongside a value.
The premise was wrong, and is corrected here
The 4.0.0 features document recorded "MUST be included in BIRTH and MUST NOT in DATA", and the chapter said SHOULD NOT, so decision and text had been out of step since it was taken. Both predate the metadata separation, which moved a metric's datatype out of the BIRTH altogether:
(and
-dbirth-no-metadatafor DMETA/DMMETA.)payloads-metric-datatype-reqtherefore contradicted those two, requiring the datatype in NBIRTH and DBIRTH. That contradiction predates this PR and is fixed in it.What the rules now say
-metric-datatype-req-metric-datatype-not-req-data-ignored-data-mismatch-data-mismatch-rebirthThe Rebirth is the same response the specification already gives to an unresolved sequence gap, and its only mechanism for re-establishing a metric definition. The receiver rules are stated for a Host Application because it is the party that can request one.
The distinction that makes this work
These govern a Metric's own datatype field, not the datatype of the
TypedValuecarrying the value. The TypedValue's selects which field the value occupies, so it is structural rather than metadata and stays.In the Protocol Buffers encoding the two are separate fields and only the Metric's is omitted. In the JSON encoding a Metric's TypedValue is flattened —
payloads-json-typedvalue-flatrequires its datatype to be carried by the enclosing Metric'sdatatypekey — so a metric carrying a value still has that key, and in these messages it is the TypedValue's. A non-normative comment says so, because the two are otherwise indistinguishable in JSON.This is also why the DDATA example keeps its
"datatype": "Float": that key is the flattened TypedValue's and-json-typedvalue-flatmakes it mandatory.NCMD and DCMD are out of scope
A Command invocation is identified by a metric datatype of
Command— the schema says thecommandfield is "present when datatype == Command instead of 'value'" — so the field is load-bearing there and a MUST NOT would make a Command unidentifiable. The previous revision of this PR covered CMD; that was wrong.The Chapter 5 duplicates, now folded in
operational-behavior-data-publish-node-metric-datatypeand-device-metric-datatypedescribed the same scenario in the v3 model — the datatype must not change "in subsequent NDATA messages" — which cannot happen now that NDATA carries no Metric datatype at all. They also still said "NBIRTH".Both now state the publisher rule in terms of the META (the datatype of a defined metric changes only in an NMMETA or DMMETA) and refer to the Payloads chapter for what a Host Application does with a disagreeing message, rather than stating that a second time. The ids are kept, so nothing conformance-visible is removed; neither is implemented in the TCK today, so no coverage changes. The grammar slip "an DBIRTH" is fixed with them.
TCK
The check moves from NDATA/DDATA/NCMD/DCMD to NBIRTH/DBIRTH/NDATA/DDATA, is scored as a MUST rather than through
setShouldResult(which records a MAYBE, not a failure), and its log text no longer says SHOULD NOT.Metric.hasDatatype()tests the Metric's own field, which is the right one.Not in this PR
Rate-limiting Rebirth Requests is filed as #663. It generalises across every rule that requires a Rebirth — the reordering timeout, this one, and the invalid-UTF-8 case from #646 — so stating it inside any single rule would leave the others unaddressed.
Verification
Build successful, 10/10 unit tests. JSON Schema valid draft 2020-12, 22/22 chapter examples validate. All five assertion ids appear exactly twice; tck-id-anomaly (7) and broken-anchor (11) baselines unchanged. The
operational_behavior_rebirthlink target verified to exist.git diff --checkclean.