Search and contents

Previewing an instruction binding

Before a binding is switched on, preview shows what it would have found. It takes a sample of readings that you export from the site's own historian, replays the sample through the binding the way the Node would judge live readings, and reports how many readings fell outside the claim's limits, where they sat, and which crossings lasted long enough to count. Kindred keeps no readings of its own, so the sample is yours to supply.

preview writes no Activity Log entry, enables nothing and changes neither the binding nor the configuration. It works on a binding in any mode, disabled included: judging a binding before it is enabled is what it is for. It needs the binding's claim to be current, as check does, and it takes the limits from the claim, so a preview cannot be run against limits you made up.

python3 -m engine.instruction_binding_tools --config node.json preview --binding oven1-cure sample.csv

--binding names the binding in the configuration's instruction_bindings section (see Instruction bindings). The other options are in the table below.

OptionDefaultMeaning
--binding required The id of the binding to preview.
--format from the file's extension csv or json. The extensions .csv, .json, .jsonl and .ndjson are recognised.
--json off Print one JSON object instead of text.
--timezone none An IANA time zone name (America/New_York), applied to a timestamp that carries no UTC offset.
--timestamp-column timestamp The column or key holding the time of each reading.
--value-column value The column or key holding the measured value.
--condition-column condition The column or key holding the scope condition tag's value.

--node-type-dir and --shared-config-dir are the same as for the other commands.

The sample

One row per reading: when it was taken, the measured tag's value, and the value of the binding's scope condition tag at that time. Every binding has a scope condition, so every sample needs that column.

timestamp,value,condition
2026-11-08T12:00:00Z,181.2,ProductA
2026-11-08T12:00:10Z,183.0,ProductA
2026-11-08T12:00:20Z,186.1,ProductA
2026-11-08T12:00:30Z,186.4,ProductA
2026-11-08T12:00:40Z,186.9,ProductA
2026-11-08T12:00:50Z,184.0,ProductA
2026-11-08T12:01:00Z,25.0,Idle
2026-11-08T12:01:10Z,Bad,ProductA
2026-11-08T12:01:20Z,176.0,ProductA
2026-11-08T12:01:30Z,174.2,ProductA

The same readings as JSON are an array of objects, or one object per line, with the same keys:

[
  { "timestamp": "2026-11-08T12:00:00Z", "value": 181.2, "condition": "ProductA" },
  { "timestamp": "2026-11-08T12:00:10Z", "value": 183.0, "condition": "ProductA" }
]
  • Timestamps are ISO 8601 and carry a UTC offset (Z or +01:00).
    • A timestamp with no offset is refused unless --timezone gives the zone the file was written in. A timestamp that has an offset keeps it.
    • With a zone given, a local time in a clock change is refused too. The hour a clock goes back is read twice and the hour it goes forward is never read, so the instant cannot be told and a guess would reorder the replay. Export such a sample with UTC offsets.
    • A timestamp that is missing or cannot be read refuses the whole file, naming its row. A reading that cannot be placed in time would silently break the replay of how long a crossing lasted.
  • A value or condition that cannot be used is counted, not refused. A historian export holds Bad and blank cells, and the preview treats them as the Node does: a value that is not a usable number is not evaluated, and a condition that cannot be read is reported. A blank cell is a missing value.
  • A CSV cell is text, so a condition cell is read as the kind of value the binding expects: text as written (a space is a character, as it would be in the live tag), a number, or true or false (1 and 0 also read as booleans). A JSON file keeps the types it holds.
  • The rows are sorted by time before they are replayed, and rows with the same timestamp keep the file's order. The report says how many were out of order.
  • Row numbers in a message count the rows after the header that hold something, or the records of a JSON file; a blank line is not counted. A message never repeats a cell, a column name or a path.
  • Blank lines in a CSV, before the header or between rows, and rows of nothing but empty cells, are skipped.
  • Size. A CSV is read row by row and may hold up to 1 000 000 rows; more than that is refused and never cut short. The readings are kept in memory for sorting and for the median, so a sample of that size needs about a quarter of a gigabyte. A JSON file has to be read whole, so it may be at most 50 MiB.

