Skip to content

chore: deploy triage-bot.yml + canonical auto-merge.yml#174

Merged
github-actions[bot] merged 1 commit into
mainfrom
chore/triage-bot-and-canonical-auto-merge
May 18, 2026
Merged

chore: deploy triage-bot.yml + canonical auto-merge.yml#174
github-actions[bot] merged 1 commit into
mainfrom
chore/triage-bot-and-canonical-auto-merge

Conversation

@ANcpLua
Copy link
Copy Markdown
Owner

@ANcpLua ANcpLua commented May 18, 2026

Last piece of the triage-gate stack. The branch ruleset on this repo blocks direct workflow-file pushes, so this comes via PR.

Final piece of the triage-gate stack: required_conversation_resolution
is on, TRIAGE_PAT is set, triage-bot.yml classifies threads, canonical
auto-merge.yml removes owner-clause (cooldown lives in pr-heal.yml).
Copilot AI review requested due to automatic review settings May 18, 2026 15:54
@github-actions
Copy link
Copy Markdown

@coderabbitai autofix

@github-actions github-actions Bot merged commit 43ac3ef into main May 18, 2026
6 of 8 checks passed
@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented May 18, 2026

Caution

Review failed

The pull request is closed.

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro Plus

Run ID: a01daa38-a62a-42c5-8375-10a76f27f4cd

📥 Commits

Reviewing files that changed from the base of the PR and between ee6fdb9 and e34d3f2.

📒 Files selected for processing (2)
  • .github/workflows/auto-merge.yml
  • .github/workflows/triage-bot.yml

Cache: Disabled due to Reviews > Disable Cache setting

Knowledge base: Disabled due to data retention organization setting


Behavior Changes

The PR introduces a two-tiered automated PR management system:

  1. triage-bot.yml (new, 129 lines): Event-driven workflow that runs on PR review comment creation/edits and review submissions. Uses GraphQL to query unresolved review threads, deterministically classifies each as dismiss or needs-human based on heuristics (thread body patterns like [triage:auto-resolve], comment prefixes nit|nitpick|praise, Copilot-authored short comments), then resolves dismissed threads via GraphQL resolveReviewThread mutation. Aggregates results and posts a PR comment summarizing decisions. Concurrency configured per PR to prevent duplicate runs.

  2. auto-merge.yml (modified, +34/-22): Removed owner-clause condition from job if: statement (github.event.pull_request.user.login == github.repository_owner || ...), shifting owner PR auto-merge from event-driven to explicit cron-based workflow (pr-heal.yml). Retain event-driven handling for bot and AI-agent PRs plus CodeRabbit-approved manual PRs. No changes to merge operation itself.

Risk Surface

  • Token scope dependency: TRIAGE_PAT secret must have permissions for readwrite:discussion_comment (GraphQL mutations) and repository access; missing or insufficient permissions will cause silent failures (caught as warnings).
  • Workflow coupling: Auto-merge behavior now split across two workflows; pr-heal.yml must exist and be correctly configured for owner PR handling, or owner PRs will not auto-merge.
  • GitHub API quota: GraphQL bulk thread queries on high-activity repositories may accumulate API calls; no explicit rate-limit handling visible.
  • Classification false positives/negatives: Heuristic-based thread classification (pattern matching on comment body, author type, length) may misclassify threads; no feedback loop to refine rules without code changes.
  • Comment mutation failures: GraphQL resolveReviewThread failures are caught and logged as warnings; threads will remain unresolved without propagating failure status to job exit code.

Validation Evidence

  • Commit message confirms required feature enablement: required_conversation_resolution configured, TRIAGE_PAT set.
  • Workflow trigger events align with use case: PR review comment creation/edits and review submissions (when human feedback is typically given).
  • Concurrency configuration prevents race conditions during simultaneous review activity on same PR.
  • Error handling in triage script uses try-catch with warning-level logging, allowing workflow to proceed even if individual thread mutations fail.

Generated Artifacts

  • .github/workflows/triage-bot.yml: 129-line workflow containing embedded GraphQL/REST API calls for review thread query, mutation, and comment posting.
  • .github/workflows/auto-merge.yml: Revised workflow with reduced job condition logic; now acts as tier-2 handler (bots/agents/CodeRabbit only).
  • PR comment posts per-PR triage decisions (human-readable report) for transparency.

Cross-Repo Implications

  • Deployment depends on pr-heal.yml existence in same repository and correct cron/trigger configuration; if missing, owner PR auto-merge is broken.
  • TRIAGE_PAT must be provisioned at organization or repository level with appropriate GraphQL permissions; missing token will cause workflow failures.
  • Interaction with required_conversation_resolution branch protection: workflow resolves unresolved threads, effectively bypassing the conversation-resolution gate for dismissible thread categories; may conflict with manual review policies if heuristics are too permissive.

