|
74 | 74 | days-before-pr-close: 7 |
75 | 75 | stale-issue-label: stale |
76 | 76 | stale-pr-label: stale |
77 | | - exempt-issue-labels: enhancement,maintainer,pinned,security,no-stale,bad-barnacle,clawsweeper:queueable-fix,clawsweeper:source-repro,clawsweeper:fix-shape-clear |
| 77 | + exempt-issue-labels: enhancement,maintainer,pinned,security,no-stale,bad-barnacle,bug,clawsweeper:queueable-fix,clawsweeper:source-repro,clawsweeper:fix-shape-clear |
78 | 78 | exempt-pr-labels: maintainer,no-stale,bad-barnacle |
79 | 79 | operations-per-run: 2000 |
80 | 80 | ascending: true |
@@ -106,7 +106,7 @@ jobs: |
106 | 106 | days-before-pr-stale: -1 |
107 | 107 | days-before-pr-close: -1 |
108 | 108 | stale-issue-label: stale |
109 | | - exempt-issue-labels: enhancement,maintainer,pinned,security,no-stale,bad-barnacle,clawsweeper:queueable-fix,clawsweeper:source-repro,clawsweeper:fix-shape-clear |
| 109 | + exempt-issue-labels: enhancement,maintainer,pinned,security,no-stale,bad-barnacle,bug,clawsweeper:queueable-fix,clawsweeper:source-repro,clawsweeper:fix-shape-clear |
110 | 110 | operations-per-run: 2000 |
111 | 111 | ascending: true |
112 | 112 | include-only-assigned: true |
@@ -178,7 +178,7 @@ jobs: |
178 | 178 | days-before-pr-close: 7 |
179 | 179 | stale-issue-label: stale |
180 | 180 | stale-pr-label: stale |
181 | | - exempt-issue-labels: enhancement,maintainer,pinned,security,no-stale,bad-barnacle,clawsweeper:queueable-fix,clawsweeper:source-repro,clawsweeper:fix-shape-clear |
| 181 | + exempt-issue-labels: enhancement,maintainer,pinned,security,no-stale,bad-barnacle,bug,clawsweeper:queueable-fix,clawsweeper:source-repro,clawsweeper:fix-shape-clear |
182 | 182 | exempt-pr-labels: maintainer,no-stale,bad-barnacle |
183 | 183 | operations-per-run: 2000 |
184 | 184 | ascending: true |
@@ -209,7 +209,7 @@ jobs: |
209 | 209 | days-before-pr-stale: -1 |
210 | 210 | days-before-pr-close: -1 |
211 | 211 | stale-issue-label: stale |
212 | | - exempt-issue-labels: enhancement,maintainer,pinned,security,no-stale,bad-barnacle,clawsweeper:queueable-fix,clawsweeper:source-repro,clawsweeper:fix-shape-clear |
| 212 | + exempt-issue-labels: enhancement,maintainer,pinned,security,no-stale,bad-barnacle,bug,clawsweeper:queueable-fix,clawsweeper:source-repro,clawsweeper:fix-shape-clear |
213 | 213 | operations-per-run: 2000 |
214 | 214 | ascending: true |
215 | 215 | include-only-assigned: true |
@@ -246,6 +246,190 @@ jobs: |
246 | 246 | If you believe this PR should be revived, post in #clawtributors on Discord to talk to a maintainer. |
247 | 247 | That channel is the escape hatch for high-quality PRs that get auto-closed. |
248 | 248 |
|
| 249 | + stale-bug-verification: |
| 250 | + if: ${{ github.event_name != 'workflow_dispatch' || inputs.backfill_stale_closures != true }} |
| 251 | + permissions: |
| 252 | + issues: write |
| 253 | + runs-on: ubuntu-24.04 |
| 254 | + steps: |
| 255 | + - uses: actions/create-github-app-token@bcd2ba49218906704ab6c1aa796996da409d3eb1 # v3 |
| 256 | + id: app-token |
| 257 | + continue-on-error: true |
| 258 | + with: |
| 259 | + app-id: "2729701" |
| 260 | + private-key: ${{ secrets.GH_APP_PRIVATE_KEY }} |
| 261 | + permission-issues: write |
| 262 | + permission-metadata: read |
| 263 | + - uses: actions/create-github-app-token@bcd2ba49218906704ab6c1aa796996da409d3eb1 # v3 |
| 264 | + id: app-token-fallback |
| 265 | + continue-on-error: true |
| 266 | + with: |
| 267 | + app-id: "2971289" |
| 268 | + private-key: ${{ secrets.GH_APP_PRIVATE_KEY_FALLBACK }} |
| 269 | + permission-issues: write |
| 270 | + permission-metadata: read |
| 271 | + - name: Mark inactive bugs for ClawSweeper verification |
| 272 | + uses: actions/github-script@3a2844b7e9c422d3c10d287c895573f7108da1b3 # v9 |
| 273 | + with: |
| 274 | + github-token: ${{ steps.app-token.outputs.token || steps.app-token-fallback.outputs.token }} |
| 275 | + retries: 3 |
| 276 | + script: | |
| 277 | + const dayMs = 24 * 60 * 60 * 1000; |
| 278 | + const nowMs = Date.now(); |
| 279 | + const maxMarks = 25; |
| 280 | + const barnacleActorIds = new Set([257215752, 264559031]); |
| 281 | + const exemptLabels = new Set([ |
| 282 | + "enhancement", |
| 283 | + "maintainer", |
| 284 | + "pinned", |
| 285 | + "security", |
| 286 | + "no-stale", |
| 287 | + "bad-barnacle", |
| 288 | + "clawsweeper:queueable-fix", |
| 289 | + "clawsweeper:source-repro", |
| 290 | + "clawsweeper:fix-shape-clear", |
| 291 | + ]); |
| 292 | + const { owner, repo } = context.repo; |
| 293 | + const marked = []; |
| 294 | + const unmarked = []; |
| 295 | +
|
| 296 | + const labelNames = item => |
| 297 | + new Set( |
| 298 | + (item.labels || []).map(label => |
| 299 | + (typeof label === "string" ? label : label.name).toLowerCase(), |
| 300 | + ), |
| 301 | + ); |
| 302 | + const eventTimestamp = event => |
| 303 | + Date.parse(event.created_at || event.submitted_at || ""); |
| 304 | + const isBarnacleStaleComment = event => |
| 305 | + event.event === "commented" && |
| 306 | + barnacleActorIds.has(event.actor?.id || event.user?.id || 0) && |
| 307 | + String(event.body || "").includes("marked as stale"); |
| 308 | + const hasSubstantiveUpdateSinceStale = (item, timeline) => { |
| 309 | + const orderedTimeline = timeline |
| 310 | + .map((event, index) => ({ event, index, timestamp: eventTimestamp(event) })) |
| 311 | + .filter(entry => Number.isFinite(entry.timestamp)) |
| 312 | + .toSorted( |
| 313 | + (left, right) => left.timestamp - right.timestamp || left.index - right.index, |
| 314 | + ); |
| 315 | + const staleEventIndex = orderedTimeline.findLastIndex( |
| 316 | + entry => |
| 317 | + entry.event.event === "labeled" && |
| 318 | + String(entry.event.label?.name || "").toLowerCase() === "stale", |
| 319 | + ); |
| 320 | + if (staleEventIndex < 0) return false; |
| 321 | + const staleAtMs = orderedTimeline[staleEventIndex].timestamp; |
| 322 | + const updatedAtMs = Date.parse(item.updated_at); |
| 323 | + if (!Number.isFinite(updatedAtMs)) return false; |
| 324 | + const laterEvents = orderedTimeline |
| 325 | + .slice(staleEventIndex + 1) |
| 326 | + .map(entry => entry.event); |
| 327 | + if (laterEvents.some(event => !isBarnacleStaleComment(event))) return true; |
| 328 | + const lastAutomationAtMs = Math.max(staleAtMs, ...laterEvents.map(eventTimestamp)); |
| 329 | + return updatedAtMs > lastAutomationAtMs; |
| 330 | + }; |
| 331 | + const removeStale = async item => { |
| 332 | + try { |
| 333 | + await github.rest.issues.removeLabel({ |
| 334 | + owner, |
| 335 | + repo, |
| 336 | + issue_number: item.number, |
| 337 | + name: "stale", |
| 338 | + }); |
| 339 | + unmarked.push(item); |
| 340 | + } catch (error) { |
| 341 | + if (error.status !== 404) throw error; |
| 342 | + } |
| 343 | + }; |
| 344 | +
|
| 345 | + for await (const response of github.paginate.iterator(github.rest.issues.listForRepo, { |
| 346 | + owner, |
| 347 | + repo, |
| 348 | + state: "open", |
| 349 | + labels: "bug", |
| 350 | + sort: "updated", |
| 351 | + direction: "asc", |
| 352 | + per_page: 100, |
| 353 | + })) { |
| 354 | + for (const listedItem of response.data) { |
| 355 | + if (listedItem.pull_request) continue; |
| 356 | + const listedLabels = labelNames(listedItem); |
| 357 | + const isExempt = [...listedLabels].some(label => exemptLabels.has(label)); |
| 358 | +
|
| 359 | + if (listedLabels.has("stale")) { |
| 360 | + if (isExempt) { |
| 361 | + await removeStale(listedItem); |
| 362 | + continue; |
| 363 | + } |
| 364 | + const timeline = await github.paginate( |
| 365 | + github.rest.issues.listEventsForTimeline, |
| 366 | + { owner, repo, issue_number: listedItem.number, per_page: 100 }, |
| 367 | + ); |
| 368 | + if (hasSubstantiveUpdateSinceStale(listedItem, timeline)) { |
| 369 | + await removeStale(listedItem); |
| 370 | + } |
| 371 | + // Existing stale bugs are intentionally not re-labeled or |
| 372 | + // dispatched; #114238 requires separate backfill approval. |
| 373 | + continue; |
| 374 | + } |
| 375 | +
|
| 376 | + if (isExempt || marked.length >= maxMarks) continue; |
| 377 | + const assigned = (listedItem.assignees || []).length > 0; |
| 378 | + const staleAfterDays = assigned ? 30 : 14; |
| 379 | + if (Date.parse(listedItem.updated_at) >= nowMs - staleAfterDays * dayMs) continue; |
| 380 | +
|
| 381 | + // Re-read immediately before mutation so a recent comment, |
| 382 | + // assignment, or exemption cannot be raced by the scan. |
| 383 | + const { data: item } = await github.rest.issues.get({ |
| 384 | + owner, |
| 385 | + repo, |
| 386 | + issue_number: listedItem.number, |
| 387 | + }); |
| 388 | + const currentLabels = labelNames(item); |
| 389 | + const currentlyExempt = [...currentLabels].some(label => exemptLabels.has(label)); |
| 390 | + const currentlyAssigned = (item.assignees || []).length > 0; |
| 391 | + const currentStaleAfterDays = currentlyAssigned ? 30 : 14; |
| 392 | + if ( |
| 393 | + item.state !== "open" || |
| 394 | + currentLabels.has("stale") || |
| 395 | + !currentLabels.has("bug") || |
| 396 | + currentlyExempt || |
| 397 | + Date.parse(item.updated_at) >= nowMs - currentStaleAfterDays * dayMs |
| 398 | + ) { |
| 399 | + continue; |
| 400 | + } |
| 401 | +
|
| 402 | + await github.rest.issues.addLabels({ |
| 403 | + owner, |
| 404 | + repo, |
| 405 | + issue_number: item.number, |
| 406 | + labels: ["stale"], |
| 407 | + }); |
| 408 | + const body = [ |
| 409 | + currentlyAssigned |
| 410 | + ? "This assigned bug report has been automatically marked as stale after 30 days of inactivity." |
| 411 | + : "This bug report has been automatically marked as stale due to inactivity.", |
| 412 | + "ClawSweeper is checking whether current `main` already fixes the reported behavior.", |
| 413 | + "Inactivity alone will not close a bug report.", |
| 414 | + ].join("\n"); |
| 415 | + await github.rest.issues.createComment({ |
| 416 | + owner, |
| 417 | + repo, |
| 418 | + issue_number: item.number, |
| 419 | + body, |
| 420 | + }); |
| 421 | + marked.push(item); |
| 422 | + } |
| 423 | + } |
| 424 | +
|
| 425 | + core.info(`Marked ${marked.length} bug issue(s) for ClawSweeper verification.`); |
| 426 | + core.info(`Removed stale from ${unmarked.length} updated or exempt bug issue(s).`); |
| 427 | + await core.summary |
| 428 | + .addHeading("Bug stale verification") |
| 429 | + .addRaw(`Marked for ClawSweeper review: ${marked.length}\n\n`) |
| 430 | + .addRaw(`Returned to active/exempt state: ${unmarked.length}\n\n`) |
| 431 | + .write(); |
| 432 | +
|
249 | 433 | backfill-stale-closures: |
250 | 434 | if: ${{ github.event_name == 'workflow_dispatch' && inputs.backfill_stale_closures == true }} |
251 | 435 | permissions: |
@@ -286,6 +470,7 @@ jobs: |
286 | 470 | "security", |
287 | 471 | "no-stale", |
288 | 472 | "bad-barnacle", |
| 473 | + "bug", |
289 | 474 | "clawsweeper:queueable-fix", |
290 | 475 | "clawsweeper:source-repro", |
291 | 476 | "clawsweeper:fix-shape-clear", |
@@ -497,6 +682,106 @@ jobs: |
497 | 682 | } |
498 | 683 | } |
499 | 684 |
|
| 685 | + audit-bug-closure-reasons: |
| 686 | + needs: stale |
| 687 | + if: ${{ github.event_name != 'workflow_dispatch' || inputs.backfill_stale_closures != true }} |
| 688 | + permissions: |
| 689 | + issues: read |
| 690 | + runs-on: ubuntu-24.04 |
| 691 | + steps: |
| 692 | + - name: Reject Barnacle NOT_PLANNED bug closures |
| 693 | + uses: actions/github-script@3a2844b7e9c422d3c10d287c895573f7108da1b3 # v9 |
| 694 | + with: |
| 695 | + github-token: ${{ github.token }} |
| 696 | + script: | |
| 697 | + const auditWindowMs = 48 * 60 * 60 * 1000; |
| 698 | + const cutoffMs = Date.now() - auditWindowMs; |
| 699 | + // Immutable GitHub bot account ids for openclaw-barnacle[bot] and |
| 700 | + // barnacle-openclaw[bot]. Logins are display-only and spoofable. |
| 701 | + const barnacleActorIds = new Set([257215752, 264559031]); |
| 702 | + const { owner, repo } = context.repo; |
| 703 | + const violations = []; |
| 704 | + const escapeSummaryCell = value => |
| 705 | + String(value) |
| 706 | + .replaceAll("&", "&") |
| 707 | + .replaceAll("<", "<") |
| 708 | + .replaceAll(">", ">") |
| 709 | + .replaceAll('"', """) |
| 710 | + .replaceAll("'", "'"); |
| 711 | +
|
| 712 | + pages: for await (const response of github.paginate.iterator( |
| 713 | + github.rest.issues.listForRepo, |
| 714 | + { |
| 715 | + owner, |
| 716 | + repo, |
| 717 | + state: "closed", |
| 718 | + sort: "updated", |
| 719 | + direction: "desc", |
| 720 | + per_page: 100, |
| 721 | + }, |
| 722 | + )) { |
| 723 | + const items = response.data; |
| 724 | +
|
| 725 | + for (const item of items) { |
| 726 | + const updatedAtMs = Date.parse(item.updated_at); |
| 727 | + if (Number.isFinite(updatedAtMs) && updatedAtMs < cutoffMs) break pages; |
| 728 | + if (item.pull_request || item.state_reason !== "not_planned") continue; |
| 729 | + const closedAtMs = Date.parse(item.closed_at || ""); |
| 730 | + if (!Number.isFinite(closedAtMs) || closedAtMs < cutoffMs) continue; |
| 731 | + const labels = (item.labels || []).map(label => |
| 732 | + typeof label === "string" ? label : label.name, |
| 733 | + ); |
| 734 | + if (!labels.includes("bug")) continue; |
| 735 | +
|
| 736 | + const timeline = await github.paginate(github.rest.issues.listEventsForTimeline, { |
| 737 | + owner, |
| 738 | + repo, |
| 739 | + issue_number: item.number, |
| 740 | + per_page: 100, |
| 741 | + }); |
| 742 | + const closeEvent = timeline |
| 743 | + .filter(event => event.event === "closed") |
| 744 | + .toSorted((left, right) => |
| 745 | + Date.parse(left.created_at || "") - Date.parse(right.created_at || ""), |
| 746 | + ) |
| 747 | + .at(-1); |
| 748 | + if (!closeEvent || !barnacleActorIds.has(closeEvent.actor?.id || 0)) continue; |
| 749 | + violations.push({ |
| 750 | + number: item.number, |
| 751 | + title: item.title, |
| 752 | + actor: closeEvent.actor.login, |
| 753 | + url: item.html_url, |
| 754 | + }); |
| 755 | + } |
| 756 | + } |
| 757 | +
|
| 758 | + if (violations.length === 0) { |
| 759 | + core.info("No Barnacle NOT_PLANNED bug closures found in the last 48 hours."); |
| 760 | + return; |
| 761 | + } |
| 762 | +
|
| 763 | + await core.summary |
| 764 | + .addHeading("Barnacle bug closure invariant failed") |
| 765 | + .addRaw( |
| 766 | + "Bug-labeled issues must be verified by ClawSweeper instead of closed by Barnacle as not planned.\n\n", |
| 767 | + ) |
| 768 | + .addTable([ |
| 769 | + [ |
| 770 | + { data: "Issue", header: true }, |
| 771 | + { data: "Title", header: true }, |
| 772 | + { data: "Actor", header: true }, |
| 773 | + ], |
| 774 | + ...violations.map(violation => [ |
| 775 | + `[#${violation.number}](${violation.url})`, |
| 776 | + escapeSummaryCell(violation.title), |
| 777 | + violation.actor, |
| 778 | + ]), |
| 779 | + ]) |
| 780 | + .write(); |
| 781 | + core.setFailed( |
| 782 | + `Found ${violations.length} Barnacle NOT_PLANNED bug closure(s) in the last 48 hours.`, |
| 783 | + ); |
| 784 | +
|
500 | 785 | lock-closed-issues: |
501 | 786 | needs: stale |
502 | 787 | if: ${{ github.event_name != 'workflow_dispatch' || inputs.backfill_stale_closures != true }} |
|
0 commit comments