Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .claude/skills/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,5 @@
!btrace-perfetto/**
!check-code-attribution/
!check-code-attribution/**
!java-sdk-review/
!java-sdk-review/**
148 changes: 148 additions & 0 deletions .claude/skills/java-sdk-review/SKILL.md
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.
4 changes: 4 additions & 0 deletions agents.toml
Original file line number Diff line number Diff line change
Expand Up @@ -23,3 +23,7 @@ source = "path:.agents/skills/btrace-perfetto"
[[skills]]
name = "check-code-attribution"
source = "path:.agents/skills/check-code-attribution"

[[skills]]
name = "java-sdk-review"
source = "path:.agents/skills/java-sdk-review"
44 changes: 36 additions & 8 deletions warden.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,11 @@ version = 1
# getsentry Warden CI only provides WARDEN_OPENROUTER_API_KEY; pinning an
# anthropic/* model fails auth.

# Warden's schema does not support per-skill verification config; this is the only
# placement available. Disabled for attribution policy checks: a second verifier
# pass often rejects valid header/NOTICES mismatches (e.g. "NOTICES still documents it").
[defaults.verification]
enabled = false

# Warden's schema does not support per-skill chunking config; these patterns apply
# globally but are tuned for check-code-attribution. Attribution checks need the full
# file header and a NOTICES cross-check — not isolated diff hunks.
# to every skill. They were tuned for check-code-attribution, which needs the full
# file header and a NOTICES cross-check — not isolated diff hunks. java-sdk-review
# also benefits from whole files: its rules depend on fields, locks and callers
# outside the changed lines.
[[defaults.chunking.filePatterns]]
pattern = "**/*.api"
mode = "skip"
Expand Down Expand Up @@ -94,6 +90,11 @@ ignorePaths = [
"warden.toml",
]

# Disabled for attribution policy checks: a second verifier pass often rejects valid
# header/NOTICES mismatches (e.g. "NOTICES still documents it").
[skills.verification]
enabled = false

[[skills.triggers]]
type = "pull_request"
actions = ["opened", "synchronize"]
Expand All @@ -102,3 +103,30 @@ failCheck = false

[[skills.triggers]]
type = "local"

# sentry-java conventions and contracts that need reading beyond the changed lines.
# Rules that a model can check from one file belong in decision-model-linter instead.
[[skills]]
name = "java-sdk-review"

Copy link
Copy Markdown

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 trigger java-sdk-review, leaving the shipped Compose integration outside the Android and integration review rules.

Evidence
  • warden.toml filters this skill to **/src/main/**; src/androidMain/** does not match, and warden-findings.json records the skill being skipped with reason path_filter when changed paths do not match.
  • sentry-compose/build.gradle.kts configures androidMain as a production source set and applies the multiplatform publishing plugin; its public API is recorded under api/android.
  • SentryNavigationIntegration.kt is shipped under src/androidMain and implements Compose navigation lifecycle integration, which falls within the skill's Android and integration conventions.

Identified by Warden · code-review · E62-9UP

paths = ["**/src/main/**"]
ignorePaths = [
# Samples and test helpers ship no SDK API.
"sentry-samples/**",
"sentry-android-integration-tests/**",
"sentry-test-support/**",
"sentry-system-test-support/**",
]
incremental = true
maxTurns = 30
# Report only: Warden comments on PRs but does not block merges.
failOn = "off"
reportOn = "medium"

[[skills.triggers]]
type = "pull_request"
actions = ["opened", "synchronize", "reopened"]
requestChanges = false
failCheck = false

[[skills.triggers]]
type = "local"
Loading