@@ -14,10 +14,13 @@ mod tests {
1414 use lore_revision:: commit;
1515 use lore_revision:: commit:: CommitOptions ;
1616 use lore_revision:: file;
17+ use lore_revision:: instance;
18+ use lore_revision:: interface:: ExecutionContext ;
1719 use lore_revision:: interface:: LoreArray ;
1820 use lore_revision:: interface:: LoreString ;
1921 use lore_revision:: lore:: RepositoryId ;
2022 use lore_revision:: node:: NodeFlags ;
23+ use lore_revision:: relay:: EventDispatcher ;
2124 use lore_revision:: repository;
2225 use lore_revision:: revision:: sync;
2326 use lore_revision:: revision:: sync:: SyncOptions ;
@@ -134,7 +137,11 @@ mod tests {
134137 . await
135138 . expect ( "Failed to commit revision" ) ;
136139
137- // Sync back to first revision
140+ let ( _current_revision, branch_id) = instance:: load_current_anchor ( & repository)
141+ . await
142+ . expect ( "Failed to load current anchor" ) ;
143+
144+ // Sync back to first revision (local search keeps branch latest unchanged)
138145 Box :: pin ( sync:: sync (
139146 repository. clone ( ) ,
140147 & write_token,
@@ -147,6 +154,14 @@ mod tests {
147154 . await
148155 . expect ( "Failed to sync back to first revision" ) ;
149156
157+ let latest_after_back = branch:: load_latest ( repository. clone ( ) , branch_id)
158+ . await
159+ . expect ( "Failed to load branch latest after sync back" ) ;
160+ assert_eq ! (
161+ latest_after_back, second_signature,
162+ "Local explicit sync should not move branch latest backwards"
163+ ) ;
164+
150165 // Verify file added in first revision is still there
151166 assert ! (
152167 fs:: metadata( file_path. as_path( ) )
@@ -159,18 +174,48 @@ mod tests {
159174 "File added in second revision was not removed as expected after sync back" ,
160175 ) ;
161176
162- // Sync forward to second revision
163- Box :: pin ( sync :: sync (
177+ // Simulate stale branch latest after an explicit remote sync bug
178+ branch :: store_latest (
164179 repository. clone ( ) ,
165- & write_token,
166- SyncOptions {
167- revision : Some ( second_signature. to_string ( ) ) ,
168- filter_mode : lore_revision:: filter:: FilterMode :: Full ,
180+ branch_id,
181+ first_signature,
182+ branch:: BranchLatestStatus :: Convergent ,
183+ )
184+ . await
185+ . expect ( "Failed to seed stale branch latest" ) ;
186+
187+ let remote_execution = std:: sync:: Arc :: new ( ExecutionContext :: new_client (
188+ LoreGlobalArgs {
189+ remote : 1 ,
169190 ..Default :: default ( )
170191 } ,
171- ) )
172- . await
173- . expect ( "Failed to sync forward to second revision" ) ;
192+ EventDispatcher :: no_dispatch ( ) ,
193+ ) ) ;
194+
195+ // Sync forward to second revision with explicit remote search location
196+ LORE_CONTEXT
197+ . scope (
198+ remote_execution,
199+ Box :: pin ( sync:: sync (
200+ repository. clone ( ) ,
201+ & write_token,
202+ SyncOptions {
203+ revision : Some ( second_signature. to_string ( ) ) ,
204+ filter_mode : lore_revision:: filter:: FilterMode :: Full ,
205+ ..Default :: default ( )
206+ } ,
207+ ) ) ,
208+ )
209+ . await
210+ . expect ( "Failed to sync forward to second revision" ) ;
211+
212+ let latest_after_forward = branch:: load_latest ( repository. clone ( ) , branch_id)
213+ . await
214+ . expect ( "Failed to load branch latest after sync forward" ) ;
215+ assert_eq ! (
216+ latest_after_forward, second_signature,
217+ "Explicit remote sync should update branch latest pointer"
218+ ) ;
174219
175220 // Verify file added in first revision is still there
176221 assert ! (
0 commit comments