Skip to content

Self-evolving Context Database for AI Agents. Unify Agent Memory, Knowledge RAG and Skills.

fix(semantic): do not materialize missing DAG roots (#4474)

Oneflye24b834e5a33
diff --git a/openviking/storage/queuefs/semantic_dag.py b/openviking/storage/queuefs/semantic_dag.py
index 9b51a1abc..0fa381e87 100644
--- a/openviking/storage/queuefs/semantic_dag.py
+++ b/openviking/storage/queuefs/semantic_dag.py
@@ -473,7 +473,7 @@ class SemanticDagExecutor:
logger.warning(
f"[SemanticDagExecutor] Failed to list directory {uri}: {e} from {from_hint}"
)
- return [], []
+ raise
children_dirs: List[str] = []
file_paths: List[str] = []
diff --git a/tests/storage/test_semantic_dag_skip_files.py b/tests/storage/test_semantic_dag_skip_files.py
index 7331e7bfe..505305daf 100644
--- a/tests/storage/test_semantic_dag_skip_files.py
+++ b/tests/storage/test_semantic_dag_skip_files.py
@@ -1,6 +1,8 @@
# Copyright (c) 2026 Beijing Volcano Engine Technology Co., Ltd.
# SPDX-License-Identifier: AGPL-3.0
+from types import SimpleNamespace
+
import pytest
from openviking.server.identity import RequestContext, Role
@@ -30,6 +32,23 @@ class _FakeVikingFS:
return uri.replace("viking://", "/local/acc1/")
+class _UnlistableRootVikingFS(_FakeVikingFS):
+ def __init__(self, *, fail_sidecar_write, list_error):
+ super().__init__({})
+ self.fail_sidecar_write = fail_sidecar_write
+ self.list_error = list_error
+ self.materialized_dirs = set()
+
+ async def ls(self, uri, node_limit=None, ctx=None):
+ raise self.list_error(uri)
+
+ async def write_file(self, path, content, ctx=None, lease_ref=None):
+ self.materialized_dirs.add(path.rsplit("/", 1)[0])
+ if self.fail_sidecar_write:
+ raise OSError("sidecar write failed after creating parent")
+ await super().write_file(path, content, ctx=ctx, lease_ref=lease_ref)
+
+
class _FakeProcessor:
def __init__(self):
self.summarized_files = []
@@ -133,5 +152,68 @@ async def test_messages_jsonl_excluded_in_subdirectory(monkeypatch):
assert "data.csv" in summarized_names
[email protected]("fail_sidecar_write", [False, True])
[email protected]("list_error", [FileNotFoundError, NotADirectoryError])
+async def test_unlistable_semantic_root_is_not_materialized_as_directory(
+ monkeypatch, fail_sidecar_write, list_error
+):
+ root_uri = "viking://user/user1/memories/profile.md"
+ fake_fs = _UnlistableRootVikingFS(
+ fail_sidecar_write=fail_sidecar_write,
+ list_error=list_error,
+ )
+ monkeypatch.setattr("openviking.storage.queuefs.semantic_dag.get_viking_fs", lambda: fake_fs)
+ monkeypatch.setattr(
+ "openviking.storage.queuefs.semantic_dag.get_openviking_config",
+ lambda: SimpleNamespace(semantic=SimpleNamespace(overview_sample_limit=32)),
+ )
+
+ processor = _FakeProcessor()
+ ctx = RequestContext(user=UserIdentifier("acc1", "user1"), role=Role.USER)
+ executor = SemanticDagExecutor(
+ processor=processor,
+ context_type="memory",
+ max_concurrent_llm=2,
+ ctx=ctx,
+ generation_trigger="reindex",
+ skip_vectorization=True,
+ )
+
+ await executor.run(root_uri)
+
+ assert root_uri not in fake_fs.materialized_dirs
+ assert fake_fs.writes == []
+
+
+async def test_empty_semantic_directory_still_receives_sidecars(monkeypatch):
+ root_uri = "viking://user/user1/memories/empty"
+ fake_fs = _FakeVikingFS({root_uri: []})
+ monkeypatch.setattr("openviking.storage.queuefs.semantic_dag.get_viking_fs", lambda: fake_fs)
+ monkeypatch.setattr(
+ "openviking.storage.queuefs.semantic_dag.get_openviking_config",
+ lambda: SimpleNamespace(semantic=SimpleNamespace(overview_sample_limit=32)),
+ )
+
+ processor = _FakeProcessor()
+ ctx = RequestContext(user=UserIdentifier("acc1", "user1"), role=Role.USER)
+ executor = SemanticDagExecutor(
+ processor=processor,
+ context_type="memory",
+ max_concurrent_llm=2,
+ ctx=ctx,
+ generation_trigger="reindex",
+ skip_vectorization=True,
+ )
+
+ await executor.run(root_uri)
+
+ assert [path for path, _content in fake_fs.writes] == [
+ f"{root_uri}/.overview.md",
+ f"{root_uri}/.abstract.md",
+ ]
+
+
if __name__ == "__main__":
pytest.main([__file__])