@@ -7,7 +7,7 @@ describe("V7-H04 spec migrations", () => {
77 it ( "stamps schema_version on a v0 (pre-versioning) spec" , ( ) => {
88 const v0 = { projectName : "demo" , spec : { } , nodes : [ ] , edges : [ ] } ;
99 const out = migrate ( v0 ) ;
10- expect ( out . schema_version ) . toBe ( 1 ) ;
10+ expect ( out . schema_version ) . toBe ( CURRENT_SCHEMA_VERSION ) ;
1111 expect ( out . projectName ) . toBe ( "demo" ) ;
1212 } ) ;
1313
@@ -30,9 +30,40 @@ describe("V7-H04 spec migrations", () => {
3030 spec : { loss : { kind : "cross_entropy" } , optim : { kind : "adamw" } } ,
3131 nodes : [ { id : "a" } ] ,
3232 } ;
33- const out = migrate ( v0 ) as typeof v0 & { schema_version : number } ;
34- expect ( out . schema_version ) . toBe ( 1 ) ;
35- expect ( out . spec ) . toEqual ( v0 . spec ) ;
33+ const out = migrate ( v0 ) as typeof v0 & {
34+ schema_version : number ;
35+ spec : Record < string , unknown > ;
36+ } ;
37+ expect ( out . schema_version ) . toBe ( CURRENT_SCHEMA_VERSION ) ;
38+ expect ( out . spec . loss ) . toEqual ( v0 . spec . loss ) ;
39+ expect ( out . spec . optim ) . toEqual ( v0 . spec . optim ) ;
40+ expect ( out . spec . data_materialization ) . toBeDefined ( ) ;
3641 expect ( out . nodes ) . toEqual ( v0 . nodes ) ;
3742 } ) ;
43+
44+ it ( "adds data materialization defaults when loading v1 specs" , ( ) => {
45+ const v1 = {
46+ schema_version : 1 ,
47+ spec : { loss : { kind : "cross_entropy" } } ,
48+ } ;
49+ const out = migrate ( v1 ) as typeof v1 & {
50+ spec : { data_materialization ?: unknown } ;
51+ } ;
52+ expect ( out . schema_version ) . toBe ( CURRENT_SCHEMA_VERSION ) ;
53+ expect ( out . spec . data_materialization ) . toEqual ( {
54+ packing_policy : "best_fit" ,
55+ max_seq_len : 4096 ,
56+ pad_to_max : true ,
57+ include_provenance : true ,
58+ required_token_fields : [
59+ "input_ids" ,
60+ "target_ids" ,
61+ "loss_mask" ,
62+ "doc_ids" ,
63+ "pack_id" ,
64+ "valid_token_count" ,
65+ "num_docs" ,
66+ ] ,
67+ } ) ;
68+ } ) ;
3869} ) ;
0 commit comments