The Problem No One Talks About

Every AI engineer who has built a serious knowledge system hits the same wall. You have triples — (Alice, attended, Meeting_42) — and they work fine for simple facts. But then the question arrives that triples cannot answer cleanly: what can I say about that attendance? Who verified it? When did it become true? Did it cause anything else? Was the meeting itself a reaction to something that happened before?

The moment you need to reason about relationships, not just through them, triples break. RDF reification gives you the machinery but buries you in verbosity. Property graphs let you annotate edges, but those annotations cannot themselves be edges. The underlying model is binary and flat.

This article shows a different path: encode a metagraph as a bipartite graph, represent it in JSON-LD for semantic interoperability, and persist it in Fluree — a database that is itself an immutable temporal ledger. The result is a knowledge system where every relationship is a first-class entity, every state of the graph is preserved forever, and you can query “what did the world look like last Tuesday?” as easily as you query the present.

The theory behind this approach is covered in depth in Metagraphs for Agentic AI (in progress). This article is the implementation companion: working schema, real JSON-LD documents, actual Fluree queries, and temporal patterns you can use today.


What a Bipartite Metagraph Is (and Why It Matters)

A metagraph is a graph where edges can be nodes. That single change — edges becoming first-class entities — unlocks recursive structure: edges about edges, contexts over events, causality chains that are themselves queryable objects.

The challenge is implementing this in a real database. Most stores don’t natively support it. The practical solution, developed in detail in Metagraphs for Agentic AI, is the bipartite encoding: divide all graph elements into two disjoint partitions and enforce that edges only cross partitions, never run within them.

For a full metagraph we use a multipartite three-layer structure:

Layer N  — Entity nodes (N-nodes): people, places, concepts, objects
Layer E  — Relationship nodes (E-nodes): events, actions, decisions, interactions
Layer S  — Subgraph nodes (S-nodes): contexts, episodes, narratives, schemas

Every edge connects across exactly one layer boundary:

N → E   (entity participates in relationship)
E → N   (relationship references entity)
E → S   (relationship belongs to context)
S → E   (context contains relationship)
S → S   (meta-context references context)

There are no N→N edges, no E→E edges. The bipartite constraint is the organizing principle that makes the structure rigorous and efficiently traversable.

Concretely: a planning meeting is not a node called “Meeting” with attendees jammed into properties. It is an E-node — a full entity in its own right — and each person who attended has an edge to that E-node annotated with their role. The meeting can then be a source or target in a Causality E-node, which connects the meeting-event to a decision-event. Relationships connect relationships. That is the metagraph.


Why JSON-LD for Metagraphs

JSON-LD (JSON Linked Data) is the W3C standard for expressing RDF in JSON syntax. For metagraph work it offers three things that matter:

1. Named graphs natively. JSON-LD supports the @graph keyword and named graph containers, which maps directly onto the idea that contexts (S-nodes) are themselves addressable graph collections.

2. Semantic vocabulary. Every node and edge type gets a globally unique URI. mg:RelationshipNode means the same thing everywhere, not just in your private schema. This enables knowledge federation across agents.

3. Fluree speaks JSON-LD natively. Fluree’s entire data model is built on JSON-LD. You can load a JSON-LD document directly, query with SPARQL or FlureeQL, and reason over it with OWL/SHACL — no translation layer.


Why Fluree for Temporal Metagraphs

Fluree is a semantic graph database with one unusual architectural property: it is an immutable, append-only ledger. Every transaction creates a numbered block with a timestamp. Nothing is ever deleted or overwritten; the ledger only grows.

This makes Fluree the natural home for temporal metagraphs:

Fluree featureMetagraph benefitImmutable block ledgerEvery state of the graph is preservedas-of time-travel queriesQuery the graph as it existed at any past block or timestampJSON-LD native data modelDirect load of metagraph JSON-LD documentsW3C SPARQL supportExpressive traversal across N/E/S layersFlureeQL (Datalog-flavored)Recursive path queries, pattern matchingSHACL shapesEnforce the bipartite constraint at write timeOWL inferenceDerive implicit relationships from declared axiomsSigned transactionsProvenance-tracked writes with cryptographic identity

The immutability aligns with the metagraph’s own epistemology: in a proper knowledge system, facts are never erased — they are superseded by newer facts, and the history of supersession is itself part of the knowledge. Fluree enforces this property at the database level.


Designing the JSON-LD Vocabulary

Before writing a single Fluree transaction, we need a vocabulary — a set of URI-identified types and predicates that precisely encode the multipartite structure.

Namespace Declaration

{
  "@context": {
    "@vocab": "https://metagraph.ai/vocab#",
    "mg": "https://metagraph.ai/vocab#",
    "mgx": "https://metagraph.ai/ext#",
    "xsd": "http://www.w3.org/2001/XMLSchema#",
    "rdf": "http://www.w3.org/1999/02/22-rdf-syntax-ns#",
    "rdfs": "http://www.w3.org/2000/01/rdf-schema#",
    "owl": "http://www.w3.org/2002/07/owl#",
    "skos": "http://www.w3.org/2004/02/skos/core#",
    "dcterms": "http://purl.org/dc/terms/",
    "prov": "http://www.w3.org/ns/prov#"
  }
}

