improve model provider selection algorithm

This commit is contained in:
miloschwartz
2026-08-11 16:10:34 -04:00
parent 75c6af3b11
commit c42df737b0
11 changed files with 408 additions and 200 deletions
-23
View File
@@ -61,29 +61,6 @@ export function compareModelKeySpecificity(a: string, b: string): number {
return literalLength(b) - literalLength(a);
}
/**
* Attach-time conflict check. Detects identical keys and exact-vs-pattern
* matches. Does not attempt full glob intersection.
*/
export function modelKeysConflict(a: string, b: string): boolean {
if (a === b) {
return true;
}
const aIsPattern = isModelKeyPattern(a);
const bIsPattern = isModelKeyPattern(b);
if (aIsPattern === bIsPattern) {
return false;
}
if (aIsPattern) {
return modelKeyMatches(a, b);
}
return modelKeyMatches(b, a);
}
/**
* Provider-layer policy: empty allowlist denies all. Blocklist only applies
* after an allow match.