Loom run form
BabbCreated by: AI service unspecified
The run form says shared context once, then only what changes. It is a
spelling of canonical entries, not a different record: decoding it gives back
the canonical lines byte for byte. This page describes the format ascrates/stream-codec/src/lib.rs implements it today; where the code and this
page disagree, the code is right and this page is wrong.
@1752300096 %ps=1 iv=8 rec=meter:pdu-4 scope=host:build-01 u=J
+0 MEASURE* pdu-4.out3 {"q":"38"}
+8 MEASURE* pdu-4.out3 {"q":"41"}
decodes to
1752300096 MEASURE* pdu-4.out3 {"iv":8,"ps":1,"q":"38","rec":"meter:pdu-4","scope":"host:build-01","u":"J"}
1752300104 MEASURE* pdu-4.out3 {"iv":8,"ps":2,"q":"41","rec":"meter:pdu-4","scope":"host:build-01","u":"J"}
The one normative rule
decode(encode(lines)) == lines, byte for byte. Decoding is fixed by this
page. Encoding is not: any encoder whose output decodes to the original lines
is valid, and the bundled encoder is greedy, not optimal.
Lines
The text is LF-separated lines. Empty lines are skipped. Every other line is
a header or a row, and a row before the first header is an error.
Header
@<seconds>[ %ps=<n>][ <key>=<value>]…
@<seconds>starts a run. It is whole Unix seconds and is the base
time for the first row.%ps=<n>numbers the run's rowsn,n+1, … in the payload keyps,
unless a row states its ownps(below).- Shared items are added to the payload of every row in the run. A key
is not empty, does not start with%, and contains no=, space or
control character. A value is written one of two ways: - bare:
key=value.true,falseandnullread as those JSON
values, an integer written as it would be in canonical JSON reads as an
integer, and anything else reads as a string; - JSON:
key= <json>, with a space after=. Used for strings that
would otherwise read wrongly (empty, starting with",{,[or%,
containing a space or control character, spellingtrue,false,null
or an integer), and for arrays and objects.
A new header replaces the previous run's shared items and counter entirely.
Row
<+|-><seconds>[.<fraction>] <type> <object>[ <json object>]
- Time.
<seconds>is the change in whole seconds from the previous row,
or from the header for a run's first row. It may be negative, since entries
are not always in time order.<fraction>is the entry's own sub-second
part, copied as written; it must be a valid kernel fraction (1 to 6 digits,
no trailing zero). - Type and object are copied unchanged.
- Payload. Start from the header's shared items, then add the row's JSON
object, if any. A key in the row replaces the shared value. - Sequence. Only if the header has
%ps: a row withoutpsgets the
counter, and then the counter becomes this row'spsplus one, whether the
row stated it or not. Without%ps, rows carrypsonly if they state it.
Each decoded line is <time> <type> <object> <canonical JSON> and must be a
valid entry, or decoding fails at that line.
Size
On 1,000 meter samples the bundled encoder is about 3.2 times smaller than
canonical lines. The Python trial in ww-standard reaches about 28 times
with positional payloads and template rows, which are not yet in this
format.
Relation to Loom
Loom does not change the run form. It is listed here because a Loom view
reads entries, whatever spelling they arrived in, and because packs and run
form share the same rule: every spelling decodes to the same canonical lines.