Core Class Definitions

{
  "@context": "https://metagraph.ai/vocab#",
  "@graph": [
    {
      "@id": "mg:EntityNode",
      "@type": "owl:Class",
      "rdfs:label": "Entity Node",
      "rdfs:comment": "Layer-N node: a primitive entity in the metagraph.",
      "rdfs:subClassOf": "mg:MetagraphElement"
    },
    {
      "@id": "mg:RelationshipNode",
      "@type": "owl:Class",
      "rdfs:label": "Relationship Node",
      "rdfs:comment": "Layer-E node: a promoted relationship, event, or action that connects entity nodes.",
      "rdfs:subClassOf": "mg:MetagraphElement"
    },
    {
      "@id": "mg:SubgraphNode",
      "@type": "owl:Class",
      "rdfs:label": "Subgraph Node",
      "rdfs:comment": "Layer-S node: a context, narrative, or episode grouping relationship nodes.",
      "rdfs:subClassOf": "mg:MetagraphElement"
    },
    {
      "@id": "mg:MEMBER_OF",
      "@type": "owl:ObjectProperty",
      "rdfs:label": "member of",
      "rdfs:comment": "Connects an EntityNode to a RelationshipNode (N→E edge).",
      "rdfs:domain": "mg:EntityNode",
      "rdfs:range": "mg:RelationshipNode"
    },
    {
      "@id": "mg:PART_OF",
      "@type": "owl:ObjectProperty",
      "rdfs:label": "part of",
      "rdfs:comment": "Connects a RelationshipNode to a SubgraphNode (E→S edge).",
      "rdfs:domain": "mg:RelationshipNode",
      "rdfs:range": "mg:SubgraphNode"
    },
    {
      "@id": "mg:REFERENCES",
      "@type": "owl:ObjectProperty",
      "rdfs:label": "references",
      "rdfs:comment": "Connects a RelationshipNode back to an EntityNode (E→N back-reference).",
      "rdfs:domain": "mg:RelationshipNode",
      "rdfs:range": "mg:EntityNode"
    },
    {
      "@id": "mg:CONTAINS",
      "@type": "owl:ObjectProperty",
      "rdfs:label": "contains",
      "rdfs:comment": "Connects a SubgraphNode to the RelationshipNodes it groups (S→E edge).",
      "rdfs:domain": "mg:SubgraphNode",
      "rdfs:range": "mg:RelationshipNode"
    },
    {
      "@id": "mg:RELATES_TO",
      "@type": "owl:ObjectProperty",
      "rdfs:label": "relates to",
      "rdfs:comment": "Connects SubgraphNodes to each other (S→S meta-context edge).",
      "rdfs:domain": "mg:SubgraphNode",
      "rdfs:range": "mg:SubgraphNode"
    }
  ]
}

Property Definitions

{
  "@context": "https://metagraph.ai/vocab#",
  "@graph": [
    {
      "@id": "mg:role",
      "@type": "owl:DatatypeProperty",
      "rdfs:label": "role",
      "rdfs:comment": "The role an entity plays in a relationship (e.g., 'agent', 'patient', 'facilitator').",
      "rdfs:domain": "mg:MEMBER_OF"
    },
    {
      "@id": "mg:position",
      "@type": "owl:DatatypeProperty",
      "rdfs:label": "position",
      "rdfs:comment": "Ordinal position of an entity within an ordered relationship.",
      "rdfs:range": "xsd:integer"
    },
    {
      "@id": "mg:arity",
      "@type": "owl:DatatypeProperty",
      "rdfs:label": "arity",
      "rdfs:comment": "Number of entity participants in a relationship node.",
      "rdfs:range": "xsd:integer"
    },
    {
      "@id": "mg:relationKind",
      "@type": "owl:DatatypeProperty",
      "rdfs:label": "relation kind",
      "rdfs:comment": "Semantic category of a RelationshipNode (e.g., 'Event', 'Decision', 'Causality').",
      "rdfs:domain": "mg:RelationshipNode"
    },
    {
      "@id": "mg:strength",
      "@type": "owl:DatatypeProperty",
      "rdfs:label": "strength",
      "rdfs:comment": "Confidence or weight of a causal or semantic relationship (0.0–1.0).",
      "rdfs:range": "xsd:decimal"
    },
    {
      "@id": "mg:validFrom",
      "@type": "owl:DatatypeProperty",
      "rdfs:label": "valid from",
      "rdfs:comment": "The earliest point in time at which this element was true.",
      "rdfs:range": "xsd:dateTime"
    },
    {
      "@id": "mg:validTo",
      "@type": "owl:DatatypeProperty",
      "rdfs:label": "valid to",
      "rdfs:comment": "The latest point in time at which this element was true. Absent means currently valid.",
      "rdfs:range": "xsd:dateTime"
    },
    {
      "@id": "mg:subgraphKind",
      "@type": "owl:DatatypeProperty",
      "rdfs:label": "subgraph kind",
      "rdfs:comment": "Category of a SubgraphNode: 'episode', 'context', 'narrative', 'schema'.",
      "rdfs:domain": "mg:SubgraphNode"
    }
  ]
}

