Skip to content
pgmnemo

pgmnemo

pgmnemo : Provenance-gated vector memory for LLM agents in PostgreSQL

Overview

ID Extension Package Version Category License Language
1900
pgmnemo
pgmnemo
0.8.3
RAG
Apache-2.0
SQL
Attribute Has Binary Has Library Need Load Has DDL Relocatable Trusted
----dt-
No
No
No
Yes
no
yes
Relationships
Schemas pgmnemo
Requires
vector
See Also
vector
pg_search
pg_ai_query
pg_later

SQL-only extension; requires pgvector.

Packages

Type Repo Version PG Major Compatibility Package Pattern Dependencies
EXT
PIGSTY
0.8.3
18
17
16
15
14
pgmnemo vector
RPM
PIGSTY
0.8.3
18
17
16
15
14
pgmnemo_$v pgvector
DEB
PIGSTY
0.8.3
18
17
16
15
14
postgresql-$v-pgmnemo pgvector
Linux / PG PG18 PG17 PG16 PG15 PG14
el8.x86_64
PIGSTY 0.7.2
PIGSTY 0.7.2
PIGSTY 0.7.2
PIGSTY 0.7.2
PIGSTY 0.7.2
el8.aarch64
PIGSTY 0.7.2
PIGSTY 0.7.2
PIGSTY 0.7.2
PIGSTY 0.7.2
PIGSTY 0.7.2
el9.x86_64
PIGSTY 0.7.2
PIGSTY 0.7.2
PIGSTY 0.7.2
PIGSTY 0.7.2
PIGSTY 0.7.2
el9.aarch64
PIGSTY 0.7.2
PIGSTY 0.7.2
PIGSTY 0.7.2
PIGSTY 0.7.2
PIGSTY 0.7.2
el10.x86_64
PIGSTY 0.7.2
PIGSTY 0.7.2
PIGSTY 0.7.2
PIGSTY 0.7.2
PIGSTY 0.7.2
el10.aarch64
PIGSTY 0.7.2
PIGSTY 0.7.2
PIGSTY 0.7.2
PIGSTY 0.7.2
PIGSTY 0.7.2
d12.x86_64
PIGSTY 0.7.2
PIGSTY 0.7.2
PIGSTY 0.7.2
PIGSTY 0.7.2
PIGSTY 0.7.2
d12.aarch64
PIGSTY 0.7.2
PIGSTY 0.7.2
PIGSTY 0.7.2
PIGSTY 0.7.2
PIGSTY 0.7.2
d13.x86_64
PIGSTY 0.7.2
PIGSTY 0.7.2
PIGSTY 0.7.2
PIGSTY 0.7.2
PIGSTY 0.7.2
d13.aarch64
PIGSTY 0.7.2
PIGSTY 0.7.2
PIGSTY 0.7.2
PIGSTY 0.7.2
PIGSTY 0.7.2
u22.x86_64
PIGSTY 0.7.2
PIGSTY 0.7.2
PIGSTY 0.7.2
PIGSTY 0.7.2
PIGSTY 0.7.2
u22.aarch64
PIGSTY 0.7.2
PIGSTY 0.7.2
PIGSTY 0.7.2
PIGSTY 0.7.2
PIGSTY 0.7.2
u24.x86_64
PIGSTY 0.7.2
PIGSTY 0.7.2
PIGSTY 0.7.2
PIGSTY 0.7.2
PIGSTY 0.7.2
u24.aarch64
PIGSTY 0.7.2
PIGSTY 0.7.2
PIGSTY 0.7.2
PIGSTY 0.7.2
PIGSTY 0.7.2
u26.x86_64
PIGSTY 0.7.2
PIGSTY 0.7.2
PIGSTY 0.7.2
PIGSTY 0.7.2
PIGSTY 0.7.2
u26.aarch64
PIGSTY 0.7.2
PIGSTY 0.7.2
PIGSTY 0.7.2
PIGSTY 0.7.2
PIGSTY 0.7.2
Package Version OS ORG SIZE File URL
pgmnemo_18 0.7.2 el8.x86_64 pigsty 80.9 KiB pgmnemo_18-0.7.2-1PIGSTY.el8.x86_64.rpm
pgmnemo_18 0.7.2 el8.aarch64 pigsty 80.9 KiB pgmnemo_18-0.7.2-1PIGSTY.el8.aarch64.rpm
pgmnemo_18 0.7.2 el9.x86_64 pigsty 77.9 KiB pgmnemo_18-0.7.2-1PIGSTY.el9.x86_64.rpm
pgmnemo_18 0.7.2 el9.aarch64 pigsty 77.9 KiB pgmnemo_18-0.7.2-1PIGSTY.el9.aarch64.rpm
pgmnemo_18 0.7.2 el10.x86_64 pigsty 78.1 KiB pgmnemo_18-0.7.2-1PIGSTY.el10.x86_64.rpm
pgmnemo_18 0.7.2 el10.aarch64 pigsty 78.1 KiB pgmnemo_18-0.7.2-1PIGSTY.el10.aarch64.rpm
postgresql-18-pgmnemo 0.7.2 d12.x86_64 pigsty 68.7 KiB postgresql-18-pgmnemo_0.7.2-1PIGSTY~bookworm_all.deb
postgresql-18-pgmnemo 0.7.2 d12.aarch64 pigsty 68.7 KiB postgresql-18-pgmnemo_0.7.2-1PIGSTY~bookworm_all.deb
postgresql-18-pgmnemo 0.7.2 d13.x86_64 pigsty 68.7 KiB postgresql-18-pgmnemo_0.7.2-1PIGSTY~trixie_all.deb
postgresql-18-pgmnemo 0.7.2 d13.aarch64 pigsty 68.7 KiB postgresql-18-pgmnemo_0.7.2-1PIGSTY~trixie_all.deb
postgresql-18-pgmnemo 0.7.2 u22.x86_64 pigsty 70.4 KiB postgresql-18-pgmnemo_0.7.2-1PIGSTY~jammy_all.deb
postgresql-18-pgmnemo 0.7.2 u22.aarch64 pigsty 70.4 KiB postgresql-18-pgmnemo_0.7.2-1PIGSTY~jammy_all.deb
postgresql-18-pgmnemo 0.7.2 u24.x86_64 pigsty 70.2 KiB postgresql-18-pgmnemo_0.7.2-1PIGSTY~noble_all.deb
postgresql-18-pgmnemo 0.7.2 u24.aarch64 pigsty 70.2 KiB postgresql-18-pgmnemo_0.7.2-1PIGSTY~noble_all.deb
postgresql-18-pgmnemo 0.7.2 u26.x86_64 pigsty 70.2 KiB postgresql-18-pgmnemo_0.7.2-1PIGSTY~resolute_all.deb
postgresql-18-pgmnemo 0.7.2 u26.aarch64 pigsty 70.2 KiB postgresql-18-pgmnemo_0.7.2-1PIGSTY~resolute_all.deb

