Skip to content

ci(lint): Add decision-model-linter with SDK review rules - #6823

Draft
runningcode wants to merge 4 commits into
mainfrom
no/decision-model-linter
Draft

runningcode wants to merge 4 commits into
mainfrom
no/decision-model-linter

Conversation

@runningcode

@runningcode runningcode commented Dec 1, 2026 •

Copy link
Copy Markdown
Contributor

📜 Description

Adds decision-model-linter with 30 review rules for sentry-java. Each rule is a yes/no question that typesafe/jev-1.13 answers about the changed lines of one file:

Suite Files Rules
safety main sources broad catches, swallowed exceptions, exceptions lost in executor tasks, InterruptedException, capturing the SDK's own failures, PII without sendDefaultPii, scrubbers that fail open, optional dependency probes
tests unit, Android, integration and UI test sources hollow assertions, leaked executors, fixed sleeps and unbounded or avoidable polling
publicApi main sources missing @ApiStatus, missing @TestOnly
kotlinInterop main Java getter and setter pairs Kotlin can't merge into a property
android sentry-android* missing @RequiresApi, redundant NewApi suppression
instrumentation main sources repeated headers, third-party baggage, coroutine cancellation, wasted hot-path work
resources main sources partial releases, replaced closeables, held SDK executors, timeouts on the worker executor, unitless quantities, unclear clocks, unexplained workarounds
gradle build scripts and build-logic configuration cache hazards, raised support floors

The rules come from REVIEWS.md and from six months of human review comments on this repo. Anything a parser can decide, such as banned calls and imports, formatting, or unused code, is left out on purpose. It belongs in detekt, Error Prone, or Spotless, not a model.

The workflow lints each PR's changed lines and keeps one comment with the findings.

  • Every rule starts at warn. Findings are reported but never fail the check, and a rule moves to error only after it proves precise on real PRs.
  • unchecked is error: if the model could not check a file, the check fails. A green check therefore means every changed file was reviewed.
  • A person can add the Override decision model lint label to pass a failing check while the findings stay reported.
  • Fork PRs get no secrets, so they skip the lint. The workflow uses pull_request, never pull_request_target.
  • It uses WARDEN_OPENROUTER_API_KEY, which this repo already receives. AI_GATEWAY_API_KEY doesn't work here because the linter only supports OpenRouter's decisions endpoint.

💡 Motivation and Context

The goal is that a PR is only ready for human review once automated review has passed. Warden's java-sdk-review skill covers the rules that need reading across files. This linter covers the rest, more cheaply, and each rule's precision can be tuned or removed on its own.

💚 How did you test it?

Loaded the config with the pinned linter (0.3.0) and checked which suites match sample paths: core, Android, test, Kotlin, Gradle, build-logic, samples, and generated files. Backtested on 80 PRs merged in October and November, which were not used to write the rules. Each PR was reviewed as it looked at its first review comment. There was no OpenRouter key, so agents emulated jev on the changed lines. They found 38 problems: 5 correct, 30 plausible, 3 false positives.

After the backtest:

  • publicApi.undocumentedNull is dropped (10 hits, none worth a comment).
  • safety.unjustifiedBroadCatch accepts a commented catch that must also catch LinkageError.
  • tests.hollowAssertion catches fake clocks that are never advanced.
  • Two executor rules were added for review comments nothing caught.

📝 Checklist

  • I added GH Issue ID & Linear ID
  • I added tests to verify the changes.
  • No new PII added or SDK only sends newly added PII if sendDefaultPII is enabled.
  • I updated the docs if needed.
  • I updated the wizard if needed.
  • Review from the native team if needed.
  • No breaking change or entry added to the changelog.
  • No breaking change for hybrid SDKs or communicated to hybrid SDKs.
  • Public API changes reviewed by another Mobile SDK team member or implemented according to the develop docs spec.

🔮 Next steps

  • Run the linter with jev on a few of these PRs, then tune thresholds.
  • Move the parser-decidable rules from REVIEWS.md into detekt and Error Prone.

🤖 Generated with Claude Code

#skip-changelog

Adds rules that a small model answers from the changed lines of one file:
exception handling, PII, tests, public API annotations, Kotlin interop,
Android, instrumentation, resources and time, and Gradle build logic.
Rules that a parser can decide stay with detekt, Error Prone and
Spotless, and rules that need reading across files stay with Warden.

Every rule starts at warn, so findings are reported but never fail the
check. A file the model could not check fails the check, so a green run
means every changed file was reviewed. Fork PRs get no secrets and skip
the lint.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@github-actions github-actions Bot added the risk: medium PR risk score: medium label Dec 1, 2026
@github-actions

github-actions Bot commented Dec 1, 2026 •

Copy link
Copy Markdown
Contributor

PR risk: medium

For commit 43a8ff3.

