Skip to content

chore: mark non-public declarations @internal - #1671

Open
spydon wants to merge 1 commit into
mainfrom
chore/mark-internal-api
Open

chore: mark non-public declarations @internal#1671
spydon wants to merge 1 commit into
mainfrom
chore/mark-internal-api

Conversation

@spydon

@spydon spydon commented Aug 7, 2026

Copy link
Copy Markdown
Contributor

Summary

The capability matrix extractor treats every non-underscore name in lib/ as public API, without following exports:

Dart privacy is name-based, so a declaration is public when its name does not start with _. [...] Declarations annotated with @internal are excluded: the annotation is the canonical marker that a name is public by Dart's underscore rule but is not part of the package's public API.

So implementation plumbing in lib/src/ counted as public surface that had to be either registered in sdk-compliance.yaml or left as an unexplained gap. This marks that plumbing @internal. The repo already uses the annotation on individual members; this extends it to the declarations themselves.

Annotates 24 declarations:

Package Declarations
realtime_client Push, Hook, Message, Serializer, RetryTimer, Callback, TimerCallback, TimerCalculation
gotrue GotrueFetch, GotrueRequestOptions, RequestMethodType, ApiVersion, Constants, OAuthClientResponse, OAuthClientListResponse
storage_client Fetch, ToQueryParams, Constants
supabase AuthHttpClient, Counter, Constants
supabase_flutter SupabaseAuth, Constants
functions_client Constants

How the set was chosen

Not by eye. A declaration qualifies only if it is unreachable from its package's public library, resolving export directives transitively and honouring show/hide. That makes the annotation truthful rather than a judgement call, and keeps it analyzer-legal, since @internal on something in the public API is itself a diagnostic.

Candidates were then filtered against sdk-compliance.yaml. Annotating a class hides its members from the extractor too, so anything with registered symbols would silently break the drift check. That filter removed six:

Excluded Registered symbols
storage_client/StorageBucketApi 10 (createBucket, listBuckets, ...)
gotrue/GoTrueAdminCustomProvidersApi 7
gotrue/GoTrueAdminOAuthApi 6
gotrue/GoTrueAdminMFAApi 2
realtime_client/Constants 1 (defaultConnectionCloseTimeout)
realtime_client/ChannelFilter 1 (select)

Two more were excluded for being publicly reachable in ways a naive export scan misses:

  • storage_client/File is a conditional-import typedef used in StorageFileApi.upload signatures, so it is effectively public.
  • yet_another_json_isolate/YAJsonIsolate lives in _isolates_web.dart but is conditionally exported (if (dart.library.js_interop)), so it is the package's public entry point.

Effect

before after
Symbols reported as public API 1952 1831
Unregistered 1051 930
Matrix coverage 46.2% 49.2%

111 symbols stop being counted as public API. No symbol newly appears, and no registered symbol disappears.

This shrinks the backfill problem noted in #1670 by about a ninth. The remaining 930 are genuine public API that is simply unregistered; that is a separate task.

Test plan

  • dart analyze packages/: No issues found. This is the real gate: the analyzer reports invalid_internal_annotation for anything annotated inside a public API, and invalid_use_of_internal_member for cross-package use. Neither fires.
  • Independent cross-package reference sweep, not trusting the lint config alone. The only hits were Constants, which each package declares for itself; verified supabase_flutter/src/supabase.dart imports its own src/constants.dart, so that use is same-package.
  • check-drift against a freshly extracted surface: ✅ No capability matrix drift detected.
  • dart format packages/: 0 changed.
  • gotrue tests: +448 -23, identical to unmodified main (+448 -23). The 23 failures are integration tests needing a local GoTrue on localhost:9999 and are unrelated to this change, which is annotation-only and cannot affect runtime behaviour.

Note

functions_client gains a meta: ^1.16.0 dependency, which it did not previously have. Every other touched package already depended on it.

Summary by CodeRabbit

  • Refactor
    • Clarified API boundaries across authentication, storage, realtime, functions, and Flutter integrations.
    • Internal implementation details are now explicitly identified and excluded from the supported public API.
    • Added required metadata support for improved API visibility annotations.

The capability matrix extractor treats every non-underscore name in lib/ as
public API, without following exports. Plenty of implementation plumbing in
lib/src/ therefore counted as public surface that had to be either registered
in sdk-compliance.yaml or left as an unexplained gap. @internal is the marker
the extractor already honours for exactly this case, and the repo already uses
it on members; this extends it to the declarations themselves.

Annotates 24 declarations that are public by Dart's underscore rule but are
not reachable from their package's public library: HTTP plumbing (GotrueFetch,
Fetch, AuthHttpClient, GotrueRequestOptions, RequestMethodType, ApiVersion),
realtime transport internals (Push, Hook, Message, Serializer, RetryTimer and
their typedefs), per-package Constants, and a few helpers (Counter,
ToQueryParams, SupabaseAuth, the admin OAuth client response wrappers).

Deliberately excluded: anything with symbols registered in sdk-compliance.yaml
as capability evidence, since annotating those would hide them from the
extractor and break the drift check. That ruled out StorageBucketApi,
GoTrueAdminOAuthApi, GoTrueAdminCustomProvidersApi, GoTrueAdminMFAApi,
realtime's Constants and ChannelFilter. Also excluded File and YAJsonIsolate,
which are reachable publicly via conditional imports and exports.

functions_client gains a meta dependency, which it did not previously have.

Reported public surface drops from 1952 symbols to 1831.
@spydon
spydon requested a review from a team as a code owner August 7, 2026 14:25
@coderabbitai

coderabbitai Bot commented Aug 7, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: a8d2dfbd-b0bc-45ed-ba18-6e35c1a27697

