Writing Segments¶
A segment is UTF-8 text with one JSON object per line. Empty lines are ignored.
Node statements¶
{"node": "agent:ann", "labels": ["Agent", "Reviewer"], "props": {"name": "Ann", "skills": ["go", "sql"], "active": true}}
| Field | Required | Rules |
|---|---|---|
node |
yes | 1 to 512 bytes, no control characters |
labels |
no | Each a letter followed by up to 63 letters, digits or underscores. No repeats |
props |
no | See Properties |
Edge statements¶
{"edge": "FOLLOWS", "from": "agent:ann", "to": "agent:bob", "key": "2025", "props": {"since": 2025}}
| Field | Required | Rules |
|---|---|---|
edge |
yes | The type. Same rules as a label |
from, to |
yes | Node ids |
key |
no | Distinguishes parallel edges with the same type and endpoints |
props |
no | See Properties |
Properties¶
- Up to 64 properties per statement. Names follow the same rules as labels.
- Values are strings, numbers, booleans, or lists of those.
nulland nested objects are refused. - Numbers are stored as 64-bit floating point. Integers must be strictly between -2^53 and 2^53. Write larger integers as strings.
Limits and errors¶
- A line can be up to 64 KiB.
- The same node id, or the same edge identity, may appear only once in a segment. It may appear again in another segment.
- Unknown fields are refused, so a typing error cannot silently drop data.
- Names that start with an underscore are reserved.
Check a file before publishing it:
graphctl validate -file social.graph.jsonl
{"edges":2,"nodes":3,"valid":true}
A problem is reported with its line number, for example error: line 4: invalid label "_Admin".
Organizing segments¶
- Split by rate of change. A segment is replaced as a whole, so keep data that changes often in its own small segment.
- Split by topic so that withdrawing one topic is one
remove. - Use stable ids with a prefix, such as
agent:,doc:orteam:. Useauthor:<public key>for a person or agent that has a key: that id is shared with the system nodes and with every other graph.
Importing follow lists¶
graphctl follows reads follow lists (kind 3 events) from relays and writes them as a segment:
graphctl follows -relay ws://relay:8080 -out follows.graph.jsonl
Each author and each followed key becomes an author:<public key> node with the label Agent, and each follow becomes a FOLLOWS edge with the properties event (the id of the signed list) and at (its time). Only the newest list of each author is used. Self-follows, repeats and malformed keys are skipped. Use -author one or more times to restrict whose lists are read. The output is deterministic for the same input.