@@ -63,6 +63,19 @@ def _initial_cycle_boundary(review_data: dict) -> tuple[str | None, str | None]:
6363 return None , None
6464
6565
66+ def _alternate_current_head_cycle_boundary (review_data : dict , issue_snapshot : dict | None ) -> str | None :
67+ if not isinstance (issue_snapshot , dict ) or not isinstance (issue_snapshot .get ("pull_request" ), dict ):
68+ return None
69+ if review_data .get ("assignment_method" ) != "claim" :
70+ return None
71+ for field in ("active_cycle_started_at" , "cycle_started_at" ):
72+ value = review_data .get (field )
73+ if isinstance (value , str ) and value :
74+ return None
75+ created_at = issue_snapshot .get ("created_at" )
76+ return created_at if isinstance (created_at , str ) and created_at else None
77+
78+
6679def _scope_basis_and_anchor (review_data : dict , contributor_handoff : dict | None ) -> tuple [str | None , str | None ]:
6780 if isinstance (contributor_handoff , dict ):
6881 semantic_key = str (contributor_handoff .get ("semantic_key" , "" ))
@@ -97,8 +110,11 @@ def _current_scope_fields(
97110 contributor_handoff : dict | None ,
98111 * ,
99112 alternate_current_head_approval : bool = False ,
113+ alternate_current_head_cycle_boundary : str | None = None ,
100114) -> dict [str , object ]:
101115 _ , cycle_boundary = _initial_cycle_boundary (review_data )
116+ if alternate_current_head_approval and alternate_current_head_cycle_boundary :
117+ cycle_boundary = alternate_current_head_cycle_boundary
102118 if alternate_current_head_approval :
103119 anchor_timestamp = None
104120 basis = "alternate_current_head_approval"
@@ -202,6 +218,7 @@ def derive_reviewer_response_state(
202218 approval_result : dict [str , object ] | None = None ,
203219 current_head_approval_authors : tuple [str , ...] | None = None ,
204220 stored_reviewer_review : dict | None | object = _UNSET ,
221+ alternate_current_head_cycle_boundary : str | None = None ,
205222) -> dict [str , object ]:
206223 current_reviewer = review_data .get ("current_reviewer" )
207224 if not isinstance (current_reviewer , str ) or not current_reviewer .strip ():
@@ -379,6 +396,7 @@ def derive_reviewer_response_state(
379396 current_head ,
380397 contributor_handoff ,
381398 alternate_current_head_approval = True ,
399+ alternate_current_head_cycle_boundary = alternate_current_head_cycle_boundary ,
382400 ),
383401 anchor_timestamp = latest_reviewer_response .get ("timestamp" ) if isinstance (latest_reviewer_response , dict ) else None ,
384402 current_head_sha = current_head ,
@@ -573,6 +591,7 @@ def compute_reviewer_response_state(
573591 reviews ,
574592 parse_timestamp = bot .parse_iso8601_timestamp ,
575593 )
594+ alternate_current_head_cycle_boundary = _alternate_current_head_cycle_boundary (review_data , issue_snapshot )
576595
577596 return derive_reviewer_response_state (
578597 review_data ,
@@ -585,4 +604,5 @@ def compute_reviewer_response_state(
585604 approval_result = approval_result ,
586605 current_head_approval_authors = approval_authors ,
587606 stored_reviewer_review = stored_reviewer_review ,
607+ alternate_current_head_cycle_boundary = alternate_current_head_cycle_boundary ,
588608 )
0 commit comments