The Scenario: A Strategic Decision Chain

We will model a realistic knowledge sequence that requires metagraph expressiveness:

  1. 1.

    A product team holds a planning meeting (Event)

  2. 2.

    The meeting produces a decision to accelerate a deadline (Decision)

  3. 3.

    The decision causes a scope reduction (Consequence)

  4. 4.

    All three are contained in a Q2 Planning Episode (SubgraphNode)

  5. 5.

    That episode is linked to a Strategic Context for the whole quarter (SubgraphNode)

This scenario has five events, seven people, two contexts, and multiple causal links — the minimum complexity where metagraphs become necessary and triples become untenable.


Setting Up Fluree

Install and Start Fluree

# Using Docker (recommended)
docker pull fluree/server:latest
docker run -d \
  --name fluree-metagraph \
  -p 58090:58090 \
  -v fluree-data:/var/lib/fluree \
  fluree/server:latest

# Verify
curl http://localhost:58090/fdb/health
# {"status":"ready","version":"3.x"}

Create the Ledger

curl -X POST http://localhost:58090/fdb/create-ledger \
  -H "Content-Type: application/json" \
  -d '{
    "ledger": "metagraph/planning",
    "defaultContext": {
      "mg": "https://metagraph.ai/vocab#",
      "xsd": "http://www.w3.org/2001/XMLSchema#",
      "rdfs": "http://www.w3.org/2000/01/rdf-schema#",
      "prov": "http://www.w3.org/ns/prov#"
    }
  }'

Defining the SHACL Schema

SHACL (Shapes Constraint Language) lets Fluree enforce the bipartite structure at write time. We declare that MEMBER_OF edges can only go from EntityNode to RelationshipNode, never within the same layer.

{
  "@context": {
    "mg": "https://metagraph.ai/vocab#",
    "sh": "http://www.w3.org/ns/shacl#",
    "xsd": "http://www.w3.org/2001/XMLSchema#"
  },
  "@graph": [
    {
      "@id": "mg:EntityNodeShape",
      "@type": "sh:NodeShape",
      "sh:targetClass": { "@id": "mg:EntityNode" },
      "sh:property": [
        {
          "sh:path": { "@id": "rdfs:label" },
          "sh:minCount": 1,
          "sh:datatype": { "@id": "xsd:string" }
        },
        {
          "sh:path": { "@id": "mg:kind" },
          "sh:minCount": 1,
          "sh:datatype": { "@id": "xsd:string" }
        }
      ]
    },
    {
      "@id": "mg:RelationshipNodeShape",
      "@type": "sh:NodeShape",
      "sh:targetClass": { "@id": "mg:RelationshipNode" },
      "sh:property": [
        {
          "sh:path": { "@id": "mg:relationKind" },
          "sh:minCount": 1
        },
        {
          "sh:path": { "@id": "mg:arity" },
          "sh:minCount": 1,
          "sh:datatype": { "@id": "xsd:integer" }
        }
      ]
    },
    {
      "@id": "mg:MemberOfShape",
      "@type": "sh:PropertyShape",
      "sh:path": { "@id": "mg:MEMBER_OF" },
      "sh:class": { "@id": "mg:RelationshipNode" },
      "sh:nodeKind": "sh:IRI"
    },
    {
      "@id": "mg:PartOfShape",
      "@type": "sh:PropertyShape",
      "sh:path": { "@id": "mg:PART_OF" },
      "sh:class": { "@id": "mg:SubgraphNode" }
    }
  ]
}

Load the schema into Fluree:

curl -X POST http://localhost:58090/fdb/metagraph/planning/transact \
  -H "Content-Type: application/json" \
  -d @schema.jsonld

Loading the Metagraph: Layer by Layer

Layer N — Entity Nodes

