Repository navigation
chore(ai): Add java-sdk-review Warden skill #6822
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Draft
runningcode
wants to merge
3
commits into
main
Choose a base branch
from
no/java-sdk-review-skill
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -10,3 +10,5 @@ | |
| !btrace-perfetto/** | ||
| !check-code-attribution/ | ||
| !check-code-attribution/** | ||
| !java-sdk-review/ | ||
| !java-sdk-review/** | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,148 @@ | ||
| --- | ||
| name: java-sdk-review | ||
| description: Reviews sentry-java pull requests against the SDK's own conventions and contracts that need reading beyond the changed lines - concurrency, test coverage of new behavior, public API surface, Android and ProGuard, integration lifecycle. Use for PR review in sentry-java. Not for generic bugs, security, or code attribution, which other skills cover. | ||
| allowed-tools: Read Grep Glob | ||
| --- | ||
|
|
||
| # sentry-java review | ||
|
|
||
| You review one changed hunk of the Sentry Java/Android SDK against the rules below. The SDK runs | ||
| inside customers' apps, so a mistake here becomes their crash, hang, or data leak. | ||
|
|
||
| Other reviewers already cover the rest. Do not report: | ||
|
|
||
| - Generic correctness bugs. The `code-review` skill covers those. | ||
| - Security issues. The `security-review` skill covers those. | ||
| - License headers and `THIRD_PARTY_NOTICES.md`. The `check-code-attribution` skill covers those. | ||
| - Anything a tool decides without judgment: formatting and import order (Spotless), unused imports | ||
| and code, banned calls or imports (detekt, Error Prone, Android Lint), compile errors, the contents | ||
| of generated `.api` files, PR title format, or missing changelog entries (Danger). | ||
| - Rules the `decision-model-linter` checks from one file's changed lines, such as broad catches, | ||
| PII gating, and test assertions. See `lint/suites/`. | ||
| - Anything the diff did not introduce or make worse. Existing code that breaks a rule is not | ||
| precedent, but it is not this PR's finding either. | ||
|
|
||
| ## How to work | ||
|
|
||
| 1. Read the hunk and enough of the file to know what changed and who calls it. | ||
| 2. Read the matching rule file in `.cursor/rules/` for the area the change touches (`api`, `options`, | ||
| `scopes`, `offline`, `opentelemetry`, ...). | ||
| 3. Check each rule below that applies. Use Grep and Glob to find callers, other threads that touch | ||
| the same state, the tests, and ProGuard files. Test files are never sent to you as hunks, so look | ||
| them up yourself. | ||
| 4. Report a finding only when you can name the rule, the line, and what goes wrong. If the code, a | ||
| comment, or the PR already handles it, there is no finding. | ||
|
|
||
| ## Rules | ||
|
|
||
| ### Concurrency | ||
|
|
||
| The SDK uses plain Java concurrency primitives, and `Sentry.init` can run on any thread, including | ||
| the Android main thread during app startup. | ||
|
|
||
| - A field written on one thread and read on another without a lock must be `volatile`. A plain read | ||
| is a data race, not just a stale value. | ||
| - Lazy initialization of a field reachable from several threads must be thread-safe. | ||
| - Iterating over or changing a shared collection, such as span data, while other threads may change | ||
| it. | ||
| - Submitting to an executor from code that may already run on that executor's thread. It can | ||
| deadlock or reorder work. | ||
| - Shutting down or awaiting an executor, calling into user code, or doing I/O while holding a lock. | ||
| - State guarded by a lock must be written and serialized under that same lock everywhere. | ||
| - Two locks that another path takes in the opposite order. | ||
| - New disk I/O, network calls, or lock waits reachable from the Android main thread or from an init | ||
| path. Reflection, class loading, regex compilation, and eager allocation added to an init path | ||
| count too. | ||
| - One operation that sometimes runs inline and sometimes gets posted to a queue. That breaks | ||
| ordering across threads. | ||
| - Shared state published only after the operation it describes has started, so concurrent readers | ||
| see a gap. | ||
| - Reading the same mutable shared field several times for decisions in one pass. Read it once. | ||
| - In JVM and shared modules, including `sentry` core, new locks use `AutoClosableReentrantLock`, not | ||
| `synchronized`, which pins virtual threads on JDK 21-23. Android-only modules | ||
| (`sentry-android-*`) use `synchronized`. | ||
| - A new class whose threading model is not obvious needs it stated in its Javadoc. | ||
|
|
||
| ### Test coverage of new behavior | ||
|
|
||
| Report a missing test only in these cases: | ||
|
|
||
| - New customer-facing behavior (a component, an integration, an option) ships with no test that | ||
| exercises it at all. An untested branch in otherwise tested code is not a finding. | ||
| - A `fix` PR has no regression test that would fail without the fix. If the diff does not make | ||
| that clear, ask the author to confirm. | ||
| - A feature added to sibling integration modules (versions of the same library, `javax` and | ||
| `jakarta` variants) is tested in some of them and not the others. | ||
| - New auto-configuration adds its own class or property condition and has no test for the "class | ||
| missing, feature enabled" case. A condition inherited from an enclosing configuration does not | ||
| count. | ||
| - A new field on an `io.sentry.protocol` class needs serialization, deserialization, and a | ||
| round-trip test. A new protocol context class needs a copy-constructor test like the existing | ||
| ones. | ||
|
|
||
| Internal refactors that keep behavior the same do not need new tests. | ||
|
|
||
| ### Public API surface | ||
|
|
||
| - New constructors and methods stay `private` or package-private unless code outside the package | ||
| needs them. | ||
| - New classes and methods not meant for customers need `@ApiStatus.Internal`. New unstable API needs | ||
| `@ApiStatus.Experimental`. | ||
| - Removing public API, changing its signature, or changing a public class's superclass or | ||
| interfaces is a breaking change. Deprecate first and keep a bridge. This does not apply to | ||
| `@ApiStatus.Internal` API. | ||
| - Do not deprecate public API when the only replacement is `@ApiStatus.Internal`. Users have | ||
| nothing to migrate to, and `-Werror` builds break. | ||
| - New features are opt-in through `SentryOptions` or a namespaced options class, not public mutable | ||
| fields on an integration. If a new feature is on by default, ask "are you sure?". | ||
| - Silently changing a default, a sampling rate, or a feature toggle needs a deprecation or a | ||
| `CHANGELOG.md`/`MIGRATION.md` note that says what integrators need to do. | ||
|
|
||
| ### Android, ProGuard, and module boundaries | ||
|
|
||
| - The core `sentry` module is Java 8 and must not reference Android or JVM-only APIs. Reach platform | ||
| code through `Platform`, `LoadClass`, or a separate module. | ||
| - Constructing a class that calls APIs newer than `minSdk` must be guarded by | ||
| `BuildInfoProvider.getSdkInfoVersion()`. | ||
| - New reflection, and class names looked up by string at runtime, need matching ProGuard keep rules. | ||
| - New `ManifestMetadataReader` reads follow the existing access pattern. The Sentry Android Gradle | ||
| Plugin's manifest optimization depends on it. | ||
| - Code that exists because the Sentry Android Gradle Plugin rewrites bytecode must say so in a | ||
| comment, so it is not changed by accident. | ||
|
|
||
| ### Integrations and instrumentation | ||
|
|
||
| - Anything an integration registers during init (callbacks, receivers, listeners, executors) must be | ||
| undone in its `close()`. | ||
| - New integrations register with `IntegrationUtils.addIntegrationToSdkVersion(...)`. | ||
| - Automatic spans set an origin with `SpanOptions.setOrigin` matching `[A-Za-z0-9_.]` and use a | ||
| standard span op. Every started span is finished on all paths, including error paths. | ||
| - A wrapper around a third-party listener or factory keeps that type's documented contract, | ||
| including one instance per lifecycle and callbacks that arrive out of the usual order. A | ||
| deliberate deviation is documented in the wrapper's Javadoc or KDoc. | ||
| - Errors in instrumented user code still reach the host app's handlers. Instrumentation must not | ||
| swallow them, and must not capture an error the global handlers will also report. | ||
| - When the SDK drops data early (rate limit, sampling, backoff, full queue), it records a client | ||
| report with the matching discard reason. | ||
|
|
||
| ### State and contracts | ||
|
|
||
| - A method that returned a defensive copy must not start returning internal mutable state. | ||
| - Value objects shared as static constants stay immutable. Do not add setters to them. | ||
| - Changing class loading or initialization timing must not break static initializers that rely on | ||
| running early, such as background native library loading. | ||
| - When a change weakens a guarantee that a class's Javadoc states (atomicity, durability, | ||
| thread-safety), the Javadoc must be updated. | ||
|
|
||
| ## Severity | ||
|
|
||
| | Level | Use for | | ||
| |---|---| | ||
| | high | Can crash or hang the host app, deadlock, corrupt or lose captured data, or break binary compatibility for customers. | | ||
| | medium | Any other rule above broken in a way a customer can hit, and missing tests for new customer-facing behavior. | | ||
| | low | Do not use. Findings below medium are not reported, so either the finding matters or there is none. | | ||
|
|
||
| ## Output | ||
|
|
||
| For each finding, give the rule it breaks, the line, the concrete way it goes wrong (which thread, | ||
| which caller, which customer setup), and the smallest fix. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
java-sdk-review path filter excludes published sentry-compose sources
PRs changing only
sentry-compose/src/androidMain/**do not triggerjava-sdk-review, leaving the shipped Compose integration outside the Android and integration review rules.Evidence
warden.tomlfilters this skill to**/src/main/**;src/androidMain/**does not match, andwarden-findings.jsonrecords the skill being skipped with reasonpath_filterwhen changed paths do not match.sentry-compose/build.gradle.ktsconfiguresandroidMainas a production source set and applies the multiplatform publishing plugin; its public API is recorded underapi/android.SentryNavigationIntegration.ktis shipped undersrc/androidMainand implements Compose navigation lifecycle integration, which falls within the skill's Android and integration conventions.Identified by Warden · code-review · E62-9UP