@@ -2361,6 +2361,50 @@ test("serial canonical discovery attributes a failure only to the target that th
23612361 assert . equal ( scenario . resolutions . length , 0 ) ;
23622362} ) ;
23632363
2364+ test ( "serial recovery revalidation attributes a failure only to the target that threw" , async ( ) => {
2365+ const scenario = await automaticReconcileScenario ( {
2366+ rows : [
2367+ row ( "first" , "publication:first" , 1 , "retry_exhausted" , true , "eligible" , "openclaw/repo#1" ) ,
2368+ row (
2369+ "second" ,
2370+ "publication:second" ,
2371+ 2 ,
2372+ "retry_exhausted" ,
2373+ true ,
2374+ "eligible" ,
2375+ "openclaw/repo#2" ,
2376+ ) ,
2377+ row ( "third" , "publication:third" , 3 , "retry_exhausted" , true , "eligible" , "openclaw/repo#3" ) ,
2378+ ] ,
2379+ failTargetOnInspection : 1 ,
2380+ failedStatus : 403 ,
2381+ } ) ;
2382+
2383+ assert . equal ( scenario . first . code , 0 , scenario . first . stderr ) ;
2384+ const summary = JSON . parse ( scenario . first . stdout ) ;
2385+ assert . deepEqual ( summary . skip_reasons , { http_403 : 1 , not_inspected_abort : 2 } ) ;
2386+ assert . deepEqual ( summary . skip_samples , [
2387+ {
2388+ target : "openclaw/repo#1" ,
2389+ reason : "live target check failed for openclaw/repo#1 (403)" ,
2390+ } ,
2391+ {
2392+ target : "openclaw/repo#2" ,
2393+ reason :
2394+ "canonical target was not inspected because canonical discovery aborted after another target inspection failed" ,
2395+ } ,
2396+ {
2397+ target : "openclaw/repo#3" ,
2398+ reason :
2399+ "canonical target was not inspected because canonical discovery aborted after another target inspection failed" ,
2400+ } ,
2401+ ] ) ;
2402+ assert . equal ( summary . skipped_targets , 3 ) ;
2403+ assert . equal ( scenario . restRequests , 4 ) ;
2404+ assert . equal ( scenario . recoveries . length , 0 ) ;
2405+ assert . equal ( scenario . resolutions . length , 0 ) ;
2406+ } ) ;
2407+
23642408test ( "automatic recovery refuses a pull request whose current head has advanced" , async ( ) => {
23652409 const item = row (
23662410 "stale" ,
@@ -2419,6 +2463,7 @@ async function automaticReconcileScenario(options) {
24192463 let inventoryRequests = 0 ;
24202464 let graphqlRequests = 0 ;
24212465 let restRequests = 0 ;
2466+ const restRequestsByNumber = new Map ( ) ;
24222467 let duplicateFailurePending = options . failFirstDuplicateCleanup === true ;
24232468 let duplicateSkipsRemaining =
24242469 options . skipDuplicateCleanupCount ?? Number ( options . skipFirstDuplicateCleanup === true ) ;
@@ -2486,6 +2531,7 @@ async function automaticReconcileScenario(options) {
24862531 if ( request . url ?. startsWith ( "/repos/" ) ) {
24872532 restRequests += 1 ;
24882533 const number = Number ( request . url . split ( "/" ) . at ( - 1 ) ) ;
2534+ restRequestsByNumber . set ( number , ( restRequestsByNumber . get ( number ) || 0 ) + 1 ) ;
24892535 if ( request . url . includes ( "/pulls/" ) ) {
24902536 response . writeHead ( 200 , { "content-type" : "application/json" } ) ;
24912537 response . end (
@@ -2504,6 +2550,7 @@ async function automaticReconcileScenario(options) {
25042550 if (
25052551 ( options . failedRepository &&
25062552 request . url . includes ( `/${ options . failedRepository } /issues/` ) ) ||
2553+ ( options . failTargetOnInspection === number && restRequestsByNumber . get ( number ) >= 2 ) ||
25072554 ( options . failTargetAfterCleanup === number && resolutions . length >= 2 )
25082555 ) {
25092556 response . writeHead ( options . failedStatus ?? 503 , { "content-type" : "application/json" } ) ;
0 commit comments