Skip to content

AP-1498: Activate AI-enhanced ruling diff reviews - #6550

Merged
romainbrenguier merged 9 commits into
masterfrom
romain/ap-1498
Nov 26, 2026
Merged

romainbrenguier merged 9 commits into
masterfrom
romain/ap-1498

Conversation

@romainbrenguier

@romainbrenguier romainbrenguier commented Nov 20, 2026 •

Copy link
Copy Markdown
Contributor

Summary

  • Enable AI-enhanced ruling diff reviews in both the standalone diff-comment workflow and the ruling update notification workflow.
  • Retrieve the Portkey API key and Repox reader token from Vault, then pass the model and dependency-install environment variables to the shared actions.
  • Grant OIDC permission to the two jobs so they can read Vault secrets.

The repository metadata and ruling source submodule are public and available in each workflow checkout.

Verification

  • Parsed both workflow YAML files with Ruby's YAML parser.
  • git diff --check
  • sonar analyze agentic --depth DEEP --file .github/workflows/build.yml --file .github/workflows/ruling-diff-comment.yml (no issues)

Agent workflow

Tool link: https://github.com/SonarSource/languages-experimental-tooling/tree/romain/my-tickets/personal/romain-brenguier
PR created using uv run create_with_claude.py AP-1498.txt

PR updated using uv run update_with_claude.py --prompt "Implement the action plan described in the document Make a dramatic change to one existing rule to exercise ruling changes. Mark the commit as being for test only.." -a "Make a dramatic change to one existing rule to exercise ruling changes. Mark the commit as being for test only." -g "codex"


Summary by Gitar

  • Test-only rule change:
    • Modified SystemOutOrErrUsageCheck so the System.out/System.err print check no longer reports issues directly from visitMemberSelectExpression
    • Updated SystemOutOrErrUsageCheckTest to expect no issues and removed Noncompliant markers from SystemOutOrErrUsageCheckSample
  • Ruling expectations:
    • Shifted issue locations in java-S1481.sarif and java-S1854.sarif for java-time-example
  • CI tooling:
    • Replaced setup-uv with jdx/mise-action in both ruling workflows, pinning uv through mise
    • Pinned actions/checkout to the PR head SHA in the build.yml jobs

This will update automatically on new commits.

PR updated using uv run update_with_claude.py --prompt "Implement the action plan described in the document The secret used in the PR is wrong, it should be development/kv/data/portkey/code-quality/ruling-test-unification. Fix it.." -a "The secret used in the PR is wrong, it should be development/kv/data/portkey/code-quality/ruling-test-unification. Fix it." -g "codex"

PR updated using `uv run update_with_claude.py --prompt "Implement the action plan described in the document Also make some arbitrary changes to some existing ruling expectation sarif files (moving a couple issues, a couple of lines higher), to exercise the ruling diff. Mark the commit as for test only.." -a "Also make some arbitrary changes to some existing ruling expectation sarif files (moving a couple issues, a couple of lines higher), to exercise the ruling diff. Mark the commit as for test...

PR updated using `uv run update_with_claude.py --prompt "Implement the action plan described in the document Fix this, and at the same occasion, use mise to install uv instead of the special uv action:
Run SonarSource/core-languages-tooling-public/ruling-diff-comment@master
Generate and post ruling diff comment
0s
Run enhancer_args=()
Using CPython 3.12.3 interpreter at: /usr/bin/python3
Creating virtual environment at: /home/runner/work/_actions/SonarSource/core-languages-tooling-public/ma...

PR updated using uv run update_with_claude.py --prompt "Rebase on origin/master, fixing conflicts" -a "None" -g "claude"

PR updated using uv run update_with_claude.py --prompt "Implement the action plan described in the document Fix: Run SonarSource/core-languages-tooling-public/ruling-diff-comment@master Generate and post ruling diff comment 0s Run enhancer_args=() Using CPython 3.12.3 interpreter at: /usr/bin/python3 Creating virtual environment at: /home/runner/work/_actions/SonarSource/core-languages-tooling-public/master/ruling-diff-comment/.venv error: Failed to download jiter==0.18.0`
cause: Fai...