Source

pig build pkg pgmnemo;		# build rpm/deb

Install

Make sure PGDG and PIGSTY repo available:

pig repo add pgsql -u   # add both repo and update cache

Install this extension with pig:

pig install pgmnemo;		# install via package name, for the active PG version

pig install pgmnemo -v 18;   # install for PG 18
pig install pgmnemo -v 17;   # install for PG 17
pig install pgmnemo -v 16;   # install for PG 16
pig install pgmnemo -v 15;   # install for PG 15
pig install pgmnemo -v 14;   # install for PG 14

Create this extension with:

CREATE EXTENSION pgmnemo CASCADE; -- requires vector

Source: pgmnemo v0.8.3 README, Usage Guide, extension control file, SQL definition.

Usage

pgmnemo stores provenance-gated agent lessons in PostgreSQL and retrieves them through vector, BM25-style text, graph-edge, JSONB metadata, and relational filters. The extension control file requires vector, so pgvector must be available before creating pgmnemo. The local package metadata targets PostgreSQL 14-18.

Create and Ingest Lessons

CREATE EXTENSION IF NOT EXISTS vector;
CREATE EXTENSION IF NOT EXISTS pgmnemo CASCADE;

SELECT pgmnemo.ingest(
  p_role        := 'developer',
  p_project_id  := 1,
  p_topic       := 'security',
  p_lesson_text := 'Rotate JWT secrets after any key-compromise incident.',
  p_importance  := 4,
  p_embedding   := NULL,
  p_commit_sha  := 'abc1234',
  p_metadata    := '{"source":"incident-runbook"}'::jsonb
);