{
  "@context": {
    "mg": "https://metagraph.ai/vocab#",
    "xsd": "http://www.w3.org/2001/XMLSchema#"
  },
  "@graph": [
    {
      "@id": "mg:person/alice",
      "@type": "mg:EntityNode",
      "mg:kind": "Person",
      "rdfs:label": "Alice",
      "mg:description": "Lead product engineer",
      "mg:validFrom": {
        "@value": "2026-01-01T00:00:00Z",
        "@type": "xsd:dateTime"
      }
    },
    {
      "@id": "mg:person/bob",
      "@type": "mg:EntityNode",
      "mg:kind": "Person",
      "rdfs:label": "Bob",
      "mg:description": "Product manager"
    },
    {
      "@id": "mg:person/carol",
      "@type": "mg:EntityNode",
      "mg:kind": "Person",
      "rdfs:label": "Carol",
      "mg:description": "Engineering director"
    },
    {
      "@id": "mg:project/horizon",
      "@type": "mg:EntityNode",
      "mg:kind": "Project",
      "rdfs:label": "Project Horizon",
      "mg:description": "Next-generation AI platform"
    },
    {
      "@id": "mg:milestone/q2-launch",
      "@type": "mg:EntityNode",
      "mg:kind": "Milestone",
      "rdfs:label": "Q2 Product Launch",
      "mg:description": "Public launch of Horizon v1",
      "mg:validFrom": {
        "@value": "2026-04-01T00:00:00Z",
        "@type": "xsd:dateTime"
      },
      "mg:validTo": {
        "@value": "2026-06-30T23:59:59Z",
        "@type": "xsd:dateTime"
      }
    },
    {
      "@id": "mg:feature/realtime-collab",
      "@type": "mg:EntityNode",
      "mg:kind": "Feature",
      "rdfs:label": "Real-time Collaboration",
      "mg:description": "Multi-user simultaneous editing capability"
    }
  ]
}
{
  "@context": {
    "mg": "https://metagraph.ai/vocab#",
    "xsd": "http://www.w3.org/2001/XMLSchema#",
    "prov": "http://www.w3.org/ns/prov#"
  },
  "@graph": [
    {
      "@id": "mg:event/planning-meeting-2026-03-24",
      "@type": "mg:RelationshipNode",
      "rdfs:label": "Q2 Planning Meeting",
      "mg:relationKind": "Event",
      "mg:arity": 3,
      "mg:description": "Cross-functional planning session for Q2 deliverables",
      "prov:startedAtTime": {
        "@value": "2026-03-24T14:00:00Z",
        "@type": "xsd:dateTime"
      },
      "prov:endedAtTime": {
        "@value": "2026-03-24T15:30:00Z",
        "@type": "xsd:dateTime"
      },
      "mg:outcome": "Agreed to accelerate Q2 deadline by 3 weeks",
      "mg:mood": "contentious",
      "mg:REFERENCES": [
        { "@id": "mg:project/horizon" },
        { "@id": "mg:milestone/q2-launch" }
      ]
    },
    {
      "@id": "mg:decision/accelerate-q2",
      "@type": "mg:RelationshipNode",
      "rdfs:label": "Decision: Accelerate Q2 Deadline",
      "mg:relationKind": "Decision",
      "mg:arity": 2,
      "mg:description": "Commit to delivering Horizon v1 three weeks ahead of original plan",
      "prov:generatedAtTime": {
        "@value": "2026-03-24T15:20:00Z",
        "@type": "xsd:dateTime"
      },
      "mg:authority": "Carol",
      "mg:reversible": false,
      "mg:REFERENCES": [
        { "@id": "mg:milestone/q2-launch" }
      ]
    },
    {
      "@id": "mg:consequence/scope-cut",
      "@type": "mg:RelationshipNode",
      "rdfs:label": "Scope Reduction: Real-time Collaboration Deferred",
      "mg:relationKind": "Consequence",
      "mg:arity": 2,
      "mg:description": "Real-time collaboration feature moved to Q3 to meet accelerated Q2 deadline",
      "prov:generatedAtTime": {
        "@value": "2026-03-25T09:00:00Z",
        "@type": "xsd:dateTime"
      },
      "mg:REFERENCES": [
        { "@id": "mg:feature/realtime-collab" },
        { "@id": "mg:milestone/q2-launch" }
      ]
    },
    {
      "@id": "mg:causal/meeting-causes-decision",
      "@type": "mg:RelationshipNode",
      "rdfs:label": "Causal Link: Meeting → Decision",
      "mg:relationKind": "Causality",
      "mg:arity": 2,
      "mg:strength": 0.92,
      "mg:reasoning": "The meeting's contentious discussion of competitive pressure directly produced the acceleration commitment",
      "mg:direction": "forward"
    },
    {
      "@id": "mg:causal/decision-causes-scope-cut",
      "@type": "mg:RelationshipNode",
      "rdfs:label": "Causal Link: Decision → Scope Cut",
      "mg:relationKind": "Causality",
      "mg:arity": 2,
      "mg:strength": 0.88,
      "mg:reasoning": "Accelerating the deadline without adding resources required reducing scope"
    }
  ]
}

Connecting Entities to Relationships (N→E edges)

In JSON-LD, the participation edges are expressed as separate membership assertions. Because Fluree’s data model follows RDF, the most natural encoding is to assert MEMBER_OF triples directly, with role and position as reified properties on intermediate nodes or as separate named graphs.

Here we use a clean reified participation pattern that preserves role metadata while staying within the JSON-LD model:

