@@ -8,16 +8,16 @@ import { computeRecommendationScore } from "./lib/recommendationScore";
88import { INSTALL_BACKFILL_CLEAN_WINDOW_READY_CURSOR_CREATION_TIME } from "./lib/skillInstallBackfill" ;
99import {
1010 backfillOneSkillInstallEstimate ,
11- buildCanonicalTopicPatch ,
12- runCatalogTopicCanonicalization ,
11+ buildCanonicalCatalogMetadataPatch ,
12+ runCatalogMetadataCanonicalization ,
1313 runSkillInstallBackfill ,
1414} from "./migrations" ;
1515
1616type InstallBackfillWrappedHandler = {
1717 _handler : ( ctx : unknown , args : { dryRun ?: boolean ; confirm ?: string } ) => Promise < unknown > ;
1818} ;
1919
20- type CatalogTopicCanonicalizationWrappedHandler = {
20+ type CatalogMetadataCanonicalizationWrappedHandler = {
2121 _handler : ( ctx : unknown , args : { dryRun ?: boolean ; confirm ?: string } ) => Promise < unknown > ;
2222} ;
2323
@@ -119,121 +119,189 @@ function isRecord(value: unknown): value is Record<string, unknown> {
119119 return typeof value === "object" && value !== null ;
120120}
121121
122- describe ( "catalog topic canonicalization migration" , ( ) => {
123- it ( "promotes current inferred topics into the canonical topics field " , ( ) => {
122+ describe ( "catalog metadata canonicalization migration" , ( ) => {
123+ it ( "promotes current inferred categories and topics into canonical fields " , ( ) => {
124124 expect (
125- buildCanonicalTopicPatch ( {
125+ buildCanonicalCatalogMetadataPatch ( {
126+ categoryKind : "skill" ,
127+ categories : undefined ,
126128 topics : undefined ,
129+ inferredCategories : [ "development" , "research" ] ,
127130 inferredTopics : [ "TypeScript" , "Code Review" ] ,
128131 currentSourceId : "skillVersions:v1" ,
129132 inferredSourceId : "skillVersions:v1" ,
133+ inferredCategoryConfidence : "high" ,
130134 inferredTopicConfidence : "high" ,
135+ inferredClassifierVersion : "taxonomy-prototype-v9" ,
131136 inferredTopicClassifierVersion : "topic-prototype-v1" ,
137+ inferredInputHash : "category-hash" ,
132138 inferredTopicInputHash : "topic-hash" ,
139+ inferredAt : 123 ,
133140 } ) ,
134141 ) . toEqual ( {
142+ categories : [ "development" , "research" ] ,
135143 topics : [ "TypeScript" , "Code Review" ] ,
144+ inferredCategories : undefined ,
136145 inferredTopics : undefined ,
146+ inferredCategoryConfidence : undefined ,
137147 inferredTopicConfidence : undefined ,
148+ inferredClassifierVersion : undefined ,
138149 inferredTopicClassifierVersion : undefined ,
150+ inferredInputHash : undefined ,
139151 inferredTopicInputHash : undefined ,
152+ inferredAt : undefined ,
140153 } ) ;
141154 } ) ;
142155
143- it ( "preserves explicit publisher topics while clearing inferred topic metadata" , ( ) => {
156+ it ( "preserves explicit publisher metadata while clearing inferred metadata" , ( ) => {
144157 expect (
145- buildCanonicalTopicPatch ( {
158+ buildCanonicalCatalogMetadataPatch ( {
159+ categoryKind : "plugin" ,
160+ categories : [ "tools" ] ,
146161 topics : [ ] ,
162+ inferredCategories : [ "models" ] ,
147163 inferredTopics : [ "TypeScript" ] ,
148164 currentSourceId : "skillVersions:v1" ,
149165 inferredSourceId : "skillVersions:v1" ,
166+ inferredCategoryConfidence : "medium" ,
150167 inferredTopicConfidence : "high" ,
151168 } ) ,
152169 ) . toEqual ( {
170+ inferredCategories : undefined ,
153171 inferredTopics : undefined ,
172+ inferredCategoryConfidence : undefined ,
154173 inferredTopicConfidence : undefined ,
174+ inferredClassifierVersion : undefined ,
155175 inferredTopicClassifierVersion : undefined ,
176+ inferredInputHash : undefined ,
156177 inferredTopicInputHash : undefined ,
178+ inferredAt : undefined ,
157179 } ) ;
158180 } ) ;
159181
160- it ( "does not promote stale inferred topics " , ( ) => {
182+ it ( "does not promote stale inferred metadata " , ( ) => {
161183 expect (
162- buildCanonicalTopicPatch ( {
184+ buildCanonicalCatalogMetadataPatch ( {
185+ categoryKind : "skill" ,
186+ categories : undefined ,
163187 topics : undefined ,
188+ inferredCategories : [ "development" ] ,
164189 inferredTopics : [ "TypeScript" ] ,
165190 currentSourceId : "skillVersions:v2" ,
166191 inferredSourceId : "skillVersions:v1" ,
192+ inferredClassifierVersion : "taxonomy-prototype-v9" ,
167193 inferredTopicClassifierVersion : "topic-prototype-v1" ,
168194 } ) ,
169195 ) . toEqual ( {
196+ inferredCategories : undefined ,
170197 inferredTopics : undefined ,
198+ inferredCategoryConfidence : undefined ,
171199 inferredTopicConfidence : undefined ,
200+ inferredClassifierVersion : undefined ,
172201 inferredTopicClassifierVersion : undefined ,
202+ inferredInputHash : undefined ,
173203 inferredTopicInputHash : undefined ,
204+ inferredAt : undefined ,
174205 } ) ;
175206 } ) ;
176207
177- it ( "does not promote inferred topics after a publisher metadata save " , ( ) => {
208+ it ( "does not promote inferred categories for legacy skill-family package rows " , ( ) => {
178209 expect (
179- buildCanonicalTopicPatch ( {
210+ buildCanonicalCatalogMetadataPatch ( {
211+ categoryKind : "none" ,
212+ categories : undefined ,
180213 topics : undefined ,
214+ inferredCategories : [ "models" ] ,
215+ inferredTopics : [ "TypeScript" ] ,
216+ currentSourceId : "packageReleases:v1" ,
217+ inferredSourceId : "packageReleases:v1" ,
218+ inferredCategoryConfidence : "high" ,
219+ inferredTopicConfidence : "high" ,
220+ } ) ,
221+ ) . toEqual ( {
222+ topics : [ "TypeScript" ] ,
223+ inferredCategories : undefined ,
224+ inferredTopics : undefined ,
225+ inferredCategoryConfidence : undefined ,
226+ inferredTopicConfidence : undefined ,
227+ inferredClassifierVersion : undefined ,
228+ inferredTopicClassifierVersion : undefined ,
229+ inferredInputHash : undefined ,
230+ inferredTopicInputHash : undefined ,
231+ inferredAt : undefined ,
232+ } ) ;
233+ } ) ;
234+
235+ it ( "does not promote inferred metadata after a publisher metadata save" , ( ) => {
236+ expect (
237+ buildCanonicalCatalogMetadataPatch ( {
238+ categoryKind : "skill" ,
239+ categories : undefined ,
240+ topics : undefined ,
241+ inferredCategories : [ "development" ] ,
181242 inferredTopics : [ "TypeScript" ] ,
182243 currentSourceId : "skillVersions:v1" ,
183244 inferredSourceId : "skillVersions:v1" ,
245+ inferredCategoryConfidence : "high" ,
184246 inferredTopicConfidence : "high" ,
185- hasPublisherTopicIntent : true ,
247+ hasPublisherCatalogIntent : true ,
186248 } ) ,
187249 ) . toEqual ( {
250+ inferredCategories : undefined ,
188251 inferredTopics : undefined ,
252+ inferredCategoryConfidence : undefined ,
189253 inferredTopicConfidence : undefined ,
254+ inferredClassifierVersion : undefined ,
190255 inferredTopicClassifierVersion : undefined ,
256+ inferredInputHash : undefined ,
191257 inferredTopicInputHash : undefined ,
258+ inferredAt : undefined ,
192259 } ) ;
193260 } ) ;
194261
195- it ( "is a no-op when no inferred topic state exists" , ( ) => {
262+ it ( "is a no-op when no inferred catalog state exists" , ( ) => {
196263 expect (
197- buildCanonicalTopicPatch ( {
264+ buildCanonicalCatalogMetadataPatch ( {
265+ categoryKind : "skill" ,
266+ categories : [ "development" ] ,
198267 topics : [ "Publisher Topic" ] ,
199268 currentSourceId : "skillVersions:v1" ,
200- inferredSourceId : "skillVersions:v1" ,
201269 } ) ,
202270 ) . toBeNull ( ) ;
203271 } ) ;
204272
205273 it ( "dry-runs both tracked canonicalization migrations" , async ( ) => {
206274 const runMutation = vi . fn ( ) . mockResolvedValue ( { } ) ;
207275 const handler = (
208- runCatalogTopicCanonicalization as unknown as CatalogTopicCanonicalizationWrappedHandler
276+ runCatalogMetadataCanonicalization as unknown as CatalogMetadataCanonicalizationWrappedHandler
209277 ) . _handler ;
210278
211279 const result = await handler ( { runMutation } , { } ) ;
212280
213281 expect ( runMutation ) . toHaveBeenNthCalledWith ( 1 , internal . migrations . run , {
214- fn : "migrations:canonicalizeSkillTopics " ,
282+ fn : "migrations:canonicalizeSkillCatalogMetadata " ,
215283 dryRun : true ,
216284 reset : true ,
217285 } ) ;
218286 expect ( runMutation ) . toHaveBeenNthCalledWith ( 2 , internal . migrations . run , {
219- fn : "migrations:canonicalizePackageTopics " ,
287+ fn : "migrations:canonicalizePackageCatalogMetadata " ,
220288 dryRun : true ,
221289 reset : true ,
222290 } ) ;
223291 expect ( result ) . toMatchObject ( {
224292 ok : true ,
225293 dryRun : true ,
226- confirmRequired : "canonicalize-catalog-topics " ,
294+ confirmRequired : "canonicalize-catalog-metadata " ,
227295 } ) ;
228296 } ) ;
229297
230- it ( "requires explicit confirmation before canonicalizing topics " , async ( ) => {
298+ it ( "requires explicit confirmation before canonicalizing catalog metadata " , async ( ) => {
231299 const handler = (
232- runCatalogTopicCanonicalization as unknown as CatalogTopicCanonicalizationWrappedHandler
300+ runCatalogMetadataCanonicalization as unknown as CatalogMetadataCanonicalizationWrappedHandler
233301 ) . _handler ;
234302
235303 await expect ( handler ( { runMutation : vi . fn ( ) } , { dryRun : false } ) ) . rejects . toThrow (
236- 'Pass confirm="canonicalize-catalog-topics " to apply.' ,
304+ 'Pass confirm="canonicalize-catalog-metadata " to apply.' ,
237305 ) ;
238306 } ) ;
239307} ) ;
0 commit comments