📥 Commits

Reviewing files that changed from the base of the PR and between c6b5b35 and 5ccdb78.

📒 Files selected for processing (19)
  • packages/functions_client/lib/src/constants.dart
  • packages/functions_client/pubspec.yaml
  • packages/gotrue/lib/src/constants.dart
  • packages/gotrue/lib/src/fetch.dart
  • packages/gotrue/lib/src/gotrue_admin_oauth_api.dart
  • packages/gotrue/lib/src/types/api_version.dart
  • packages/gotrue/lib/src/types/fetch_options.dart
  • packages/realtime_client/lib/src/message.dart
  • packages/realtime_client/lib/src/push.dart
  • packages/realtime_client/lib/src/retry_timer.dart
  • packages/realtime_client/lib/src/serializer.dart
  • packages/storage_client/lib/src/constants.dart
  • packages/storage_client/lib/src/fetch.dart
  • packages/storage_client/lib/src/types.dart
  • packages/supabase/lib/src/auth_http_client.dart
  • packages/supabase/lib/src/constants.dart
  • packages/supabase/lib/src/counter.dart
  • packages/supabase_flutter/lib/src/constants.dart
  • packages/supabase_flutter/lib/src/supabase_auth.dart

📝 Walkthrough

Walkthrough

The PR adds @internal annotations to implementation-facing APIs across the SDK packages. It also adds the meta runtime dependency to functions_client.

Changes

Internal API visibility

Layer / File(s) Summary
Functions annotation support
packages/functions_client/lib/src/constants.dart, packages/functions_client/pubspec.yaml
Adds the meta dependency and marks Constants as internal.
GoTrue annotations
packages/gotrue/lib/src/constants.dart, packages/gotrue/lib/src/fetch.dart, packages/gotrue/lib/src/gotrue_admin_oauth_api.dart, packages/gotrue/lib/src/types/*
Marks GoTrue constants, fetch APIs, OAuth responses, API versions, and request options as internal.
Realtime annotations
packages/realtime_client/lib/src/message.dart, packages/realtime_client/lib/src/push.dart, packages/realtime_client/lib/src/retry_timer.dart, packages/realtime_client/lib/src/serializer.dart
Marks Realtime messages, push APIs, callbacks, hooks, retry timers, and serializers as internal.
Storage annotations
packages/storage_client/lib/src/constants.dart, packages/storage_client/lib/src/fetch.dart, packages/storage_client/lib/src/types.dart
Marks Storage constants, fetch APIs, and query parameter conversion as internal.
Supabase annotations
packages/supabase/lib/src/auth_http_client.dart, packages/supabase/lib/src/constants.dart, packages/supabase/lib/src/counter.dart, packages/supabase_flutter/lib/src/constants.dart, packages/supabase_flutter/lib/src/supabase_auth.dart
Marks Supabase and Supabase Flutter implementation declarations as internal.

Estimated code review effort: 2 (Simple) | ~10 minutes

Possibly related PRs

Suggested labels: v3

Suggested reviewers: tr00d

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and concisely describes the main change: marking non-public declarations with @internal.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch chore/mark-internal-api

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

This PR reduces the reported public API surface across the Supabase Flutter/Dart monorepo by marking implementation-only declarations in lib/src/ as @internal, so the capability-matrix extractor no longer treats them as supported public API.

Changes:

  • Annotated internal-only classes/typedefs/extensions in multiple packages with @internal (and added package:meta/meta.dart imports where needed).
  • Added a direct meta dependency to functions_client to support the new @internal usage there.
  • Kept analyzer legality intact (no invalid_internal_annotation / cross-package invalid_use_of_internal_member fallout per the PR test plan).

Reviewed changes

Copilot reviewed 19 out of 19 changed files in this pull request and generated no comments.

Show a summary per file
File Description
packages/supabase/lib/src/counter.dart Marks Counter as internal API via @internal.
packages/supabase/lib/src/constants.dart Marks Constants as internal API via @internal.
packages/supabase/lib/src/auth_http_client.dart Marks AuthHttpClient as internal API via @internal.
packages/supabase_flutter/lib/src/supabase_auth.dart Marks SupabaseAuth implementation plumbing as @internal.
packages/supabase_flutter/lib/src/constants.dart Marks Constants as internal API via @internal.
packages/storage_client/lib/src/types.dart Marks ToQueryParams extension as @internal.
packages/storage_client/lib/src/fetch.dart Marks Fetch as internal API via @internal.
packages/storage_client/lib/src/constants.dart Marks Constants as internal API via @internal.
packages/realtime_client/lib/src/serializer.dart Marks Serializer as internal API via @internal.
packages/realtime_client/lib/src/retry_timer.dart Marks reconnect timer typedefs + RetryTimer as @internal.
packages/realtime_client/lib/src/push.dart Marks Callback, Push, and Hook as @internal.
packages/realtime_client/lib/src/message.dart Marks Message as internal API via @internal.
packages/gotrue/lib/src/types/fetch_options.dart Marks GotrueRequestOptions as @internal.
packages/gotrue/lib/src/types/api_version.dart Marks ApiVersion as internal API via @internal.
packages/gotrue/lib/src/gotrue_admin_oauth_api.dart Marks OAuth admin response types as @internal.
packages/gotrue/lib/src/fetch.dart Marks RequestMethodType and GotrueFetch as @internal.
packages/gotrue/lib/src/constants.dart Marks Constants as internal API via @internal.
packages/functions_client/pubspec.yaml Adds meta dependency to support @internal.
packages/functions_client/lib/src/constants.dart Marks Constants as internal API via @internal.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

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