{
  "@context": {
    "mg": "https://metagraph.ai/vocab#",
    "xsd": "http://www.w3.org/2001/XMLSchema#"
  },
  "@graph": [
    {
      "@id": "mg:participation/alice-planning",
      "@type": "mg:Participation",
      "mg:participant": { "@id": "mg:person/alice" },
      "mg:inRelationship": { "@id": "mg:event/planning-meeting-2026-03-24" },
      "mg:role": "facilitator",
      "mg:position": 1
    },
    {
      "@id": "mg:participation/bob-planning",
      "@type": "mg:Participation",
      "mg:participant": { "@id": "mg:person/bob" },
      "mg:inRelationship": { "@id": "mg:event/planning-meeting-2026-03-24" },
      "mg:role": "presenter",
      "mg:position": 2
    },
    {
      "@id": "mg:participation/carol-planning",
      "@type": "mg:Participation",
      "mg:participant": { "@id": "mg:person/carol" },
      "mg:inRelationship": { "@id": "mg:event/planning-meeting-2026-03-24" },
      "mg:role": "decision-maker",
      "mg:position": 3
    },
    {
      "@id": "mg:participation/carol-decision",
      "@type": "mg:Participation",
      "mg:participant": { "@id": "mg:person/carol" },
      "mg:inRelationship": { "@id": "mg:decision/accelerate-q2" },
      "mg:role": "authority",
      "mg:position": 1
    },
    {
      "@id": "mg:participation/bob-decision",
      "@type": "mg:Participation",
      "mg:participant": { "@id": "mg:person/bob" },
      "mg:inRelationship": { "@id": "mg:decision/accelerate-q2" },
      "mg:role": "proposer",
      "mg:position": 2
    },
    {
      "@id": "mg:participation/meeting-causes-decision-cause",
      "@type": "mg:Participation",
      "mg:participant": { "@id": "mg:event/planning-meeting-2026-03-24" },
      "mg:inRelationship": { "@id": "mg:causal/meeting-causes-decision" },
      "mg:role": "cause",
      "mg:position": 1
    },
    {
      "@id": "mg:participation/meeting-causes-decision-effect",
      "@type": "mg:Participation",
      "mg:participant": { "@id": "mg:decision/accelerate-q2" },
      "mg:inRelationship": { "@id": "mg:causal/meeting-causes-decision" },
      "mg:role": "effect",
      "mg:position": 2
    },
    {
      "@id": "mg:participation/decision-causes-scope-cause",
      "@type": "mg:Participation",
      "mg:participant": { "@id": "mg:decision/accelerate-q2" },
      "mg:inRelationship": { "@id": "mg:causal/decision-causes-scope-cut" },
      "mg:role": "cause",
      "mg:position": 1
    },
    {
      "@id": "mg:participation/decision-causes-scope-effect",
      "@type": "mg:Participation",
      "mg:participant": { "@id": "mg:consequence/scope-cut" },
      "mg:inRelationship": { "@id": "mg:causal/decision-causes-scope-cut" },
      "mg:role": "effect",
      "mg:position": 2
    }
  ]
}

Note the recursive power here: the causal link nodes (mg:causal/meeting-causes-decision) treat other E-nodes (the meeting and the decision) as their participants. Causality between relationships is a first-class relationship. This is the metagraph property that is impossible in flat hypergraphs.

Layer S — Subgraph Nodes (Contexts and Episodes)

{
  "@context": {
    "mg": "https://metagraph.ai/vocab#",
    "xsd": "http://www.w3.org/2001/XMLSchema#",
    "dcterms": "http://purl.org/dc/terms/"
  },
  "@graph": [
    {
      "@id": "mg:episode/q2-planning-session",
      "@type": "mg:SubgraphNode",
      "rdfs:label": "Q2 Planning Episode",
      "mg:subgraphKind": "episode",
      "mg:description": "The cluster of events, decisions, and consequences that emerged from the March 24 planning session",
      "dcterms:created": {
        "@value": "2026-03-24T14:00:00Z",
        "@type": "xsd:dateTime"
      },
      "mg:CONTAINS": [
        { "@id": "mg:event/planning-meeting-2026-03-24" },
        { "@id": "mg:decision/accelerate-q2" },
        { "@id": "mg:consequence/scope-cut" },
        { "@id": "mg:causal/meeting-causes-decision" },
        { "@id": "mg:causal/decision-causes-scope-cut" }
      ]
    },
    {
      "@id": "mg:context/q2-strategic",
      "@type": "mg:SubgraphNode",
      "rdfs:label": "Q2 Strategic Context",
      "mg:subgraphKind": "context",
      "mg:description": "The broader strategic frame for all Q2 product decisions",
      "mg:horizon": "2026-Q2",
      "mg:priority": "high",
      "mg:RELATES_TO": [
        { "@id": "mg:episode/q2-planning-session" }
      ]
    }
  ]
}

Querying the Metagraph in Fluree

Fluree supports both SPARQL and FlureeQL. We will use both to show the options.

Query 1: All Participants in the Planning Meeting

PREFIX mg: <https://metagraph.ai/vocab#>
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>

SELECT ?personLabel ?role ?position
WHERE {
  ?p mg:inRelationship mg:event/planning-meeting-2026-03-24 .
  ?p mg:participant ?person .
  ?p mg:role ?role .
  ?p mg:position ?position .
  ?person rdfs:label ?personLabel .
}
ORDER BY ?position

Result:

personLabel | role            | position
------------|-----------------|----------
Alice       | facilitator     | 1
Bob         | presenter       | 2
Carol       | decision-maker  | 3

