From 15d0b103dc84f5474599baea9bcb6bb1c875564a Mon Sep 17 00:00:00 2001 From: David Schachter Date: Mon, 16 Nov 2026 23:23:34 -0800 Subject: [PATCH 1/4] ADFA-7182: Strip the Rovo Dev block from the current PR description The workflow wrote back the description from the event payload, or from the sweep's earlier list, with the block removed. An edit made in between was undone: on PR #2263 a description update made seconds after a push was reverted this way. stripBody now reads the description by PR number just before writing it. GitHub has no conditional update, so a sub-second window between the read and the write remains. Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_01Vh2DAZjbyUcUDporb95N9T --- .github/workflows/strip-rovo-nag.yml | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/.github/workflows/strip-rovo-nag.yml b/.github/workflows/strip-rovo-nag.yml index 484cc24698..e405075935 100644 --- a/.github/workflows/strip-rovo-nag.yml +++ b/.github/workflows/strip-rovo-nag.yml @@ -58,7 +58,13 @@ jobs: const isRovoAd = (comment) => isAtlassianBot(comment.user) && adPhrases.some((re) => re.test(comment.body ?? '')); - async function stripBody(pr) { + // Reads the description now, not from the event payload or an earlier + // list: writing back an older copy would undo any edit made since, + // such as one made seconds after the push that made Atlassian append + // the block. GitHub has no conditional update, so a sub-second window + // between this read and the write remains. + async function stripBody(number) { + const { data: pr } = await github.rest.pulls.get({ owner, repo, pull_number: number }); const body = pr.body ?? ''; const cleaned = body.replace(marked, '').replace(bare, '').trimEnd(); if (cleaned === body.trimEnd()) { @@ -66,8 +72,8 @@ jobs: } // This update runs as GITHUB_TOKEN, which does not trigger further // workflow runs, so stripping the block cannot loop back on itself. - await github.rest.pulls.update({ owner, repo, pull_number: pr.number, body: cleaned }); - core.info(`Stripped the Rovo Dev block from the body of PR #${pr.number}.`); + await github.rest.pulls.update({ owner, repo, pull_number: number, body: cleaned }); + core.info(`Stripped the Rovo Dev block from the body of PR #${number}.`); return true; } @@ -92,7 +98,7 @@ jobs: if (context.eventName === 'pull_request_target') { const pr = context.payload.pull_request; - if (!(await stripBody(pr))) { + if (!(await stripBody(pr.number))) { core.info( `No Rovo Dev block in PR #${pr.number} (edited by ${context.payload.sender.login}); nothing to strip.` ); @@ -122,7 +128,7 @@ jobs: let bodies = 0; let comments = 0; for (const pr of pulls) { - if (await stripBody(pr)) { + if (await stripBody(pr.number)) { bodies += 1; } comments += await deleteAdComments(pr.number); From 59d4317ca6b28b7c1b1dcac836e6363444f9f1c4 Mon Sep 17 00:00:00 2001 From: David Schachter Date: Mon, 16 Nov 2026 23:45:24 -0800 Subject: [PATCH 2/4] ADFA-7182: Bound the strip workflow: linear-time patterns, timeout, retries From an independent review of this PR. - Both patterns started a match at every position inside a run of blank lines, and the fallback matched that whitespace in two places, so a description of thousands of blank lines backtracked for minutes (4,000 lines: about 7 s; 65,000: past the job limit). Anyone who can open a PR could stall a run, or the sweep, that way. Matches now start only where a run of whitespace starts, and each pattern matches it in one place. Both block forms are still stripped. - The job stops after 5 minutes; a run is a few API calls. - API calls retry 3 times, so one failed call no longer stops the sweep partway through. Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_01Vh2DAZjbyUcUDporb95N9T --- .github/workflows/strip-rovo-nag.yml | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/.github/workflows/strip-rovo-nag.yml b/.github/workflows/strip-rovo-nag.yml index e405075935..4cad45efef 100644 --- a/.github/workflows/strip-rovo-nag.yml +++ b/.github/workflows/strip-rovo-nag.yml @@ -32,20 +32,27 @@ jobs: github.event.comment.user.login == 'atlassian[bot]' && contains(github.event.comment.body, 'Rovo Dev code review')) runs-on: ubuntu-latest + # Each run is a few API calls; anything longer is stuck. + timeout-minutes: 5 steps: - name: Strip the Rovo Dev block and delete the Rovo Dev comment uses: actions/github-script@f28e40c7f34bde8b3046d885e986cb6290c5673b # v7.1.0 with: + # One failed call would otherwise stop the sweep partway through. + retries: 3 script: | const { owner, repo } = context.repo; // Atlassian wraps the description block in HTML comment markers. // Anchoring on those catches every wording of the message, not just // "not activated", and swallows the horizontal rule tucked inside. - const marked = /\n*[\s\S]*?[ \t]*/gi; + // Both patterns start only where a run of whitespace starts, and match + // whitespace in one place: a description with thousands of blank lines + // otherwise backtracks for minutes to hours. + const marked = /(?[\s\S]*?[ \t]*/gi; // Fallback for the day Atlassian drops the markers. - const bare = /\n*(?:-{3,}[ \t]*\n)?[ \t]*(?:\*\*|)?\s*Rovo Dev code review:[\s\S]*?Atlassian organization admin needs to activate Rovo Dev\.[ \t]*/gi; + const bare = /(?)\s*)?Rovo Dev code review:[\s\S]*?Atlassian organization admin needs to activate Rovo Dev\.[ \t]*/gi; // Deliberately narrow: a real Rovo Dev code review would also come // from atlassian[bot], and deleting one of those would lose content. From 18c1017e2936055c885840489e56497209e23225 Mon Sep 17 00:00:00 2001 From: David Schachter Date: Mon, 16 Nov 2026 23:58:23 -0800 Subject: [PATCH 3/4] ADFA-7182: Give the sweep 15 minutes; never retry the description write From CodeRabbit. - A 5-minute limit could stop the manual sweep partway through a long list of open PRs. The limit is now 15 minutes: the last sweep took 19 s, and a run near the limit is stuck. - A retried pulls.update resent a description computed before its backoff of seconds, undoing any edit made meanwhile. That one call now has retries: 0; a later run strips the block instead. Reads and comment calls still retry. Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_01Vh2DAZjbyUcUDporb95N9T --- .github/workflows/strip-rovo-nag.yml | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/.github/workflows/strip-rovo-nag.yml b/.github/workflows/strip-rovo-nag.yml index 4cad45efef..4c9f7964f1 100644 --- a/.github/workflows/strip-rovo-nag.yml +++ b/.github/workflows/strip-rovo-nag.yml @@ -32,8 +32,9 @@ jobs: github.event.comment.user.login == 'atlassian[bot]' && contains(github.event.comment.body, 'Rovo Dev code review')) runs-on: ubuntu-latest - # Each run is a few API calls; anything longer is stuck. - timeout-minutes: 5 + # An event run is a few API calls and the sweep a few per open PR (19 s for + # all of them in August), so a run near this limit is stuck. + timeout-minutes: 15 steps: - name: Strip the Rovo Dev block and delete the Rovo Dev comment uses: actions/github-script@f28e40c7f34bde8b3046d885e986cb6290c5673b # v7.1.0 @@ -79,7 +80,9 @@ jobs: } // This update runs as GITHUB_TOKEN, which does not trigger further // workflow runs, so stripping the block cannot loop back on itself. - await github.rest.pulls.update({ owner, repo, pull_number: number, body: cleaned }); + // Not retried: a retry resends this body after a backoff of seconds, + // undoing any edit made meanwhile. A later run strips the block instead. + await github.rest.pulls.update({ owner, repo, pull_number: number, body: cleaned, request: { retries: 0 } }); core.info(`Stripped the Rovo Dev block from the body of PR #${number}.`); return true; } From b30f67f2e90059bc1db7dbdc0a624818ab9629dd Mon Sep 17 00:00:00 2001 From: David Schachter Date: Tue, 17 Nov 2026 08:18:24 -0800 Subject: [PATCH 4/4] ADFA-7182: Retry a failed description write with a fresh read; sweep past failures From CodeRabbit and the review by itsaky-adfa. Since the write was no longer retried, one failed write ended the run: a sweep skipped every PR after it, and the comments claimed a later run would recover, though nothing schedules one. - A failed write is retried up to twice, each time after reading the description again, so a retry never resends an older copy. Statuses the client also does not retry (400, 401, 403, 404, 422) fail at once. - The sweep logs a PR it cannot clean, goes on with the rest, and fails the step at the end. - The comments now say what happens. Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_01Vh2DAZjbyUcUDporb95N9T --- .github/workflows/strip-rovo-nag.yml | 61 ++++++++++++++++++++-------- 1 file changed, 44 insertions(+), 17 deletions(-) diff --git a/.github/workflows/strip-rovo-nag.yml b/.github/workflows/strip-rovo-nag.yml index 4c9f7964f1..d0556e33b4 100644 --- a/.github/workflows/strip-rovo-nag.yml +++ b/.github/workflows/strip-rovo-nag.yml @@ -39,7 +39,8 @@ jobs: - name: Strip the Rovo Dev block and delete the Rovo Dev comment uses: actions/github-script@f28e40c7f34bde8b3046d885e986cb6290c5673b # v7.1.0 with: - # One failed call would otherwise stop the sweep partway through. + # Reads and comment calls retry as they are. The description write retries + # with a fresh read instead: see stripBody. retries: 3 script: | const { owner, repo } = context.repo; @@ -66,25 +67,40 @@ jobs: const isRovoAd = (comment) => isAtlassianBot(comment.user) && adPhrases.some((re) => re.test(comment.body ?? '')); + // The client's own default: these mean the request itself is wrong. + const notRetried = [400, 401, 403, 404, 422]; + const writeAttempts = 3; + // Reads the description now, not from the event payload or an earlier // list: writing back an older copy would undo any edit made since, // such as one made seconds after the push that made Atlassian append // the block. GitHub has no conditional update, so a sub-second window // between this read and the write remains. async function stripBody(number) { - const { data: pr } = await github.rest.pulls.get({ owner, repo, pull_number: number }); - const body = pr.body ?? ''; - const cleaned = body.replace(marked, '').replace(bare, '').trimEnd(); - if (cleaned === body.trimEnd()) { - return false; + for (let attempt = 1; ; attempt++) { + const { data: pr } = await github.rest.pulls.get({ owner, repo, pull_number: number }); + const body = pr.body ?? ''; + const cleaned = body.replace(marked, '').replace(bare, '').trimEnd(); + if (cleaned === body.trimEnd()) { + return false; + } + try { + // This update runs as GITHUB_TOKEN, which does not trigger further + // workflow runs, so stripping the block cannot loop back on itself. + // The client doesn't retry it: that would resend this body after a + // backoff of seconds, undoing any edit made meanwhile. The loop + // retries it after reading the description again. + await github.rest.pulls.update({ owner, repo, pull_number: number, body: cleaned, request: { retries: 0 } }); + core.info(`Stripped the Rovo Dev block from the body of PR #${number}.`); + return true; + } catch (error) { + if (attempt >= writeAttempts || notRetried.includes(error.status)) { + throw error; + } + core.warning(`Writing the description of PR #${number} failed (${error.status ?? error.message}); reading it again.`); + await new Promise((resolve) => setTimeout(resolve, 1000 * attempt * attempt)); + } } - // This update runs as GITHUB_TOKEN, which does not trigger further - // workflow runs, so stripping the block cannot loop back on itself. - // Not retried: a retry resends this body after a backoff of seconds, - // undoing any edit made meanwhile. A later run strips the block instead. - await github.rest.pulls.update({ owner, repo, pull_number: number, body: cleaned, request: { retries: 0 } }); - core.info(`Stripped the Rovo Dev block from the body of PR #${number}.`); - return true; } async function deleteComment(comment, number) { @@ -137,12 +153,23 @@ jobs: }); let bodies = 0; let comments = 0; + let failed = 0; + // One pull request that can't be cleaned doesn't stop the rest; the run + // fails at the end so the failure is still seen. for (const pr of pulls) { - if (await stripBody(pr.number)) { - bodies += 1; + try { + if (await stripBody(pr.number)) { + bodies += 1; + } + comments += await deleteAdComments(pr.number); + } catch (error) { + failed += 1; + core.error(`Could not clean PR #${pr.number}: ${error.message}`); } - comments += await deleteAdComments(pr.number); } core.info( - `Swept ${pulls.length} open pull requests: stripped ${bodies} bodies, deleted ${comments} comments.` + `Swept ${pulls.length} open pull requests: stripped ${bodies} bodies, deleted ${comments} comments, ${failed} failed.` ); + if (failed > 0) { + core.setFailed(`${failed} of ${pulls.length} pull requests could not be cleaned; see the errors above.`); + }