Skip to content

ci: add advisory AI triage for pull requests before CI approval - #4639

Merged
dolfim-ibm merged 4 commits into
mainfrom
ci/ai-pr-triage
Oct 7, 2026
Merged

dolfim-ibm merged 4 commits into
mainfrom
ci/ai-pr-triage

Conversation

@dolfim-ibm

@dolfim-ibm dolfim-ibm commented Oct 7, 2026 •

Copy link
Copy Markdown
Member

Adds the AI PR Triage workflow. It runs on pull_request_target for every non-draft PR, before a maintainer approves CI. It gives an advisory first look with Bob Shell. No job checks out or runs code from the PR.

What it does

  • Duplicate PRs. It collects candidates with deterministic rules: other PRs that cite the same issue (issue timeline cross-references), and open PRs with overlapping diff hunks in the same files. Bob Shell then rates each candidate as duplicate, related, or unrelated. The model can rate only PR numbers from this candidate list.

  • CI safety. Path rules always force ai:ci-needs-care: CI files, build and dependency files, conftest.py, shell scripts, binaries, and agent instruction files (AGENTS.md, .agents/, .bob/, …). Pattern hints in added lines (process execution, eval, network, encoded payloads, secret access) go to the model as context. The model can only make the verdict stricter, never less strict.

  • Reference data summary. It sorts changed files under tests/data/**/groundtruth/ into formatting-only, coordinates-only, text, table, and structure changes, with per-file details (for example text: 386 → 385, table 0: shape 3x4 → 3x5, reading order changed). The model says if the changes are expected from the PR intent.

  • Topic labels. The triage adds labels from the existing repository set (bug, enhancement, docx, markdown, ocr, table structure, …). Rules map the conventional-commit title (fix → bug, scope (docx) → docx) and the changed source paths to labels, and the model can add up to 3 more from the same allowlist (.github/scripts/pr_topic_labels.py). They are added only on the first triage of a PR, labels that do not exist are never created, and topic labels are never removed. On the last 40 PRs, the rules gave every label that maintainers set, except xml on an epub PR and tests on a dependency PR.

Trust model

Job Token LLM PR code
prepare read-only no read through the API and blob-less git fetch, never checked out
analyze contents: read, no write Bob Shell, read-only custom mode, --disable-tool-groups edit,execute,browser,mcp,skill,artifact,subagent,mode, MCP and subagents off data files only
publish pull-requests/issues: write no validates the JSON again, label allowlist, sanitizes text (no mentions, no HTML)

Bob Shell run pre-approves all tools of a mode. For this reason the mode has only the read group. The prompt and the mode come from the base branch. The answer is discarded if it contains the API key.

The labels are advisory: ai:ci-safe, ai:ci-needs-care, ai:possible-duplicate. They never add tests:full. A new push removes them.

Never a blocking check

The workflow is a review aid, not a gate. Every job and every step uses continue-on-error. Long steps have a timeout below the job timeout. An error (missing secret, API outage, invalid model answer) shows as a warning annotation on the run, and the PR check stays green. The comment then shows only the parts that finished.

Setup needed before merge

  • Secret BOB_API_KEY (API key with the Inference scope).
  • Optional variables: BOB_TEAM_ID (for general keys) and BOB_TRIAGE_MAX_COST (default 2).

Checklist:

  • Documentation has been updated, if necessary. (.github/CI_LABELS.md)
  • Examples have been added, if necessary.
  • Tests have been added, if necessary.

Review evidence:

@github-actions

github-actions Bot commented Oct 7, 2026

Copy link
Copy Markdown
Contributor

✅ DCO Check Passed

Thanks @dolfim-ibm, all your commits are properly signed off. 🎉

@mergify

mergify Bot commented Oct 7, 2026

Copy link
Copy Markdown
Contributor

Merge Protections

🟢 Merge protection satisfied — ready to merge.

Show 1 satisfied protection

🟢 Enforce conventional commit

Make sure that we follow https://www.conventionalcommits.org/en/v1.0.0/

  • title ~= ^(fix|feat|docs|style|refactor|perf|test|build|ci|chore|revert)(?:\(.+\))?(!)?:

@codecov

codecov Bot commented Oct 7, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

Add the "AI PR Triage" workflow. It runs on pull_request_target and never
checks out or runs PR code.

- prepare (read-only token): finds possible duplicate PRs from shared issue
  references and overlapping diff hunks, applies deterministic CI-safety rules
  for sensitive paths, and summarizes groundtruth changes (formatting,
  coordinates, text, tables, structure).
- analyze (no GitHub write access): runs Bob Shell in a read-only custom mode
  on the collected data and validates its JSON answer.
- publish (no LLM): applies an allowlist of ai:* labels and updates one sticky
  comment. Deterministic findings always override a "safe" model verdict.

Signed-off-by: Michele Dolfi <dol@zurich.ibm.com>
@dolfim-ibm
dolfim-ibm marked this pull request as ready for review October 7, 2026 12:16
Signed-off-by: Michele Dolfi <dol@zurich.ibm.com>
PeterStaar-IBM
PeterStaar-IBM previously approved these changes Oct 7, 2026
Signed-off-by: Michele Dolfi <dol@zurich.ibm.com>
Signed-off-by: Michele Dolfi <dol@zurich.ibm.com>
@dolfim-ibm
dolfim-ibm merged commit 76e2b21 into main Oct 7, 2026
117 of 121 checks passed
@dolfim-ibm
dolfim-ibm deleted the ci/ai-pr-triage branch October 7, 2026 17:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants