Gate what an AI agent's persistent memory may assert before the agent relies on it. Local-first, deterministic, stdlib-only (Python 3.11+).
Memory is a point-in-time snapshot, not live state.
memgov transplants the RCGov
axiom — InjectContext_t ⇒ ContextReady_t, govern what a model reads
before it answers — onto the memory layer of coding agents (Claude Code,
GPT Codex, and anything else whose memory is Markdown on disk).
Two agents share a workspace. Agent A's memory says a paper is "not yet deposited". In reality it was published yesterday — by a session that didn't update A's memory. A, trusting its memory, deposits it again.
Multiply that by every status-bearing claim agents write down: "awaiting review", "CI is broken", "tool X can't start". Each goes stale silently the moment another session, another agent, or the human changes the world.
- SHARED_STATE.md — a small, human-readable table of committed canonical live state: fact, current state (dated), verification anchor, and a key regex. The session that changes durable state overwrites the matching row — the row overwrite is the cross-agent handoff.
memgov scan— cross-store drift detection (the CONFLICT_MAP): flags memory lines that match a resolved row's key while still carrying a stale/status marker. Non-compensatory: flagged lines are a review queue, never auto-deleted; only verification clears them. Every pass appends to a measurement ledger (LEDGER.jsonl) — clean passes are evidence too.memgov fresh— freshness check: status-bearing memory files untouched for N days get flagged before an agent relies on them.memgov hook-context— one command that emits the SessionStart context block (SHARED_STATE + freshness + drift summary) in thehookSpecificOutputJSON schema accepted by both Claude Code and Codex hooks unchanged.
pip install . # or: run in-place with python3 -m memgov
cd /path/to/your/workspace
python3 -m memgov init # scaffolds memgov.toml + SHARED_STATE.md
$EDITOR memgov.toml # point [stores] at your agents' memory dirs
python3 -m memgov scan --summary
python3 -m memgov hook-context # what your agents will see at SessionStartThen wire the SessionStart hooks:
- Claude Code: merge
adapters/claude-code/settings.snippet.jsoninto~/.claude/settings.json; optionally installadapters/claude-code/skills/memory-restore/as a skill. - Codex: merge
adapters/codex/hooks.snippet.jsoninto<repo>/.codex/hooks.json; pasteadapters/codex/AGENTS.section.mdinto yourAGENTS.md.
- Status-bearing memories get an absolute date and a verify anchor (a command / path / API that yields ground truth).
- The session that changes state updates SHARED_STATE in the same session. The tooling is the safety net, not a license to write stale notes.
- Agents never edit each other's private stores; corrections flow through
SHARED_STATE rows. See
docs/MEMORY_GOVERNANCE_BASIS.template.mdfor the fill-in governance document.
memgov is the memory-domain sibling of
RCGov (context governor) and a
cousin of mmv-secretary
(session continuity clerk). Concept mapping: SHARED_STATE rows ≈ RCGov's
Authority Commitment Gate; scan output ≈ CONFLICT_MAP + Non-Injection
Report; the review-queue rule ≈ non-compensatory gating.
No embeddings, no LLM calls, no background daemon, no writes to your memory
stores (except the opt-in .last_restored marker). Detection is regex over
Markdown — conservative, auditable, tunable in memgov.toml.
python3 -m pytest tests/ -q # 10 tests, stdlib + pytest onlyA companion systems paper documents the motivating incident, the RCGov theory transplant, and the first measured detection-and-repair cycle:
Toeda, T. (2026). Memory Is Not Live State — Cross-Agent Memory Governance by Transplanting the Reflective Context Governor onto Agent Memory (memgov v0.1.0). MOBIUS LLC. DOI: 10.5281/zenodo.21231158.
See CITATION.cff for machine-readable metadata.
Code: AGPL-3.0-or-later. Documentation under docs/: CC BY-NC-SA 4.0
(see docs/LICENSE-DOCS.md).