You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tooling.apache.org by ar...@apache.org on 2026/07/07 15:27:34 UTC

(tooling-trusted-releases) 01/01: #1370 - initial admin page for renaming, moving and deleting projects

This is an automated email from the ASF dual-hosted git repository.

alitheg pushed a commit to branch arm
in repository https://gitbox.apache.org/repos/asf/tooling-trusted-releases.git

commit 89395163062bd12c19d44e9743d670853e118e46
Author: Alastair McFarlane <ar...@apache.org>
AuthorDate: Tue Jul 7 16:26:57 2026 +0100

    #1370 - initial admin page for renaming, moving and deleting projects
---
 atr/admin/__init__.py                      | 306 ++++++++++++++++++++++++++
 atr/admin/templates/admin-catalog.html     |  11 +
 atr/admin/templates/catalog-committee.html |  11 +
 atr/admin/templates/catalog-confirm.html   |  12 ++
 atr/shared/repoint.py                      |  62 ++++++
 atr/storage/__init__.py                    |   1 +
 atr/storage/writers/__init__.py            |   2 +
 atr/storage/writers/catalogue.py           | 332 +++++++++++++++++++++++++++++
 tests/unit/test_admin_catalog.py           |  44 ++++
 tests/unit/test_catalogue_shared.py        |  33 +++
 tests/unit/test_catalogue_writer.py        | 297 ++++++++++++++++++++++++++
 tests/unit/test_release_notification.py    |  51 +++++
 12 files changed, 1162 insertions(+)

