Packages are not properly removed from Lenient packages endpoint once an explicitly compatible version is available (example: Search API Pantheon 3.0.0)
>>> [!note] Migrated issue
<!-- Drupal.org comment -->
<!-- Migrated from issue #3246383. -->
Reported by: [damienmckenna](https://www.drupal.org/user/108450)
>>>
<h3 id="summary-problem-motivation">Problem/Motivation</h3>
<p>Once a package has a Drupal 9 compatible release, it should be removed from the lenient packages end-point, so that when composer resolves dependencies it falls back to the primary package endpoint and finds the dependency there.</p>
<p>Right now - this is not happening, and because the lenient facade is checked first when resolving dependencies, old versions are offered instead of the explicitly compatible d9 versions. </p>
<ul>
<li>When releases are packaged, we update both the primary packages endpoint, and the lenient endpoint.</li>
<li>There is already logic in the lenient endpoint that checks if the release declares explicit compatibility, and if it does, excludes it from being included in the lenient endpoint</li>
<li>However - it is not deleting the previous generated composer metadata file - so it is still on disk and being served by the CDN (Composer 1 used to regenerate the full tree every time, Composer 2 does not, so these are being left behind) </li>
</ul>
<h4>Example - per @DamienMcKenna and @brooke_heaton</h4>
<p><strong>Search API Pantheon 3.0.0 </strong><br>
When the Lenient repo is added on a project is becomes impossible to add the Search API Pantheon 3.0.0 release to a site, instead it attempts to add the 8.x-1.0 release from the Lenient repository, the only way of adding 3.0.0 is to add "drupal/search_api_pantheon" to the "exclude" list on the lenient repo.</p>
<pre>Problem 1<br> - Root composer.json requires drupal/search_api_pantheon ^3, it is satisfiable by drupal/search_api_pantheon[dev-3.0.x, 3.0.0, 3.0.x-dev (alias of dev-3.0.x)] from composer repo (https://packages.drupal.org/8) but drupal/search_api_pantheon[dev-1.x, 1.0.0-alpha1, ..., 1.x-dev (alias of dev-1.x)] from composer repo (https://packages.drupal.org/lenient) has higher repository priority. The packages with higher priority do not match your constraint and are therefore not installable. See https://getcomposer.org/repoprio for details and assistance.</pre><h4 id="summary-steps-reproduce">Steps to reproduce</h4>
<ul>
<li>Add the Lenient repo to a codebase above the main D8 repo.</li>
<li>Run<br>
<pre>composer require drupal/search_api_pantheon</pre><p> (Or one of the other projects that is appearing improperly in both endpoints) </p></li>
</ul>
<h3 id="summary-proposed-resolution">Proposed resolution</h3>
<p>From a stand up on the Drupal Association side, we believe we've narrowed down the issue. </p>
<p>When repackaging the endpoints and processing a particular release: </p>
<ul>
<li>We should delete the flat file that has been regenerated for that release </li>
<li><del>Then</del> we should run the compatibility check to decide whether to rewrite it because it still belongs in the lenient endpoint or <strong>not</strong> to write it because it is now d9 compatible in the main endpoint. </li>
<li>We should then purge the CDN after that logic check. </li>
</ul>
<h3 id="summary-remaining-tasks">Remaining tasks</h3>
<ul>
<li>Implement the proposed resolution.</li>
<li>Clean-up the meta data for releases that have already been made that exist in both places. </li>
</ul>
issue