Query 2: The Full Causal Chain from Meeting to Scope Cut

This query traverses two levels of causality: meeting → decision → scope cut.

PREFIX mg: <https://metagraph.ai/vocab#>
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>

SELECT ?causeName ?effectName ?strength ?reasoning
WHERE {
  ?causal a mg:RelationshipNode ;
          mg:relationKind "Causality" ;
          mg:strength ?strength ;
          mg:reasoning ?reasoning .

  ?cause_p mg:inRelationship ?causal ;
           mg:role "cause" ;
           mg:participant ?causeNode .

  ?effect_p mg:inRelationship ?causal ;
            mg:role "effect" ;
            mg:participant ?effectNode .

  ?causeNode rdfs:label ?causeName .
  ?effectNode rdfs:label ?effectName .
}
ORDER BY ?strength DESC

Result:

causeName              | effectName                              | strength | reasoning
-----------------------|-----------------------------------------|----------|-------------------
Q2 Planning Meeting    | Decision: Accelerate Q2 Deadline        | 0.92     | The meeting's contentious...
Decision: Accelerate…  | Scope Reduction: Real-time…             | 0.88     | Accelerating the deadline...

Query 3: Who Was Responsible for the Scope Cut (Tracing Back Through Causality)

This is the query type that is impossible with flat triples: given a consequence, trace back through causal links to find which humans were in the originating events.

PREFIX mg: <https://metagraph.ai/vocab#>
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>

SELECT DISTINCT ?personLabel ?role ?via
WHERE {
  # Find the consequence
  mg:consequence/scope-cut rdfs:label ?consequenceLabel .

  # Walk backwards through causality: scope-cut ← decision ← meeting
  ?effect_p1 mg:inRelationship ?causal1 ;
             mg:role "effect" ;
             mg:participant mg:consequence/scope-cut .

  ?cause_p1 mg:inRelationship ?causal1 ;
            mg:role "cause" ;
            mg:participant ?intermediary .

  OPTIONAL {
    ?effect_p2 mg:inRelationship ?causal2 ;
               mg:role "effect" ;
               mg:participant ?intermediary .

    ?cause_p2 mg:inRelationship ?causal2 ;
              mg:role "cause" ;
              mg:participant ?originEvent .
  }

  # Find people in either origin or intermediary events
  {
    ?p mg:inRelationship ?intermediary ;
       mg:participant ?person ;
       mg:role ?role .
    BIND("via intermediary" AS ?via)
  } UNION {
    ?p mg:inRelationship ?originEvent ;
       mg:participant ?person ;
       mg:role ?role .
    BIND("via origin" AS ?via)
  }

  ?person a mg:EntityNode .
  ?person rdfs:label ?personLabel .
}

Result:

personLabel | role            | via
------------|-----------------|-------------------
Carol       | decision-maker  | via origin (meeting)
Carol       | authority       | via intermediary (decision)
Bob         | presenter       | via origin (meeting)
Bob         | proposer        | via intermediary (decision)
Alice       | facilitator     | via origin (meeting)

The scope cut traces back to the meeting, and the people who bear most responsibility for it — Carol as decision-maker and Bob as proposer — appear twice in the chain.

The Temporal Layer: Fluree’s Superpower

Now we get to the capability that makes Fluree exceptional for metagraph work: every state of the ledger is preserved and queryable. This is not a soft feature — it is the fundamental architecture.

Understanding Fluree Blocks

Every transaction in Fluree creates a block:

Block 1:  Schema loaded                    (t=2026-03-20T09:00:00Z)
Block 2:  Entity nodes created             (t=2026-03-20T09:01:00Z)
Block 3:  Event nodes created              (t=2026-03-24T16:00:00Z)
Block 4:  Participation edges loaded       (t=2026-03-24T16:05:00Z)
Block 5:  Subgraph nodes created           (t=2026-03-24T16:10:00Z)
Block 6:  Scope cut consequence added      (t=2026-03-25T09:00:00Z)
Block 7:  Causal link strength revised     (t=2026-03-28T11:00:00Z)
Block 8:  Real-time collab feature updated (t=2026-04-02T14:00:00Z)

Time-Travel Query: What Did the Graph Look Like Before the Scope Cut?

Using Fluree’s as-of parameter, we can query the ledger as it existed at any past block or timestamp.

{
  "ledger": "metagraph/planning",
  "query": {
    "select": { "?event": ["*"] },
    "where": [
      ["?event", "@type", "mg:RelationshipNode"],
      ["?event", "mg:relationKind", "?kind"]
    ]
  },
  "opts": {
    "as-of": "2026-03-24T17:00:00Z"
  }
}

At 2026-03-24T17:00:00Z, only the planning meeting and the decision exist. The scope cut consequence was added on March 25. This query returns:

[
  {
    "@id": "mg:event/planning-meeting-2026-03-24",
    "mg:relationKind": "Event",
    "rdfs:label": "Q2 Planning Meeting"
  },
  {
    "@id": "mg:decision/accelerate-q2",
    "mg:relationKind": "Decision",
    "rdfs:label": "Decision: Accelerate Q2 Deadline"
  }
]