Walkthrough

This PR separates owner-PR auto-merge handling into a distinct cron-based workflow (pr-heal.yml) by removing the owner-login condition from the event-driven auto-merge job, and introduces a new triage-bot.yml workflow that automatically classifies and resolves trivial review threads using GraphQL mutations and REST API comment posting.

Changes

Auto-merge tier restructuring

Layer / File(s) Summary
Job condition and tier documentation
.github/workflows/auto-merge.yml
Workflow header documentation is updated to describe the new tier split: this event-driven workflow handles bot and AI-agent PRs plus CodeRabbit-approved manual PRs, while owner-authored PRs are routed through a separate pr-heal.yml cron workflow. The enable-auto-merge job if: condition removes the github.event.pull_request.user.login == github.repository_owner clause, completing the tier decoupling.

Automated review thread triage

Layer / File(s) Summary
Workflow trigger and permission configuration
.github/workflows/triage-bot.yml
Establishes the new "Triage Bot" workflow with triggers on review comment creation/edit, review submission, and manual dispatch (with optional pr_number input). Requires pull-requests: write permission and configures concurrency grouping by PR number to prevent run cancellation.
Thread classification and resolution logic
.github/workflows/triage-bot.yml
Implements the triage job: queries up to 100 unresolved review threads via GraphQL, applies deterministic classification rules (checking for [triage:auto-resolve] marker, nit/nitpick/praise prefixes, and short Copilot-authored comments) to tag threads as dismiss or needs-human, calls GraphQL resolveReviewThread mutation for dismissible threads with failure warnings, and posts a PR comment summarizing all decisions and noting that needs-human threads block auto-merge.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Possibly related PRs

  • ANcpLua/ANcpLua.Analyzers#118: Modifies the same .github/workflows/auto-merge.yml workflow's bot/auto-merge handling and job condition logic.
  • ANcpLua/ANcpLua.NET.Sdk#149: Directly overlaps with changes to jobs.enable-auto-merge.if condition in the same auto-merge workflow.
  • ANcpLua/ANcpLua.NET.Sdk#94: Addresses the same owner-tier handling in .github/workflows/auto-merge.yml, implementing an alternative "Owner auto-merge" tier structure.

Suggested labels

area:infra, area:security

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch chore/triage-bot-and-canonical-auto-merge
✨ Simplify code
  • Create PR with simplified code
  • Commit simplified code in branch chore/triage-bot-and-canonical-auto-merge
  • 🛠️ architecture hardening
  • 🛠️ security pass
  • 🛠️ test gap closure
  • 🛠️ docs and changelog alignment
  • 🛠️ performance and allocation pass

Comment @coderabbitai help to get the list of available commands and usage tips.

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented May 18, 2026

Note

Autofix is a beta feature. Expect some limitations and changes as we gather feedback and continue to improve it.

Autofix skipped. No unresolved CodeRabbit review comments with fix instructions found.

@claude
Copy link
Copy Markdown

claude Bot commented May 18, 2026

Claude encountered an error after 2s —— View job


I'll analyze this and get back to you.

@codacy-production
Copy link
Copy Markdown

Up to standards ✅

🟢 Issues 0 issues

Results:
0 new issues

View in Codacy

AI Reviewer: first review requested successfully. AI can make mistakes. Always validate suggestions.

Run reviewer

TIP This summary will be updated as you push new changes.

Copy link
Copy Markdown

@codacy-production codacy-production Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

The PR introduces automation for comment triage and updates the auto-merge strategy. While the structure is sound, two logic issues in the triage bot script should be addressed before merging to ensure functionality and prevent PR noise.

  • The author check for GitHub Copilot is currently incorrect and will fail to match bot-authored comments.
  • The reporting logic lacks a mechanism to prevent comment spam, as it posts a new summary every time the workflow runs.

Codacy analysis reports the PR is up to standards, and the auto-merge logic for agent branches and owner cooldown is correctly implemented.

Test suggestions

  • Verify triage-bot resolves comments with explicit '[triage:auto-resolve]' tag.
  • Verify triage-bot resolves 'nit:' and 'praise:' comments via case-insensitive regex.
  • Verify triage-bot resolves short informational comments from 'Copilot'.
  • Verify triage-bot flags unknown comments as 'needs-human' and keeps them unresolved.
  • Verify auto-merge workflow enables native auto-merge for AI agent branches.
  • Verify auto-merge workflow enables native auto-merge upon CodeRabbit approval.
  • Verify owner-authored PRs do not trigger immediate auto-merge, respecting the new cooldown tier.

TIP Improve review quality by adding custom instructions
TIP How was this review? Give us feedback

}

