Comparing deliveries
A project that passes every consistency check is internally sound: its components agree with each other, every input has a producer, every reference resolves. That verdict says nothing at all about the software already running in the field, in a test bench or in somebody else’s integration, and about whether the delivery being prepared can be dropped in where that one sits today. The two are different questions, they are wrong in different ways, and DDD answers them with two different commands.
Two questions, not one
ddd check answers do these components fit together. It reads the description files of
the project, resolves them into a data dictionary and reports every
disagreement it finds inside that one delivery. Everything it needs is on disk in front of
it, which is why it can run on a developer’s machine before the first compilation.
ddd compare answers can this delivery replace the one already out there. That is a
question about two deliveries, and it is directional: it asks whether everything the
previous delivery offered is still there and still means the same thing, not whether the two
are identical. A delivery that adds ten new measurements is a perfectly good replacement; a
delivery that quietly turns a uint16 into a uint32 is not, even though it is
internally just as consistent as its predecessor.
The two questions stay separate on purpose, because a project can be internally consistent and still be an invalid replacement, and a project can be a faithful replacement while being internally broken. Neither answer implies the other.
Why the second question needs an archived dictionary
The obvious way to compare two deliveries would be to compare their description files, but the sources of the previous delivery have moved on. The working tree that produced it has been committed over, the components have been renamed or split, the include patterns now match different files, and the paths inside them point at a directory layout that no longer exists. Reconstructing the released delivery from a version control tag is possible in principle and unreliable in practice, and it is impossible altogether when the delivery came from another company as a binary with an a2l next to it.
The artefact to archive is therefore not the sources but the dictionary they resolve to.
ddd dump writes it as a single self-contained json document, with every value already
worked out: the shape of each object, the limits (as given, or as derived from the datatype
and the conversion), the owning component and the list of components that read it.
ddd dump examples/pressure/release/pressure.ddd.json > examples/pressure/release/PressureLoop-1.4.0.json
{
"name": "ValveDuty",
"id": "4tnm8r7mst6h",
"extensions": {},
"kind": "measurement",
"datatype": "uint8",
"description": "Commanded valve duty cycle",
"unit": "%",
"conversion": {
"kind": "linear",
"factor": 0.5,
"offset": 0.0
},
"limits": {
"min": 0,
"max": 100
},
"shape": [],
"dimensions": [],
"init": null,
"section": null,
"raster": null,
"volatile": false,
"condition": null,
"references": {},
"owner": "Controller",
"consumers": [
"Actuator"
],
"local": false,
"a2l": {
"export": true,
"format": null,
"display_identifier": null
}
}
Nothing in that document refers to a file, a glob or a directory, so it keeps its meaning for
as long as the binary it was archived next to is in use. It carries a "format" version at
its top level, and its schema is published with ddd schema dictionary, so a delivery
archived today stays readable by a later release of the tool and by tools DDD does not ship.
Note
ddd dump writes the dictionary to stdout and its diagnostics to stderr, in both output
formats. That is what makes ddd dump project.ddd.json > baseline.json safe: a second
json document can never end up in the archived file. What a redirection cannot promise is
the bytes, which the shell writes: the > of Windows PowerShell 5.1 re-encodes the
dictionary as UTF-16, which ddd compare refuses to read back.
ddd dump project.ddd.json -o baseline.json writes the file itself, as utf-8 on every
platform, and is the spelling for a script that may run there.
The workflow
Archiving happens once, at release time, next to the binary and the a2l that were released with it. Comparing happens on every candidate that comes after it:
ddd dump project.ddd.json > baseline.json # at release time
ddd compare baseline.json project.ddd.json # later, for the next delivery
ddd check project.ddd.json --baseline baseline.json # both questions, one exit code
ddd check --baseline exists because a ci job wants one command and one exit code. It runs
the consistency checks on the project and, on the same dictionary, the comparison against the
archived one, and reports both sets of findings together. ddd compare does the same for
its candidate side: when the candidate is a project description rather than a dump, its own
consistency findings are reported alongside the comparison.
Either side may be a dump or a description. ddd compare looks at what a file contains
rather than at its name, so an archived dictionary, a project description and a single
component description are all acceptable on either side. Comparing two archived dumps is the
release-to-release case, comparing a dump with the working tree is the daily case, and
comparing two working trees is how a branch is judged against the trunk it will be merged
into. Nothing has to be staged into a temporary file first. A json file that is neither -
one that states no format, no project and no component, a file holding only a name
for one - is no delivery, and is refused on either side in those words rather than read as an
empty dictionary, of which every object would be an addition or a removal.
ddd compare has no --standalone. It reads a component file given as the baseline under the
floor ddd check --standalone reads one under, whether or not it is told so, as the section
below on the baseline says; a component file given as the candidate it reads as a project’s file
is read, so that an input nobody in the file produces is an error of the candidate. A supplier
comparing two versions of a component with inputs therefore uses
ddd check --baseline --standalone, the command that takes the option.
Renames
A rename is invisible to a comparison keyed on names alone: the old spelling is a removal and
the new one an unrelated addition, the two never meet, and a rename that also widened a
datatype or rescaled a conversion is not reported at all - only that one name left and another
arrived. An id on the producing declaration is what relates them, so adopting one turns
the workflow above into:
ddd id --assign components/*.ddd.json # once, per project
ddd dump project.ddd.json > baseline.json # at release time
ddd compare baseline.json project.ddd.json --renames renames.json # later, for the next delivery
renames.json holds one entry per renamed object - its id, its old name under from
and its new one under to; a member of a renamed structured variable is listed under the
instance’s id followed by the member’s path below the instance as the access path spells it,
k7m2q9xr4t8w.value for a member of a single structure and k7m2q9xr4t8w[2].raw for one
of the third element of an array of them, so that every entry has an id of its own:
[{ "id": "k7m2q9xr4t8w", "from": "FiltGain", "to": "FilterGain" }]
sorted by the new name, and written whether or not the comparison found errors, since a delivery that cannot be accepted still needs its renames listed so that whoever fixes it knows what moved. This is what a calibration dataset, a recorded measurement or a test script keyed by the old spelling is migrated with.
The comparison itself reports renamed-object for each pair it finds this way, or
renamed-read-object, an error, for a pair whose object a component reads, and the
ordinary interface comparison still runs across the pair, so a rename that also changed the
object is no longer invisible. The rename’s pair of ids runs the other way from the removals’:
renamed-object keeps the plain id for the unread rename, since a relaxation of it that a
project already gives must not reach the rename of an object a component reads. And where a spelling freed by a rename has been claimed by a
different object in the same delivery, it reports reused-name instead - the failure that
binds an old dataset to new storage without anything about the delivery looking broken.
A structured variable renamed with its id kept is each leaf’s renamed-object, or
renamed-read-object where a component reads the variable, and nothing more for the display identifiers a member composes, V.J.b becoming W.J.b, since the
instance’s name at their head is the rename told again; an identifier that changed in any other
way, or one a leaf’s own member states, is still changed-a2l.
A structured variable of a structure that holds members of external types alone, at any depth,
has no leaf, because DDD cannot see into storage its own types do not describe, and so nothing says its removal, its
rename or its reuse: the variable is reported as an object is, at the variable. Dropped, it is
removed-object where a component read it and removed-unused-object where none did, and a
baseline that is a component file read alone grades it by its scope, as it does an object; renamed
with its id kept, it is renamed-read-object or renamed-object, and renames.json
lists it under its own id; another id under its name is reused-name; and one that arrived
is added-object. A variable that has leaves is not said a second time at the variable.
The comparison checks
Every difference between the two dictionaries is graded by what it costs the people who
already depend on the baseline. An error means their software is now wrong, whether or not it
still compiles; a warning means behaviour or tooling changes but no consumer becomes wrong;
information means the candidate offers something the baseline did not. The identifiers below
are the same kind of stable identifier as the consistency checks, and ddd checks prints
them together with everything else.
severity |
check |
reported when |
|---|---|---|
error |
|
an object of the baseline is gone and somebody read it, or an output of a component read alone, whose readers the run was not shown; a structured variable with no leaf is an object here |
error |
|
kind, datatype, unit, scaling, shape, axes, locality or where a table keeps its point counts changed, or the value of a constant, or the layout a released structure fixed: a bitfield’s width, the type a structured variable names, or the members of that structure in order, each with what it holds and its dimensions, nested and external ones included, an external one by its header too, save a member added at the end of it when the variable is no array, or volatile turned on for an object a component reads or an output of a component read alone |
error |
|
an object of the baseline that a component read, or an output of a component read alone, is offered under a different name, so a reader compiled against the baseline
looks for a spelling that is gone; its |
error |
|
the preprocessor condition of an object a component reads, or of any output of a component read alone, was added or replaced, so a reader compiled against the baseline does not
link in a build where the new condition is false; a |
error |
|
a name of the baseline now names a different object |
error |
|
a constant of the baseline is gone, so a reader that uses its macro no longer builds |
warning |
|
an object of the baseline is offered under a different name and no component read it;
its |
warning |
|
an object of the baseline is gone; no component read it, a structured variable with no leaf included |
warning |
|
the initial value, volatility, memory section or measurement raster of an object changed, or the event or cycle of a raster; volatile turned on for an object a component reads or an output of a component read alone is changed-interface instead |
warning |
|
the physical limits of an object got tighter, so calibrated data may not fit; on a
measurement a component reads, or on an output measurement of a component read alone, it is
|
warning |
|
the physical limits of a measurement a component reads, or of an output measurement of a component read alone, got wider, so a reader sized for the baseline’s range may meet a value it was not written for |
warning |
|
another component produces the object now |
warning |
|
the preprocessor condition of an object changed; one added or replaced on an object a
component reads, or on an output of a component read alone, is |
warning |
|
the a2l entry of an object changed |
warning |
|
the two sides of a comparison describe differently named projects |
warning |
|
a compared dictionary records a plugin that is not among the candidate’s, so that plugin’s comparison rules did not run |
info |
|
the candidate declares an object the baseline did not |
info |
|
the candidate declares a constant the baseline did not |
info |
|
the physical limits of a measurement a component reads, or of an output measurement of a component read alone, got tighter: a reader still gets values inside the range it was written for |
info |
|
an input of a component read alone is gone: the component stops reading it, which harms nobody |
changed-interface is one check rather than a dozen because the properties it covers -
kind, datatype, unit, conversion, shape, the axes an object refers to, whether it is
component local, and the layout a structure fixed for its consumers - are the properties a
consumer compiles against and calibrates against. Any one of them changing makes the consumer
wrong in the same way, and the message names which ones differ. A conversion compares by its
kind and its parameters, and an enum by its name together with its enumerators in order:
revaluing ON from 1 to 2 changes every reading of every recording keyed on it, while
documenting an enumerator changes nothing, so descriptions are no more compared here than
anywhere else. A dimension compares as its spelling and its value: a name from the
constant vocabulary and the number it stands for are
different spellings of one size, and the spelling is what the generated code carries, so
respelling [8] as ["PRESSURE_CELLS"] changes the interface even while the number
stands. A baseline archived before dictionary format 4 recorded no spellings at all, so
against such a baseline only the values are compared: adopting a constant for a size that
stands reads clean, and a changed size still does not. A dimension a constant names is told with the
size the constant gives, [N=8] != [N=4], because the spelling alone reads the same on both
sides of a size that changed behind it.
The layout of a structure is interface as well, because a reader
may be a binary compiled against the previous delivery’s headers, which takes each member out
of the offset those headers gave it. A bitfield narrowed from three bits to two changes the
value every reader takes out of the word, and widened it moves every member after it. A
structured variable’s layout is read from the dictionary’s types: the members of its
structure in order, a nested structure expanded into its own members whatever it is called,
an external member by its type’s name, its header and its dimensions, and every dimension by
its spelling and its value. A member inserted, removed, renamed or swapped with another leaves such a
reader reading a member other than the one it was built to read, while every member the two
deliveries share still compares identical to the byte - same path, same datatype, same
conversion, same limits - and so may a nested structure that grew or was rearranged, a nested
array that changed size, or an external member of another type, header or dimension. Each is
reported once, at every variable whose layout it changed, naming the structure and where the
two layouts part; a structure in no variable’s layout changes nothing anybody reads, and is
not compared. One change alone keeps every member where a reader of the previous delivery looks
for it: a member added after every member of the structure of a single variable, which is
the addition of its leaves and no more. Added to the structure of an array of structures, it
moves every element after the first, and added to a structure nested in another, it is that
structure grown, so neither is an addition alone. And a structured variable is compared as a
variable, not only through its members: its type is what every consumer’s header
declares, so renaming Sensor_t to Sensor2_t with the members untouched is a changed
interface, while a structure nested in it is reached through the member that holds it, so
renaming that one with its layout kept changes nothing. Its kind is the variable’s as well:
a measurement turned into a parameter is one edit of one declaration, and the declaration in
every reader’s header gains a const, so it is one changed-interface at the variable and
not one per member, a structure of external members included.
The vocabularies an object reaches the outputs through are compared as entries too, by name,
because a change in one of them changes what a reader or a measuring tool is given while every
object still compares identical to the byte. Every constant reaches the generated header as a
macro and the a2l as a SYSTEM_CONSTANT, whether or not an object is dimensioned by it, so a
constant whose value changed is changed-interface, said at the constant; a gain used by no
object is the case that was silent. An object the constant dimensions says its own shape at the
object as well, because the macro and the size are two facts and neither stands for the other. A
constant that is gone is removed-constant, an error, because a reader that uses the macro no
longer builds, and a constant that arrived is added-constant, an information, as an object
that arrived is. A constant that was renamed is two findings, removed-constant for the old name
and added-constant for the new one, because a constant has no id to pair a rename by. A baseline archived before dictionary format 4 recorded no
constants, so against one none is compared. A raster whose event number or cycle changed is changed-storage, said at the
raster: every IF_DATA that names it carries the event, and it is the event a measuring tool
receives the value in. The cycle compares as the period it resolves to, so 10ms respelled
10000us is no change. A raster that came or went says nothing, because an object that names it
says its own change of raster. The header of an external type is part of the layout above: the
generated header includes it, so a member of the same type from another header is another
definition to a reader compiled against the first, and it is the variable’s one
changed-interface. The sections a project declares are not yet compared, because the data
dictionary does not carry them; a change of a section’s access or alignment waits for it to.
A reader may be a binary compiled against the previous headers, and two edits cost it more
than they cost the people who keep an object nobody reads. Turning volatile on is a
changed interface for an object a component reads: a reader built without the qualifier now
reaches the object through an lvalue that is not volatile, which C leaves undefined, so the
finding is changed-interface, said once, at the variable for a structured one, and not
again as changed-storage. Renaming such an object is renamed-read-object: the reader
looks for a spelling that is gone. Both cannot replace the baseline. The same edits on an
object nobody reads stay changed-storage and renamed-object, warnings, and turning
volatile off is changed-storage everywhere. A structured variable’s rename is still
said under each leaf’s path, since a dataset is keyed by it, and each leaf answers for the
readers of its variable. -W renamed-object=ignore relaxes the warning only: an id carries
one severity, so the error stands under its own.
Wrapping an object a component reads in a condition costs its readers the same. Where the
condition is false the object is neither declared nor defined, so the builds of a reader compiled
against the baseline, which looks for it in every build, no longer link there. Adding a
condition to such an object, or replacing one with another - which DDD cannot weigh, and takes
as the builds the object is present in changing - is narrowed-condition, an error, naming
the readers. A condition going away puts the object in every build and stays
changed-condition, a warning, as does any change of a condition on an object nobody reads.
-W changed-condition=ignore relaxes the warning only, and does not reach this error.
changed-storage covers the four properties of an object that change how it behaves rather than
what it means, and the event and cycle of a raster: the initial value, volatile, the memory section and the measurement
raster; a variable that moved from the 100 ms event to the 1 ms one changes the a2l a
calibration engineer works with while invalidating nobody’s code. An initial value compares
as the bytes it produces and not as it was spelled - DDD offers 7 on a uint8[4] and
[7, 7, 7, 7] as two spellings of one array, and a string’s text as the character codes it
stands for - so a delivery that respells one without moving a byte still replaces its
predecessor. A scalar is the array it fills only when every element of the array holds it, so
two tables that differ in any element - a square map and its transpose - are two initial
values, and the finding names the first index they part at, in the order c lays the elements
out. -0.0 is not 0.0, since the sign bit is a stored byte, and changing one into the
other is a change of the initial value; in an integer datatype -0 is 0. An object stating
no initial value stores zeros, so adding 0, [0, 0] or "" to one that had none moves no
byte and is no change, in either direction. Where two of them do differ, the finding spells both the way the file spells
them, cut short past a few elements when the array is long, and names the first index they
part at. On a structured variable those three properties are the variable’s own, its members
having no volatility, section or raster of their own, and are reported at the variable, once,
as its producer and its condition are; what a member answers for is its own datatype,
meaning, shape, bit width and a2l entry. A member’s own change is reported at every path that
reaches it - an edit of one member of a structure that two arrays of a thousand hold is told at
each element - and the paths are in the order ddd list gives them, an index counted as a number,
[2] before [10], as are the removals, the additions and the entries of renames.json.
changed-a2l covers the export flag, the display format and the display identifier, which
move labels around in a calibration tool without touching the software.
volatile is graded differently here than it is inside a project, where it is interface
and a disagreement is a definition-mismatch error - see Consistency checks. The
difference is who is left describing the object wrongly. Inside one project two components are
compiled together against one address, so one of them is compiled against an assumption that
does not hold. Between two deliveries there is only one answer at a time, but a reader may be a binary
compiled against the previous headers and never regenerated, which is why turning
volatile on is an error for an object a component reads, as above; what changed for an
object nobody reads is how it behaves. On a calibration object, volatile losing
its true is more than a change of behaviour in the abstract: the compiler is then entitled
to fold the value it was built with into the code that reads it, so the parameter keeps its
address and its a2l entry but stops being tunable while the software runs.
Two removals are distinguished because they cost different things. An object that a component read cannot simply disappear: the baseline names the components that read it, so DDD knows that the software which was built against it no longer builds, and that is an error. An object that no component read may still be named in a calibration dataset, in a measurement configuration or in an external tool that addresses it by name. DDD cannot see any of those, so its removal is a warning: it is reported so that somebody who can see them makes the decision, rather than a build being failed on a suspicion.
A worked example
The example below is a small project called PressureLoop, with three components: a
Sensor producing the raw measurements, a Controller computing a valve duty cycle from
them, and an Actuator consuming that duty cycle. The layout is the ordinary one, a
project file next to a directory of components, and the deliveries of the story ship with
DDD under examples/pressure, so every command below runs as shown from a checkout:
examples/pressure/release/
pressure.ddd.json the project
components/
sensor.ddd.json
controller.ddd.json
actuator.ddd.json
The delivery that went out
Sensor publishes three measurements and keeps one calibration parameter to itself - shown
here as it ships, identities included, without the $schema line that binds every shipped
file to its schema for the editor’s benefit:
{
"component": {
"name": "Sensor",
"interface": [
{
"scope": "output",
"definition": {
"name": "PressureRaw",
"id": "jh24xz65w9hs",
"kind": "measurement",
"description": "Manifold pressure",
"datatype": "uint16",
"unit": "kPa",
"conversion": {
"factor": 0.1
},
"limits": {
"min": 0,
"max": 400
},
"volatile": false
}
},
{
"scope": "output",
"definition": {
"name": "TemperatureRaw",
"id": "nb1f98w9yt2v",
"kind": "measurement",
"description": "Manifold temperature",
"datatype": "sint16",
"unit": "degC",
"conversion": {
"factor": 0.1
},
"limits": {
"min": -40,
"max": 150
},
"volatile": false
}
},
{
"scope": "output",
"definition": {
"name": "SupplyVoltage",
"id": "wcvef190n8h6",
"kind": "measurement",
"description": "Sensor supply voltage",
"datatype": "uint16",
"unit": "V",
"conversion": {
"factor": 0.001
},
"limits": {
"min": 0,
"max": 16
},
"volatile": false
}
},
{
"scope": "local",
"definition": {
"name": "FilterGain",
"id": "cxf129crsj6e",
"kind": "parameter",
"description": "Low pass gain of the pressure signal",
"datatype": "uint8",
"conversion": {
"factor": 0.01
},
"limits": {
"min": 0,
"max": 1
},
"init": 50,
"volatile": false
}
}
],
"description": "Reads the manifold sensors"
}
}
Controller reads PressureRaw and TemperatureRaw and produces ValveDuty
(uint8, %, factor 0.5, limits 0 to 100); Actuator reads ValveDuty and
SupplyVoltage. The producing declarations carry their identities, written by
ddd id --assign before the release went out - once, and for good, since the identity is
what lets a later delivery rename an object without the comparison reporting a removal and an
unrelated addition (Renames above). The project is consistent, so it is released, and its
dictionary is archived under the name of the release:
$ ddd check examples/pressure/release/pressure.ddd.json
ok: 5 variables in 3 components are consistent
$ ddd dump examples/pressure/release/pressure.ddd.json > examples/pressure/release/PressureLoop-1.4.0.json
The delivery that wants to replace it
Development continues in work/ (shipped as examples/pressure/work) - a copy of
release/, so it carries the same identities - and by the time the next delivery is
prepared five things have changed. PressureRaw was widened from uint16 to uint32
to leave room for a finer resolution later. TemperatureRaw was dropped, because the
controller now reads the temperature over the bus instead. The limits of ValveDuty were
tightened from 0 .. 100 to 0 .. 80, to protect a valve that turned out not to like being
driven fully open. The limits of SupplyVoltage were relaxed from 0 .. 16 to 0 .. 18, so
that an 18 V supply variant fits. And a new measurement, AmbientPressure, was added,
which Controller reads; being new, it was given an identity of its own by a second
ddd id --assign, which leaves the existing ones alone.
Each of those is a defensible change, and the candidate passes the consistency checks exactly as its predecessor did, because the components were all updated together:
$ ddd check examples/pressure/work/pressure.ddd.json
ok: 5 variables in 3 components are consistent
Against the archived dictionary, the same five changes look rather different:
$ ddd compare examples/pressure/release/PressureLoop-1.4.0.json examples/pressure/work/pressure.ddd.json
examples/pressure/work/pressure.ddd.json: error[changed-interface]: 'PressureRaw' is not the same object any more (datatype: uint32 != uint16), read by Controller
examples/pressure/work/pressure.ddd.json: error[removed-object]: 'TemperatureRaw' is gone, but was read by Controller
examples/pressure/work/pressure.ddd.json: warning[widened-limits]: 'SupplyVoltage': limits widened from [0, 16] to [0, 18], read by Actuator
examples/pressure/work/pressure.ddd.json: info[narrowed-read-limits]: 'ValveDuty': limits tightened from [0, 100] to [0, 80], read by Actuator
examples/pressure/work/pressure.ddd.json: info[added-object]: 'AmbientPressure' is new in PressureLoop (measurement, produced by Sensor)
2 errors, 1 warning, 2 infos
pressure.ddd.json cannot replace PressureLoop-1.4.0.json
Five findings for five changes. Widening PressureRaw is an error because every consumer
was compiled against a two-byte object and a calibration tool reads two bytes at its address;
removing TemperatureRaw is an error because the baseline records that Controller read
it. Relaxing the limits of SupplyVoltage is a warning, because Actuator reads it and a
reader sized for 16 V may meet a value it was not written for, for the reason given two
sections further down. Tightening ValveDuty is only information, because Actuator
still gets values inside the range it was written for. Adding AmbientPressure is
information as well, since nothing that worked against the baseline can be disturbed by an
object it never knew about.
The last line names the two files, not the two projects, because two deliveries of one project share its name and naming the projects would print the same word twice.
An object that nobody read
Suppose instead that the only change is the removal of FilterGain, the calibration
parameter that Sensor declared local and that therefore no other component ever read:
$ ddd compare examples/pressure/release/PressureLoop-1.4.0.json examples/pressure/work/pressure.ddd.json # the candidate without FilterGain
examples/pressure/work/pressure.ddd.json: warning[removed-unused-object]: 'FilterGain' is gone; no component read it, but a calibration dataset or an external tool still might
1 warning
pressure.ddd.json can replace PressureLoop-1.4.0.json
No component stops linking, so this is not the error that TemperatureRaw was, and the
delivery is still a valid replacement. It is not nothing either: the object had a label in
the a2l, a value in every calibration dataset and possibly a line in a test bench
configuration, and all of those now refer to something that has ceased to exist. The message
says so in as many words, and the decision is left to the reader.
Both questions, one exit code
A ci job normally does not want to run two commands and combine two exit codes.
ddd check --baseline runs the consistency checks and the comparison over the same
resolved dictionary, and reports everything in one list. Here the five-change candidate
additionally reads a ValvePosition that nobody produces:
$ ddd check examples/pressure/work/pressure.ddd.json --baseline examples/pressure/release/PressureLoop-1.4.0.json # the candidate also reading ValvePosition
examples/pressure/work/components/actuator.ddd.json#component.interface[2]: error[missing-producer]: 'ValvePosition' is read by component 'Actuator' but no component declares it as output
examples/pressure/work/pressure.ddd.json: error[changed-interface]: 'PressureRaw' is not the same object any more (datatype: uint32 != uint16), read by Controller
examples/pressure/work/pressure.ddd.json: error[removed-object]: 'TemperatureRaw' is gone, but was read by Controller
examples/pressure/work/pressure.ddd.json: warning[widened-limits]: 'SupplyVoltage': limits widened from [0, 16] to [0, 18], read by Actuator
examples/pressure/work/pressure.ddd.json: info[narrowed-read-limits]: 'ValveDuty': limits tightened from [0, 100] to [0, 80], read by Actuator
examples/pressure/work/pressure.ddd.json: info[added-object]: 'AmbientPressure' is new in PressureLoop (measurement, produced by Sensor)
examples/pressure/work/pressure.ddd.json: info[added-object]: 'ValvePosition' is new in PressureLoop (measurement, produced by nobody)
3 errors, 1 warning, 3 infos
The consistency findings point at the declaration that caused them, down to the json pointer inside the file, while the comparison findings point at the project as a whole, because a difference between two dictionaries belongs to the delivery rather than to one line of one description file.
Limits: the direction of the change decides, and so does where the data flows
Limits are the one property where the direction of the change decides the verdict, and which direction is the dangerous one depends on which way the data flows. Calibration data - a parameter, a value block, a curve, a map or an axis - flows into the software, so widening its limits from 0 .. 16 V to 0 .. 18 V is silent: every value the baseline permitted is still permitted, so there is nothing a calibration dataset can trip over. Reporting it would train the reader to ignore the check.
The opposite direction is a warning, because a value that used to be legal may not be any more. A calibration dataset written against the baseline can hold a value outside the new range, an operator can have a test case that drives the signal there, and a calibration tool will refuse the write or clip it. Neither the compiler nor the linker has anything to say about it, which is exactly why the tool must:
$ ddd compare examples/pressure/release/PressureLoop-1.4.0.json examples/pressure/work/pressure.ddd.json # FilterGain's limits narrowed to 0 .. 0.5 instead
examples/pressure/work/pressure.ddd.json: warning[narrowed-limits]: 'FilterGain': limits tightened from [0, 1] to [0, 0.5]
1 warning
pressure.ddd.json can replace PressureLoop-1.4.0.json
That run exits 0: a narrowing is worth knowing about and worth a conscious decision, but
it is not by itself a reason to refuse the delivery. A project that wants it to be one turns
it into an error, either individually with -W narrowed-limits=error or for every warning
at once with --strict.
A measurement somebody reads is the other way round. Its limits are what the producer states
for its readers, and a reader may hold a lookup indexed by the value or a clamp sized for
it. Widening them is therefore widened-limits, a warning: a measurement that was
0 .. 100 and is now 0 .. 60000 hands its readers values they were never written for, which
neither the compiler nor the linker can see, and which --strict turns into “cannot
replace”. Narrowing them is narrowed-read-limits, an information, because a reader still
gets values inside the range it was written for. A range that moved both ways is a widening.
A measurement nobody reads has no reader to promise anything to, and keeps the grades of
calibration data.
A symptom is not reported under its cause
A different range is very often a consequence of something bigger, and reporting the
consequence next to the cause buries the cause. When the interface of an object has changed,
the change of limits that follows from it is therefore not reported separately. The next section
shows PressureRaw with its limits brought down from 400 to 250, this time accompanied by a
rescaled conversion, and the narrowed-read-limits information that the limits alone would
give is gone: there is one thing to fix, and once it is fixed
the limits question can be asked again on its own terms.
A rescaled conversion is an error
Of everything the comparison looks at, a changed conversion is the one that deserves the most
attention, because it is the failure that compiles, links, runs, and reports every value
wrong by a constant factor. Suppose the resolution of PressureRaw is improved from
0.1 kPa per count to 0.01 kPa per count, and its limits are brought down to 250 kPa to match
what the new raw range can express. The datatype is untouched, so every consumer still
compiles and every access is still to a two-byte object at the same address. The project is
internally consistent, because all its components were updated together:
$ ddd check examples/pressure/work/pressure.ddd.json # PressureRaw rescaled to a factor of 0.01 instead
ok: 5 variables in 3 components are consistent
Nothing in the build says a word. What has happened is that a calibration dataset from the previous delivery, a logged measurement file, a test limit written into a test bench and a threshold in a diagnostic tool now all mean ten times what they used to. The comparison is the only place where that can be caught, so it is an error and not a warning:
$ ddd compare examples/pressure/release/PressureLoop-1.4.0.json examples/pressure/work/pressure.ddd.json # PressureRaw rescaled to a factor of 0.01 instead
examples/pressure/work/pressure.ddd.json: error[changed-interface]: 'PressureRaw' is not the same object any more (conversion: linear(factor=0.01, offset=0) != linear(factor=0.1, offset=0)), read by Controller
1 error
pressure.ddd.json cannot replace PressureLoop-1.4.0.json
The differing properties are spelled out candidate first and baseline second, so
factor=0.01 != factor=0.1 reads as “it is 0.01 now, it was 0.1 before”. The narrowing of
the limits from 400 to 250 is not listed: it is the symptom of the rescaling, and it is the
rescaling that has to be discussed.
Warning
Rescaling a released object is not a change that can be made compatible by editing the description files, because the incompatibility lives in every artefact that was produced against the previous scaling. Either the previous scaling is kept, or the object is given a new name so that the old and the new value are visibly two different things.
When the baseline is the wrong file
A comparison against the wrong archived dump does not fail. It produces a confident, fully
formed report of hundreds of removals and changes that means nothing at all, and the time
lost to reading it is the point of the project-mismatch warning. Two deliveries of one
project share the project name, so when the two sides name different projects, the most
likely explanation is that the wrong file was picked up:
$ ddd compare examples/pressure/release/PressureLoop-1.4.0.json examples/pressure/work/pressure.ddd.json # the candidate renamed AirLoop
examples/pressure/work/pressure.ddd.json: error[changed-interface]: 'PressureRaw' is not the same object any more (datatype: uint32 != uint16), read by Controller
examples/pressure/work/pressure.ddd.json: error[removed-object]: 'TemperatureRaw' is gone, but was read by Controller
examples/pressure/work/pressure.ddd.json: warning[project-mismatch]: the baseline describes project 'PressureLoop' and the candidate describes 'AirLoop'; the comparison below only makes sense if that rename was intended
examples/pressure/work/pressure.ddd.json: warning[widened-limits]: 'SupplyVoltage': limits widened from [0, 16] to [0, 18], read by Actuator
examples/pressure/work/pressure.ddd.json: info[narrowed-read-limits]: 'ValveDuty': limits tightened from [0, 100] to [0, 80], read by Actuator
examples/pressure/work/pressure.ddd.json: info[added-object]: 'AmbientPressure' is new in AirLoop (measurement, produced by Sensor)
2 errors, 2 warnings, 2 infos
pressure.ddd.json cannot replace PressureLoop-1.4.0.json
The comparison is carried out anyway, and it is a warning rather than an error, because renaming a project is a legitimate thing to do and the report is then exactly what the reader wants. It is reported before any object is compared, and among the warnings it comes first, because it should be looked at before anything below it is believed.
A baseline that cannot be read at all is a different matter: there is nothing to compare, so no verdict is printed, and what the candidate has of its own is reported all the same:
$ ddd compare examples/pressure/release/PressureLoop-1.3.0.json examples/pressure/work/pressure.ddd.json
examples/pressure/release/PressureLoop-1.3.0.json: error[file-not-found]: in the baseline: file '/home/you/ddd/examples/pressure/release/PressureLoop-1.3.0.json' does not exist
1 error
The in the baseline: prefix is there so that a missing or malformed file on the reference
side is never mistaken for a problem with the delivery being judged. The message spells the
file out in full, as it does for a description that cannot be found: what a finding is
located at is an absolute path - rendered here against the directory the command ran in -
and a file that is not there is worth naming where it was looked for.
The baseline’s warnings are not findings of this run
When the baseline is given as a project description rather than as a dump, DDD has to analyse it to obtain its dictionary, and that analysis produces findings about that delivery: an output nobody read two releases ago, an object with no identity yet. Those findings are not this run’s business. Reported here they would be attributed to the candidate, they would appear twice whenever both sides are the same tree, and a clean delivery could be failed because of the state of its predecessor.
Its warnings and infos are therefore collected in a bag of their own and dropped. Here is an
older working tree - the 1.3 delivery, shipped as examples/pressure/v1.3 - whose
ValveDuty was read by nobody:
$ ddd check examples/pressure/v1.3/pressure.ddd.json
examples/pressure/v1.3/components/controller.ddd.json#component.interface[2]: warning[unused-output]: 'ValveDuty' is written by component 'Controller' but read by nobody
1 warning
Used as the baseline of a comparison, that warning does not reappear:
$ ddd compare examples/pressure/v1.3/pressure.ddd.json examples/pressure/release/pressure.ddd.json
examples/pressure/release/pressure.ddd.json can replace examples/pressure/v1.3/pressure.ddd.json
The verdict line names the two files rather than the two projects, because two deliveries of one project carry one project name - and, as here, one file name too, so where the two file names are the same it spells the paths out as they were typed.
This run’s -W reaches it in one direction only. A promotion does not:
-W unused-output=error is a run asking to be told about its own unread outputs, and applied
to the baseline as well it promoted the ValveDuty above into an error about a delivery
that went out long ago, carried it over and refused a verdict. --strict does not reach it
either. A relaxation does: -W missing-producer=ignore is a project deciding it can live with
an input nobody produces, and that is as true of the trunk it is compared against as of the working
tree, so a project that builds with it can compare its branch against its trunk, as
ddd check of either is clean. Only a lower grade than the check has by default is a
relaxation; the Compare tab reads a baseline under the relaxations every build record of the
project makes, and a check one of them does not relax is not relaxed. A plugin’s check has no grade
to compare with until its plugin is loaded, so a -W of it reaches the baseline as ignore
alone. --standalone does reach
it, because that states how the file was handed over - a component read on its own - and the
baseline was handed over the same way.
A baseline that is a component file is read alone, and the readers its dictionary records are
the component’s own and nobody else’s, because the run was not shown the rest. So a supplier’s
gate grades an output by what one file can know: it is taken as read by every grade that waits
on a reader, with a message that does not claim to know who read it, since “no component read
it” is a claim about components the run never saw. An output the component stopped offering is
removed-object; renamed, it is renamed-read-object, given a condition or another one
narrowed-condition, and turned volatile changed-interface, each an error; and the
limits of a measurement it widens are widened-limits and those it narrows
narrowed-read-limits. An input the component stopped reading is removed-input, an
information, because a component that reads less harms nobody. An object it declares local
keeps its grade, removed-unused-object, because no other component can read it, and every
other grade of an object nobody reads.
ddd check --standalone --baseline, ddd compare and the Compare tab of ddd gui take it
from the file, and read it under the floor ddd check --standalone reads a component under
whether or not the run said so, so that an input of the component nobody was shown the producer
of is not an error of the baseline. A dictionary
archived by ddd dump --standalone carries no mark of how it was read, and the mark is a
change of the format, so it is deferred: a comparison against such a dump is graded as one of
a whole project is, which costs the supplier’s gate its scope until the baseline is the
component file itself.
Its errors are another matter. A baseline whose own components disagree has no dictionary that
can be trusted, so every error it produces is carried over under the in the baseline:
prefix, at the severity its own analysis gave it, and the run fails on them: the comparison is
made, the errors are reported beside it and the verdict is a refusal, whether the candidate is a
dump or a description. A candidate given as a description is analysed all the same, and all its
findings and its renames are reported - a broken baseline withholds nothing of the candidate’s,
as ddd check --baseline never withheld it. A baseline that could not be read at all, as in the
missing-file example above, is carried over in the same way, but has no dictionary to compare
with: no verdict is printed and no renames file is written, while the candidate’s own findings are
still reported. A promotion of this run does not make one of them an error, and a -W that
relaxes the check relaxes it. A baseline that is to be compared against has to be one that checks
clean of errors on its own, under the project’s own policy.
A dictionary dumped from a project that failed holds what the analysis left it: ddd dump exits
1 on an input nobody produces and writes the file. Given as the candidate, an object that lost its
producer while a component still reads it is missing-producer, an error, as ddd check says
of the same description, and so it cannot replace the baseline that had a producer for it; it is
said in place of that pair’s changed-owner, being the one fact, and -W missing-producer=ignore
relaxes it as it relaxes the check. An object with no producer on both sides is no change the
comparison makes - two dumps of one component read alone hold its inputs so, and the dictionary
carries no mark of which a dump is - and an input that arrived with no producer is an
added-object and no more. A candidate given as a description has it said by its analysis, with no
changed-owner beside it. The one exception is the floor of ddd check --standalone, which
silences that analysis for what a component read alone was never shown and does not reach a producer
the baseline had: the comparison then says it, once, as an error whatever the floor says, which is
what makes a component that turns an output into an input fail that gate, and a project’s own
-W missing-producer=ignore still silences it.
One pair gets one verdict, whoever asks. ddd compare, ddd check --baseline and the Compare
tab of ddd gui ask the same function, and the delivery cannot replace the baseline when any
finding of the run is an error, whether it is the candidate’s own, one carried over from the
baseline, or the comparison’s. The tab counts the open project’s own errors in its verdict as the commands do,
and its answer says how many the project has of its own.
In a build pipeline
ddd compare and ddd check --baseline follow the same conventions as every other
command that produces findings: 0 when the run is clean, 1 when there are findings of
error severity, 2 on a usage error, and --format json for a machine readable report
carrying the same identifiers, severities and messages. In the text format the findings, the
summary and the verdict line all go to stderr and stdout is left empty; with --format json
the report is the whole of stdout and the verdict line is dropped, since a json document that
a job is about to parse must not have a sentence appended to it.
Severities are tuned the same way as everywhere else, so a project that has decided a widening is acceptable but wants the new objects out of its build log can say so:
$ ddd compare examples/pressure/release/PressureLoop-1.4.0.json examples/pressure/work/pressure.ddd.json -W widened-limits=ignore -W narrowed-read-limits=ignore -W added-object=ignore
examples/pressure/work/pressure.ddd.json: error[changed-interface]: 'PressureRaw' is not the same object any more (datatype: uint32 != uint16), read by Controller
examples/pressure/work/pressure.ddd.json: error[removed-object]: 'TemperatureRaw' is gone, but was read by Controller
2 errors
pressure.ddd.json cannot replace PressureLoop-1.4.0.json
A pipeline that treats the comparison as a release gate rather than as a report runs it with
--strict, which turns every warning into an error, so that a widened measurement, a narrowed limit of calibration data, a changed
owner or a moved a2l entry also has to be acknowledged before the delivery goes out.
The remaining piece is discipline about the archive itself. The dump has to be produced from the same sources that produced the binary, stored with it, and named after the release, so that the question “which delivery is this candidate replacing” has a file as its answer rather than a memory. Everything else about the comparison follows from that one habit.
Note
ddd compare reports the difference between two data dictionaries, and a dictionary
describes data rather than code. A delivery whose comparison is clean can still behave
differently, because its algorithms changed; what a clean comparison guarantees is that
everything built, calibrated and measured against the previous delivery still addresses the
same objects, with the same layout, the same scaling and the same meaning. The layout is the
one the dictionary describes: what an external type holds is its own header’s, which no
dictionary records.