Event trace#
The canonical form for recording, replaying, and simulating DS sessions. The event trace is the single artefact through which DS's determinism, testability, and debuggability guarantees are realised.
The conformance surface is the typed in-memory event sequence every conforming runtime delivers through its stream callback. Every event has the same envelope shape (seq + clock_ns + source + event_id + kind-discriminated payload). On-disk capture format is integrator territory: the integrator picks how the typed events get to bytes (protobuf, JSON-lines, CBOR, bespoke, nothing-at-all). The content the integrator records is fixed; the encoding is their choice.
What this is not#
Not a wire protocol for adapter ↔ engine traffic at runtime. Adapter ingest is integrator-driven; the event trace is what the engine emits for observable events after they enter or leave it.
Not an on-disk encoding spec. The runtime delivers a typed event sequence to the integrator's callback; recording format (protobuf, JSON, custom, none) is the integrator's choice. A protobuf schema is provided as an interoperability reference (see [LFST.2]) but is not normative.
Not a metrics / telemetry surface. See §Out of stream scope.
Not a debugger protocol — debugger bridges layer on top of the existing stream callback.
Not prescriptive about how recordings are stored, rotated, compressed, or archived — operational choices.
The determinism backstop [LFST.1]#
[LFST.1.1] DS's determinism guarantee ([LDET.1.1]) is over a fixed event trace. The trace is both the engine's input and the record of its output, and replay needs both halves: the recorded inputs drive the engine, and the recorded outputs are what the replay compares against ([LFST.9.3]).
An event the engine does not emit is reproducible by nothing. Emitting completely is therefore the engine's obligation and not the integrator's ([LFST.12.7]).
see also: LDET.1.1, LFST.12.7, LFST.9.3
[LFST.1.3] The engine must emit completely, and the obligation is unconditional. The engine must emit, through the callback surface ([NCBK.2.1]), every event of every class: an inject-class event for every input it consumed, a compare-class event for every observable it produced, and every clock value it observed ([RFCS.17.1]). The engine must emit whether or not a subscriber is registered, and must not let anything downstream of an event decide whether that event is emitted.
An integrator may subscribe to all, some or none of that surface, and may record or discard what it receives. Neither choice is a conformance question, and neither is the engine's to constrain.
An integrator that records the whole surface therefore holds a replayable event trace by construction, having done nothing further. Replayability is not a recording discipline the integrator must follow; it is a guarantee the engine owes. A trace is unreplayable only where a subscriber filtered ([LFST.9.2.1]).
All or nothing, never selectively. An engine with no stream surface at all
— a constspace target, or a realtime one configured without one — emits
nothing and produces no trace, which is a coherent state. What the engine must
not do is emit some kinds and withhold others: a trace missing one kind reads
as complete and is not, and nothing in it says otherwise.
The recording hook sits at step (1) of the consumption loop — on arrival, before evaluation ([RARC.5.8.10]) — precisely so that what an event did downstream cannot decide whether it was emitted. [RFCS.6.7] reasons to this conclusion for one atom; it holds for all of them.
see also: LFST.9.2.1, NCBK.2.1, RARC.5.8.10, RFCS.17.1, RFCS.6.7
[LFST.12.7] The engine must emit every observable event kind. No kind is optional, and no deployment, capability or configuration leaves one kind unemitted while the others are emitted ([LFST.1.3]).
see also: LFST.1.3
[LFST.12.8] The engine must not sample within a kind. A 1-in-N selection of one kind's events yields a trace that is not replayable and that carries nothing announcing itself as such ([LFST.1.3]).
see also: LFST.1.3
[LFST.1.2] This doc specifies the format the stream takes.
Encoding: integrator's choice (with reference schema) [LFST.2]#
[LFST.2.1] The runtime delivers events as typed in-memory values through the registered stream callback. The encoding the integrator uses to capture those values to disk, send them across processes, or feed them into a replay engine is the integrator's choice. The spec commits to the content — the envelope fields, the event-kind taxonomy, the sequencing invariants — not to a wire format.
ratified
[LFST.2.2] An interoperability reference protobuf schema ships alongside this doc. Integrators wanting interoperability with off-the-shelf DS tooling (replayers, debuggers, conformance runners) capture to that schema. Integrators with bespoke pipelines (JSON-lines for a log-aggregator, CBOR for embedded, internal control-plane messages, in-process queues) encode however suits them. Determinism is preserved across encodings as long as the encoding is a faithful round-trip of the typed event content.
ratified
[LFST.2.3] Deterministic on-disk equality is an integrator-side property of the chosen encoding. Two integrators using the same encoding on the same platform produce byte-identical files; two integrators using different encodings of the same event sequence produce different bytes that nevertheless round-trip to the same typed events. The conformance check is the round-trip property, not byte equality across pipelines.
Stream organisation [LFST.3]#
[LFST.3.1] A stream is a sequence:
[StreamHeader]
[StreamEvent 0]
[StreamEvent 1]
...
[StreamEvent N]
ratified
[LFST.3.2] The first item is always the header. Every subsequent item is one event. Storage layout (single file, rotated files, journaling, in-memory ring) is the integrator's choice; the conformance surface is "the sequence in seq order".
[LFST.3.3] Streaming readers see events in seq order as they arrive at whatever transport the integrator runs.
Stream header [LFST.4]#
[LFST.4.1] Every event trace opens with a header,
proto/stream_header.proto#StreamHeader ([RFCS.4.2]). It records what the trace
was made against and by whom: the DS version that wrote it ([LFST.4.3]), the run
and tier identifiers ([LFST.4.4], [LFST.4.5]), the dialect binding
([LFST.4.6]), the compiled rule set's hash ([LFST.4.7]), the realtime contract's
hash ([RBND.1.4]) and the wall-clock instant the trace opened ([RFCS.4.8]). What a
reader requires of the header, and what it refuses, is [RFCS.4.7].
ratified — see also: LFST.4.3, LFST.4.4, LFST.4.5, LFST.4.6, LFST.4.7, RBND.1.4, RFCS.4.2, RFCS.4.7, RFCS.4.8
[LFST.4.2] Field notes:
[LFST.4.3]
ds_versionis the DS version that wrote the trace, and the only version it carries. A reader accepts a trace whoseds_versionbegins with its own<major>.<minor>.and refuses every other ([LDET.1.10]).
ratified — see also: LDET.1.10
[LFST.4.4]
session_idis the run identifier the integrator gave the engine ([NLFC.1.2]), or empty if it gave none; the engine generates no identifier of its own. An integrator running several tiers gives them one run identifier, and one that restarts a single tier gives each run its own, if it wants the recordings told apart.
ratified — see also: NLFC.1.2
[LFST.4.5]
tier_ididentifies which tier produced this stream. Integrator-defined; opaque to the format. A single-tier deployment uses whatever string the integrator picked.
[LFST.4.6] The dialect binding is
capabilitiesanddialect_def_sha256, copied from the compiled rule set's ([RBND.1.3]). A reader holding the rule set compares them with its own ([RFCS.4.5]).
[LFST.4.7]
dsc_hashis the compiled rule set'sdsc_sha256([RDSC.3.6]). Replay and deep inspection need the rule set; tools find it by this hash, and a reader holding it checks the two agree ([RFCS.4.5]).
ratified — see also: RDSC.3.6, RFCS.4.5
[LFST.4.10] A trace starts at its first atom's
clock_ns([RFCS.6.6]). Every later event'sclock_nsis at or after it, because the engine's monotonic clock never moves back ([LTIM.2.8.2]).wall_start_iso8601anchors the start to calendar time ([RFCS.4.8]).
ratified — see also: LTIM.2.8.2, RFCS.4.8, RFCS.6.6
Per-event envelope [LFST.5]#
[LFST.5.1] Every event carries its seq ([LFST.5.3]), its clock_ns
([LFST.5.4]), its kind and that kind's payload ([NCBK.2.2]). The kind is one of
proto/stream_event_kind.proto#StreamEventKind's, and [NCBK.2.3] says when the
engine emits each. A fact the engine asserts carries its event_id
([LFST.5.6]).
A cache read is not an event. It is a pure internal read of the engine's cache, re-derived on replay from the writes before it, which the replayed rules make again ([LFST.9.2]).
ratified — see also: LFST.5.3, LFST.5.4, LFST.5.6, LFST.9.2, NCBK.2.2, NCBK.2.3
[LFST.5.2] Envelope fields:
[LFST.5.3]
seq— per-stream monotonic, gap-free, and0for the stream's first event. Assigned by the tier's engine at the moment of consumption. The canonical total order of the stream.
ratified
[LFST.5.4]
clock_ns— the engine's monotonic clock ([LTIM.2.8.2]), not the wall clock, in nanoseconds. Informational relative toseq; two events can shareclock_nsand differ inseq.
ratified — see also: LTIM.2.8.2
[LFST.5.6]
event_id— a deterministic UUID stamped on everyFactAssert, derived from the run identifier and the tier identifier the integrator gave the engine ([NLFC.1.2]), either of which may be absent, and theFactAssert'sseq. All three are replay-reproducible, soevent_idreproduces on replay ([RARC.5.8.8]). The fact keeps thatevent_idfor as long as it is in working memory. What the two identifiers mean, and whether they are unique, is the integrator's; with neither given,seqalone distinguishes oneevent_idfrom another.An
event_idmeans nothing outside the engine that stamped it. It identifies a fact within that engine's stream and the stream's replay. A fact that arrives from another tier is a newFactAsserton the receiving engine and gets that engine's ownevent_id; an engine must not take anevent_idfrom outside, and noevent_idcorrelates two streams. A program that must recognise one fact on two tiers gives the fact an identifier of its own, in a slot the author fills and maintains ([LFST.7.2.4]).
ratified — checks: alloy×10 — see also: LFST.7.2.4, NLFC.1.2, RARC.5.8.8
[LFST.5.7] The kinds are a closed set, and allocation is append-only: a
new kind takes a number StreamEventKind has never held, and a number out
of use stays reserved ([STYL.2.8.7]).
Event kinds [LFST.6]#
Inputs from outside the engine [LFST.6.1]#
[LFST.6.1.1] Inputs are what the engine consumes from outside it: a fact
the host asserts or retracts, among them a fact another tier published and a
call's response fact or CallError ([LCRS.4.2.2]); a fact delivered with the
facts it refers to ([RFCS.24]); and a sample of the engine's two clocks
([LTIM.2.8.5]). Each is an inject-class atom on the trace ([RFCS.3.1],
[RFCS.3.4]). Delivering them in seq order to an engine configured as the
recording one was reproduces the session ([LFST.9.2.1]).
ratified — see also: LCRS.4.2.2, LFST.9.2.1, LTIM.2.8.5, RFCS.24, RFCS.3.1, RFCS.3.4
Engine internals (observable, deterministic from inputs) [LFST.6.2]#
[LFST.6.2.1] Engine internals are what the engine does in response to its inputs: a rule's firing and the facts it matched, a fact the engine emits or withdraws with its cause ([RFCS.7a.2]), a fault ([LERR.1]) and a pump boundary ([RFCS.22]). They are recorded for verification, observability and debugging. On the trace each is a compare-class atom: a replayer re-derives it and compares it, and never delivers it to the engine ([RFCS.3.4]).
$ClockTick is the engine's own re-driver for time-dependent conditions
([LTIM.2.4.2]). It is working-memory machinery, not an author construct, and the
trace records the clock samples that drive it ([LTIM.2.8.5]) rather than the
tick.
see also: LERR.1, LTIM.2.4.2, LTIM.2.8.5, RFCS.22, RFCS.3.4, RFCS.7a.2
Engine-initiated externalizable actions [LFST.6.3]#
[LFST.6.3.1] Actions are what the engine sends toward external systems: a
call ([RFCS.15]), a cache write or delete, a publish across tiers and a log
line. On replay none is re-executed externally: no real adapter call, cache
write or publish happens. The replaying engine produces the same events, and the
replayer compares them with the recorded ones; a divergence is a determinism
failure ([LFST.9.3]). A CallIssued carries the service, the typed arguments
([RFCS.15.2]), the correlation ([LCRS.3.1]) and the firing's identity. Which
actions a trace records is [RFCS.15.7].
ratified — see also: LCRS.3.1, LFST.9.3, RFCS.15, RFCS.15.2, RFCS.15.7
[LFST.6.3.2] An outbound call is recorded as a CallIssued atom ([RFCS.15]),
and the engine emits one for every call it issues ([RFCS.15.6]). As an
engine-initiated action it is compare class: re-derived and byte-compared
on replay, never delivered to the engine as an input ([RFCS.3.4]). Recorded
provenance for the other verbs is deferred ([RFCS.15.7]).
ratified — see also: RFCS.15, RFCS.15.6, RFCS.15.7, RFCS.3.4
Sequencing [LFST.7]#
Single-writer-per-stream [LFST.7.1]#
checks: tla×11
[LFST.7.1.1] Each tier's engine is the single writer for its own stream.
All events — local rule activations, cross-tier fact
arrivals, adapter responses, cache ops, engine errors — pass
through the engine's consumption loop before being
recorded. seq is assigned at consumption in the order the
engine processes events.
ratified — checks: tla×3
[LFST.7.1.2] The engine is the determinism choke point. If the consumption loop is deterministic (single-threaded, or strictly serialising parallel work before recording), then replay is deterministic by construction. If the consumption loop is non-deterministic, replay is broken. This architectural constraint is load-bearing for DS's determinism guarantee.
[LFST.7.1.3] Multi-tier deployments record one stream per tier, each
with its own seq starting at 0.
ratified
Cross-tier correlation [LFST.7.2]#
[LFST.7.2.1] A cross-tier event appears in both the sender's stream and the receiver's stream:
[LFST.7.2.2] Sender's stream:
Publishevent with the sender'sseqand anevent_id.
[LFST.7.2.3] Receiver's stream:
FactAssertevent with the receiver'sseq, the receiving-tier-assigned clock_ns, and the receiver's ownevent_id([LFST.5.6]).
see also: LFST.5.6
[LFST.7.2.4] The engine supplies no key that joins two streams. Tools
reconstructing whole-session behaviour align them by values the facts carry:
an author who needs a published fact recognised on both tiers declares an
identifying slot on its schema and fills it on the sending tier, and the value
crosses with the fact. An event_id is no such key ([LFST.5.6]). The
per-stream total order remains seq-only.
see also: LFST.5.6
Simultaneous events within a source [LFST.7.3]#
[LFST.7.3.1] If two events arrive at the engine at the same logical
moment (same syscall batch, same cycle), the seq order is
the engine's consumption order. The engine's consumption
order is determined by:
[LFST.7.3.2] Source-system order (for adapter-originated events: the order they arrived on the wire).
[LFST.7.3.3] Rule-RHS order (for rule-fired actions: the order the rule's RHS executed them).
ratified
[LFST.7.3.4] Spec-defined rule-firing order within a cycle (per [LDET]: the terminal ordinal, which is source order, then activation-creation order within one rule).
ratified
[LFST.7.3.5] The engine records the order it processed events; there's no separate tie-break machinery.
[LFST.7.3.6] When consuming one input event (a host fact assert or retract,
or an adapter event) triggers downstream truth-maintenance effects
(justification withdrawal → logical-fact retract, or re-justification → assert),
the engine must assign the input event's own stream record a seq before the
records of the effects it causes ([RFCS.6.7]). An engine withdrawal is ordered
the same way, before the withdrawals it cascades into ([RFCS.7a.4]). For these
a reader never observes a cascade fact_retract/fact_assert earlier in seq
than the event that caused it: the triggering event is consumed before its
consequences are processed, the causal reading of [LFST.7.3.1] (seq =
consumption order). It is the event-trace corollary of the justification-linkage
principle ([LLOG.15]).
A rule's assert is not ordered so. Each RHS action is propagated before it is
recorded, so a retraction an emit causes is recorded ahead of
that action ([RARC.5.6.8]).
ratified — see also: LFST.7.3.1, LLOG.15, RARC.5.6.8, RFCS.6.7, RFCS.7a.4
[LFST.7.3.7] [LFST.7.3.6] orders an event against the cascade it causes within the same cycle. It does not reorder independent events across sources ([LFST.7.3.2]–[LFST.7.3.4] still decide those); it constrains only the cause→effect pair.
see also: LFST.7.3.2, LFST.7.3.4, LFST.7.3.6
Parallelism [LFST.7.4]#
[LFST.7.4.1] A runtime may process parallel work across multiple
workers, but seq assignment must be strictly
serialised. Either the consumption loop is
single-threaded, or parallel workers complete their work
and their effects are merged through a single serialiser
before being assigned seq. Per [LDET]: the output must be indistinguishable from
sequential firing.
checks: tla
No site-wide total order [LFST.7.5]#
[LFST.7.5.1] The spec commits to per-stream total ordering via
seq. It does not commit to a site-wide total order across streams
from different tiers, nor to a key that correlates them ([LFST.7.2.4]).
see also: LFST.7.2.4
[LFST.7.5.2] Two events happening at the "same wall-clock instant"
in two different tiers — say two CacheSets produced
by different tiers — have no spec-defined relative
order beyond what falls out of per-stream seq plus
each event's clock_ns. Tools reconstructing a whole-
site view merge streams and apply whichever
reconciliation suits them (wall-clock on clock_ns,
causal via values the facts carry ([LFST.7.2.4]), or both).
see also: LFST.7.2.4
[LFST.7.5.3] The commitment to single-writer-per-stream ([LFST.7.5.1]) delivers:
see also: LFST.7.5.1
[LFST.7.5.4] Within-tier replay — per-stream
seqis a total order; replay on any one tier is byte-for-byte deterministic.
[LFST.7.5.5] Cross-tier causal inspection — an identifying slot the author gives a published fact ([LFST.7.2.4]) lets tools match a
Publishin the sender's stream to the resultingFactAssertin the receiver's, and walk causality without needing a global order.
see also: LFST.7.2.4
[LFST.7.5.6] Multi-tier debugging — the
session_idin each stream header correlates the tiers; the debugger or replay tool presents whatever reconciled view the operator requests.
[LFST.7.5.7] v1 commits to per-stream total order; there is no site-wide total order, no global sequencer and no engine-supplied key across streams.
Concurrent-writer cache-plane edge case [LFST.7.6]#
[LFST.7.6.1] This scenario does not arise: the cache is per-engine engine state ([LSTO.4.7]), not a store shared across tiers. Cross-tier cache influence reaches a lower engine as a recorded input (a trace / inbox write, [LSTO.4.7.3] / [LTIE.5]), so there are no concurrent writers to one shared key and no storage-backend-observed order to depend on. The determinism below is therefore structural, not a property of a storage adapter.
see also: LSTO.4.7, LSTO.4.7.3, LTIE.5
[LFST.7.6.2] What the DS spec commits to:
[LFST.7.6.3] Each tier's cache write is an
action_cache_setevent on its own stream with its ownseq. No recording carries it ([RFCS.3.6]).
see also: RFCS.3.6
[LFST.7.6.4] A subsequent
CacheGetis not recorded — it is a pure internal read of the engine's own cache, re-derived on replay, where the rules that wrote the cache fire again on the recorded inputs. No store is shared between engines ([LSTO.4.7.3]), so no read has a value from outside the engine to record.
see also: LSTO.4.7.3
[LFST.7.6.5] Replay of a specific tier's stream is therefore deterministic: the engine's cache is a function of its own recorded input stream, so a read re-derives exactly what it observed live, with no dependence on cross-tier write timing.
[LFST.7.6.6] Authors who need write ordering across tiers store
facts through a call to the storage service (total order per
storage adapter) rather than cache (last-write-
wins semantics).
Inspection without the rule artefact [LFST.8]#
[LFST.8.1] Some tools can read a stream without access to the compiled rule artefact:
[LFST.8.2] Envelope decoding needs only the envelope .proto (ships with the runtime). Tools can extract
seq,clock_ns,event_id, and the oneof tag (event kind) — from the first byte, before any schema has been announced. This is the floor a reader always has, not a ceiling: once the announcements arrive, slot values become readable too ([LFST.8.10]).
ratified — see also: LFST.8.10
[LFST.8.3] Opaque payload bytes are available.
[LFST.8.4] Session metadata from the header is readable (all fields in the header are envelope-like: known .proto, no artefact dependency).
[LFST.8.5] This is enough for:
[LFST.8.6] Streaming recording to metrics (event-rate counting).
[LFST.8.7] Identifying which session produced a stream.
[LFST.8.8] Routing to the correct artefact for deep inspection.
[LFST.8.9] Rough filtering by event kind.
[LFST.8.10] Deep payload inspection (schema-typed fact slot values, typed response paths, etc.) requires a description of the schema, and there are two places to get one. They are equally sufficient to decode a payload.
From the artefact. It ships the payload .proto
definitions generated from the rule file's schema
declarations; a tool fetches it by ruleset_hash and
decodes with those.
From the stream itself. Every stream announces each schema — its name, then one entry per slot in declaration order — before the first fact that uses it, and a reader is required to record those announcements as they arrive. A tool may decode from them.
The two agree by construction rather than by luck: a payload's fields are numbered by slot position, so the declaration-ordered announcement determines the same field numbers, names and types the generated definition has. The ordering requirement in the stream format exists for this reason.
Where both are available the artefact is the source. A
disagreement between them means the stream and the artefact
do not belong together, which ruleset_hash should already
have caught.
What a stream does not describe. A schema's lifecycle and
default TTL are in the artefact (proto/schema_logical.proto#SchemaLogical,
proto/schema_ttl.proto#SchemaTtl) and in no stream atom, and a
unit-typed slot is announced, in both, by the kind its unit is
stored as, with no unit. A reader that needs a schema's
lifecycle takes the artefact. A slot's unit appears in neither.
ratified
[LFST.8.11] If the artefact isn't available:
[LFST.8.12] Replayers: still fail cleanly at stream open — ruleset hash X not found; unable to replay. Replay needs the rules, not merely the fact shapes, so reading slot values from the announcements ([LFST.8.10]) does not rescue it. The message should not say the payloads cannot be decoded, because they can; what is missing is everything else.
see also: LFST.8.10
[LFST.8.13] Debuggers: decode slot values from the stream's own schema announcements ([LFST.8.10]). A stream that carries neither an artefact reference nor its announcements is malformed, and a debugger reaching one should say so rather than quietly showing less.
see also: LFST.8.10
[LFST.8.14] Conformance harness: fail (conformance requires full semantic inspection).
Replay semantics [LFST.9]#
[LFST.9.1] A replayer opens a stream, reads the header, checks
compatibility (format_version supported; platform matches
if byte-determinism required; artefact available), then
consumes events in seq order.
ratified
What replay does with each event kind [LFST.9.2]#
Kind class |
Replay action |
|---|---|
Inputs |
Inject into the engine exactly as the original recorded them. |
Engine internals |
Do not drive. The engine produces these itself as it processes the inputs. Compare the replay-produced event to the recorded event; divergence = determinism failure. |
Engine-initiated actions |
Intercept. The engine "produces" these as it fires rules, but they're captured by the replayer and compared against the recorded events. Do not actually execute externally: no real adapter calls, no real cache persistence, no real storage writes. |
[LFST.9.2.1] A replayable event trace. A trace is replayable when it holds every recordable event the engine emitted, as [RFCS.3.6] records it: an inject-class atom for every input the engine consumed, a compare-class atom for every observable [RFCS.3.6] gives an atom, and every clock value it observed ([RFCS.17.1]). Its prelude also carries the host's cache seeds, which are starting state and no event ([RFCS.26.1]). An event of a kind [RFCS.3.6] gives no atom is not in a trace, and its absence does not make the trace unreplayable. A replayable trace is replayed against an engine configured as the recording one was: the trace carries no engine setting, and configuration is a precondition of replay ([LDET.2.7]).
The engine must emit all three, so producing a replayable trace is not a discipline the integrator follows ([LFST.1.3]). An integrator that subscribes to the whole surface and records what it receives holds one by construction. A trace is unreplayable only where a subscriber filtered, and a replayer must refuse such a trace rather than report the absent events as divergences.
Replay drives the engine from the trace's own clock. The replayer applies
each ClockAdvance before the atoms that follow it ([RFCS.10.5]), so every
re-derived atom's clock_ns reproduces. Where the recording engine read that
clock from is immaterial — a wall-clock reading written into a ClockAdvance
is a recorded number like any other. What matters is that the engine recorded
every value it observed, which [RFCS.10.3] requires of it.
Cadence is likewise the recorder's obligation and not the replayer's problem. The replayer fires the engine to quiescence ([RARC.5.6.6]) between the inputs the trace marks as separately pumped, and the trace marks them because the engine emits a pump boundary rather than leaving a reader to infer one.
One fault ends a trace rather than making it unreplayable. A
pump_wcet_ns overrun halts the tier ([RTCT.7.3]), so the EngineError it
emits is the last record on the trace. A replayer drives the trace to that
point, comparing every atom before it, and stops there; the terminal fault is
the recorded run's cause of death, not an observable the replay must reproduce.
That is the only cap of [RTCT.7.1] decided on a measurement rather than on a
count the engine holds, and it is the only place a replay meets a recorded atom
it does not compare.
checks: idris×59 — see also: LDET.2.7, LFST.1.3, RARC.5.6.6, RFCS.10.3, RFCS.10.5, RFCS.17.1, RFCS.26.1, RFCS.3.6, RTCT.7.1, RTCT.7.3
Determinism failure at replay [LFST.9.3]#
[LFST.9.3.1] If replay produces a CallIssued event that differs from
the recorded CallIssued at the same seq, replay fails immediately.
What is compared is the atom KIND and the atom BODY — the whole body,
not a chosen subset of it, and every field byte for byte but a timetag, which
is compared as an identity. [LFST.9.3.6] is the normative home of the field
list and of that pairing, and the list includes clock_ns and seq.
The compare has no exclusion list, and must never acquire one. Every
field of a compared body participates: a timetag that breaks the pairing is the
Divergence. A terminal fault is no exclusion either, because nothing follows it
([LFST.9.2.1]). A field a replay cannot reproduce is
not a reason to narrow the comparison — it is evidence that the replay is
not re-deriving under the recorded conditions, and the conditions must be
brought into line instead.
So every field of a compared body but a timetag, whose value is the engine's
own ([RFCS.11.2]), must be a function of the recorded program, the recorded inputs, and the session identity the replay adopts.
A field that is a function of the replaying process — a fresh id minted at
engine creation, a wall clock, an address — is a defect in what the replay
adopts, wherever it is found.
This clause binds replay ([LFST.9.6]), the operation that re-derives. Inspection ([RFCS.1.2]) re-derives nothing and compares nothing, so no sentence here reaches it.
And it does NOT bind a comparison between two ENGINES. A differential harness that runs two implementations over the same inputs and diffs their output is not replay: neither side is re-deriving a recording under the conditions that recording was made in, which is the situation every sentence above is about.
The test is the remedy this clause prescribes. It forbids narrowing the
compare because the conditions must be brought into line instead — adopt the
recorded session identity, and the divergence disappears at its source. That
remedy exists for a replay, which has one engine and one recording. It does
not exist for a differential, where the divergence can be that the two
implementations emit different event sets and so number seq differently
while every recorded event matches. Nothing can be brought into line there,
because nothing is out of line — the quantity being compared is not the same
quantity.
⚠ A differential must not borrow this clause's authority, and that is the real hazard. A tool that tolerates divergences and reports itself as replay verification reads as a conformance result. Its tolerances are findings about the two implementations, and they belong in its own output where a reader can see them — not inherited from a clause that forbids exactly what the tool does.
Replay fails immediately with:
ratified — see also: LFST.9.2.1, LFST.9.3.6, LFST.9.6, RFCS.1.2, RFCS.11.2
[LFST.9.3.2] The
seqwhere divergence occurred.
[LFST.9.3.3] The recorded event vs the replay-produced event (diff).
[LFST.9.3.4] The engine state at that instant.
[LFST.9.3.5] This is the bit-for-bit determinism check. A passing replay proves the recording faithfully represents the engine's behaviour on this platform at this runtime version.
[LFST.9.3.6] When the outbound call is persisted as a CallIssued atom
([RFCS.15]), replay compares the re-derived call
against the recorded atom rather than an in-memory event. The
byte-compare of [LFST.9.3.1] is strict over every
field the recorded atom carries — service, correlation,
args, clock_ns, seq, rule_name (the
wire-only call_id is absent on the recorded atom, [RFCS.15.2])
— and any difference is the effect Divergence at that seq. The
recomputed call and its recorded atom are diffed once.
A timetag is compared as an identity, not as a value ([RFCS.11.2]).
As the replayer compares atoms in seq order ([LFST.9.3.7]), it pairs each
recorded timetag with the re-derived atom's timetag the first time either
occurs, on any compare-class atom that carries one. Every later atom must
agree with that pairing in both directions: a recorded timetag met with a
second re-derived one, or a re-derived timetag met with a second recorded
one, is the Divergence at that seq. On the engine that recorded the stream,
replay re-derives the recorded values, and the pairing is the identity.
ratified — see also: LFST.9.3.1, LFST.9.3.7, RFCS.11.2, RFCS.15, RFCS.15.2
[LFST.9.3.7] Active compare over both compare-class atoms. The
byte-compare of [LFST.9.3.1] / [LFST.9.3.6] is performed by the replayer, not
merely defined. As replay re-fires the engine at each recorded pump boundary ([LFST.9.2.1],
[RFCS.22]),
each re-derived CallIssued and RuleFireAnnotation atom is captured and byte-compared, in
seq order (a two-pointer merge — both streams are seq-ordered), against the
recorded atom, failing fast with DS_ERR_FS_DIVERGENCE ([NERR.13]) at the
first difference. The structural checks are part of it: a recorded compare
atom with no re-derived twin (missing), a re-derived atom with no recorded twin
(extra), or a kind/order mismatch is the same Divergence — replay fired a
different rule set — a stronger check than the byte-compare alone. RuleFireAnnotation's
identity (timetag, rule_name) ([RFCS.11.2]) is compared too, its timetag by
[LFST.9.3.6]'s pairing; its parity with
the bracketed CallIssued's join key ([RFCS.15.2]) is what resolves a recorded CallIssued
to its firing. DS_ERR_FS_DIVERGENCE is distinct from the EngineDivergence
event (a callback surface); this is the replay compare verdict.
see also: LFST.9.2.1, LFST.9.3.1, LFST.9.3.6, NERR.13, RFCS.11.2, RFCS.15.2, RFCS.22
Replay is one operation [LFST.9.6]#
[LFST.9.6] A replayer re-executes an event trace against the engine: it delivers each inject-class event as a recorded input, re-derives each compare-class event and byte-compares it against the record ([LFST.9.3.1]), and treats each structural event as framing ([RFCS.17.5]).
A replay that meets any divergence has failed, and reports
DS_ERR_FS_DIVERGENCE ([NERR.13]). Whether the replayer stops at the first
divergence or completes the trace and reports every one it met is the caller's
choice and the implementation's latitude; it does not change the verdict. A
replayer that completes the trace must not report success on the strength of
having finished.
Rebuilding working memory by re-applying recorded events, without running the engine, is not a mode of this operation and is not a second one. A tool needing the recorded state without the determinism check either replays and reads the result, or inspects the trace directly ([RFCS.1.2]) — which requires neither an engine nor the compiled program.
see also: LFST.9.3.1, NERR.13, RFCS.1.2, RFCS.17.5
Versioning [LFST.10]#
[LFST.10.4] An event trace carries no version of its own. The only
version a trace records is the DS version that wrote it, and a runtime accepts
a trace whose recorded version begins with its own <major>.<minor>. and
refuses every other ([LDET.1.10]).
A change to what the bytes mean therefore waits for the minor bump, because recordings made earlier in a series must keep replaying identically within it. A new inject-class atom is such a change: an older reader cannot skip it without losing an input it was handed ([RFCS.3.4]).
Unknown event kinds [LFST.10.3]#
[LFST.10.3.1] New event kinds arrive at higher field numbers in the
oneof. Old readers see them as unset oneof:
[LFST.10.3.2] Replayers: refuse to proceed. A replay that silently drops unknown events is non-deterministic.
[LFST.10.3.3] Debuggers / inspection tools: skip with a warning.
[LFST.10.3.4] Conformance harness: refuse. Unknown events mean the runtime under test doesn't implement a feature.
Out of stream scope [LFST.11]#
[LFST.11.1] The stream captures observable engine events. It does not capture:
[LFST.11.2] CPU / memory / thread-scheduling state. Runtime- implementation-defined. Different choices still produce byte-identical streams.
[LFST.11.3] Internal Rete-memory layout. Alpha / beta / agenda internals. Exposable to a debugger on request per [LDEB], but not in the stream.
[LFST.11.4] Performance counters. Latency, memory usage, queue depths. Separate telemetry surface.
[LFST.11.5] Wall-clock timing between events.
clock_nsis engine clock; wall-clock delta is a live-mode property that doesn't replay.
[LFST.11.6] Log-line delivery timing in wall time. A
logaction's content reaches the stream callback as anaction_logevent, which no recording carries ([RFCS.3.6]); when it flushes to an operator's aggregator is in neither.
see also: RFCS.3.6
[LFST.11.7] Hardware-level characteristics. Cache hits, TLB misses, any microarchitectural state.
[LFST.11.8] The compiled rule artefact itself. Referenced by
ruleset_hash; stored separately.
[LFST.11.9] The .proto payload definitions. Travel with the rule artefact; fetched by hash.
[LFST.11.10] Debugger / operator interactions. Pausing, stepping, setting a breakpoint don't add stream events; the resulting engine events (e.g.,
ClockAdvance) do.
[LFST.11.11] Engine startup / shutdown procedures. The stream starts after the header, ends at session end.
[LFST.11.12] Adapter-internal state. An adapter's own reasoning before it sent a response is its business; the stream records what the engine received.
[LFST.11.13] Metric deltas / profiling data. Separate telemetry surface.
[LFST.11.14] User-interactive operator commands. Operational, out-of-band.
[LFST.11.15] Backrefs across events. Each event is self-contained. Tools thread causality using
seqorder and payload content.
Consequence for the recording implementation [LFST.11.16]#
[LFST.11.16.1] The recording hook is narrow: it records exactly what enters or leaves the engine's observable surface. Hot paths don't get burdened with telemetry; they only record events that are already the engine's semantic contract.
Sampling and production volume [LFST.12]#
[LFST.12.1] Streams are gap-free. seq is monotonic and
continuous across all events the stream delivers.
ratified
[LFST.12.2] Operational realities:
[LFST.12.3] Peak event rates of 1,000-10,000 events/sec per tier (per [LSCO] sizing) produce 50KB-500KB/sec of stream (~50 bytes/event protobuf-encoded).
[LFST.12.4] Per-tier recording for a 24/7 deployment: 4GB-40GB/day.
[LFST.12.5] That's the cost of full fidelity. Testing and debugging pay for it because byte-for-byte determinism demands it.
Hot reload and session boundaries [LFST.13]#
[LFST.13.1] Hot reload is not an open question: [LSCO.7.6] makes policy reloadability load-bearing. What v1 defers is reload mid-session ([LFST.13.6]). Event-trace assumption for v1:
[LFST.13.2] A hot reload ends the current session and starts a new one.
[LFST.13.3] The new session has a new
ruleset_hash(reflecting the reloaded rules).
[LFST.13.4] The
session_idmay be retained or rotated at operator discretion.
[LFST.13.5] Cross-session continuity is a tooling concern, not a format concern.
[LFST.13.6] One session holds one ruleset. A stream shows a reload as a session boundary ([LFST.13.2]).
see also: LFST.13.2
Stream-format commitments [LFST.14]#
[LFST.14.3] Compression is at rest. Streams compress well (repeated schema names, similar payload shapes), and whether to compress is an operational choice, not a format choice: the format is uncompressed, and operators compress at rest.
[LFST.14.4] Replay is scoped to the minor series. A runtime reads a trace whose recorded DS version begins with its own
<major>.<minor>.and refuses every other ([LDET.1.10]). Replaying an older recording requires the release that wrote it.
see also: LDET.1.10
[LFST.14.5] Multi-writer fault. A recording subsystem that crashes mid-write leaves the stream truncated, possibly mid-message. Reader discipline: on a partial final message, stop reading and flag the stream as truncated. Conformance requires full (not truncated) streams.