Skip to content

Feat: memory deletion — clearNamespace / forget / list (soft-delete) [WALM-115]#287

Draft
hungtranphamminh wants to merge 6 commits into
devfrom
feat/walm-115-delete-mem
Draft

Feat: memory deletion — clearNamespace / forget / list (soft-delete) [WALM-115]#287
hungtranphamminh wants to merge 6 commits into
devfrom
feat/walm-115-delete-mem

Conversation

@hungtranphamminh

Copy link
Copy Markdown
Collaborator

Summary

Why

The SDK exposed remember/recall/restore but no way to delete a memory or clear a namespace. After an agent reset, stale memories keep surfacing in recall() — reported by two Walrus-Sessions-4 integrators (#258, +1 in-thread): a reset agent self-anchored on its own discarded outputs, and "day-one vs day-four" demo integrity broke on the same wallet. The only workaround (rotate the namespace string) orphans data forever.

What

Adds owner-scoped memory deletion across the stack. Deletion is soft — a deleted memory immediately stops surfacing in recall(), but the underlying Walrus blob persists (un-recallable, not erased).

  • clearNamespace(ns) — soft-delete every memory in a namespace (the reset primitive).
  • forget(id) — soft-delete a single memory by its per-row id.
  • list(ns, { limit, cursor }) — enumerate a namespace (metadata only — id, blob_id, created_at, importance; no decrypted text), cursor-paginated via has_more / next_cursor.

Delivered in: the relayer (/api/clear-namespace, /api/list, /api/memories/forget) plus a deleted_at migration, the TS SDK (0.0.8), and the Python SDK (0.1.5) — with unit + e2e tests and public API-reference docs (relayer + both SDKs). MCP sidecar tools are included but dormant — see Related.

Solution

  • Soft-delete via a deleted_at tombstone (migration 010): deletion stops a memory surfacing in recall() (and the analyze pre-extraction context) while retaining the row. The underlying Walrus blob is user-owned and persists — "delete" means un-recallable, not cryptographically erased (carried honestly in all docstrings). Fits the privacy floor: no new server-readable plaintext.
  • The existing hard /api/forget is left untouched for benchmark-harness cleanup; clearNamespace is a separate soft path.
  • list() keyset pagination on (created_at, id) (stable tie-break, no skip/dup under concurrent deletes); metadata-only so it's decrypt-free.
  • Owner-scoped everywhere — every query binds the auth-derived owner; forget(id) of an id you don't own is a clean no-op (no cross-owner existence oracle).

Types of Changes

  • Breaking change (existing functionality would change)
  • New feature (non-breaking)
  • Bug fix (non-breaking)
  • Performance optimization
  • Refactor (no behavior change)
  • Dependency update
  • Documentation
  • Test
  • Security / permission-scope change

Testing

  • Tested locally
  • Added/updated unit tests
  • Added/updated integration tests
  • cargo test / harness tests pass

Checklist

  • Follows the project's commit + code conventions
  • No ticket IDs / competitor names / local-doc paths in code comments
  • Docs updated if needed
  • Respects the privacy floor (no server-readable plaintext index)
  • All new and existing tests pass

Related

  • Closes No way to delete memories or clear a namespace — stale memories pollute recall after agent resets #258 (delete / clear namespace). Acknowledged in-thread by both reporting integrators.
  • Linear: WALM-115.
  • MCP is deferred to a separate go-live PR. The sidecar tools (memwal_clear_namespace / memwal_list / memwal_forget) are added but dormant: the sidecar's Docker build installs a pinned published SDK that predates these methods, so the tools resolve them only once the sidecar is built against the new SDK. No MCP version bump in this PR.
  • Follow-ups (separate tickets): MCP go-live (sidecar build → pnpm/workspace); hard-purge/erasure job (must filter deleted_at IS NULL in restore's blob-discovery).

…-115]

Add a soft-delete tombstone (deleted_at, migration 010) and three owner-scoped
endpoints on the relayer:

- POST /api/clear-namespace  — soft-delete every memory in a namespace
- POST /api/list             — enumerate a namespace (metadata only, no decrypt),
                               keyset-paginated via (created_at, id) cursor + has_more
- POST /api/memories/forget  — soft-delete one memory by its per-row id

Soft-delete stops a memory surfacing in recall (and the analyze pre-extraction
context) while retaining the row; the underlying Walrus blob persists. The hard
DELETE path (/api/forget) is left untouched for benchmark-harness cleanup.
stats() now excludes tombstoned rows. Includes Rust unit tests (SQL invariants,
cursor keyset/tie-break, stats live-only) and e2e coverage (clear, list+forget,
pagination, per-row, cross-owner).
Expose the relayer's soft-delete endpoints on the TS SDK: clearNamespace(ns),
list(ns, { limit, cursor }) (metadata-only, cursor-paginated with has_more /
next_cursor), and forget(id). Docstrings carry the honest semantics — un-recallable
not erased, 0 = safe idempotent no-op, clearNamespace clears what exists at call
time. Bump 0.0.7 -> 0.0.8.
Mirror the memory-deletion API on the Python SDK: clear_namespace, list (with
cursor pagination), and forget on both the async MemWal and the sync MemWalSync,
plus the ClearNamespaceResult / MemoryListItem / ListResult / ForgetResult
dataclasses and exports. Same honest docstrings as the TS SDK. Bump 0.1.4 -> 0.1.5.
Add the three deletion tools to the MCP sidecar (scripts/mcp/tools) and register
default-namespace injection for clear_namespace + list in the client bridge
(forget is id-scoped, so excluded). These call the SDK's clearNamespace/list/forget.

Dormant until the MCP go-live: the sidecar Docker build installs a pinned
published SDK that predates these methods, so the tools resolve them only once the
sidecar is built against the new SDK (separate go-live PR). No version bump here.
…WALM-115]

Add the memory-deletion API to the public docs: the 3 endpoints in the relayer
api-reference, the TS + Python SDK method references, the SDK overview method
lists, and a Quick Start snippet in the SDK README. Carries the honest
semantics (soft-delete = un-recallable not erased; 0/cleared/forgotten = safe
no-op; list is metadata-only + cursor-paginated). The hard /api/forget stays
undocumented (harness-only), matching existing convention.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

No way to delete memories or clear a namespace — stale memories pollute recall after agent resets

1 participant