The model rated this change low. It was raised to medium because:

  • R3: a changed path is not covered by the repository's fact sheet: lint/decision-model-linter.config.ts, lint/files.ts, lint/suites/android.ts, lint/suites/gradle.ts, lint/suites/instrumentation.ts and 6 more
  • R5: dependencies or bundled SDK versions changed: lint/package-lock.json, lint/package.json
  • R6: build or release configuration changed: .github/workflows/decision-model-lint.yml, .gitignore
  • R7: the model was not confident enough that the change is low

This label is a hint for reviewers, not an approval.

@sentry

sentry Bot commented Dec 1, 2026 •

Copy link
Copy Markdown

📲 Install Builds

Android

🔗 App Name App ID Version Configuration
SDK Size io.sentry.tests.size 8.66.0 (1) release

⚙️ sentry-android Build Distribution Settings

runningcode and others added 2 commits December 1, 2026 10:54
The config ignores sentry-android-integration-tests entirely, so its UI tests never got the tests
suite. The tests suite now re-includes the modules' src directories, matches androidTest flavor
source sets such as androidTestReplay, and covers the macrobenchmark module, which keeps its tests
in src/main. SDK suites still ignore the modules' app code. sentry-samples has no test source sets.

flakyWait flagged a Thread.yield() poll bounded by a deadline, though nothing signals that a thread
has parked. It now reports only fixed sleeps, unbounded waits, ordering assumptions, and polls
where a Future, latch, idling resource, fake clock, or the executor's completion was available.

lostExecutorException reports tasks whose exceptions would vanish in a Future nobody reads.
unjustifiedBroadCatch now lists the task body as a boundary, so the catch both rules ask for
agrees with it.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Spring and servlet modules keep tests that run against a real server in
integrationTest source sets, which no suite matched.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@github-actions github-actions Bot added risk: medium PR risk score: medium and removed risk: medium PR risk score: medium labels Dec 1, 2026
Comment on lines +61 to +77
comment=$(gh api "repos/$GITHUB_REPOSITORY/issues/$PR/comments" --paginate \
--jq ".[] | select(.user.login == \"github-actions[bot]\" and (.body | contains(\"$marker\"))) | .id" | head -n 1)
body=
if [ -s "$report" ] && { [ "$status" -le 1 ] || [ "$OVERRIDDEN" = true ]; }; then
body=$(printf '%s\n%s' "$marker" "$(cat "$report")")
elif [ "$status" -eq 0 ] && [ -n "$comment" ]; then
body=$(printf '%s\nNo findings on the latest commit.' "$marker")
fi
if [ -n "$body" ] && [ -n "$comment" ]; then
gh api -X PATCH "repos/$GITHUB_REPOSITORY/issues/comments/$comment" -f body="$body" > /dev/null
elif [ -n "$body" ]; then
gh api "repos/$GITHUB_REPOSITORY/issues/$PR/comments" -f body="$body" > /dev/null
fi
cat "$report" >> "$GITHUB_STEP_SUMMARY"

if [ "$status" -ne 0 ] && [ "$OVERRIDDEN" = true ]; then exit 0; fi
exit "$status"

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Comment API write failure bypasses the lint status gate

If a GitHub comment create or update fails, -e exits before the intended status gate: an otherwise-clean run with an existing comment fails, and an override cannot pass failed lint. The comment lookup pipeline does not have the claimed pipefail behavior because this step uses GitHub Actions’ default shell.

Evidence
  • The step does not specify shell:, so GitHub Actions uses its default Bash shell with -e, not -o pipefail.
  • When lint succeeds and an existing bot comment is found, lines 66–70 set a “No findings” body and make an unguarded PATCH request. For a failed lint with the override label, lines 64–72 likewise write the report before reaching the override gate.
  • A nonzero result from either direct gh api write exits the script under -e, skipping lines 76–77; thus a comment-write failure can fail a clean check or prevent the override from taking effect. The lookup pipeline’s status is instead the final head status without `pipefail.

Identified by Warden · code-review · YQX-HGT

@github-actions github-actions Bot removed the risk: medium PR risk score: medium label Dec 1, 2026
Drop publicApi.undocumentedNull, which fired 10 times on October and November
PRs without one finding worth a comment. Let unjustifiedBroadCatch accept a
commented catch that must also catch LinkageError, since rethrowIfFatal would
rethrow it. Make hollowAssertion catch fake clocks that are never advanced.

Add two executor rules for missed review comments: hold the SDK executor only
as a local, and schedule timeouts on the timer executor.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@runningcode
runningcode force-pushed the no/decision-model-linter branch from f925672 to 43a8ff3 Compare December 1, 2026 14:47
@github-actions github-actions Bot added the risk: medium PR risk score: medium label Dec 1, 2026

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

risk: medium PR risk score: medium

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant