diff --git a/.github/workflows/cursor-automation.yml b/.github/workflows/cursor-automation.yml index 3d7dfed4b..31ef5a731 100644 --- a/.github/workflows/cursor-automation.yml +++ b/.github/workflows/cursor-automation.yml @@ -394,20 +394,12 @@ jobs: core.warning(`PR #${pullNumber} is not eligible for source cleanup; skipping.`); return; } - const issueNumber = auto.extractSourceIssueNumber(pull); + const issueNumbers = auto.extractSourceIssueNumbers(pull); const expectedIssueNumber = Number(process.env.SOURCE_ISSUE_NUMBER); - if (!issueNumber || issueNumber !== expectedIssueNumber) { + if (!issueNumbers.includes(expectedIssueNumber)) { core.warning(`PR #${pullNumber} source issue changed while queued; skipping cleanup.`); return; } - const { data: sourceIssue } = await github.rest.issues.get({ - ...context.repo, - issue_number: issueNumber, - }); - if (pull.merged && sourceIssue.state !== 'closed') { - core.warning(`Merged PR #${pullNumber} does not currently close issue #${issueNumber}; skipping cleanup.`); - return; - } const removeLabel = async (issue_number, name) => { try { await github.rest.issues.removeLabel({ @@ -419,15 +411,29 @@ jobs: if (error.status !== 404) throw error; } }; - for (const name of ['ready-for-agent', 'needs-info', 'ready-for-human']) { - await removeLabel(issueNumber, name); - } - if (!pull.merged) { - await github.rest.issues.addLabels({ + for (const issueNumber of issueNumbers) { + const { data: sourceIssue } = await github.rest.issues.get({ ...context.repo, issue_number: issueNumber, - labels: ['ready-for-human'], }); + if (sourceIssue.pull_request) { + core.warning(`#${issueNumber} is a pull request, not a source issue; skipping cleanup.`); + continue; + } + if (pull.merged && sourceIssue.state !== 'closed') { + core.warning(`Merged PR #${pullNumber} does not currently close issue #${issueNumber}; skipping cleanup.`); + continue; + } + for (const name of ['ready-for-agent', 'needs-info', 'ready-for-human']) { + await removeLabel(issueNumber, name); + } + if (!pull.merged) { + await github.rest.issues.addLabels({ + ...context.repo, + issue_number: issueNumber, + labels: ['ready-for-human'], + }); + } } for (const name of ['automation:codex-loop', 'ready-for-human']) { await removeLabel(pullNumber, name); @@ -491,6 +497,7 @@ jobs: script: | const auto = require(`${process.env.GITHUB_WORKSPACE}/scripts/cursor-automation.cjs`); const recoveryVersion = 'protected-tests-and-media-v1'; + const auditedIssueNumbers = new Set([2679, 2697, 2705, 2708, 2709]); const repository = `${context.repo.owner}/${context.repo.repo}`; const issues = await github.paginate( github.rest.search.issuesAndPullRequests, @@ -509,6 +516,7 @@ jobs: }); let dispatched = 0; for (const issue of issues) { + if (!auditedIssueNumbers.has(Number(issue.number))) continue; const comments = await github.paginate( github.rest.issues.listComments, { ...context.repo, issue_number: issue.number, per_page: 100 }, @@ -517,6 +525,7 @@ jobs: trustedActors: process.env.ISSUE_BOT_LOGINS, recoveryVersion, notBefore: '2026-07-31T12:54:37Z', + notAfter: '2026-08-04T08:27:14Z', })) continue; if (pulls.some((pull) => auto.isTrustedOpenPullForIssue(pull, issue.number, { repository, @@ -1008,6 +1017,15 @@ jobs: ); ' + - name: Validate classification result + id: validate_classification + if: steps.prepare.outputs.should_run == 'true' + run: | + node -e ' + const auto = require(process.env.RUNNER_TEMP + "/cursor-automation.cjs"); + auto.parseClassificationFile(".cursor-runtime/classification.json"); + ' + - name: Apply classification id: apply if: steps.prepare.outputs.should_run == 'true' @@ -1105,9 +1123,11 @@ jobs: ? 'research_failed' : '${{ steps.classify_agent.outcome }}' === 'failure' ? 'classification_failed' - : '${{ steps.apply.outcome }}' === 'failure' - ? 'apply_failed' - : 'processing_failed'; + : '${{ steps.validate_classification.outcome }}' === 'failure' + ? 'classification_failed' + : '${{ steps.apply.outcome }}' === 'failure' + ? 'apply_failed' + : 'processing_failed'; const chinese = /[\u3400-\u9fff]/u.test( `${issue.title || ''}\n${issue.body || ''}`, ); @@ -3027,15 +3047,12 @@ jobs: core.setOutput('exists', existing ? 'true' : 'false'); core.setOutput('url', existing ? existing.html_url : ''); if (existing) { - await github.rest.issues.createComment({ - ...context.repo, - issue_number: Number(process.env.ISSUE_NUMBER), - body: [ - auto.TRIAGE_MARKER, - auto.DISCLAIMER, - '', - `A trusted related pull request is already open: ${existing.html_url}`, - ].join('\n'), + await auto.markNeedsHuman({ + github, + context, + issueNumber: Number(process.env.ISSUE_NUMBER), + message: `A trusted related pull request is already open: ${existing.html_url}`, + dedupeMarker: ``, }); } @@ -3467,7 +3484,60 @@ jobs: name: implement-patch-${{ github.run_id }} path: patch-in + - name: Checkout trusted helper for publish guard + uses: actions/checkout@v7 + with: + ref: ${{ github.event.repository.default_branch }} + persist-credentials: false + path: helpers + + - name: Ensure automation helper present + working-directory: helpers + env: + BOOTSTRAP_SHA: ${{ github.sha }} + run: | + set -euo pipefail + if [[ -f scripts/cursor-automation.cjs ]]; then + cp scripts/cursor-automation.cjs "$RUNNER_TEMP/cursor-automation.cjs" + exit 0 + fi + git fetch --depth=1 origin "${BOOTSTRAP_SHA}" + git show "FETCH_HEAD:scripts/cursor-automation.cjs" > "$RUNNER_TEMP/cursor-automation.cjs" + test -s "$RUNNER_TEMP/cursor-automation.cjs" + + - name: Skip publish if trusted related PR opened during implementation + id: existing + uses: actions/github-script@v9 + with: + github-token: ${{ secrets.TRIAGE_GITHUB_TOKEN || secrets.GITHUB_TOKEN }} + script: | + const auto = require(`${process.env.RUNNER_TEMP}/cursor-automation.cjs`); + const issueNumber = Number(process.env.ISSUE_NUMBER); + const botPull = await auto.findOpenBotPrForIssue({ + github, + context, + issueNumber, + }); + const existing = botPull || await auto.findOpenPullForIssue({ + github, + context, + issueNumber, + includeRelated: true, + }); + core.setOutput('exists', existing ? 'true' : 'false'); + if (existing) { + await auto.markNeedsHuman({ + github, + context, + issueNumber, + message: `A trusted related pull request is already open: ${existing.html_url}`, + dedupeMarker: ``, + }); + core.notice(`Trusted related pull request ${existing.html_url} opened during implementation; skip publishing a duplicate branch.`); + } + - name: Publish branch from fresh runner + if: steps.existing.outputs.exists != 'true' id: publish run: | set -euo pipefail @@ -3510,7 +3580,7 @@ jobs: exit 1 - name: Mark needs human on publish failure - if: failure() && steps.publish.outputs.handoff == 'true' + if: failure() && steps.existing.outputs.exists != 'true' && steps.publish.outputs.handoff == 'true' uses: actions/github-script@v9 env: ISSUE_NUMBER: ${{ needs.implement.outputs.issue_number }} @@ -3538,32 +3608,6 @@ jobs: }); } - - name: Checkout helper for PR body helpers - if: steps.publish.outputs.published == 'true' - uses: actions/checkout@v7 - with: - ref: ${{ github.event.repository.default_branch }} - persist-credentials: false - path: helpers - - - name: Ensure automation helper present - if: steps.publish.outputs.published == 'true' - working-directory: helpers - env: - BOOTSTRAP_SHA: ${{ github.sha }} - EVENT_NAME: ${{ github.event_name }} - HEAD_REPO: '' - BASE_REPO: ${{ github.repository }} - run: | - set -euo pipefail - if [[ -f scripts/cursor-automation.cjs ]]; then - cp scripts/cursor-automation.cjs "$RUNNER_TEMP/cursor-automation.cjs" - exit 0 - fi - git fetch --depth=1 origin "${BOOTSTRAP_SHA}" - git show "FETCH_HEAD:scripts/cursor-automation.cjs" > "$RUNNER_TEMP/cursor-automation.cjs" - test -s "$RUNNER_TEMP/cursor-automation.cjs" - - name: Open draft PR if: steps.publish.outputs.published == 'true' id: openpr @@ -3582,6 +3626,29 @@ jobs: script: | const auto = require(`${process.env.RUNNER_TEMP}/cursor-automation.cjs`); const fs = require('node:fs'); + const issueNumber = Number(process.env.ISSUE_NUMBER); + const botPull = await auto.findOpenBotPrForIssue({ + github, + context, + issueNumber, + }); + const existing = botPull || await auto.findOpenPullForIssue({ + github, + context, + issueNumber, + includeRelated: true, + }); + if (existing) { + await auto.markNeedsHuman({ + github, + context, + issueNumber, + message: `A trusted related pull request is already open: ${existing.html_url}`, + dedupeMarker: ``, + }); + core.notice(`Trusted related pull request ${existing.html_url} opened before PR creation; skip the duplicate.`); + return; + } let statusText = ''; let agentBody = ''; try { diff --git a/scripts/cursor-automation.cjs b/scripts/cursor-automation.cjs index 784d9794c..7007ac522 100644 --- a/scripts/cursor-automation.cjs +++ b/scripts/cursor-automation.cjs @@ -1172,17 +1172,25 @@ function extractIssueCommentWatermark(body) { return String(body || '').match(ISSUE_WATERMARK_RE)?.[1] || ''; } -function extractSourceIssueNumber(pull) { +function extractSourceIssueNumbers(pull) { const body = String(pull?.body || ''); const marker = body.match(SOURCE_ISSUE_RE); - if (marker) return Number(marker[1]); - const closing = body.match( - /(?:^|\W)(?:close[sd]?|fix(?:e[sd])?|resolve[sd]?)\s+#(\d+)\b/i, - ); - if (closing) return Number(closing[1]); + if (marker) return [Number(marker[1])]; + const closing = []; + const closingPattern = + /(?:^|\W)(?:close[sd]?|fix(?:e[sd])?|resolve[sd]?)\s+#(\d+)\b/gi; + for (const match of body.matchAll(closingPattern)) { + const issueNumber = Number(match[1]); + if (Number.isFinite(issueNumber) && issueNumber > 0) closing.push(issueNumber); + } + if (closing.length) return [...new Set(closing)]; const headRef = String(pull?.head?.ref || pull?.headRefName || ''); const branch = headRef.match(/^cursor\/issue-(\d+)-/i); - return branch ? Number(branch[1]) : null; + return branch ? [Number(branch[1])] : []; +} + +function extractSourceIssueNumber(pull) { + return extractSourceIssueNumbers(pull)[0] || null; } function extractProcessedIssueFollowupIds( @@ -1468,8 +1476,8 @@ function nextSourceIssueLabelsAfterPull(existing = [], merged = false) { function shouldCleanupSourceIssueAfterPull(pull, options = {}) { if (!pull || String(pull.state || '').toLowerCase() !== 'closed') return false; - const issueNumber = extractSourceIssueNumber(pull); - if (!Number.isFinite(issueNumber) || issueNumber <= 0) return false; + const issueNumbers = extractSourceIssueNumbers(pull); + if (!issueNumbers.length) return false; const repository = String(options.repository || '').toLowerCase(); const baseRepo = String( @@ -1480,11 +1488,16 @@ function shouldCleanupSourceIssueAfterPull(pull, options = {}) { const merged = Boolean(pull.merged || pull.merged_at || pull.mergedAt); if (merged) { const body = String(pull.body || ''); - const closing = new RegExp( - `(?:^|\\W)(?:close[sd]?|fix(?:e[sd])?|resolve[sd]?)\\s+#${issueNumber}\\b`, - 'i', - ); - if (closing.test(body)) return true; + if (SOURCE_ISSUE_RE.test(body)) { + const issueNumber = issueNumbers[0]; + const closing = new RegExp( + `(?:^|\\W)(?:close[sd]?|fix(?:e[sd])?|resolve[sd]?)\\s+#${issueNumber}\\b`, + 'i', + ); + if (closing.test(body)) return true; + } else { + return true; + } } return shouldGatePullOnSourceIssueFollowups(pull, options); @@ -3102,9 +3115,26 @@ function isTrustedOpenPullForIssue(pull, issueNumber, { const trustedAuthor = trustedAssociations.has( String(pull.author_association || pull.authorAssociation || '').toUpperCase(), ); + const body = String(pull.body || ''); + const sourceMarker = body.match(SOURCE_ISSUE_RE); + const labels = (pull.labels || []).map((label) => ( + typeof label === 'string' ? label : label?.name + )); + const author = String(pull.user?.login || pull.author?.login || '').toLowerCase(); + const headRef = String(pull.head?.ref || pull.headRefName || ''); + const automationManaged = + isBotPrMarker(body) + || labels.includes('automation:bot-pr') + || ( + ['netcatty-bot', 'github-actions[bot]', 'github-actions'].includes(author) + && /^cursor\/issue-\d+-/.test(headRef) + ); + const referencesIssue = automationManaged + ? Boolean(sourceMarker && sourceMarker[1] === String(issueNumber)) + : pullReferencesIssue(pull, issueNumber, { includeRelated }); return ( (Boolean(normalizedRepository) && headRepository === normalizedRepository || trustedAuthor) - && pullReferencesIssue(pull, issueNumber, { includeRelated }) + && referencesIssue ); } @@ -3132,6 +3162,7 @@ function shouldRetryIssueHandoff(comments = [], { trustedActors = '', recoveryVersion = '', notBefore = '', + notAfter = '', } = {}) { const actors = new Set( String(trustedActors || '') @@ -3140,25 +3171,44 @@ function shouldRetryIssueHandoff(comments = [], { .filter(Boolean), ); const notBeforeMs = Date.parse(String(notBefore || '')); - const trustedBodies = (comments || []) - .filter((comment) => { - if (!actors.has(String(comment.user?.login || '').toLowerCase())) return false; - if (!Number.isFinite(notBeforeMs)) return true; - const createdAt = Date.parse(comment.created_at || comment.createdAt || ''); - return Number.isFinite(createdAt) && createdAt >= notBeforeMs; - }) - .map((comment) => String(comment.body || '')); - if (!trustedBodies.length) return false; + const notAfterMs = Date.parse(String(notAfter || '')); + const trustedComments = (comments || []).filter((comment) => ( + actors.has(String(comment.user?.login || '').toLowerCase()) + )); if ( recoveryVersion - && trustedBodies.some((body) => body.includes(`cursor-handoff-recovery:version=${recoveryVersion}`)) + && trustedComments.some((comment) => ( + String(comment.body || '').includes(`cursor-handoff-recovery:version=${recoveryVersion}`) + )) ) return false; - return trustedBodies.some((body) => ( - /cursor-implement-failure:[^>]*kind=protected_path/i.test(body) - || /cursor-classification-failure:kind=research_failed/i.test(body) - || body.includes('收到这条补充了,但自动复核没有安全完成') - || body.includes('The automatic follow-up did not finish safely') - )); + const boundedComments = trustedComments + .filter((comment) => { + if (!Number.isFinite(notBeforeMs) && !Number.isFinite(notAfterMs)) return true; + const createdAt = Date.parse(comment.created_at || comment.createdAt || ''); + if (!Number.isFinite(createdAt)) return false; + if (Number.isFinite(notBeforeMs) && createdAt < notBeforeMs) return false; + if (Number.isFinite(notAfterMs) && createdAt > notAfterMs) return false; + return true; + }) + .sort((left, right) => ( + Date.parse(left.created_at || left.createdAt || '') + - Date.parse(right.created_at || right.createdAt || '') + )); + let latestTerminal = ''; + for (const comment of boundedComments) { + const body = String(comment.body || ''); + const retryableFailure = + /cursor-implement-failure:[^>]*kind=protected_path/i.test(body) + || /cursor-classification-failure:kind=research_failed/i.test(body) + || body.includes('收到这条补充了,但自动复核没有安全完成') + || body.includes('The automatic follow-up did not finish safely'); + if (retryableFailure) { + latestTerminal = 'retryable_failure'; + } else if (/cursor-followup:comment-id=[^;>]+;result=(?:no_change|updated)/i.test(body)) { + latestTerminal = 'success'; + } + } + return latestTerminal === 'retryable_failure'; } async function findOpenBotPrForIssue({ github, context, issueNumber }) { @@ -3607,6 +3657,7 @@ module.exports = { buildTriageComment, buildPullRequestBody, extractIssueCommentWatermark, + extractSourceIssueNumbers, extractSourceIssueNumber, extractProcessedIssueFollowupIds, countIssueFollowupRepliesSince, diff --git a/scripts/cursor-automation.test.cjs b/scripts/cursor-automation.test.cjs index 7637543b7..f0792104d 100644 --- a/scripts/cursor-automation.test.cjs +++ b/scripts/cursor-automation.test.cjs @@ -840,6 +840,13 @@ test('source cleanup includes merged maintainer fixes but not unmerged handoffs' repository: 'binaricat/Netcatty', }; assert.equal(auto.shouldCleanupSourceIssueAfterPull(maintainerPull, options), true); + assert.deepEqual( + auto.extractSourceIssueNumbers({ + ...maintainerPull, + body: 'Fixes #42\nResolves #43\nCloses #42', + }), + [42, 43], + ); assert.equal( auto.shouldCleanupSourceIssueAfterPull({ ...maintainerPull, @@ -980,6 +987,8 @@ test('workflow cleans source labels after eligible PR close and dedupes clean no assert.match(workflow, /types: \[opened, synchronize, reopened, ready_for_review, closed\]/); assert.match(workflow, /kind == 'source_issue_cleanup'/); assert.match(workflow, /shouldCleanupSourceIssueAfterPull\(pull/); + assert.match(workflow, /const issueNumbers = auto\.extractSourceIssueNumbers\(pull\)/); + assert.match(workflow, /for \(const issueNumber of issueNumbers\)/); assert.match(workflow, /github\.rest\.issues\.removeLabel/); assert.match(workflow, /github\.rest\.issues\.addLabels/); assert.match(workflow, /not eligible for source cleanup; skipping/); @@ -997,6 +1006,8 @@ test('workflow cleans source labels after eligible PR close and dedupes clean no assert.match(workflow, /Reconcile handoffs/); assert.ok((workflow.match(/auto\.extractPaginatedItems\(response\)/g) || []).length >= 2); assert.match(workflow, /notBefore: '2026-07-31T12:54:37Z'/); + assert.match(workflow, /notAfter: '2026-08-04T08:27:14Z'/); + assert.match(workflow, /auditedIssueNumbers = new Set\(\[2679, 2697, 2705, 2708, 2709\]\)/); assert.match(workflow, /is:issue is:closed label:"ready-for-human" label:triage/); assert.match(workflow, /is:pr is:merged label:"ready-for-human" label:"automation:bot-pr"/); const route = workflow.match(/\n route:\n[\s\S]*?(?=\n cleanup_source_issue:)/)?.[0] || ''; @@ -1133,6 +1144,10 @@ test('buildPullRequestBody records the issue comment snapshot', () => { assert.match(body, //); assert.equal(auto.extractIssueCommentWatermark(body), '987'); assert.equal(auto.extractSourceIssueNumber({ body }), 42); + assert.deepEqual( + auto.extractSourceIssueNumbers({ body: `${body}\nFixes #99` }), + [42], + ); }); test('parseIssueFollowupStatus is fail-closed and builds durable reply markers', () => { @@ -1345,6 +1360,7 @@ test('legacy retry only accepts trusted fixed failure categories once', () => { ...options, recoveryVersion: 'handoff-v2', notBefore: '2026-07-31T12:54:37Z', + notAfter: '2026-08-04T08:27:14Z', }; assert.equal(auto.shouldRetryIssueHandoff([{ user: { login: 'netcatty-bot' }, @@ -1356,6 +1372,47 @@ test('legacy retry only accepts trusted fixed failure categories once', () => { body: '收到这条补充了,但自动复核没有安全完成,已经转给维护者继续处理。', created_at: '2026-08-01T12:00:00Z', }], boundedOptions), true); + assert.equal(auto.shouldRetryIssueHandoff([ + { + user: { login: 'netcatty-bot' }, + body: '', + created_at: '2026-08-01T12:00:00Z', + }, + { + user: { login: 'netcatty-bot' }, + body: '', + created_at: '2026-08-02T12:00:00Z', + }, + ], boundedOptions), false); + assert.equal(auto.shouldRetryIssueHandoff([ + { + user: { login: 'netcatty-bot' }, + body: '', + created_at: '2026-08-01T12:00:00Z', + }, + { + user: { login: 'netcatty-bot' }, + body: '', + created_at: '2026-08-02T12:00:00Z', + }, + ], boundedOptions), true); + assert.equal(auto.shouldRetryIssueHandoff([{ + user: { login: 'netcatty-bot' }, + body: '', + created_at: '2026-08-05T12:00:00Z', + }], boundedOptions), false); + assert.equal(auto.shouldRetryIssueHandoff([ + { + user: { login: 'netcatty-bot' }, + body: '', + created_at: '2026-08-01T12:00:00Z', + }, + { + user: { login: 'netcatty-bot' }, + body: '', + created_at: '2026-08-05T12:00:00Z', + }, + ], boundedOptions), false); }); test('findOpenPullForIssue accepts same-repo work but ignores untrusted fork claims', async () => { @@ -1384,6 +1441,29 @@ test('findOpenPullForIssue accepts same-repo work but ignores untrusted fork cla assert.equal(found.number, 8); }); +test('automation pull references only control the marked source issue', () => { + const pull = { + number: 8, + state: 'open', + body: [ + '', + '', + 'Related to #42', + 'Fixes #43', + ].join('\n'), + labels: [{ name: 'automation:bot-pr' }], + user: { login: 'netcatty-bot' }, + head: { + ref: 'cursor/issue-41-123', + repo: { full_name: 'binaricat/Netcatty' }, + }, + }; + const options = { repository: 'binaricat/Netcatty', includeRelated: true }; + assert.equal(auto.isTrustedOpenPullForIssue(pull, 41, options), true); + assert.equal(auto.isTrustedOpenPullForIssue(pull, 42, options), false); + assert.equal(auto.isTrustedOpenPullForIssue(pull, 43, options), false); +}); + test('getPendingIssueFollowupsForPull does not block maintainer Fixes-only PRs', async () => { let issuesFetched = 0; const pull = { @@ -2222,10 +2302,46 @@ test('classification failure handoff receives its issue number', () => { assert.match(handoff, /buildClassificationFailureMessage/); assert.match(handoff, /steps\.research\.outcome/); assert.match(handoff, /steps\.classify_agent\.outcome/); + assert.match(handoff, /steps\.validate_classification\.outcome/); assert.match(handoff, /actions\/runs\/\$\{context\.runId\}/); assert.match(handoff, /fs\.existsSync\(helper\)/); assert.match(handoff, /const failureMessage = auto/); assert.doesNotMatch(handoff, /自动复核没有安全完成/); + assert.match(workflow, /name: Validate classification result/); + assert.match(workflow, /auto\.parseClassificationFile\("\.cursor-runtime\/classification\.json"\)/); +}); + +test('implementation publish rechecks related work and records a deduplicated handoff', () => { + const workflow = fs.readFileSync( + path.join(__dirname, '..', '.github', 'workflows', 'cursor-automation.yml'), + 'utf8', + ); + const implement = workflow.match( + /\n implement:\n[\s\S]*?(?=\n publish_implement:\n)/, + )?.[0] || ''; + const publish = workflow.match( + /\n publish_implement:\n[\s\S]*?(?=\n codex_loop:\n)/, + )?.[0] || ''; + assert.match(implement, /cursor-existing-related-pr:\$\{existing\.number\}/); + assert.match(implement, /auto\.markNeedsHuman/); + assert.match(publish, /name: Skip publish if trusted related PR opened during implementation/); + assert.match(publish, /includeRelated: true/); + assert.match(publish, /auto\.markNeedsHuman/); + assert.match(publish, /cursor-existing-related-pr:\$\{existing\.number\}/); + assert.ok( + publish.indexOf('name: Skip publish if trusted related PR opened during implementation') + < publish.indexOf('name: Publish branch from fresh runner'), + ); + assert.match( + publish, + /name: Publish branch from fresh runner\n\s+if: steps\.existing\.outputs\.exists != 'true'/, + ); + const openPr = publish.match( + /- name: Open draft PR[\s\S]*?(?=\n\s{6}- name:)/, + )?.[0] || ''; + assert.match(openPr, /findOpenPullForIssue/); + assert.match(openPr, /includeRelated: true/); + assert.match(openPr, /skip the duplicate/); }); test('classification follow-up rate-limit handoff receives its issue number', () => { diff --git a/scripts/github-workflow-ci.test.cjs b/scripts/github-workflow-ci.test.cjs index ffc17ec59..1f391a24c 100644 --- a/scripts/github-workflow-ci.test.cjs +++ b/scripts/github-workflow-ci.test.cjs @@ -300,7 +300,7 @@ test("issue implementation publishing tolerates competing automation runs", () = assert.match(publishJob[0], /echo "handoff=true" >> "\$GITHUB_OUTPUT"/); assert.match( publishJob[0], - /if: failure\(\) && steps\.publish\.outputs\.handoff == 'true'/, + /if: failure\(\) && steps\.existing\.outputs\.exists != 'true' && steps\.publish\.outputs\.handoff == 'true'/, ); assert.doesNotMatch(publishJob[0], /steps\.publish\.outcome == 'failure'/); assert.match(publishJob[0], /labels: \['ready-for-human'\]/);