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
Path to a Memproof policy YAML file. If
None and no config is provided, defaults to "memproof.yaml" in the current working directory.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.
A pre-built configuration object. When provided, all other keyword arguments (except
policy_schema_path) are ignored. See Configuration.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.Base URL for the LangGraph checkpoint API. Only used when
adapter="langgraph".API key for authenticating with the LangGraph checkpoint API.
OpenAI API key. Only used when
adapter="openai_sessions".OpenAI organization ID. Only used when
adapter="openai_sessions".URL of the MCP memory server. Only used when
adapter="mcp".Trailproof audit trail storage backend. Supported values:
"memory"— in-memory store (events are lost on process exit)."jsonl"— JSONL file-backed persistent store.
File path for the JSONL trail store. Required when
trail_store="jsonl".HMAC-SHA256 secret key for signing trail events. When provided, each event includes a cryptographic signature for tamper detection.
Enable the Attesta external approval service for
require_approval policy decisions.Base URL for the Attesta approval service.
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).The memory content to store. Must be non-empty.
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.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.Optional list of tags to associate with the memory.
Arbitrary key-value metadata to attach to the memory record.
Time-to-live in seconds. If set, the memory will be considered expired after this duration. Must be greater than 0.
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.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.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.The ID of the memory to update.
Operation context. Same format as
remember().New content for the memory. If
None, the content is not changed.Replacement tag list. If
None, tags are not changed.Key-value pairs to merge into the existing metadata. Existing keys not present in the patch are preserved.
New TTL value in seconds. Must be greater than 0 if provided.
Client-supplied idempotency key.
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.The ID of the memory to delete.
Operation context. Same format as
remember().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.The search query string. Must be non-empty.
Restricts the search to memories within this scope.
Operation context for auditing the search request.
Maximum number of results to return. Must be between 1 and 100 (inclusive).
Additional key-value filters passed to the adapter. The available filter keys depend on the adapter implementation.
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.The operation ID returned by
remember(), update(), or forget().Example
approve()
Approve a pending operation that was held by arequire_approval policy decision.
The ID of the operation to approve.
Identifier of the actor (human reviewer) performing the approval.
Optional free-text notes to attach to the approval decision.
Example
deny()
Deny a pending operation that was held by arequire_approval policy decision.
The ID of the operation to deny.
Identifier of the actor performing the denial.
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.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.Filter by event type (e.g.
"memproof.pipeline.committed").Filter by metadata fields (e.g.
{"operation_id": "op-abc123"} or {"tenant_id": "acme"}).Maximum number of events to return.
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: