@@ -41,10 +41,14 @@ async fn orphan_reporting_uses_complete_registry_rows_not_token_accounting() {
4141 . unwrap ( ) ;
4242 let profile_root = dir. path ( ) . join ( "profile" ) ;
4343 let eligible_root = dir. path ( ) . join ( "eligible-repo" ) ;
44+ let conflicting_root = dir. path ( ) . join ( "conflicting-repo" ) ;
45+ let conflicting_registered_root = dir. path ( ) . join ( "registered-elsewhere" ) ;
4446 let blocked_root = dir. path ( ) . join ( "blocked-repo" ) ;
4547 std:: fs:: create_dir_all ( & eligible_root) . unwrap ( ) ;
48+ std:: fs:: create_dir_all ( & conflicting_root) . unwrap ( ) ;
49+ std:: fs:: create_dir_all ( & conflicting_registered_root) . unwrap ( ) ;
4650 std:: fs:: create_dir_all ( & blocked_root) . unwrap ( ) ;
47- for root in [ & eligible_root, & blocked_root] {
51+ for root in [ & eligible_root, & conflicting_root , & blocked_root] {
4852 let status = std:: process:: Command :: new ( "git" )
4953 . args ( [ "init" , "--quiet" ] )
5054 . current_dir ( root)
@@ -61,8 +65,18 @@ async fn orphan_reporting_uses_complete_registry_rows_not_token_accounting() {
6165 )
6266 . unwrap ( ) ;
6367 write_repository_identity_marker ( & eligible_root, "proj_eligible" ) . unwrap ( ) ;
68+ write_enrollment_marker (
69+ & conflicting_root,
70+ & EnrollmentMarker {
71+ project_id : "proj_conflict" . to_string ( ) ,
72+ storage_mode : StorageMode :: ProfileSharded ,
73+ } ,
74+ )
75+ . unwrap ( ) ;
76+ write_repository_identity_marker ( & conflicting_root, "proj_conflict" ) . unwrap ( ) ;
6477 for ( project_id, project_root) in [
6578 ( "proj_eligible" , & eligible_root) ,
79+ ( "proj_conflict" , & conflicting_root) ,
6680 ( "proj_blocked" , & blocked_root) ,
6781 ] {
6882 let data_root = profile_root. join ( "projects" ) . join ( project_id) ;
@@ -88,9 +102,24 @@ async fn orphan_reporting_uses_complete_registry_rows_not_token_accounting() {
88102 let db = crate :: global_db:: GlobalDb :: open_at ( & dir. path ( ) . join ( "global.db" ) )
89103 . await
90104 . unwrap ( ) ;
105+ db. upsert_code_project (
106+ "proj_conflict" ,
107+ & conflicting_registered_root,
108+ None ,
109+ None ,
110+ Some ( "main" ) ,
111+ )
112+ . await
113+ . unwrap ( ) ;
91114 let ( count, warnings) = orphan_store_manifest_report ( & db, & profile_root) . await ;
92115
93116 assert_eq ! ( count, 1 , "{warnings:?}" ) ;
117+ assert ! (
118+ warnings
119+ . iter( )
120+ . any( |warning| warning. contains( "proj_conflict" ) ) ,
121+ "{warnings:?}"
122+ ) ;
94123
95124 let scan = crate :: migrate:: registry:: scan_profile_store_manifests ( & profile_root, 1_800_000_000 ) ;
96125 let eligible = crate :: migrate:: registry:: RegistryReconstructionReport {
@@ -99,10 +128,42 @@ async fn orphan_reporting_uses_complete_registry_rows_not_token_accounting() {
99128 . into_iter ( )
100129 . filter ( |plan| {
101130 plan. status == crate :: migrate:: registry:: RegistryReconstructionStatus :: Eligible
131+ && plan. project . project_id == "proj_eligible"
102132 } )
103133 . collect ( ) ,
104134 issues : Vec :: new ( ) ,
105135 } ;
136+ let mut batch_left = eligible. plans [ 0 ] . clone ( ) ;
137+ batch_left. project . aliases = vec ! [ dir. path( ) . join( "shared-alias" ) ] ;
138+ let mut batch_right = batch_left. clone ( ) ;
139+ batch_right. project . project_id = "proj_batch_other" . to_string ( ) ;
140+ batch_right. project . project_root = conflicting_root. clone ( ) ;
141+ batch_right. store . project_id = batch_right. project . project_id . clone ( ) ;
142+ batch_right. store . store_id = "store:proj_batch_other:profile_sharded" . to_string ( ) ;
143+ batch_right. store . store_relpath = "projects/proj_batch_other" . to_string ( ) ;
144+ batch_right. store . manifest_relpath =
145+ Some ( "projects/proj_batch_other/store_manifest.json" . to_string ( ) ) ;
146+ batch_right. graph_scopes . clear ( ) ;
147+ batch_right. artifacts . clear ( ) ;
148+ batch_left. graph_scopes . clear ( ) ;
149+ batch_left. artifacts . clear ( ) ;
150+ let batch_diff = crate :: migrate:: registry:: diff_registry_reconstruction_report (
151+ & db,
152+ & crate :: migrate:: registry:: RegistryReconstructionReport {
153+ plans : vec ! [ batch_left, batch_right] ,
154+ issues : Vec :: new ( ) ,
155+ } ,
156+ )
157+ . await ;
158+ assert_eq ! ( batch_diff. missing_plans, 0 ) ;
159+ assert ! (
160+ batch_diff
161+ . issues
162+ . iter( )
163+ . any( |issue| issue. contains( "shared-alias" ) ) ,
164+ "{:?}" ,
165+ batch_diff. issues
166+ ) ;
106167 let applied = crate :: migrate:: registry:: apply_registry_reconstruction_report ( & db, & eligible)
107168 . await
108169 . unwrap ( ) ;
0 commit comments