createStatement
Write a typed claim — subject, predicate, object — and learn what it automatically superseded.
createStatement(input: CreateStatementInput): Promise<CreateStatementResult>createStatement(request: StatementCreateRequest): Promise<StatementCreateResponse>Parameters
kindFact | Preference | EventrequiredWhat sort of claim this is. These three are the whole set — there is no custom kind.
subjectstringrequiredThe entity the claim is about.
predicatestringrequiredMust be in the active schema.
objectStatementObjectrequiredOne of the four kinds above.
confidencefloatoptionalDefaults server-side.
eventAtUnixNanos64-bit integeroptionalWhen the thing happened.
validFromUnixNanos64-bit integeroptionalStart of the interval the claim is asserted over.
validToUnixNanos64-bit integeroptionalEnd of it. Bitemporal, and separate from event time.
extractorIdintegeroptionalAttribute the claim to an extractor — see listExtractors.
schemaVersionintegeroptionalPin the schema version the claim was written under.
sessionId64-bit integeroptionalAttribute it to a session.
evidencestring[]optionalMemory ids backing the claim.
Returns
statementIdstringalwaysThe new statement.
autoSupersededstringPresent when this write automatically superseded an existing statement — a single-cardinality predicate getting a new value. The write succeeded and something else stopped being current; ignoring this field is how a caller loses track of what it replaced.
chainRootstringalwaysThe supersession chain this joined.
Example
const created = await brain.createStatement({
kind: "Fact",
subject: priyaId,
predicate: "works_at",
object: { kind: "entity", id: lisbonOfficeId },
evidence: [memoryId],
});
if (created.autoSuperseded) console.log("replaced", created.autoSuperseded);The object union
A statement's object is one of four kinds:
entity{ id }value{ value }memory{ id }statement{ id }A value object carries one of six typed values: text, integer, float,
bool, unix_nanos and blob. unix_nanos is distinct from integer so
Brain can range-query it as a time.
Events never supersede
Supersession is for claims that can be corrected. An Event records that
something happened; a later event does not make an earlier one false, so
Brain never auto-supersedes one. See Supersession.
On the wire
subject is UUID bytes and kind is an integer discriminant rather than a
string. evidence is a single reference, not an array of ids. Every request
carries a requestId plus an optional actAs.
Was this page helpful?