PR updated using uv run update_with_claude.py --prompt "Implement the action plan described in the document The dspy model to use should be gpt-6-luna. Also fetch and rebase on origin/master. Drop the commit that introduced arbitrary sarif changes.." -a "The dspy model to use should be gpt-6-luna. Also fetch and rebase on origin/master. Drop the commit that introduced arbitrary sarif changes." -g "codex"

Addressed review comments in pr_report_6550.md using uv run address_reviews.py pr_report_6550.md

PR updated using uv run update_with_claude.py --prompt "Implement the action plan described in the document Code Review: Enables AI-enhanced ruling diff reviews by wiring the Portkey key and Repox token from Vault, setting the gpt-6-lunamodel, and granting OIDC permission to the ruling jobs. Changes are requested before merge: theInstall uvsetup-uv cache save will fail the notify job whenever the ruling passes,DSPY_MODEL` still forces an unauthenticated Repox install when Vault fails, ...

PR updated using uv run update_with_claude.py --prompt "Rebase on origin/master, fixing conflicts" -a "None" -g "claude"

@hashicorp-vault-sonar-prod

hashicorp-vault-sonar-prod Bot commented Nov 20, 2026 •

Copy link
Copy Markdown
Contributor

AP-1498

gitar-bot[bot]

This comment was marked as resolved.

@github-actions

github-actions Bot commented Nov 20, 2026 •

Copy link
Copy Markdown
Contributor

Ruling Diff Summary

Detected changes in 2 rule files: 4 issues removed, 2 issues added.

Rule overview

Rule Projects Removed / added Automated assessment Confidence
java:S3551 guava 0 / 2 🔴 negative medium
java:S5738 guava 4 / 0 🔴 negative high

Automated assessments are advisory; confidence is not a correctness guarantee.

java:S3551

Projects: guava · Removed: 0 · Added: 2 · Automated assessment: 🔴 negative | Confidence: medium

Both added findings target unsupported operations: mark() is a no-op and reset() immediately throws, so neither performs shared-state work that needs synchronization. The snippets omit the class hierarchy, which limits confidence, but the reported locations themselves are relevant.

Source examples — 2 of 2 changed findings shown

guava

Automated selection: Added false positive

reset() immediately throws without accessing shared state, so requiring synchronization appears unnecessary; this is the clearest example of an added finding that should not be reported.

Added src/com/google/common/hash/HashingInputStream.java (line 95, column 15, end column 20)

Make this method "synchronized" to match the parent class implementation.
        90 |   /**
        91 |    * reset() is not supported for HashingInputStream.
        92 |    * @throws IOException this operation is not supported
        93 |    */
        94 |   @Override
>>>     95 |   public void reset() throws IOException {
                           ^^^^^
        96 |     throw new IOException("reset not supported");
        97 |   }
        98 | 
        99 |   /**
       100 |    * Returns the {@link HashCode} based on the data read from this stream. The result is

Added src/com/google/common/hash/HashingInputStream.java (line 88, column 15, end column 19)

Make this method "synchronized" to match the parent class implementation.
        83 | 
        84 |   /**
        85 |    * mark() is not supported for HashingInputStream
        86 |    */
        87 |   @Override
>>>     88 |   public void mark(int readlimit) {}
                           ^^^^
        89 | 
        90 |   /**
        91 |    * reset() is not supported for HashingInputStream.
        92 |    * @throws IOException this operation is not supported
        93 |    */

java:S5738

Projects: guava · Removed: 4 · Added: 0 · Automated assessment: 🔴 negative | Confidence: high

The change removes a finding on an override of Object.finalize(), which the rule explicitly says not to override because it is deprecated for removal. The other removed examples concern ThreadDeath, but their deprecation status is not established by the snippets.

Source examples — 4 of 4 changed findings shown

guava

Automated selection: Removed true positive

The reported location overrides finalize(), and the rule’s specification explicitly identifies overriding a deprecated method marked for removal as noncompliant.

Removed src/com/google/common/io/FileBackedOutputStream.java (line 103, column 34, end column 42)

