From 6f510a3f7cb3d5d839d6f568d3476361a99e1833 Mon Sep 17 00:00:00 2001 From: Nelson Osacky Date: Tue, 1 Dec 2026 10:31:51 +0100 Subject: [PATCH 1/3] chore(ai): Add java-sdk-review Warden skill The org code-review skill only reports generic bugs and does not know sentry-java's conventions. java-sdk-review covers the SDK rules that need reading beyond the changed lines: concurrency, test coverage of new behavior, public API surface, Android and ProGuard, and integration lifecycle. It reports at medium and up and never blocks a merge. Verification moves from the defaults onto check-code-attribution, so the new skill keeps Warden's second verification pass. Co-Authored-By: Claude Opus 5.5 --- .claude/skills/.gitignore | 2 + .claude/skills/java-sdk-review/SKILL.md | 143 ++++++++++++++++++++++++ agents.toml | 4 + warden.toml | 44 ++++++-- 4 files changed, 185 insertions(+), 8 deletions(-) create mode 100644 .claude/skills/java-sdk-review/SKILL.md diff --git a/.claude/skills/.gitignore b/.claude/skills/.gitignore index 2dd55eba801..a48c6295384 100644 --- a/.claude/skills/.gitignore +++ b/.claude/skills/.gitignore @@ -10,3 +10,5 @@ !btrace-perfetto/** !check-code-attribution/ !check-code-attribution/** +!java-sdk-review/ +!java-sdk-review/** diff --git a/.claude/skills/java-sdk-review/SKILL.md b/.claude/skills/java-sdk-review/SKILL.md new file mode 100644 index 00000000000..cbab727465a --- /dev/null +++ b/.claude/skills/java-sdk-review/SKILL.md @@ -0,0 +1,143 @@ +--- +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. +- Formatting and import order (Spotless), the contents of generated `.api` files, PR title format, + or missing changelog entries (Danger). +- 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 + +- Each new branch or handled failure type in changed logic needs a test, including limit and + rejection paths such as oversized input being dropped. +- A `fix` PR needs a 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) needs equivalent tests in each. +- Auto-configuration guarded by a class or property condition needs a test for the "class missing, + feature enabled" case. +- 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. + +Only report a gap for customer-facing behavior. 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. diff --git a/agents.toml b/agents.toml index 04ad184c02c..a6582cc44ce 100644 --- a/agents.toml +++ b/agents.toml @@ -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" diff --git a/warden.toml b/warden.toml index f13067372ce..4702fc91eaa 100644 --- a/warden.toml +++ b/warden.toml @@ -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" @@ -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"] @@ -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" +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" From 9deba1b09de30290c2e4ec0d48dbea9992fc293b Mon Sep 17 00:00:00 2001 From: Nelson Osacky Date: Tue, 1 Dec 2026 10:40:36 +0100 Subject: [PATCH 2/3] chore(ai): Leave tool-decidable checks out of java-sdk-review Formatting, unused imports, and banned calls are decided by Spotless, detekt, Error Prone, and Android Lint. A model reviewing them only adds noise. Co-Authored-By: Claude Opus 5.5 --- .claude/skills/java-sdk-review/SKILL.md | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/.claude/skills/java-sdk-review/SKILL.md b/.claude/skills/java-sdk-review/SKILL.md index cbab727465a..3e936f55d30 100644 --- a/.claude/skills/java-sdk-review/SKILL.md +++ b/.claude/skills/java-sdk-review/SKILL.md @@ -14,8 +14,11 @@ 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. -- Formatting and import order (Spotless), the contents of generated `.api` files, PR title format, - or missing changelog entries (Danger). +- 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. From 0769693e1bc46ba9f1d5b907f904f67a811dfd44 Mon Sep 17 00:00:00 2001 From: Nelson Osacky Date: Tue, 1 Dec 2026 15:47:23 +0100 Subject: [PATCH 3/3] ref(skills): Narrow java-sdk-review test coverage findings A backtest on October and November PRs found 1 of 7 test coverage findings worth a comment. Report only behavior shipped with no test at all, fixes without a regression test, uneven sibling modules, and auto-configuration conditions the change adds itself. Co-Authored-By: Claude Opus 5.5 --- .claude/skills/java-sdk-review/SKILL.md | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/.claude/skills/java-sdk-review/SKILL.md b/.claude/skills/java-sdk-review/SKILL.md index 3e936f55d30..12327e48309 100644 --- a/.claude/skills/java-sdk-review/SKILL.md +++ b/.claude/skills/java-sdk-review/SKILL.md @@ -65,20 +65,22 @@ the Android main thread during app startup. ### Test coverage of new behavior -- Each new branch or handled failure type in changed logic needs a test, including limit and - rejection paths such as oversized input being dropped. -- A `fix` PR needs a regression test that would fail without the fix. If the diff does not make +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) needs equivalent tests in each. -- Auto-configuration guarded by a class or property condition needs a test for the "class missing, - feature enabled" case. + `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. -Only report a gap for customer-facing behavior. Internal refactors that keep behavior the same do -not need new tests. +Internal refactors that keep behavior the same do not need new tests. ### Public API surface