diff --git a/atr/admin/__init__.py b/atr/admin/__init__.py
index 6162dc50..9307ae9d 100644
--- a/atr/admin/__init__.py
+++ b/atr/admin/__init__.py
@@ -274,6 +274,312 @@ async def browse_as_post(
     return await session.redirect(root.index)
 
 
+@admin.typed
+async def catalog_get(_session: web.Committer, _catalog: Literal["catalog"]) -> str:
+    """
+    URL: GET /catalog
+
+    Pick a committee to correct.
+    """
+    async with db.session() as data:
+        committees = await data.committee().order_by(sql.Committee.key).all()
+
+    listing = htpy.ul(".list-group")[
+        [
+            htpy.li(".list-group-item")[htpy.a(href=f"/admin/catalog/{committee.key}")[committee.name or committee.key]]
+            for committee in committees
+        ]
+    ]
+    return await template.render("admin-catalog.html", committees=listing)
+
+
+@admin.typed
+async def catalog_committee_get(
+    _session: web.Committer, _catalog: Literal["catalog"], committee_key: safe.CommitteeKey
+) -> str:
+    """
+    URL: GET /catalog/<committee_key>
+
+    List a committee's projects with their release and artifact counts.
+    """
+    async with db.session() as data:
+        projects = await data.project(committee_key=str(committee_key), _releases=True).order_by(sql.Project.key).all()
+        artifact_counts = await _catalog_artifact_counts(data, [str(project.key) for project in projects])
+        summaries = [
+            (project, len(project.releases_including_embargoed), artifact_counts.get(str(project.key), 0))
+            for project in projects
+        ]
+
+    table = htpy.table(".table")[
+        htpy.thead[
+            htpy.tr[
+                htpy.th["Project"],
+                htpy.th["Status"],
+                htpy.th["Releases"],
+                htpy.th["Artifacts"],
+                htpy.th["Actions"],
+            ]
+        ],
+        htpy.tbody[
+            [
+                htpy.tr[
+                    htpy.td[htpy.strong[project.key]],
+                    htpy.td[project.status.value],
+                    htpy.td[str(release_count)],
+                    htpy.td[str(artifact_count)],
+                    htpy.td[
+                        htpy.a(
+                            ".btn.btn-sm.btn-outline-secondary.me-1",
+                            href=f"/admin/catalog/{committee_key}/rename/{project.key}",
+                        )["Rename"],
+                        htpy.a(
+                            ".btn.btn-sm.btn-outline-secondary.me-1",
+                            href=f"/admin/catalog/{committee_key}/move/{project.key}",
+                        )["Move"],
+                        htpy.a(
+                            ".btn.btn-sm.btn-outline-danger",
+                            href=f"/admin/catalog/{committee_key}/remove/{project.key}",
+                        )["Delete or merge"],
+                    ],
+                ]
+                for project, release_count, artifact_count in summaries
+            ]
+        ],
+    ]
+    return await template.render("catalog-committee.html", committee_key=str(committee_key), projects=table)
+
+
+def _catalog_select(name: str, options: list[tuple[str, str]], placeholder: str) -> htpy.Element:
+    return htpy.select(".form-select", name=name)[
+        htpy.option(value="", disabled=True, selected=True)[placeholder],
+        [htpy.option(value=value)[label] for value, label in options],
+    ]
+
+
+async def _catalog_artifact_counts(data: db.Session, project_keys: list[str]) -> dict[str, int]:
+    if not project_keys:
+        return {}
+    via = sql.validate_instrumented_attribute
+    result = await data.execute(
+        sqlmodel.select(via(sql.Artifact.project_key), sqlalchemy.func.count())
+        .where(via(sql.Artifact.project_key).in_(project_keys))
+        .group_by(via(sql.Artifact.project_key))
+    )
+    return {row[0]: int(row[1]) for row in result.all()}
+
+
+class CatalogMoveForm(form.Form):
+    destination: str = form.label(
+        "Destination committee", "The committee to move this project to.", widget=form.Widget.CUSTOM
+    )
+
+
+@admin.typed
+async def catalog_move_get(
+    _session: web.Committer,
+    _catalog: Literal["catalog"],
+    committee_key: safe.CommitteeKey,
+    _move: Literal["move"],
+    project_key: safe.ProjectKey,
+) -> str:
+    """
+    URL: GET /catalog/<committee_key>/move/<project_key>
+
+    Confirm moving a project to another committee.
+    """
+    async with db.session() as data:
+        committees = await data.committee().order_by(sql.Committee.key).all()
+    destinations = [c for c in committees if str(c.key) != str(committee_key)]
+    rendered_form = await form.render(
+        model_cls=CatalogMoveForm,
+        submit_label="Move project",
+        submit_classes="btn-primary",
+        custom={
+            "destination": _catalog_select(
+                "destination",
+                [(str(c.key), c.name or str(c.key)) for c in destinations],
+                "Choose a committee",
+            )
+        },
+    )
+    intro = htpy.div[
+        htpy.p[f"Move {project_key} out of {committee_key} and into another committee."],
+        htpy.p(".text-muted")["Moving across a podling boundary changes the incubating badge."],
+    ]
+    return await template.render(
+        "catalog-confirm.html",
+        heading=f"Move {project_key}",
+        committee_key=str(committee_key),
+        intro=intro,
+        form=rendered_form,
+    )
+
+
+@admin.typed
+async def catalog_move_post(
+    session: web.Committer,
+    _catalog: Literal["catalog"],
+    committee_key: safe.CommitteeKey,
+    _move: Literal["move"],
+    project_key: safe.ProjectKey,
+    move_form: CatalogMoveForm,
+) -> web.WerkzeugResponse:
+    """
+    URL: POST /catalog/<committee_key>/move/<project_key>
+
+    Apply the move.
+    """
+    raw = move_form.destination.strip()
+    if not raw:
+        raise exceptions.BadRequest("Choose a destination committee.")
+    try:
+        destination = safe.CommitteeKey(raw)
+    except ValueError as error:
+        raise exceptions.BadRequest(f"Invalid committee key: {error}") from error
+    async with storage.write(session) as write:
+        wafa = write.as_foundation_admin()
+        await wafa.catalogue.move_project(project_key, destination)
+    return await session.redirect(catalog_committee_get, committee_key=str(committee_key))
+
+
+class CatalogRenameForm(form.Form):
+    new_key: str = form.label("New project key", "The corrected project key, e.g. hbase-connectors.")
+    new_name: str = form.label("New display name (optional)", "Leave blank to keep the current name.")
+
+
+@admin.typed
+async def catalog_rename_get(
+    _session: web.Committer,
+    _catalog: Literal["catalog"],
+    committee_key: safe.CommitteeKey,
+    _rename: Literal["rename"],
+    project_key: safe.ProjectKey,
+) -> str:
+    """
+    URL: GET /catalog/<committee_key>/rename/<project_key>
+
+    Confirm renaming or retargeting a project.
+    """
+    rendered_form = await form.render(
+        model_cls=CatalogRenameForm,
+        submit_label="Rename project",
+        submit_classes="btn-primary",
+    )
+    intro = htpy.div[htpy.p[f"Rename {project_key}. Every release, artifact, and lifecycle event moves with it."],]
+    return await template.render(
+        "catalog-confirm.html",
+        heading=f"Rename {project_key}",
+        committee_key=str(committee_key),
+        intro=intro,
+        form=rendered_form,
+    )
+
+
+@admin.typed
+async def catalog_rename_post(
+    session: web.Committer,
+    _catalog: Literal["catalog"],
+    committee_key: safe.CommitteeKey,
+    _rename: Literal["rename"],
+    project_key: safe.ProjectKey,
+    rename_form: CatalogRenameForm,
+) -> web.WerkzeugResponse:
+    """
+    URL: POST /catalog/<committee_key>/rename/<project_key>
+
+    Apply the rename.
+    """
+    raw = rename_form.new_key.strip()
+    if not raw:
+        raise exceptions.BadRequest("Enter a new project key.")
+    try:
+        new_key = safe.ProjectKey(raw)
+    except ValueError as error:
+        raise exceptions.BadRequest(f"Invalid project key: {error}") from error
+    new_name = rename_form.new_name.strip() or None
+    async with storage.write(session) as write:
+        wafa = write.as_foundation_admin()
+        await wafa.catalogue.rename_project(project_key, new_key, new_name)
+    return await session.redirect(catalog_committee_get, committee_key=str(committee_key))
+
+
+class CatalogRemoveForm(form.Form):
+    disposition: Literal["delete", "rehome"] = form.label(
+        "What happens to this project's releases and artifacts",
+        "Delete them, or rehome them into another project.",
+    )
+    rehome_target: str = form.label(
+        "Rehome target (only for rehome)", "The project to merge into.", widget=form.Widget.CUSTOM, default=""
+    )
+
+
+@admin.typed
+async def catalog_remove_get(
+    _session: web.Committer,
+    _catalog: Literal["catalog"],
+    committee_key: safe.CommitteeKey,
+    _remove: Literal["remove"],
+    project_key: safe.ProjectKey,
+) -> str:
+    """
+    URL: GET /catalog/<committee_key>/remove/<project_key>
+
+    Confirm deleting a project or rehoming its contents into another project.
+    """
+    async with db.session() as data:
+        projects = await data.project(committee_key=str(committee_key)).order_by(sql.Project.key).all()
+    targets = [p for p in projects if str(p.key) != str(project_key)]
+    rendered_form = await form.render(
+        model_cls=CatalogRemoveForm,
+        submit_label="Apply",
+        submit_classes="btn-danger",
+        custom={
+            "rehome_target": _catalog_select(
+                "rehome_target",
+                [(str(p.key), p.name or str(p.key)) for p in targets],
+                "Choose a project",
+            )
+        },
+    )
+    intro = htpy.div[
+        htpy.p[f"Remove {project_key}. Choose whether to delete its releases and artifacts or merge them elsewhere."],
+        htpy.p(".text-muted")["A rehome halts if any release version or artifact already exists on the target."],
+    ]
+    return await template.render(
+        "catalog-confirm.html",
+        heading=f"Delete or merge {project_key}",
+        committee_key=str(committee_key),
+        intro=intro,
+        form=rendered_form,
+    )
+
+
+@admin.typed
+async def catalog_remove_post(
+    session: web.Committer,
+    _catalog: Literal["catalog"],
+    committee_key: safe.CommitteeKey,
+    _remove: Literal["remove"],
+    project_key: safe.ProjectKey,
+    remove_form: CatalogRemoveForm,
+) -> web.WerkzeugResponse:
+    """
+    URL: POST /catalog/<committee_key>/remove/<project_key>
+
+    Apply the delete or the rehome.
+    """
+    async with storage.write(session) as write:
+        wafa = write.as_foundation_admin()
+        if remove_form.disposition == "rehome":
+            target = remove_form.rehome_target.strip()
+            if not target:
+                raise exceptions.BadRequest("A rehome needs a target project key.")
+            await wafa.catalogue.rehome_project(project_key, safe.ProjectKey(target))
+        else:
+            await wafa.catalogue.delete_project(project_key)
+    return await session.redirect(catalog_committee_get, committee_key=str(committee_key))
+
+
 @admin.typed
 async def configuration(_session: web.Committer, _configuration: Literal["configuration"]) -> web.QuartResponse:
     """
diff --git a/atr/admin/templates/admin-catalog.html b/atr/admin/templates/admin-catalog.html
new file mode 100644
index 00000000..8adee0d3
--- /dev/null
+++ b/atr/admin/templates/admin-catalog.html
@@ -0,0 +1,11 @@
+{% extends "layouts/base-admin.html" %}
+
+{%- block title -%}Catalogue corrections ~ ATR{%- endblock title -%}
+
+{%- block description -%}Pick a committee to correct its projects and artifacts.{%- endblock description -%}
+
+{% block content %}
+    <h1>Catalogue corrections</h1>
+    <p>Choose a committee to review and correct its catalogued projects.</p>
+    {{ committees }}
+{% endblock content %}
diff --git a/atr/admin/templates/catalog-committee.html b/atr/admin/templates/catalog-committee.html
new file mode 100644
index 00000000..03dc51e8
--- /dev/null
+++ b/atr/admin/templates/catalog-committee.html
@@ -0,0 +1,11 @@
+{% extends "layouts/base-admin.html" %}
+
+{%- block title -%}Catalogue: {{ committee_key }} ~ ATR{%- endblock title -%}
+
+{%- block description -%}Correct the projects and artifacts for {{ committee_key }}.{%- endblock description -%}
+
+{% block content %}
+    <h1>Catalogue: {{ committee_key }}</h1>
+    <p><a href="/admin/catalog">Back to committees</a></p>
+    {{ projects }}
+{% endblock content %}
diff --git a/atr/admin/templates/catalog-confirm.html b/atr/admin/templates/catalog-confirm.html
new file mode 100644
index 00000000..e53088e4
--- /dev/null
+++ b/atr/admin/templates/catalog-confirm.html
@@ -0,0 +1,12 @@
+{% extends "layouts/base-admin.html" %}
+
+{%- block title -%}{{ heading }} ~ ATR{%- endblock title -%}
+
+{%- block description -%}Confirm a catalogue correction.{%- endblock description -%}
+
+{% block content %}
+    <h1>{{ heading }}</h1>
+    <p><a href="/admin/catalog/{{ committee_key }}">Back to {{ committee_key }}</a></p>
+    {{ intro }}
+    {{ form }}
+{% endblock content %}
diff --git a/atr/shared/repoint.py b/atr/shared/repoint.py
new file mode 100644
index 00000000..135502ce
--- /dev/null
+++ b/atr/shared/repoint.py
@@ -0,0 +1,62 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+#
+#   http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
+
+import dataclasses
+from typing import Final
+
+import sqlmodel
+
+import atr.models.sql as sql
+
+# Tables whose column holds a project key verbatim
+PROJECT_KEY_REFS: Final[list[tuple[type[sqlmodel.SQLModel], str]]] = [
+    (sql.Project, "super_project_key"),
+    (sql.ProjectCycle, "project_key"),
+    (sql.Release, "project_key"),
+    (sql.Artifact, "project_key"),
+    (sql.LifecycleEvent, "project_key"),
+    (sql.Task, "project_key"),
+    (sql.CheckResultIgnore, "project_key"),
+]
+
+# Tables whose column holds a release key, "{project_key}-{version}". Task.version_key
+# is a logical reference, not a foreign key, but we rewrite it too so a moved project
+# leaves no stale check-task pointers
+RELEASE_KEY_REFS: Final[list[tuple[type[sqlmodel.SQLModel], str]]] = [
+    (sql.Release, "key"),
+    (sql.Artifact, "release_key"),
+    (sql.LifecycleEvent, "version_key"),
+    (sql.CheckResult, "release_key"),
+    (sql.BallotPaper, "release_key"),
+    (sql.Distribution, "release_key"),
+    (sql.Quarantined, "release_key"),
+    (sql.Revision, "release_key"),
+    (sql.Task, "version_key"),
+]
+
+# Tables whose column holds a cycle key, "{project_key}-{cycle}"
+CYCLE_KEY_REFS: Final[list[tuple[type[sqlmodel.SQLModel], str]]] = [
+    (sql.ProjectCycle, "cycle_key"),
+    (sql.Release, "cycle_key"),
+    (sql.LifecycleEvent, "cycle_key"),
+]
+
+
+@dataclasses.dataclass(frozen=True)
+class Collision:
+    kind: str
+    key: str
diff --git a/atr/storage/__init__.py b/atr/storage/__init__.py
index 58161167..a0623c5d 100644
--- a/atr/storage/__init__.py
+++ b/atr/storage/__init__.py
@@ -259,6 +259,7 @@ class WriteAsFoundationAdmin(WriteAsFoundationCommitter):
         # via MRO resolves to this class's property override, which reads
         # _WriteAsFoundationAdmin__asf_uid, which had not yet been assigned.
         super().__init__(write, data)
+        self.catalogue = writers.catalogue.FoundationAdmin(write, self, data)
         self.policy = writers.policy.FoundationAdmin(write, self, data)
         self.project = writers.project.FoundationAdmin(write, self, data)
         self.release = writers.release.FoundationAdmin(write, self, data)
diff --git a/atr/storage/writers/__init__.py b/atr/storage/writers/__init__.py
index c5b96163..feb7f874 100644
--- a/atr/storage/writers/__init__.py
+++ b/atr/storage/writers/__init__.py
@@ -19,6 +19,7 @@ from __future__ import annotations
 
 import atr.storage.writers.announce as announce
 import atr.storage.writers.cache as cache
+import atr.storage.writers.catalogue as catalogue
 import atr.storage.writers.checks as checks
 import atr.storage.writers.committee as committee
 import atr.storage.writers.distributions as distributions
@@ -39,6 +40,7 @@ import atr.storage.writers.workflowstatus as workflowstatus
 __all__ = [
     "announce",
     "cache",
+    "catalogue",
     "checks",
     "committee",
     "distributions",
diff --git a/atr/storage/writers/catalogue.py b/atr/storage/writers/catalogue.py
new file mode 100644
index 00000000..3eafda33
--- /dev/null
+++ b/atr/storage/writers/catalogue.py
@@ -0,0 +1,332 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+#
+#   http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
+
+# Removing this will cause circular imports
+from __future__ import annotations
+
+import sqlalchemy
+import sqlmodel
+
+import atr.cycles as cycles
+import atr.db as db
+import atr.models.safe as safe
+import atr.models.sql as sql
+import atr.shared.repoint as repoint
+import atr.storage as storage
+
+
+class FoundationAdmin:
+    def __init__(self, write: storage.Write, write_as: storage.WriteAsFoundationAdmin, data: db.Session):
+        self.__write_as = write_as
+        self.__data = data
+        asf_uid = write.authorisation.asf_uid
+        if asf_uid is None:
+            raise storage.AccessError("Not authorized", status=403)
+        self.__asf_uid = asf_uid
+
+    async def move_project(self, project_key: safe.ProjectKey, dest_committee_key: safe.CommitteeKey) -> None:
+        await self.__data.begin_immediate()
+        self.__data.expire_all()
+        try:
+            project = await self.__data.project(key=str(project_key)).get()
+            if project is None:
+                raise storage.AccessError(f"Project '{project_key}' not found.", status=404)
+            await self._ensure_catalog_only(str(project_key))
+            dest = await self.__data.committee(key=str(dest_committee_key)).get()
+            if dest is None:
+                raise storage.AccessError(f"No destination committee '{dest_committee_key}'.", status=404)
+            project.committee_key = str(dest_committee_key)
+            project.mark_updated(by=self.__asf_uid, update_type=sql.UpdateType.MANUAL)
+            await self.__data.commit()
+        except Exception:
+            await self.__data.rollback()
+            raise
+        self.__write_as.append_to_audit_log(
+            asf_uid=self.__asf_uid,
+            project_key=str(project_key),
+            moved_to=str(dest_committee_key),
+        )
+
+    async def rename_project(self, old_key: safe.ProjectKey, new_key: safe.ProjectKey, new_name: str | None) -> None:
+        old = str(old_key)
+        new = str(new_key)
+        if old == new:
+            raise storage.AccessError("The new key matches the current key.", status=400)
+        await self.__data.begin_immediate()
+        self.__data.expire_all()
+        try:
+            project = await self.__data.project(key=old).get()
+            if project is None:
+                raise storage.AccessError(f"Project '{old}' not found.", status=404)
+            await self._ensure_catalog_only(old)
+            if await self.__data.project(key=new).get() is not None:
+                raise storage.AccessError(f"A project '{new}' already exists; use rehome to merge.", status=409)
+            await self._repoint(old, new)
+            if new_name is not None:
+                renamed = await self.__data.project(key=new).get()
+                if renamed is None:
+                    raise storage.AccessError("The renamed project could not be reloaded.", status=500)
+                renamed.name = new_name
+            await self._assert_fk_integrity()
+            await self.__data.commit()
+        except Exception:
+            await self.__data.rollback()
+            raise
+        self.__write_as.append_to_audit_log(
+            asf_uid=self.__asf_uid,
+            renamed_from=old,
+            renamed_to=new,
+        )
+
+    async def rehome_project(self, source_key: safe.ProjectKey, target_key: safe.ProjectKey) -> None:
+        source = str(source_key)
+        target = str(target_key)
+        if source == target:
+            raise storage.AccessError("Source and target are the same project.", status=400)
+        await self.__data.begin_immediate()
+        self.__data.expire_all()
+        try:
+            if await self.__data.project(key=source).get() is None:
+                raise storage.AccessError(f"Project '{source}' not found.", status=404)
+            if await self.__data.project(key=target).get() is None:
+                raise storage.AccessError(f"Target project '{target}' not found.", status=404)
+            await self._ensure_catalog_only(source)
+            await self._ensure_catalog_only(target)
+            collisions = await self._collisions(source, target)
+            if collisions:
+                listed = ", ".join(f"{c.kind} {c.key}" for c in collisions)
+                raise storage.AccessError(f"Rehome halted on collision: {listed}", status=409)
+
+            await self.__data.execute(sqlalchemy.text("PRAGMA defer_foreign_keys=ON"))
+            source_release_keys = await self._release_keys(source)
+            source_cycle_keys = await self._cycle_keys(source)
+            moved_keys = await self._rehome_rows(source, target, source_release_keys)
+            await self._rehome_cycles(target, moved_keys, source_cycle_keys)
+            await self._drop_project(source)
+            await self._assert_fk_integrity()
+            await self.__data.commit()
+        except Exception:
+            await self.__data.rollback()
+            raise
+        self.__write_as.append_to_audit_log(asf_uid=self.__asf_uid, rehomed_from=source, rehomed_to=target)
+
+    async def _rehome_rows(self, source: str, target: str, source_release_keys: list[str]) -> list[str]:
+        via = sql.validate_instrumented_attribute
+        # A sub-project of the source hangs under the target once its parent is gone
+        await self.__data.execute(
+            sqlmodel.update(sql.Project)
+            .where(via(sql.Project.super_project_key) == source)
+            .values(super_project_key=target)
+        )
+        # Each release moves under the target project; its cycle is resolved later, against
+        # the target's own version scheme rather than assumed to be the default
+        releases = await self.__data.release(project_key=source).all()
+        moved_keys = [f"{target}-{release.version}" for release in releases]
+        for release in releases:
+            await self.__data.execute(
+                sqlmodel.update(sql.Release)
+                .where(via(sql.Release.key) == release.key)
+                .values(key=f"{target}-{release.version}", project_key=target)
+            )
+        # Release-key children rewrite their prefix (Release itself moved above); project-key
+        # children point at the target. Both scoped to the source's own rows
+        release_child_refs = [(model, attr) for model, attr in repoint.RELEASE_KEY_REFS if model is not sql.Release]
+        await self._rewrite_prefix(release_child_refs, source_release_keys, source, target)
+        for model, attr in repoint.PROJECT_KEY_REFS:
+            if model in (sql.Project, sql.ProjectCycle, sql.Release):
+                continue
+            column = via(getattr(model, attr))
+            await self.__data.execute(sqlmodel.update(model).where(column == source).values(**{attr: target}))
+        return moved_keys
+
+    async def _rehome_cycles(self, target: str, moved_keys: list[str], source_cycle_keys: list[str]) -> None:
+        via = sql.validate_instrumented_attribute
+        # Re-resolve cycle membership for the moved releases against the target's scheme,
+        # creating any cycle the target lacks. The raw updates bypassed the ORM, so expire
+        # first to re-read the moved rows fresh
+        self.__data.expire_all()
+        target_project = await self.__data.project(key=target).get()
+        if target_project is None:
+            raise storage.AccessError("The rehome target could not be reloaded.", status=500)
+        await cycles.reassign_release_cycles(self.__data, target_project)
+        # A lifecycle event belongs in the same cycle as its release. version_key already
+        # points at the moved release key, so align each event with the cycle just resolved
+        for moved_key in moved_keys:
+            moved_release = await self.__data.get(sql.Release, moved_key)
+            if moved_release is None:
+                raise storage.AccessError("A moved release could not be reloaded.", status=500)
+            await self.__data.execute(
+                sqlmodel.update(sql.LifecycleEvent)
+                .where(via(sql.LifecycleEvent.version_key) == moved_key)
+                .values(cycle_key=moved_release.cycle_key)
+            )
+        # Project-level events with no release can't take a release's cycle, so the ones left
+        # on a source cycle fall back to the target default, which always exists
+        await self.__data.execute(
+            sqlmodel.update(sql.LifecycleEvent)
+            .where(via(sql.LifecycleEvent.cycle_key).in_(source_cycle_keys))
+            .values(cycle_key=f"{target}-default")
+        )
+
+    async def _drop_project(self, source: str) -> None:
+        via = sql.validate_instrumented_attribute
+        # The source's own cycles and project row go; a rehome target keeps its cycles
+        await self.__data.execute(sqlmodel.delete(sql.ProjectCycle).where(via(sql.ProjectCycle.project_key) == source))
+        await self.__data.execute(sqlmodel.delete(sql.Project).where(via(sql.Project.key) == source))
+
+    async def delete_project(self, project_key: safe.ProjectKey) -> None:
+        key = str(project_key)
+        await self.__data.begin_immediate()
+        self.__data.expire_all()
+        try:
+            if await self.__data.project(key=key).get() is None:
+                raise storage.AccessError(f"Project '{key}' not found.", status=404)
+            await self._ensure_catalog_only(key)
+            await self.__data.execute(sqlalchemy.text("PRAGMA defer_foreign_keys=ON"))
+            via = sql.validate_instrumented_attribute
+            release_keys = await self._release_keys(key)
+            cycle_keys = await self._cycle_keys(key)
+
+            # A sub-project survives with its super pointer cleared; we delete this project,
+            # not the ones that hang beneath it
+            await self.__data.execute(
+                sqlmodel.update(sql.Project)
+                .where(via(sql.Project.super_project_key) == key)
+                .values(super_project_key=None)
+            )
+            for model, attr in repoint.RELEASE_KEY_REFS:
+                column = via(getattr(model, attr))
+                await self.__data.execute(sqlmodel.delete(model).where(column.in_(release_keys)))
+            for model, attr in repoint.CYCLE_KEY_REFS:
+                column = via(getattr(model, attr))
+                await self.__data.execute(sqlmodel.delete(model).where(column.in_(cycle_keys)))
+            for model, attr in repoint.PROJECT_KEY_REFS:
+                if (model, attr) == (sql.Project, "super_project_key"):
+                    continue
+                column = via(getattr(model, attr))
+                await self.__data.execute(sqlmodel.delete(model).where(column == key))
+            await self.__data.execute(sqlmodel.delete(sql.Project).where(via(sql.Project.key) == key))
+            await self._assert_fk_integrity()
+            await self.__data.commit()
+        except Exception:
+            await self.__data.rollback()
+            raise
+        self.__write_as.append_to_audit_log(asf_uid=self.__asf_uid, deleted_project=key)
+
+    async def _collisions(self, source_key: str, target_key: str) -> list[repoint.Collision]:
+        via = sql.validate_instrumented_attribute
+        collisions: list[repoint.Collision] = []
+        source_releases = await self.__data.release(project_key=source_key).all()
+        for release in source_releases:
+            candidate = f"{target_key}-{release.version}"
+            if await self.__data.get(sql.Release, candidate) is not None:
+                collisions.append(repoint.Collision(kind="release", key=candidate))
+        source_artifacts = (
+            (
+                await self.__data.execute(
+                    sqlmodel.select(sql.Artifact).where(via(sql.Artifact.project_key) == source_key)
+                )
+            )
+            .scalars()
+            .all()
+        )
+        for artifact in source_artifacts:
+            existing = await self.__data.get(sql.Artifact, (target_key, artifact.version, artifact.artifact_path))
+            if existing is not None:
+                collisions.append(repoint.Collision(kind="artifact", key=artifact.artifact_path))
+        return collisions
+
+    async def _repoint(self, old_key: str, new_key: str) -> None:
+        # Defer foreign key checks to commit, so we can rewrite parent primary keys
+        # and their children in any order within this one transaction
+        await self.__data.execute(sqlalchemy.text("PRAGMA defer_foreign_keys=ON"))
+        via = sql.validate_instrumented_attribute
+        release_keys = await self._release_keys(old_key)
+        cycle_keys = await self._cycle_keys(old_key)
+
+        # The project key itself
+        await self.__data.execute(
+            sqlmodel.update(sql.Project).where(via(sql.Project.key) == old_key).values(key=new_key)
+        )
+        # Columns that hold the project key verbatim
+        for model, attr in repoint.PROJECT_KEY_REFS:
+            column = via(getattr(model, attr))
+            await self.__data.execute(sqlmodel.update(model).where(column == old_key).values(**{attr: new_key}))
+        # Columns that hold a release key; scoped to this project's own release keys, so a
+        # sibling project whose key shares this prefix is never swept in
+        await self._rewrite_prefix(repoint.RELEASE_KEY_REFS, release_keys, old_key, new_key)
+        # Columns that hold a cycle key
+        await self._rewrite_prefix(repoint.CYCLE_KEY_REFS, cycle_keys, old_key, new_key)
+
+    async def _rewrite_prefix(
+        self, refs: list[tuple[type[sqlmodel.SQLModel], str]], keys: list[str], old_key: str, new_key: str
+    ) -> None:
+        if not keys:
+            return
+        via = sql.validate_instrumented_attribute
+        # The suffix starts one past "{old_key}-", and SQLite substr is 1-based
+        suffix_start = len(old_key) + 2
+        for model, attr in refs:
+            column = via(getattr(model, attr))
+            rewritten = sqlalchemy.literal(f"{new_key}-").op("||")(sqlalchemy.func.substr(column, suffix_start))
+            await self.__data.execute(sqlmodel.update(model).where(column.in_(keys)).values(**{attr: rewritten}))
+
+    async def _release_keys(self, project_key: str) -> list[str]:
+        via = sql.validate_instrumented_attribute
+        result = await self.__data.execute(
+            sqlmodel.select(via(sql.Release.key)).where(via(sql.Release.project_key) == project_key)
+        )
+        return list(result.scalars().all())
+
+    async def _cycle_keys(self, project_key: str) -> list[str]:
+        via = sql.validate_instrumented_attribute
+        result = await self.__data.execute(
+            sqlmodel.select(via(sql.ProjectCycle.cycle_key)).where(via(sql.ProjectCycle.project_key) == project_key)
+        )
+        return list(result.scalars().all())
+
+    async def _ensure_catalog_only(self, project_key: str) -> None:
+        # A catalogued project carries only project, cycle, release, artifact and lifecycle
+        # rows. A live ATR project also has revisions and release file-state, whose keys this
+        # page does not yet re-point, so refuse those rather than corrupt them
+        via = sql.validate_instrumented_attribute
+        release_keys = await self._release_keys(project_key)
+        if not release_keys:
+            return
+        result = await self.__data.execute(
+            sqlmodel.select(sqlalchemy.func.count())
+            .select_from(sql.Revision)
+            .where(via(sql.Revision.release_key).in_(release_keys))
+        )
+        if int(result.scalar() or 0) > 0:
+            raise storage.AccessError(
+                f"Project '{project_key}' has live release-workflow data (revisions); "
+                "this page corrects catalogued projects only.",
+                status=409,
+            )
+
+    async def _assert_fk_integrity(self) -> None:
+        # Flush pending ORM work so the check sees the full picture, then refuse to commit if
+        # a correction has left any dangling reference behind
+        await self.__data.flush()
+        result = await self.__data.execute(sqlalchemy.text("PRAGMA foreign_key_check"))
+        violations = result.fetchall()
+        if violations:
+            tables = ", ".join(sorted({str(row[0]) for row in violations}))
+            raise storage.AccessError(
+                f"Correction aborted: it would leave dangling references in {tables}.", status=500
+            )
diff --git a/tests/unit/test_admin_catalog.py b/tests/unit/test_admin_catalog.py
new file mode 100644
index 00000000..d1f16698
--- /dev/null
+++ b/tests/unit/test_admin_catalog.py
@@ -0,0 +1,44 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+#
+#   http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
+
+import atr.admin as admin_module
+
+
+def test_catalog_handlers_exist_and_import() -> None:
+    # Importing atr.admin registers the handlers via the @admin.typed decorator; if the
+    # type annotations are malformed the import itself raises, so this both smoke-tests
+    # import and confirms the two workspace handlers are present
+    assert hasattr(admin_module, "catalog_get")
+    assert hasattr(admin_module, "catalog_committee_get")
+
+
+def test_move_handlers_exist() -> None:
+    assert hasattr(admin_module, "catalog_move_get")
+    assert hasattr(admin_module, "catalog_move_post")
+    assert hasattr(admin_module, "CatalogMoveForm")
+
+
+def test_rename_handlers_exist() -> None:
+    assert hasattr(admin_module, "catalog_rename_get")
+    assert hasattr(admin_module, "catalog_rename_post")
+    assert hasattr(admin_module, "CatalogRenameForm")
+
+
+def test_remove_handlers_exist() -> None:
+    assert hasattr(admin_module, "catalog_remove_get")
+    assert hasattr(admin_module, "catalog_remove_post")
+    assert hasattr(admin_module, "CatalogRemoveForm")
diff --git a/tests/unit/test_catalogue_shared.py b/tests/unit/test_catalogue_shared.py
new file mode 100644
index 00000000..74a1b67e
--- /dev/null
+++ b/tests/unit/test_catalogue_shared.py
@@ -0,0 +1,33 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+#
+#   http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
+
+import atr.models.sql as sql
+import atr.shared.repoint as repoint
+
+
+def test_registries_include_every_key_referencing_table() -> None:
+    # Every table that foreign-keys a project, release, or cycle key must appear,
+    # so the re-point engine never orphans a row
+    project_models = {model for model, _ in repoint.PROJECT_KEY_REFS}
+    release_models = {model for model, _ in repoint.RELEASE_KEY_REFS}
+    assert sql.Artifact in project_models
+    assert sql.LifecycleEvent in project_models
+    assert sql.Task in project_models
+    assert sql.CheckResultIgnore in project_models
+    assert sql.Distribution in release_models
+    assert sql.BallotPaper in release_models
+    assert sql.Revision in release_models
diff --git a/tests/unit/test_catalogue_writer.py b/tests/unit/test_catalogue_writer.py
new file mode 100644
index 00000000..f89e7a00
--- /dev/null
+++ b/tests/unit/test_catalogue_writer.py
@@ -0,0 +1,297 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+#
+#   http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
+
+import datetime
+import unittest.mock as mock
+from collections.abc import AsyncIterator
+
+import pytest
+import sqlalchemy
+import sqlalchemy.event
+import sqlalchemy.ext.asyncio
+import sqlalchemy.pool
+import sqlmodel
+
+import atr.db as db
+import atr.models.safe as safe
+import atr.models.sql as sql
+import atr.storage as storage
+import atr.storage.writers.catalogue as catalogue
+
+
+@pytest.fixture
+async def sessionmaker() -> AsyncIterator[sqlalchemy.ext.asyncio.async_sessionmaker[db.Session]]:
+    engine = sqlalchemy.ext.asyncio.create_async_engine(
+        "sqlite+aiosqlite:///:memory:",
+        connect_args={"check_same_thread": False},
+        poolclass=sqlalchemy.pool.StaticPool,
+    )
+
+    # The app enables foreign keys per connection; the test engine must opt in too,
+    # or the re-point ordering these tests exist to prove is never enforced
+    @sqlalchemy.event.listens_for(engine.sync_engine, "connect")
+    def _fk_on(dbapi_connection, _record) -> None:
+        cursor = dbapi_connection.cursor()
+        cursor.execute("PRAGMA foreign_keys=ON")
+        cursor.close()
+
+    async with engine.begin() as conn:
+        await conn.run_sync(sqlmodel.SQLModel.metadata.create_all)
+    maker = sqlalchemy.ext.asyncio.async_sessionmaker(bind=engine, class_=db.Session, expire_on_commit=False)
+    yield maker
+    await engine.dispose()
+
+
+def _writer(data: db.Session) -> catalogue.FoundationAdmin:
+    writer = object.__new__(catalogue.FoundationAdmin)
+    writer._FoundationAdmin__data = data
+    writer._FoundationAdmin__asf_uid = "tester"
+    writer._FoundationAdmin__write_as = mock.MagicMock()
+    return writer
+
+
+async def _seed_project(data: db.Session, committee: str, key: str, is_podling: bool = False) -> None:
+    data.add(sql.Committee(key=committee, name=committee.title(), is_podling=is_podling))
+    data.add(sql.Committee(key="dest", name="Dest", is_podling=False))
+    data.add(sql.Project(key=key, name=f"Apache {key}", committee_key=committee))
+    await data.commit()
+
+
+@pytest.mark.asyncio
+async def test_move_project_reassigns_committee(sessionmaker) -> None:
+    async with sessionmaker() as data:
+        await _seed_project(data, "alpha", "alpha-one")
+        await _writer(data).move_project(safe.ProjectKey("alpha-one"), safe.CommitteeKey("dest"))
+
+        moved = await data.get(sql.Project, "alpha-one")
+        assert moved is not None
+        assert moved.committee_key == "dest"
+
+
+@pytest.mark.asyncio
+async def test_move_project_rejects_missing_destination(sessionmaker) -> None:
+    async with sessionmaker() as data:
+        await _seed_project(data, "alpha", "alpha-one")
+        with pytest.raises(storage.AccessError, match="destination committee"):
+            await _writer(data).move_project(safe.ProjectKey("alpha-one"), safe.CommitteeKey("ghost"))
+
+
+async def _seed_release_with_children(data: db.Session, project_key: str, version: str) -> None:
+    release_key = f"{project_key}-{version}"
+    cycle_key = f"{project_key}-default"
+    # The project's default cycle already exists: creating a Project fires an after_insert
+    # hook that populates "{key}-default". LifecycleEvent has no ORM relationship to its
+    # release or cycle, so its insert can't be ordered within one flush; commit the release
+    # first, the way the seed does
+    data.add(
+        sql.Release(
+            key=release_key,
+            project_key=project_key,
+            cycle_key=cycle_key,
+            version=version,
+            phase=sql.ReleasePhase.RELEASE,
+            created=datetime.datetime(2020, 1, 1, tzinfo=datetime.UTC),
+        )
+    )
+    await data.commit()
+    data.add(
+        sql.Artifact(
+            project_key=project_key,
+            version=version,
+            artifact_path=f"apache-{project_key}-{version}.tar.gz",
+            release_key=release_key,
+        )
+    )
+    data.add(
+        sql.LifecycleEvent(
+            project_key=project_key,
+            cycle_key=cycle_key,
+            version_key=release_key,
+            event=sql.LifecycleEventType.RELEASE,
+            effective=datetime.datetime(2020, 1, 1, tzinfo=datetime.UTC),
+        )
+    )
+    await data.commit()
+
+
+@pytest.mark.asyncio
+async def test_rename_repoints_every_dependent_row(sessionmaker) -> None:
+    async with sessionmaker() as data:
+        await _seed_project(data, "alpha", "alpha-one")
+        await _seed_release_with_children(data, "alpha-one", "1.2.0")
+
+        await _writer(data).rename_project(safe.ProjectKey("alpha-one"), safe.ProjectKey("alpha-core"), "Apache Core")
+
+        assert await data.get(sql.Project, "alpha-one") is None
+        renamed = await data.get(sql.Project, "alpha-core")
+        assert renamed is not None
+        assert renamed.name == "Apache Core"
+        assert await data.get(sql.Release, "alpha-core-1.2.0") is not None
+        assert await data.get(sql.Release, "alpha-one-1.2.0") is None
+        artifact = await data.get(sql.Artifact, ("alpha-core", "1.2.0", "apache-alpha-one-1.2.0.tar.gz"))
+        assert artifact is not None
+        assert artifact.release_key == "alpha-core-1.2.0"
+        cycle = await data.get(sql.ProjectCycle, "alpha-core-default")
+        assert cycle is not None
+
+
+@pytest.mark.asyncio
+async def test_rename_rejects_existing_target_key(sessionmaker) -> None:
+    async with sessionmaker() as data:
+        await _seed_project(data, "alpha", "alpha-one")
+        data.add(sql.Project(key="alpha-two", name="Apache Two", committee_key="alpha"))
+        await data.commit()
+        with pytest.raises(storage.AccessError, match="already exists"):
+            await _writer(data).rename_project(safe.ProjectKey("alpha-one"), safe.ProjectKey("alpha-two"), None)
+
+
+async def _seed_managed_project(data: db.Session, committee: str, key: str) -> None:
+    # A project carrying a revision looks like one that went through the ATR release
+    # workflow, which the catalogue-correction page refuses to touch
+    await _seed_project(data, committee, key)
+    await _seed_release_with_children(data, key, "1.0.0")
+    data.add(
+        sql.Revision(
+            key=f"{key}-1.0.0 00001",
+            release_key=f"{key}-1.0.0",
+            asfuid="someone",
+            phase=sql.ReleasePhase.RELEASE_CANDIDATE_DRAFT,
+        )
+    )
+    await data.commit()
+
+
+@pytest.mark.asyncio
+async def test_rename_refuses_a_project_with_live_workflow_data(sessionmaker) -> None:
+    async with sessionmaker() as data:
+        await _seed_managed_project(data, "alpha", "alpha-one")
+        with pytest.raises(storage.AccessError, match="catalogued projects only"):
+            await _writer(data).rename_project(safe.ProjectKey("alpha-one"), safe.ProjectKey("alpha-core"), None)
+
+
+@pytest.mark.asyncio
+async def test_move_refuses_a_project_with_live_workflow_data(sessionmaker) -> None:
+    async with sessionmaker() as data:
+        await _seed_managed_project(data, "alpha", "alpha-one")
+        with pytest.raises(storage.AccessError, match="catalogued projects only"):
+            await _writer(data).move_project(safe.ProjectKey("alpha-one"), safe.CommitteeKey("dest"))
+
+
+@pytest.mark.asyncio
+async def test_delete_refuses_a_project_with_live_workflow_data(sessionmaker) -> None:
+    async with sessionmaker() as data:
+        await _seed_managed_project(data, "alpha", "alpha-one")
+        with pytest.raises(storage.AccessError, match="catalogued projects only"):
+            await _writer(data).delete_project(safe.ProjectKey("alpha-one"))
+
+
+@pytest.mark.asyncio
+async def test_rehome_refuses_when_source_has_live_workflow_data(sessionmaker) -> None:
+    async with sessionmaker() as data:
+        await _seed_managed_project(data, "alpha", "alpha-src")
+        data.add(sql.Project(key="alpha-dst", name="Apache Dst", committee_key="alpha"))
+        await data.commit()
+        with pytest.raises(storage.AccessError, match="catalogued projects only"):
+            await _writer(data).rehome_project(safe.ProjectKey("alpha-src"), safe.ProjectKey("alpha-dst"))
+
+
+@pytest.mark.asyncio
+async def test_rehome_moves_contents_and_deletes_source(sessionmaker) -> None:
+    async with sessionmaker() as data:
+        await _seed_project(data, "alpha", "alpha-src")
+        # Creating the project auto-populates its default cycle; no manual cycle needed
+        data.add(sql.Project(key="alpha-dst", name="Apache Dst", committee_key="alpha"))
+        await data.commit()
+        await _seed_release_with_children(data, "alpha-src", "1.0.0")
+
+        await _writer(data).rehome_project(safe.ProjectKey("alpha-src"), safe.ProjectKey("alpha-dst"))
+
+        assert await data.get(sql.Project, "alpha-src") is None
+        moved = await data.get(sql.Release, "alpha-dst-1.0.0")
+        assert moved is not None
+        assert moved.project_key == "alpha-dst"
+        assert moved.cycle_key == "alpha-dst-default"
+        assert await data.get(sql.Release, "alpha-src-1.0.0") is None
+
+        # The artifact re-points to the target project and release, keeping its filename
+        artifact = await data.get(sql.Artifact, ("alpha-dst", "1.0.0", "apache-alpha-src-1.0.0.tar.gz"))
+        assert artifact is not None
+        assert artifact.release_key == "alpha-dst-1.0.0"
+        assert await data.get(sql.Artifact, ("alpha-src", "1.0.0", "apache-alpha-src-1.0.0.tar.gz")) is None
+
+        events = (
+            (
+                await data.execute(
+                    sqlmodel.select(sql.LifecycleEvent).where(
+                        sql.validate_instrumented_attribute(sql.LifecycleEvent.version_key) == "alpha-dst-1.0.0"
+                    )
+                )
+            )
+            .scalars()
+            .all()
+        )
+        assert len(events) == 1
+        assert events[0].cycle_key == moved.cycle_key
+
+
+@pytest.mark.asyncio
+async def test_rehome_halts_on_version_collision(sessionmaker) -> None:
+    async with sessionmaker() as data:
+        await _seed_project(data, "alpha", "alpha-src")
+        data.add(sql.Project(key="alpha-dst", name="Apache Dst", committee_key="alpha"))
+        await data.commit()
+        await _seed_release_with_children(data, "alpha-src", "1.0.0")
+        await _seed_release_with_children(data, "alpha-dst", "1.0.0")
+
+        with pytest.raises(storage.AccessError, match="collision"):
+            await _writer(data).rehome_project(safe.ProjectKey("alpha-src"), safe.ProjectKey("alpha-dst"))
+
+        # Nothing moved: the source release still exists
+        assert await data.get(sql.Release, "alpha-src-1.0.0") is not None
+
+
+@pytest.mark.asyncio
+async def test_delete_project_removes_project_and_contents(sessionmaker) -> None:
+    async with sessionmaker() as data:
+        await _seed_project(data, "alpha", "alpha-one")
+        data.add(sql.Project(key="alpha-two", name="Apache Two", committee_key="alpha"))
+        await data.commit()
+        await _seed_release_with_children(data, "alpha-one", "2.0.0")
+
+        await _writer(data).delete_project(safe.ProjectKey("alpha-one"))
+
+        assert await data.get(sql.Project, "alpha-one") is None
+        assert await data.get(sql.Release, "alpha-one-2.0.0") is None
+        assert await data.get(sql.ProjectCycle, "alpha-one-default") is None
+
+
+@pytest.mark.asyncio
+async def test_delete_project_orphans_a_child_super_pointer_rather_than_deleting_it(sessionmaker) -> None:
+    # A sub-project points at the deleted project via super_project_key; the child must
+    # survive with its pointer cleared, not be swept away by the delete
+    async with sessionmaker() as data:
+        await _seed_project(data, "alpha", "alpha-one")
+        data.add(
+            sql.Project(key="alpha-one-sub", name="Apache Sub", committee_key="alpha", super_project_key="alpha-one")
+        )
+        await data.commit()
+
+        await _writer(data).delete_project(safe.ProjectKey("alpha-one"))
+
+        child = await data.get(sql.Project, "alpha-one-sub")
+        assert child is not None
+        assert child.super_project_key is None
diff --git a/tests/unit/test_release_notification.py b/tests/unit/test_release_notification.py
new file mode 100644
index 00000000..c078af14
--- /dev/null
+++ b/tests/unit/test_release_notification.py
@@ -0,0 +1,51 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+#
+#   http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
+
+import datetime
+
+import atr.construct as construct
+import atr.mail as mail
+import atr.models.args as args
+import atr.models.sql as sql
+
+
+def _notification() -> args.Send:
+    committee = sql.Committee(name="Apache Example", key="example")
+    project = sql.Project(name="Apache Example", key="example")
+    released = datetime.datetime(2026, 7, 3, 12, 0, 0, tzinfo=datetime.UTC)
+    return construct.release_notification(committee, project, "1.2.3", released)
+
+
+def test_release_notification_goes_to_the_releases_list_from_noreply():
+    send = _notification()
+
+    assert send.email_to == "releases@tooling.apache.org"
+    assert send.email_sender == mail.NOREPLY_EMAIL_ADDRESS
+    assert send.footer_category == mail.MailFooterCategory.AUTO
+
+
+def test_release_notification_subject_names_committee_project_and_version():
+    send = _notification()
+
+    assert send.subject == "Apache Example Released Example 1.2.3"
+
+
+def test_release_notification_body_carries_the_version_and_a_catalogue_link():
+    send = _notification()
+
+    assert "1.2.3" in send.body
+    assert "/catalog/example" in send.body


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@tooling.apache.org
For additional commands, e-mail: commits-help@tooling.apache.org