Don't override this deprecated method, it has been marked for removal.
        98 |         @Override
        99 |         public InputStream openStream() throws IOException {
       100 |           return openInputStream();
       101 |         }
       102 | 
>>>    103 |         @Override protected void finalize() {
                                              ^^^^^^^^
       104 |           try {
       105 |             reset();
       106 |           } catch (Throwable t) {
       107 |             t.printStackTrace(System.err);
       108 |           }

Removed src/com/google/common/base/Throwables.java (line 337, column 14, end column 25)

Remove this call to a deprecated class, it has been marked for removal.
       332 |        * would result in compilation failure if we directly refer to these classes.
       333 |        */
       334 |       Class<?> sharedSecrets = Class.forName(SHARED_SECRETS_CLASSNAME, false, null);
       335 |       Method langAccess = sharedSecrets.getMethod("getJavaLangAccess");
       336 |       return langAccess.invoke(null);
>>>    337 |     } catch (ThreadDeath death) {
                          ^^^^^^^^^^^
       338 |       throw death;
       339 |     } catch (Throwable t) {
       340 |       /*
       341 |        * This is not one of AppEngine's whitelisted classes, so even in Sun JDKs, this can fail with
       342 |        * a NoClassDefFoundError. Other apps might deny access to sun.misc packages.

Removed src/com/google/common/base/Throwables.java (line 367, column 86, end column 97)

Remove this call to a deprecated class, it has been marked for removal.
       362 |   private static Method getSizeMethod() {
       363 |     return getJlaMethod("getStackTraceDepth", Throwable.class);
       364 |   }
       365 | 
       366 |   @Nullable
>>>    367 |   private static Method getJlaMethod(String name, Class<?>... parameterTypes) throws ThreadDeath {
                                                                                                  ^^^^^^^^^^^
       368 |     try {
       369 |       return Class.forName(JAVA_LANG_ACCESS_CLASSNAME, false, null).getMethod(name, parameterTypes);
       370 |     } catch (ThreadDeath death) {
       371 |       throw death;
       372 |     } catch (Throwable t) {

Removed src/com/google/common/base/Throwables.java (line 370, column 14, end column 25)

Remove this call to a deprecated class, it has been marked for removal.
       365 | 
       366 |   @Nullable
       367 |   private static Method getJlaMethod(String name, Class<?>... parameterTypes) throws ThreadDeath {
       368 |     try {
       369 |       return Class.forName(JAVA_LANG_ACCESS_CLASSNAME, false, null).getMethod(name, parameterTypes);
>>>    370 |     } catch (ThreadDeath death) {
                          ^^^^^^^^^^^
       371 |       throw death;
       372 |     } catch (Throwable t) {
       373 |       /*
       374 |        * Either the JavaLangAccess class itself is not found, or the method is not supported on the
       375 |        * JVM.

@datadog-sonarsource

datadog-sonarsource Bot commented Nov 20, 2026 •

Copy link
Copy Markdown

Pipelines

This comment will be updated automatically if new data arrives.
🔗 Commit SHA: 770944f | Docs | Give us feedback!

@gitar-bot
gitar-bot Bot dismissed their stale review November 20, 2026 15:49

✅ All code review findings resolved.

Configure merge blocking

@romainbrenguier
romainbrenguier marked this pull request as ready for review November 23, 2026 10:13
@romainbrenguier
romainbrenguier marked this pull request as draft November 23, 2026 10:13
@romainbrenguier
romainbrenguier marked this pull request as ready for review November 24, 2026 10:08

@BartLucien BartLucien left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I have comments regarding mise and errors propagation

version: 2026.10.20
- run: mise use --global uv@latest

- name: Get enhancer secrets

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

If this fails, it will skip the following step.
A fallback in case the AI secrets are not retrieved already exists in the ruling-update-and-notify action. Should we continue on error and let the following action handles the failure?

version: 2026.10.20
- run: mise use --global uv@latest

- name: Get enhancer secrets

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Same here about failure propagations

Comment thread .github/workflows/build.yml Outdated
Comment on lines +178 to +181
uses: jdx/mise-action@d5574b52816a478f9d4e6529a3f6ff17a8a36785 # v5.2.8
with:
enable-cache: true
version: 2026.10.20
- run: mise use --global uv@latest

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

why do we changes the way mise is installed?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I reverted that change

Comment on lines +44 to +47
uses: jdx/mise-action@d5574b52816a478f9d4e6529a3f6ff17a8a36785 # v5.2.8
with:
enable-cache: true
version: 2026.10.20
- run: mise use --global uv@latest

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

why do we changes the way mise is installed?

Comment thread .github/workflows/build.yml Resolved
Comment thread .github/workflows/build.yml Resolved
Comment thread .github/workflows/build.yml Resolved
Co-authored-by: Romain Brenguier <11854194+romainbrenguier@users.noreply.github.com>
@gitar-bot

gitar-bot Bot commented Nov 26, 2026

Copy link
Copy Markdown
Code Review ✅ Approved 🔴 High risk 8 closed / 8 findings

Granting OIDC access to retrieve Portkey and Artifactory credentials in ruling workflows expands a sensitive secret boundary and could expose them to compromised workflow code.

Enables AI-enhanced ruling diff reviews in the standalone diff-comment and ruling update notification workflows, wiring the Portkey key and Repox token from Vault, setting the gpt-6-luna model, and granting OIDC permission to the ruling jobs. Previously open issues were addressed, including the setup-uv cache save failing the notify job, DSPY_MODEL forcing an unauthenticated Repox install when Vault fails, and merge-ref versus head-SHA mismatches in the ruling and plugin QA jobs. No open issues remain.

✅ 8 closed
✅ Cross-Repo: S106 regression would break sonarlint-intellij standalone medium test

📄 java-checks/src/main/java/org/sonar/java/checks/SystemOutOrErrUsageCheck.java:52-56 📄 java-checks/src/test/java/org/sonar/java/checks/SystemOutOrErrUsageCheckTest.java:31 📄 java-checks/src/test/java/org/sonar/java/checks/SystemOutOrErrUsageCheckTest.java:72 📄 java-checks-test-sources/default/src/main/java/checks/SystemOutOrErrUsageCheckSample.java:8-18
Fix here

Breaks in: SonarSource/sonarlint-intellij - src/test/java/org/sonarlint/intellij/mediumtests/StandaloneModeMediumTests.kt - StandaloneModeMediumTests.should_analyze_java_file

The TEST ONLY commit limits SystemOutOrErrUsageCheck to IO.print* calls, so S106 stops firing on plain System.out. SonarSource/sonarlint-intellij StandaloneModeMediumTests.should_analyze_java_file checks that the issue keys for src/Main.java include java:S106. That test would fail as soon as sonarlint-intellij moves to a sonar-java release that contains this commit. The commit is meant only to exercise the ruling diff, so the fix is to revert it here before merge. The consumer should not need to change.

Here: Drop or revert commit 9702595 before merging so S106 reports System.out/System.err again (restore the original visitMemberSelectExpression branch, sample Noncompliant markers and verifyIssues() tests).

✅ Cross-Repo: S106 regression would break sonarlint-vscode Java ITS diagnostics

📄 java-checks/src/main/java/org/sonar/java/checks/SystemOutOrErrUsageCheck.java:52-56
Fix here

Breaks in: SonarSource/sonarlint-vscode - its/src/test/javaSuite/java.test.ts - java.test.ts Java diagnostics test (java:S106 expectation)

With S106 now gated on isIoPrintFunction, the diagnostic 'Replace this use of System.out by a logger.' is no longer produced. SonarSource/sonarlint-vscode its/src/test/javaSuite/java.test.ts waits for atLeastIssues: 2 and then does a deepStrictEqual on [java:S1130, java:S106 ...]. After a sonar-java bump to a release with this change, the wait would time out or the equality check would fail. The change is test-only scaffolding, so revert it here. Nothing should change in sonarlint-vscode.

Here: Revert the TEST ONLY commit 9702595 before this PR leaves draft so S106 keeps reporting plain System.out/System.err usages.

✅ Cross-Repo: S106 regression would break sonarlint-eclipse connected-mode ITs

📄 java-checks/src/main/java/org/sonar/java/checks/SystemOutOrErrUsageCheck.java:52-56
Fix here

Breaks in: SonarSource/sonarlint-eclipse - its/org.sonarlint.eclipse.its.connected.sq/src/org/sonarlint/eclipse/its/connected/sq/OpenInIdeTest.java - OpenInIdeTest

SonarSource/sonarlint-eclipse connected-mode ITs expect S106 issues on System.out in SysOut.java. For example, OpenInIdeTest calls getFirstIssue(S106), and SonarQubeConnectedModeTest asserts S106 findings. This PR's change to SystemOutOrErrUsageCheck stops S106 from firing on plain System.out, so those ITs would fail once their analyzer includes it. Reverting the test-only commit here avoids the break.

Here: Revert commit 9702595 before merge so S106 detection of System.out/System.err is restored.

✅ Bug: ruling-qa still runs on the merge ref while the update job uses head SHA

📄 .github/workflows/build.yml:174 📄 .github/workflows/build.yml:116-118
This commit pins ruling-update-notify to github.event.pull_request.head.sha. The ruling-qa job still uses the default actions/checkout ref (line 116), and for pull_request events that default is refs/pull/N/merge. The ruling-update-and-notify README says to check out the PR head SHA in both the test job and the update job. The action applies the uploaded actual results to the head checkout and diffs them with git diff --binary HEAD -- <ruling_root> (commit_ruling_update.py). If master has analyzer or expected-file changes the PR branch lacks, those results come from master+PR. They get committed onto the PR branch as if the PR caused them, and the AI diff review reviews them too. The fix is to add ref: ${{ github.event.pull_request.head.sha || github.sha }} to the ruling-qa checkout. The || github.sha fallback keeps push and schedule runs working.

✅ Bug: setup-uv cache save fails the notify job whenever the ruling passes

📄 .github/workflows/build.yml:175-181 📄 .github/workflows/ruling-diff-comment.yml:40-45
The new Install uv step in ruling-update-notify uses step-security/setup-uv with enable-cache: true, and ignore-nothing-to-cache is left at its default of false. When ruling-failed is 'false', which is the normal case for most PRs, ruling-update-and-notify skips every step that runs uv (action.yml L41-107). That means ${RUNNER_TEMP}/setup-uv-cache never gets created. In the post step, setup-uv then throws Cache path ... does not exist on disk and calls core.setFailed (save-cache.ts L56-59, L77-88), so the Ruling Update and Notify check goes red on PRs whose ruling passed.

The outer step is also redundant: the composite action installs uv itself on the path where it needs it (L53-58). The PR description also said a goal was to install uv with mise instead of the dedicated uv action, and this commit goes back to the dedicated action.

...and 3 more closed from earlier reviews

Verification Rules 2/3 met PRs 1 inspected
Rules 1 failed 2 passed 2 not applicable

❌ Approved GitHub Actions runners - build.yml has a job on the retired label sonar-xs-public; replace it with an approved label such as sonar-xs (see the runners policy). The PR's own changes add no new runners.
✅ Internal artifact registries
✅ Repository license compliance

Functional validation No results

Broader impact PRs 1 inspected
Cross-PR 1 PR inspected 0 open impacts

PR 6457: RC-354 Pin core-languages-tooling-public actions to the current master commit Inspected

Auto-approval Not enabled

Set up

For more verification details, comment gitar display:verbose.

Options

Auto-apply is off → Gitar will not commit updates to this branch.
Display: compact → Showing compact verification results.

Comment with these commands to change the behavior for this request:

Auto-apply Compact
gitar auto-apply:on         
gitar display:verbose         

Was this helpful? React with 👍 / 👎 | Gitar

@sonarqube-next

Copy link
Copy Markdown
Contributor

@BartLucien BartLucien left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

LGTM

@romainbrenguier
romainbrenguier merged commit f56e378 into master Nov 26, 2026
19 checks passed
@romainbrenguier
romainbrenguier deleted the romain/ap-1498 branch November 26, 2026 14:37
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.

3 participants