Skip to content

A user erasure tombstones only the shared embeddings of the namespaces its shared rows live in - #221

Merged
zlareb1 merged 4 commits into
mainfrom
fix/erasure-shared-embeddings-by-namespace
Nov 4, 2026
Merged

zlareb1 merged 4 commits into
mainfrom
fix/erasure-shared-embeddings-by-namespace

Conversation

@zlareb1

@zlareb1 zlareb1 commented Nov 3, 2026 •

Copy link
Copy Markdown
Member

Changelog category (leave one):

  • Bug Fix (user-visible misbehavior in a release)

Changelog entry (one or two sentences a user of Loom can read without the diff; the release pull request collects these into the release notes):

A user_id erasure no longer tombstones the shared embedding of another namespace's shared memory that has the same key, so that memory stays in vector search.

Why

Failing case: in one org, team-a holds a loom.shared row user_employer promoted from user u1, and team-b holds a shared row user_employer promoted from u2. erasure.request {scope_type: "user_id", scope_value: "u1"} runs shared_embeddings.tombstone, which read SELECT DISTINCT memory_key FROM loom.shared ... and tombstoned loom.memory_embeddings WHERE org = o AND scope = 'shared' AND memory_key IN ['user_employer']. That filter has no namespace, so team-b's shared embedding (its excerpt and vector) was tombstoned. Its loom.shared row stayed live, so the fact dropped out of vector search for a user nobody erased.

Pattern: the key alone is not an identity across namespaces. server/erasure/store/predicates.py already says so for the link tables, and the other user-scope steps match on (namespace, memory_key).

Fix: the step reads (namespace, memory_key) pairs from the shared rows promoted from the user and tombstones by PARENT_KEYS_IN, the same bound pair predicate the link steps use, sliced with chunks.

Scope and risk

Touches only tombstone_shared_embeddings_by_user. The matched set can only shrink: every embedding it still tombstones was tombstoned before. The census does not count this table for the user scope (shared*.tombstone is a step-only table), so the residue check is unchanged.

Compatibility, rollout and rollback

  • Wire: none.
  • Operator steps: none.
  • Rollback: reverting restores the key-only match; no stored data or migration involved.

Tests

  • tests/unit/test_erasure_shared_embeddings_sql.py::test_a_shared_row_of_the_same_key_in_another_namespace_keeps_its_embedding runs the step on clickhouse-local over two shared embeddings of key k1, in team-a (promoted from the erased user) and team-b (promoted from another user). It fails on main's step (2 == 1: both are tombstoned) and passes now: only team-a's is tombstoned.
  • tests/unit/test_erasure_repo.py::test_tombstone_shared_embeddings_by_user_names_each_namespace_with_its_key failed before the fix (the read selected the key alone) and passes after: the read selects namespace, memory_key, the count and the mutation bind (namespace, memory_key) IN {keys:Array(Tuple(String, String))} with [("team-a", "k1")].
  • tests/analyzer/shapes.txt regenerated (python -m tests.analyzer.corpus --write); the corpus stub row for the read now carries namespace.
  • Ran tests/unit/test_erasure*.py, tests/unit/test_clickhouse_mutation_inventory.py, tests/analyzer/test_corpus.py, make format lint, mypy on the module.

AI assistance in the code (leave one; writing this description with AI is fine):

  • AI-generated (an agent wrote most of the diff): Claude Code. Checked the shared-embedding writer (promote.py stamps the shared row's namespace on the embedding) and the analyzer shape diff.

  • I can explain every line of this diff and how it interacts with the rest of Loom.

Checklist

  • make format-check, make lint, make typecheck and make test-unit pass; the integration suite passes if server behaviour changed.
  • Generated files are regenerated in this PR, not by hand.
  • Docs under docs/ describe the system as it now is, and this description names any operator steps and wire changes.
  • Repository text has no dates, people, host names, internal namespaces, ticket or decision numbers.
  • Commits are signed off (git commit -s), as CONTRIBUTING.md asks.

🤖 Generated with Claude Code

zlareb1 and others added 4 commits November 3, 2026 13:42
…s its shared rows live in

The shared-embeddings step read the keys of the loom.shared rows promoted
from the erased user and tombstoned every scope='shared' embedding of those
keys in the org. A shared row of the same key spelling in another namespace,
promoted from someone else, lost its embedding and dropped out of vector
search while its loom.shared row stayed live.

The step now reads (namespace, memory_key) pairs and tombstones by the pair.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: zlareb1 <[email protected]>
A shared row of the same key in another namespace, promoted from someone
else, keeps its embedding: two shared embeddings are stored and read back.
The stub test's docstring says only what it checks.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: zlareb1 <[email protected]>
@zlareb1
zlareb1 merged commit 8439f10 into main Nov 4, 2026
22 checks passed
@zlareb1
zlareb1 deleted the fix/erasure-shared-embeddings-by-namespace branch November 4, 2026 13:11
@pufit pufit mentioned this pull request Nov 4, 2026
9 tasks done
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