@@ -249,10 +249,19 @@ function extractReviewReadiness(body) {
249249 }
250250 const start = body . indexOf ( REVIEW_READINESS_START ) ;
251251 const end = body . indexOf ( REVIEW_READINESS_END ) ;
252+ const startCount = body . split ( REVIEW_READINESS_START ) . length - 1 ;
253+ const endCount = body . split ( REVIEW_READINESS_END ) . length - 1 ;
252254 // Any marker presence counts as present: an author-edited section that is
253255 // inverted or partial must never trigger another append, or every `edited`
254- // event would stack a second checklist (and a second body write).
255- if ( start === - 1 || end === - 1 || end <= start ) {
256+ // event would stack a second checklist (and a second body write). Exactly
257+ // one marker pair is required: duplicates are malformed, not complete.
258+ if (
259+ start === - 1 ||
260+ end === - 1 ||
261+ end <= start ||
262+ startCount !== 1 ||
263+ endCount !== 1
264+ ) {
256265 return {
257266 present : start !== - 1 || end !== - 1 ,
258267 complete : false ,
@@ -298,6 +307,14 @@ function stripReviewReadinessSection(body) {
298307 const start = body . indexOf ( REVIEW_READINESS_START ) ;
299308 const end = body . indexOf ( REVIEW_READINESS_END ) ;
300309 if ( start === - 1 || end === - 1 || end <= start ) return body ;
310+ // Malformed marker sets (duplicates, extra pairs) stay untouched: removing
311+ // only one section would leave the body half-cleaned and still marked.
312+ if (
313+ body . split ( REVIEW_READINESS_START ) . length - 1 !== 1 ||
314+ body . split ( REVIEW_READINESS_END ) . length - 1 !== 1
315+ ) {
316+ return body ;
317+ }
301318 const stripped =
302319 body . slice ( 0 , start ) + body . slice ( end + REVIEW_READINESS_END . length ) ;
303320 return stripped . replace ( / \n { 3 , } / g, "\n\n" ) . trimEnd ( ) ;
0 commit comments