@@ -666,18 +666,26 @@ try {
666666 } ) ;
667667 throw error ;
668668 }
669+ const unresolvedRebaseConflicts = needsHumanRebaseConflictReason ( error ) ;
669670 outcome = {
670- action : "execute_fix" ,
671+ action : unresolvedRebaseConflicts ? "needs_human" : "execute_fix" ,
671672 status : "blocked" ,
672673 repair_strategy : fixArtifact . repair_strategy ,
673674 reason : error . message ,
674- ...( isRetryableCodexFailure ( error ) ? { requeue_required : true } : { } ) ,
675+ ...( unresolvedRebaseConflicts
676+ ? { needs_human : [ unresolvedRebaseConflicts ] }
677+ : isRetryableCodexFailure ( error )
678+ ? { requeue_required : true }
679+ : { } ) ,
675680 } ;
676681 }
677682}
678683
679- report . status = outcome . status ;
684+ report . status = outcome . action === "needs_human" ? "needs_human" : outcome . status ;
680685if ( outcome . reason && ! report . reason ) report . reason = outcome . reason ;
686+ if ( Array . isArray ( outcome . needs_human ) && outcome . needs_human . length > 0 ) {
687+ report . needs_human = uniqueStrings ( [ ...( report . needs_human ?? [ ] ) , ...outcome . needs_human ] ) ;
688+ }
681689report . actions . push ( outcome ) ;
682690writeReport ( report , resultPath ) ;
683691if ( outcome . requeue_required === true ) process . exitCode = 1 ;
@@ -689,6 +697,11 @@ updateAutomergeProgressStatus({
689697 headSha : outcome . commit ?? null ,
690698} ) ;
691699
700+ function needsHumanRebaseConflictReason ( error : JsonValue ) {
701+ const message = String ( error ?. message ?? error ?? "" ) ;
702+ return / r e b a s e c o n f l i c t s r e m a i n u n r e s o l v e d : / i. test ( message ) ? message : null ;
703+ }
704+
692705function isRetryableCodexFailure ( ...values : JsonValue [ ] ) {
693706 const messages = values . flat ( ) . map ( String ) ;
694707 const message = messages . join ( "\n" ) ;
@@ -1982,7 +1995,10 @@ function editValidatePrepareMerge({
19821995 repositoryContext,
19831996 reconcileWithBase,
19841997 sourceHead,
1985- rebaseResult,
1998+ rebaseResult :
1999+ rebaseResult ?. status === "conflicts"
2000+ ? { ...rebaseResult , unmerged_paths : unmergedPaths ( targetDir ) }
2001+ : rebaseResult ,
19862002 maxEditAttempts,
19872003 validationCommands : validationPreflight . resolved_commands ?? [ ] ,
19882004 isAutomergeRepair : isAutomergeRepairJob ( ) ,
@@ -2090,6 +2106,30 @@ function editValidatePrepareMerge({
20902106 headSha : currentHead ( targetDir ) ,
20912107 } ) ;
20922108
2109+ if ( rebaseResult ?. status === "conflicts" ) {
2110+ const remainingConflicts = unmergedPaths ( targetDir ) ;
2111+ if ( remainingConflicts . length > 0 ) {
2112+ previousSummary =
2113+ readTextIfExists ( summaryPath ) . trim ( ) ||
2114+ `Rebase conflicts remain unresolved after edit attempt ${ attempt } : ${ remainingConflicts . join ( ", " ) } ` ;
2115+ logProgress ( "rebase conflicts remain after Codex edit pass" , {
2116+ mode,
2117+ attempt,
2118+ max_attempts : maxEditAttempts ,
2119+ unresolved : remainingConflicts ,
2120+ } ) ;
2121+ updateAutomergeProgressStatus ( {
2122+ id : `codex-edit-${ mode } -${ attempt } ` ,
2123+ label : `Codex edit ${ attempt } ` ,
2124+ status : attempt < maxEditAttempts ? "retrying" : "blocked" ,
2125+ details : `unresolved rebase conflicts: ${ remainingConflicts . join ( ", " ) } ` ,
2126+ headSha : currentHead ( targetDir ) ,
2127+ } ) ;
2128+ if ( attempt < maxEditAttempts ) continue ;
2129+ throw new Error ( `rebase conflicts remain unresolved: ${ remainingConflicts . join ( ", " ) } ` ) ;
2130+ }
2131+ }
2132+
20932133 const hasWorkingTreeChanges = Boolean (
20942134 run ( "git" , [ "status" , "--porcelain" ] , { cwd : targetDir } ) . trim ( ) ,
20952135 ) ;
0 commit comments