• Resolve the winning archetypes for a (type, subType) selection from a flat candidate list: filter to the selection, dedup by shortcode keeping the winner by the composite ordering priority desc, tier asc, UUID asc, and return the winners sorted by that same ordering (so the first element is the highest-priority default).

    Candidates with a blank shortcode are not collapsed together (they fall back to their UUID as the dedup key) — an archetype should always carry a meaningful shortcode, and merging distinct unkeyed drafts would hide them.

    Parameters

    • candidates: readonly ArchetypeCandidate[]

      Every discovered candidate for the document type.

    • type: string

      The currently-selected document type.

    • subType: string

      The currently-selected subtype ("" when the type has none).

    Returns ArchetypeCandidate[]

    The winning candidates, best (default) first.