
amu-pgvector
io.github.sangaraju1988由 GitHub 帳號 sangaraju1988 發布v0.1.3更新於 Oct 28, 2026
Lineage-gated agent memory tools on Postgres + pgvector, enforced by row-level security.
概覽
以 Postgres + pgvector 實作的譜系閘控代理記憶:儲存快取結果,只回傳給有權檢視其來源欄位的資料庫角色。
- 可以做什麼
- 以語意搜尋已儲存的記憶單元,結果依請求角色的權限過濾
- 記錄快取結果及產生它的 SQL,藉此擷取其資料譜系
- 在重用或新增結果前檢查指標定義是否衝突
- 所有讀寫都經過 Postgres 資料列層級安全性,原生 SQL、Python 用戶端、LangChain 與此伺服器共用同一道閘門
- 適用情境
- 適合多個代理或部門共用快取結果記憶,且需要避免某團隊的衍生數值外洩給無權檢視底層欄位的團隊時使用。也適合需要對指標定義做衝突偵測的情境。
- 執行需求
- 以 uvx 從 PyPI 套件(含 mcp 附加項)在使用者本機執行的程序。需要已安裝 pgvector 擴充並匯入專案 SQL 結構的 PostgreSQL 資料庫,以及透過 AMU_PGVECTOR_DSN 提供的 Postgres DSN,供伺服器所用角色連線;該角色須為 amu_writer 成員才能記錄或檢查衝突。使用內建備援嵌入器時,AMU_PGVECTOR_EMBEDDING_DIM 必須與結構中的向量維度一致。
安裝
在 SourceWeft 中
- 開啟 儀表板中的 amu-pgvector,將其新增到工作區。
- 為需要使用其工具的對話啟用該服務。
Desktop only,透過 STDIO。 STDIO 服務會啟動本機處理程序,因此需要 SourceWeft 桌面主機。
其他 MCP 客戶端
參照 儲存庫 中的啟動說明。
README
amu-pgvector
Reference implementation of Lineage-Aware Memory Governance (Sangaraju & Vissa, IEEE Access, 10.1109/ACCESS.2026.3730363) on PostgreSQL + pgvector.
The problem
Say Finance computes avg(income) for a customer segment and caches the
result so the next agent that asks the same question doesn't have to
recompute it. Later, a Marketing agent asks a semantically similar
question -- "what's the average customer income by segment?" -- and a
naive shared memory, gated only on the metric's name or content tags,
serves back Finance's cached result. Marketing was never permitted to see
income. The result itself doesn't look like income -- it's a number --
but it was derived from a column Marketing isn't permitted to touch,
and nothing about matching on metric name or content catches that. That's
the leak this project closes: gating reuse on how a result was derived,
not on what it looks like.
60-second quickstart
Every line above was run against this exact repo before being written
here (see docs/design.md for what a from-scratch install actually looks
like). amu_owner/amu_owner_password is the docker-compose default --
change it for anything beyond local development.
How the gate works
amu.memory_units is a normal Postgres table with FORCE ROW LEVEL SECURITY enabled. Every write goes through a trigger that extracts the
lineage of the SQL that actually produced the cached result (via
amu-governance's
sql_lineage module -- not self-reported by the agent), closes it over any
registered materialized-view/derived-table edges, and computes S(a): the
set of sensitive columns that lineage actually touches. A SELECT policy
enforces S(a) ⊆ P(d) -- the row is visible only if every column in S(a)
is in the requesting role's permitted set P(d) -- for every query against
the table, from every client: raw SQL, amu.search(), the Python client,
the LangChain integration, and the MCP server all go through the same
policy, because it's the table's policy, not any one client's filter.
See docs/design.md for how every paper concept maps to
a specific SQL object, and docs/sql-reference.md
for an exhaustive reference of every table, function, role and policy.
Security model and limits
Protected: cross-department leakage of a cached result's derivation
columns (the core guarantee, enforced by RLS); silent metric-definition
conflicts (amu.check_conflict()); a column reclassified as sensitive
after AMUs already exist (a trigger recomputes affected rows, no
rewrite needed); lineage closure that silently truncates a long or cyclic
derivation chain (fails closed -- marks the AMU unresolved and invisible,
rather than serving a partially-traced result).
Explicitly out of scope: a writer that lies about lineage (the SQL
gate trusts amu_writer's input by design); inference by combining
several individually-permitted AMUs; Postgres superusers, who always
bypass RLS; timing side channels; a "convenience mode" identity option
(off by default) that's only as safe as the boundary between trusted
application code and agent-influenced code on a pooled connection.
Full writeup: docs/threat-model.md.
Benchmarks
Every number below is quoted directly from
results/SUMMARY.md, generated by
benchmarks/generate_summary.py from committed results/<name>/<timestamp>/
runs (git SHA, Postgres/pgvector versions, hardware, seed and parameters
in each run's manifest.json). Re-run the benchmark scripts yourself to
reproduce or challenge these; nothing here is estimated.
Leak rate (2000 requests over 600 synthetic AMUs, Finance/Marketing/Support):
Latency (p50/p95 at k=10; RLS and hnsw.iterative_scan each on/off,
same role/queries/data per row):
Read honestly: hnsw.iterative_scan=relaxed_order (what amu.search()
uses by default, so that filtered results still hit k even when most rows
are hidden) costs real latency at scale -- roughly 16x slower than
iterative-off at 100k rows in this run. That's the price of the recall
guarantee below; if your visible fraction is consistently high, you may
prefer to query without it. 1M-row scale was not attempted: the 100k HNSW
index build alone took about 7 minutes on the machine this was run on
(Docker Desktop on macOS, sharing the host with unrelated workloads) --
recorded honestly rather than extrapolated.
Filtered recall (recall@10 of gated HNSW search vs. exact brute-force over the same role's actually-visible rows, n=20,000):
Integrations
- Plain SQL --
sql/amu_pgvector.sqlis the artifact that matters most: idempotent, installs on a managed Postgres as a normal database owner (no superuser), no C extensions beyondvector. Works identically on Supabase and Neon (seesubmissions/supabase-neon-guide.mdfor a from-scratch tutorial covering both). - LangChain --
langchain-amuprovidesAMUVectorStoreandAMURetriever. Every read runs under the store's own Postgres role, so RLS gates LangChain the same way it gates raw SQL. Seepackages/langchain-amu/. - MCP --
pip install amu-pgvector[mcp]adds anamu-pgvector-mcpconsole script exposingamu_search,amu_recordandamu_check_conflictas tools, gated the same way. Seepackages/amu-pgvector/src/amu_pgvector/mcp_server.py.
Citation
See CITATION.cff to also cite this software directly.
License
MIT. See LICENSE.
Related
- Paper: Sangaraju & Vissa, IEEE Access, DOI 10.1109/ACCESS.2026.3730363
- Reference library: amu-governance (PyPI)
docs/design.md-- paper concepts mapped to SQL objects, plus every real gotcha found while building thisdocs/threat-model.md-- what's protected, what's notdocs/sql-reference.md-- every table, function, role and policy
來源:README.md,提交 ad181f7
工具
0版本歷史
2- v0.1.3最新Oct 1, 2026
- v0.1.2Sep 29, 2026
評分
已滿足適用檢查項的 50%
該評分衡量此收錄條目的完整程度,依據註冊中心條目、端點與公開來源計算得出。它不是對伺服器本身的評價,也不表示伺服器安全或目前可用:可連通性是帶日期的檢查結果,評分也不包含安裝量或使用者評價。
- 近 30 天內可連通25 分
請保持端點能夠回應 MCP 握手;SourceWeft 每 30 天探測一次。
- 已宣告認證方式10 分
請在註冊中心條目中宣告憑證請求標頭,或保持端點能夠回應探測,以便判定其認證方式。
- 已列出工具15 分
請讓伺服器在無憑證時回應 tools/list,或發布可在沙箱中無憑證啟動的軟體包。
- 描述必需15 分
- 圖示10 分
- 文件15 分
- 授權條款10 分