Chapter 6
Statements about statements
The first metagraph power, edges as vertices, is what agent memory uses most: how sure, where from, who checked. This chapter covers annotations, reifiers, promotion of virtual statements, and what happens on delete.
An annotation is a statement
An annotation is a statement whose subject is a statement ID. Nothing else about it is special. In the running example:
s1 = (:alice, :worksAt, :acme)
s2 = (s1, :confidence, 0.9)
s3 = (s1, :source, :chat12)
graphlava's spec stores an annotation like any statement, routed by its object. s3 has a node as object, so it goes to the orderings. s2 has a literal as object, so it is an inline property in s1's property record. Reading all of s1's literal annotations is one record read.
Writing and reading them in SPARQL 1.2
RDF 1.2 has an annotation syntax. The spec compiles it to "insert or find (:alice, :worksAt, :acme) with ID r, then insert the annotations with subject r":
PREFIX : <http://example.org/>
INSERT DATA {
:alice :worksAt :acme {| :confidence 0.9 ; :source :chat12 |} .
}
To read, bind the reifier with ~. In graphlava the reifier is the statement ID, so binding it is free in every ordering scan. No rdf:reifies triple is stored or joined:
SELECT ?who ?c ?src WHERE {
<< ?who :worksAt :acme ~ ?r >> .
?r :confidence ?c ; :source ?src .
FILTER(?c > 0.8)
}
The spec's plan for the first two patterns is one scan of the :worksAt statements and one read of the property record. Reifiers come back to clients as IRIs, <urn:meta-core:stmt:{id}>, which can be used in later requests (recommended; the form is still open).
Annotations of annotations
An annotation has an ID too, so it can be annotated. Carol checked the source:
INSERT DATA {
:alice :worksAt :acme {| :source :chat12 {| :checkedBy :carol |} |} .
}
s1 = (:alice, :worksAt, :acme)
s3 = (s1, :source, :chat12)
s4 = (s3, :checkedBy, :carol)
Depth is unlimited. Each level is one more statement and one more join in a query.
Update keeps the ID
graphlava stores current state, not history. Updating a statement's object keeps its ID, so annotations stay attached:
| Before | After update(s1, :globex) | |
|---|---|---|
s1 | (:alice, :worksAt, :acme) | (:alice, :worksAt, :globex) |
s2 | (s1, :confidence, 0.9) | unchanged, still on s1 |
This is the right behaviour for annotations that describe the slot ("this was set by the profile sync") and the wrong one for annotations that describe the old value ("0.9 sure it is Acme"). The application decides which annotations to reset in the same transaction. If you need the old value and its layers kept, that is tiramemsu's job: its supersede writes a new statement and replays the layers onto it.
The update fails with a conflict if (:alice, :worksAt, :globex) already exists and :worksAt is not a multi predicate.
A plain set(:alice, :worksAt, :globex) is different: it replaces all values of (:alice, :worksAt) by deleting the old statement and inserting a new one, so the annotations go with the old statement. To get update-in-place from set and insert too, declare the predicate functional (ADR 0028): at most one object per subject. Then a job change rewrites the object of s1 and keeps its ID, its :confidence and its :source. functional and multi exclude each other, and the planner treats (s, p) of a functional predicate as a key.
Virtual statements and promotion
Logically, everything in graphlava is a statement. Physically, four kinds of statement are virtual: they answer queries but have no statement ID. They get one when something annotates them. That step is called promotion, and it is one-way.
| Virtual statement | Served from | On promotion, the ID lives in |
|---|---|---|
inline property (:alice, :age, 34) | the subject's property record | the property slot (replaced by a pointer) and the orderings |
hyperedge role (e1, :agent, :alice) | hedge and incidence | hedge_promo; the role stays served from the record |
graph membership (s1, :in, :session7) | the ID's chunk, or gmem | the gmem entry |
| derived fact from a rule | the rule engine | a stored statement |
# :age is an inline property: no statement ID yet
INSERT DATA { :alice :age 34 . }
# annotating it promotes it, in the same transaction
INSERT DATA { :alice :age 34 {| :source :hrRecord |} . }
Until promotion, a query that binds the reifier of a virtual statement gets no binding, as if it had no reifier. Removing all annotations later does not demote it, and later value updates keep its new ID.
Why bother. Most values are overwritten often and never annotated: a status, a last-seen time, a counter. Keeping them in one property record means an overwrite is one write instead of seven. The few that need a handle pay for one when they need it.
Delete cascades down the layers
Deleting a statement deletes, in the same transaction, every statement whose subject is it, and repeats for each of those. Deleting s1 takes s2, s3 and s4 with it.
DELETE DATA { :alice :worksAt :acme . } # removes s1 and its annotations, transitively
| Case | Behaviour (spec) |
|---|---|
| Annotations of the deleted item | Deleted, transitively |
KEEP ANNOTATIONS after DELETE | Only the item goes; annotations stay with a dangling subject |
| The item fills a hyperedge role | Fails with ReferencedByHyperedge unless DETACH |
| More than the cascade limit (default 100,000) | Fails with CascadeLimitExceeded and rolls back |
| Another statement has the item as object | Not an annotation. Undecided in the spec; the recommended option blocks the delete unless DETACH, so no dangling object is created |
IDs are never reused, so an annotation kept with KEEP ANNOTATIONS can never end up pointing at a new, unrelated statement.
One reifier per triple
By default a predicate allows at most one statement per (s, p, o). Inserting an existing triple returns its ID and changes nothing. So a triple has exactly one reifier, its ID. RDF 1.2 allows several reifiers for one triple, each with its own annotations; graphlava's recommended answer is that a second reifier IRI becomes an alias of the same ID. This is an open question in the spec, gated on v0.
When you need several occurrences of one triple, declare the predicate multi. Alice met Bob twice, and each meeting has its own date:
# with :met declared multi, each reifier names its own statement
INSERT DATA {
:alice :met :bob ~ _:m1 {| :when "2026-11-20"^^xsd:date |} .
:alice :met :bob ~ _:m2 {| :when "2026-11-27"^^xsd:date |} .
}
Whether a reifier may point at a triple that is not asserted, as RDF 1.2 allows for quotes and claims, is also open; the recommended option stores it with an unasserted flag that normal matching skips.
The epistemic layer
An agent needs to know what it knows, and how. In statement terms, that layer is made of three patterns:
| Pattern | Shape | Stored as | On delete of s1 |
|---|---|---|---|
| Confidence | (s1, :confidence, 0.9) | inline property of s1 | goes with it |
| Source | (s1, :source, :chat12) | statement in the orderings | goes with it |
| Belief that rests on a fact | (:belief7, :supportedBy, s1) | statement; s1 is the object | not a cascade; the recommended option blocks the delete unless DETACH |
The last row matters. Under the recommended option, deleting the evidence fails while a belief still points at it. Put the dependency the right way round: if a belief should fall with its evidence, make the belief's link an annotation of the evidence, (s1, :supports, :belief7), or let a Datalog rule derive the belief (chapter 9), so it is recomputed when its premises change.
In graphlava. An annotation is a statement whose subject is a statement ID, stored by the same routing rule as any statement. The statement ID is the SPARQL reifier. Inline properties, hyperedge roles, memberships and derived facts are statements with no ID until annotated. Deleting a statement cascades to its annotations; a reference from the object position does not cascade, and the recommended option blocks the delete unless DETACH. A predicate declared functional updates in place on set, keeping ID and annotations.
Takeaways
- Statements about statements need nothing but an ID in subject position.
- graphlava gives IDs lazily: virtual statements are promoted on first annotation, and stay promoted.
- Updates keep IDs and annotations, and so does
seton afunctionalpredicate; reset annotations that described the old value. - Delete cascades in the subject direction only; an object-position reference is expected to block it. Model dependencies so they cascade the way you want.