Skip to content

fix: use permissive validator for KG entity values - #873

Merged
igorls merged 1 commit into
MemPalace:developfrom
sha2fiddy:feature/455/kg-sanitize-punctuation
Apr 14, 2026
Merged

fix: use permissive validator for KG entity values#873
igorls merged 1 commit into
MemPalace:developfrom
sha2fiddy:feature/455/kg-sanitize-punctuation

Conversation

@sha2fiddy

Copy link
Copy Markdown
Contributor

Summary

  • Adds sanitize_kg_value() in config.py — a permissive validator for knowledge graph subject/object fields that allows punctuation (commas, colons, parentheses, slashes, #, etc.) while still blocking null bytes and enforcing the 128-char length limit
  • Updates mcp_server.py KG tools (kg_add, kg_invalidate, kg_query, kg_timeline) to use sanitize_kg_value for subject/object/entity fields; predicates still use the strict sanitize_name
  • sanitize_name was designed for wing/room names with filesystem constraints — KG entity values live in SQLite and don't need those restrictions

Closes #455

Test plan

  • New tests for sanitize_kg_value: accepts commas, colons, parens, slashes, #, Unicode; rejects empty, whitespace-only, null bytes, over-length
  • Full test suite passes (875 tests)
  • ruff check clean
  • ruff format --check clean

)

sanitize_name rejects commas, colons, parentheses, and slashes — characters
that commonly appear in knowledge graph subject/object values. Adds
sanitize_kg_value for KG entity fields (subject, object, entity) while
keeping sanitize_name for predicates and wing/room names.
@sha2fiddy
sha2fiddy marked this pull request as ready for review April 14, 2026 13:29
@igorls igorls added bug Something isn't working area/kg Knowledge graph labels Apr 14, 2026
@igorls
igorls merged commit 4741bc0 into MemPalace:develop Apr 14, 2026
6 checks passed
@sha2fiddy
sha2fiddy deleted the feature/455/kg-sanitize-punctuation branch April 18, 2026 16:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/kg Knowledge graph bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

KG object field too restrictive: sanitize_name rejects commas and common punctuation

2 participants