You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tooling.apache.org by sb...@apache.org on 2026/08/13 15:44:09 UTC

(tooling-trusted-releases) branch sbp updated (7fba130a -> 2a9acb8f)

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

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


 discard 7fba130a Count release files correctly using metadata
 discard d9bbed2d Write an audit entry if missing rather than deferring indefinitely
     add 18e5d2f8 #1506 - separate unfinished dir for embargoed releases
     add 64bc8450 #1506 - Sandbox tool calls
     new 2a9acb8f Write an audit entry if missing rather than deferring indefinitely

This update added new revisions after undoing existing revisions.
That is to say, some revisions that were in the old version of the
branch are not in the new version.  This situation occurs
when a user --force pushes a change and generates a repository
containing something like this:

 * -- * -- B -- O -- O -- O   (7fba130a)
            \
             N -- N -- N   refs/heads/sbp (2a9acb8f)

You should already have received notification emails for all of the O
revisions, and so the following emails describe only the N revisions
from the common base, B.

Any revisions marked "omit" are not gone; other references still
refer to them.  Any revisions marked "discard" are gone forever.

The 1 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 atr/admin/__init__.py                |  14 +++++
 atr/config.py                        |   3 +
 atr/get/file.py                      |   4 +-
 atr/get/projects.py                  |   2 +-
 atr/paths.py                         | 105 ++++++++++++++++++-----------------
 atr/server.py                        |  15 +++--
 atr/storage/writers/release.py       |   1 +
 atr/tasks/__init__.py                |  10 ++--
 atr/tasks/checks/__init__.py         |  38 +++++++++++--
 atr/tasks/checks/compare.py          |   3 +
 atr/tasks/checks/paths.py            |   4 ++
 atr/tasks/checks/rat.py              |  12 +++-
 atr/tasks/checks/signature.py        |   1 +
 atr/tasks/sbom.py                    |  45 +++++++++++----
 atr/worker.py                        |   7 +++
 tests/unit/test_admin_consistency.py |   4 +-
 tests/unit/test_paths.py             |  88 +++++++++++++++++++++++++++++
 tests/unit/test_sbom_osv.py          |   3 +-
 18 files changed, 278 insertions(+), 81 deletions(-)


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


(tooling-trusted-releases) 01/01: Write an audit entry if missing rather than deferring indefinitely

Posted by sb...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

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

commit 2a9acb8f0b58705ada720f7b2c11304ea71e8af4
Author: Sean B. Palmer <se...@miscoranda.com>
AuthorDate: Thu Aug 13 15:39:29 2026 +0100

    Write an audit entry if missing rather than deferring indefinitely
---
 atr/auditlog.py                            | 20 +++++++++++++----
 atr/models/args.py                         |  3 +++
 atr/storage/writers/announce.py            |  3 +++
 atr/storage/writers/release.py             | 27 ++++++++++++++---------
 tests/unit/test_announce_deletion_order.py |  1 +
 tests/unit/test_auditlog.py                | 35 ++++++++++++++++++++++++------
 tests/unit/test_release_finalise.py        | 29 +++++--------------------
 7 files changed, 73 insertions(+), 45 deletions(-)

diff --git a/atr/auditlog.py b/atr/auditlog.py
index 54dcdcb6..96cc90be 100644
--- a/atr/auditlog.py
+++ b/atr/auditlog.py
@@ -34,19 +34,31 @@ async def write_release_log(
     version_key: safe.VersionKey,
     *,
     until: str | None = None,
-    required_action: str | None = None,
+    marker: dict[str, Any] | None = None,
 ) -> int:
     source = pathlib.Path(config.get().STORAGE_AUDIT_LOG_FILE)
     events = await asyncio.to_thread(_matching_events, source, str(project_key), str(version_key), until)
