Skip to content
ThirdLayer

Docs > Ontology and knowledge graph

Knowledge graph

Understand how Dex materializes Object records, typed links, co-occurrence edges, identity resolution, manual edits, and read-only Agent SQL.

Dex’s knowledge graph is the live, permissioned representation of your workspace’s people, companies, custom Objects, relationships, and interaction history.

Rather than maintaining a disconnected graph database that drifts from structured tables, Dex projects the knowledge graph directly over your workspace’s typed Postgres Object tables (zeta_store), relationship links, and provenance-backed observations. Every read—whether in Nexus, via dex zeta, or through Agent SQL—enforces the same row-level security rules.

Graph elementWhere it comes fromExample
NodesMaterialized Object records defined by your ontologyperson (“Maya Chen”), company (“Acme Corp”), commitment (“Send SOC 2 pack”)
Typed relationship edgesExplicit link fields (manyOne, oneMany, manyMany) between Object typesMaya Chen --company--> Acme Corp; Renewal Q4 --contacts--> [Maya Chen, Sam Lee]
Co-occurrence / activity edgesRecords that appear together in the same synced or manual observationTwo people and a company co-occurring in the same Slack thread, email, or meeting note

When a sync encounters a reference pointing to an entity that has not been synced yet, Dex stores a pending reference and automatically links the records once the target identity arrives.

As synced Datasets feed into Object mappings, Dex resolves records deterministically using the mapping’s cluster.keys:

  • Cross-source merging (scopedBy: "scope") — Rows from Gmail, Slack, and Attio that normalize to the same cluster key (such as maya@acme.com) fold into one person record inside that output Data Scope, combining fields by mapping priority.
  • Per-connection isolation (scopedBy: "connection") — Keys that are unique only within a single tool stay partitioned per provider connection.
  • Fail-closed on collisions — If one incoming source row asserts keys that already belong to two distinct records, Dex refuses to silently auto-merge them and records a mapping error (sync_error) for review.
  • Explicit merging with aliases — When you intentionally merge duplicate records (dex zeta records merge or in Nexus), Dex consolidates sources and identities onto the surviving record, trashes the duplicate, and records a record alias so existing references and old record UUIDs continue to resolve cleanly.

Synced records are not read-only. Both people and authorized agents can update fields on synced or manual records:

  • Manual edits win over syncs. Editing a cell records a cell_edit entry; future sync recomputations skip hand-edited cells so your corrections are never overwritten. Resetting a cell restores automatic synced folding.
  • Full audit trail. Record mutations log to record_history with their origin (user, agent, sync, merge, or system).
  • Safe deletion. Deleting a record snapshots it into trash (record_trash, restorable via dex zeta records restore) and marks synced source links as suppressed so the next sync pass does not resurrect a record you deleted.

Agents and users can query the knowledge graph in three ways:

1. Structured record queries (dex zeta records)

Section titled “1. Structured record queries (dex zeta records)”

Filter, search, page (up to 1,000 rows per page), aggregate, and inspect full provenance context:

Terminal window
# Inspect an Object's fields and supported filter operators
dex zeta objects get --object person
# Query with typed filters and aggregations
dex zeta records list --object commitment --filter '{"status":{"eq":"Open"}}' --limit 100
dex zeta records aggregate --object deal --group-by stage
# Inspect a record's source rows, evidence, and linked timeline events
dex zeta records context --object person --id <record-id>

When creating or updating records with loose inputs (such as "yes", formatted dates, select choice labels, or a linked record’s title), pass --typecast so Dex coerces values to each field’s schema.

For joins, counts, cohort comparisons, and multi-object analytics, Dex exposes a sandboxed read-only SQL interface over your workspace’s Object views (o_<object>) and Dataset views (d_<dataset>):

Terminal window
# Discover available views and lowercased column names first
dex zeta sql schema
# Run a single read-only SELECT (joins use <link_field>_id or <link_field>_ids)
dex zeta sql query "
SELECT c.name AS company, COUNT(p.id) AS contacts
FROM o_person p
JOIN o_company c ON p.company_id = c.id
GROUP BY c.name
ORDER BY contacts DESC
"

Security and runtime guarantees on Agent SQL:

  • Parsed with a Postgres AST validator (libpg-query): allows only a single SELECT over allowlisted workspace o_* and d_* views and safe SQL functions.
  • Executes inside a read-only transaction (SET LOCAL transaction_read_only = on) under a dedicated NOLOGIN workspace SQL role with caller RLS claims applied—every row is filtered to what the calling user is allowed to read.
  • Protected by a 10-second statement timeout and a 10,000-row / 5 MB response cap (1,000 rows by default; truncated: true signals you should aggregate or narrow the query).

When a recurring question needs a stable definition shared across people and agents, define a saved View (views/*.md) and query it with dex views query <id>.