Skip to main content

Provider-agnostic governance layer for AI agent memory: reuse-aware decay, confidence-gated recall injection, and memory-health metrics. Governs the memory you already have (mem0/Zep/vector DB) instead of storing it.

Project description

memgov

Provider-agnostic governance layer for AI agent memory. It doesn't store your memory — it governs the memory you already have (mem0 / Zep / a raw vector DB): decays it by recency × reuse, gates recall injection behind a confidence threshold so stale junk never reaches the prompt, and surfaces memory-health metrics. Local-first (SQLite), zero required deps, BYO store.

The problem

The 2025–2026 memory stores (mem0, Zep, LangMem, Letta) solved write and retrieve. But after a quarter of accumulation, teams hit the second-order problem: memory useful in week 1 is actively harmful in week 12, and nothing ages it out. Stores answer "what do I remember?" — none answer "what should I have forgotten, and what's safe to inject right now?" That's governance, and it's missing.

memgov fills that lane:

  • Reuse-aware decay — a tunable recency × reuse score, not a crude global TTL.
  • Confidence-gated recall — always search, but only inject when retrieval confidence clears a threshold and the memory isn't stale.
  • Memory healthactive / fading / stale ratios so silent degradation becomes observable before answers get bad.

Install

pip install memgov        # zero required deps

Python 3.11+.

Quick start

from memgov import Governor, Candidate

gov = Governor()                              # local SQLite sidecar

# register memories your store already holds, keyed by the store's native id
gov.track("mem-1", agent_id="bot")
gov.reinforce("mem-1", agent_id="bot")        # user restated it -> reinforce

gov.recompute(agent_id="bot")                 # recompute decay scores + states

# on recall: your store returns candidates; memgov gates what actually injects
candidates = [Candidate("mem-1", confidence=0.82),
              Candidate("mem-9", confidence=0.31)]   # low-confidence
inject = gov.gate(candidates, agent_id="bot")        # only the worthy ones
print([c.mem_id for c in inject])             # -> ['mem-1']

print(gov.health(agent_id="bot"))             # active/fading/stale snapshot

How it works

  • Sidecar metadata keyed by your store's native mem_id (memgov never holds the memory text — it tracks the signals decay needs).
  • track / touch / reinforce record usage signals; reinforce (user restated/confirmed) is the strongest keep signal.
  • recompute rescans an agent's memories and assigns decay_score (0..1) and a state: active | fading | stale | pinned.
  • gate is the core: it receives recall candidates and passes only those with confidence ≥ threshold and not stale. pin protects a memory from ever decaying.

See it (no deps, no API key)

python examples/demo_governance.py

Status

Early MVP (v0.1). Implemented: decay scorer, gate middleware, health metrics, SQLite sidecar, CLI. Planned: store adapters (mem0/Zep), MCP-server option, embedding-confidence helpers, health dashboard.

License

MIT.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

memgov-0.1.0.tar.gz (12.7 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

memgov-0.1.0-py3-none-any.whl (11.8 kB view details)

Uploaded Python 3

File details

Details for the file memgov-0.1.0.tar.gz.

File metadata

  • Download URL: memgov-0.1.0.tar.gz
  • Upload date:
  • Size: 12.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.5

File hashes

Hashes for memgov-0.1.0.tar.gz
Algorithm Hash digest
SHA256 d04b2a3d48b36aefc044802fe720c8a3d162005e1528eec78f7a233bda6afc8c
MD5 f148a23ae7f53aab1f6a69dbfeb1aff5
BLAKE2b-256 a35085a290839c728f2dce8627d0eaa01a153a8712d1a08f4a1a9aad96bbb38a

See more details on using hashes here.

File details

Details for the file memgov-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: memgov-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 11.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.5

File hashes

Hashes for memgov-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 da79dec3832168b4226ee14c35499e9e986ed5d7a9f634ea28168095244790a2
MD5 69c42087b48d2aeb49b8bc2da6b0b8ea
BLAKE2b-256 6d536c7a16441b1ad3d62ebb7e147ba89de0f5961d75902b7284618d7dba50cc

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page