-    if required_action is not None:
-        if not any(event.get("action") == required_action for event in events):
-            raise ValueError(f"No {required_action} event was found for {project_key}-{version_key}")
+    if (marker is not None) and (not _marker_present(events, marker)):
+        await asyncio.to_thread(_append_event, source, marker)
+        events.append(_normalise(marker, str(project_key), str(version_key)))
     target = paths.audit_release_log_file(project_key, version_key)
     content = "".join(json.dumps(event, allow_nan=False) + "\n" for event in events)
     await util.atomic_write_file(target.path, content, mode=0o444)
     return len(events)
 
 
+def _append_event(source: pathlib.Path, event: dict[str, Any]) -> None:
+    line = json.dumps({"event": event, "level": "info", "logger": "atr.storage.audit"}, allow_nan=False)
+    with source.open("a", encoding="utf-8") as handle:
+        handle.write(line + "\n")
+
+
+def _marker_present(events: list[dict[str, Any]], marker: dict[str, Any]) -> bool:
+    return any(
+        (event.get("action") == marker["action"]) and (event.get("datetime") == marker["datetime"]) for event in events
+    )
+
+
 def _matches(event: dict[str, Any], project_key: str, version_key: str, release_key: str) -> bool:
     if event.get("release_key") == release_key:
         return True
diff --git a/atr/models/args.py b/atr/models/args.py
index 42a71d5c..56b01c01 100644
--- a/atr/models/args.py
+++ b/atr/models/args.py
@@ -184,6 +184,9 @@ class ReleaseFinalise(schema.Strict):
         default=None,
         description="Optional path suffix appended under the committee distribution path",
     )
+    email_to: str | None = pydantic.Field(default=None, description="The announcement email To address")
+    email_cc: list[str] = schema.factory(list)
+    email_bcc: list[str] = schema.factory(list)
     audit_until: str = schema.description("Inclusive audit log datetime boundary for the release log")
 
 
diff --git a/atr/storage/writers/announce.py b/atr/storage/writers/announce.py
index 24222bde..de181c9c 100644
--- a/atr/storage/writers/announce.py
+++ b/atr/storage/writers/announce.py
@@ -278,6 +278,9 @@ class ReleaseManager(CommitteeParticipant):
                 revision_number=preview_revision_number,
                 svn_revision=published_revision,
                 download_path_suffix=effective_download_path_suffix,