if (summary.length > 0) {
await github.rest.issues.createComment({
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 MEDIUM RISK

This workflow will create a new PR comment every time a review or comment event occurs if unresolved threads exist, leading to excessive noise. Consider modifying the script to search for an existing 'Triage Bot report' and update it, or only post if a thread was actually resolved during the run.

Try running the following prompt in your coding agent:

Update the triage-bot.yml script to first search for an existing issue comment authored by the bot with the header '## Triage Bot report'. If found, update that comment; otherwise, only call github.rest.issues.createComment if a thread was newly resolved.

} else if (/^\s*(nit:|nitpick:|praise:)/i.test(body)) {
decision = 'dismiss';
reason = 'classified as nit/nitpick/praise — non-blocking';
} else if (author === 'Copilot' && body.length < 200) {
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 MEDIUM RISK

The author login for GitHub Copilot is usually github-copilot[bot]. The current check for Copilot will not match the actual bot user, rendering the auto-resolution rule ineffective.

Suggested change
} else if (author === 'Copilot' && body.length < 200) {
} else if (author === 'github-copilot[bot]' && body.length < 200) {

@ANcpLua
Copy link
Copy Markdown
Owner Author

ANcpLua commented May 18, 2026

Triage Bot report

  • thread ic6C5GaI from @codacy-production: needs-human — no rule matched — keeping blocked for manual review

    🟡 MEDIUM RISK This workflow will create a new PR comme

  • thread ic6C5GaN from @codacy-production: needs-human — no rule matched — keeping blocked for manual review

    🟡 MEDIUM RISK The author login for GitHub Copilot is u

Threads marked needs-human stay unresolved and block auto-merge.

1 similar comment
@ANcpLua
Copy link
Copy Markdown
Owner Author

ANcpLua commented May 18, 2026

Triage Bot report

  • thread ic6C5GaI from @codacy-production: needs-human — no rule matched — keeping blocked for manual review

    🟡 MEDIUM RISK This workflow will create a new PR comme

  • thread ic6C5GaN from @codacy-production: needs-human — no rule matched — keeping blocked for manual review

    🟡 MEDIUM RISK The author login for GitHub Copilot is u

Threads marked needs-human stay unresolved and block auto-merge.

Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: e34d3f229a

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

- name: Triage unresolved review threads
uses: actions/github-script@v7
with:
github-token: ${{ secrets.TRIAGE_PAT }}
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Skip triage when TRIAGE_PAT is unavailable

This workflow always passes secrets.TRIAGE_PAT to actions/github-script, but pull_request_review and pull_request_review_comment also fire for PRs from forks, where repository secrets are not provided; in that case the step runs without a usable token and fails before any thread triage happens. Because this bot is intended to clear non-blocking threads for required_conversation_resolution, fork PRs can stay blocked indefinitely unless someone resolves threads manually. Add an explicit guard/fallback for missing TRIAGE_PAT (for example, skip with a notice or use a safe alternative token path).

Useful? React with 👍 / 👎.

query($owner: String!, $repo: String!, $number: Int!) {
repository(owner: $owner, name: $repo) {
pullRequest(number: $number) {
reviewThreads(first: 100) {
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Paginate review-thread fetch past the first 100 items

The GraphQL query fetches only reviewThreads(first: 100) and never follows pagination cursors, so PRs with more than 100 threads leave the remainder unprocessed. Since this workflow is meant to resolve non-blocking threads under required_conversation_resolution, any unresolved thread beyond the first page can still block merge even after a successful bot run. Add cursor-based pagination (pageInfo.hasNextPage / after) to ensure all unresolved threads are triaged.

Useful? React with 👍 / 👎.

Comment on lines +86 to +87
const first = t.comments.nodes[0] ?? {};
const body = first.body ?? '';
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Evaluate full thread context before auto-resolving it

The triage decision is based only on t.comments.nodes[0] (the first comment in the thread), so a thread that starts as a nit: but later contains a substantive human follow-up can still be auto-resolved incorrectly. In repositories with required_conversation_resolution, this removes a real review blocker and can allow merge without handling the latest objection. Classify using the latest unresolved context (or all comments), not just the first message.

Useful? React with 👍 / 👎.

runs-on: ubuntu-latest
steps:
- name: Triage unresolved review threads
uses: actions/github-script@v7
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Pin github-script to an immutable commit SHA

This step pulls actions/github-script@v7 by moving tag, which can change behavior without a repository diff and runs with a write-capable token (TRIAGE_PAT). A compromised or regressed upstream tag would execute arbitrary script code in this job and could misuse PR-write credentials. Pin the action to a full commit SHA to make the workflow deterministic and reduce supply-chain risk.

Useful? React with 👍 / 👎.

@ANcpLua
Copy link
Copy Markdown
Owner Author

ANcpLua commented May 18, 2026

Triage Bot report

  • thread ic6C5GaI from @codacy-production: needs-human — no rule matched — keeping blocked for manual review

    🟡 MEDIUM RISK This workflow will create a new PR comme

  • thread ic6C5GaN from @codacy-production: needs-human — no rule matched — keeping blocked for manual review

    🟡 MEDIUM RISK The author login for GitHub Copilot is u

  • thread ic6C5KbX from @chatgpt-codex-connector: needs-human — no rule matched — keeping blocked for manual review

    **P1 Badge

  • thread ic6C5Kbc from @chatgpt-codex-connector: needs-human — no rule matched — keeping blocked for manual review

    **P2 Badge

  • thread ic6C5Kbh from @chatgpt-codex-connector: needs-human — no rule matched — keeping blocked for manual review

    **P1 Badge

  • thread ic6C5Kbk from @chatgpt-codex-connector: needs-human — no rule matched — keeping blocked for manual review

    **P2 Badge

Threads marked needs-human stay unresolved and block auto-merge.

1 similar comment
@ANcpLua
Copy link
Copy Markdown
Owner Author

ANcpLua commented May 18, 2026

Triage Bot report

  • thread ic6C5GaI from @codacy-production: needs-human — no rule matched — keeping blocked for manual review

    🟡 MEDIUM RISK This workflow will create a new PR comme

  • thread ic6C5GaN from @codacy-production: needs-human — no rule matched — keeping blocked for manual review

    🟡 MEDIUM RISK The author login for GitHub Copilot is u

  • thread ic6C5KbX from @chatgpt-codex-connector: needs-human — no rule matched — keeping blocked for manual review

    **P1 Badge

  • thread ic6C5Kbc from @chatgpt-codex-connector: needs-human — no rule matched — keeping blocked for manual review

    **P2 Badge

  • thread ic6C5Kbh from @chatgpt-codex-connector: needs-human — no rule matched — keeping blocked for manual review

    **P1 Badge

  • thread ic6C5Kbk from @chatgpt-codex-connector: needs-human — no rule matched — keeping blocked for manual review

    **P2 Badge

Threads marked needs-human stay unresolved and block auto-merge.

@chatgpt-codex-connector
Copy link
Copy Markdown

Summary

  • Implemented a fork-safe secret guard and token fallback so the triage step no longer hard-fails when TRIAGE_PAT is unavailable (for example on fork-triggered review events). .github/workflows/triage-bot.ymlL57-L70
  • Pinned actions/github-script to a full commit SHA to reduce moving-tag supply chain risk for this write-capable workflow step. .github/workflows/triage-bot.ymlL55-L55
  • Added GraphQL pagination for review threads (pageInfo + cursor loop) so triage processes all unresolved threads, not only the first 100. .github/workflows/triage-bot.ymlL72-L95
  • Changed triage classification to evaluate the latest thread comment (sorted by createdAt) instead of only the first comment, and corrected Copilot matching to github-copilot[bot]. .github/workflows/triage-bot.ymlL101-L121
  • Updated report behavior to upsert an existing ## Triage Bot report comment when present, and only create a new report comment when at least one thread was actually resolved—reducing PR comment noise. .github/workflows/triage-bot.ymlL144-L173

Testing

  • git status --short && git diff -- .github/workflows/triage-bot.yml | sed -n '1,220p'
  • nl -ba .github/workflows/triage-bot.yml | sed -n '50,220p'
  • git add .github/workflows/triage-bot.yml && git commit -m "fix: harden triage bot thread handling and reporting"

Committed on the current branch as:

  • 111fefdfix: harden triage bot thread handling and reporting

View task →

@chatgpt-codex-connector
Copy link
Copy Markdown

Summary

  • Updated triage-bot.yml to address the review-blocking triage issues: pinned actions/github-script to an immutable SHA, added fallback token behavior with explicit fork-context warning handling, and gated resolution attempts on TRIAGE_PAT availability. .github/workflows/triage-bot.ymlL55-L69 .github/workflows/triage-bot.ymlL135-L148
  • Implemented cursor-based GraphQL pagination for unresolved review threads so runs process beyond the first 100 threads. .github/workflows/triage-bot.ymlL71-L101
  • Switched classification to evaluate the latest comment in each thread (instead of the first), and fixed Copilot author matching to github-copilot[bot] for short informational comments. .github/workflows/triage-bot.ymlL109-L128
  • Reduced report noise by updating an existing ## Triage Bot report comment when present, and creating a new report only when at least one thread was newly resolved. .github/workflows/triage-bot.ymlL151-L177
  • Committed changes on branch with commit 16c705e and created a follow-up PR record via make_pr titled “fix: harden triage-bot thread triage and reporting flow”.

Testing

  • git diff -- .github/workflows/triage-bot.yml
  • git status --short
  • git commit -m "fix: harden triage bot thread handling and reporting"

View task →

@ANcpLua ANcpLua review requested due to automatic review settings May 18, 2026 16:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant