We are currently solving the following issue within our repository. Here is the issue text:
--- BEGIN ISSUE ---
ALTER MODULE foo RENAME TO bar gives ISE
We should produce a parse error or an unimplemented message.

We could actually support it, but it might actually be kind of hairy to do, since in the data model modules really don't *do* anything, they *just* lay claim to a name. (And DDL isn't *that* important anyway; renaming a module might actually work in SDL...)

--- END ISSUE ---

Below are some code segments, each from a relevant file. One or more of these files may contain bugs.
--- BEGIN FILES ---
Path: `edb/schema/modules.py`
Content:
```
1 #
2 # This source file is part of the EdgeDB open source project.
3 #
4 # Copyright 2008-present MagicStack Inc. and the EdgeDB authors.
5 #
6 # Licensed under the Apache License, Version 2.0 (the "License");
7 # you may not use this file except in compliance with the License.
8 # You may obtain a copy of the License at
9 #
10 #     http://www.apache.org/licenses/LICENSE-2.0
11 #
12 # Unless required by applicable law or agreed to in writing, software
13 # distributed under the License is distributed on an "AS IS" BASIS,
14 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 # See the License for the specific language governing permissions and
16 # limitations under the License.
17 #
18 
19 
20 from __future__ import annotations
21 
22 
23 from edb import errors
24 
25 from edb.edgeql import ast as qlast
26 from edb.edgeql import qltypes
27 
28 from . import annos as s_anno
29 from . import delta as sd
30 from . import name as sn
31 from . import objects as so
32 from . import schema as s_schema
33 
34 RESERVED_MODULE_NAMES = {
35     'super',
36 }
37 
38 
39 class Module(
40     s_anno.AnnotationSubject,
41     so.Object,  # Help reflection figure out the right db MRO
42     qlkind=qltypes.SchemaObjectClass.MODULE,
43     data_safe=False,
44 ):
45     # N.B: Modules are not "qualified" objects, even though they can
46     # be nested (because they might *not* be nested) and we arrange
47     # for their names to always be represented with an UnqualName.
48     pass
49 
50 
51 class ModuleCommandContext(sd.ObjectCommandContext[Module]):
52     pass
53 
54 
55 class ModuleCommand(
56     sd.ObjectCommand[Module],
57     context_class=ModuleCommandContext,
58 ):
59 
60     def _validate_legal_command(
61         self,
62         schema: s_schema.Schema,
63         context: sd.CommandContext,
64     ) -> None:
65         super()._validate_legal_command(schema, context)
66 
67         last = str(self.classname)
68         first = last
69         enclosing = None
70         if '::' in str(self.classname):
71             first, _, _ = str(self.classname).partition('::')
72             enclosing, _, last = str(self.classname).rpartition('::')
73             if not schema.has_module(enclosing):
74                 raise errors.UnknownModuleError(
75                     f'module {enclosing!r} is not in this schema')
76 
77         if last in RESERVED_MODULE_NAMES:
78             raise errors.SchemaDefinitionError(
79                 f"module {last!r} is a reserved module name")
80 
81         if (
82             not context.stdmode and not context.testmode
83             and sn.UnqualName(first) in s_schema.STD_MODULES
84         ):
85             raise errors.SchemaDefinitionError(
86                 f'cannot {self._delta_action} {self.get_verbosename()}: '
87                 f'module {first} is read-only',
88                 span=self.span)
89 
90 
91 class CreateModule(ModuleCommand, sd.CreateObject[Module]):
92     astnode = qlast.CreateModule
93 
94 
95 class AlterModule(ModuleCommand, sd.AlterObject[Module]):
96     astnode = qlast.AlterModule
97 
98 
99 class DeleteModule(ModuleCommand, sd.DeleteObject[Module]):
100     astnode = qlast.DropModule
101 
102     def _validate_legal_command(
103         self,
104         schema: s_schema.Schema,
105         context: sd.CommandContext,
106     ) -> None:
107         super()._validate_legal_command(schema, context)
108 
109         # For now, we disallow deleting non-empty modules.
110 
111         # Modules aren't actually stored with any direct linkage
112         # to the objects in them, so explicitly search for objects
113         # in the module (excluding the module itself).
114         has_objects = bool(any(schema.get_objects(
115             included_modules=[self.classname],
116             excluded_items=[self.classname],
117         )))
118 
119         if has_objects:
120             vn = self.scls.get_verbosename(schema)
121             raise errors.SchemaError(
122                 f'cannot drop {vn} because it is not empty'
123             )
124
```
--- END FILES ---

Please first localize the bug based on the issue statement, and then generate a patch according to the `git diff` format fenced by three backticks.

Here is an example:

```diff
diff --git a/examples/server_async.py b/examples/server_async.py
--- a/examples/server_async.py
+++ b/examples/server_async.py
@@ -313,4 +313,4 @@
 
 
 if __name__ == "__main__":
-    asyncio.run(run_async_server("."), debug=True)
+    asyncio.run(run_async_server(), debug=True)
diff --git a/examples/server_sync.py b/examples/server_sync.py
--- a/examples/server_sync.py
+++ b/examples/server_sync.py
@@ -313,5 +313,5 @@
 
 
 if __name__ == "__main__":
-    server = run_sync_server(".")
+    server = run_sync_server()
     server.shutdown()

```