+                email_to=email_to,
+                email_cc=email_cc or [],
+                email_bcc=email_bcc or [],
                 audit_until=audit_stamp,
             )
             self.__write_as.append_to_audit_log(
diff --git a/atr/storage/writers/release.py b/atr/storage/writers/release.py
index c928c2fe..9f2f0186 100644
--- a/atr/storage/writers/release.py
+++ b/atr/storage/writers/release.py
@@ -61,7 +61,6 @@ import atr.storage.datatypes as datatypes
 import atr.svn as svn
 import atr.tasks.checks as checks
 import atr.tasks.checks.signature as signature
-import atr.tasks.task
 import atr.util as util
 
 if TYPE_CHECKING:
@@ -1922,15 +1921,23 @@ class FoundationAdmin(FoundationCommitter):
         return stat.S_ISDIR(mode)
 
     async def __release_audit_log(self, task_args: args.ReleaseFinalise) -> int:
-        try:
-            return await auditlog.write_release_log(
-                task_args.project_key,
-                task_args.version_key,
-                until=task_args.audit_until,
-                required_action=auditlog.RELEASE_ANNOUNCE_ACTION,
-            )
-        except ValueError as exc:
-            raise atr.tasks.task.DeferredError(str(exc)) from exc
+        marker = {
+            "datetime": task_args.audit_until,
+            "action": auditlog.RELEASE_ANNOUNCE_ACTION,
+            "asf_uid": task_args.asf_uid,
+            "project_key": str(task_args.project_key),
+            "version_key": str(task_args.version_key),
+            "revision_number": str(task_args.revision_number),
+            "email_to": task_args.email_to,
+            "email_cc": task_args.email_cc,
+            "email_bcc": task_args.email_bcc,
+        }
+        return await auditlog.write_release_log(
+            task_args.project_key,
+            task_args.version_key,
+            until=task_args.audit_until,
+            marker=marker,
+        )
 
     async def __remove_release_directory(
         self,
diff --git a/tests/unit/test_announce_deletion_order.py b/tests/unit/test_announce_deletion_order.py
index 93a34040..2bf2d63f 100644
--- a/tests/unit/test_announce_deletion_order.py
+++ b/tests/unit/test_announce_deletion_order.py
@@ -175,6 +175,7 @@ async def test_finalise_queues_task_and_keeps_files(monkeypatch: pytest.MonkeyPa
     task_args = tasks[0].task_args
     parsed = args.ReleaseFinalise.model_validate(task_args)
     assert parsed.svn_revision == 85
+    assert parsed.email_to == "announce@example.apache.org"
     audit_call = release_manager._ReleaseManager__write_as.append_to_audit_log.call_args
     assert audit_call.kwargs["action"] == "release_announce"
     assert audit_call.kwargs["datetime"] == parsed.audit_until
diff --git a/tests/unit/test_auditlog.py b/tests/unit/test_auditlog.py
index c7082bb4..5d57c37b 100644
--- a/tests/unit/test_auditlog.py
+++ b/tests/unit/test_auditlog.py
@@ -91,6 +91,31 @@ async def test_write_release_log(tmp_path: pathlib.Path, monkeypatch: pytest.Mon
     assert file_mode(target) == 0o444
 
 
+async def test_write_release_log_appends_missing_marker(
+    tmp_path: pathlib.Path, monkeypatch: pytest.MonkeyPatch
+) -> None:
+    stray = {"datetime": "2026-08-10T12:00:01.000Z", "action": "announce", "project_key": "proj", "version_key": "1.0"}
+    source = write_source(tmp_path, monkeypatch, [wrap(stray)])
+    marker = {
+        "datetime": "2026-08-10T12:00:02.000Z",
+        "action": "announce",
+        "project_key": "proj",
+        "version_key": "1.0",
+        "email_to": "announce@proj.apache.org",
+    }
+
+    count = await auditlog.write_release_log(
+        safe.ProjectKey("proj"), safe.VersionKey("1.0"), until="2026-08-10T12:00:02.000Z", marker=marker
+    )
+
+    target = tmp_path / "audit" / "releases" / "proj" / "1.0.jsonl"
+    events = read_events(target)
+    assert count == 2
+    assert [event["action"] for event in events] == ["announce", "announce"]
+    assert events[1]["email_to"] == "announce@proj.apache.org"
+    assert json.loads(source.read_text(encoding="utf-8").splitlines()[-1])["event"] == marker
+
+
 async def test_write_release_log_boundary_and_marker(tmp_path: pathlib.Path, monkeypatch: pytest.MonkeyPatch) -> None:
     announced = {
         "datetime": "2026-08-10T12:00:02.000Z",
@@ -100,21 +125,17 @@ async def test_write_release_log_boundary_and_marker(tmp_path: pathlib.Path, mon
     }
     archived = {"datetime": "2026-08-10T12:00:03.000Z", "action": "archive", "project_key": "proj", "version": "1.0"}
     created = {"datetime": "2026-08-10T12:00:01.000Z", "action": "create", "project_key": "proj", "version": "1.0"}
-    write_source(tmp_path, monkeypatch, [wrap(created), wrap(announced), wrap(archived)])
+    source = write_source(tmp_path, monkeypatch, [wrap(created), wrap(announced), wrap(archived)])
     project_key = safe.ProjectKey("proj")
     version_key = safe.VersionKey("1.0")
     until = "2026-08-10T12:00:02.000Z"
 
-    count = await auditlog.write_release_log(project_key, version_key, until=until, required_action="announce")
+    count = await auditlog.write_release_log(project_key, version_key, until=until, marker=announced)
 
     target = tmp_path / "audit" / "releases" / "proj" / "1.0.jsonl"
     assert count == 2
     assert [event["action"] for event in read_events(target)] == ["create", "announce"]
-
-    with pytest.raises(ValueError):
-        await auditlog.write_release_log(
-            project_key, version_key, until="2026-08-10T12:00:01.500Z", required_action="announce"
-        )
+    assert len(source.read_text(encoding="utf-8").splitlines()) == 3
 
 
 async def test_write_release_log_replaces_readonly(tmp_path: pathlib.Path, monkeypatch: pytest.MonkeyPatch) -> None:
diff --git a/tests/unit/test_release_finalise.py b/tests/unit/test_release_finalise.py
index 11a89a7b..e195d5f4 100644
--- a/tests/unit/test_release_finalise.py
+++ b/tests/unit/test_release_finalise.py
@@ -38,7 +38,6 @@ import atr.storage.datatypes as datatypes
 import atr.storage.writers.release as release_writer
 import atr.tasks as tasks
 import atr.tasks.svnpub as svnpub
-import atr.tasks.task
 
 INTERNAL_PUBLISH_URL: Final[str] = "https://internal.example.invalid/repos/dist/atr"
 
@@ -86,6 +85,7 @@ def finalise_args() -> args.ReleaseFinalise:
         revision_number=safe.RevisionNumber("00001"),
         svn_revision=42,
         download_path_suffix=safe.RelPath("project-1.0.0"),
+        email_to="announce@project.apache.org",
         audit_until="2026-08-11T00:00:00.000Z",
     )
 
@@ -154,28 +154,6 @@ def test_finalise_wiring() -> None:
     assert isinstance(parsed, results.ReleaseFinalise)
 
 
-async def test_finalise_defers_when_announce_event_missing(
-    sqlite_sessionmaker, tmp_path: pathlib.Path, monkeypatch: pytest.MonkeyPatch
-) -> None:
-    setup_state(tmp_path, monkeypatch, {"artifact.tar.gz": b"content"})
-    monkeypatch.setattr(release_writer.svn, "export", FakeExport({"artifact.tar.gz": b"content"}))
-    monkeypatch.setattr(
-        release_writer.auditlog,
-        "write_release_log",
-        mock.AsyncMock(side_effect=ValueError("No release_announce event was found")),
-    )
-    delete = mock.AsyncMock()
-    monkeypatch.setattr(release_writer.util, "delete_immutable_directory", delete)
-    async with sqlite_sessionmaker() as data:
-        await seed_released(data)
-
-        with pytest.raises(atr.tasks.task.DeferredError):
-            await writer(data).finalise_published_release(finalise_args())
-
-    delete.assert_not_awaited()
-    assert entry_exists(tmp_path / "unfinished" / "project" / "1.0.0" / "00001" / "artifact.tar.gz")
-
-
 async def test_finalise_fails_when_publication_differs(
     sqlite_sessionmaker, tmp_path: pathlib.Path, monkeypatch: pytest.MonkeyPatch
 ) -> None:
@@ -336,7 +314,10 @@ async def test_finalise_verifies_compiles_and_deletes(
     assert str(delete.await_args.args[0]) == str(tmp_path / "unfinished" / "project" / "1.0.0.deleting-")
     assert not entry_exists(tmp_path / "unfinished" / "project" / "1.0.0")
     assert write_release_log.await_args.kwargs["until"] == "2026-08-11T00:00:00.000Z"
-    assert write_release_log.await_args.kwargs["required_action"] == auditlog.RELEASE_ANNOUNCE_ACTION
+    marker = write_release_log.await_args.kwargs["marker"]
+    assert marker["action"] == auditlog.RELEASE_ANNOUNCE_ACTION
+    assert marker["datetime"] == "2026-08-11T00:00:00.000Z"
+    assert marker["email_to"] == "announce@project.apache.org"
 
 
 async def test_finalise_warns_on_unexpected_publication_files(


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