Skip to content
pgmnemo

pgmnemo

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

Overview

IDExtensionPackageVersionCategoryLicenseLanguage
1900
pgmnemo
pgmnemo
0.8.3
RAG
Apache-2.0
SQL
AttributeHas BinaryHas LibraryNeed LoadHas DDLRelocatableTrusted
----dt-
No
No
No
Yes
no
yes
Relationships
Schemaspgmnemo
Requires
vector
See Also
vector
pg_search
pg_ai_query
pg_later

SQL-only extension; requires pgvector.

Packages

TypeRepoVersionPG Major CompatibilityPackage PatternDependencies
EXT
PIGSTY
0.8.3
18
17
16
15
14
pgmnemovector
RPM
PIGSTY
0.8.3
18
17
16
15
14
pgmnemo_$vpgvector
DEB
PIGSTY
0.8.3
18
17
16
15
14
postgresql-$v-pgmnemopgvector
Linux / PGPG18PG17PG16PG15PG14
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
PackageVersionOSORGSIZEFile URL
pgmnemo_180.7.2el8.x86_64pigsty80.9 KiBpgmnemo_18-0.7.2-1PIGSTY.el8.x86_64.rpm
pgmnemo_180.7.2el8.aarch64pigsty80.9 KiBpgmnemo_18-0.7.2-1PIGSTY.el8.aarch64.rpm
pgmnemo_180.7.2el9.x86_64pigsty77.9 KiBpgmnemo_18-0.7.2-1PIGSTY.el9.x86_64.rpm
pgmnemo_180.7.2el9.aarch64pigsty77.9 KiBpgmnemo_18-0.7.2-1PIGSTY.el9.aarch64.rpm
pgmnemo_180.7.2el10.x86_64pigsty78.1 KiBpgmnemo_18-0.7.2-1PIGSTY.el10.x86_64.rpm
pgmnemo_180.7.2el10.aarch64pigsty78.1 KiBpgmnemo_18-0.7.2-1PIGSTY.el10.aarch64.rpm
postgresql-18-pgmnemo0.7.2d12.x86_64pigsty68.7 KiBpostgresql-18-pgmnemo_0.7.2-1PIGSTY~bookworm_all.deb
postgresql-18-pgmnemo0.7.2d12.aarch64pigsty68.7 KiBpostgresql-18-pgmnemo_0.7.2-1PIGSTY~bookworm_all.deb
postgresql-18-pgmnemo0.7.2d13.x86_64pigsty68.7 KiBpostgresql-18-pgmnemo_0.7.2-1PIGSTY~trixie_all.deb
postgresql-18-pgmnemo0.7.2d13.aarch64pigsty68.7 KiBpostgresql-18-pgmnemo_0.7.2-1PIGSTY~trixie_all.deb
postgresql-18-pgmnemo0.7.2u22.x86_64pigsty70.4 KiBpostgresql-18-pgmnemo_0.7.2-1PIGSTY~jammy_all.deb
postgresql-18-pgmnemo0.7.2u22.aarch64pigsty70.4 KiBpostgresql-18-pgmnemo_0.7.2-1PIGSTY~jammy_all.deb
postgresql-18-pgmnemo0.7.2u24.x86_64pigsty70.2 KiBpostgresql-18-pgmnemo_0.7.2-1PIGSTY~noble_all.deb
postgresql-18-pgmnemo0.7.2u24.aarch64pigsty70.2 KiBpostgresql-18-pgmnemo_0.7.2-1PIGSTY~noble_all.deb
postgresql-18-pgmnemo0.7.2u26.x86_64pigsty70.2 KiBpostgresql-18-pgmnemo_0.7.2-1PIGSTY~resolute_all.deb
postgresql-18-pgmnemo0.7.2u26.aarch64pigsty70.2 KiBpostgresql-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