Handling of existing `[id=...]` in title and section headings

When converting an existing document like

[id="id1"]
= The Page Title

[id="id2"]
== First Section

xref:id1[Linking the top]

== Second Section

content

the expected created IDs for me would be:

[#the-page:::id1]
== The Page Title

and

[discrete#the-page:::id2]
=== First Section

Instead, the following is created:

[#the-page:::]
== The Page Title
[id="id1"]

and this for the other

[discrete#the-page:::id2,id="id2"]
=== First Section

I started to create branch here with a (failing) test case here: https://gitlab.com/ahus1/antora-assembler/-/tree/handle-existing-ids

Before continuing, I'd like to hear if the behavior I expect is also expected by others, or if I should aim for something different.

Besides that, I'd be happy to get some directions on how an implementation could look like.