Graph-Native Infrastructure for Context and Accountable AI Systems
Python agent-memoryaiai-governanceai-infrastructureartificial-intelligencecontext-engineeringcontext-graphsdata-engineeringdecision-intelligencedeveloper-toolsexplainable-aigenerative-aigraph-ragknowledge-graphllmontologyprovenancepythonreasoningsemantic-search
fix(context): preserve Markdown path errors
Saurabh Meenac0b6a8048017
diff --git a/semantica/context/agent_memory.py b/semantica/context/agent_memory.pyindex 2df42647..5456e30c 100644--- a/semantica/context/agent_memory.py+++ b/semantica/context/agent_memory.py@@ -1865,10 +1865,15 @@ class AgentMemory:if "\n" not in data and "\r" not in data:candidate = Path(data)try:- if candidate.exists():- documents = self._read_markdown_path(candidate)- except OSError:- pass+ candidate_exists = candidate.exists()+ except OSError as exc:+ raise OSError(+ "Failed to inspect possible Markdown import "+ f"path: {candidate}"+ ) from exc++ if candidate_exists:+ documents = self._read_markdown_path(candidate)if documents is None:documents = [("markdown document", data)]diff --git a/tests/context/test_agent_memory_markdown.py b/tests/context/test_agent_memory_markdown.pyindex ce1a00d2..9bb6c290 100644--- a/tests/context/test_agent_memory_markdown.py+++ b/tests/context/test_agent_memory_markdown.py@@ -658,6 +658,38 @@ def test_empty_markdown_export_and_import_are_no_ops():assert memory.import_data("", format="markdown") == 0+def test_markdown_string_path_read_errors_are_not_treated_as_content(tmp_path):+ source = tmp_path / "memory.md"+ source.write_text(+ markdown_document(required_frontmatter(), "Content"), encoding="utf-8"+ )+ memory = AgentMemory()++ with patch.object(+ memory,+ "_read_markdown_path",+ side_effect=PermissionError("read denied"),+ ):+ with pytest.raises(PermissionError, match="read denied"):+ memory.import_data(str(source), format="markdown")+++def test_markdown_string_path_inspection_errors_are_actionable():+ memory = AgentMemory()++ with patch(+ "semantica.context.agent_memory.Path.exists",+ side_effect=PermissionError("inspection denied"),+ ):+ with pytest.raises(+ OSError, match="Failed to inspect possible Markdown import path"+ ) as exc_info:+ memory.import_data("memory.md", format="markdown")++ assert isinstance(exc_info.value.__cause__, PermissionError)+ assert "inspection denied" in str(exc_info.value.__cause__)++def test_legacy_dict_import_behavior_is_unchanged():memory = AgentMemory()data = {