pgmnemo.ingest() is the preferred write path. It validates the 1024-dimensional embedding when supplied, stamps verified rows when provenance is present, and applies the provenance gate.

Provenance Gate

SHOW pgmnemo.gate_strict;

SET pgmnemo.gate_strict = 'warn';
SET pgmnemo.gate_strict = 'enforce';

pgmnemo.gate_strict accepts enforce, warn, or off. In the default enforced mode, inserts fail when both p_commit_sha and p_artifact_hash are NULL. pgmnemo.include_unverified is separate: it controls whether unverified rows are eligible for recall, not whether writes are allowed.

Recall

-- Text-only recall.
SELECT topic, lesson_text, score
FROM pgmnemo.recall_lessons(
  NULL::vector(1024),
  5,
  'developer',
  1,
  'JWT secret rotation'
);

-- Hybrid vector and text recall.
SELECT lesson_id, topic, score, vec_score, bm25_score, rrf_score
FROM pgmnemo.recall_hybrid(
  '<1024-dimensional vector literal>'::vector(1024),
  'JWT rotation key compromise',
  10,
  'developer',
  1
);

Hybrid routing in recall_lessons() requires pgmnemo.disable_hybrid to be off, non-empty query_text, and a non-NULL embedding. Use recall_hybrid() directly when you want explicit diagnostic scores.

Navigation and Expansion

SELECT *
FROM pgmnemo.navigate_locate(
  NULL::vector(1024),
  'JWT rotation',
  10,
  'developer',
  1,
  '{"topic":"security"}'::jsonb,
  2000
);

SELECT *
FROM pgmnemo.navigate_expand(
  ARRAY[1001, 1002]::bigint[],
  include_edges := true
);

navigate_locate() returns ranked lesson IDs and short previews within a character budget. navigate_expand() fetches selected full lessons and optional graph neighbors after the caller chooses which IDs are worth expanding.

Edges and Outcome Learning

SELECT pgmnemo.add_edge(1001, 1002, 'CAUSED_BY', 0.85, '{"run_id":7320}'::jsonb);

SELECT pgmnemo.reinforce(1001, 'success');
SELECT pgmnemo.reinforce(1002, 'failure');

pgmnemo.add_edge() is the idempotent helper for lesson relationships. reinforce() adjusts confidence after observed outcomes and feeds later match confidence.

Maintenance and GUCs

SELECT * FROM pgmnemo.stats();

SELECT pgmnemo.reembed(
  p_lesson_id  := 1001,
  p_new_vector := '<1024-dimensional vector literal>'::vector(1024)
);

SELECT pgmnemo.recompute_content(
  p_lesson_id       := 1001,
  p_new_lesson_text := 'Rotate JWT secrets within 24 hours after compromise.'
);

Useful settings include pgmnemo.gate_strict, pgmnemo.include_unverified, pgmnemo.ef_search, pgmnemo.disable_hybrid, pgmnemo.recency_weight, pgmnemo.importance_weight, pgmnemo.graph_proximity_weight, pgmnemo.temporal_boost, and pgmnemo.max_query_text_chars.

Last updated on