Brain Docs

Reference

Rust SDKInstallationHTTP clientWire client
create_statementget_statementlist_statementssupersede_statementtombstone_statementretract_statementstatement_history
ErrorsRetriesPagination
Brain/Docs
✦ ASKBrain on GitHubDashboard
Rust SDKStatementscreate_statement

create_statement

Write a typed claim — subject, predicate, object — and learn what it automatically superseded.

PURPOSE

Write one typed claim into the graph. The predicate must be declared in the active schema; an undeclared one is PredicateNotInSchema, not a silent accept.

POST/v1/statementsBearer API keystable
async fn create_statement(&self, input: &CreateStatementInput) -> Result<CreateStatementResult, BrainHttpError>
Handshake credentialstable
async fn create_statement(&self, request: &StatementCreateRequest) -> Result<StatementCreateResponse>

Parameters

ParameterTypeRequired
kindFact | Preference | Eventrequired

What sort of claim this is. These three are the whole set — there is no custom kind.

subjectstringrequired

The entity the claim is about.

predicatestringrequired

Must be in the active schema.

objectStatementObjectrequired

One of the four kinds above.

confidencefloatoptional

Defaults server-side.

event_at_unix_nanos64-bit integeroptional

When the thing happened.

valid_from_unix_nanos64-bit integeroptional

Start of the interval the claim is asserted over.

valid_to_unix_nanos64-bit integeroptional

End of it. Bitemporal, and separate from event time.

extractor_idintegeroptional

Attribute the claim to an extractor — see list_extractors.

schema_versionintegeroptional

Pin the schema version the claim was written under.

session_id64-bit integeroptional

Attribute it to a session.

evidencestring[]optional

Memory ids backing the claim.

Returns

FieldTypePresence
statement_idstringalways

The new statement.

auto_supersededstring

Present 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.

chain_rootstringalways

The supersession chain this joined.

Example

let created = brain
    .create_statement(&CreateStatementInput {
        kind: "Fact".into(),
        subject: priya_id.clone(),
        predicate: "works_at".into(),
        object: StatementObject::Entity { id: lisbon_office_id.clone() },
        evidence: vec![memory_id.clone()],
        ..Default::default()
    })
    .await?;

if let Some(old) = &created.auto_superseded {
    println!("replaced {old}");
}

The object union

A statement's object is one of four kinds:

OptionTypeDefault / Env
entity{ id }
Points at an entity.
value{ value }
A typed literal — see below.
memory{ id }
Points at a memory.
statement{ id }
Points at another statement — a claim about a claim.

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.

See also
supersede_statementSupersession

Was this page helpful?

tombstone_entity

Retire an entity — it leaves listings but its id keeps resolving.

get_statement

Read one statement — and the supersession-following default that can hand you a different one.

On this page

ParametersReturnsExampleThe object unionOn the wire
Suggest an editOpen in Playground