Skip to content

build: add public API dumps with binary-compatibility-validator - #843

Merged
nickolas-dimitrakas merged 1 commit into
mainfrom
build/api-dump-bcv
Oct 6, 2026
Merged

nickolas-dimitrakas merged 1 commit into
mainfrom
build/api-dump-bcv

Conversation

@nickolas-dimitrakas

Copy link
Copy Markdown
Contributor

Summary

Adds a committed, reviewable record of the public API surface of android-core and android-kit-base, and a check that fails when a change moves it.

  • Applies kotlinx binary-compatibility-validator 0.18.2 to both published modules and commits the generated dumps (android-core/api/android-core.api, android-kit-base/api/android-kit-base.api). BuildConfig is ignored; members annotated @RestrictTo are treated as non-public.
  • Runs ./gradlew apiCheck in the existing Unit Tests job, so a signature change fails the build until the dump is regenerated with ./gradlew apiDump and the diff is part of the pull request.
  • Adds scripts/check_api_dump.py, which compares the dumps against the base branch and classifies each changed class. A change to any class outside com.mparticle.internal, or to an internal class listed in scripts/api-frozen-internals.txt (classes kits import, classes resolved by name, classes named in proguard.pro), fails the job. Other internal changes are reported for review. The step is skipped when the pull request carries the api-change-approved label, the path for an intentional, reviewed API change; because the workflow does not run on label events, push a commit (or rebase) after labelling to re-run it.
  • Documents the commands in AGENTS.md.

No source or artifact changes. The dumps describe the compiled surface as it is on main today.

Why

The dump is the baseline for upcoming internal refactoring: it makes every accidental change to the compiled surface (a class or method becoming final, a static moving, an overload appearing) visible in review before it can ship.

Verification

  • ./gradlew apiDump on main produces 3,541 declarations for core and 499 for kit-base; ./gradlew apiCheck passes.
  • ./gradlew ktlintCheck passes.
  • Classifier self-test: removing a public method from AttributionError in the dump exits 2 (frozen); adding a method to internal.UserStorage exits 0 with a reviewable report; a base without dumps is treated as baseline creation and exits 0.

Follow-up

The api-change-approved label does not exist yet and needs to be created in the repository settings.

🤖 Generated with Claude Code

@github-actions

github-actions Bot commented Sep 24, 2026 •

Copy link
Copy Markdown

📦 SDK Size Impact Report

What the SDK adds to a minified release APK.

Measured against an empty baseline app. Unlike the Rokt kit, android-core ships no Compose and no resources, so there is nothing here that a host app would already provide.

mParticle Core SDK

Metric Target branch This PR Change
APK size 119.79 KB 119.79 KB +2 bytes
Download size 117.60 KB 117.60 KB +2 bytes
Dex bytes 213.75 KB 213.75 KB 0 bytes

➡️ SDK size impact change is minimal.

Raw measurements

Target branch:

{"baseline_dex_bytes": 0, "baseline_download_bytes": 2509, "baseline_install_bytes": 7523, "core_dex_bytes": 218884, "core_download_bytes": 122934, "core_install_bytes": 130185}

This PR:

{"baseline_dex_bytes": 0, "baseline_download_bytes": 2514, "baseline_install_bytes": 7530, "core_dex_bytes": 218884, "core_download_bytes": 122941, "core_install_bytes": 130194}

Measured 1d39db4 merged into eb2b44b

@nickolas-dimitrakas nickolas-dimitrakas self-assigned this Sep 24, 2026
@github-actions

github-actions Bot commented Sep 24, 2026 •

Copy link
Copy Markdown

📦 SDK Size Impact Report

What the SDK adds to a minified release APK.

Measured against a Compose + Material3 reference app, so these are the costs on top of an app that already ships Compose. The reference app's dependencies are a documented convention, not a measured average: see size-report-rokt/README.md.

mParticle Core + Rokt kit

Metric Target branch This PR Change
APK size 1.26 MB 1.26 MB 0 bytes
Download size 1.24 MB 1.24 MB +2 bytes
Dex bytes 2.22 MB 2.22 MB 0 bytes

Rokt SDK+ umbrella (adds the payment extension)

Metric Target branch This PR Change On top of mParticle Core + Rokt kit
APK size 6.53 MB 6.53 MB 0 bytes +5.27 MB
Download size 6.43 MB 6.43 MB -3 bytes +5.19 MB
Dex bytes 7.10 MB 7.10 MB 0 bytes +4.89 MB

➡️ SDK size impact change is minimal.

Raw measurements

Target branch:

{"baseline_dex_bytes": 1829108, "baseline_download_bytes": 1240062, "baseline_install_bytes": 1300934, "kit_dex_bytes": 4156052, "kit_download_bytes": 2540334, "kit_install_bytes": 2623275, "sdkplus_dex_bytes": 9278708, "sdkplus_download_bytes": 7978468, "sdkplus_install_bytes": 8148975}

This PR:

{"baseline_dex_bytes": 1829108, "baseline_download_bytes": 1240062, "baseline_install_bytes": 1300934, "kit_dex_bytes": 4156052, "kit_download_bytes": 2540336, "kit_install_bytes": 2623275, "sdkplus_dex_bytes": 9278708, "sdkplus_download_bytes": 7978465, "sdkplus_install_bytes": 8148975}

Measured 1d39db4 merged into eb2b44b

@cursor

cursor Bot commented Oct 6, 2026 •

Copy link
Copy Markdown

PR Summary

Low Risk
Build and CI configuration change only, introducing automated binary API surface tracking without affecting production runtime code.

Overview
Integrates the kotlinx.binary-compatibility-validator Gradle plugin into android-core and android-kit-base to automatically track and enforce public API consistency.

Adds baseline API signature dumps and integrates validation into the CI pull request workflow via ./gradlew apiCheck and a custom classifier script scripts/check_api_dump.py. The CI check prevents unauthorized modifications to public and frozen internal interfaces unless the PR is tagged with the api-change-approved label. Documentation for checking and regenerating dumps is also added to AGENTS.md.

Reviewed by Cursor Bugbot for commit 1d39db4. Bugbot is set up for automated code reviews on this repo. Configure here.

@nickolas-dimitrakas
nickolas-dimitrakas force-pushed the build/api-dump-bcv branch 2 times, most recently from 008250e to c08882b Compare October 6, 2026 21:04
Base automatically changed from test/testutils-visibility-seams to main October 6, 2026 21:45
Applies kotlinx binary-compatibility-validator to android-core and
android-kit-base and commits the generated API dumps. `./gradlew apiCheck`
now runs in the Unit Tests job and fails when the compiled public surface
differs from the committed dump, so every change to the surface is visible in
the pull request diff. A small classifier marks changes to frozen contracts:
any class outside com.mparticle.internal, plus the internal classes that kits
compile against or that android-core/proguard.pro names.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
@nickolas-dimitrakas
nickolas-dimitrakas merged commit 49124e4 into main Oct 6, 2026
44 of 45 checks passed
@nickolas-dimitrakas
nickolas-dimitrakas deleted the build/api-dump-bcv branch October 6, 2026 21:50
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.

2 participants