Skip to main content
The goldenmatch-extensions package runs GoldenMatch directly from SQL, without leaving the database. It ships a pgrx-based PostgreSQL extension and a DuckDB UDF package. goldenmatch-duckdb on PyPI goldenmatch-duckdb downloads goldenmatch-embed on PyPI goldenmatch_pg release

PostgreSQL

Install

The fastest path is the prebuilt Docker image with the extension preinstalled:
Prebuilt release tarballs (Linux x86_64, PostgreSQL 15/16/17) are attached to each goldenmatch-pg-v* release. Each tarball unpacks a pgrx package tree (the .so, the .control, and the SQL files) that you copy into your PostgreSQL install:
Other platforms build from source (cargo pgrx install) — see packages/rust/extensions/CLAUDE.md. Then enable it:

Functions

DuckDB

Registered UDFs:

Orientation from inside a session

A SQL connection is the surface with the least to read: no filesystem, no package to import, just function names. goldenmatch_docs() returns the packaged llms.txt so a tool — or an AI agent — can find the authoritative documentation instead of inferring behaviour from call signatures. It takes no arguments and depends on nothing else in the extension. On PostgreSQL the text is compiled into the shared library, so the function answers even in a backend where the Python bridge fails to initialise.

Graph and embedding kernels

These run native-direct in pure Rust, with no CPython round-trip. They expose GoldenMatch’s clustering primitives and the local embedder directly in SQL, on both backends (and as DataFusion FFI UDFs). One shared kernel backs all surfaces, so results are identical across them.

Connected components and pair dedupe

goldenmatch_connected_components groups a candidate-pair graph into entities, one component per entity, with singletons included. goldenmatch_pair_dedup canonicalizes a candidate-pair set and keeps the best score per pair. Both take the edge columns as lists. Pass integer record ids to the bare name, or string ids to the _str sibling.

Local embedding

goldenmatch_embed_local embeds text with a saved in-house model through the goldenembed ONNX runtime. No network and no API key. model_path is a directory holding config.json and model.onnx.
On PostgreSQL, gm_embed(text) is a one-argument convenience that reads the model directory from the GOLDENEMBED_MODEL_DIR environment variable instead of taking it per call, and returns real[] (float4) to match the DataFusion goldenmatch_embed UDF. The model loads once per backend process and is cached. A NULL input embeds the empty string rather than returning NULL.
PostgreSQL
The DuckDB embedding UDF needs the optional embed runtime: pip install goldenmatch-duckdb[embed].

Identity graph (stateful, PostgreSQL)

PostgreSQL can maintain a durable, event-sourced identity graph in-database: stable entity ids that survive across runs, incremental absorb of new records, steward corrections, a tamper-evident audit log, and MDM operator views. This is Postgres-only (it needs a durable multi-connection store); DuckDB stays the stateless dedupe surface. Point the extension at the database it runs in with a superuser GUC (or the GOLDENMATCH_IDENTITY_DSN / GOLDENMATCH_DATABASE_URL server env), then resolve a table into a named dataset:
The read functions serve that in-DB dataset when db_path is empty (pass a SQLite path or a libpq DSN to read an external store instead). Every function returns JSON identical to the MCP / REST / CLI surfaces.
The write functions (gm_resolve, gm_identity_merge / _split / _claim, gm_identity_resolve_conflict, gm_identity_audit_seal) commit on the store’s own connection to the configured DSN, not the caller’s SQL transaction; replay is idempotent. They require goldenmatch.identity_dsn (or the env fallback) to be set. Empty optional args (dataset, reason) mean “unset”.

Requirements

  • Python 3.11+
  • goldenmatch >= 1.1.0
  • DuckDB 1.0+ (DuckDB extension)
  • PostgreSQL 15, 16, or 17 (Postgres extension)
The scoring and table operations embed CPython through pyo3 and call the GoldenMatch Python API, so they match the Python package exactly. The graph and embedding kernels run native-direct in pure Rust with no CPython, sharing one kernel across DuckDB, PostgreSQL, and DataFusion.