proto/fact_external.proto#
Normative. proto/** is part of specs/ ([STYL.2.14.1]); message names, field numbers, types and reserved ranges carry the same force as a clause of English ([STYL.2.14.2]). Cite this file as proto/fact_external.proto and a message within it as proto/fact_external.proto#<Message> ([STYL.2.14.3]). This page is the protobuf source, rendered.
/* SPDX-FileCopyrightText: 2026 Dan Finster and the Desert Sage Contributors */
/* SPDX-License-Identifier: BSD-4-Clause OR AGPL-3.0-or-later */
syntax = "proto3";
package ds.v1;
import "slot.proto"; // SlotKind, for SlotShape.temporal_kind
// The portable typed-value encoding. A call's arguments ([RFCS.15.2]) and a
// fact that leaves the engine ([RFCS.23]) are both written as `Arg`s, so one
// encoder and one decoder serve both.
//
// Kind, Arg and FactExternal are in one file because Arg and FactExternal
// refer to each other: a fact-reference slot and a fact argument both carry a
// nested FactExternal.
Kind#
// Every value kind, in ONE number space ([RFCS.23.2]). A slot value admits the
// common kinds and KIND_FACT_REF; a call argument admits the common kinds and
// KIND_ENCODED_FACT. In this edition a call argument never carries KIND_NULL
// ([LNUL.11.1]). A number that belongs to one subtype is reserved in the
// other ([STYL.2.8.7]). The common numbers are the slot kinds' existing ones.
// A Time, Date or Duration value is KIND_INT: a Kind is how a value is
// represented, not the type it was declared with.
enum Kind {
KIND_INT = 0;
KIND_FLOAT = 1;
KIND_STRING = 2;
KIND_BOOL = 3;
KIND_JSON = 4;
KIND_FACT_REF = 5; // slot values only
KIND_BYTES = 6;
KIND_NULL = 7;
KIND_ENCODED_FACT = 8; // call arguments only
}
Arg#
// One named, typed value. The `value` member that `kind` names is set, and no
// other; KIND_NULL sets none.
message Arg {
string name = 1;
Kind kind = 2;
oneof value {
int64 int_value = 3;
double float_value = 4;
string string_value = 5;
bool bool_value = 6;
string json_value = 7; // the JSON text of [LGRA.5.8.7a]
bytes bytes_value = 8;
FactExternal fact = 9; // KIND_FACT_REF and KIND_ENCODED_FACT
}
}
FactExternal#
// A fact that leaves the engine ([RFCS.23]): stored by record_fact,
// published to another tier, or passed as a call argument. It decodes without
// the program that wrote it.
message FactExternal {
string schema = 1; // the schema's name
bytes schema_hash = 2; // SHA-256 of the schema's SchemaShape ([RFCS.23.3])
repeated Arg fields = 3; // one per slot, in the writing schema's declaration order
// No event_id: it means nothing outside the engine that stamped it ([RFCS.23.5]).
int64 asserted_at = 5; // UTC instant the fact entered working memory, ns since the Unix epoch
bool has_asserted_at = 6; // false: the wall clock had no value then; asserted_at is ignored ([RFCS.23.5])
}
SchemaShape#
// What schema_hash fingerprints ([RFCS.23.3]): the schema's name and, for each
// slot sorted by name, its name, kind and nullability, for a fact-reference
// slot the referenced schema's name, and for a temporal slot its declared kind.
message SchemaShape {
string schema = 1;
repeated SlotShape slots = 2;
}
SlotShape#
message SlotShape {
string name = 1;
Kind kind = 2;
bool nullable = 3;
string ref_schema = 4; // KIND_FACT_REF: the referenced schema's name; else empty
SlotKind temporal_kind = 5; // a Time, Date or Duration slot: SLOT_KIND_TIME, _DATE or _DURATION; else unset
}