|
| 1 | +<!-- |
| 2 | +SPDX-FileCopyrightText: Copyright (c) 2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved. |
| 3 | +SPDX-License-Identifier: Apache-2.0 |
| 4 | +--> |
| 5 | + |
| 6 | +# Advisory semantic conflict review |
| 7 | + |
| 8 | +The `CodeRabbit Semantic Conflict Review` workflow performs best-effort semantic |
| 9 | +compatibility analysis for open, non-draft PRs targeting `main` or `release/**`. |
| 10 | +No opt-in label is needed. It compares both branches from their merge base and |
| 11 | +follows affected callers, contracts, configuration, and tests across files. |
| 12 | + |
| 13 | +- PR creation, reopening, updates, and becoming ready evaluate the threshold; |
| 14 | + they do not automatically spend an AI call. A scan every six hours also evaluates it. |
| 15 | +- The first analysis needs new target commits and either 24 hours since the |
| 16 | + merge-base commit or at least 30 target commits beyond that base. After a |
| 17 | + completed PASS/FAIL analysis, count from its target SHA and completion time. |
| 18 | + PR updates invalidate the old verdict but do not bypass these thresholds. |
| 19 | +- An authorized `ci: full pre-merge approved` label or enabling auto-merge |
| 20 | + bypasses the threshold. Approval-label authors are checked against the existing |
| 21 | + `trt-llm-ci-approvers` team using its existing token. All pre-merge requests |
| 22 | + share a one-hour cooldown, including when the SHA pair changes. A signal |
| 23 | + during cooldown is skipped; ordinary scans and the post-merge audit remain. |
| 24 | +- Exact revision pairs, including requests still awaiting a reply, are deduplicated. |
| 25 | + A missing, truncated or inconclusive latest reply pauses routine requests, |
| 26 | + including for new revision pairs, until a verified reply or a manual/merge-intent |
| 27 | + retry. This avoids repeatedly paying for unusable replies. Workflow dispatch |
| 28 | + accepts one PR number and bypasses the thresholds, cooldown and deduplication |
| 29 | + for that PR only. |
| 30 | +- Merge events request a post-merge audit regardless of thresholds or cooldown. |
| 31 | + The six-hour scan recovers merges from the preceding 24 hours. The audit pins |
| 32 | + the actual merge commit and historical target, including for release PRs; |
| 33 | + later target updates do not invalidate it. Squash-only rules or the two-parent |
| 34 | + merge must establish the historical target; ambiguous rebase history is rejected. |
| 35 | + A pre-merge result/request can be reused only when its head/target pair and |
| 36 | + GitHub's recorded test-merge tree match the actual merged tree. Otherwise the |
| 37 | + audit includes the actual merged code in a new analysis request. |
| 38 | + |
| 39 | +## Request transport and scan limits |
| 40 | + |
| 41 | +The workflow reads the semantic instructions from `.coderabbit.yaml`; the native |
| 42 | +custom check remains `off` during ordinary reviews. It requests an ordinary |
| 43 | +CodeRabbit PR chat reply with `SEMANTIC_REVIEW_V3`, the full revision record and |
| 44 | +source links. Native custom-check PASS table cells can truncate those details. |
| 45 | +Legacy table replies remain readable but truncated evidence never becomes PASS. |
| 46 | +The request explicitly forbids formal review submission or Request Changes. |
| 47 | + |
| 48 | +Commands use the existing `TRTLLM_AGENT_SHARED_TOKEN` and require the |
| 49 | +`trtllm-agent` User account (ID `296075020`), verified before scanning. There is |
| 50 | +no fallback to `github-actions[bot]`, whose commands may be ignored. Repository |
| 51 | +reads and Check publication still use `GITHUB_TOKEN`; neither token executes PR |
| 52 | +code. Acceptance of the service-account commands, especially on merged/release |
| 53 | +PRs, requires a deployment pilot. Missing replies never imply semantic success. |
| 54 | + |
| 55 | +Scheduled scans run at minute 23 every six hours (UTC). Each scan sends at most |
| 56 | +20 new AI requests, including audits, to avoid an initial burst across all open |
| 57 | +PRs. Recent merged PRs are considered first; open PRs use a rotating starting |
| 58 | +point. Exact-pair deduplication avoids resending completed or in-flight requests. |
| 59 | +Scans restart from live state, not a saved cursor. Saturation can delay PRs; |
| 60 | +use a manual dispatch for a specific PR rather than relying on a resume guarantee. |
| 61 | + |
| 62 | +Each token's remaining REST budget is read once, then tracked from response |
| 63 | +headers, including pagination. A scan stops below a 100-request reserve or on |
| 64 | +primary/secondary rate limiting and reports processed PRs and new requests. |
| 65 | +Ordinary permission errors remain failures. Limits on a scheduled scan do not |
| 66 | +change single-PR event or manual-dispatch behavior. Frequency reduction does not |
| 67 | +reduce the peak cost of one scan. A rate-limited or missed scan can also delay |
| 68 | +post-merge recovery beyond its 24-hour lookback. |
| 69 | + |
| 70 | +## Result verification |
| 71 | + |
| 72 | +The `Semantic conflict with target branch` Check starts neutral. Stale results |
| 73 | +become neutral when the PR event or scheduled scan observes a version change. |
| 74 | +The verifier checks the bot identity, most recent trusted request, exact revision |
| 75 | +record, and GitHub merge base. Publication and preview select the newest applicable |
| 76 | +reply after that request; delayed events cannot restore an older verdict, and |
| 77 | +pending manual retries cannot reuse an earlier PASS. Before deployment, the preview |
| 78 | +also accepts manual evaluations when no trusted request exists for the pair. |
| 79 | +PASS becomes success; FAIL makes the Check and |
| 80 | +publishing job red; Inconclusive remains neutral. A successful request job only |
| 81 | +means orchestration succeeded. Checks on the actual merge SHA use the distinct |
| 82 | +`Semantic conflict audit (post-merge)` name, with a receipt linking the analysis |
| 83 | +on the original PR. Evidence includes code locations and regression scenarios. |
| 84 | +The instructions first discover cross-branch interactions, then verify their |
| 85 | +contracts, including test replacements and the production paths they exercise. |
| 86 | +Replies must cite immutable source links |
| 87 | +with full SHAs and line numbers from both head and target. A PASS/FAIL without |
| 88 | +those citations becomes Inconclusive, including in the preview; an older PASS |
| 89 | +cannot substitute for that incomplete reply. Citation presence does not prove |
| 90 | +the AI's reasoning or the cited code is correct. |
| 91 | + |
| 92 | +CodeRabbit can make mistakes, including false positives. Keep these checks and |
| 93 | +workflows non-required: their failures then do not block merging. No required |
| 94 | +waiting gate is added, and auto-merge does not wait for this analysis. Audit does |
| 95 | +not revert code or modify branches. Repository rules remain unchanged. |
| 96 | +The thresholds and cooldown limit frequency, not total calls per PR. |
| 97 | + |
| 98 | +Changes to this automation run the separate read-only `CodeRabbit Semantic |
| 99 | +Review Preview` workflow, including fork drafts. `Automation tests and result |
| 100 | +lookup (not AI approval)` runs Node tests and reads actual CodeRabbit replies; |
| 101 | +`AI verdict (advisory; skipped = unavailable)` runs only for a verified current |
| 102 | +PASS/FAIL and is otherwise gray/skipped. `precommit-check.yml` is unchanged. |
| 103 | + |
| 104 | +Both workflows use the same verifier. Privileged jobs load only trusted default |
| 105 | +branch scripts, never PR code. The preview has read-only permissions. Before |
| 106 | +merge, a maintainer can use the exported `command(pair)` function in |
| 107 | +`.github/scripts/coderabbit_semantic_review_request.js` to prepare a chat request |
| 108 | +with fixed `head`, `target`, `mergeBase` and `branch`, then post it on the PR. |
| 109 | +After the reply arrives, rerun the **tests and result lookup** job; rerunning only |
| 110 | +the AI job reuses old outputs. Preview tests do not establish production trigger, |
| 111 | +permission, command-acceptance or post-merge behavior. |
0 commit comments