Skip to content

feat(resolver): diamond dependency priority resolution by registry declaration order #204

@mrwogu

Description

@mrwogu

Context

When two registries at the same layer both extend the same skill (diamond dependency), there is currently no defined priority resolution. For example, if both @bu-retail and @bu-travel extend @clm5core/clm512-expert, the result is non-deterministic.

Parent issue: #199 (Phase 2)
Spec: docs/superpowers/specs/2026-03-30-skill-overlay-extends-design.md §5.1

Proposal

Priority should be determined by registries: declaration order in promptscript.yaml. A registry declared later in the YAML wins at collision. This is deterministic and explicit — changing YAML order changes compilation result.

Configuration

registries:
  '@clm5core': ...      # Layer 2
  '@bu-retail': ...     # Layer 3 — lower priority
  '@bu-travel': ...     # Layer 3 — higher priority (declared later)

Logging behavior

ℹ Registry priority (highest last): @clm5core, @bu-retail, @bu-travel
⚠ skill clm512-expert: references/architecture.md from @bu-travel overrides @bu-retail

Implementation approach

  1. Tag imported blocks with their source registry index during import resolution
  2. When applyExtends() encounters conflicting extensions on the same skill, resolve by registry index (higher index = higher priority)
  3. For append-strategy properties (references, examples, requires): deduplicate by filename, higher-priority registry wins with a warning logged

Design considerations

  • Requires extending the AST or resolution context to carry registry source metadata
  • The current applyExtends() in extensions.ts applies extensions sequentially — registry ordering must be enforced before this step
  • Must handle the case where both registries add a reference with the same filename (dedup by basename, higher-priority wins)

Acceptance criteria

  • Extensions from multiple registries on the same skill resolve by declaration order
  • Later-declared registry takes priority at property collision
  • Reference filename collisions deduplicate with warning logged
  • Registry priority is logged at info level during compilation
  • Tests for 2-registry and 3-registry diamond scenarios
  • Documentation updated with priority resolution rules

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions