fix: make entity_registry.research() local-only by default#811
Merged
bensig merged 2 commits intoMemPalace:developfrom Apr 15, 2026
Merged
fix: make entity_registry.research() local-only by default#811bensig merged 2 commits intoMemPalace:developfrom
bensig merged 2 commits intoMemPalace:developfrom
Conversation
822a500 to
3e00568
Compare
research() previously called _wikipedia_lookup() unconditionally, sending entity names to en.wikipedia.org on every uncached lookup. This violates the project's local-first and privacy-by-architecture principles documented in CLAUDE.md. Changes: - research() now returns "unknown" for uncached words by default - New allow_network=True parameter required for Wikipedia lookups - Wikipedia 404 now returns "unknown" instead of asserting "person" with 0.70 confidence, preventing entity registry poisoning - Added privacy warning docstring to _wikipedia_lookup() - Added tests for local-only default, opt-in network, 404 handling, and cache-not-persisted-on-local-only behaviour Refs: MemPalace#809
- Use .get() instead of .setdefault() for cache reads in research() so the local-only path never mutates _data unnecessarily - Move .setdefault() to the network-write path only - Use result.setdefault() for word/confirmed keys to ensure consistent return shape across all _wikipedia_lookup error paths - Extract duplicated mock_result dict into _MOCK_SAOIRSE_PERSON constant shared by 3 test functions
53da579 to
01ead58
Compare
bensig
approved these changes
Apr 15, 2026
Collaborator
bensig
left a comment
There was a problem hiding this comment.
Code reviewed — no issues found. CLAUDE.md compliance verified.
igorls
added a commit
that referenced
this pull request
Apr 16, 2026
Advisor caught: initial boundary (962776c..develop) skipped PRs that landed on develop after v3.3.0 tag but before the sync-back merge. Adds entries for #871 MEMPAL_VERBOSE, #811 research() local-only default, #866 init .gitignore, #864 MCP stdout redirect, #863 precompact hook, #865 searcher empty results, #831 cold-start palace, #862 init help, #815 Slack provenance, #840 save hook auto-mine. Also drops the awkward caveat on #846 created_at — it's post-v3.3.0.
shafdev
pushed a commit
to shafdev/mempalace
that referenced
this pull request
Apr 17, 2026
Advisor caught: initial boundary (962776c..develop) skipped PRs that landed on develop after v3.3.0 tag but before the sync-back merge. Adds entries for MemPalace#871 MEMPAL_VERBOSE, MemPalace#811 research() local-only default, MemPalace#866 init .gitignore, MemPalace#864 MCP stdout redirect, MemPalace#863 precompact hook, MemPalace#865 searcher empty results, MemPalace#831 cold-start palace, MemPalace#862 init help, MemPalace#815 Slack provenance, MemPalace#840 save hook auto-mine. Also drops the awkward caveat on MemPalace#846 created_at — it's post-v3.3.0.
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
research()previously called_wikipedia_lookup()unconditionally, sending entity names toen.wikipedia.orgon every uncached lookup — violating the project's local-first and privacy by architecture principles (CLAUDE.md)research()is now local-only by default: returns"unknown"for uncached words without any network callallow_network=Trueparameter required to explicitly opt in to Wikipedia lookups"unknown"(confidence 0.3) instead of asserting"person"(confidence 0.70), preventing entity registry poisoning with false positivesRefs: #809 (Finding 1)
What changed
mempalace/entity_registry.pyresearch()— addedallow_network: bool = Falseparameter; uncached words return"unknown"immediately whenallow_networkisFalse_wikipedia_lookup()— 404 handler now returnsinferred_type: "unknown"instead of"person"; added privacy warning docstringtests/test_entity_registry.pytest_research_local_only_by_default— verifies no network call happens by defaulttest_research_with_allow_network— verifies Wikipedia is called when opted intest_research_local_only_not_cached— verifies local-only results are not persisted to wiki_cachetest_wikipedia_404_returns_unknown— verifies 404 returns "unknown", not "person"allow_network=Truewhere they intentionally test the Wikipedia pathTest plan
pytest tests/test_entity_registry.py -v— 29/29 passedpytest tests/ -v --ignore=tests/benchmarks— 689 passed, 3 failed (pre-existing: version mismatch + KG re-add bug)ruff check— all checks passedruff format --check— all files formattedresearch()withoutallow_network(confirmed: only tests call it, and they already mock_wikipedia_lookup)