Skip to content

feat(memory): enforce namespace isolation - #27

Open
DivyamTalwar wants to merge 1 commit into
mainfrom
codex/scoped-memory-namespaces-20260824
Open

feat(memory): enforce namespace isolation#27
DivyamTalwar wants to merge 1 commit into
mainfrom
codex/scoped-memory-namespaces-20260824

Conversation

@DivyamTalwar

Copy link
Copy Markdown
Owner

Why

JITMIND accepted user_id, but durable memories and the LLM mutation context were still read from a shared store. That makes cross-user recall and even cross-user update/delete possible in a multi-tenant process.

What changed

  • adds validated, component-safe namespaces with a backward-compatible ("default",) scope
  • derives ("users", user_id) when callers already use user_id
  • persists the namespace on both MemoryEntry and source Page
  • scopes mutation prompts, ranked context, bi-temporal queries, graph queries, PPR traversal, and final retrieval hits before LLM integration
  • rejects cross-namespace version updates and fails closed when a custom store cannot provide isolation
  • documents the contract and adds a dependency-free scale microbenchmark

Competitive rationale / provenance

This is an original implementation informed by two public patterns:

No source code was copied. JITMIND deliberately keeps namespace components as a tuple, avoiding ambiguous delimiter-based prefix matching, and carries the boundary through its existing bi-temporal and graph paths.

Evidence

  • python -m pytest -q42 passed
  • python -m compileall -q jitmind → pass
  • python benchmarks/benchmark_namespace_filter.py (10,000 memories / 100 tenants) → 100 selected in 6.118 ms on the development runner
  • new tests cover exact/prefix semantics, scoped current + historical reads, fail-closed updates, and retrieval rejection

Review notes

This PR is intentionally independent from the other JITMIND proposals and targets main. It is ready for review and must remain unmerged for comparative evaluation.

Copy link
Copy Markdown
Owner Author

Verification checkpoint

  • Exact head: c6e69e30a5ae4382a6ce5fc206572a5693e3472a
  • GitHub Actions CI run: 32662931272success
  • Matrix: Python 3.10 (97251718903), 3.11 (97251718913), and 3.12 (97251718833) all passed install, pytest, and compileall
  • Local suite: 42 passed
  • Namespace benchmark: 10,000 memories / 100 tenants, target scope selected in 6.118 ms on the development runner

Security review focus: namespace gating occurs before mutation prompts and answer integration; cross-namespace version changes fail closed. This PR remains intentionally open and unmerged.

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.

1 participant