ecluse:ecluse-core
Safe HaskellNone
LanguageGHC2021

Ecluse.Core.Package.Merge

Description

Merge admitted source snapshots with trusted-source precedence. The plan carries exact artifact coordinates for raw assembly and reports integrity divergence.

Synopsis

Provenance

data Provenance Source #

Which upstream a document came from. The caller decides this and applies it before merging. Ord is the trust order: TrustedSource sorts before GatedSource, so the smallest wins.

Constructors

TrustedSource

A private-upstream document. Its versions are already vetted, so they enter the union unfiltered and win any collision.

GatedSource

A public-upstream document. Its versions are the set that already survived the rules engine. The merge unions them but never re-filters.

Merging

type SourceId = Int Source #

The 0-based index of an input to one mergePackuments call. The caller pairs each SourceId back to the raw Value it passed at that position, which Provenance alone cannot name.

data MergePlan Source #

The decisions a merge reached over several upstream packuments. The serve layer replays the plan onto the raw upstream Values. It is never a finished, re-serialisable document.

Constructors

MergePlan 

Fields

  • mpName :: PackageName

    The package identity, carried from the contributions. A check upstream of the merge drops any contribution whose name disagrees, so this is never a substituted or manufactured value.

  • mpSurvivors :: Map Text SourceId

    Each surviving version key mapped to the SourceId of the input that won it. Trusted wins a collision. The serve layer takes that version's object from that source's raw Value.

  • mpDistTags :: Map Text Version

    dist-tags reconciled over the survivors. latest comes from the public tag or the ordering, never the private one. Other tags carry by precedence, and an absent target drops.

  • mpArtifacts :: Map Text (NonEmpty AdmittedEntry)

    Exact admitted entries from each version's winning source snapshot.

  • mpTime :: Map Text UTCTime

    Publish times from winning candidates. A winner with no known time contributes no entry.

  • mpDivergences :: Set Divergence

    Every distinct same-version integrity conflict: the winner's fingerprint against each fingerprint that contradicts it on a shared algorithm. Differing algorithm sets do not count.

Instances

Instances details
Show MergePlan Source # 
Instance details

Defined in Ecluse.Core.Package.Merge

Eq MergePlan Source # 
Instance details

Defined in Ecluse.Core.Package.Merge

data Divergence Source #

Conflicting digests for one version. The private copy wins and both fingerprints remain for alarms.

Constructors

Divergence 

Fields

integrityHashes :: IntegrityFingerprint -> [(Text, Maybe HashAlg, Text)] Source #

Sorted filename, algorithm, and original digest-body triples, including duplicates.

integrityDivergences :: Map Text PackageDetails -> Map Text PackageDetails -> Set Divergence Source #

Compare integrity-admitted versions independently of rule eligibility, with the trusted map winning. Inputs must share a validated package identity. Only shared version keys are compared.

mergePackuments :: [(Provenance, Snapshot PackageInfo)] -> Maybe MergePlan Source #

Merge admitted snapshots with trusted-source precedence and divergence reporting. Empty input yields Nothing.

The merge accumulator

The merge folds each input's contribute into the lawful Merge Monoid, which planFrom then projects to a MergePlan. Merge is opaque, so a SourceId always names a real input position.

data Merge Source #

The monoidal accumulator the merge folds into. It leaves every version key's candidates unresolved, because a pairwise winner decision during the fold is not associative for 3+ copies.

Instances

Instances details
Monoid Merge Source # 
Instance details

Defined in Ecluse.Core.Package.Merge

Methods

mempty :: Merge #

mappend :: Merge -> Merge -> Merge #

mconcat :: [Merge] -> Merge #

Semigroup Merge Source # 
Instance details

Defined in Ecluse.Core.Package.Merge

Methods

(<>) :: Merge -> Merge -> Merge #

sconcat :: NonEmpty Merge -> Merge #

stimes :: Integral b => b -> Merge -> Merge #

Show Merge Source # 
Instance details

Defined in Ecluse.Core.Package.Merge

Methods

showsPrec :: Int -> Merge -> ShowS #

show :: Merge -> String #

showList :: [Merge] -> ShowS #

Eq Merge Source # 
Instance details

Defined in Ecluse.Core.Package.Merge

Methods

(==) :: Merge -> Merge -> Bool #

(/=) :: Merge -> Merge -> Bool #

contribute :: Provenance -> Snapshot PackageInfo -> Merge Source #

One input's contribution to the accumulator, at local SourceId 0. The Semigroup offset re-indexes it to the input's position when mergePackuments folds over the inputs.

planFrom :: Merge -> Maybe MergePlan Source #

Project the resolved MergePlan from a folded Merge. It resolves each version key to its precedence winner. Nothing only for mempty, the empty merge, which has nothing to serve.