Memproof
memproof.Memproof is the single entry point for the library. It assembles the internal pipeline (risk engine, policy engine, Trailproof audit trail, quarantine store, approval broker, and memory adapter) and exposes a concise async API.
Constructor
MemproofConfig object via config, or use the convenience keyword arguments — they are forwarded to a new MemproofConfig internally. If config is provided, the keyword arguments are ignored (except policy_schema_path).
Parameters
str | None
default:"None"
Path to a Memproof policy YAML file. If
None and no config is provided, defaults to "memproof.yaml" in the current working directory.str
default:"\"in_memory\""
Which memory adapter to use. Supported values:
"in_memory"— ephemeral, dictionary-backed store (useful for testing)."langgraph"— LangGraph checkpoint-backed store."openai_sessions"— OpenAI Sessions API-backed store."mcp"— MCP memory server-backed store.
MemproofConfig | None
default:"None"
A pre-built configuration object. When provided, all other keyword arguments (except
policy_schema_path) are ignored. See Configuration.str | None
default:"None"
Path to the JSON Schema file used to validate the policy YAML. If
None, Memproof looks for schemas/memproof-policy.schema.json relative to the package root.str
default:"\"\""
Base URL for the LangGraph checkpoint API. Only used when
adapter="langgraph".str
default:"\"\""
API key for authenticating with the LangGraph checkpoint API.
str
default:"\"\""
OpenAI API key. Only used when
adapter="openai_sessions".str
default:"\"\""
OpenAI organization ID. Only used when
adapter="openai_sessions".str
default:"\"\""
URL of the MCP memory server. Only used when
adapter="mcp".str
default:"\"memory\""
Trailproof audit trail storage backend. Supported values:
"memory"— in-memory store (events are lost on process exit)."jsonl"— JSONL file-backed persistent store.
str | None
default:"None"
File path for the JSONL trail store. Required when
trail_store="jsonl".str | None
default:"None"
HMAC-SHA256 secret key for signing trail events. When provided, each event includes a cryptographic signature for tamper detection.
bool
default:"False"
Enable the Attesta external approval service for
require_approval policy decisions.str
default:"\"\""
Base URL for the Attesta approval service.
str
default:"\"\""
Bearer token for authenticating with the Attesta approval service.
Example
Methods
remember()
Create a new memory through the full control pipeline (risk assessment, policy evaluation, event logging, and adapter persistence).str
required
The memory content to store. Must be non-empty.
dict | MemoryScope
required
Identifies where this memory belongs. Accepts either a
MemoryScope instance or a dictionary with the keys tenant_id, project_id, agent_id, and optionally session_id and subject_id.dict | OperationContext
required
Describes who is performing the operation and when. Accepts either an
OperationContext instance or a dictionary with the keys actor_type, actor_id, source, timestamp, and optionally request_id, correlation_id, and metadata.list[str] | None
default:"None"
Optional list of tags to associate with the memory.
dict[str, Any] | None
default:"None"
Arbitrary key-value metadata to attach to the memory record.
int | None
default:"None"
Time-to-live in seconds. If set, the memory will be considered expired after this duration. Must be greater than 0.
str | None
default:"None"
Client-supplied idempotency key. If the same key is reused, the original response is returned without re-executing the operation. If
None, a unique key is generated automatically.MemoryOperationResponse
Contains
operation_id, status, the created memory record (if committed), risk_assessment, and the decision from the policy engine. See Models.Example
get()
Retrieve a single memory record by its ID.str
required
The unique identifier of the memory to retrieve.
Errors
NotFoundError— raised if no memory with the given ID exists.
Example
update()
Update an existing memory through the full control pipeline. Only the fields you provide are changed; omitted fields remain unchanged.str
required
The ID of the memory to update.
dict | OperationContext
required
Operation context. Same format as
remember().str | None
default:"None"
New content for the memory. If
None, the content is not changed.list[str] | None
default:"None"
Replacement tag list. If
None, tags are not changed.dict[str, Any] | None
default:"None"
Key-value pairs to merge into the existing metadata. Existing keys not present in the patch are preserved.
int | None
default:"None"
New TTL value in seconds. Must be greater than 0 if provided.
str | None
default:"None"
Client-supplied idempotency key.
MemoryOperationResponse
Contains the updated memory, risk assessment, and policy decision. See Models.
Example
forget()
Delete a memory through the full control pipeline. The operation still flows through risk assessment and policy evaluation before the adapter removes the record.str
required
The ID of the memory to delete.
dict | OperationContext
required
Operation context. Same format as
remember().str | None
default:"None"
Client-supplied idempotency key.
Example
search()
Search for memories within a given scope. The search query is forwarded to the adapter, which returns ranked results.str
required
The search query string. Must be non-empty.
dict | MemoryScope
required
Restricts the search to memories within this scope.
dict | OperationContext
required
Operation context for auditing the search request.
int
default:"20"
Maximum number of results to return. Must be between 1 and 100 (inclusive).
dict[str, Any] | None
default:"None"
Additional key-value filters passed to the adapter. The available filter keys depend on the adapter implementation.
MemorySearchResponse
Contains a
hits list of MemorySearchHit objects, each with a memory and a relevance score. See Models.Example
get_operation_status()
Retrieve the current status of a previously submitted operation. This is a synchronous method.str
required
The operation ID returned by
remember(), update(), or forget().Example
approve()
Approve a pending operation that was held by arequire_approval policy decision.
str
required
The ID of the operation to approve.
str
required
Identifier of the actor (human reviewer) performing the approval.
str | None
default:"None"
Optional free-text notes to attach to the approval decision.
Example
deny()
Deny a pending operation that was held by arequire_approval policy decision.
str
required
The ID of the operation to deny.
str
required
Identifier of the actor performing the denial.
str | None
default:"None"
Optional free-text notes explaining the denial.
Example
verify_audit_trail()
Verify the integrity of the Trailproof audit trail by validating the SHA-256 hash chain. If any event has been tampered with, the chain breaks and verification fails.TrailVerificationResult
Contains
valid (bool), event_count (int), and error (str or None if valid). See Trailproof documentation for details.Example
query_audit_trail()
Query the Trailproof audit trail with optional filters for event type and metadata fields.str | None
default:"None"
Filter by event type (e.g.
"memproof.pipeline.committed").dict[str, Any] | None
default:"None"
Filter by metadata fields (e.g.
{"operation_id": "op-abc123"} or {"tenant_id": "acme"}).int | None
default:"None"
Maximum number of events to return.
list[TrailEvent]
A list of Trailproof
TrailEvent objects matching the query criteria.Example
Scope and Context Flexibility
Every method that acceptsscope or context parameters can receive either a Pydantic model instance or a plain dictionary. Memproof coerces dictionaries internally: