MemoryGuard
Governed shared memory for coding agents.
Local-first MCP memory with automatic organization, scoped rules, evidence, and rollback.
Let agents write without turning shared memory into an unreviewed pile. MemoryGuard organizes each write, preserves the evidence behind changes, and keeps governance decisions reversible.
No account. No remote server. No telemetry. Memory stays local.
Quick start · Upgrade · Knowledge Library · Architecture · Supported hosts · Privacy and safety
A synthetic governed projection: signals move through memory categories while raw conversation text remains outside the graph.
What's New in v0.5.2
- Canonical rule reconciliation: durable rule-intelligence jobs, source links, evidence anchors, projection parity, and a safe legacy fallback until readiness is proven.
- Physically read-only diagnostics: canonical status, rule reads, and governance diagnostics never enter a write transaction; live WAL readers observe concurrent committed writes without
immutable=1. - Multi-process runtime lease: MCP processes sharing one workspace reject writes from a different build instead of allowing split-brain state changes.
- Desktop and neuron graph: fixed workspace launch, detached native window, folder-style rule habits, subtree drag, denser outward pulses, and connected category links.
- History and Knowledge Library fixes: history mojibake repair and dual-write reconciliation; knowledge deletion now trusts scan results and protects stale indexes after partial scans.
Why MemoryGuard
Persistent memory solves storage. It does not solve governance.
When several coding agents write into the same context, records become duplicated, stale, contradictory, over-broad, or unsafe to reuse. MemoryGuard sits between coding agents and their shared memory to keep that context usable.
| Without governance | With MemoryGuard |
|---|---|
| Notes accumulate without a canonical state | Writes are classified, deduplicated, superseded, or surfaced as conflicts |
| A correction silently destroys the old value | Evidence and supersede chains preserve what changed and why |
| Tokens and credentials can remain active | Sensitive-looking content is quarantined from active memory |
| Every write needs manual approval | Agents write normally; people review exceptions and outcomes |
| Raw chat logs leak into future context | Conversation history remains a separate, explicitly read evidence archive |
System architecture
%%{init: {"theme":"base","themeVariables":{"background":"#071521","fontFamily":"Arial, sans-serif","fontSize":"14px","primaryTextColor":"#EEF4F8","lineColor":"#557287","edgeLabelBackground":"#071521","clusterBkg":"#0A1A29","clusterBorder":"#27445A"},"flowchart":{"htmlLabels":true,"curve":"basis","nodeSpacing":32,"rankSpacing":48,"padding":14}}}%%
flowchart TB
Hosts["CODING-AGENT HOSTS<br/>Claude Code · Codex · Cursor · TRAE "]:::host
Gateway["LOCAL INTEGRATION<br/>MCP stdio · redirect rules · lifecycle hooks "]:::gateway
subgraph Core["GOVERNANCE CORE "]
direction LR
Identity["TRUST<br/>identity · scope "]:::core
MemoryAPI["MEMORY<br/>governed I/O "]:::active
Rules["RULES<br/>scope · assignment "]:::rule
HistoryAPI["HISTORY<br/>search · timeline "]:::history
Security["SAFETY<br/>validate · quarantine "]:::danger
Identity --> MemoryAPI
Identity --> Rules
Identity --> HistoryAPI
MemoryAPI --> Security
end
subgraph Stores["LOCAL GOVERNED STORES "]
direction LR
SharedDB[("MEMORY STORE<br/>records · rules · evidence ")]:::store
HistoryDB[("HISTORY STORE<br/>isolated conversations ")]:::historyStore
AuditDB[("RECOVERY STORE<br/>versions · receipts · backups ")]:::store
end
Bootstrap["BOUNDED CONTEXT BOOTSTRAP<br/>mandatory rule pack · relevant recall "]:::bootstrap
Control["HUMAN CONTROL<br/>CLI · desktop governance console "]:::surface
Hosts --> Gateway --> Identity
MemoryAPI --> SharedDB
Rules --> SharedDB
HistoryAPI --> HistoryDB
Security --> AuditDB
SharedDB --> Bootstrap
Control --> Identity
classDef host fill:#12243A,stroke:#38D5C8,color:#EEF4F8,stroke-width:1.4px;
classDef gateway fill:#0D3338,stroke:#38D5C8,color:#EEF4F8,stroke-width:2.4px;
classDef core fill:#12243A,stroke:#557287,color:#EEF4F8,stroke-width:1.4px;
classDef active fill:#0D383A,stroke:#38D5C8,color:#EEF4F8,stroke-width:2px;
classDef rule fill:#3B2C18,stroke:#F3B562,color:#EEF4F8,stroke-width:1.8px;
classDef history fill:#102F45,stroke:#73C7F5,color:#EEF4F8,stroke-width:1.8px;
classDef danger fill:#3A2028,stroke:#EA6A6A,color:#EEF4F8,stroke-width:1.8px;
classDef bootstrap fill:#EEF4F8,stroke:#38D5C8,color:#071521,stroke-width:2.4px;
classDef store fill:#0B1624,stroke:#7F96A8,color:#EEF4F8,stroke-width:1.4px;
classDef historyStore fill:#102436,stroke:#73C7F5,color:#EEF4F8,stroke-width:1.4px;
classDef surface fill:#EEF4F8,stroke:#38D5C8,color:#071521,stroke-width:2px;
style Core fill:#081827,stroke:#27445A,stroke-width:1px,color:#EEF4F8
style Stores fill:#081827,stroke:#27445A,stroke-width:1px,color:#EEF4F8
linkStyle default stroke:#557287,stroke-width:1.4px;
Quick start
1. Install
python -m pip install agent-memguard
For the desktop governance console:
python -m pip install "agent-memguard[gui]"
2. Authorize the current project
memoryguard source add .
3. Connect your coding agent
Run one provider installer:
# Claude Code
python -m memoryguard.provider_adapters install claude
# Codex
python -m memoryguard.provider_adapters install codex
# Cursor
python -m memoryguard.provider_adapters install cursor
Restart the host after installation, then verify the integration:
memoryguard doctor
memoryguard mcp-status
memoryguard hooks status --provider all
Launch the desktop console:
memoryguard gui
memoryguard-gui . remains available for desktop shortcuts. In PowerShell and
other terminals, use memoryguard gui . so startup errors remain visible.
With no path, MemoryGuard uses MEMORYGUARD_WORKSPACE or the fixed user-level
control directory (MEMORYGUARD_HOME, defaulting to
%LOCALAPPDATA%\MemoryGuard on Windows). It no longer remembers a previously
selected project, infers a workspace from the launch directory, or opens a
folder picker.
On Windows, memoryguard gui detaches the native window from the terminal, so
closing PowerShell does not close the GUI.
Provider-specific setup and behavior:
Upgrade
MemoryGuard currently upgrades through Python's package manager:
python -m pip install --upgrade agent-memguard
memoryguard --version
memoryguard doctor
If you installed the GUI extra, keep it during the upgrade:
python -m pip install --upgrade "agent-memguard[gui]"
There is no separate memoryguard update self-update command yet. The package
manager is the authoritative upgrade path, while MemoryGuard's schema
migrations run when the upgraded application opens its local stores.
Knowledge Library
The desktop console can turn a selected folder into one governed local knowledge library. Source files remain where they are; MemoryGuard stores the searchable index in its user data home instead of copying a runtime database into every source project.
| Capability | Current behavior |
|---|---|
| Folder ingestion | Add a folder as a book and ingest supported files as documents |
| Structure | Parse documents, preserve chapter/section context, and create traceable chunks |
| Retrieval | Full-text search, optional embeddings, and a layered knowledge graph |
| Natural synchronization | Re-ingest changed files; a partial or failed scan does not silently remove previously indexed content |
| Lifecycle | Move a book to the library trash, restore it, or explicitly purge its recovery snapshot |
| Memory candidates | Preview evidence-backed candidates before accepting them into governed long-term memory |
Open the desktop console and choose Knowledge Library. Remote embedding or model-backed indexing is opt-in and requires explicit authorization; local full-text retrieval remains available without sending source text to a remote provider.
Write and governance lifecycle
%%{init: {"theme":"base","themeVariables":{"background":"#071521","fontFamily":"Arial, sans-serif","fontSize":"14px","primaryTextColor":"#EEF4F8","lineColor":"#557287","edgeLabelBackground":"#071521","clusterBkg":"#0A1A29","clusterBorder":"#27445A"},"flowchart":{"htmlLabels":true,"curve":"basis","nodeSpacing":30,"rankSpacing":42,"padding":14}}}%%
flowchart TD
subgraph Intake["01 · INTAKE "]
direction LR
Write(["Memory write "]):::entry
Scope["Resolve identity<br/>scope · audience "]:::core
Validate{"Authorized? "}:::decision
Reject["Reject<br/>no persistence "]:::danger
Write --> Scope --> Validate
Validate -- NO --> Reject
end
subgraph Organize["02 · ORGANIZE "]
direction TB
Secret{"Sensitive? "}:::decision
Quarantine["Quarantine<br/>outside active set "]:::danger
Compare["Classify · compare<br/>governed records "]:::active
Relation{"Relationship "}:::decision
New["NEW<br/>create active record "]:::result
Duplicate["DUPLICATE<br/>merge provenance "]:::result
Correction["CORRECTION<br/>supersede old record "]:::rule
Conflict["CONFLICT<br/>preserve both sides "]:::danger
Secret -- YES --> Quarantine
Secret -- NO --> Compare --> Relation
Relation --> New
Relation --> Duplicate
Relation --> Correction
Relation --> Conflict
end
subgraph Govern["03 · GOVERN "]
direction LR
Receipt[("Evidence event<br/>version receipt ")]:::store
Review["CLI or desktop review "]:::surface
Action["Correct · merge<br/>restore · delete "]:::rule
Snapshot["Reversible<br/>snapshot "]:::active
Receipt --> Review --> Action --> Snapshot
end
Validate -- YES --> Secret
Quarantine --> Receipt
New --> Receipt
Duplicate --> Receipt
Correction --> Receipt
Conflict --> Receipt
classDef entry fill:#EEF4F8,stroke:#38D5C8,color:#071521,stroke-width:2.4px;
classDef core fill:#12243A,stroke:#557287,color:#EEF4F8,stroke-width:1.5px;
classDef decision fill:#0D3338,stroke:#38D5C8,color:#EEF4F8,stroke-width:2px;
classDef active fill:#0D383A,stroke:#38D5C8,color:#EEF4F8,stroke-width:2px;
classDef result fill:#12243A,stroke:#38D5C8,color:#EEF4F8,stroke-width:1.6px;
classDef rule fill:#3B2C18,stroke:#F3B562,color:#EEF4F8,stroke-width:1.8px;
classDef danger fill:#3A2028,stroke:#EA6A6A,color:#EEF4F8,stroke-width:1.8px;
classDef store fill:#0B1624,stroke:#7F96A8,color:#EEF4F8,stroke-width:1.4px;
classDef surface fill:#EEF4F8,stroke:#38D5C8,color:#071521,stroke-width:2px;
style Intake fill:#081827,stroke:#27445A,stroke-width:1px,color:#EEF4F8
style Organize fill:#081827,stroke:#27445A,stroke-width:1px,color:#EEF4F8
style Govern fill:#081827,stroke:#27445A,stroke-width:1px,color:#EEF4F8
linkStyle default stroke:#557287,stroke-width:1.4px;
The console is not an approval queue. Agents keep moving. MemoryGuard records the outcome and exposes the evidence needed to correct it later.
What you can govern
| Signal | Governance action |
|---|---|
| Duplicate or stale memory | Inspect the canonical record and supersede chain; restore an earlier version when needed |
| Conflicting memories | Keep both visible until the conflict is resolved deliberately |
| Secrets, tokens, or credentials | Quarantine the record so it cannot enter active shared memory |
| Incorrect automatic organization | Correct, merge, lock, restore, or roll back with evidence |
| Multiple coding agents | Bind agents to one shared group while preserving source identity and scope |
| Mandatory rules | Assign rules to an Agent, project, provider, runtime role, or shared group |
Rules and history stay separate
MemoryGuard deliberately keeps governed long-term memory and raw conversation history on different paths.
| Surface | Purpose | Context behavior |
|---|---|---|
| Rules and habits | Preferences, procedures, corrections, facts, projects, and scoped mandatory rules | Mandatory rules use a bounded independent budget; ordinary records are recalled when relevant |
| Conversation history | Local raw-evidence archive with owner and shared-group access controls | Never enters bootstrap automatically; raw text is read only through explicit history tools |
| Neuron graph | Navigation and governance over memory, rules, projects, agents, and sessions | History nodes contain safe metadata and summaries, not raw chat content |
History retrieval is progressive: search results, then a bounded timeline, then an explicitly selected turn or session. Extracting from history creates a preview first; it does not silently write a long-term memory.
%%{init: {"theme":"base","themeVariables":{"background":"#071521","fontFamily":"Arial, sans-serif","fontSize":"14px","primaryTextColor":"#EEF4F8","lineColor":"#557287","edgeLabelBackground":"#071521","clusterBkg":"#0A1A29","clusterBorder":"#27445A"},"flowchart":{"htmlLabels":true,"curve":"basis","nodeSpacing":30,"rankSpacing":42,"padding":14}}}%%
flowchart LR
subgraph HistoryPath["CONVERSATION EVIDENCE "]
direction TB
Archive[("Raw local history ")]:::historyStore
Search["Search summaries "]:::history
Timeline["Bounded timeline "]:::history
Read["Explicit turn or session "]:::history
Preview["Evidence-backed<br/>extraction preview "]:::history
Confirm["Explicit acceptance "]:::surface
Isolation["NO AUTOMATIC<br/>BOOTSTRAP PATH "]:::barrier
Archive --> Search --> Timeline --> Read --> Preview --> Confirm
Archive -.-> Isolation
end
subgraph GovernedMemory["GOVERNED LONG-TERM MEMORY "]
direction TB
Mandatory["Scoped mandatory rules "]:::rule
Assignments["Agent · project<br/>role · group scope "]:::core
RulePack["Mandatory-rule<br/>budget "]:::budget
Ordinary["Facts · preferences<br/>projects · procedures "]:::memory
Recall["Task-relevant<br/>recall budget "]:::budget
Context["BOUNDED CONTEXT PACKET "]:::context
Mandatory --> Assignments --> RulePack --> Context
Ordinary --> Recall --> Context
end
HistoryPath ==>|GOVERNED WRITE | GovernedMemory
classDef rule fill:#3B2C18,stroke:#F3B562,color:#EEF4F8,stroke-width:1.8px;
classDef core fill:#12243A,stroke:#557287,color:#EEF4F8,stroke-width:1.4px;
classDef memory fill:#0D383A,stroke:#38D5C8,color:#EEF4F8,stroke-width:1.8px;
classDef budget fill:#12243A,stroke:#38D5C8,color:#EEF4F8,stroke-width:1.6px;
classDef context fill:#EEF4F8,stroke:#38D5C8,color:#071521,stroke-width:2.4px;
classDef history fill:#102F45,stroke:#73C7F5,color:#EEF4F8,stroke-width:1.6px;
classDef historyStore fill:#102436,stroke:#73C7F5,color:#EEF4F8,stroke-width:1.6px;
classDef surface fill:#EEF4F8,stroke:#73C7F5,color:#071521,stroke-width:2px;
classDef barrier fill:#3A2028,stroke:#EA6A6A,color:#EEF4F8,stroke-width:2px;
style GovernedMemory fill:#081827,stroke:#27445A,stroke-width:1px,color:#EEF4F8
style HistoryPath fill:#081827,stroke:#27445A,stroke-width:1px,color:#EEF4F8
linkStyle default stroke:#557287,stroke-width:1.4px;
Supported hosts
| Host | Integration | Current boundary |
|---|---|---|
| Claude Code | Global MCP binding, redirect rules, user-level lifecycle Hook | Verified takeover path |
| Codex | Global MCP binding, redirect rules, user-level lifecycle Hook | Verified takeover path |
| Cursor | Global MCP binding, redirect rules, user-level lifecycle Hook | Verified takeover path |
| TRAE | MCP binding and redirect rules | No verified Hook seam; reported as a fallback instead of full takeover |
Provider status is reported honestly as redirected, observed, operational, or unsupported. MemoryGuard does not claim it can disable every host's native memory when the host exposes no reliable integration point.
Architecture
| Layer | Responsibility |
|---|---|
| Evidence | Authorized files, documents, host-native memory, external MCP descriptors, and conversation archives |
| Memory | Local SQLite shared-memory stores, scoped rules, provenance, conflicts, quarantine, and versions |
| Governance | MCP tools, CLI, desktop console, provider adapters, Hooks, confirmation bridges, and rollback |
The shared-memory store is the governed source of truth. Evidence remains traceable without being treated as automatically trusted memory.
Privacy and safety
- MemoryGuard runs as a local MCP stdio server.
- All governed data stays local unless you explicitly authorize a remote model or embedding operation.
- The Knowledge Library database uses
MEMORYGUARD_HOMEor the platform user data directory, so a selected source folder does not receive its own knowledge database. - Some shared-memory, conversation-history, audit, and recovery artifacts still
use an authorized workspace's
.memoryguard/directory in the current release. Storage is therefore local, but not yet fully centralized. - Source scanning is read-only by default.
- Mutating governance paths use validation, explicit scope, provenance, and reversible state.
- Quarantined records stay outside active shared memory.
- Raw conversation history is never injected into bootstrap automatically.
- Shared-group history access follows current active membership and does not grant deletion rights over another Agent's source.
CLI
The installed memoryguard command exposes these top-level operations:
| Command | Purpose |
|---|---|
audit [path] |
Run a read-only audit and generate a report |
open [path] |
Open the latest interactive report |
explain <finding_id> |
Explain evidence and risk for a finding |
plan <finding_ids...> |
Build a minimal fix plan without writing |
apply <plan_id> |
Apply a confirmed plan with backup and rescan |
verify |
Compare the workspace before and after a change |
undo <change_id> |
Restore a backed-up change and verify it |
source <action> |
List, add, remove, or preview authorized sources |
scan |
Scan authorized sources and build the coverage ledger |
import <action> <bundle> |
Preview or create an offline import bundle |
doctor |
Diagnose installation and integration state |
mcp-status |
Inspect local shared-memory groups |
hooks <action> |
Install, inspect, pause, repair, or remove host Hooks |
gc [path] |
Preview or apply garbage collection for rebuildable artifacts |
gui [path] |
Launch the interactive governance console |
desktop |
Launch the trusted desktop executor |
Run memoryguard --help or memoryguard <command> --help for the live command
reference.
MCP API
The MCP server exposes tools for:
- governed memory read, search, write, update, delete, and status;
- bounded context bootstrap with mandatory-rule isolation;
- rule creation, feedback, merge governance, undo, and scope statistics;
- Agent binding and shared-group inspection;
- source scanning, graph projection, import previews, and build planning;
- external MCP discovery and import;
- document extraction previews and candidate acceptance;
- conversation-history search, timeline, explicit read, export, deletion, and extraction preview;
- provider installation and host-agent enrichment.
Use MCP tools/list as the source of truth for the exact tool set supported by
the installed version.
Project links
- PyPI package
- GitHub releases
- Memory continuity and lossless storage spec
- Contributing guide
- Contributor License Agreement
- Issue tracker
Roadmap
- Current: local MCP memory, automatic organization, scoped rules, conversation evidence, Knowledge Library, provider adapters, governance UI, and rollback.
- Next: content-addressed deduplication, natural source synchronization, delta/checkpoint storage, derived-index maintenance, and clearer governance reports. Long-term records are not retired merely because they are old.
- Later: team and enterprise capabilities only after validated demand.
Contributing
Issues and pull requests are welcome. Read CONTRIBUTING.md before submitting a change. Pull requests require agreement to the CLA.
License
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file agent_memguard-0.5.2.tar.gz.
File metadata
- Download URL: agent_memguard-0.5.2.tar.gz
- Upload date:
- Size: 1.4 MB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via:
twine/7.0.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
aec8a181d72fee1769b5506126c3580a8c9a52a8b0ecc3fabc52795ced74c891
|
|
| MD5 |
41ba1d5ccb4aedf7773b67b16d3428e6
|
|
| BLAKE2b-256 |
7cfc68aa9ace5cb8b7ac4cc79d3038718844dc36718e9ff40b80062b85a63e8c
|
Provenance
The following attestation bundles were made for agent_memguard-0.5.2.tar.gz:
Publisher:
publish.yml on irisxc4/memoryguard
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
agent_memguard-0.5.2.tar.gz -
Subject digest:
aec8a181d72fee1769b5506126c3580a8c9a52a8b0ecc3fabc52795ced74c891 - Sigstore transparency entry: 2369416510
- Sigstore integration time:
-
Permalink:
irisxc4/memoryguard@04c57c60e6000da86b518fae2179b7fce0663ab6 -
Branch / Tag:
refs/tags/v0.5.2 - Owner: https://github.com/irisxc4
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@04c57c60e6000da86b518fae2179b7fce0663ab6 -
Trigger Event:
release
-
Statement type:
File details
Details for the file agent_memguard-0.5.2-py3-none-any.whl.
File metadata
- Download URL: agent_memguard-0.5.2-py3-none-any.whl
- Upload date:
- Size: 1.2 MB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via:
twine/7.0.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
0e999f700e2623e6872b8bd1dfa40646c308cfa9475ea2718bae4db07743d61c
|
|
| MD5 |
97321d66cdb620f367fe294c6cc51b3f
|
|
| BLAKE2b-256 |
4685ea6669711889094707946a9ebcb80887648361391110e6af523cd8af6fb4
|
Provenance
The following attestation bundles were made for agent_memguard-0.5.2-py3-none-any.whl:
Publisher:
publish.yml on irisxc4/memoryguard
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
agent_memguard-0.5.2-py3-none-any.whl -
Subject digest:
0e999f700e2623e6872b8bd1dfa40646c308cfa9475ea2718bae4db07743d61c - Sigstore transparency entry: 2369416575
- Sigstore integration time:
-
Permalink:
irisxc4/memoryguard@04c57c60e6000da86b518fae2179b7fce0663ab6 -
Branch / Tag:
refs/tags/v0.5.2 - Owner: https://github.com/irisxc4
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@04c57c60e6000da86b518fae2179b7fce0663ab6 -
Trigger Event:
release
-
Statement type: