@@ -2093,6 +2093,10 @@ function executeCommand(command: LooseRecord) {
20932093 ) ;
20942094 const dispatchDecision = reviewDispatchDecisionForCommand ( command ) ;
20952095 if ( dispatchDecision . action !== "dispatch" ) {
2096+ const verdictRouter =
2097+ dispatchDecision . action === "reuse_completed_review"
2098+ ? dispatchCompletedReviewVerdict ( command , dispatchDecision )
2099+ : null ;
20962100 const dispatchStatus = markCoordinatedReviewDispatchActions ( {
20972101 command,
20982102 job,
@@ -2106,6 +2110,7 @@ function executeCommand(command: LooseRecord) {
21062110 status : dispatchStatus ,
21072111 coordination_action : dispatchDecision . action ,
21082112 reason : dispatchDecision . reason ,
2113+ ...( verdictRouter ? { verdict_router : verdictRouter } : { } ) ,
21092114 } ,
21102115 } ;
21112116 }
@@ -2991,6 +2996,7 @@ function reviewDispatchDecisionForCommand(
29912996 headAfter : headBefore ,
29922997 activeLeaseExpiresAt : null ,
29932998 completedReviewAt : null ,
2999+ completedReviewCommentId : null ,
29943000 } ) ;
29953001 }
29963002 const comments = ghPaged < JsonValue > (
@@ -3026,6 +3032,7 @@ function reviewDispatchDecisionForCommand(
30263032 completedReview ?. publishedAt ??
30273033 completedReview ?. reviewedAt ??
30283034 ( completedReview ? "recently" : null ) ,
3035+ completedReviewCommentId : completedReview ?. commentId ?? null ,
30293036 } ) ;
30303037 } catch ( error ) {
30313038 return {
@@ -3036,6 +3043,7 @@ function reviewDispatchDecisionForCommand(
30363043}
30373044
30383045function reviewDispatchActionStatus ( decision : ReviewDispatchCoordinationDecision ) {
3046+ if ( decision . action === "reuse_completed_review" ) return "executed" ;
30393047 return [ "wait_for_active_review" , "retry" ] . includes ( decision . action ) ? "waiting" : "skipped" ;
30403048}
30413049
@@ -3333,6 +3341,53 @@ function dispatchClawSweeperReview(command: LooseRecord): LooseRecord {
33333341 } ;
33343342}
33353343
3344+ function dispatchCompletedReviewVerdict (
3345+ command : LooseRecord ,
3346+ decision : Extract < ReviewDispatchCoordinationDecision , { action : "reuse_completed_review" } > ,
3347+ ) {
3348+ const attemptId = `completed-review-${ command . comment_id ?? "sweep" } -${ decision . commentId } ` ;
3349+ const payload = JSON . stringify ( {
3350+ event_type : "clawsweeper_comment" ,
3351+ client_payload : {
3352+ target_repo : command . repo ,
3353+ ...( command . target_branch ? { target_branch : String ( command . target_branch ) } : { } ) ,
3354+ item_number : String ( command . issue_number ) ,
3355+ comment_id : String ( decision . commentId ) ,
3356+ max_comments : "1" ,
3357+ force_reprocess : "true" ,
3358+ attempt_id : attemptId ,
3359+ source_event : "comment_router" ,
3360+ source_action : "reuse_completed_review" ,
3361+ } ,
3362+ } ) ;
3363+ const result = runGitHubSpawnMutation (
3364+ command ,
3365+ "review_verdict_dispatch" ,
3366+ {
3367+ repository : reviewRepo ,
3368+ workflow : "repair-comment-router.yml" ,
3369+ event : "repository_dispatch" ,
3370+ commentId : decision . commentId ,
3371+ attemptId,
3372+ } ,
3373+ [ "api" , `repos/${ reviewRepo } /dispatches` , "--method" , "POST" , "--input" , "-" ] ,
3374+ { env : dispatchTokenEnv ( ) , input : payload } ,
3375+ ) ;
3376+ if ( result . status !== 0 ) {
3377+ throw new Error (
3378+ `failed to requeue completed ClawSweeper verdict for #${ command . issue_number } : ${ stripAnsi ( result . stderr || result . stdout ) . trim ( ) } ` ,
3379+ ) ;
3380+ }
3381+ return {
3382+ workflow : "repair-comment-router.yml" ,
3383+ event : "repository_dispatch" ,
3384+ repo : reviewRepo ,
3385+ item_number : command . issue_number ,
3386+ comment_id : decision . commentId ,
3387+ attempt_id : attemptId ,
3388+ } ;
3389+ }
3390+
33363391function dispatchClawSweeperAssist ( command : LooseRecord ) : LooseRecord {
33373392 let dispatchKey = dispatchReceiptKey ( command ) ;
33383393 const workflowName = "assist.yml" ;
0 commit comments