MindGraphDocs

Connect a database

Bind a SQL database to your Operational Ontology and MindGraph reads its shape, drafts a typed ontology from your schema, and syncs your rows in as objects — then fuses them with what your documents and conversations say about the same things. Postgres today; read-only, always.

Note:MindGraph is powered by MnesticDB. Postgres is an optional read-only source connector: indexed projections are stored in MnesticDB, while live fields are fetched from the source on demand. Postgres is not MindGraph's database engine.
Note:This is the “connect” authoring path, a peer to authoring a schema by hand or proposing one from documents. It runs from the dashboard (Dashboard → Ontology → Connect a database); connection management is intentionally not in the SDKs (credential custody stays in one audited place).

Prerequisites

  • A Postgres database reachable over TLS from the public internet — managed Postgres like Neon, Supabase, or RDS-public. (VPC-only databases aren't supported yet; the egress guard refuses private/internal addresses.)
  • A least-privilege read-only role. We never write back.
create a read-only role
CREATE ROLE mindgraph_ro LOGIN PASSWORD '…';
GRANT CONNECT ON DATABASE app TO mindgraph_ro;
GRANT USAGE ON SCHEMA public TO mindgraph_ro;
GRANT SELECT ON ALL TABLES IN SCHEMA public TO mindgraph_ro;
Note:Managed providers (e.g. Neon) hand out connection strings with channel_binding=require — that's fine, MindGraph normalizes it. Credentials are AES-256-GCM encrypted at rest; the host is resolved, validated against a private-range blocklist, pinned, and dialed over forced TLS (SSRF-hardened). The connection string is never logged.

The flow

  1. Connect. Enter the read-only Postgres connection (host/port/db/user/password, or a connection string). We test-connect before storing.
  2. Introspect. Pick the tables that matter — MindGraph lists them with their columns, primary keys, and foreign keys.
  3. Propose from your schema. An LLM drafts semantic object types (a customers table → a Customer, not a tbl_cust), maps each field to its column, classifies fields indexed vs live, picks a primary key + title, and turns foreign keys into typed relations — all with backing pre-filled into a draft schema.
  4. Review & activate. In the Mapped Data tab, confirm field→column mappings, the primary key, and the title; flip indexed/live; drop noise. Confirming the PK and title is required — a wrong PK silently dup/loses objects. Activate.
  5. Sync. “Sync now” per object type (and “Sync edges” per relation) projects your rows as thin Layer::Ontology objects.

Indexed vs live fields

  • indexed — projected into the node, embedded, searchable, and reasoned-about (contradiction-checkable). Use for identity / searchable / slow-changing fields (name, status, tier).
  • live — declared but never stored; fetched from the source on demand at read time. Use for volatile or bulky fields (balances, running totals, timestamps, blobs). Never stale, never copied.

Sync semantics

  • Manual for now — “Sync now” is on demand; scheduled/incremental auto-sync is coming. You control (and see) every sync, so there's no silent background cost.
  • Idempotent — each row maps to a deterministic node id, so re-sync updates in place rather than duplicating.
  • Incremental or full — incremental advances by a cursor column; a full pass reads everything and can tombstone rows that vanished from the source (deletes are never hard-deletes, and reappearing rows are restored).
  • Read-only projection — the external DB remains authoritative for mapped fields; MindGraph indexes a projection in MnesticDB and owns the cognitive overlay. No writeback.

Query it

Once synced, agents reach your objects through generated read tools (see Operational Ontology). summarize_<obj> is the payoff — the live database row plus the claims, risks, and decisions your documents added to it:

const result = await mg.queryOntology({
  query: "What's going on with Acme Corp?",
  include_cognitive_context: true,
});
// → the Customer row (tier, value) AND the call-note claims
//   (frustrated with onboarding, churn risk) — fused, with sources.
Warning:v1 limitations: Postgres only; public-TLS endpoint required; read-only (no writeback); manual “Sync now” (scheduled sync is inert); delete detection runs on a full pass or a mapped deleted_at column (cursor-incremental sync can't see deletes).