feat(namespaces): propagate namespace through public surfaces (Sprint C.2, #16)#101
Merged
Conversation
…I (C.2, #16) Exposes the memory `namespace` argument through every public surface so callers can scope operations to a single domain. Backend support shipped in Sprint C.1 (PR #100); this PR makes it reachable. HTTP API (src/app.ts): - POST /memory/:id/add — body field `namespace` - GET /memory/:id/query — query param - POST /memory/:id/consolidate — body field - POST /memory/:id/import — body field + per-record fallback - GET /memory/:id/export — query param - GET /memory/:id/timeline — query param - GET /memory/:id/resume — query param - GET /memory/:id/stats — query param (with namespace folded into cache key) Cache keys for timeline/stats/resume now include namespace so cached responses don't leak across namespaces. Sleep is intentionally agent-wide and NOT namespace-scoped: the 10-phase cycle would need every phase to filter by namespace, which is a deeper change than C.2. The SleepSchema no longer accepts a `namespace` field so the API doesn't lie about behavior it cannot yet deliver. Future work can re-add it once sleep phases are all namespace-aware. MemoryManager extensions beyond C.1: - timeline() — 5th positional `namespace?` param, WHERE filter - stats() — 2nd positional `namespace?` param. Entity/relationship counts remain agent-scoped (knowledge graph is shared across namespaces by design, see migration-v3.1 header); warm/hot/cold/ reflection counts filter by (agent_id, namespace). - resume() — 3rd positional `namespace?` param, filters warm_tier, procedures, reflections, and the memory health summary. - exportMemory() — 2nd positional `namespace?` param. Warm-tier rows, procedures, and reflections are namespace-scoped in the export; entities + relationships are included in every export so a JSONL dump is self-contained for re-import. MCP (src/mcp.ts) + tool-definitions (src/tool-definitions.ts): - `memforge_add`, `memforge_query`, `memforge_timeline`, `memforge_consolidate`, `memforge_stats` gain optional `namespace` arg with terse descriptions noting default 'default'. - `memforge_sleep` does NOT take namespace (agent-wide, documented). TypeScript SDK (src/client.ts): - MemForgeClient and ResilientMemForgeClient: `namespace` param on add/query/consolidate/timeline/stats/resume/exportMemory. Non-breaking — existing positional call sites still compile. OpenAPI spec (src/openapi.ts): - namespace parameter documented on each applicable route with the regex pattern (^[a-z0-9][a-z0-9_-]*$). Routes that were missing from the spec (/sleep, /resume, /export, /import) are added. Python SDK (python/memforge/client.py + resilient.py): - Matching `namespace` kwarg on add/query/consolidate/timeline/stats/ resume. `sleep` does not take namespace (parity with TS). Tests (tests/http-api.test.ts): - New "Namespace support" suite: 5 tests for add+consolidate in a non-default namespace, namespace-scoped query, cross-namespace isolation, and 400s on invalid namespace input for both POST and GET. ROADMAP.md: #16 marked ✅ DONE — shipped in PR #100 (backend) + this PR (public surface).
This was referenced Apr 18, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Exposes the memory `namespace` argument through every public surface. Backend support shipped in Sprint C.1 (PR #100); this PR makes it reachable from HTTP, MCP tools, TS SDK, Python SDK, and OpenAPI. Completes #16 Memory Namespaces.
Sleep is intentionally agent-wide (not namespace-scoped). Making it namespace-aware would require every phase in the 10-phase cycle to filter by namespace — deeper than this PR. `SleepSchema` explicitly does not accept `namespace` so the API doesn't claim behavior it can't deliver.
Surfaces updated
Tests
`tests/http-api.test.ts` — new "Namespace support" suite (5 tests): add+consolidate to non-default namespace, scoped query, cross-namespace isolation, 400s on invalid namespace input (POST and GET).
Python SDK tests out of scope — Python test infrastructure isn't in CI.
Design notes
Test plan
ROADMAP
#16 marked ✅ DONE (backend via PR #100, public surface via this PR).