The scope cut simply does not exist at that point in time. The database’s history is the metagraph’s history.

Time-Travel Query: How Has a Node Changed Over Time?

Suppose on March 28, after discussing it further, a team member revised the causal strength of the meeting-to-decision link from 0.92 to 0.78 (new information suggested the competitive pressure had been overstated). Fluree records both states.

{
  "ledger": "metagraph/planning",
  "query": {
    "history": "mg:causal/meeting-causes-decision",
    "commit-details": true
  }
}

Result — Fluree returns every block in which this node was touched:

[
  {
    "f:t": 4,
    "f:assert": [
      {
        "@id": "mg:causal/meeting-causes-decision",
        "mg:strength": 0.92,
        "mg:reasoning": "The meeting's contentious discussion of competitive pressure..."
      }
    ],
    "f:commit": {
      "f:time": "2026-03-24T16:05:00Z",
      "f:author": "bob@example.com"
    }
  },
  {
    "f:t": 7,
    "f:assert": [
      {
        "@id": "mg:causal/meeting-causes-decision",
        "mg:strength": 0.78
      }
    ],
    "f:retract": [
      {
        "@id": "mg:causal/meeting-causes-decision",
        "mg:strength": 0.92
      }
    ],
    "f:commit": {
      "f:time": "2026-03-28T11:00:00Z",
      "f:author": "alice@example.com"
    }
  }
]

The original causal assessment was 0.92; Alice revised it to 0.78 four days later. Both facts are permanent. You know who changed it and when. This is provenance baked into the database, not bolted on.

SPARQL Time-Travel: Combining Temporal and Graph Queries

Fluree’s SPARQL endpoint accepts an as-of annotation for time-aware SPARQL queries.

# Find all causal links and their strength AS OF the end of March
# (before any April revisions)
PREFIX mg: <https://metagraph.ai/vocab#>
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>

SELECT ?linkLabel ?strength ?reasoningSnippet
WHERE {
  ?link a mg:RelationshipNode ;
        mg:relationKind "Causality" ;
        rdfs:label ?linkLabel ;
        mg:strength ?strength .
  OPTIONAL { ?link mg:reasoning ?reasoningSnippet . }
}

With "as-of": "2026-03-31T23:59:59Z" the query returns strength 0.92 for the meeting→decision link (the original value). With "as-of": "2026-04-01T00:00:00Z" it returns 0.78 (after Alice’s revision). The graph’s epistemology evolves over time and every state is queryable.

Temporal Metagraph Pattern: Valid-Time Predicates

Beyond Fluree’s block-level time travel, the metagraph vocabulary itself carries valid-time predicates — mg:validFrom and mg:validTo — that express when something was true in the real world, independent of when it was recorded.

This is the distinction between transaction time (when was it recorded?) and valid time (when was it true?). Both matter. The real-time collaboration feature was always planned for Q2; the decision to defer it to Q3 was made on March 25 but refers to an already-existing entity (mg:feature/realtime-collab) that had its own validTo updated.

{
  "@context": { "mg": "https://metagraph.ai/vocab#", "xsd": "http://www.w3.org/2001/XMLSchema#" },
  "@graph": [
    {
      "@id": "mg:feature/realtime-collab",
      "mg:validFrom": { "@value": "2026-01-01T00:00:00Z", "@type": "xsd:dateTime" },
      "mg:validTo": { "@value": "2026-06-30T23:59:59Z", "@type": "xsd:dateTime" },
      "mg:targetRelease": "Q2-2026",
      "mg:deferredTo": "Q3-2026",
      "mg:deferralReason": { "@id": "mg:consequence/scope-cut" }
    }
  ]
}

Now you can query: “What features were in scope for Q2 at the time of the planning meeting?” — using Fluree’s as-of to pin the transaction time, and valid-time predicates in the WHERE clause to filter by domain truth.


Advanced Pattern: Named-Graph Provenance with JSON-LD

JSON-LD’s @graph containers allow us to attach provenance metadata to entire sub-graphs. This maps directly to Fluree’s named-graph support and to the S-node concept in the metagraph model.

{
  "@context": {
    "mg": "https://metagraph.ai/vocab#",
    "prov": "http://www.w3.org/ns/prov#",
    "xsd": "http://www.w3.org/2001/XMLSchema#"
  },
  "@id": "mg:named-graph/bob-meeting-notes",
  "@type": "mg:SubgraphNode",
  "mg:subgraphKind": "provenance-graph",
  "prov:wasAttributedTo": { "@id": "mg:person/bob" },
  "prov:generatedAtTime": {
    "@value": "2026-03-24T16:30:00Z",
    "@type": "xsd:dateTime"
  },
  "mg:confidence": 0.85,
  "mg:note": "Bob's personal notes — subjective, may differ from official minutes",
  "@graph": [
    {
      "@id": "mg:event/planning-meeting-2026-03-24",
      "mg:mood": "tense",
      "mg:keyMoment": "Carol cut off debate at 15:15 and issued the deadline decision unilaterally"
    },
    {
      "@id": "mg:decision/accelerate-q2",
      "mg:perceivedFairness": 0.4,
      "mg:bobDisagreement": true
    }
  ]
}

