serpent-os / tools

The home of moss (system state manager) and boulder (moss format build tool)
https://serpentos.com
132 stars 12 forks source link

moss: Fix sync transaction & use pinned providers #325

Closed tarkah closed 1 month ago

tarkah commented 1 month ago

Issue

Transaction resolution was borked in sync due to the fact we were explicitly adding transitive packages to the transaction.

This is incorrect since transitive packages should only get added to a transaction via provider resolution from a dependent explicit package. There are two issues from doing this:

Even if we solve the above by removing orphaned packages from the TX, the wrong package would get removed because the transitive with an edge to the explicit was the resolved transitive, not the explicitly added one.

The reason we explicitly added transitives was to ensure sync updates to transitive packages were picked up in the final state. This was needed because TX provider resolution will first resolve against selections and installed packages before available packages.

Solution

Allow a TX to resolve providers first based on a list of "pinned" packages. During sync, we can define this pinned list of providers as "packages that have a sync update". Then we only add explicit packages to the TX. When provider resolution is done on those explicits dependencies, if it matches one of the pinned packages, it will use that first before then falling back to selections -> installed -> available.

This results in a transaction that cannot have orphans because it only resolved from explicit packages while also resulting in a TX that includes updated transitives if they were part of the pinned provider list.