@@ -147,6 +147,7 @@ export interface ContextRegistryRankOptions {
147147 source ?: string ;
148148 tags ?: string [ ] ;
149149 negativeExamples ?: string [ ] ;
150+ localQualitySignals ?: Record < string , number > ;
150151}
151152
152153export interface RankedContextEntry {
@@ -181,11 +182,12 @@ export function rankContextEntry(task: string, terms: string[], entry: ContextEn
181182 const dependency = fieldScore ( terms , ( entry . dependencyChain ?? [ ] ) . join ( " " ) , 10 ) ;
182183 const source = sourceWeight ( entry . trustLevel ) ;
183184 const quality = Math . min ( 10 , entry . qualityScore ?? qualityScore ( entry ) ) ;
185+ const localFeedback = Math . max ( - 3 , Math . min ( 3 , options . localQualitySignals ?. [ feedbackKey ( entry ) ] ?? 0 ) ) ;
184186 const regression = regressionWeight ( terms , entry ) ;
185187 const negativePenalty = negativePenaltyForEntry ( entry , options . negativeExamples ?? [ ] ) ;
186188 const exactBoost = exactId ? 1000 : 0 ;
187189 const taskType = taskTypeWeight ( options . taskType , entry . kind ) ;
188- const score = exactBoost + lexical + symbol + dependency + source + quality + regression + taskType - negativePenalty ;
190+ const score = exactBoost + lexical + symbol + dependency + source + quality + localFeedback + regression + taskType - negativePenalty ;
189191 const scoreBreakdown : RetrievalScoreBreakdown = {
190192 lexical,
191193 path : 0 ,
@@ -200,13 +202,22 @@ export function rankContextEntry(task: string, terms: string[], entry: ContextEn
200202 dependency,
201203 source,
202204 quality,
205+ localFeedback,
203206 regression,
204207 exactId : exactBoost ,
205208 total : score
206209 } ;
207210 return { entry, score, scoreBreakdown, exactId } ;
208211}
209212
213+ export function contextEntryFeedbackKey ( entry : Pick < ContextEntry , "sourceName" | "id" > ) : string {
214+ return `${ entry . sourceName } \0${ entry . id } ` ;
215+ }
216+
217+ function feedbackKey ( entry : ContextEntry ) : string {
218+ return contextEntryFeedbackKey ( entry ) ;
219+ }
220+
210221export function matchesEntryFilters ( entry : ContextEntry , options : ContextRegistryRankOptions ) : boolean {
211222 if ( options . packageVersion && entry . packageVersion !== options . packageVersion ) return false ;
212223 if ( options . language && entry . language !== options . language ) return false ;
0 commit comments