prompt: We are currently solving the following issue within our repository. Here is the issue text:
  --- BEGIN ISSUE ---
  Implement room version 6
  Will contain additional features:
  * #6898
  * https://github.com/matrix-org/synapse/pull/7381
  * #7501
  
  Do not enable by default just yet.
  
  --- END ISSUE ---
  
  Below are some code segments, each from a relevant file. One or more of these files may contain bugs.
  --- BEGIN FILES ---
  Path: `synapse/api/room_versions.py`
  Content:
  ```
  1 # -*- coding: utf-8 -*-
  2 # Copyright 2019 New Vector Ltd
  3 #
  4 # Licensed under the Apache License, Version 2.0 (the "License");
  5 # you may not use this file except in compliance with the License.
  6 # You may obtain a copy of the License at
  7 #
  8 #     http://www.apache.org/licenses/LICENSE-2.0
  9 #
  10 # Unless required by applicable law or agreed to in writing, software
  11 # distributed under the License is distributed on an "AS IS" BASIS,
  12 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13 # See the License for the specific language governing permissions and
  14 # limitations under the License.
  15 
  16 from typing import Dict
  17 
  18 import attr
  19 
  20 
  21 class EventFormatVersions(object):
  22     """This is an internal enum for tracking the version of the event format,
  23     independently from the room version.
  24     """
  25 
  26     V1 = 1  # $id:server event id format
  27     V2 = 2  # MSC1659-style $hash event id format: introduced for room v3
  28     V3 = 3  # MSC1884-style $hash format: introduced for room v4
  29 
  30 
  31 KNOWN_EVENT_FORMAT_VERSIONS = {
  32     EventFormatVersions.V1,
  33     EventFormatVersions.V2,
  34     EventFormatVersions.V3,
  35 }
  36 
  37 
  38 class StateResolutionVersions(object):
  39     """Enum to identify the state resolution algorithms"""
  40 
  41     V1 = 1  # room v1 state res
  42     V2 = 2  # MSC1442 state res: room v2 and later
  43 
  44 
  45 class RoomDisposition(object):
  46     STABLE = "stable"
  47     UNSTABLE = "unstable"
  48 
  49 
  50 @attr.s(slots=True, frozen=True)
  51 class RoomVersion(object):
  52     """An object which describes the unique attributes of a room version."""
  53 
  54     identifier = attr.ib()  # str; the identifier for this version
  55     disposition = attr.ib()  # str; one of the RoomDispositions
  56     event_format = attr.ib()  # int; one of the EventFormatVersions
  57     state_res = attr.ib()  # int; one of the StateResolutionVersions
  58     enforce_key_validity = attr.ib()  # bool
  59 
  60     # bool: before MSC2261/MSC2432, m.room.aliases had special auth rules and redaction rules
  61     special_case_aliases_auth = attr.ib(type=bool)
  62     # Strictly enforce canonicaljson, do not allow:
  63     # * Integers outside the range of [-2 ^ 53 + 1, 2 ^ 53 - 1]
  64     # * Floats
  65     # * NaN, Infinity, -Infinity
  66     strict_canonicaljson = attr.ib(type=bool)
  67     # bool: MSC2209: Check 'notifications' key while verifying
  68     # m.room.power_levels auth rules.
  69     limit_notifications_power_levels = attr.ib(type=bool)
  70 
  71 
  72 class RoomVersions(object):
  73     V1 = RoomVersion(
  74         "1",
  75         RoomDisposition.STABLE,
  76         EventFormatVersions.V1,
  77         StateResolutionVersions.V1,
  78         enforce_key_validity=False,
  79         special_case_aliases_auth=True,
  80         strict_canonicaljson=False,
  81         limit_notifications_power_levels=False,
  82     )
  83     V2 = RoomVersion(
  84         "2",
  85         RoomDisposition.STABLE,
  86         EventFormatVersions.V1,
  87         StateResolutionVersions.V2,
  88         enforce_key_validity=False,
  89         special_case_aliases_auth=True,
  90         strict_canonicaljson=False,
  91         limit_notifications_power_levels=False,
  92     )
  93     V3 = RoomVersion(
  94         "3",
  95         RoomDisposition.STABLE,
  96         EventFormatVersions.V2,
  97         StateResolutionVersions.V2,
  98         enforce_key_validity=False,
  99         special_case_aliases_auth=True,
  100         strict_canonicaljson=False,
  101         limit_notifications_power_levels=False,
  102     )
  103     V4 = RoomVersion(
  104         "4",
  105         RoomDisposition.STABLE,
  106         EventFormatVersions.V3,
  107         StateResolutionVersions.V2,
  108         enforce_key_validity=False,
  109         special_case_aliases_auth=True,
  110         strict_canonicaljson=False,
  111         limit_notifications_power_levels=False,
  112     )
  113     V5 = RoomVersion(
  114         "5",
  115         RoomDisposition.STABLE,
  116         EventFormatVersions.V3,
  117         StateResolutionVersions.V2,
  118         enforce_key_validity=True,
  119         special_case_aliases_auth=True,
  120         strict_canonicaljson=False,
  121         limit_notifications_power_levels=False,
  122     )
  123     MSC2432_DEV = RoomVersion(
  124         "org.matrix.msc2432",
  125         RoomDisposition.UNSTABLE,
  126         EventFormatVersions.V3,
  127         StateResolutionVersions.V2,
  128         enforce_key_validity=True,
  129         special_case_aliases_auth=False,
  130         strict_canonicaljson=False,
  131         limit_notifications_power_levels=False,
  132     )
  133     STRICT_CANONICALJSON = RoomVersion(
  134         "org.matrix.strict_canonicaljson",
  135         RoomDisposition.UNSTABLE,
  136         EventFormatVersions.V3,
  137         StateResolutionVersions.V2,
  138         enforce_key_validity=True,
  139         special_case_aliases_auth=True,
  140         strict_canonicaljson=True,
  141         limit_notifications_power_levels=False,
  142     )
  143     MSC2209_DEV = RoomVersion(
  144         "org.matrix.msc2209",
  145         RoomDisposition.UNSTABLE,
  146         EventFormatVersions.V3,
  147         StateResolutionVersions.V2,
  148         enforce_key_validity=True,
  149         special_case_aliases_auth=True,
  150         strict_canonicaljson=False,
  151         limit_notifications_power_levels=True,
  152     )
  153 
  154 
  155 KNOWN_ROOM_VERSIONS = {
  156     v.identifier: v
  157     for v in (
  158         RoomVersions.V1,
  159         RoomVersions.V2,
  160         RoomVersions.V3,
  161         RoomVersions.V4,
  162         RoomVersions.V5,
  163         RoomVersions.MSC2432_DEV,
  164         RoomVersions.STRICT_CANONICALJSON,
  165         RoomVersions.MSC2209_DEV,
  166     )
  167 }  # type: Dict[str, RoomVersion]
  168
  ```
  --- 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()
  
  ```
  
golden_diff: diff --git a/synapse/api/room_versions.py b/synapse/api/room_versions.py
  --- a/synapse/api/room_versions.py
  +++ b/synapse/api/room_versions.py
  @@ -120,34 +120,14 @@
           strict_canonicaljson=False,
           limit_notifications_power_levels=False,
       )
  -    MSC2432_DEV = RoomVersion(
  -        "org.matrix.msc2432",
  -        RoomDisposition.UNSTABLE,
  +    V6 = RoomVersion(
  +        "6",
  +        RoomDisposition.STABLE,
           EventFormatVersions.V3,
           StateResolutionVersions.V2,
           enforce_key_validity=True,
           special_case_aliases_auth=False,
  -        strict_canonicaljson=False,
  -        limit_notifications_power_levels=False,
  -    )
  -    STRICT_CANONICALJSON = RoomVersion(
  -        "org.matrix.strict_canonicaljson",
  -        RoomDisposition.UNSTABLE,
  -        EventFormatVersions.V3,
  -        StateResolutionVersions.V2,
  -        enforce_key_validity=True,
  -        special_case_aliases_auth=True,
           strict_canonicaljson=True,
  -        limit_notifications_power_levels=False,
  -    )
  -    MSC2209_DEV = RoomVersion(
  -        "org.matrix.msc2209",
  -        RoomDisposition.UNSTABLE,
  -        EventFormatVersions.V3,
  -        StateResolutionVersions.V2,
  -        enforce_key_validity=True,
  -        special_case_aliases_auth=True,
  -        strict_canonicaljson=False,
           limit_notifications_power_levels=True,
       )
   
  @@ -160,8 +140,6 @@
           RoomVersions.V3,
           RoomVersions.V4,
           RoomVersions.V5,
  -        RoomVersions.MSC2432_DEV,
  -        RoomVersions.STRICT_CANONICALJSON,
  -        RoomVersions.MSC2209_DEV,
  +        RoomVersions.V6,
       )
   }  # type: Dict[str, RoomVersion]
  
verification_info: {"golden_diff": "diff --git a/synapse/api/room_versions.py b/synapse/api/room_versions.py\n--- a/synapse/api/room_versions.py\n+++ b/synapse/api/room_versions.py\n@@ -120,34 +120,14 @@\n         strict_canonicaljson=False,\n         limit_notifications_power_levels=False,\n     )\n-    MSC2432_DEV = RoomVersion(\n-        \"org.matrix.msc2432\",\n-        RoomDisposition.UNSTABLE,\n+    V6 = RoomVersion(\n+        \"6\",\n+        RoomDisposition.STABLE,\n         EventFormatVersions.V3,\n         StateResolutionVersions.V2,\n         enforce_key_validity=True,\n         special_case_aliases_auth=False,\n-        strict_canonicaljson=False,\n-        limit_notifications_power_levels=False,\n-    )\n-    STRICT_CANONICALJSON = RoomVersion(\n-        \"org.matrix.strict_canonicaljson\",\n-        RoomDisposition.UNSTABLE,\n-        EventFormatVersions.V3,\n-        StateResolutionVersions.V2,\n-        enforce_key_validity=True,\n-        special_case_aliases_auth=True,\n         strict_canonicaljson=True,\n-        limit_notifications_power_levels=False,\n-    )\n-    MSC2209_DEV = RoomVersion(\n-        \"org.matrix.msc2209\",\n-        RoomDisposition.UNSTABLE,\n-        EventFormatVersions.V3,\n-        StateResolutionVersions.V2,\n-        enforce_key_validity=True,\n-        special_case_aliases_auth=True,\n-        strict_canonicaljson=False,\n         limit_notifications_power_levels=True,\n     )\n \n@@ -160,8 +140,6 @@\n         RoomVersions.V3,\n         RoomVersions.V4,\n         RoomVersions.V5,\n-        RoomVersions.MSC2432_DEV,\n-        RoomVersions.STRICT_CANONICALJSON,\n-        RoomVersions.MSC2209_DEV,\n+        RoomVersions.V6,\n     )\n }  # type: Dict[str, RoomVersion]\n", "issue": "Implement room version 6\nWill contain additional features:\r\n* #6898\r\n* https://github.com/matrix-org/synapse/pull/7381\r\n* #7501\r\n\r\nDo not enable by default just yet.\n", "before_files": [{"content": "# -*- coding: utf-8 -*-\n# Copyright 2019 New Vector Ltd\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\nfrom typing import Dict\n\nimport attr\n\n\nclass EventFormatVersions(object):\n    \"\"\"This is an internal enum for tracking the version of the event format,\n    independently from the room version.\n    \"\"\"\n\n    V1 = 1  # $id:server event id format\n    V2 = 2  # MSC1659-style $hash event id format: introduced for room v3\n    V3 = 3  # MSC1884-style $hash format: introduced for room v4\n\n\nKNOWN_EVENT_FORMAT_VERSIONS = {\n    EventFormatVersions.V1,\n    EventFormatVersions.V2,\n    EventFormatVersions.V3,\n}\n\n\nclass StateResolutionVersions(object):\n    \"\"\"Enum to identify the state resolution algorithms\"\"\"\n\n    V1 = 1  # room v1 state res\n    V2 = 2  # MSC1442 state res: room v2 and later\n\n\nclass RoomDisposition(object):\n    STABLE = \"stable\"\n    UNSTABLE = \"unstable\"\n\n\n@attr.s(slots=True, frozen=True)\nclass RoomVersion(object):\n    \"\"\"An object which describes the unique attributes of a room version.\"\"\"\n\n    identifier = attr.ib()  # str; the identifier for this version\n    disposition = attr.ib()  # str; one of the RoomDispositions\n    event_format = attr.ib()  # int; one of the EventFormatVersions\n    state_res = attr.ib()  # int; one of the StateResolutionVersions\n    enforce_key_validity = attr.ib()  # bool\n\n    # bool: before MSC2261/MSC2432, m.room.aliases had special auth rules and redaction rules\n    special_case_aliases_auth = attr.ib(type=bool)\n    # Strictly enforce canonicaljson, do not allow:\n    # * Integers outside the range of [-2 ^ 53 + 1, 2 ^ 53 - 1]\n    # * Floats\n    # * NaN, Infinity, -Infinity\n    strict_canonicaljson = attr.ib(type=bool)\n    # bool: MSC2209: Check 'notifications' key while verifying\n    # m.room.power_levels auth rules.\n    limit_notifications_power_levels = attr.ib(type=bool)\n\n\nclass RoomVersions(object):\n    V1 = RoomVersion(\n        \"1\",\n        RoomDisposition.STABLE,\n        EventFormatVersions.V1,\n        StateResolutionVersions.V1,\n        enforce_key_validity=False,\n        special_case_aliases_auth=True,\n        strict_canonicaljson=False,\n        limit_notifications_power_levels=False,\n    )\n    V2 = RoomVersion(\n        \"2\",\n        RoomDisposition.STABLE,\n        EventFormatVersions.V1,\n        StateResolutionVersions.V2,\n        enforce_key_validity=False,\n        special_case_aliases_auth=True,\n        strict_canonicaljson=False,\n        limit_notifications_power_levels=False,\n    )\n    V3 = RoomVersion(\n        \"3\",\n        RoomDisposition.STABLE,\n        EventFormatVersions.V2,\n        StateResolutionVersions.V2,\n        enforce_key_validity=False,\n        special_case_aliases_auth=True,\n        strict_canonicaljson=False,\n        limit_notifications_power_levels=False,\n    )\n    V4 = RoomVersion(\n        \"4\",\n        RoomDisposition.STABLE,\n        EventFormatVersions.V3,\n        StateResolutionVersions.V2,\n        enforce_key_validity=False,\n        special_case_aliases_auth=True,\n        strict_canonicaljson=False,\n        limit_notifications_power_levels=False,\n    )\n    V5 = RoomVersion(\n        \"5\",\n        RoomDisposition.STABLE,\n        EventFormatVersions.V3,\n        StateResolutionVersions.V2,\n        enforce_key_validity=True,\n        special_case_aliases_auth=True,\n        strict_canonicaljson=False,\n        limit_notifications_power_levels=False,\n    )\n    MSC2432_DEV = RoomVersion(\n        \"org.matrix.msc2432\",\n        RoomDisposition.UNSTABLE,\n        EventFormatVersions.V3,\n        StateResolutionVersions.V2,\n        enforce_key_validity=True,\n        special_case_aliases_auth=False,\n        strict_canonicaljson=False,\n        limit_notifications_power_levels=False,\n    )\n    STRICT_CANONICALJSON = RoomVersion(\n        \"org.matrix.strict_canonicaljson\",\n        RoomDisposition.UNSTABLE,\n        EventFormatVersions.V3,\n        StateResolutionVersions.V2,\n        enforce_key_validity=True,\n        special_case_aliases_auth=True,\n        strict_canonicaljson=True,\n        limit_notifications_power_levels=False,\n    )\n    MSC2209_DEV = RoomVersion(\n        \"org.matrix.msc2209\",\n        RoomDisposition.UNSTABLE,\n        EventFormatVersions.V3,\n        StateResolutionVersions.V2,\n        enforce_key_validity=True,\n        special_case_aliases_auth=True,\n        strict_canonicaljson=False,\n        limit_notifications_power_levels=True,\n    )\n\n\nKNOWN_ROOM_VERSIONS = {\n    v.identifier: v\n    for v in (\n        RoomVersions.V1,\n        RoomVersions.V2,\n        RoomVersions.V3,\n        RoomVersions.V4,\n        RoomVersions.V5,\n        RoomVersions.MSC2432_DEV,\n        RoomVersions.STRICT_CANONICALJSON,\n        RoomVersions.MSC2209_DEV,\n    )\n}  # type: Dict[str, RoomVersion]\n", "path": "synapse/api/room_versions.py"}], "after_files": [{"content": "# -*- coding: utf-8 -*-\n# Copyright 2019 New Vector Ltd\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\nfrom typing import Dict\n\nimport attr\n\n\nclass EventFormatVersions(object):\n    \"\"\"This is an internal enum for tracking the version of the event format,\n    independently from the room version.\n    \"\"\"\n\n    V1 = 1  # $id:server event id format\n    V2 = 2  # MSC1659-style $hash event id format: introduced for room v3\n    V3 = 3  # MSC1884-style $hash format: introduced for room v4\n\n\nKNOWN_EVENT_FORMAT_VERSIONS = {\n    EventFormatVersions.V1,\n    EventFormatVersions.V2,\n    EventFormatVersions.V3,\n}\n\n\nclass StateResolutionVersions(object):\n    \"\"\"Enum to identify the state resolution algorithms\"\"\"\n\n    V1 = 1  # room v1 state res\n    V2 = 2  # MSC1442 state res: room v2 and later\n\n\nclass RoomDisposition(object):\n    STABLE = \"stable\"\n    UNSTABLE = \"unstable\"\n\n\n@attr.s(slots=True, frozen=True)\nclass RoomVersion(object):\n    \"\"\"An object which describes the unique attributes of a room version.\"\"\"\n\n    identifier = attr.ib()  # str; the identifier for this version\n    disposition = attr.ib()  # str; one of the RoomDispositions\n    event_format = attr.ib()  # int; one of the EventFormatVersions\n    state_res = attr.ib()  # int; one of the StateResolutionVersions\n    enforce_key_validity = attr.ib()  # bool\n\n    # bool: before MSC2261/MSC2432, m.room.aliases had special auth rules and redaction rules\n    special_case_aliases_auth = attr.ib(type=bool)\n    # Strictly enforce canonicaljson, do not allow:\n    # * Integers outside the range of [-2 ^ 53 + 1, 2 ^ 53 - 1]\n    # * Floats\n    # * NaN, Infinity, -Infinity\n    strict_canonicaljson = attr.ib(type=bool)\n    # bool: MSC2209: Check 'notifications' key while verifying\n    # m.room.power_levels auth rules.\n    limit_notifications_power_levels = attr.ib(type=bool)\n\n\nclass RoomVersions(object):\n    V1 = RoomVersion(\n        \"1\",\n        RoomDisposition.STABLE,\n        EventFormatVersions.V1,\n        StateResolutionVersions.V1,\n        enforce_key_validity=False,\n        special_case_aliases_auth=True,\n        strict_canonicaljson=False,\n        limit_notifications_power_levels=False,\n    )\n    V2 = RoomVersion(\n        \"2\",\n        RoomDisposition.STABLE,\n        EventFormatVersions.V1,\n        StateResolutionVersions.V2,\n        enforce_key_validity=False,\n        special_case_aliases_auth=True,\n        strict_canonicaljson=False,\n        limit_notifications_power_levels=False,\n    )\n    V3 = RoomVersion(\n        \"3\",\n        RoomDisposition.STABLE,\n        EventFormatVersions.V2,\n        StateResolutionVersions.V2,\n        enforce_key_validity=False,\n        special_case_aliases_auth=True,\n        strict_canonicaljson=False,\n        limit_notifications_power_levels=False,\n    )\n    V4 = RoomVersion(\n        \"4\",\n        RoomDisposition.STABLE,\n        EventFormatVersions.V3,\n        StateResolutionVersions.V2,\n        enforce_key_validity=False,\n        special_case_aliases_auth=True,\n        strict_canonicaljson=False,\n        limit_notifications_power_levels=False,\n    )\n    V5 = RoomVersion(\n        \"5\",\n        RoomDisposition.STABLE,\n        EventFormatVersions.V3,\n        StateResolutionVersions.V2,\n        enforce_key_validity=True,\n        special_case_aliases_auth=True,\n        strict_canonicaljson=False,\n        limit_notifications_power_levels=False,\n    )\n    V6 = RoomVersion(\n        \"6\",\n        RoomDisposition.STABLE,\n        EventFormatVersions.V3,\n        StateResolutionVersions.V2,\n        enforce_key_validity=True,\n        special_case_aliases_auth=False,\n        strict_canonicaljson=True,\n        limit_notifications_power_levels=True,\n    )\n\n\nKNOWN_ROOM_VERSIONS = {\n    v.identifier: v\n    for v in (\n        RoomVersions.V1,\n        RoomVersions.V2,\n        RoomVersions.V3,\n        RoomVersions.V4,\n        RoomVersions.V5,\n        RoomVersions.V6,\n    )\n}  # type: Dict[str, RoomVersion]\n", "path": "synapse/api/room_versions.py"}]}