This will allow to hand out system-user assertions limited to a
limited set of serial assertions.
Implements the spec in https://forum.snapcraft.io/t/18163
Motivation
With the new assertion bulk refresh API we can fetch or update
many assertions together, either assertions related/dependent or
unrelated/independent of each other.
To help driving and managing that this introduces asserts.Pool:
* a Pool can track unresolved assertions to be fetched
* or assertions to be updated
* it can record resolved assertions as fetched from the store and
implicitly turn unresolved prerequisites into assertions to
resolve
* assertions can be organized in groups, as the doc comment explains:
Failure can be tracked isolated to groups, conversely any
error related to a single group alone will stop any work to
resolve it. Independent assertions should not be grouped.
* assertions that are part of or are required by more than one
group are tracked only once, for example store account-keys or
developer account assertions for developers of many snaps on
the system.
The latter is achieved by labeling each assertion with a Grouping
which represents all the groups it belongs to, at the low-level
this uses internal.Groupings/Grouping.
This organization into groupings matches well with the capabilities
of the API and means assertions will be typically requested only
once and grouped in ways that should be cache friendly.
This converts the singleton asserts.ErrNotFound to a richer asserts.NotFoundError struct carrying Type and optionally PrimaryKey, similar to store.AssertionNotFoundError which then gets folded with this.
This means code doesn't have to worry anymore which is which or to convert between the two. And when possible there is more information around. Though Backstores can continue to return minimal information (Type but not Headers in the new error).
A helper asserts.IsNotFound is also added to cover the simple old ==/!= asserts.ErrNotFound needs.
This also fixes/adjust some error handling to usually not repeat the richer information twice.
asserts: introduce NewDecoderWithTypeMaxBodySize
NewDecoderWithTypeMaxBodySize allow to create an assertion stream Decoder that is configured with optional per-type max body sizes.
This will allow snap-repair to control what size of repair scripts/bodies is happy to accept.