This named graph is itself an S-node in the metagraph. Bob’s perspective on the events is a first-class entity that can be compared against Carol’s or against the official minutes. In a multi-agent system, each agent can maintain its own named graph of beliefs, and the metagraph model provides the structure to reason about disagreements across perspectives.

# Compare two agents' views of the meeting mood
PREFIX mg: <https://metagraph.ai/vocab#>
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>

SELECT ?graphLabel ?observer ?mood ?confidence
WHERE {
  ?namedGraph mg:subgraphKind "provenance-graph" ;
              rdfs:label ?graphLabel ;
              mg:confidence ?confidence .

  ?namedGraph prov:wasAttributedTo ?observerNode .
  ?observerNode rdfs:label ?observer .

  GRAPH ?namedGraph {
    mg:event/planning-meeting-2026-03-24 mg:mood ?mood .
  }
}

Result:

graphLabel          | observer | mood        | confidence
--------------------|----------|-------------|------------
Bob's Meeting Notes | Bob      | tense       | 0.85
Official Minutes    | Carol    | contentious | 0.98

Same event, different named graphs, different moods, different confidence levels. The metagraph model does not force reconciliation — it preserves both perspectives and lets the query decide which to trust.


Comparison: Metagraph JSON-LD/Fluree vs. Flat Alternatives

CapabilityRDF triplesProperty graphMetagraph + FlureeN-ary relationshipsReification (verbose)Not nativeFirst-class E-nodesRelationships about relationshipsManual reificationImpossibleNative multipartite layersTemporal historyManually add timestampsManually add timestampsImmutable ledger, zero extra workTime-travel queriesNot standardPlugin/extensionNative as-ofProvenance per statementVerbose reificationNot supportedNamed graphs + prov:Multi-perspective knowledgeNamed graphsNot supportedS-nodes with named graphsCausal tracingGraph walk in SPARQLCypher path queryBidirectional metagraph traversalSchema enforcementSHACL/OWL externalType systemSHACL native, enforced at writeJSON interoperabilityJSON-LDVendor-specificJSON-LD native


When to Use This Stack

This combination — bipartite metagraph model + JSON-LD vocabulary + Fluree — is appropriate when:

  1. 1.

    Relationships are events you need to reason about, not just connections you need to traverse. When “Alice attended the meeting” has to be queried, annotated, and connected to other events, an E-node is the right representation.

  2. 2.

    History is part of the knowledge. AI agent memory requires knowing what was believed when, not just what is believed now. Fluree makes this automatic.

  3. 3.

    Provenance matters. Multi-agent systems where different agents hold different views of the same event need named-graph provenance, and JSON-LD provides the standard representation.

  4. 4.

    Causal reasoning is a query, not a procedure. When you need to ask “what chain of events led to this outcome and who was responsible?”, the metagraph’s causal E-nodes make this a standard SPARQL traversal.

  5. 5.

    Semantic interoperability is a requirement. JSON-LD vocabulary with proper URIs means your knowledge graph can be federated with other graphs that use the same vocabulary.

It is probably not the right choice for high-throughput write paths (Fluree’s immutable ledger pays a write cost), for purely transitive knowledge graphs with no meta-level reasoning, or for teams without RDF/SPARQL familiarity.


Conclusion

The move from triples to metagraphs is not a choice about databases — it is a choice about what kind of questions you need to ask. If your questions ever include “why did that happen?”, “who was involved in the chain of events?”, “what did we believe last week?”, or “how has this relationship changed over time?”, you need a knowledge model where relationships are things, not just connections.

The bipartite encoding makes that model practical today, without waiting for native metagraph databases. The three-layer structure — N-nodes for entities, E-nodes for events and relationships, S-nodes for contexts and episodes — maps cleanly to JSON-LD graphs and Fluree’s ledger model.

JSON-LD provides the vocabulary layer: globally unique identifiers for every type and property, named-graph containers for provenance, and prov: and SHACL integration for trust and constraint enforcement.

Fluree provides the persistence layer: every state of the knowledge graph preserved forever, time-travel queries as a first-class feature, and cryptographic provenance on every write.

Together they give you a knowledge system that does what agent memory actually needs to do: remember not just facts, but the context of how those facts came to be, when they changed, and what caused them.


This article is a companion to “Metagraphs for Agentic AI” by Volodymyr Pavlyshyn (in progress). The book covers the theory behind metagraph structures, formal definitions from Basu and Blanning, and complete implementations across Neo4j/Kuzu, TypeDB, PostgreSQL, and LadybugDB. The multipartite bipartite encoding in this article is developed in detail in Chapters 6 and 11.

https://leanpub.com/metagraphforaiagents


Originally published on Sovereign Agentic AI on Substack.