The Model: a Labeled Property Graph with History
PARTIAL
ehgraph stores a labeled property graph: nodes and directed edges,
each with one type and a map of properties, plus the history of how
that graph changed. This page is the model at git f200516
(2026-11-10). It is PARTIAL for the same reason as the chapter: ehgraph
has no release tag, and the server embeds it behind
NOETL_EHGRAPH_EMBEDDED, off by default
(15.1). How to query the model is
15.3. How a batch becomes one version is
15.4.
The word label on this page is the graph type. A playbook tool-list label is a different term (Appendix G).
One type, and a property map
docs/wiki/Cypher.md §1 maps the store onto openCypher:
| In the store | What a query sees |
|---|---|
| A namespace | The graph. The request chooses it (namespace, /db/{namespace}, or Bolt database=). A query does not name the namespace |
A node's type, exactly one | Its label. (n:AccessPoint) matches type = "AccessPoint". A node with no type, or with a second type, is refused (15.3) |
An edge's type | The relationship type. Edges are directed |
props: string, int, float, bool, timestamp, list, or map | Properties. A timestamp is stored as a timestamp and reads back as {"$timestamp": "<rfc3339>"}. Timestamps compare with each other |
Caller-chosen string id | The reserved property id. It is never stored inside props. Matching {id: …} is a direct lookup |
Default edge id edge:{src}:{type}:{dst}:{origin} | One relationship for a (start, type, end) triple, unless the write gives the edge its own id |
JSON numbers with no fraction are integers (docs/wiki/API-and-MCP.md).
An edge whose src or dst is missing or inactive is rejected, and
the whole batch is rejected with it. ehgraph does not create a
placeholder node.
An optional file data_dir/schemas/<namespace>.json turns validation
on for that namespace. Without the file the namespace is schemaless.
With "strict": true, only declared types are accepted and required
properties must be present (docs/wiki/Getting-Started.md).
Each element also carries first_seen, last_seen, source,
origin, execution_id, and version_updated. Cypher reads them with
eh.firstSeen, eh.lastSeen, eh.source, eh.origin,
eh.executionId, eh.version, and eh.active.
Deleting keeps the history
DELETE and graph.deactivate soft-deactivate. The element stays,
with its history and its versions (docs/wiki/Cypher.md;
crates/ehgraph-cypher/src/exec.rs:80-81, as 15.3
cites). A deactivation bumps version_updated. MATCH and
graph.query see active elements unless the request asks for inactive
ones (active: false) or for either (active: "any").
MERGE on a deactivated id reactivates it. An identical upsert, same
ids and same content, writes nothing and does not bump the version.
The change log is the authority
Each namespace has its own monotonic graph_version. A write batch is
one framed record: magic || version || length || crc32 || json body,
with ehgraph's magic EHGR. The shape is the one EHDB's L0 log uses.
The process does not link EHDB and does not write an EHDB dataset
(docs/wiki/Architecture.md; the README states the same boundary).
A write is acknowledged only after the frame is fsynced and the head pointer is published. If the process dies after the frame is durable and before the head file moves, the next open fast-forwards the head. A torn tail is truncated and ignored.
Replaying a batch with the same idempotency key does not change state
or version. An identical upsert with no key is also a no-op. Keys are
remembered per namespace for a bounded window (docs/wiki/API-and-MCP.md):
- Time (DEFAULT):
[store] idempotency_window_s, 24 hours, measured on the log clock (the highest committedts_ms, which never goes backwards), not on the wall clock (crates/ehgraph/src/config.rs:155-157). - Count (DEFAULT):
[store] idempotency_max_keys, 100,000. The oldest keys go first (config.rs:159-161).
Inside the window, the same key with a different payload is
CONFLICT. After the key is forgotten, a retry is a new write planned
against the current graph: an unchanged upsert is still a no-op, a
retry that lands after someone else changed those elements re-applies
the old payload, and a reused key with a different payload is accepted.
Parts seal on size, on record count, or on age. The defaults are 8 MiB,
1,024 records, and 30 seconds, and the age seal is on
(config.rs:367-375, default_seal_age). Sealed parts are immutable.
That age bound is how long a record can sit in the unshipped tail a
backup can still lose (15.6).
Materialized state and session graphs are derived. Deleting
namespaces/<name>/derived/ and reopening rebuilds them from full
snapshots plus the log.
Snapshots and session graphs
graph.snapshot.create writes an Arrow IPC snapshot at the current
head. The scope defaults to the full namespace.
A session opens explicitly (graph.session.open) or on first use. The
server loads one scope — the full namespace, a property filter, a k-hop
neighbourhood, or a named snapshot — builds Arrow record batches and a
CSR adjacency index, and pins that graph_version. Later reads in the
session do not touch the log. graph.session.refresh builds a new
graph and swaps it in. A read that started before the swap finishes on
the old version.
Sessions are read-only. A write that names a graph_session_id returns
READ_ONLY_SESSION. Writes go to the log and show up in the session
only after a refresh.
Memory has a per-session cap and a global budget
(15.6). On overflow the server drops only
sessions that are already closed or expired, then returns
MEMORY_BUDGET_EXCEEDED. It does not evict an active session. The
idle timeout is 300 seconds and the maximum lifetime is 24 hours
(DEFAULT, config.rs:358-363). A later read with that id returns
SESSION_EXPIRED.
Two owners who load the same scope get two resident graphs. Copies are not shared. Concurrent first loads for the same owner and the same scope share one load.
One primary per topology domain
You run one instance per purpose. The README's examples are
ehgraph-noetl-cluster (embedded in the server) and ehgraph-network
(standalone, for qnetmon). Each instance is a single primary. Instances
do not know about each other. Read replicas are named in the config and
refused at open (15.7).
One process holds an exclusive lock on data_dir/LOCK. A second
process on that directory is refused, and so is a second handle in the
same process. EhGraph::open calls ensure_primary before it serves
(crates/ehgraph/src/lib.rs:188). role = "replica" and
role = "standby" return UNAVAILABLE: "read replicas and standby are
not enabled" (crates/ehgraph-api/src/dispatch.rs:1272-1278).
docs/wiki/Roadmap.md assumes these graphs fit in one node's memory,
up to about 10⁶ elements, and says to scale by adding instances rather
than by splitting one namespace. That size is an assumption
(GUIDANCE), not a measurement taken for this page. Sharding is
deferred until a measured domain does not fit.