diff --git a/edb/schema/modules.py b/edb/schema/modules.py
--- a/edb/schema/modules.py
+++ b/edb/schema/modules.py
@@ -96,6 +96,19 @@
     astnode = qlast.AlterModule
 
 
+class RenameModule(ModuleCommand, sd.RenameObject[Module]):
+
+    def apply(
+        self,
+        schema: s_schema.Schema,
+        context: sd.CommandContext,
+    ) -> s_schema.Schema:
+        raise errors.SchemaError(
+            f'renaming modules is not supported',
+            span=self.span,
+        )
+
+
 class DeleteModule(ModuleCommand, sd.DeleteObject[Module]):
     astnode = qlast.DropModule

{"golden_diff": "diff --git a/edb/schema/modules.py b/edb/schema/modules.py\n--- a/edb/schema/modules.py\n+++ b/edb/schema/modules.py\n@@ -96,6 +96,19 @@\n     astnode = qlast.AlterModule\n \n \n+class RenameModule(ModuleCommand, sd.RenameObject[Module]):\n+\n+    def apply(\n+        self,\n+        schema: s_schema.Schema,\n+        context: sd.CommandContext,\n+    ) -> s_schema.Schema:\n+        raise errors.SchemaError(\n+            f'renaming modules is not supported',\n+            span=self.span,\n+        )\n+\n+\n class DeleteModule(ModuleCommand, sd.DeleteObject[Module]):\n     astnode = qlast.DropModule\n", "issue": "ALTER MODULE foo RENAME TO bar gives ISE\nWe should produce a parse error or an unimplemented message.\r\n\r\nWe could actually support it, but it might actually be kind of hairy to do, since in the data model modules really don't *do* anything, they *just* lay claim to a name. (And DDL isn't *that* important anyway; renaming a module might actually work in SDL...)\n", "before_files": [{"content": "#\n# This source file is part of the EdgeDB open source project.\n#\n# Copyright 2008-present MagicStack Inc. and the EdgeDB authors.\n#\n# Licensed under the Apache License, Version 2.0 (the \"License\");\n# you may not use this file except in compliance with the License.\n# You may obtain a copy of the License at\n#\n#     http://www.apache.org/licenses/LICENSE-2.0\n#\n# Unless required by applicable law or agreed to in writing, software\n# distributed under the License is distributed on an \"AS IS\" BASIS,\n# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n# See the License for the specific language governing permissions and\n# limitations under the License.\n#\n\n\nfrom __future__ import annotations\n\n\nfrom edb import errors\n\nfrom edb.edgeql import ast as qlast\nfrom edb.edgeql import qltypes\n\nfrom . import annos as s_anno\nfrom . import delta as sd\nfrom . import name as sn\nfrom . import objects as so\nfrom . import schema as s_schema\n\nRESERVED_MODULE_NAMES = {\n    'super',\n}\n\n\nclass Module(\n    s_anno.AnnotationSubject,\n    so.Object,  # Help reflection figure out the right db MRO\n    qlkind=qltypes.SchemaObjectClass.MODULE,\n    data_safe=False,\n):\n    # N.B: Modules are not \"qualified\" objects, even though they can\n    # be nested (because they might *not* be nested) and we arrange\n    # for their names to always be represented with an UnqualName.\n    pass\n\n\nclass ModuleCommandContext(sd.ObjectCommandContext[Module]):\n    pass\n\n\nclass ModuleCommand(\n    sd.ObjectCommand[Module],\n    context_class=ModuleCommandContext,\n):\n\n    def _validate_legal_command(\n        self,\n        schema: s_schema.Schema,\n        context: sd.CommandContext,\n    ) -> None:\n        super()._validate_legal_command(schema, context)\n\n        last = str(self.classname)\n        first = last\n        enclosing = None\n        if '::' in str(self.classname):\n            first, _, _ = str(self.classname).partition('::')\n            enclosing, _, last = str(self.classname).rpartition('::')\n            if not schema.has_module(enclosing):\n                raise errors.UnknownModuleError(\n                    f'module {enclosing!r} is not in this schema')\n\n        if last in RESERVED_MODULE_NAMES:\n            raise errors.SchemaDefinitionError(\n                f\"module {last!r} is a reserved module name\")\n\n        if (\n            not context.stdmode and not context.testmode\n            and sn.UnqualName(first) in s_schema.STD_MODULES\n        ):\n            raise errors.SchemaDefinitionError(\n                f'cannot {self._delta_action} {self.get_verbosename()}: '\n                f'module {first} is read-only',\n                span=self.span)\n\n\nclass CreateModule(ModuleCommand, sd.CreateObject[Module]):\n    astnode = qlast.CreateModule\n\n\nclass AlterModule(ModuleCommand, sd.AlterObject[Module]):\n    astnode = qlast.AlterModule\n\n\nclass DeleteModule(ModuleCommand, sd.DeleteObject[Module]):\n    astnode = qlast.DropModule\n\n    def _validate_legal_command(\n        self,\n        schema: s_schema.Schema,\n        context: sd.CommandContext,\n    ) -> None:\n        super()._validate_legal_command(schema, context)\n\n        # For now, we disallow deleting non-empty modules.\n\n        # Modules aren't actually stored with any direct linkage\n        # to the objects in them, so explicitly search for objects\n        # in the module (excluding the module itself).\n        has_objects = bool(any(schema.get_objects(\n            included_modules=[self.classname],\n            excluded_items=[self.classname],\n        )))\n\n        if has_objects:\n            vn = self.scls.get_verbosename(schema)\n            raise errors.SchemaError(\n                f'cannot drop {vn} because it is not empty'\n            )\n", "path": "edb/schema/modules.py"}], "after_files": [{"content": "#\n# This source file is part of the EdgeDB open source project.\n#\n# Copyright 2008-present MagicStack Inc. and the EdgeDB authors.\n#\n# Licensed under the Apache License, Version 2.0 (the \"License\");\n# you may not use this file except in compliance with the License.\n# You may obtain a copy of the License at\n#\n#     http://www.apache.org/licenses/LICENSE-2.0\n#\n# Unless required by applicable law or agreed to in writing, software\n# distributed under the License is distributed on an \"AS IS\" BASIS,\n# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n# See the License for the specific language governing permissions and\n# limitations under the License.\n#\n\n\nfrom __future__ import annotations\n\n\nfrom edb import errors\n\nfrom edb.edgeql import ast as qlast\nfrom edb.edgeql import qltypes\n\nfrom . import annos as s_anno\nfrom . import delta as sd\nfrom . import name as sn\nfrom . import objects as so\nfrom . import schema as s_schema\n\nRESERVED_MODULE_NAMES = {\n    'super',\n}\n\n\nclass Module(\n    s_anno.AnnotationSubject,\n    so.Object,  # Help reflection figure out the right db MRO\n    qlkind=qltypes.SchemaObjectClass.MODULE,\n    data_safe=False,\n):\n    # N.B: Modules are not \"qualified\" objects, even though they can\n    # be nested (because they might *not* be nested) and we arrange\n    # for their names to always be represented with an UnqualName.\n    pass\n\n\nclass ModuleCommandContext(sd.ObjectCommandContext[Module]):\n    pass\n\n\nclass ModuleCommand(\n    sd.ObjectCommand[Module],\n    context_class=ModuleCommandContext,\n):\n\n    def _validate_legal_command(\n        self,\n        schema: s_schema.Schema,\n        context: sd.CommandContext,\n    ) -> None:\n        super()._validate_legal_command(schema, context)\n\n        last = str(self.classname)\n        first = last\n        enclosing = None\n        if '::' in str(self.classname):\n            first, _, _ = str(self.classname).partition('::')\n            enclosing, _, last = str(self.classname).rpartition('::')\n            if not schema.has_module(enclosing):\n                raise errors.UnknownModuleError(\n                    f'module {enclosing!r} is not in this schema')\n\n        if last in RESERVED_MODULE_NAMES:\n            raise errors.SchemaDefinitionError(\n                f\"module {last!r} is a reserved module name\")\n\n        if (\n            not context.stdmode and not context.testmode\n            and sn.UnqualName(first) in s_schema.STD_MODULES\n        ):\n            raise errors.SchemaDefinitionError(\n                f'cannot {self._delta_action} {self.get_verbosename()}: '\n                f'module {first} is read-only',\n                span=self.span)\n\n\nclass CreateModule(ModuleCommand, sd.CreateObject[Module]):\n    astnode = qlast.CreateModule\n\n\nclass AlterModule(ModuleCommand, sd.AlterObject[Module]):\n    astnode = qlast.AlterModule\n\n\nclass RenameModule(ModuleCommand, sd.RenameObject[Module]):\n\n    def apply(\n        self,\n        schema: s_schema.Schema,\n        context: sd.CommandContext,\n    ) -> s_schema.Schema:\n        raise errors.SchemaError(\n            f'renaming modules is not supported',\n            span=self.span,\n        )\n\n\nclass DeleteModule(ModuleCommand, sd.DeleteObject[Module]):\n    astnode = qlast.DropModule\n\n    def _validate_legal_command(\n        self,\n        schema: s_schema.Schema,\n        context: sd.CommandContext,\n    ) -> None:\n        super()._validate_legal_command(schema, context)\n\n        # For now, we disallow deleting non-empty modules.\n\n        # Modules aren't actually stored with any direct linkage\n        # to the objects in them, so explicitly search for objects\n        # in the module (excluding the module itself).\n        has_objects = bool(any(schema.get_objects(\n            included_modules=[self.classname],\n            excluded_items=[self.classname],\n        )))\n\n        if has_objects:\n            vn = self.scls.get_verbosename(schema)\n            raise errors.SchemaError(\n                f'cannot drop {vn} because it is not empty'\n            )\n", "path": "edb/schema/modules.py"}]}