Self-evolving Context Database for AI Agents. Unify Agent Memory, Knowledge RAG and Skills.
Python agent-contextagent-memoryagent-pluginsagentic-ragcontext-databasedsh-pluginknowledge-basememorymemory-managementself-evolvingvector-database
fix(storage): honor delete-protected roots on mv source (parity with #2873) (#2898)
Evoc2384e1d4948
diff --git a/openviking/storage/viking_fs.py b/openviking/storage/viking_fs.pyindex b1af53dc1..e632fbdfa 100644--- a/openviking/storage/viking_fs.py+++ b/openviking/storage/viking_fs.py@@ -608,6 +608,12 @@ class VikingFS:from openviking.storage.transaction import LockContext, get_lock_managerself._ensure_mutable_access(old_uri, ctx)+ # mv is implemented as copy + recursive rm of the source (see the+ # ``rm(old_path, recursive=is_dir)`` below), so the source must also clear+ # the delete guard. Without this, a protected account root such as+ # ``viking://`` — which rm() rejects up front (#2873) — could still be+ # destroyed via mv, since the write guard alone permits the bare root.+ self._ensure_delete_access(old_uri, ctx)self._ensure_mutable_access(new_uri, ctx)old_path = self._uri_to_path(old_uri, ctx=ctx)new_path = self._uri_to_path(new_uri, ctx=ctx)diff --git a/tests/misc/test_vikingfs_uri_guard.py b/tests/misc/test_vikingfs_uri_guard.pyindex f64d2122f..8fab4255e 100644--- a/tests/misc/test_vikingfs_uri_guard.py+++ b/tests/misc/test_vikingfs_uri_guard.py@@ -189,6 +189,40 @@ class TestVikingFSURITraversalGuard:fs._delete_from_vector_store.assert_not_called()fs.agfs.mv.assert_not_called()+ @pytest.mark.asyncio+ @pytest.mark.parametrize(+ ("source_uri", "match"),+ [+ # Bare account root: the net-new gap — rm() rejects it (#2873) but mv()'s+ # write guard alone used to let it through to the recursive source delete.+ ("viking://", "Deleting viking://"),+ ("/", "Deleting viking://"),+ # viking://user is already blocked by the write guard; assert mv still+ # refuses it (parity with rm) regardless of which guard fires first.+ ("viking://user", "viking://user is not supported"),+ ("viking://user/", "viking://user is not supported"),+ ("/user", "viking://user is not supported"),+ ("user", "viking://user is not supported"),+ ],+ )+ async def test_mv_rejects_protected_namespace_roots_in_source_before_side_effects(+ self, source_uri: str, match: str+ ) -> None:+ fs = _make_viking_fs()+ fs._collect_uris = AsyncMock(return_value=[])+ fs._update_vector_store_uris = AsyncMock()+ fs._delete_from_vector_store = AsyncMock()++ with pytest.raises(PermissionDeniedError, match=match):+ await fs.mv(source_uri, "viking://temp/dst")++ fs._collect_uris.assert_not_called()+ fs._update_vector_store_uris.assert_not_called()+ fs._delete_from_vector_store.assert_not_called()+ fs.agfs.stat.assert_not_called()+ fs.agfs.rm.assert_not_called()+ fs.agfs.mv.assert_not_called()+@pytest.mark.asyncioasync def test_read_file_keeps_valid_uri_behavior(self) -> None:fs = _make_viking_fs()