-
Notifications
You must be signed in to change notification settings - Fork 7
Description
Problem
ExternalPackManifest.validate() checks for duplicate component IDs (duplicateComponentID) but does not check for duplicate (destination, fileType) pairs within the same pack.
A pack author could write:
components:
- id: lint-hook
description: Lint hook
hookEvent: PreToolUse
hook:
source: hooks/lint.sh
destination: lint.sh
- id: format-hook
description: Format hook
hookEvent: PreToolUse
hook:
source: hooks/format.sh
destination: lint.sh # ← same destination, different IDThis passes validation but the second component silently overwrites the first during mcs sync. Both get tracked in PackArtifactRecord, but only one file exists on disk.
Proposed Solution
Add a duplicateDestination validation in ExternalPackManifest.validate():
- Scan all components with
copyPackFileinstall actions - Build a set of
(destination, fileType)pairs - If a duplicate is found, throw a new
ManifestError.duplicateDestination(destination:fileType:componentIDs:)error
This catches the mistake at pack load time with a clear error message, consistent with the existing duplicateComponentID check.
Context
The cross-pack collision resolver (DestinationCollisionResolver) deliberately skips intra-pack duplicates (distinctPackIndices.count >= 2) — namespacing a pack against itself doesn't make sense. This validation would catch the problem earlier, at manifest load time.
References
Sources/mcs/ExternalPack/ExternalPackManifest.swift—validate()methodSources/mcs/Install/DestinationCollisionResolver.swift— cross-pack collision detection