What the report says

The replay is the same one the Node uses for live readings: a reading counts only while the binding's scope condition holds, and a crossing counts only once it has lasted for the binding's persistence rule, measured on the sample's own timestamps. The preview adds no comparison of its own.

FigureMeaning
Rows Every row of the sample, split into: in scope and a usable number; not in scope (the condition is readable and is not the binding's value); in scope but not a usable number; and the condition could not be read, by reason (missing, not finite, or the wrong kind of value).
Outside each limit The readings outside that limit, as a share of the readings that were in scope and usable, and as a share of all rows. A reading exactly at a limit is inside. This counts single readings, whether or not the crossing lasted.
Values in scope The minimum, median and maximum of the readings in scope and usable, in the claim's unit. The report prints them beside the limits and does not compare them.
Crossings that lasted The number of crossings that lasted long enough to count, and the first 10, each with its time, value, the limit and how long it had been outside. Further ones are counted.
First outside readings When readings were outside a limit and none lasted long enough, the first 3, to show what a crossing that did not last looked like.

A share is shown as "none judged" and never as 0 % when nothing could be judged.

A sample with nothing to judge is not a clean result

Each of these has its own verdict and exit code 4, and none reports a share or a statistic as zero:

VerdictWhen
no_readings The file is empty, has a header and no rows, or holds no records.
none_in_scope No row was in scope: the condition never had the binding's value, or could not be read. The report says how many of each.
none_evaluable Rows were in scope, and none of their values was a usable number.
no_crossings Readings were judged and no crossing lasted long enough to count (exit code 0).
crossings At least one crossing lasted long enough to count (exit code 1).

For the sample above, the binding in Instruction bindings (limits 175 and 185 °C, three readings of persistence) is reported like this:

Preview of binding oven1-cure (claim 7f3c1b52-2d0e-4c58-9a1f-6e4b8d2a9c10), unit °C
Nothing was written and no binding was changed.
Limits: lower 175, upper 185 °C

Sample: 10 rows, 2026-11-08T12:00:00+00:00 to 2026-11-08T12:01:30+00:00
  in scope and a usable number: 8
  not in scope: 1
  in scope but not a usable number: 1

Outside the lower limit: 1 reading, 12.5% of the 8 in scope (10.0% of all 10 rows)
Outside the upper limit: 3 readings, 37.5% of the 8 in scope (30.0% of all 10 rows)
Values in scope: minimum 174.2, median 183.5, maximum 186.9 °C

Crossings that lasted long enough to count: 1
  2026-11-08T12:00:40+00:00  186.9 °C, outside the upper limit 185 (3 readings, 20 s outside)

What it prints and does not

The report names the binding's id, the claim's id, the unit, the two limits, and the times and values of the sample itself (the first crossings are the point of it). It never prints the claim's sentence, its document or locator, the binding's product or operation labels, a node id or the condition's value. Because the sample's own values are printed, treat the output as plant data.

JSON

--json prints one strict JSON object with these keys. A figure that has no value is null.

KeyHolds
binding_id, claim_id, unit The ids and the unit.
limits lower and upper, as the claim states them (null for a limit it does not state).
verdict, detail The verdict above, and for no_readings why.
rows The counts of each kind of row, and how many were out of order.
outside For each limit: count, share_of_evaluable and share_of_all_rows.
confirmed readings (readings inside a lasting crossing) and crossings.
values minimum, median and maximum.
span The first and last timestamps of the sample.
first_crossings, crossings_not_shown The listed crossings, and how many more there were.
first_outside_readings The first readings outside a limit.

Exit codes

The text printed is for a person to read and may change; the exit code is the promise.

Exit codeMeaning
0 A report was produced and no crossing lasted long enough to count
1 At least one crossing lasted long enough to count
2 The request could not be used: a configuration or path that cannot be read, a binding that is not in the configuration, a claim that is not current or whose unit differs from the binding's, or a sample that is refused
3 The Node's database could not be reached
4 There was nothing to judge (a verdict in the second table above)

A refused sample is found before the database is asked for the claim, so it needs no database to be reported.

Release: v0.11.0