DS event-trace file format#
A trace file is a binary sequential file recording the event trace of one DS engine session — every recordable event the engine emitted, in the order it emitted them. It is self-describing: every schema needed to decode a fact is defined in the file before its first use. A reader needs no external DSC or schema registry.
This document covers the .dstrace trace-file format: atom framing, the
StreamHeader header, the scalar atoms, and the schema-driven fact-body codec.
Companion protos live in proto/:
proto/stream_header.proto#StreamHeader,
proto/stream_header.proto#ClockAdvance,
proto/stream_header.proto#RuleFireAnnotation,
proto/fact_assert.proto#FactAssert, proto/fact_retract.proto#FactRetract.
Schema atoms (SchemaDef / Slot) reuse the DSC proto definitions in proto/.
[RFCS.4] A fact-ref slot is carried as a handle. A fact-ref is an intra-engine
reference to another fact in the same working memory, with no identity outside
the engine. Within one stream the referenced fact's fact_id names it, so that
is what a fact body carries ([RFCS.6.3]). The handle means nothing outside the
stream that recorded it: a fact that leaves the engine is a FactExternal,
which inlines the facts it refers to ([RFCS.23]). (Json-
typed slots do travel — encoded as their proto_source maps them, TYPE_STRING
carrying the canonical serialized JSON text.)
Prefix RFCS.
Purpose [RFCS.1]#
[RFCS.1.1] A trace file captures the event trace of one DS engine session — every recordable event the engine emitted ([RFCS.3.6]), in the order it emitted them ([LFST.1.3]) — with enough schema information embedded to decode every fact without any external artefact.
[RFCS.1.2] An event trace is read two ways.
Replay re-executes the trace against a DS engine and compares what the engine produces with what the trace holds ([LFST.9]). It is the determinism check, and the only reading that requires the compiled program ([LDET.2.6]).
Inspection reads the trace without an engine. Every schema is announced before its first use ([LFST.8.10]), so a tool decodes every event from the trace itself and needs neither engine nor artefact.
Debugging is not a third reading. A debugger drives replay with interactive control ([LDEB.10.7], [LDEB.8.7]).
see also: LDEB.10.7, LDEB.8.7, LDET.2.6, LFST.8.10, LFST.9
[RFCS.1.3] An event trace records every observable event of one DS engine session: every input the engine consumed, every observable it produced, and the structural atoms that frame them. The three classes, and what a reader must do with each, are [RFCS.17.1] and [RFCS.17.5]; the atom census is [RFCS.3.1].
The engine emits these events through the typed callback surface ([NCBK.2]) and performs no I/O of its own. A trace file is one serialisation of that sequence, and producing it is the integrator's choice ([LFST.2.1]).
Atom framing [RFCS.2]#
A stream is a Stream container holding repeated Atom atoms = 1; the framing
is two levels and both protobuf, and an atom is identified by its oneof field
number ([RFCS.19.1], [RFCS.16.1]).
see also: RFCS.16.1, RFCS.19.1
[RFCS.2.2] A stream is read forward-only and single-pass. A reader processes atoms one at a time in order and never seeks backwards.
The stream does have an outer container — a Stream whose
repeated Atom atoms = 1 makes the unit on the wire an outer frame
[0x0A][varint len][Atom] ([RFCS.19.1]). An implementer who emits atoms
without it is one level short.
see also: RFCS.19.1
Atom types [RFCS.3]#
[RFCS.3.5] An event trace uses the following atoms. Field # is the field
the atom occupies in proto/atom.proto#Atom's body oneof, which is its wire
identity ([RFCS.16.1]); the Atom column is its body message, which is its
name. SchemaDef and Slot reuse the DSC allocations, and their rows are owned
by [RDSC.7.1].
[RFCS.3.1]
Atom |
Field # |
Direction |
Purpose |
Container-legality |
Stream-class |
|---|---|---|---|---|---|
StreamHeader |
258 |
— |
Stream header; first atom in body |
stream |
structural |
SchemaDef |
256 |
— |
Schema definition (from DSC format) |
both |
structural |
Slot |
257 |
— |
Slot definition (from DSC format) |
both |
structural |
FactAssert |
1 |
— |
Fact assert |
stream |
inject |
FactRetract |
2 |
— |
Fact retract |
stream |
inject |
Checkpoint |
259 |
— |
Inline checkpoint; random-access entry point ([RFCS.9]) (v2): deferred, so not allocated in |
stream |
structural |
ClockAdvance |
3 |
— |
Clock advance |
stream |
inject |
PumpBoundary |
4 |
— |
Pump-to-quiescence boundary ([RFCS.22]); a replayer pumps on meeting one |
stream |
inject |
ExternalAssert |
5 |
— |
Host input whose fact holds a fact reference, as a |
stream |
inject |
CacheSeed |
6 |
— |
A cache entry the host seeded before the first stream event, in the prelude ([RFCS.26]) |
stream |
inject |
RuleFireAnnotation |
261 |
— |
Rule-fire annotation: begin/end of activation |
stream |
compare |
CallIssued |
262 |
— |
Outbound-call provenance ([RFCS.15.2]); compared, never injected |
stream |
compare |
~~Seal~~ |
260 |
— |
Reserved, out of use. Field 260 is never reissued |
— |
— |
TextNote |
323 |
— |
Optional clear-text annotation ([RFCS.25]) (v2): deferred, so not allocated in |
stream |
structural |
ComputationError |
325 |
— |
Trap provenance — a computation with no honest answer ([LERR.1.4.7]) |
stream |
compare |
FactEmit |
326 |
— |
Author-emitted fact — a rule fired and the engine produced it ([RFCS.6a]) |
stream |
compare |
FactPublish |
331 |
— |
A rule's |
stream |
compare |
FactWithdraw |
327 |
— |
Engine withdrawal + closed cause enum ([RFCS.7a]); compared, never injected |
stream |
compare |
TypeError |
328 |
— |
Invalid operation at a present value; the activation is abandoned ([LERR.1.2]); compared, never injected |
stream |
compare |
BoundsError |
329 |
— |
A declared cap was reached ([RTCT.7.1]); the operation is rejected and the engine is intact; compared, never injected |
stream |
compare |
EngineError |
330 |
— |
Engine state is no longer trustworthy; the tier halts ([LERR.1.4.7]); compared, never injected |
stream |
compare |
ratified — defined in: proto/atom.proto#Atom — see also: LERR.1.2, LERR.1.4.7, RFCS.15.2, RFCS.22, RFCS.24, RFCS.25, RFCS.26, RFCS.27, RFCS.6a, RFCS.7a, RFCS.9, RTCT.7.1
[RFCS.3.6] What each stream event records as. The stream callback is the
engine's one channel, and a recording is the recordable events an integrator
keeps from it ([LFST.9.2.1]). For each proto/stream_event_kind.proto#StreamEventKind
member, named as that file says, a recorder must write the atom below, and
must write none for a kind that has none. A kind with no atom reaches the
stream callback only: nothing a replay injects or compares rests on it.
Kind |
Atom |
|---|---|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
none |
A replay re-derives what the kinds with no atom report: a cache write, a log line and a cooldown window come from a rule firing again on the recorded inputs.
ratified — see also: LFST.9.2.1, RFCS.15.2, RFCS.22, RFCS.24.1, RFCS.24.3, RFCS.27, RFCS.6.7, RFCS.6a, RFCS.7a
[RFCS.3.2] SchemaDef and Slot bodies are identical to those defined
in the DSC format ([RDSC.5.8] and [RDSC.5.5]). A reader that already
understands the DSC format requires no new proto definitions for
these atoms.
[RFCS.3.3] The FactAssert atom is defined in
proto/fact_assert.proto. In an event trace an encoder must write its
clock_ns (the monotonic engine clock at assertion, [RFCS.6.6]) and its seq
(the event's place in the delivered stream, [LFST.12.1]), as every event atom
carries its own ([RFCS.7.5]). It must leave rule_name empty: a FactAssert
records a host input, and a fact a rule produces is a FactEmit
([RFCS.6a.1]).
defined in: proto/fact_assert.proto#FactAssert — see also: LFST.12.1, RFCS.6.6, RFCS.6a.1, RFCS.7.5
[RFCS.3.4] Atom injection classification (the codec rule). On
replay each atom is exactly one of three classes, and the class fixes
what a reader may do with it. Which atom is in which class is the
Stream-class column of [RFCS.3.1], its single normative home; this
clause states what each class obliges a reader to do.
inject — recorded external inputs; the replayer delivers them to the engine as recorded ([LFST.9.2]).
compare — engine-produced annotations and outbound effects; the replayer re-derives them and byte-compares to the record ([LFST.9.3]) and must not deliver them to the engine.
structural / ignore — framing, schema and seek atoms with no replay-input meaning.
This clause binds replay ([LFST.9.6]), which runs the engine and compares what it produces, so for it the three classes are three different obligations. There is one operation for the rule to bind, and no mode within it reads an atom differently.
A re-deriving reader's inject path MUST refuse any atom outside the
inject class — delivering a CallIssued (or RuleFireAnnotation) to the engine as an input would
corrupt determinism, and skipping an inject-class atom would drop a real
input. This makes the load-bearing invariant — a call is never a
replay input — a rule the codec enforces rather than a convention (it
is the same invariant the stream-transducer unification carries verbatim
across live and recorded transports).
Stream header [RFCS.4]#
see also: LFST.9.2, LFST.9.3, LFST.9.6, RFCS.3.1, RFCS.4
[RFCS.4.1] A lean trace file must begin with a StreamHeader atom. A
self-contained trace file ([RFCS.13]) begins with its embedded DSC — a
DscHeader atom — with the StreamHeader atom following the DSC front. A reader
must dispatch on the leading atom ([RFCS.13.3]): StreamHeader first → lean;
DscHeader first → self-contained (process the embedded DSC front, then the
event trace). A reader must reject a file that begins with neither
StreamHeader nor DscHeader. In the self-contained case the leading DSC atoms are
the embedded program and are processed as such, not skipped.
[RFCS.4.2] The StreamHeader body, and its inline RealtimeConfig /
RealtimeNodeCap / RealtimeSeriesCap companions, are defined in
proto/stream_header.proto#StreamHeader. Field 1 is reserved and out of use;
ds_version (field 10) is the DS version that wrote the stream, and a reader
accepts its own <major>.<minor>. series and rejects every other ([LDET.1.10]).
defined in: proto/stream_header.proto#StreamHeader — see also: LDET.1.10, LFST.9.2.1, RBND.1.3, RBND.1.4, RBND.2.3, RBND.4b, RFCS.4.3, RFCS.4.4, RFCS.4.8, RFCS.6.6
[RFCS.4.3] session_id records the run identifier the engine was given
([NLFC.1.2]), or is empty if it was given none. It is the engine's, not the
file's: the trace records it so that a replay can be given the same identifier
and reproduce every event_id ([LFST.5.6]).
ratified — see also: LFST.5.6, NLFC.1.2
[RFCS.4.4] tier_id records the tier identifier the engine was given
([NLFC.1.2]), or is empty if it was given none. It is opaque to the format, and
is recorded for the same reason as session_id ([RFCS.4.3]).
ratified — see also: NLFC.1.2, RFCS.4.3
[RFCS.4.5] dsc_hash is binding whenever a DSC is obtainable. A
reader that has DSC bytes — whether embedded at the front of the
file ([RFCS.13]) or supplied alongside it (the replay path,
[RFCS.1.2]) — MUST verify the DSC against its own dsc_sha256 ([RDSC.3.6])
and compare dsc_hash, capabilities and dialect_def_sha256 with the DSC's
[RBND.1.3] tuple, field by field ([RBND.3.1]) via the dialect-binding comparison [RBND.6]; mismatch is
fatal (DS_ERR_BND_DSC_MISMATCH or DS_ERR_BND_DIALECT_MISMATCH).
Embedded and supplied forms differ only in where the DSC bytes come from, not
in whether they are verified. Two streams are not compared: one whose header
holds neither dsc_hash nor dialect_def_sha256, which the engine replays
without a binding check ([RBND.2.1]), and a schema-only offline dump with no
DSC available at all, which can neither replay nor bind to a program. The dump
relies on the in-stream SchemaDef / Slot atoms, which remain authoritative
for schema interpretation.
see also: RBND.1.3, RBND.2.1, RBND.3.1, RBND.6, RDSC.3.6, RFCS.1.2, RFCS.13
[RFCS.4.7] Fail-closed conditions enumerated. A reader must refuse a stream at open whose header meets any of these:
ds_versionoutside the reader's own<major>.<minor>.series ([LDET.1.10]) →DS_ERR_FS_VERSION;capabilitiesnot strictly ascending overCapability's members, or namingCAPABILITY_UNSPECIFIED→DS_ERR_PARSE([RBND.1.3]);one of
dsc_hashanddialect_def_sha256and not the other →DS_ERR_BND_INCOMPLETE([RBND.2.1]);both, an engine that has loaded a DSC, and a tuple that differs from the DSC's ([RBND.5.1]) →
DS_ERR_BND_DSC_MISMATCHorDS_ERR_BND_DIALECT_MISMATCH.
A header that holds neither binding field is not refused: the engine replays the stream without a binding check ([RBND.2.1]). The FS-specific codes are [NERR.13]'s; binding errors flow through unchanged per [RBND.7.2].
see also: LDET.1.10, NERR.13, RBND.1.3, RBND.2.1, RBND.5.1, RBND.7.2
[RFCS.4.8] wall_start_iso8601 is the host wall-clock time at which
the stream opened, in UTC, ISO 8601 (for example
2026-06-18T14:30:00.123456Z). It is provenance metadata, not a
replay input: a reader must drive replay from the engine monotonic
clock ([RFCS.6.6]), never from this field, so an incorrect or
unsynchronised host clock cannot perturb a replay. It anchors the
monotonic timeline to calendar time — wall_start_iso8601 plus the
engine-clock span ([RFCS.6.6]) gives both when the stream ran and how
long it took. The ISO-8601 string carries the offset inline. The field is optional
("" when unanchored); its absence is never fatal ([RFCS.4.7] does not
gate on it) because it is provenance, not a binding or replay input.
Schema announcement [RFCS.5]#
[RFCS.5.1] The encoder must announce every schema the engine has
registered immediately after the StreamHeader atom, before any event
atom: for each, one SchemaDef atom followed by one Slot atom for each
slot defined on that schema, in declaration order. Schemas are announced
in registration order, and loading an artefact registers its schemas in the
order its SchemaDef atoms appear. The compiler's own schemas, those with synthetic names
([LLEX.10.6.1]), are not announced: no fact in a stream can name one.
An engine registers no schema once it has emitted its first stream event
([NFCT.1.1]). The encoder must therefore write the StreamHeader and the
announcements only once that holds: when it encodes its first event, or as
soon as it begins if the engine has already emitted one. The set is then
complete when the header is written, and no schema is announced later.
Declaration order is normative, not cosmetic. A payload's fields are numbered by slot position, so the order of these atoms is what lets a reader reconstruct the payload's field numbers and decode slot values without the artefact ([LFST.8.10]). Emitting the same slots in another order would describe a different message.
A Slot atom in a trace carries the kind the artefact declared, the temporal
kinds included ([RDSC.5.5.8]), so a reader can tell a timestamp from a count
and render each as its type. The encoder must fill every other field of
proto/slot.proto#Slot the engine holds for the slot as it would stand in the
artefact: schema_ref, sampled, retained, tolerance, identity_role,
nullable and capacity. So a trace's announcement says which slots are keys
and which may be null.
ratified — see also: LFST.8.10, LLEX.10.6.1, NFCT.1.1, RDSC.5.5.8
[RFCS.5.2] Once a schema has been announced, its SchemaDef and Slot
atoms must not be repeated within the trace body — the atoms
from the StreamHeader header onward.
An embedded DSC front is not part of that body. In a self-contained
trace file ([RFCS.13]) the leading DSC carries its own SchemaDef / Slot
atoms for every schema the .ds declared, and the body announces them
again. That is not a repeat under this clause, and it is deliberate:
embed is pure concatenation and strip its exact inverse
([RFCS.13.1]), so the body must be complete on its own or stripping a
front would yield a trace whose descriptors had gone missing.
The front still counts as an announcement for the reader — it may populate its pool from the front and need not wait for the body's copy ([RFCS.5.3]). Announcement is what the reader relies on; non-repetition is what the encoder is held to; the boundary sits in different places for the two, and that is the whole of it.
see also: RFCS.13, RFCS.13.1, RFCS.5.3
[RFCS.5.3] A reader must process SchemaDef and Slot atoms as they
arrive and add the schema to its descriptor pool before continuing.
When the following FactAssert arrives, the descriptor must already be
available; if it is not, [RFCS.5.4] applies.
Atoms in an embedded DSC front count. When a stream is
self-contained ([RFCS.13]), the leading DSC's SchemaDef / Slot atoms
populate the pool exactly as the body's do — they are processed as the
embedded program, not skipped ([RFCS.4.1]). A reader must not wait for
a body announcement of a schema the front already described.
This is a permission for the reader, not a licence for the encoder to omit: the body still announces every schema it uses ([RFCS.5.1]), so a stripped stream stays readable.
see also: RFCS.13, RFCS.4.1, RFCS.5.1, RFCS.5.4
[RFCS.5.4] A reader must treat a FactAssert atom for an unrecognised
schema_name as a fatal stream error. A schema_name is unrecognised in two
cases:
no
SchemaDeffor it has reached the reader's descriptor pool ([RFCS.5.3]);the reader is a runtime replaying the stream, and its engine holds no schema of that name: neither the artefact it loaded nor the built-in module declares one ([NFCT.1.1]).
A runtime replaying the stream must stop at that atom and return
DS_ERR_SCHEMA_UNKNOWN in either case, and the same code whether it meets the
atom as it opens the stream or partway through the replay. A reader with no engine, decoding a stream offline, meets only the
first case.
Fact assert [RFCS.6]#
[RFCS.6.1] A FactAssert atom records a single host fact assertion, and is
defined in proto/fact_assert.proto. Which of its fields an event trace
carries is [RFCS.3.3].
defined in: proto/fact_assert.proto#FactAssert — see also: RFCS.3.3
[RFCS.6.2] Relevant fields in the event-trace context:
Field |
Meaning in an event trace |
|---|---|
|
The engine's id for the fact ([RFCS.6.9]); unique within the trace; echoed by |
|
The schema's own name ([LIMP.13.1]) |
|
Proto-encoded fact body, typed per the schema's |
|
TTL at time of assertion; |
|
Engine monotonic clock at the assertion (ns); not wall time. Wall-clock anchoring is the header's |
|
Always |
|
The event's place in the delivered stream ([LFST.12.1]); always written ([RFCS.3.3]) |
|
deterministic UUID stamped on every assertion, derived from the run identifier, the tier identifier and |
see also: LFST.12.1, LFST.5.6, LIMP.13.1, RFCS.3.3, RFCS.4.8, RFCS.6.8, RFCS.6.9
[RFCS.6.3] fact is encoded using the protobuf message type defined
by the proto_source field of the schema's SchemaDef atom. A reader
uses the descriptor loaded from that SchemaDef to decode fact.
A nullable slot's field is optional ([RDSC.5.8.3]). A writer must
encode a null in such a slot by omitting the field, and must write the
field for any other value, the type's zero included. A reader must decode
an absent nullable field as null and a present one as its value, and
must not substitute the type's zero for an absent one. A non-nullable
slot's field has no presence: an absent one is the type's zero, as protobuf
defines.
A non-nullable Json or fact-reference slot has no such zero. Empty text is no
JSON document, a null root is not a value of that slot ([LNUL.3.4]), and a
handle is never 0. A writer must write the field, and a reader must refuse
the body with DS_ERR_PARSE where it is absent.
A Json field whose document is null at its root is the canonical null
([LNUL.3.4]). A writer must not write one, since a
null is the omitted field. A reader must decode one as null in a nullable
slot, and must refuse the body with DS_ERR_PARSE in a non-nullable one.
A String or Json field holds well-formed UTF-8 (RFC 3629). A reader must
refuse with DS_ERR_PARSE a body in which such a field's text is not, as a
malformed body and not as [LSTR.8.5]'s host text. It must not repair the text.
A Bytes field holds any octets.
A fact-reference slot's field is uint64 ([RDSC.5.8.3]), and carries the
fact_id under which the referenced fact was recorded earlier in the same
stream. That fact always precedes the one that refers to it, because a
reference is written when the referring fact is asserted ([LGRA.5.7a.2]) and the
fact it names was live then. A writer must write that handle, and a reader
must resolve it to the fact recorded under it. That is the fact a record
carries, or a fact an ExternalAssert delivered, whose handle its fact_ids
lists although no record carries its body ([RFCS.24.3]). A handle identifies a
fact within one stream and nowhere else ([RFCS.4]).
ratified — see also: LGRA.5.7a.2, LNUL.3.4, LSTR.8.5, RDSC.5.8.3, RFCS.24.3, RFCS.4
[RFCS.6.4] fact_id values are scoped to the file in which they
appear. A fact_id from one file must not be used to retract a fact
asserted in a different file.
[RFCS.6.9] How the engine numbers its facts. The engine must give each
fact its fact_id from one counter per engine, which starts at 1 and
increases by 1 with each id taken. The engine takes the next id:
for each fact that enters working memory, whatever put it there: a host assert, a rule's
emit, anExternalAssertdelivery, in [RFCS.24.3]'s order, a hydrated row ([NCBK.9.3]) or a fault fact ([LERR.9.8]). An identity update's replacement is a fact that enters ([RFCS.6.7]);for each host assert a bound refuses, whose
FactAssertis recorded although no fact enters ([RFCS.6.7]). No later atom names that id.
The engine takes no id for a no-op reassertion, whose FactAssert carries the
live fact's id ([RFCS.6.7]), nor for a host call refused as not a well-formed
input, which records nothing, nor for a fact the lowering or the engine
creates for its own use ([RFCS.6a.5], [LDET.5.8]). No fact has the id 0, so a
fact_id field holding 0 names no fact. A clone continues the counter
([IARC.11.2]).
The ids are observable. Every compared body carries them ([RFCS.6a.3]), so a replay matches its recording only if it numbers as the recorded run did.
ratified — see also: IARC.11.2, LDET.5.8, LERR.9.8, NCBK.9.3, RFCS.24.3, RFCS.6.7, RFCS.6a.3, RFCS.6a.5
[RFCS.6.5] schema_name must match the schema_name field of a
SchemaDef atom that has already appeared in the same file. The compiler must emit
schema_name in NFC, and the runtime must treat an incoming schema_name
as NFC and must not re-normalize; a producer and consumer that disagree on the
NFC-normalized form do not decode the fact body ([LNAM.2.8], [LNAM.7.1]).
[RFCS.6.6] Across every atom that carries it — FactAssert ([RFCS.6.2])
and ClockAdvance ([RFCS.10.2]) — clock_ns is the
engine monotonic clock (CLOCK_MONOTONIC-class; relative, not a
calendar time). Replay re-drives the engine clock from the recorded
clock_ns values. A stream's start is the first atom's clock_ns,
its end is the last atom's clock_ns, and its execution
duration is end − start; because the end is whichever atom was
written last, a truncated stream still reports its duration up to the
point it stopped. The nanosecond unit is not an accuracy guarantee —
effective resolution is platform-bounded and low digits may be zero —
so a reader must order events by seq ([LFST.5.3]), never by
clock_ns low-bits. An encoder writes clock_ns on every atom that carries
it ([RFCS.3.3]): replay re-drives the clock from it.
see also: LFST.5.3, RFCS.10.2, RFCS.3.3, RFCS.6.2
[RFCS.6.7] A FactAssert records an assert ARRIVING, not a fact entering working
memory. The two differ on a no-op reassertion — an assert whose identity
and every slot compare equal to a fact already live ([RARC.5.2.3]) — and the
atom must be written anyway.
The no-op discipline is a working-memory discipline, not a recording one. Suppressing the WM change is load-bearing: series absorb and refraction depend on a same-value re-assert being silent to the network. None of that reaches the recorder, and [RARC.5.8.10] already puts the input hook at step (1) of the consumption loop — on arrival, before evaluation — precisely so that what an input did downstream cannot decide whether it was recorded.
Why it cannot be dropped. A no-op reassertion is an input the host supplied
and pumped for. Omit it and the recording holds neither the assert nor its pump,
so a replayer pumps fewer times than the original did. The trace is then a
complete-looking record of a run that did not happen: the PumpBoundary
([RFCS.22]) for that pump is there and the input that provoked it is not, so
the replay drives a pump against a working memory the recording never had.
Replay is unaffected by the atom's presence. A replayer injects the recorded assert, the engine performs the identical no-op suppression, and the same series-absorb and refraction outcomes follow. The atom restores the input without disturbing the discipline.
⚠ The volume cost is real and belongs to the input, not to this clause. A
source re-reporting an unchanged value writes one FactAssert per report, each
report a suppressing recorder would drop included. That is the price [LFST.12.5] already named — "the cost
of full fidelity" — and an encoder must not reintroduce suppression as a
compression: [LFST.12.8] forbids sampling within a kind.
The arriving assert precedes everything its evaluation produces. An
identity update (replaced — same identity, a changed slot) records the
FactAssert first and then a FactWithdraw for the superseded fact with cause
SUPERSEDED ([RFCS.7a.2]), never a modify-in-place. A replayer that delivers
the assert re-derives the withdrawal after it, and compares it ([RFCS.7a.3]).
A host retract is an input, and is ordered the same way. The engine records
the FactRetract on arrival ([RARC.5.8.10]), before everything its evaluation
produces: the faults it raises and the withdrawals it cascades into follow it. A
replayer that delivers the retract re-derives them after it.
An assert the engine refuses is recorded too. A bounds refusal ([LERR.1.5])
of a host assert answers an input that arrived, so the engine records its
FactAssert and then the BoundsError its evaluation produced. A replayer
delivers the assert, the engine refuses it again, and the replay compares the
re-derived BoundsError with the recorded one. The engine's refusal of a
delivered input is not a replay failure. A host call refused because it is not
a well-formed input, such as an unknown schema or a slot value of the wrong kind
(RARC.5.2.6), records nothing and produces nothing.
So does a host assert whose deadline would fall outside the Time range.
A fact's TTL deadline is its entry stamp ([LTIM.2.8.6]) plus its TTL. Where
that sum would fall outside the representable range, the engine must refuse
the assert with DS_ERR_TIME_RANGE ([LTIM.1.1.5]) and leave the engine as it
was before the call: neither clock moves, no sample is recorded, nothing enters
working memory, and a pending initial block stays pending ([LGRA.24.3]). The
call is not a step ([LTIM.2.8.4]), though the deadline it is refused for is
reckoned from the sample that step would have taken. So a recording holds no
trace of it, and a replay has nothing to re-derive.
A refusal inside a pump ends the firing, not the pump. A bounds refusal
([LERR.1.5]) of a rule's action is recorded as a BoundsError in the firing
that attempted it. The firing stops at the refused action, by the prefix rule
of [LNUL.11.1]: the actions before it stand, and the actions after it do not
run. The pump goes on, and returns DS_ERR_CONTRACT_BREACH. A replayer treats that status from a replayed pump as
an outcome, not a failure: it continues past the pump, and compares the
re-derived BoundsError with the recorded one when that atom arrives. A
refusal the recording holds and the replay does not re-derive, or the reverse,
is a divergence.
A halt is the other outcome a replayed input reports. An input during which
the engine raises an EngineError returns DS_ERR_ENGINE_HALTED ([NCBK.2.9]):
a pump whose firing faults, an assert or retract whose propagation does. Where
the engine was running when the replayer delivered that input, the status is
the recorded run's halt, re-derived, and a replayer must treat it as an
outcome: it continues, and compares the re-derived EngineError with the
recorded one when that atom arrives. The EngineError is the tier's last
record ([LERR.1.4.7]), so this is how the replay of a halted run reaches the
end of its recording, which is filed as that run's evidence ([NDET.2.1]). An
EngineError the recording holds and the replay does not re-derive, or the
reverse, is a divergence.
So is a status the pump's own evaluation reports. A refused call
leaves DS_ERR_NAN_REJECTED as a pump's status ([NCBK.6.8]), and a read no
backing can answer leaves DS_ERR_SERIES_NO_BACKING ([NERR.6]). Each is a
one-shot report: the recorded run went on, and the recording holds what followed.
A replayer must treat either as an outcome and continue. No atom records
either, and the compare of what the firing did is what decides: a call the
recording holds and the replay refuses, or the reverse, is a divergence at that
CallIssued. A pump refused before its step ([NLFC.9.5]) leaves no PumpBoundary,
so a replay never delivers it.
Any other failing status from a replayed pump ends the replay, and so does the refusal of an input that met an engine already halted: that input did not reproduce the run.
A replay's own status says whether it reproduced the run, not whether the run
halted. A replay that reaches the end of its recording with every
compare clean must return DS_OK, and it returns DS_OK for a run that
halted too, having compared the EngineError. The halt latch says the run halted
([NCBK.2.11]), and a host that replays a recording reads both. So
DS_ERR_ENGINE_HALTED from a replay means one thing: the replay did not reproduce
the run, or met an engine already halted.
ratified — see also: LERR.1.4.7, LERR.1.5, LFST.12.5, LFST.12.8, LGRA.24.3, LNUL.11.1, LTIM.1.1.5, LTIM.2.8.4, LTIM.2.8.6, NCBK.2.11, NCBK.2.9, NCBK.6.8, NDET.2.1, NERR.6, NLFC.9.5, RARC.5.2.3, RARC.5.8.10, RFCS.22, RFCS.7a.2, RFCS.7a.3
[RFCS.6.8] The event_id derivation. An engine must derive each
FactAssert's event_id ([LFST.5.6]) by this function, and no other. Let $r$
and $t$ be the UTF-8 bytes of the run identifier and the tier identifier the
integrator gave the engine, each empty when absent ([NLFC.1.2]); $s$ the
FactAssert's seq ([LFST.5.3]); $\operatorname{be}_{64}(s)$ its eight bytes,
most significant first; $\Vert$ concatenation; and $\texttt{1F}$ the single
byte 0x1F. The literal is the bytes of its ASCII characters.
$$h = \operatorname{SHA\text{-}256}\bigl(\texttt{"ds.rfcs.event_id.v1"} \Vert \texttt{1F} \Vert r \Vert \texttt{1F} \Vert t \Vert \texttt{1F} \Vert \operatorname{be}_{64}(s)\bigr)$$
$$u_i = h_i ;; (0 \le i < 16,\ i \ne 6, 8), \qquad u_6 = (h_6 \wedge \texttt{0F}) \vee \texttt{80}, \qquad u_8 = (h_8 \wedge \texttt{3F}) \vee \texttt{80}$$
$h_i$ is byte $i$ of the digest, counting from 0, and $\wedge$ and $\vee$ are bitwise. The two assignments set the UUID version to 8 and the variant to the standard one.
The event_id is $u_0 \ldots u_{15}$ written as 32 lower-case hexadecimal
digits, two per byte with the high nibble first, in groups of 8, 4, 4, 4 and 12
digits separated by -: 36 characters.
Fact emit [RFCS.6a]#
[RFCS.6a.1] A FactEmit atom records a fact the engine produced by
firing a rule the program author wrote. Its Cause-free counterpart on
the integrator side is FactAssert ([RFCS.6]).
The verb says who did it. A fact injected by the integrator is
asserted; a fact injected by rules is emitted. The inject/compare
split is therefore legible from the atom name, without consulting the
[RFCS.3.1] census.
ratified — see also: RFCS.6, RFCS.3.1
[RFCS.6a.2] The FactEmit body is defined in proto/fact_emit.proto.
It carries the same fact-bearing fields as FactAssert ([RFCS.6.2]) and
one the integrator atom has no use for: rule_name, the emitting rule, which is
never empty on this atom. Field 9 is reserved and out of use.
ttl_ns carries the per-emit TTL override ([LDTL.4.1]). The override is
evaluated from an expression at emit time, so it is not recoverable
from the .dsc and a reader that does not carry it cannot reproduce the
fact deadline.
ratified — see also: RFCS.6.2, LDTL.4.1
[RFCS.6a.3] FactEmit is compare class ([RFCS.3.4]). A replayer
re-derives it by firing the same rule and byte-compares it against the
record ([LFST.9.3]); it must not deliver it to the engine as an
input.
A re-derived fact's reference slot carries the fact_id of the fact it refers
to, as a live engine writes it ([RFCS.6.3]), and a replayer must compare it
as written. fact_id is part of every compared body, so a replay that passes
reproduces the recording's fact_ids, and the slot is then the recorded
handle. A slot that differs from the record is a divergence like any other.
This is what [LFST.9.2] requires of an engine-internal event, and what
[RARC.5.8.11] requires of a LogicalAssert. A replayer that delivered it
would feed the engine its own output back as input, so the determinism check
could not cover facts at all.
ratified — see also: RFCS.3.4, LFST.9.2, LFST.9.3, RARC.5.8.11, RFCS.6.3
[RFCS.6a.4] An emit that supersedes a live fact records the successor first. When a rule's emit replaces a live fact under the same identity ([LFAC.2.5.3]), the engine must record the FactEmit for the new fact and then the FactWithdraw for the superseded one, with cause SUPERSEDED ([RFCS.7a.2]). This is the order [RFCS.6.7] gives a host upsert: a supersedure under one identity records the successor before the withdrawal it causes.
The order of changes inside working memory is unaffected: the superseded fact leaves before its successor enters, so exactly one live fact per key holds at every point ([LFAC.2.5.3]). A replayer re-derives both atoms and compares them in this order ([RFCS.6a.3], [RFCS.7a.3]).
The clause covers supersedure under one identity only. A rule's as
correlation sweep ([LRST.2.2]) is a different case: it withdraws a fact of a
different identity as the rule's own action, which runs before the emit it
makes room for ([LCRS.6.2.1]). The engine records that FactWithdraw where the
action runs, ahead of the FactEmit. The firing causes both, and neither
causes the other.
A fault fact's replacement ([LERR.9.5]) is not a supersedure under
[LFAC.2.5.3] either. Fault schemas carry no identity roles in the artefact
([LERR.9.2]). The engine replaces a live fault fact by its own latching rule,
retracting it and then asserting the new one. The engine must record the
FactWithdraw for the live fault fact, with cause SUPERSEDED, and then the
FactEmit for its replacement ([LERR.9.8]).
ratified — see also: LCRS.6.2.1, LERR.9.2, LERR.9.5, LERR.9.8, LFAC.2.5.3, LRST.2.2, RFCS.6.7, RFCS.6a.3, RFCS.7a.2, RFCS.7a.3
[RFCS.6a.5] A compiler-owned fact is not recorded. A fact of a schema whose name is reserved for engine-managed identifiers ([LGRA.15.2]) — an after-clause timer fact ([LTAC.3.1]), a timeout-clause timer fact ([LCCO.7.2]) or a capture-corr fact ([LRST.4]) — is created by the lowering, not by a rule the author wrote. The engine must not record a FactEmit or a FactWithdraw for one, and the encoder announces none of these schemas ([RFCS.5.1]). A replayer re-derives such a fact from the recorded inputs that caused it.
ratified — see also: LCCO.7.2, LGRA.15.2, LRST.4, LTAC.3.1, RFCS.5.1
Fact publish [RFCS.27]#
[RFCS.27.1] A FactPublish atom (proto/fact_publish.proto#FactPublish) records
that a rule's publish ran: the schema it named, the rule, the firing's timetag,
and the action's clock_ns and seq. A publish the engine refused
([LTIE.4.8]) records none. It holds no slot value and no fact handle, since a
publish puts no fact in working memory ([LTIE.4.3]).
ratified — defined in: proto/fact_publish.proto#FactPublish — see also: LTIE.4.3, LTIE.4.8
[RFCS.27.2] FactPublish is compare class ([RFCS.3.4]). A replayer re-derives
it by firing the same rule and compares it against the record ([LFST.9.3.1]); it
must not deliver it to the engine as an input. The body holds no value, so a
replay that passes shows that the same rule published the same schema at the same
point, and shows nothing of the values. What crosses a tier is the event's
FactExternal ([NCBK.10.1]), which no atom records.
ratified — see also: LFST.9.3.1, NCBK.10.1, RFCS.3.4
Fact retract [RFCS.7]#
[RFCS.7.1] A FactRetract atom records the retraction of a previously
asserted fact.
ratified
[RFCS.7.2] The FactRetract body is defined in
proto/fact_retract.proto#FactRetract.
defined in: proto/fact_retract.proto#FactRetract
[RFCS.7.5] A FactRetract carries the seq and clock_ns of the stream
event that reported the retraction, as every other event atom carries its
own: seq is the event's place in the delivered stream ([LFST.12.1]), and
clock_ns is the engine's monotonic clock when the engine applied the
retraction, as FactAssert's is at the assertion ([RFCS.6.2]). An encoder
must write both. A retraction then has a position of its own in a trace, not
only the place it happens to sit in the file.
defined in: proto/fact_retract.proto#FactRetract — see also: LFST.12.1, RFCS.6.2
[RFCS.7.3] A reader must treat a FactRetract as a fatal stream error
unless its fact_id is carried by a FactAssert, a FactEmit or one of an
ExternalAssert's fact_ids ([RFCS.24.1]) earlier in the current file, whose
fact was in working memory when the reader met that atom, and no earlier
FactRetract named it. A runtime replaying the
stream must stop at that atom and return DS_ERR_FS_UNKNOWN_FACT_ID, the same
code whether it meets the atom as it opens the stream or partway through the
replay.
The integrator may retract a fact a rule emitted — a handle is a handle, and nothing in the API distinguishes them — so the referent set is every fact-bearing atom rather than only the integrator's. A well-formed recording never holds a retract this clause refuses: the host had no live fact to retract.
ratified — see also: RFCS.24.1
[RFCS.7.4] TTL expiry is not recorded as a FactRetract. It is an engine
withdrawal and is recorded as a FactWithdraw carrying TTL_EXPIRED
([RFCS.7a.2]), which a replayer compares rather than applies.
Double retraction is prevented by construction rather than by a rule
someone must remember: the replay re-derives the expiry from ttl_ns,
and the recorded atom is compared against what it re-derived.
FactEmit carries ttl_ns ([RFCS.6a.2]), which is what makes the
re-derivation above possible.
Fact withdraw [RFCS.7a]#
[RFCS.7a.1] A FactWithdraw atom records the engine taking back a fact it
was holding. Its counterpart on the integrator side is FactRetract
([RFCS.7.1]).
Withdraw is the corpus own word for the engine side: [IRET.12.2] is
titled "Justification withdrawal" and [LLOG.15.1] speaks of "the same
justification withdrawal, whatever ends the match".
ratified — see also: RFCS.7.1, IRET.12.2, LLOG.15.1
[RFCS.7a.2] The FactWithdraw body carries a closed Cause enum,
on the TrapKind precedent ([LERR.1.4.9]) — so a consumer branches on a
cause rather than string-matching, and a cause added without a raiser is
visible:
value |
raised by |
|---|---|
|
the truth-maintenance cascade — the last justifier LHS stopped matching |
|
the pump TTL sweep |
|
supersedure generally — a successor took the fact's place under the same identity. Both an identity upsert replacing a keyed fact ([LFAC.2.5.1]) and an |
|
a fact the lowering created to carry a deferred action, withdrawn because that action has run or an answer has ended it — the |
|
a rule's own |
|
a fact an activation emitted into a |
The engine must set the cause of each FactWithdraw it records where the
withdrawal originates, and must not record one whose cause is
CAUSE_UNSPECIFIED. Several origins reach one retraction path, so a cause
computed on that path would label them all alike.
The cause binds a recorded withdrawal only. A compiler-owned fact's
withdrawal is never recorded ([RFCS.6a.5]), so no cause the engine gives it
reaches any reader, and none binds. SYNTHETIC_DISCHARGED is the member that
names such a withdrawal. A runtime may label one by another member inside the
engine, as when a timeout sibling releases its call's capture fact by
correlation ([LCCO.7.2]).
Every member has a raiser, as every TrapKind member has. Number 4 is
reserved: the engine has no concept of a disconnected adapter ([RARC.14.5]),
so no withdrawal has that cause. A member added to a closed enum breaks a
reader that switches on it, so a new cause is a format change ([LDET.1.10]).
A reader must accept a FactWithdraw whose cause the enum does not hold,
the reserved 4 included, and carry the number. The atom is compare class
([RFCS.7a.3]), so an unknown cause is a difference the comparison finds, not a
decode error.
ratified — see also: LCCO.7.2, LCCO.7.6, LCYC.3.1.1, LDET.1.10, LERR.1.4.9, LFAC.2.5.1, LRST.2.2, LRST.4, LSCO.4.5.9, LSCP.2.4.1, LTAC.3.1, RARC.14.5, RFCS.6a.5, RFCS.7a, RFCS.7a.3
[RFCS.7a.3] FactWithdraw is compare class ([RFCS.3.4]) — re-derived and
byte-compared, never delivered to the engine, on the same reasoning as
[RFCS.6a.3].
A reader must treat a FactWithdraw whose fact_id matches no FactEmit or
FactAssert in the current file as a fatal stream error. The engine may
withdraw a fact the integrator asserted (a TTL expiry does not care who
asserted it), so unlike [RFCS.7.3] this rule spans both producers.
ratified — see also: RFCS.3.4, RFCS.6a.3, RFCS.7.3
[RFCS.7a.4] An engine withdrawal is recorded before everything its evaluation produces. When the engine withdraws a fact, whatever the cause ([RFCS.7a.2]), it must record the FactWithdraw before every atom the withdrawal's evaluation produces: the faults raised while the network re-evaluates without the fact, and the FactWithdraw of every fact the withdrawal cascades into. Each cascaded withdrawal is in turn recorded before what its own evaluation produces.
This is the order [RFCS.6.7] gives a host retract, applied to the engine's own withdrawals: a cause precedes its consequences in the stream. A replayer re-derives the withdrawal and what follows it, and compares them in this order ([RFCS.7a.3]).
The clause orders a withdrawal against its own consequences only. Where a superseded fact's withdrawal falls relative to its successor is [RFCS.6a.4]'s.
ratified — see also: RFCS.6.7, RFCS.6a.4, RFCS.7a.2, RFCS.7a.3
File boundaries [RFCS.8]#
Deferred: not binding in this edition.
[RFCS.8.1] The encoder may close the current file and open a new one at any time. Each file is a complete, independently decodable unit.
[RFCS.8.2] When a new file is opened, the encoder must emit:
A
StreamHeaderheader atom.For every schema that has facts currently asserted in working memory: a
SchemaDefatom and itsSlotatoms (even if those schemas appeared in a previous file).A
FactAssertatom for every fact currently in working memory, using freshfact_idvalues scoped to the new file.
⚠ Item 3 is unsettled. It re-emits as FactAssert, which is
inject class, facts the engine produced as FactEmit, which is compare class
([RFCS.6a.3]), so a trace spanning a file boundary does not support the
determinism check. The same question arises at an inline checkpoint
([RFCS.9.1a]) and is resolved once for both.
see also: RFCS.6a.3, RFCS.9.1a
[RFCS.8.3] The re-emitted FactAssert atoms in [RFCS.8.2] (item 3) must use the
clock_ns of the original assertion, not the time the new file was
opened, so that replay preserves the original timing.
see also: RFCS.8.2
[RFCS.8.4] Facts that were asserted and subsequently retracted before the file boundary must not appear in the new file.
[RFCS.8.5] Consumers that process multiple sequential files from the
same session must reset their fact_id tracking at each file
boundary.
Inline checkpoints [RFCS.9]#
Deferred: not binding in this edition.
[RFCS.9.1] A Checkpoint atom marks a position in the stream where a
complete WM snapshot is embedded inline. It serves the same purpose
as a file boundary ([RFCS.8]) but within a single file, enabling
O(events-since-checkpoint) re-drive for reverse navigation without
managing multiple files.
see also: RFCS.8
[RFCS.9.1a] Scope: working memory and the cache. A Checkpoint
snapshots live facts (the FactAssert atoms of [RFCS.9.3]) and the
engine's cache ([RFCS.9.3a]) — the cache is engine state ([LSTO.4.7])
that rules read inside the fire loop (cached() in where,
[LSTO.4.3.1a]), so a seek that restored WM but not the cache would
diverge on the first cache-keyed rule. It does not snapshot series
backing state — running stats, sketches, deques, and signal backings
are engine state outside WM and are not serialised ([LSER.9.2],
[LDET.2.2a]). A reader that seeks to a Checkpoint and drives forward
restores WM and the cache exactly but cold-starts every series, so
series-derived facts are warm-up-biased until the backings re-warm and
diverge from the original run. Faithful replay of series-reading rules
requires a full drive from a recording that began at engine-cold, where
the backings rebuild identically from the stream.
⚠ This clause states the snapshot's scope, not its correctness, and the
mechanism is unsettled. A snapshot re-emits live working
memory as FactAssert ([RFCS.9.3]), which is inject class. A fact the engine
produced is a FactEmit, which is compare class ([RFCS.6a.3]). A replayer
given the snapshot is therefore handed as input what it was to re-derive, so a
trace carrying a Checkpoint does not support the determinism check. The two
candidate resolutions — a distinct snapshot class, or declaring such a trace
unreplayable — differ by an atom allocation, and neither is settled here.
see also: LDET.2.2a, LSER.9.2, LSTO.4.3.1a, LSTO.4.7, RFCS.6a.3, RFCS.9.3, RFCS.9.3a
[RFCS.9.2] The Checkpoint body, including its nested CacheEntry
message — the engine cache snapshot ([RFCS.9.3a]), one entry per live
cache key — is defined in proto/stream_header.proto#Checkpoint.
defined in: proto/stream_header.proto#Checkpoint — see also: RFCS.9.3a
[RFCS.9.3] Immediately following a Checkpoint atom the encoder MUST
emit: for every schema with live facts — one SchemaDef and its Slot
atoms (even if already announced earlier in the file), then one
FactAssert atom per currently-live fact. These re-emitted FactAssert atoms
use the original clock_ns of each assertion ([RFCS.8.3]) and
fresh fact_id values valid only within the segment that begins at
this checkpoint.
see also: RFCS.8.3
[RFCS.9.3a] The Checkpoint atom also carries the engine's cache: the
Checkpoint.cache repeated field ([RFCS.9.2]) holds one entry per live
cache key — key, value_json (the opaque stored value), and
ttl_deadline_ns (0 = no expiry). A reader that seeks to it
restores the cache from these entries before driving forward, so
cached() reads after the seek return exactly what they returned at
the original checkpoint ([LSTO.4.7]). Expired-by-clock_ns entries MAY
be omitted by the encoder. The snapshot is embedded in the Checkpoint body
(not re-emitted as separate atoms) because cache entries are not .dstrace
stream atoms in v1 ([RFCS.15.7]); the field is additive to Checkpoint and
needs no StreamHeader version bump.
see also: LSTO.4.7, RFCS.15.7, RFCS.9.2
[RFCS.9.4] A reader MAY use a Checkpoint atom as a random-access entry
point for reverse navigation: restore WM state from the following
FactAssert atoms, the cache from Checkpoint.cache ([RFCS.9.3a]), and both
clocks from Checkpoint.clock_ns and Checkpoint.wall_ns ([LTIM.2.8.5]), then
apply subsequent stream events forward. When Checkpoint.has_wall is false
the wall clock had no value at the checkpoint, and the reader restores it
without one, ignoring wall_ns. A fact restored from a FactAssert
atom enters with the entry stamp the atom carries ([RFCS.9.3]), not the clock
the checkpoint restored, so dwell and within read after a seek what they
read in the recording ([LTIM.2.8.6]).
see also: LTIM.2.8.5, LTIM.2.8.6, RFCS.9.3, RFCS.9.3a
[RFCS.9.5] A reader that does not implement checkpoint seeking MUST
still process the following SchemaDef/Slot/FactAssert atoms normally.
Such a reader skips the Checkpoint atom; the SchemaDef/Slot/FactAssert atoms that
follow are standard atoms and are processed as usual, appearing as
re-assertions. Readers must handle duplicate assertions idempotently
(assert over the existing fact using the same fact_id within the
segment).
[RFCS.9.6] The encoder SHOULD emit a Checkpoint every N WM-mutation
events, where N is the checkpoint interval configured at session open
(default 500). An encoder MAY choose not to emit Checkpoint atoms at
all; the stream remains valid, but reverse navigation degrades to
O(N) re-scan from the start of the file.
Clock advances [RFCS.10]#
[RFCS.10.1] A ClockAdvance atom records a new sample of the engine's two
clocks ([LTIM.2.8.5]): clock_ns is the monotonic clock ([LTIM.2.8.2]) and
wall_ns the wall clock ([LTIM.2.8.3]). Every ClockAdvance carries both,
whichever of them moved. has_wall is false when the wall clock has no value,
and wall_ns then carries nothing; the engine must write has_wall on
every ClockAdvance. Clock advances are input events ([LFST.6.1]) and are
required for replay: without them, time-bound rules
(after:, TTL expirations, cooldown: windows) fire at different
times during replay, breaking determinism.
checks: idris — see also: LTIM.2.8.2, LTIM.2.8.3, LTIM.2.8.5, LFST.6.1
[RFCS.10.2] The ClockAdvance body is defined in
proto/stream_header.proto#ClockAdvance.
defined in: proto/stream_header.proto#ClockAdvance
[RFCS.10.3] The engine must emit a ClockAdvance event for every clock
value it observes, of either clock, under a live clock and a mock clock alike.
A value is observed when a sample reads it ([LTIM.2.8.4]); a mock clock's
value is observed by the next sample after it is set, not when it is set
([NTST.3.3]). It must not coalesce, decimate or omit the values its samples
observe.
A time-bound rule — after:, a TTL expiry, a cooldown: window — decides on
the value the engine held, so a value the trace does not carry is one a replay
cannot restore, and the rule fires somewhere the recording never was. Dropping
clock values to reduce trace size is sampling within a kind, which
[LFST.12.8] forbids, and the saving is bought from the guarantee
([LFST.1.3]).
ratified — see also: LFST.1.3, LFST.12.8, LTIM.2.8.4, NTST.3.3
[RFCS.10.5] A replaying reader ([LFST.9.6]) MUST apply each ClockAdvance by
advancing the replay engine's monotonic clock to clock_ns and setting its
wall clock to wall_ns before processing the next atom. When has_wall is
false the recorded wall clock had no value: the reader leaves the replay
engine's wall clock without one and ignores wall_ns, so a now() the
recording faulted ([LTIM.2.8.3]) faults again in the replay.
The reader must end the replay with DS_ERR_TIME_RANGE at a ClockAdvance
whose clock_ns is outside the monotonic clock's range ([LTIM.2.8.2]), as a
host's move past the range is refused ([NTST.3.1]).
checks: tla×3 idris×7 — see also: LFST.9.6, LTIM.2.8.2, LTIM.2.8.3, NTST.3.1
Rule-fire annotations [RFCS.11]#
[RFCS.11.1] A RuleFireAnnotation atom marks the beginning or end of a rule
activation firing. It is required for Bindings scope in stepback: a replaying
reader ([LFST.9.6]) uses RuleFireAnnotation to know which rule was firing at
the current trace position and to bracket facts to their activation.
see also: LFST.9.6
[RFCS.11.2] The RuleFireAnnotation body is defined in
proto/stream_header.proto#RuleFireAnnotation.
The timetag (field 6) is the firing activation's identity: the same
(timetag, rule_name) the bracketed CallIssued records, so the two atoms carry a
byte-identical join key ([RFCS.15.2]). The encoder must record the firing
activation's own creation timetag ([LDET.5.5]). 0 appears only on the
ahead-of-time dispatch path, which carries no fire identity, and is never a valid
timetag.
A timetag's value is the engine's own. [LDET.5.5] fixes the order in which an
engine's timetags ascend, not their origin or their step, so two conforming engines
may record different values for one run. A timetag, on this atom or any other
that carries one, identifies a firing within one stream. A consumer may use it
to join that stream's atoms and to order one rule's firings, and must not
compare its value with a timetag from another engine's stream. A replayer
compares it by the pairing [LFST.9.3.6] defines.
ratified — defined in: proto/stream_header.proto#RuleFireAnnotation — see also: LDET.5.5, LFST.9.3.6, RFCS.15.2
[RFCS.11.3] For every rule firing, the encoder MUST emit one RuleFireAnnotation
atom with end=false immediately before any atoms produced by that rule's
RHS, and one RuleFireAnnotation atom with end=true immediately after.
A fact a rule produces is a FactEmit ([RFCS.6a.1]), not a FactAssert; the
bracket spans every atom the firing produced, whatever its kind.
ratified — see also: RFCS.6a.1
[RFCS.11.4] All atoms between a matching begin/end RuleFireAnnotation pair
are attributed to that activation — the FactEmit atoms the rule produced
([RFCS.6a.1]) and every other atom its firing emitted. RuleFireAnnotation.rule_name and
RuleFireAnnotation.timetag on the preceding begin atom are the provenance
for those atoms — and, being the same (timetag, rule_name) the
bracketed CallIssued records, resolve the CallIssued↔RuleFireAnnotation join ([RFCS.15.2]).
see also: RFCS.15.2, RFCS.6a.1
[RFCS.11.5] A replaying reader ([LFST.9.6]) uses RuleFireAnnotation to
populate the "current activation" display when stepping through the trace —
the most recent unmatched begin atom identifies the rule firing at the current
position.
see also: LFST.9.6
[RFCS.11.6] An inspecting reader that does not use RuleFireAnnotation
MUST skip it. The rule_name field on each fact-bearing atom
remains sufficient for fact-level provenance without RuleFireAnnotation.
A replaying reader must not skip it. RuleFireAnnotation is compare class
([RFCS.3.1]) and is one of the two atoms the byte-compare is performed over
([LFST.9.3.7]); a replayer that skipped it would drop half the comparison and
still report success. The permission above is for a reader that compares
nothing ([RFCS.1.2]).
see also: LFST.9.3.7, RFCS.1.2, RFCS.3.1
Schema-atom sourcing [RFCS.12]#
[RFCS.12.3] The engine's schema registry is the source, not the DSC.
An encoder must announce every schema the engine holds before the first fact
that uses it ([RFCS.5.1]), or a reader hits [RFCS.5.4] at the first
FactAssert. Every such schema came from the loaded artefact ([NFCT.1.1]),
the built-in schemas the program uses with it ([LIMP.12.2]), so the DSC carries
a SchemaDef and its Slot atoms for each.
An encoder may forward those atoms, extracting them from the DSC bytes by the
DSC framing ([RDSC.2]), or construct them from the schema registry. A
SchemaDef it constructs names the schema and may carry an empty
proto_source: the Slot atoms are the schema's shape on the wire, and a
reader decodes the schema's facts from them, with no artefact ([LFST.8.10]).
see also: LFST.8.10, LIMP.12.2, NFCT.1.1, RDSC.2, RFCS.5.1, RFCS.5.4
Self-containment — embedded DSC [RFCS.13]#
A .dstrace may be made self-contained by prepending its bound
.dsc. Both are streaming atom formats, so [DSC][StreamHeader] is one valid
stream, and the order is the natural load order (definitions before
references).
[RFCS.13.1] embed is concatenation (cat dsc dstrace) — no
transformation, no crypto. strip removes the front by walking DSC
atoms by length and stopping at the StreamHeader atom, yielding the bare lean
stream; the dsc_hash binding survives, so a stripped stream still
verifies against a supplied DSC. extract is free — the bytes
strip removes are exactly the .dsc.
[RFCS.13.2] The boundary walk must be atom-aware, not a byte scan.
A reader must locate the DSC→StreamHeader boundary by walking atom lengths;
it must not scan the bytes for the StreamHeader atom's tag, because a DSC atom
payload may contain those bytes and false-positive the boundary.
[RFCS.13.3] The leading atom discriminates the form. A
DscHeader first atom means self-contained ([DSC][StreamHeader]); a
StreamHeader first atom means lean. A reader must dispatch on the first
atom's oneof field number ([RFCS.16.1]), which is its identity — not on
any four-byte prefix. StreamHeader must occupy a field number distinct
from every DSC atom's ([RDSC.7.5]) so the boundary is unambiguous
once the DSC's trailing atom is no longer the end of file.
[RFCS.13.4] Self-containment is determinism-neutral: the concatenated stream replays bit-identically to the lean stream plus its DSC ([LDET.2.6]).
see also: LDET.2.6
Call provenance — the CallIssued atom [RFCS.15]#
[RFCS.15.1] A CallIssued atom records an outbound engine-initiated call
(CallIssued, [LFST.6.3]) as first-class provenance, so an archived
stream holds the calls a run issued — not only the responses it
received (those arrive as response facts or CallError facts →
FactAssert, [RFCS.6]). The body is CallIssued (proto/call_issued.proto,
[RFCS.15.2]); the recorder is its only producer.
ratified — defined in: proto/call_issued.proto#CallIssued — see also: LFST.6.3, RFCS.15.2, RFCS.6
[RFCS.15.2] The CallIssued body is defined in
proto/call_issued.proto#CallIssued. The recorder is its only producer; it
leaves field 1, call_id, absent.
The arguments are typed and named. args holds one Arg ([RFCS.23.2]) per
kwarg the call supplies, sorted by kwarg name; an optional kwarg the call omits
is absent, not null. A kwarg declared with a schema or with Schema
([LADP.8.6.1]) is an Arg of kind KIND_ENCODED_FACT carrying the bound fact
as a FactExternal ([RFCS.23.1]). The call callback ([NCBK.6.2]) and the
DS_EV_ACTION_CALL event carry the same arguments.
Joins. (timetag, rule_name) is the firing activation's identity:
RuleFireAnnotation ([RFCS.11.2]) carries the byte-identical pair, so a
recorded CallIssued resolves to the RuleFireAnnotation bracketing it.
correlation joins it forward to the answers it will (or will not) receive.
correlation is always present and never empty ([LCRS.3.1]): the author's
as string, or the per-activation value the compiler generated
([LCCO.3.4]).
ratified — defined in: proto/call_issued.proto#CallIssued — see also: LADP.8.6.1, LCCO.3.4, LCRS.3.1, NCBK.6.2, RFCS.11.2, RFCS.23.1, RFCS.23.2
[RFCS.15.3] Emit rule. When call recording is enabled ([RFCS.15.6]),
the encoder MUST emit exactly one CallIssued atom per DS_EV_ACTION_CALL
event. The engine emits that event once the call's arguments evaluate, before
the call callback runs, whatever the callback answers ([IDSP.6.5],
[IDSP.1.4]). The engine emits the event, never the atom ([IARC.1.14]); the
encoder (recording writer) encodes the CallIssued from it. A call the engine
refuses before that point — an argument that fails to evaluate, or a NaN
([LEXP.4.2]) — emits no event, hence no CallIssued.
ratified — see also: IARC.1.14, IDSP.1.4, IDSP.6.5, LEXP.4.2, RFCS.15.6
[RFCS.15.4] Classification. CallIssued is a compare atom
([RFCS.3.4]): never injected, byte-compared on replay ([LFST.9.3.1]).
see also: LFST.9.3.1, RFCS.3.4
[RFCS.15.5] Canonical serialization. The persisted body carries the
cross-platform wire obligation the FactAssert atom already meets:
deterministic field order, golden vectors matching the codec bit-for-bit
([LDET.3.4.1]). args is canonical by construction: sorted by kwarg name, each
value in the single encoding its kind has ([RFCS.23.2]) — a Float as an
IEEE-754 double, a Json value as canonical JSON text ([LDET.3.2.7]).
see also: LDET.3.2.7, LDET.3.4.1, RFCS.23.2
[RFCS.15.6] Emission is unconditional; recording is the integrator's
cost. The engine must emit a CallIssued event for every outbound call it
issues ([LFST.1.3]), and must not gate that emission on a capability, a build
flag or a configuration value.
The engine serialises nothing and grows nothing. It emits a typed event, and the integrator encodes bytes if it wants bytes ([RFCS.15.3]). Serialization and trace growth are therefore costs an integrator elects by subscribing, not costs the emission imposes; an engine with no subscriber invokes nothing.
Whether a target carries a stream surface at all is a separate question and is
answered for the whole surface, never per kind ([LFST.1.3]). A constspace
or realtime build without one emits nothing and produces no trace. What no
build may do is emit some kinds and withhold others: the resulting trace reads
as complete, and nothing in it says otherwise.
[RFCS.15.7] Verb scope. Of the outbound verbs, v1 records call with its
arguments, and publish as a marker with no values ([RFCS.27]).
cache does not straddle the injection classification
([RFCS.3.4]): CacheGet is a pure internal read
([RARC.5.7.9], [LFST.9.2]) — not a replay input at all — while
CacheSet / CacheDelete are pure outputs. Cache provenance
is therefore cleanly output-only and is not recorded per verb.
v1 records the outbound CallIssued plus correlation_id and leaves
the request-to-response span to tooling; a timeout is the
absence of a matching response, inferred rather than
recorded.
see also: LFST.9.2, RARC.5.7.9, RFCS.27, RFCS.3.4
The unified atom registry [RFCS.16]#
[RFCS.16.1] There is one atom registry: a single protobuf oneof body over one
field-number space, shared by the DSC container (Dsc { repeated Atom }) and the
recorded event trace (Stream { repeated Atom }). Each container carries a legal
subset of the registry (per [RFCS.17.1]); an atom's field number is its wire
identity in both.
see also: RFCS.17.1
[RFCS.16.3] A field inside an atom's body that the reader does not know is
skipped, as protobuf skips it; within one <major>.<minor>. series
([LDET.1.10]) that can only be a field the series has struck and reserved,
which nothing may read ([STYL.2.8.7]).
see also: LDET.1.10
[RFCS.16.5] There is no promotion mechanism and no frequency ranking — a field number is wire identity, and no atom is renumbered.
[RFCS.16.6] Shared bodies are distinguished by number, never by an in-body discriminator. An atom is identified by its own oneof field number alone ([RFCS.16.1]); were two atoms to reuse one protobuf body, a reader would tell them apart by that number and never by a discriminator inside the body. There is one number per atom and no in-band discriminator.
Every live oracle atom carries a body of its own (proto/test_oracle.proto). SchemaDef
and Slot share their bodies with the DSC container, not with each other, and hold
one number each ([RFCS.3.2]).
defined in: proto/test_oracle.proto — see also: RFCS.16.1, RFCS.3.2
Container-legality + stream-class metadata [RFCS.17]#
[RFCS.17.1] Each registry atom carries two normative table columns, resolved by a known reader and never number-encoded:
container-legality —
DSC/stream/both.stream-class —
inject/compare/structural(meaningful when the atom appears in a stream).
[RFCS.17.2] [RFCS.17.1]'s two columns are columns of the census tables, not of this document. Both tables carry them, for their own rows:
table |
columns |
|---|---|
|
Atom · Field # · Direction · Purpose · container-legality · stream-class |
|
Atom · Field # · Multiplicity · |
Both tables carry data ([STYL.5.3.2.1]), which is each table's only copy.
The two columns state which containers may carry an atom, and what a replayer does with it.
see also: RDSC.7.1, RFCS.17.1, RFCS.3.1
[RFCS.17.3] An atom appearing in a container its container-legality does not admit is malformed; a reader must reject such a container.
[RFCS.17.4] Container legality has one normative home, and it is this clause.
Under [RFCS.16.1] there is one registry over one field-number space, so which container may carry an atom is a column of one table rather than a property of two alphabets. [RDSC.8.8] cites this clause for the rule and states only what is local to the DSC grammar: that a production may name a DSC-legal terminal and no other. Membership itself is a query over the container-legality column, which is gate-checkable where a prose list is not.
see also: RDSC.8.1, RDSC.8.8, RFCS.16.1
[RFCS.17.5] On replay a reader must treat each atom by its stream-class: deliver
an inject atom to the engine as a recorded input; re-derive a compare atom and
byte-compare it to the record and must not deliver it ([LFST.9.3]); and treat a
structural atom as framing/schema/seek with no replay-input role.
see also: LFST.9.3
[RFCS.17.6] Stream-class divides along the same line container legality does ([RFCS.17.4]): table fact versus behaviour rule.
Membership is a table fact — which atoms are
inject,compare,structural. Its single home is the stream-class column ([RFCS.17.2]), and[RFCS.3.4]does not enumerate it. Membership is a query over that column, which is gate-checkable where a prose list is not.Behaviour is a rule, and prose is its home — so
[RFCS.3.4]is retained, not superseded, as the single home for the obligations a column cannot carry: that a reader's inject path must refuse any atom outside the inject class, the determinism reasoning behind it (acallis never a replay input — deliveringCallIssuedorRuleFireAnnotationas an input corrupts determinism, and skipping an inject-class atom drops a real input), and the skip-safety corollary.
[RFCS.17.5] therefore does not restate [RFCS.3.4]'s obligations, and [RFCS.3.4] does
not restate the column. Each fact has exactly one home.
Framing mechanics [RFCS.19]#
[RFCS.19.1] The framing is two levels and both are protobuf. A container is a
Dsc or a Stream, each declared repeated Atom atoms = 1
(proto/atom.proto#Dsc, proto/atom.proto#Stream). So the unit repeated on the wire is
the outer frame — [0x0A][varint len][Atom], the field-1 tag of the container message
— and the inner Atom is itself [tag][varint len][body], where that tag is the
atom's oneof field number and carries its identity ([RFCS.16.1]).
container = { frame } ; (* Dsc or Stream; type from the first atom *)
frame = outer_tag , varint_len , atom ;
outer_tag = %x0A ; (* field 1, wire type 2 *)
atom = oneof_tag , varint_len , body ;
oneof_tag = ?varint of (field_number << 3 | 2)? ;
Residue the grammar cannot carry ([STYL.2.15.4]): outer_tag is one byte for every
atom. A partial trailing frame is EOF ([RFCS.19.2]); the productions
cannot say that. And the container's type is not in the grammar at all: it is the first
atom's field number ([RFCS.19.4]).
ratified — defined in: proto/atom.proto#Dsc, proto/atom.proto#Stream — see also: RFCS.16.1, RFCS.19.2, RFCS.19.4
[RFCS.19.2] A partial trailing atom ends a Stream read incrementally. In a
Stream, a partial trailing atom (a short length or a truncated body) is EOF, not an
error, for a reader consuming the stream incrementally: the reader must end the
container at the last complete atom ([RFCS.6.6]). A reader whose caller supplied the full
extent — a whole buffer — may instead treat a partial trailing atom as an error,
because the caller has asserted that extent is the whole stream; a short tail is then the
caller's slice being wrong, not the stream being in progress.
This clause does not reach a Dsc: a truncated .dsc is a loader error ([RDSC.9.7]).
Recovery of a crash-truncated recording is the incremental reader's ([RFCS.19.8]).
The two containers share a framing and differ here because of what each is for. A
recording is appended to while it is being read: a reader that called a half-written tail
corruption would fail on every live stream, and [RFCS.19.8]'s recovery to the last complete
atom would have nothing to stand on. A .dsc is never appended to while being read. It is a
finished artefact, and a truncated one is a rule bundle missing rules: accepting it would run
a policy the author did not write.
ratified — see also: RDSC.9.7, RFCS.19.1, RFCS.19.8, RFCS.6.6
[RFCS.19.3] A conforming reader must refuse a container containing an Atom whose
body oneof is unset. There is no identity to dispatch on ([RFCS.16.1]).
This has to be said because protobuf disagrees, and silently. An empty Atom is a
perfectly valid protobuf message: every field is optional, so a generated parser accepts
it and reports success. An implementer building on protobuf's own parser therefore gets
this wrong by default, and gets no diagnostic saying so.
DS departs from protobuf's parsing behaviour twice:
case |
protobuf |
DS |
where |
|---|---|---|---|
truncated trailing atom |
refuses the message |
reads on, keeps the complete atoms |
[RFCS.19.2] — DS is weaker |
|
accepts — a valid message |
refuses — no identity to dispatch on |
this clause — DS is stricter |
defined in: proto/atom.proto#Atom — see also: RFCS.16.1, RFCS.19.2
[RFCS.19.4] A reader tells a stream from a DSC by its first atom. A container is a
bare length-delimited protobuf — Dsc / Stream field 1, so it begins with the 0x0A
tag — and carries no ASCII magic. A reader must distinguish a stream from a DSC by its
first atom's oneof field number: StreamHeader (258) opens a stream, DscHeader (263)
opens a DSC.
A self-contained bundle ([RFCS.13]) opens with DscHeader and is a concatenation,
[Dsc][Stream] ([RFCS.13.1]), so the first atom does not separate a lean .dsc from a
bundle. A reader must find a bundle's stream by the atom-aware boundary walk
([RFCS.13.2]), reading frames by length until a StreamHeader atom appears where the DSC
would otherwise have ended. A reader must not scan the bytes for a header's tag: an atom
payload may contain those bytes, and StreamHeader's two-byte tag collides with payload
readily.
A reader must not classify a container by its leading byte. It parses the first atom and reports either no complete first atom ([RDSC.9.7]) or not a valid container ([RFCS.19.1]). An ASCII byte is not excluded from a protobuf tag position, so a leading-byte sniff has false positives, and a false positive rejects a valid artefact while reporting it as something else.
see also: RDSC.9.7, RFCS.13, RFCS.13.1, RFCS.13.2, RFCS.19.1
[RFCS.19.6] A writer must not frame an atom at a field number the registry does not allocate, and must fail rather than emit one.
[RFCS.19.7] A reader may reject an atom whose declared length exceeds an implementation bound without waiting for, or allocating for, its body. This does not conflict with [RFCS.19.2]: the bytes in hand are a partial trailing atom, which that clause calls EOF, yet a stream declaring a 4 GiB atom must not be able to make a reader wait for it.
The bound itself is an implementation matter and no value is specified here. What is specified is that acting on the declared length is legitimate — otherwise an implementer reading [RFCS.19.2] alone would conclude that any decision taken before a complete atom arrives is non-conforming, and the denial-of-service defence would look like a violation.
see also: RFCS.19.2
[RFCS.19.5] A writer of either container ([RFCS.19.1]) must write the fields of every message it emits in ascending field-number order: each atom body, and every message nested in one, a fact body included. It must write a field that is not repeated at most once. It must write the elements of a repeated field in the order the clause defining that field states, and, where no clause states one, in an order that depends on the writer's input alone.
A writer's bytes for one input are then the same on every conforming platform ([LDET.3.4.1]). Ascending order is a property of the bytes alone, so it can be checked on one platform's output; the element order of a repeated field no clause orders cannot.
ratified — see also: LDET.3.4.1, RFCS.19.1
[RFCS.19.8] A recording that ends at its last complete atom is in progress
or crash-truncated, not corrupt. A reader must not treat a Stream that reaches
EOF ([RFCS.19.2]) as an integrity failure: the recording is complete as far as
it goes, and the reader recovers it to the last complete atom.
The recovery path is the incremental reader ([RFCS.19.2]). This is a property of the container, so it must not depend on which entry point a caller reached for; naming the path is what keeps that true while a whole-buffer reader is still permitted to refuse a short tail. A conforming implementation must therefore offer an incremental path capable of recovering a crash-truncated recording. Without one, the recovery this clause promises has no path that delivers it.
see also: RFCS.19.2
Trap provenance — the ComputationError atom [RFCS.21]#
[RFCS.21.1] A ComputationError atom records a trap — a computation with no honest
answer ([LERR.1.4.1]). Its body is proto/engine_error.proto#ComputationError, and
it is the first of the two steps [LERR.9.1] orders: record the event, then
assert the fault fact. Recording is the delivery: the integrator receives the
atom on the stream callback ([NCBK.2.8]), and no separate fault callback
follows. The fault fact is itself recorded, as a FactEmit ([LERR.9.8]). A trap that is not
recorded did not happen as far as any consumer can tell.
Container-legality stream, stream-class compare (field 325). It is
provenance in exactly the sense CallIssued and RuleFireAnnotation are: a
replayer compares it.
Identity is rule_name + timetag, the same pair CallIssued and
RuleFireAnnotation carry ([RFCS.15]), so a trap joins to the activation that
caused it with no new join key.
A trap raised while matching carries timetag 0. No activation exists
then ([LERR.9.11]), and the engine must not give any activation the timetag
0, so 0 names no activation. Such a trap is told apart by its rule_name
($beta_<id>), node_id and fact_id, and placed among one operation's
traps by [LERR.1.4.12].
The slot-context fields name the offending operand ([LERR.9.12]): set when
that operand is a slot read, and absent otherwise. Every kind this atom records
is a computation error ([LERR.1.4.9]). A resource limit is a BoundsError or
an EngineError, and is not recorded here; a recorder failure is no fault at
all ([NCBK.1.5]).
recoverable is carried on the wire and is not derivable from kind.
[LERR.1.4.9] makes recoverability a property of the occurrence rather than of
the kind: the test is whether engine state is still trustworthy. Every kind this
atom records is reported.
A recorder failure is not this atom's concern. The recorder is a hook layer, not a writer (RARC.5.8, [IARC.1.14] — libds writes no file), so the engine emits the record as it emits any other and it is the integrator's sink that may be unable to persist it (RARC.5.8.13). A failing sink's status is what the call that fired the callback returns ([NCBK.1.5]), and the engine does not halt.
ratified — checks: alloy×6 k — defined in: proto/engine_error.proto#ComputationError, proto/engine_error.proto#TrapKind — see also: IARC.1.14, LERR.1.4.1, LERR.1.4.12, LERR.1.4.9, LERR.9.1, LERR.9.11, LERR.9.12, LERR.9.8, NCBK.1.5, NCBK.2.8, RARC.5.8, RARC.5.8.13, RARC.5.8.9, RFCS.15
Pump boundaries — the PumpBoundary atom [RFCS.22]#
[RFCS.22] A PumpBoundary atom marks one pump of the engine to quiescence
([RARC.5.6.6]). The engine must emit one per pump, including a pump that
fired nothing — that pump is exactly the one no other atom records, and it is
the case the atom exists for.
Container-legality stream, stream-class inject (field 4).
A replayer performs a pump on meeting one, so it is an input the engine was
given rather than an observable it produced, and it must not be compared
([RFCS.17.5]).
The body carries no fire count (proto/pump_boundary.proto). An inject
atom's body is delivered to the engine and never compared, so a count of what
the pump fired — engine output — would be a number a replayer must ignore while
looking like one it should check. What a pump fired is already on the trace, as
the atoms emitted between this boundary and the previous one.
Why a boundary. Without one, a trace cannot distinguish
assert, assert, pump from assert, pump, assert, pump, because a pump that
fires nothing leaves no other trace. The engine records what it did, so a
replayer reproduces it ([LFST.9.2.1]).
The cadence is read off the trace and declared nowhere. No header field
carries it; StreamHeader reserves field 15 and its name
(proto/stream_header.proto, [STYL.2.8.7]).
defined in: proto/pump_boundary.proto#PumpBoundary — see also: LFST.9.2.1, RARC.5.6.6, RFCS.17.5
Facts that leave the engine — FactExternal [RFCS.23]#
[RFCS.23.1] A fact leaves the engine as a FactExternal
(proto/fact_external.proto#FactExternal): a portable value, not a stream
atom. It is the form of a fact published to another tier ([NCBK.10]) or passed
as a call argument ([LADP.8.6.1]).
Unlike FactAssert ([RFCS.6]) it needs no SchemaDef or Slot atom to decode,
carries nothing local to one stream, and has no stream role: it decodes without
the program that wrote it. Its fields carry their slot names, so a receiver
matches them by name.
defined in: proto/fact_external.proto#FactExternal — see also: LADP.8.6.1, NCBK.10, RFCS.6
[RFCS.23.2] One typed-value encoding for facts and calls. Every value is
an Arg (proto/fact_external.proto#Arg): a name, a Kind, and the one
value member that kind names (none for KIND_NULL). Kind
(proto/fact_external.proto#Kind) is one number space with two subtypes:
a slot value admits the common kinds and
KIND_FACT_REF;a call argument admits the common kinds and
KIND_ENCODED_FACT.
A number belonging to one subtype is reserved in the other ([STYL.2.8.7]). So a
FactExternal's fields never carry KIND_ENCODED_FACT, and a call's arguments
([RFCS.15.2]) never carry KIND_FACT_REF. A call argument never carries KIND_NULL in this edition: a call whose argument has no value is not made ([LNUL.11.1]). A Json value is the JSON text
[LGRA.5.8.7a] gives it.
A Kind is how a value is represented, not the type it was declared with. A
Time, Date or Duration value is KIND_INT, carrying the integer
[RDSC.5.5.8] gives it. A program that receives one reads it as its own slot's
declared type, which [RFCS.23.3] makes the writer's.
The engine's own slot-kind and argument-kind enumerations, and every other
consumer's, are generated from Kind and reconciled against it ([STYL.5.9.7]).
ratified — defined in: proto/fact_external.proto#Arg, proto/fact_external.proto#Kind — see also: LGRA.5.8.7a, LNUL.11.1, RDSC.5.5.8, RFCS.15.2, RFCS.23.3
[RFCS.23.3] schema_hash fingerprints what decoding depends on. It is the
SHA-256 of the schema's SchemaShape (proto/fact_external.proto#SchemaShape):
the schema's own name ([LIMP.13.1]) and, for each slot in byte order of slot name, the slot's
name, its Kind, whether it is nullable, for a fact-reference slot the
referenced schema's own name, and for a slot declared Time, Date or Duration
its declared SlotKind (proto/slot.proto#SlotKind, [RDSC.5.5.8]). So a
Time slot and an Int slot of the same name hash differently, though both
carry KIND_INT ([RFCS.23.2]). The shape is encoded with its fields in field-number
order and default values omitted, so every writer produces the same bytes.
Lifecycle, identity keys, slot order and units are outside the hash: the receiving program applies its own ([RFCS.23.6]).
A FactExternal's schema is the schema's own name. A program must refuse a
FactExternal whose schema_hash differs from that of its own schema of the
same name, and must refuse one naming a schema it does not declare
([LIMP.13.3]). A record written under a changed schema is read only after migration
([RFCS.23.8]).
defined in: proto/fact_external.proto#SchemaShape — see also: LIMP.13.1, LIMP.13.3, RDSC.5.5.8, RFCS.23.2, RFCS.23.6, RFCS.23.8
[RFCS.23.4] Fields. A FactExternal carries one field per slot of the
writing schema, in that schema's declaration order, each named for its slot. A
null slot is KIND_NULL.
A fact-reference slot carries the referenced fact, inlined as a nested
FactExternal of kind KIND_FACT_REF. References are written once, when the
referring fact is asserted ([LGRA.5.7a.2]), so a referenced fact always predates
the fact that refers to it: nesting is finite and acyclic.
A reference whose target has left working memory is written as KIND_NULL,
whether or not the slot is nullable. The engine holds no copy of the
target to inline. [RFCS.23.7] says how a receiver reads it.
Nesting is at most 16 deep. The top-level fact is at depth 0 and a fact
inlined in a slot of a fact at depth d is at depth d + 1; no inlined fact
may be deeper than 16. A receiving engine must refuse a deeper FactExternal
whole, as malformed (DS_ERR_PARSE, [NCBK.10.4]). An engine writes a fact
whose references chain deeper as it is, and no receiver accepts it.
ratified — see also: LGRA.5.7a.2, NCBK.10.4, RFCS.23.7
[RFCS.23.5] asserted_at, and no event_id. A FactExternal carries
no event_id: an event_id identifies a fact only within the engine that
stamped it ([LFST.5.6]). A fact that must be recognised on another tier
carries an identifier of the author's in one of its slots ([LFST.7.2.4]).
asserted_at is the instant the fact entered working memory, as the engine
clock read it: a UTC instant, in nanoseconds since the Unix epoch, the value
now() would have given at that moment. A fact a rule publishes enters no working
memory on its way out ([LTIE.4.3]), so its asserted_at is the instant of the
publish. If the wall clock had no value at that
moment ([LTIM.2.8.3]), asserted_at is absent: has_asserted_at is false, and
the fact leaves the engine without an instant. It reproduces on replay, because the engine clock is a recorded
input, and migration keeps it. It describes the fact, not the write: a fact
stored later carries the time it was asserted.
ratified — see also: LFST.5.6, LFST.7.2.4, LTIE.4.3, LTIM.2.8.3
[RFCS.23.6] The receiving engine decides a fact's lifetime. A FactExternal
carries none. The receiving engine applies its own schema's lifecycle, so a tier's lifetimes are
decided by its own program and reproduce on replay. A per-emit TTL override
([LDTL.4.1]) is local to the engine that emitted the fact; an author who needs a
lifetime to cross a boundary puts it in a slot.
ratified — see also: LDTL.4.1
[RFCS.23.7] Receiving a fact. An engine asserting a FactExternal checks
its schema_hash ([RFCS.23.3]), decodes it, asserts it, and resolves each
nested fact-reference, innermost first:
a live fact of that schema equal to the inlined copy is the same fact, and the slot refers to it: nothing is asserted for the copy, and the fact keeps its
event_id. Of several equal live facts, it is the one with the lowestfact_id([RFCS.6.9]). With no equal live fact, an earlier inlined copy in the sameFactExternalequal to this one is the same fact, and the slot refers to what that copy resolved to;otherwise, if no live fact of that schema has the same identity key, the inlined copy is asserted and the slot refers to it;
otherwise — a live fact with that key whose values differ — the engine must refuse the whole
FactExternal: nothing is asserted and nothing is replaced.
Equal is the no-op reassertion's comparison ([LFAC.2.5.1], [LFAC.2.5.4]),
slot by slot over the inlined copy's slots, and a fact-reference slot is equal
when it resolves to the same fact. Resolving innermost first is what lets an
outer copy compare equal: its references are already resolved to live facts.
On a logical schema ts is left out, as the no-op test leaves it out
([LFAC.9.1]). On any other schema it is compared like any slot, so a copy that
differs from a live fact only in ts is another fact.
KIND_NULL in a fact-reference slot is a reference with no target
([RFCS.23.4]). The engine must admit it whether or not the slot is nullable, and
resolves and asserts nothing for it. In a nullable slot it is null. In any other
fact-reference slot the slot refers to no fact, and a read of it finds the target
gone ([NFCT.2.3]). It is equal to a live fact's slot that is null or whose target
has gone, so a live fact holding such a reference is the same fact as its own
copy, and a replay resolves it as the live run did ([RFCS.24.2]).
A reference is resolved once, before anything is asserted. Steps 1 to 3 judge every reference on working memory as the call finds it, and the engine must not judge one again during the delivery. One of the delivery's own asserts can remove a fact a reference resolved to, whether that fact was live or is an inlined copy the delivery asserted: an answer's supersede ([LCRS.6.2.4]) retracts it, or a retraction that supersede cascades into does. That refuses nothing and stops nothing. The slot refers to that fact, and a read of the slot finds the target gone ([NFCT.2.3]). No rule runs inside a delivery, so no rule can tell this from a target that left after it. The engine must do this without reading a removed fact's storage ([RDSC.9.9]).
Every fact asserted here, the received fact and each inlined copy, gets this
engine's own event_id, as any assert does ([LFST.5.6]). The received fact
itself is an ordinary assert: a live fact equal to it makes it a no-op
reassertion ([LFAC.2.5.1]).
One FactExternal is one input, however many facts receiving it asserts.
The engine must sample its clocks once for it ([LTIM.2.8.4]), and every fact
it asserts, each inlined copy and the received fact, takes that sample as its
assertion time ([RFCS.23.5]).
The entry point and its result codes are the integration's ([NCBK.10]).
ratified — see also: LCRS.6.2.4, LFAC.2.5.1, LFAC.2.5.4, LFAC.9.1, LFST.5.6, LTIM.2.8.4, NCBK.10, NFCT.2.3, RDSC.9.9, RFCS.23.3, RFCS.23.4, RFCS.23.5, RFCS.24.2, RFCS.6.9
[RFCS.23.8] Stored records across releases. A stored FactExternal is
read unchanged within a release series ([LDET.1.10]). A release whose
FactExternal encoding or Kind set differs from the previous series' must ship
a migration that rewrites records of the previous series into its own; a
release that changes neither ships none. Migration keeps asserted_at, and
recomputes schema_hash for the schema it migrates to.
The store keeps each record opaque and never reads inside it ([LSTO.2.1]).
Deferred: not binding in this edition.
Inputs that carry a fact reference — the ExternalAssert atom [RFCS.24]#
[RFCS.24.1] A host input whose fact holds a fact reference is recorded as an
ExternalAssert (proto/external_assert.proto#ExternalAssert), not as a
FactAssert. A fact body carries a reference as the handle of a fact recorded
earlier in the same stream ([RFCS.6.3]). A host input's reference need not name
one: a FactExternal may carry a fact from another engine, which this stream
never recorded. So the input is recorded as the FactExternal, with each
referenced fact inlined ([RFCS.23.4]), and a replay resolves each reference as
the live run did ([RFCS.24.2]). Every host input that holds a reference takes
this one form, whether or not the facts it names were recorded.
The recorder must write one ExternalAssert for each such input, whichever
entry point delivered it:
an
assert_external([NCBK.10.4]) whoseFactExternalholds a reference: theFactExternalexactly as the host passed it;a direct host assert whose fact holds a non-null fact-reference slot: the fact written as a
FactExternal([RFCS.23.4]), each referenced live fact inlined.
Every other host assert stays a FactAssert. The atom is written on arrival,
before anything the input causes, like every input ([RFCS.6.7]).
The input is one step ([RFCS.23.7]): its clock_ns is the one clock sample the
engine took for it, and every fact the delivery asserts carries that sample.
A delivery refused whole is not recorded ([NCBK.10.4]). Examples are a
FactExternal nested too deep, one naming a schema the program does not declare
or carrying another schema_hash, one whose reference conflicts with a live
fact's key ([RFCS.23.7]), and one holding a value over its slot's capacity.
The refusal is the entry point's status ([NCBK.10.4]). The engine
records nothing for it, and nothing of it reaches working memory or the stream:
it is a host call that delivered no input, the case [RFCS.6.7] records nothing
for. So every ExternalAssert in a stream is one the engine admitted.
Container-legality stream, stream-class inject (field 5).
ratified — defined in: proto/external_assert.proto#ExternalAssert — see also: NCBK.10.4, RFCS.23.4, RFCS.23.7, RFCS.24.2, RFCS.6.3, RFCS.6.7
[RFCS.24.2] Replay delivers the input through the receiving rules. A
replayer meeting an ExternalAssert must assert its fact as [RFCS.23.7]
receives a FactExternal, apply ttl_ns to the received fact as
[RFCS.6.2] applies a FactAssert's, and bind the handles in fact_ids, in
order, to the facts that delivery asserts.
Replay starts each input from the working memory the original run had at that point ([LFST.9.2.1]). So [RFCS.23.7]'s first rule, that a live fact equal to an inlined copy is the same fact, resolves every reference to the fact it named when recorded, whether that fact was an input or derived.
A recorded ExternalAssert was admitted when it was recorded ([RFCS.24.1]). So
a delivery that refuses, or that asserts a different number of facts than
fact_ids lists, is a replay that has not reproduced the run. The replayer must
stop with DS_ERR_FS_DIVERGENCE.
A halt that stops a delivery part-way ([NCBK.10.4]) is no refusal. fact_ids
lists the facts asserted before the delivery stopped, and a replay that stops at
the same fact has re-derived the recorded run's halt: the replayer must treat
it as an outcome ([RFCS.6.7]). A delivery a failed allocation stopped is not a
function of its input, so a replay that does not meet the failure asserts more
facts than fact_ids lists, and diverges.
ratified — see also: LFST.9.2.1, NCBK.10.4, RFCS.23.7, RFCS.24.1, RFCS.6.2, RFCS.6.7
[RFCS.24.3] fact_ids lists the facts the input asserted, in [RFCS.23.7]'s
order. Each inlined copy the delivery asserted comes first, innermost first,
then the received fact. A copy that resolved to a live fact asserted nothing and
contributes no handle. A received fact that was a no-op reassertion
([RFCS.6.7]) contributes the handle a FactAssert for the same input would
carry. A later
FactRetract of any of these facts echoes its handle, as for a FactAssert
([RFCS.6.2]).
Each fact the delivery asserts is its own stream event. The engine must
emit one FactAssert event for each fact in fact_ids, in that order, and
each takes the next seq ([LFST.5.3]). Each fact's event_id derives from its
own event's seq ([LFST.5.6]), so no two facts of one delivery share one. The
ExternalAssert carries the seq of the first of these events. The others are
recorded by no atom of their own, as every stream event of a kind the recording
does not carry is. A replayer delivering the atom emits the same events in the
same order, so every seq and event_id reproduces.
ratified — see also: LFST.5.3, LFST.5.6, RFCS.23.7, RFCS.6.2, RFCS.6.7
Annotation — the TextNote atom [RFCS.25]#
Deferred: not binding in this edition.
[RFCS.25.1] A TextNote carries one clear-text annotation, and its body is
defined in proto/stream_header.proto#TextNote. A Stream may carry any number
of them. The atom is structural ([RFCS.3.4]): it is never a replay input, and a replayer steps over it.
tagnames the kind of text. A writer must write exactly 16 bytes, padded on the right with NUL bytes, and a reader must refuse aTextNotewhosetaghas any other length (DS_ERR_PARSE).textis the annotation. A writer should write UTF-8. A reader must not interpret it, and decodes it identically whether or not it is valid UTF-8.
defined in: proto/stream_header.proto#TextNote — see also: RFCS.3.4
Cache seeds — the CacheSeed atom [RFCS.26]#
[RFCS.26.1] The prelude carries the host's cache seeds. A host seed ([NLFC.9.1]) changes what cached() reads and emits no
stream event, so the recorder must write each as an atom of its own, a
CacheSeed (proto/cache_seed.proto#CacheSeed). It writes them immediately
after the schema announcement ([RFCS.5.1]) and before any event atom: one for
each key the host seeded that the cache holds when the StreamHeader is
written, in ascending order of the key's UTF-8 bytes. Each carries:
key, the key;value_json, the value as the cache holds it, its canonical JSON text ([IARC.12.2]);deadline_ns, the entry's deadline as the cache holds it, in engine-clock nanoseconds, or0where the entry does not expire. A seed's TTL is never recorded: the deadline is what the cache keeps. The engine fixes it at its first sample, before it records that sample ([NLFC.9.4]), so the header written at that event carries it.
Seeding ends at the engine's first stream event ([NLFC.9.2]), and the encoder writes the header when it encodes that event ([RFCS.5.1]), so the prelude holds every seed of the run. Where the host seeded a key twice, the atom carries the entry the second seed left.
No other cache entry has an atom:
a seed the engine refused stored nothing ([LSTO.4.7.5]);
an
initialblock's cache items are not host seeds: the artefact carries them, and a replay applies them at its first step as the run did ([LGRA.24.3]);a recorder attached after the engine's first stream event writes no
CacheSeed, because by then the cache holds what rules wrote, which no seed describes.
Container-legality stream, stream-class inject (field 6).
A CacheSeed is no stream event and carries no seq ([LFST.5.3]).
ratified — defined in: proto/cache_seed.proto#CacheSeed — see also: IARC.12.2, LFST.5.3, LGRA.24.3, LSTO.4.7.5, NLFC.9.1, NLFC.9.2, NLFC.9.4, RFCS.5.1
[RFCS.26.2] The replayer applies the seeds before the first input. A
replayer must apply each CacheSeed to the engine, in stream order, before the
replay's first stream event. It seeds key with the value value_json holds
and with the recorded deadline, as a host seed writes the cache
([IARC.12.1]): it raises no cache event and calls no write-through. The replay
clock follows the recorded clock values ([LFST.9.2.1]), so an entry expires
where it did in the run.
A seed the replayer applies is a host seed for [RFCS.26.1] and for [NLFC.9.3]:
a recording of the replay carries the same CacheSeed atoms, and the initial
block's cache item for the same key leaves it in place, as in the run. The integrator must not seed an
engine it replays into: the stream carries that engine's seeds, and one more
would start the replay from a cache the run did not have.
A recorded CacheSeed was stored when it was recorded. So an engine that
refuses one, as a cache bound the recording engine did not have refuses it
([LSTO.4.7.5]), and a CacheSeed after an event atom, which no recorder
writes, are a replay that has not reproduced the run. The replayer must stop
with DS_ERR_FS_DIVERGENCE.
ratified — see also: IARC.12.1, LFST.9.2.1, LSTO.4.7.5, NLFC.9.3, RFCS.26.1