diff --git a/CHANGELOG.md b/CHANGELOG.md
index 0349546..eb5efd4 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -20,6 +20,62 @@ joined this list.)
## Unreleased
+### Added
+
+- **Remote Config inspector** ([#6](https://github.com/devconsole-android/DevConsole/issues/6)).
+ Read-only view of the Remote Config values active on the device, with the attribution that makes
+ them diagnosable: whether each value came from the server, an in-app default, the SDK's static
+ fallback, or a local override — plus last fetch time, last fetch status, and minimum fetch
+ interval. A key serving a default because the fetch was throttled is otherwise indistinguishable
+ from one you actually published.
+
+ Three new modules following the existing push triad: `devconsole-remote-config` (vendor-neutral
+ model and registry), `devconsole-remote-config-firebase` (reads `FirebaseRemoteConfig` by
+ reflection, so Firebase stays off the classpath of consumers that do not use it), and
+ `devconsole-remote-config-firebase-noop` (the protected-build twin, which reports
+ `disabled-build` rather than pretending config is simply empty). Neither adapter is re-exported by
+ the `devconsole` umbrella.
+
+ Surfaces on both the browser dashboard (a Remote Config page under Data) and the Compose
+ inspector's Observe screen (a **Config** tab, shown only when a provider is registered, since the
+ on-device tab row splits its width equally and should not spend a tab on an app with no Remote
+ Config), and over `GET /api/v1/remote-config`. Gated by the existing
+ `CaptureCategory.STATE`, alongside state providers and feature flags. Register a provider with
+ `DevConsoleConfig.withRemoteConfigProviders(...)` or, for a lazily-built client,
+ `DevConsole.registerRemoteConfigProvider(...)`. Read-only by design: DevConsole does not set
+ overrides and never triggers `fetch()`/`activate()`. See
+ [docs/REMOTE_CONFIG.md](docs/REMOTE_CONFIG.md).
+
+ A config value is a string of any length, so the tables show a preview and open the full value on
+ demand: click a key on the dashboard, tap a row on the Config tab. Both default to pretty-printed
+ JSON and fall back to the raw string with a toggle between them — a value like `on` or `v2` is
+ never re-quoted to make it parse, since the quotes would be the viewer's invention rather than
+ something the server sent, and a truncated or redacted value says so rather than failing to parse
+ for an unexplained reason.
+
+ Values are redacted by key name at a single boundary shared by both surfaces — the on-device
+ inspector reads in-process and never crosses the HTTP boundary, so redacting at the route alone
+ would have left it exposed. Matching is separator-insensitive here, unlike the raw
+ `RedactionPolicy`, whose defaults are an HTTP-header list compared by exact name: `api_key` and
+ `apiKey` now match the policy's `api-key` instead of being displayed in full.
+
+### Fixed
+
+- **State providers no longer race their readers.** `StateRegistry` held a plain `LinkedHashMap`
+ read without a lock, so a host registering a provider late — through
+ `DevConsole.registerStateProvider`, which is a documented path — while the dashboard's server
+ thread or the in-app inspector was iterating could throw `ConcurrentModificationException` into
+ the app being debugged. Every access is guarded now, and the insertion order surfaces list
+ providers in is preserved. `RemoteConfigRegistry` had the same shape and got the same fix before
+ it ever shipped.
+
+- **Re-initializing replaces registered providers instead of silently keeping the old ones.** Both
+ registries reject a duplicate id, and neither was cleared between `initialize()` calls, so a
+ `stop()` → `initialize(...)` carrying a replacement provider under the same id had its
+ registration refused — leaving every surface reading through the torn-down original. Both are now
+ cleared as part of the same per-init reset, and a duplicate id within one config is ignored rather
+ than thrown out of `initialize()` (state providers previously threw; Remote Config already did not).
+
## 1.1.1 — 2026-08-12
A build-and-distribution patch: no SDK code changed, and the public API is byte-for-byte the
diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md
index eaf9c2c..9bb6417 100644
--- a/CONTRIBUTING.md
+++ b/CONTRIBUTING.md
@@ -1,6 +1,6 @@
# Contributing to DevConsole
-Thanks for taking a look. This is a 31-module Android SDK plus two included Gradle builds
+Thanks for taking a look. This is a 34-module Android SDK plus two included Gradle builds
(`build-logic` and `gradle-plugin`), which sounds like a lot until you realise you rarely touch more
than one at a time. The quickest way in is to run the same commands CI runs, listed below and in
[Verify](.github/workflows/verify.yml).
diff --git a/README.md b/README.md
index ac72de3..cacdfe3 100644
--- a/README.md
+++ b/README.md
@@ -101,6 +101,7 @@ gets you nothing.
| **Crash & ANR capture** | Uncaught exceptions and a main-looper watchdog with bounded all-thread dumps and breadcrumbs. Always delegates to any crash reporter you already have. |
| **Push timeline** | Record FCM (or any) push messages and their lifecycle: received → displayed → opened. The Firebase adapter uses reflection — no compile-time Firebase dependency. |
| **State & feature flags** | Snapshot host-registered state and override feature flags from the browser. |
+| **Remote Config inspector** | Every Remote Config value active on the device, and where each one came from — server, in-app default, static fallback, or a local override — plus last fetch time and status. Read-only. The Firebase adapter uses reflection — no compile-time Firebase dependency. |
| **Data inspectors** | Browse SharedPreferences, SQLite (incl. a SQL console), and app files. Read-only by default; every edit surface is opt-in. |
| **Evidence tray & exports** | Flag anything, attach it to a bug report bundle or Markdown/Jira/GitHub clipboard text. Export HAR, Postman Collection, or a full session ZIP. |
| **Background keep-alive** | Opt-in foreground service that keeps the server alive while your app is backgrounded. Manifest-only opt-in, zero SDK-declared permissions. |
@@ -281,6 +282,63 @@ you can replay it, clone it into the composer, or flag it into a bug report:
+### Set up Remote Config
+
+Add the adapter — it is not part of the `devconsole` umbrella, so that Firebase never lands on the
+classpath of an app that doesn't use it:
+
+```kotlin
+debugImplementation("io.github.devconsole-android:devconsole-remote-config-firebase:1.2.0")
+releaseImplementation("io.github.devconsole-android:devconsole-remote-config-firebase-noop:1.2.0")
+```
+
+> These two artifacts are new: `1.1.1` predates them, and `1.2.0` is the release they first ship in.
+> To try them before that lands, take them off the branch through
+> [JitPack](#jitpack-for-unreleased-code).
+
+Then hand DevConsole your `FirebaseRemoteConfig` instance at init:
+
+```kotlin
+DevConsole.initialize(
+ application,
+ DevConsoleConfig(/* … */)
+ .withRemoteConfigProviders(listOf(FirebaseRemoteConfigAdapter(Firebase.remoteConfig))),
+)
+```
+
+If the client is built lazily — through DI, or only once a first fetch completes — register it when
+you have it. This is safe to call late, unlike feature flags, because values are read on demand
+rather than snapshotted at startup:
+
+```kotlin
+DevConsole.registerRemoteConfigProvider(FirebaseRemoteConfigAdapter(Firebase.remoteConfig))
+```
+
+That's the whole setup. Values then appear on the dashboard's **Remote Config** page and on the
+in-app inspector's **Config** tab, each tagged with where it came from:
+
+| Source | Meaning |
+|---|---|
+| `remote` | Fetched from the server and activated. |
+| `default` | An in-app default (`setDefaultsAsync`) — no server value is active for this key. |
+| `static` | Set nowhere — the SDK's static fallback for an unknown key. |
+| `override` | A local override is masking whatever the provider resolved. |
+
+That last column is the reason this inspector exists. Knowing a flag reads `false` is rarely the
+hard part; knowing whether it reads `false` because you published it, or because the last fetch was
+throttled and the app quietly fell back to a default, is. Each provider also reports its last fetch
+time, last fetch status, and minimum fetch interval — and a provider that has never fetched says
+`never`, rather than showing an epoch date.
+
+Not using Firebase? Implement `RemoteConfigProvider` for any other service — the model is
+vendor-neutral, and [docs/REMOTE_CONFIG.md](docs/REMOTE_CONFIG.md) has a worked example. The
+inspector is read-only: DevConsole never sets overrides and never triggers `fetch()` or `activate()`.
+
+Values are redacted by key name before either surface sees them, matched separator-insensitively so
+`api_key` and `apiKey` are caught as well as `api-key`. It is still an allowlist, so a secret under
+a name nobody listed is shown in full — extend `RedactionPolicy.sensitiveFieldNames` if you keep
+anything sensitive in Remote Config.
+
## Artifacts
Group `io.github.devconsole-android`, one version for everything. There is deliberately no BOM, and
@@ -300,6 +358,7 @@ Opt-in add-ons (each `-noop` twin is the matching `releaseImplementation`):
| `devconsole-network-ktor` | *(none)* | Ktor `HttpClient` capture plugin (full request + response body capture, any engine; see [Network adapters](docs/NETWORK_ADAPTERS.md)) |
| `devconsole-socket-paho` | `devconsole-socket-paho-noop` | MQTT capture via Eclipse Paho |
| `devconsole-push-firebase` | `devconsole-push-firebase-noop` | FCM push adapter (reflection-based) |
+| `devconsole-remote-config-firebase` | `devconsole-remote-config-firebase-noop` | Firebase Remote Config adapter (reflection-based; see [Remote Config](docs/REMOTE_CONFIG.md)) |
Everything else (`devconsole-core`, `devconsole-storage-room`, and the rest) arrives transitively.
You never name those. Every module publishes sources, javadoc, and a signed POM.
@@ -332,7 +391,7 @@ A release tag works as the bare tag, as above. Any branch works as `-SNA
written as `~`, so a `feature/x` branch is `feature~x-SNAPSHOT`. JitPack support starts at
**1.1.1**; earlier tags do not build there. Three things to know before you rely on it:
-- **The Gradle plugin is not on JitPack.** Only the 31 library artifacts are, so the
+- **The Gradle plugin is not on JitPack.** Only the 34 library artifacts are, so the
`plugins { id("io.github.devconsole-android") … }` block above does not apply. Name the
`debugImplementation` and `releaseImplementation` coordinates yourself. You also give up the
plugin's variant-policy check, which is the thing that keeps the full SDK out of release builds.
@@ -437,6 +496,7 @@ Full index: [docs/README.md](docs/README.md). Highlights:
[Push](docs/PUSH.md)
- [Data inspectors and exports](docs/DATA_INSPECTORS_AND_EXPORTS.md) ·
[Evidence and bug reports](docs/EVIDENCE_AND_BUG_REPORTS.md)
+- [State and feature flags](docs/STATE_AND_FLAGS.md) · [Remote Config](docs/REMOTE_CONFIG.md)
- [Crash and ANR capture](docs/CRASH_AND_ANR.md) ·
[Background keep-alive](docs/BACKGROUND_KEEPALIVE.md)
- [FAQ / troubleshooting](docs/FAQ_TROUBLESHOOTING.md)
diff --git a/docs/MAVEN_PUBLISHING.md b/docs/MAVEN_PUBLISHING.md
index cf7b052..b42e484 100644
--- a/docs/MAVEN_PUBLISHING.md
+++ b/docs/MAVEN_PUBLISHING.md
@@ -1,6 +1,6 @@
# Publishing to Maven Central
-All 31 modules under `sdk/` are wired with the
+All 34 modules under `sdk/` are wired with the
[Vanniktech Maven Publish plugin](https://github.com/vanniktech/gradle-maven-publish-plugin)
(via the `devconsole.publishing` convention), targeting the Sonatype **Central Portal** under the
group `io.github.devconsole-android`. Artifact IDs follow the mapping in
@@ -117,6 +117,6 @@ that registers `.asc` artifacts fails there with "artifact file does not exist".
`PublishingConventionPlugin` calls `signAllPublications()` only when a key is configured — the same
condition that lets a contributor run `publishToMavenLocal` without one.
-Only the 31 library modules are served; `gradle-plugin` is an `includeBuild` and is not among them,
+Only the 34 library modules are served; `gradle-plugin` is an `includeBuild` and is not among them,
so JitPack consumers use plain coordinates rather than the plugin. Check a build at
`https://jitpack.io/api/builds/com.github.devconsole-android/DevConsole`.
diff --git a/docs/PROTOCOL_REFERENCE.md b/docs/PROTOCOL_REFERENCE.md
index ed63770..507cc07 100644
--- a/docs/PROTOCOL_REFERENCE.md
+++ b/docs/PROTOCOL_REFERENCE.md
@@ -210,6 +210,15 @@ accepted since surrounding quotes are trimmed). `FeatureFlagType` has two member
allowed values the declared option set) — see [STATE_AND_FLAGS.md](STATE_AND_FLAGS.md#flags-with-named-options-environment-switching)
for the named-options use case (environment/account-tier switching).
+### Remote Config
+
+`GET /api/v1/remote-config` (auth). Read-only; there is no write route. Returns one object per
+registered provider: `id`, `fetch` (`lastFetchEpochMs` — **null**, never a sentinel, when no fetch
+has completed — plus `status` and `minimumFetchIntervalSeconds`), `unavailableReason`, and `entries`
+(`key`, `value`, `source`, `redacted`, `truncated`). `source` is one of `remote`, `default`,
+`static`, `override`, `unknown`. Gated by the `state` capture category, the same one that covers
+state providers and feature flags. See [REMOTE_CONFIG.md](REMOTE_CONFIG.md).
+
### Composer
`POST /api/v1/composer/execute` (auth — one-off request; `method` restricted to
diff --git a/docs/README.md b/docs/README.md
index c7fc3b0..94c7a7d 100644
--- a/docs/README.md
+++ b/docs/README.md
@@ -28,6 +28,7 @@ read one page here, make it the threat model, especially before you put the dash
- [Composer and mocks](COMPOSER_AND_MOCKS.md)
- [Push](PUSH.md)
- [State and feature flags](STATE_AND_FLAGS.md)
+- [Remote Config](REMOTE_CONFIG.md)
- [Crash and ANR capture](CRASH_AND_ANR.md) — all-thread dumps, breadcrumbs, `CrashPolicy`, and the
Crashes surface on both web and Android
- [Data inspectors, exports, and the More screen](DATA_INSPECTORS_AND_EXPORTS.md) — preferences,
diff --git a/docs/REMOTE_CONFIG.md b/docs/REMOTE_CONFIG.md
new file mode 100644
index 0000000..72e3fe2
--- /dev/null
+++ b/docs/REMOTE_CONFIG.md
@@ -0,0 +1,145 @@
+# Remote Config
+
+A read-only view of the Remote Config values active on the device: every key, its current value, and
+— the part that actually matters — **where that value came from**.
+
+Knowing a flag reads `false` is rarely the hard part. The hard part is knowing whether it reads
+`false` because that is what you published, or because the last fetch was throttled and the app fell
+back to an in-app default. Those two situations look identical from inside the app and are the
+difference between "the rollout works" and "the rollout never reached this device".
+
+## Registering a provider
+
+```kotlin
+DevConsole.initialize(
+ application,
+ DevConsoleConfig(/* … */)
+ .withRemoteConfigProviders(listOf(FirebaseRemoteConfigAdapter(Firebase.remoteConfig))),
+)
+```
+
+`FirebaseRemoteConfigAdapter` takes the `FirebaseRemoteConfig` instance as `Any` and reads it by
+reflection, so DevConsole has **no compile-time Firebase dependency** — Firebase stays off the
+classpath of consumers that do not use this adapter, exactly like `FirebaseRemoteMessageAdapter` for
+Cloud Messaging. Add the adapter coordinate yourself; it is deliberately not re-exported by the
+`devconsole` umbrella.
+
+```kotlin
+debugImplementation("io.github.devconsole-android:devconsole-remote-config-firebase:")
+releaseImplementation("io.github.devconsole-android:devconsole-remote-config-firebase-noop:")
+```
+
+A provider constructed later — through DI, or after a first fetch completes — can register itself:
+
+```kotlin
+DevConsole.registerRemoteConfigProvider(FirebaseRemoteConfigAdapter(Firebase.remoteConfig))
+```
+
+Late registration is supported here (unlike feature flags) because snapshots are pulled on demand
+rather than captured at startup, so there is no race with a dashboard that already read an earlier
+list. It returns `false` when the runtime is disabled or `CaptureCategory.STATE` is off.
+
+## Value sources
+
+| Source | Meaning |
+| --- | --- |
+| `remote` | Fetched from the server and activated. |
+| `default` | An in-app default (`setDefaultsAsync`); no server value is active for this key. |
+| `static` | Set nowhere — the SDK's static fallback for an unknown key. |
+| `override` | A local override is masking whatever the provider resolved. |
+| `unknown` | The provider could not attribute the value. Never guessed at. |
+
+Alongside the values, each provider reports its last fetch time, last fetch status (`success`,
+`no_fetch_yet`, `failure`, `throttled`, `unknown`), and configured minimum fetch interval. A provider
+that has never fetched reports a **null** timestamp and is rendered as "never" — never as an epoch
+date.
+
+## Another Remote Config vendor
+
+The model is vendor-neutral. Implement `RemoteConfigProvider` for any other service:
+
+```kotlin
+class ConfigCatProvider(private val client: ConfigCatClient) : RemoteConfigProvider {
+ override val id = "configcat"
+
+ override fun snapshot() = RemoteConfigSnapshot(
+ providerId = id,
+ entries = client.allValues().map { (key, value) ->
+ RemoteConfigEntry(key, value.toString(), RemoteConfigSource.REMOTE)
+ },
+ fetchInfo = RemoteConfigFetchInfo(
+ lastFetchEpochMs = client.lastRefreshMillis(),
+ status = RemoteConfigFetchStatus.SUCCESS,
+ minimumFetchIntervalSeconds = null,
+ ),
+ )
+}
+```
+
+`RemoteConfigRegistry` normalizes whatever you return: it caps values at 8 KB (setting
+`truncated`), forces the registered id onto the snapshot, and — because a debugging tool must never
+crash the app it exists to observe — converts a provider that throws into an `unavailableReason`
+rather than propagating the exception.
+
+## Redaction
+
+Values are redacted by key name at a single boundary in `:sdk:full`, so the browser dashboard and the
+on-device inspector both receive already-redacted entries. The key itself is never redacted: knowing
+*which* value was withheld is the point of the view.
+
+Matching is separator-insensitive, which the raw `RedactionPolicy` is not. Its
+`sensitiveFieldNames` defaults are an HTTP-header list (`api-key`, `apikey`) compared by exact name,
+while Remote Config keys are written snake_case and camelCase — so `api_key` and `apiKey` are matched
+against the policy's `api-key` here, instead of being displayed in full. Values are also run through
+the engine's text patterns, so a bearer token pasted into an otherwise innocuous key is still caught.
+
+This remains allowlist-based: a key holding a secret under a name nobody thought to list is still
+shown. Add your own names through `RedactionPolicy.sensitiveFieldNames`.
+
+## Dashboard and inspector
+
+The browser dashboard's **Remote Config** page (under Data, next to State & flags) lists each
+provider with its fetch line and a Key / Value / Source table, filterable by key and by source. The
+Compose inspector shows the same data on the **Config** tab of its Observe screen. That tab appears
+only when at least one provider is registered — the on-device tab row splits its width equally
+between tabs, so it does not spend one on an app that has no Remote Config.
+
+Both distinguish four states explicitly rather than rendering a blank table: no provider registered,
+capture category disabled, provider unavailable, and "fetched nothing / never fetched".
+
+### Reading a value in full
+
+A Remote Config value is a string of any length, so both surfaces show only a preview in the table
+and open the whole value on demand: click a key in the dashboard for a value window, or tap a row on
+the Config tab for the key's detail screen.
+
+Both default to pretty-printed JSON and fall back to the raw string, with a toggle between the two.
+The fallback is deliberate — plenty of values are plain strings like `on` or `v2`, and neither
+surface will re-quote one to make it parse, because the quotes would be the viewer's invention
+rather than something the server sent. A value that was truncated on capture, or withheld by
+redaction, says so instead of failing to parse for an unexplained reason.
+
+## Scope
+
+This inspector is **read-only**. DevConsole does not set overrides and does not trigger `fetch()` or
+`activate()` — it observes the Remote Config lifecycle rather than driving it. The `override` source
+is displayed when a host has applied one of its own.
+
+## REST
+
+`GET /api/v1/remote-config` (auth required, gated by `CaptureCategory.STATE`) returns every
+provider's snapshot:
+
+```json
+{"data":[{
+ "id":"firebase",
+ "fetch":{"lastFetchEpochMs":1755043200000,"status":"success","minimumFetchIntervalSeconds":3600},
+ "unavailableReason":null,
+ "entries":[
+ {"key":"checkout_v2","value":"true","source":"remote","redacted":false,"truncated":false}
+ ]
+}]}
+```
+
+See [PROTOCOL_REFERENCE.md](PROTOCOL_REFERENCE.md) and
+[STATE_AND_FLAGS.md](STATE_AND_FLAGS.md) for the neighbouring surfaces.
diff --git a/docs/STATE_AND_FLAGS.md b/docs/STATE_AND_FLAGS.md
index af1f08c..e402b01 100644
--- a/docs/STATE_AND_FLAGS.md
+++ b/docs/STATE_AND_FLAGS.md
@@ -64,6 +64,12 @@ The State & Flags page shows a provider tree with sensitivity badges, and a flag
source/default/current/override columns plus a "reset all session overrides" command. Every flag
change produces both a command-audit record and a timeline event with the before/after values.
+## Remote Config
+
+Values fetched from a Remote Config service are inspected separately, with source attribution
+(remote / default / static / override) and fetch metadata — see [REMOTE_CONFIG.md](REMOTE_CONFIG.md).
+It shares the `CaptureCategory.STATE` gate with everything on this page.
+
## Flags with named options (environment switching)
A flag is not limited to on/off. `FeatureFlag.ofOptions` declares a set of named values, which is
diff --git a/docs/superpowers/specs/2026-08-13-remote-config-inspector-design.md b/docs/superpowers/specs/2026-08-13-remote-config-inspector-design.md
new file mode 100644
index 0000000..90bebe0
--- /dev/null
+++ b/docs/superpowers/specs/2026-08-13-remote-config-inspector-design.md
@@ -0,0 +1,335 @@
+# Remote Config Inspector
+
+Date: 2026-08-13
+Status: Approved design
+Issue: [#6 — Add Remote Config Inspector to DevConsole](https://github.com/devconsole-android/DevConsole/issues/6)
+
+## Summary
+
+Add a read-only Remote Config inspector to DevConsole: every fetched Remote Config key, its current
+value, and the source that value came from (remote server, in-app default, SDK static fallback, or a
+local override), alongside fetch metadata (last fetch time, last fetch status, minimum fetch
+interval).
+
+The feature ships as a vendor-neutral core module plus a Firebase adapter that carries no
+compile-time Firebase dependency, following the existing `push` / `push-firebase` /
+`push-firebase-noop` triad exactly. Both DevConsole surfaces render it: the browser dashboard gets a
+new rail view, and the Compose inspector gets a section on its Control screen.
+
+## Problem
+
+There is no way to see Remote Config state from DevConsole today — grep finds zero references to
+Remote Config anywhere in the repository. A developer or QA engineer verifying a feature flag on a
+device has to fall back to logcat or a purpose-built debug screen in the host app.
+
+The specific question that is hard to answer without this is not "what is the value" but **"why is it
+that value"** — whether a key is showing the remote value the console published, or has silently
+fallen back to an in-app default because the fetch failed or was throttled. That distinction is the
+difference between "the rollout works" and "the rollout never reached this device."
+
+## Goals
+
+- List every Remote Config key currently active on the device with its value and source attribution.
+- Surface fetch metadata: last fetch time, last fetch status, minimum fetch interval.
+- Work without adding a Firebase dependency to consumers who do not use Firebase.
+- Support non-Firebase Remote Config providers through a host-implementable interface.
+- Render on both the browser dashboard and the on-device Compose inspector.
+- Never throw into the host application, and never leak secrets held in config values.
+
+## Non-goals
+
+- **No setting of overrides from DevConsole.** The `OVERRIDE` source is displayed when a host has
+ applied one, but DevConsole does not create overrides in this change. Deferred deliberately; see
+ "Deferred: override editing".
+- No triggering of `fetch()` / `activate()` from DevConsole. The inspector observes; it does not
+ drive the Remote Config lifecycle.
+- No timeline events or historical fetch records. This is a current-state view, not an event stream.
+- No `ui-views` work. That module is a thin launcher panel and renders no flag or state data today.
+
+## Approach
+
+Three new modules, mirroring the existing push triad:
+
+| Module | Namespace | Contents |
+| --- | --- | --- |
+| `:sdk:remote-config` | `io.devconsole.remoteconfig` | Vendor-neutral model + registry. No Android or Firebase dependencies. |
+| `:sdk:remote-config-firebase` | `io.devconsole.remoteconfig.firebase` | Reflection adapter + `RemoteConfigFirebaseCaptureMarker`. |
+| `:sdk:remote-config-firebase-noop` | `io.devconsole.remoteconfig.firebase.noop` | Protected-build twin returning an empty, clearly-labelled snapshot. |
+
+Rejected alternatives:
+
+- **Firebase-only single module.** Fewer modules, but breaks the repo's core+adapter convention and
+ locks the feature to one vendor; adding a second provider later would be a breaking restructure.
+- **Document `StateProvider` instead of shipping code.** Zero SDK code, but `StateValue` has no
+ concept of value *source* or fetch metadata — precisely what the issue asks for — so every host
+ would hand-roll Firebase reflection and still get no source attribution.
+
+## Data model (`:sdk:remote-config`)
+
+```kotlin
+enum class RemoteConfigSource(val wireName: String) {
+ REMOTE("remote"), // fetched and activated from the server
+ DEFAULT("default"), // in-app defaults (setDefaultsAsync)
+ STATIC("static"), // set nowhere; the SDK's static fallback
+ OVERRIDE("override"), // a host applied a local override
+ UNKNOWN("unknown"), // the provider could not attribute it
+}
+
+data class RemoteConfigEntry(
+ val key: String,
+ val value: String,
+ val source: RemoteConfigSource,
+ val redacted: Boolean = false,
+ val truncated: Boolean = false,
+)
+
+enum class RemoteConfigFetchStatus { SUCCESS, NO_FETCH_YET, FAILURE, THROTTLED, UNKNOWN }
+
+data class RemoteConfigFetchInfo(
+ val lastFetchEpochMs: Long?,
+ val status: RemoteConfigFetchStatus,
+ val minimumFetchIntervalSeconds: Long?,
+)
+
+data class RemoteConfigSnapshot(
+ val providerId: String,
+ val entries: List,
+ val fetchInfo: RemoteConfigFetchInfo,
+ val unavailableReason: String? = null,
+)
+
+interface RemoteConfigProvider {
+ val id: String
+
+ fun snapshot(): RemoteConfigSnapshot
+}
+```
+
+`RemoteConfigRegistry` mirrors `StateRegistry`: `register(provider)` rejecting blank and duplicate
+ids, plus `providerIds()`, `snapshot(id)`, and `snapshots()`.
+
+Decisions embedded in the model:
+
+- **`value` is a `String`.** Remote Config is string-typed at the source; `asLong()` / `asBoolean()`
+ are interpretations applied by the reader. Recording a guessed type would invent information the
+ server never sent. The dashboard may still pretty-print a value that parses as JSON.
+- **Values are truncated at 8 KB** with `truncated = true`, following the repo's existing
+ body-preview convention. A single pathological config value must not bloat every snapshot response.
+ Truncation is enforced by `RemoteConfigRegistry` when it normalizes a provider's snapshot, not by
+ each adapter, so a host-written provider inherits the cap for free rather than having to remember
+ it. `MAX_VALUE_LENGTH` is a public constant on the registry's companion.
+- **`OVERRIDE` exists but nothing emits it yet.** It is what the issue asks us to *display*, and
+ Firebase has no such concept — it arises only where a host layers one on. Reserving the enum case
+ now means the deferred override feature is not a wire-format break later.
+- **`unavailableReason` instead of exceptions.** Per CONTRIBUTING, capture code must never throw into
+ the host. `RemoteConfigRegistry` wraps every `provider.snapshot()` in `runCatching` and converts a
+ failure into an empty snapshot carrying the reason, so a broken provider degrades to a visible
+ "unavailable" row rather than taking down the inspector. Such a snapshot carries
+ `fetchInfo = RemoteConfigFetchInfo(lastFetchEpochMs = null, status = UNKNOWN,
+ minimumFetchIntervalSeconds = null)` — a failed provider must not report a confident fetch status.
+ The reason string is the throwable's message, or its class name when the message is null.
+- **Pull, not push.** Snapshots are evaluated on demand when a surface asks, exactly like
+ `StateProvider`. "Which values are currently active" is a state question, not an event stream.
+
+## Firebase adapter (`:sdk:remote-config-firebase`)
+
+```kotlin
+class FirebaseRemoteConfigAdapter @JvmOverloads constructor(
+ private val remoteConfig: Any, // com.google.firebase.remoteconfig.FirebaseRemoteConfig
+ override val id: String = "firebase",
+) : RemoteConfigProvider
+```
+
+Reflection only — no compile-time Firebase dependency — identical in construction to
+`FirebaseRemoteMessageAdapter`, including its private `Any.call(name)` helper that returns `null`
+rather than throwing when a method is absent.
+
+Reads `getAll()` → `Map`, then per value `asString()` and
+`getSource()`; and `getInfo()` → `getFetchTimeMillis()`, `getLastFetchStatus()`, and
+`getConfigSettings().getMinimumFetchIntervalInSeconds()`.
+
+Constant values, verified against `firebase-android-sdk` source rather than assumed:
+
+```java
+VALUE_SOURCE_STATIC = 0; VALUE_SOURCE_DEFAULT = 1; VALUE_SOURCE_REMOTE = 2;
+LAST_FETCH_STATUS_SUCCESS = -1; NO_FETCH_YET = 0; FAILURE = 1; THROTTLED = 2;
+```
+
+Two traps this mapping must handle explicitly, both verified above:
+
+1. **`LAST_FETCH_STATUS_SUCCESS` is `-1`, not `0`.** An "unknown status" fallback keyed on negative
+ numbers would silently mislabel every successful fetch.
+2. **`getFetchTimeMillis()` returns `-1` when no fetch has happened.** Normalized to
+ `lastFetchEpochMs = null`, never rendered as a 1969 timestamp.
+
+The adapter resolves these constants reflectively from the Firebase class when it is present and
+falls back to the literals above, so a future renumbering cannot silently mis-badge every row. Any
+unrecognized integer maps to `UNKNOWN` rather than guessing.
+
+The noop twin returns `RemoteConfigSnapshot(providerId = id, entries = emptyList(), …,
+unavailableReason = "disabled-build")` and does not reflect on the supplied object at all, matching
+the noop push adapter's contract.
+
+## Host wiring
+
+`DevConsoleConfig` gains `remoteConfigProviders` as an **additive field outside the primary
+constructor** (`withRemoteConfigProviders()`, `Builder.addRemoteConfigProvider()`) — the rule that
+file already states for preserving the 1.x JVM ABI.
+
+```kotlin
+DevConsole.initialize(
+ application,
+ DevConsoleConfig(/* … */)
+ .withRemoteConfigProviders(listOf(FirebaseRemoteConfigAdapter(Firebase.remoteConfig))),
+)
+```
+
+Late registration via `DevConsole.registerRemoteConfigProvider()` mirrors `registerStateProvider`.
+This is safe here precisely because reads are pull-based — unlike feature flags, whose init-only
+restriction exists to avoid a race between a late registration and a snapshot the dashboard has
+already read.
+
+**Capture gating uses the existing `CaptureCategory.STATE`** rather than a new category. STATE
+already means "state providers + feature flags"; Remote Config is the same shape of data. A new enum
+constant would widen the wire format and force every host to revisit their `captureCategories` set
+for no real benefit. The STATE KDoc and docs are updated to read "state providers, feature flags, and
+remote config".
+
+## Redaction
+
+Remote Config values routinely hold API keys, endpoints, and third-party tokens, so they are treated
+as a capture boundary like any other.
+
+Redaction is applied **once, in `:sdk:full`**, by wrapping the registry before it is handed to either
+consumer. Both the Ktor routes and `FullInspectorDataSource` therefore receive already-redacted
+entries, and neither the JSON serializer nor the Compose renderer needs to know redaction exists —
+the arrangement CONTRIBUTING prescribes. This matters because the Compose inspector reads in-process
+through `InspectorDataSource` and never crosses the HTTP boundary, so redaction applied only in
+`server-ktor` would leave the on-device surface unprotected.
+
+Matching is by **key name** through `RedactionEngine.redactFields()`. `RedactionPolicy`'s default
+`sensitiveFieldNames` already carries `api-key`, `apikey`, `access_token`, `refresh_token` and
+similar — exactly the shape of a leaky Remote Config key. A redacted entry has its `value` replaced
+by `RedactionPolicy.replacement` (`` by default) **and** sets `redacted = true`, so both
+surfaces can badge it as withheld rather than letting a reader mistake the replacement string for the
+literally configured value. The key itself is never redacted — knowing *which* key is withheld is the
+whole point of the view, and the key name is what the host wrote in the Remote Config console.
+
+## REST API
+
+A single endpoint, `GET /api/v1/remote-config`, returning every provider's snapshot inline:
+
+```json
+{"data":[{
+ "id":"firebase",
+ "fetch":{"lastFetchEpochMs":1755043200000,"status":"success","minimumFetchIntervalSeconds":3600},
+ "unavailableReason":null,
+ "entries":[
+ {"key":"checkout_v2","value":"true","source":"remote","redacted":false,"truncated":false}
+ ]
+}]}
+```
+
+Wire names deliberately differ from the Kotlin field names in two places, and the serializer must map
+them: `RemoteConfigSnapshot.providerId` → `"id"`, and `RemoteConfigSnapshot.fetchInfo` → `"fetch"`.
+`RemoteConfigSource.wireName` and a lowercase form of `RemoteConfigFetchStatus` supply the enum
+strings. These wire names are the stable contract; the Kotlin names may not be changed to match.
+
+Unlike `/api/v1/state`, this does not split into a list-ids call plus a per-id snapshot call. That
+two-step exists because state providers can be numerous and individually expensive to evaluate;
+Remote Config providers are effectively always one, and the whole snapshot is small.
+
+Authentication matches `GET /api/v1/flags` (authenticated session required), and the response when
+`CaptureCategory.STATE` is disabled matches whatever that route already returns, rather than
+inventing a second convention for the same category.
+
+## Surfaces
+
+### Browser dashboard
+
+- New `viewRemoteConfig` rail button in `index.html`, grouped with "State & flags".
+- A view section with a provider header (last fetch, status, minimum interval) and a table of
+ Key / Value / Source, with a source badge per row.
+- `dashboard.js` fetches `/api/v1/remote-config` and wires into the existing view-switch and refresh
+ machinery. `dashboard.css` gains `.badge-remote` / `.badge-default` / `.badge-static` /
+ `.badge-override` on top of the existing badge classes.
+- A client-side key filter input, since real Remote Config sets get large.
+
+### Compose inspector
+
+- UI-shaped mirror types `InspectorRemoteConfigUi` and `InspectorRemoteConfigProviderUi` in
+ `InspectorDataSource.kt`, carrying no `:sdk:remote-config` dependency — the precedent set by
+ `InspectorBodyKind` mirroring `network.BodyPreview`.
+- `InspectorSnapshot` gains `remoteConfig: List = emptyList()`. The
+ default keeps every existing fake and adapter compiling unchanged.
+- Rendered on the **Control** screen, where feature flags already live, as a `CollapsibleSection`:
+ header shows provider id, last fetch, and status; rows show key, value, and source badge. Key
+ filtering reuses `InspectorDetailSearchField`.
+- `FullInspectorDataSource` populates it from the redacted registry, honoring the STATE gate.
+
+### Empty and error states
+
+Four distinct states, none of which may render as a blank page:
+
+1. No provider registered → "No Remote Config provider registered", linking to the docs.
+2. `CaptureCategory.STATE` disabled → the same shape the flags surface already uses.
+3. Provider threw → `unavailableReason` surfaced as a warning row.
+4. Zero keys / never fetched → "No values" plus an explicit "last fetch: never". This is the
+ `NO_FETCH_YET` case and the single most common real-world confusion, so it is called out rather
+ than shown as an empty table.
+
+## Gradle plugin registration
+
+A new protected adapter module must be registered in **four** places, or the release-variant
+protection silently does not apply to it:
+
+1. `FULL_RUNTIME_COORDINATE` regex (`DevConsoleVariantPolicyPlugin.kt`) — add
+ `devconsole-remote-config-firebase`.
+2. `FORBIDDEN_SIGNATURES` — add `DEVCONSOLE_ENABLED_REMOTE_CONFIG_FIREBASE_V1`.
+3. `protectedDependencyPaths` convention — add `:sdk:remote-config-firebase`.
+4. `NoopRuntimeExcludesFullModulesTest` — add the module and its noop twin.
+
+`:sdk:remote-config` itself is **not** protected, exactly as `:sdk:push` is not: it is an inert data
+model with no capture behavior.
+
+## Testing
+
+- **`:sdk:remote-config`** — registry rejects blank/duplicate ids; unknown id returns null; a provider
+ that throws yields `unavailableReason` rather than propagating; truncation boundary.
+- **`:sdk:remote-config-firebase`** — adapter driven by fake Firebase-shaped Kotlin objects with
+ matching method names, the technique `FirebaseRemoteMessageAdapterTest` already uses, so no
+ Firebase dependency enters the test classpath. Covers all three sources, all four fetch statuses
+ including `SUCCESS = -1`, `fetchTimeMillis = -1` → `null`, absent methods → `UNKNOWN`, and a
+ malformed object that would throw.
+- **`:sdk:remote-config-firebase-noop`** — returns the disabled-build snapshot and does not reflect,
+ mirroring `FirebaseRemoteMessageAdapterNoopTest`.
+- **`:sdk:full`** — redaction applied on both the HTTP and in-process paths; STATE gating added to
+ `CaptureCategoryGatingTest`; `FullInspectorDataSource` mapping.
+- **`:sdk:server-ktor`** — route JSON shape, auth required, category-gated response.
+- **`gradle-plugin`** — the extended `NoopRuntimeExcludesFullModulesTest`.
+
+## Documentation and CI
+
+- New `docs/REMOTE_CONFIG.md`; linked from `docs/README.md`.
+- Row added to `docs/PROTOCOL_REFERENCE.md`; cross-reference from `docs/STATE_AND_FLAGS.md`.
+- README feature list and `CHANGELOG.md`.
+- `./gradlew apiDump` for the three new modules, which carry `api/*.api` baselines.
+- New Kotlin files carry the `@author` / `@since 13/08/26` header the repo requires.
+- `settings.gradle.kts` include lines; each module applies `devconsole.android.library`,
+ `devconsole.quality`, and `devconsole.publishing`.
+
+Verification commands: `./gradlew build`, `./gradlew testDebugUnitTest`,
+`./gradlew ktlintCheck detekt`, `./gradlew apiCheck`, `./gradlew -p gradle-plugin test`, and — because
+this touches a protected-variant boundary — the three sample `assembleDebug` / `assembleRelease` /
+`verifyDevConsoleProtectedArtifacts` runs.
+
+## Deferred: override editing
+
+The natural follow-up is a session-scoped override layer letting QA force a value without publishing
+to the Remote Config console. It is deliberately out of scope here because it needs machinery this
+change does not: hosts must read values back through DevConsole for an override to affect behavior
+(the `featureFlagValue` problem), plus an `EditingCapabilities` gate, command-audit records, timeline
+events, and session-integrity reporting.
+
+The `OVERRIDE` enum case and the `RemoteConfigProvider` interface are shaped so that work lands
+additively rather than as a breaking change.
diff --git a/gradle-plugin/src/main/kotlin/io/devconsole/gradle/DevConsoleVariantPolicyPlugin.kt b/gradle-plugin/src/main/kotlin/io/devconsole/gradle/DevConsoleVariantPolicyPlugin.kt
index 688336f..0bfca6c 100644
--- a/gradle-plugin/src/main/kotlin/io/devconsole/gradle/DevConsoleVariantPolicyPlugin.kt
+++ b/gradle-plugin/src/main/kotlin/io/devconsole/gradle/DevConsoleVariantPolicyPlugin.kt
@@ -153,7 +153,8 @@ abstract class VerifyDevConsoleProtectedArtifactsTask : DefaultTask() {
Regex(
"^io\\.github\\.devconsole-android:" +
"(?:devconsole|devconsole-network-okhttp|devconsole-mocks-okhttp|" +
- "devconsole-socket-okhttp|devconsole-socket-paho|devconsole-push-firebase):.+",
+ "devconsole-socket-okhttp|devconsole-socket-paho|devconsole-push-firebase|" +
+ "devconsole-remote-config-firebase):.+",
)
}
}
@@ -388,6 +389,7 @@ abstract class VerifyDevConsolePackagedArtifactTask : DefaultTask() {
"DEVCONSOLE_ENABLED_MOCKS_OKHTTP_V1",
"DEVCONSOLE_ENABLED_SOCKET_OKHTTP_V1",
"DEVCONSOLE_ENABLED_PUSH_FIREBASE_V1",
+ "DEVCONSOLE_ENABLED_REMOTE_CONFIG_FIREBASE_V1",
"Lio/devconsole/server/ktor/KtorLocalServerEngine;",
"io.devconsole.DevConsoleInitializer",
".devconsoleinitializer",
@@ -431,6 +433,7 @@ class DevConsoleVariantPolicyPlugin : Plugin {
":sdk:socket-okhttp",
":sdk:socket-paho",
":sdk:push-firebase",
+ ":sdk:remote-config-firebase",
),
)
// PROTECTED by default: a release-signed staging/beta/preprod build type (anything not in
diff --git a/gradle-plugin/src/test/kotlin/io/devconsole/gradle/NoopRuntimeExcludesFullModulesTest.kt b/gradle-plugin/src/test/kotlin/io/devconsole/gradle/NoopRuntimeExcludesFullModulesTest.kt
index 92c467a..6c968f2 100644
--- a/gradle-plugin/src/test/kotlin/io/devconsole/gradle/NoopRuntimeExcludesFullModulesTest.kt
+++ b/gradle-plugin/src/test/kotlin/io/devconsole/gradle/NoopRuntimeExcludesFullModulesTest.kt
@@ -36,6 +36,7 @@ class NoopRuntimeExcludesFullModulesTest {
"sdk/socket-okhttp-noop",
"sdk/socket-paho-noop",
"sdk/push-firebase-noop",
+ "sdk/remote-config-firebase-noop",
)
/**
@@ -59,6 +60,7 @@ class NoopRuntimeExcludesFullModulesTest {
":sdk:mocks-okhttp",
":sdk:socket-okhttp",
":sdk:socket-paho",
+ ":sdk:remote-config-firebase",
)
@Test
diff --git a/samples/compose-app/src/main/kotlin/io/devconsole/sample/compose/MainActivity.kt b/samples/compose-app/src/main/kotlin/io/devconsole/sample/compose/MainActivity.kt
index 80e96a1..fdc6997 100644
--- a/samples/compose-app/src/main/kotlin/io/devconsole/sample/compose/MainActivity.kt
+++ b/samples/compose-app/src/main/kotlin/io/devconsole/sample/compose/MainActivity.kt
@@ -94,6 +94,12 @@ import io.devconsole.mocks.MockRule
import io.devconsole.mocks.okhttp.DevConsoleMockInterceptor
import io.devconsole.network.okhttp.installDevConsole
import io.devconsole.push.PushInput
+import io.devconsole.remoteconfig.RemoteConfigEntry
+import io.devconsole.remoteconfig.RemoteConfigFetchInfo
+import io.devconsole.remoteconfig.RemoteConfigFetchStatus
+import io.devconsole.remoteconfig.RemoteConfigProvider
+import io.devconsole.remoteconfig.RemoteConfigSnapshot
+import io.devconsole.remoteconfig.RemoteConfigSource
import io.devconsole.socket.okhttp.DevConsoleOkHttpWebSocketListener
import io.devconsole.socket.okhttp.DevConsoleRecordingWebSocket
import io.devconsole.socket.paho.DevConsolePahoMqtt
@@ -117,6 +123,57 @@ import java.util.concurrent.atomic.AtomicInteger
private const val SHOW_ORDER_HISTORY_FLAG = "compose_sample.show_order_history"
private const val MOCK_RULE_ID = "compose-sample-orders"
+
+/**
+ * Stands in for a real Remote Config client so the sample can demonstrate the inspector without
+ * requiring a Firebase project. A Firebase-backed app registers
+ * `FirebaseRemoteConfigAdapter(Firebase.remoteConfig)` from
+ * `devconsole-remote-config-firebase` instead, and reaches the identical view.
+ *
+ * The values are chosen to show each thing the inspector is for: one key served from the server,
+ * one that fell back to an in-app default, one the server has never heard of, one masked by a local
+ * override, and one whose name trips redaction — `api_key` is written snake_case on purpose,
+ * because that is how Remote Config keys are actually written and it is the case a header-shaped
+ * allowlist misses.
+ *
+ * `checkout_experiment` holds a JSON object because that is the value shape the row can only ever
+ * preview: opening it shows the pretty-printed tree, while `promo_banner_text` beside it opens as
+ * raw text, since a plain string is not JSON and is not dressed up as though it were.
+ */
+private class SampleRemoteConfigProvider : RemoteConfigProvider {
+ override val id: String = "sample-remote-config"
+
+ override fun snapshot(): RemoteConfigSnapshot =
+ RemoteConfigSnapshot(
+ providerId = id,
+ entries =
+ listOf(
+ RemoteConfigEntry("checkout_v2_enabled", "true", RemoteConfigSource.REMOTE),
+ RemoteConfigEntry("checkout_experiment", CHECKOUT_EXPERIMENT_JSON, RemoteConfigSource.REMOTE),
+ RemoteConfigEntry("promo_banner_text", "Free delivery this week", RemoteConfigSource.REMOTE),
+ RemoteConfigEntry("max_cart_items", "20", RemoteConfigSource.DEFAULT),
+ RemoteConfigEntry("courier_eta_strategy", "", RemoteConfigSource.STATIC),
+ RemoteConfigEntry("api_base_url", "https://staging.example.test", RemoteConfigSource.OVERRIDE),
+ RemoteConfigEntry("api_key", "super-secret-value", RemoteConfigSource.REMOTE),
+ ),
+ fetchInfo =
+ RemoteConfigFetchInfo(
+ lastFetchEpochMs = System.currentTimeMillis() - FETCH_AGE_MS,
+ status = RemoteConfigFetchStatus.SUCCESS,
+ minimumFetchIntervalSeconds = 3600L,
+ ),
+ )
+
+ private companion object {
+ const val FETCH_AGE_MS = 90_000L
+
+ /** One line, exactly as a Remote Config server sends it — the viewer does the indenting. */
+ const val CHECKOUT_EXPERIMENT_JSON =
+ """{"id":"checkout-flow-2026-08","variant":"b","rollout":0.25,""" +
+ """"steps":["cart","address","payment"],"fallback":null}"""
+ }
+}
+
private val requestCount = AtomicInteger(0)
/**
@@ -285,6 +342,8 @@ class MainActivity : ComponentActivity() {
composerAllowedHosts = setOf("jsonplaceholder.typicode.com", "example.test", "postman-echo.com"),
// Lets the dashboard drive registered state mutations; state is read-only otherwise.
stateMutationsEnabled = true,
+ ).withRemoteConfigProviders(
+ listOf(SampleRemoteConfigProvider()),
).withBrowserConfig(
// Governs the in-app inspector's own More-screen Start button, which issues no
// StartRequest of its own -- without this it would bind loopback while the sample's
diff --git a/sdk/api/api/api.api b/sdk/api/api/api.api
index a0b44a8..9ecff6e 100644
--- a/sdk/api/api/api.api
+++ b/sdk/api/api/api.api
@@ -256,6 +256,7 @@ public final class io/devconsole/api/DevConsoleConfig {
public final fun getFeatureFlags ()Ljava/util/List;
public final fun getOpenTriggers ()Lio/devconsole/api/OpenTriggers;
public final fun getRedactionPolicy ()Lio/devconsole/security/RedactionPolicy;
+ public final fun getRemoteConfigProviders ()Ljava/util/List;
public final fun getRetentionPolicy ()Lio/devconsole/api/RetentionPolicy;
public final fun getScreenshotPolicy ()Lio/devconsole/api/ScreenshotPolicy;
public final fun getSessionPolicy ()Lio/devconsole/api/SessionPolicy;
@@ -274,6 +275,7 @@ public final class io/devconsole/api/DevConsoleConfig {
public final fun withCrashPolicy (Lio/devconsole/api/CrashPolicy;)Lio/devconsole/api/DevConsoleConfig;
public final fun withEditingCapabilities (Lio/devconsole/api/EditingCapabilities;)Lio/devconsole/api/DevConsoleConfig;
public final fun withOpenTriggers (Lio/devconsole/api/OpenTriggers;)Lio/devconsole/api/DevConsoleConfig;
+ public final fun withRemoteConfigProviders (Ljava/util/List;)Lio/devconsole/api/DevConsoleConfig;
public final fun withRetentionPolicy (Lio/devconsole/api/RetentionPolicy;)Lio/devconsole/api/DevConsoleConfig;
public final fun withScreenshotPolicy (Lio/devconsole/api/ScreenshotPolicy;)Lio/devconsole/api/DevConsoleConfig;
public final fun withSessionPolicy (Lio/devconsole/api/SessionPolicy;)Lio/devconsole/api/DevConsoleConfig;
@@ -284,6 +286,7 @@ public final class io/devconsole/api/DevConsoleConfig$Builder {
public fun ()V
public final fun addCaptureCategory (Lio/devconsole/api/CaptureCategory;)Lio/devconsole/api/DevConsoleConfig$Builder;
public final fun addFeatureFlag (Lio/devconsole/state/FeatureFlag;)Lio/devconsole/api/DevConsoleConfig$Builder;
+ public final fun addRemoteConfigProvider (Lio/devconsole/remoteconfig/RemoteConfigProvider;)Lio/devconsole/api/DevConsoleConfig$Builder;
public final fun addStateProvider (Lio/devconsole/state/StateProvider;)Lio/devconsole/api/DevConsoleConfig$Builder;
public final fun browserConfig (Lio/devconsole/api/BrowserConfig;)Lio/devconsole/api/DevConsoleConfig$Builder;
public final fun build ()Lio/devconsole/api/DevConsoleConfig;
@@ -320,6 +323,7 @@ public abstract interface class io/devconsole/api/DevConsoleFacadeProvider {
public abstract fun networkRecorder ()Lio/devconsole/network/NetworkTransactionRecorder;
public abstract fun openInspector (Landroid/content/Context;)Lio/devconsole/api/InspectorOpenResult;
public abstract fun recordPush (Lio/devconsole/push/PushInput;)Lio/devconsole/push/PushEvent;
+ public abstract fun registerRemoteConfigProvider (Lio/devconsole/remoteconfig/RemoteConfigProvider;)Z
public abstract fun registerStateProvider (Lio/devconsole/state/StateProvider;)Z
public abstract fun socketRecorder ()Lio/devconsole/socket/SocketRecorder;
public abstract fun startBrowser (Lio/devconsole/api/StartRequest;Lkotlin/coroutines/Continuation;)Ljava/lang/Object;
diff --git a/sdk/api/build.gradle.kts b/sdk/api/build.gradle.kts
index ea1bd21..599ce9d 100644
--- a/sdk/api/build.gradle.kts
+++ b/sdk/api/build.gradle.kts
@@ -11,6 +11,7 @@ dependencies {
api(project(":sdk:socket"))
api(project(":sdk:push"))
api(project(":sdk:state"))
+ api(project(":sdk:remote-config"))
api(project(":sdk:security"))
api(project(":sdk:mocks"))
api(project(":sdk:logs"))
diff --git a/sdk/api/src/main/kotlin/io/devconsole/api/DevConsoleConfig.kt b/sdk/api/src/main/kotlin/io/devconsole/api/DevConsoleConfig.kt
index b17f144..61e31f6 100644
--- a/sdk/api/src/main/kotlin/io/devconsole/api/DevConsoleConfig.kt
+++ b/sdk/api/src/main/kotlin/io/devconsole/api/DevConsoleConfig.kt
@@ -1,5 +1,6 @@
package io.devconsole.api
+import io.devconsole.remoteconfig.RemoteConfigProvider
import io.devconsole.security.RedactionEngine
import io.devconsole.security.RedactionPolicy
import io.devconsole.state.FeatureFlag
@@ -70,6 +71,14 @@ data class DevConsoleConfig(
var openTriggers: OpenTriggers = OpenTriggers()
private set
+ /**
+ * Remote Config sources the inspector reads. Like [stateProviders] these are pull-based, so a
+ * provider constructed after `initialize` can still be added through
+ * [io.devconsole.DevConsole.registerRemoteConfigProvider]. Gated by [CaptureCategory.STATE].
+ */
+ var remoteConfigProviders: List = emptyList()
+ private set
+
fun withStoragePolicy(value: StoragePolicy): DevConsoleConfig =
duplicate().also {
it.storagePolicy = value
@@ -112,6 +121,9 @@ data class DevConsoleConfig(
fun withOpenTriggers(value: OpenTriggers): DevConsoleConfig = duplicate().also { it.openTriggers = value }
+ fun withRemoteConfigProviders(value: List): DevConsoleConfig =
+ duplicate().also { it.remoteConfigProviders = value.toList() }
+
fun capturesCategory(category: CaptureCategory): Boolean = category in captureCategories
/**
@@ -160,7 +172,8 @@ data class DevConsoleConfig(
crashPolicy == other.crashPolicy &&
screenshotPolicy == other.screenshotPolicy &&
captureCategories == other.captureCategories &&
- openTriggers == other.openTriggers
+ openTriggers == other.openTriggers &&
+ remoteConfigProviders == other.remoteConfigProviders
private fun duplicate(): DevConsoleConfig =
copy().also {
@@ -173,6 +186,7 @@ data class DevConsoleConfig(
it.screenshotPolicy = screenshotPolicy
it.captureCategories = captureCategories
it.openTriggers = openTriggers
+ it.remoteConfigProviders = remoteConfigProviders
}
/** Mutable builder for Java callers and for incremental construction. */
@@ -194,6 +208,7 @@ data class DevConsoleConfig(
private var screenshotPolicy = ScreenshotPolicy()
private var captureCategories: Set = CaptureCategory.all()
private var openTriggers = OpenTriggers()
+ private val remoteConfigProviders = mutableListOf()
fun eventBufferCapacity(value: Int) = apply { eventBufferCapacity = value }
@@ -229,6 +244,8 @@ data class DevConsoleConfig(
fun openTriggers(value: OpenTriggers) = apply { openTriggers = value }
+ fun addRemoteConfigProvider(value: RemoteConfigProvider) = apply { remoteConfigProviders += value }
+
fun build(): DevConsoleConfig {
val configured =
DevConsoleConfig(
@@ -247,6 +264,7 @@ data class DevConsoleConfig(
.withScreenshotPolicy(screenshotPolicy)
.withCaptureCategories(captureCategories)
.withOpenTriggers(openTriggers)
+ .withRemoteConfigProviders(remoteConfigProviders)
return retentionPolicy?.let(configured::withRetentionPolicy) ?: configured
}
}
diff --git a/sdk/api/src/main/kotlin/io/devconsole/api/DevConsoleFacadeProvider.kt b/sdk/api/src/main/kotlin/io/devconsole/api/DevConsoleFacadeProvider.kt
index a3fe94d..89426b1 100644
--- a/sdk/api/src/main/kotlin/io/devconsole/api/DevConsoleFacadeProvider.kt
+++ b/sdk/api/src/main/kotlin/io/devconsole/api/DevConsoleFacadeProvider.kt
@@ -8,6 +8,7 @@ import io.devconsole.mocks.MockEngine
import io.devconsole.network.NetworkTransactionRecorder
import io.devconsole.push.PushEvent
import io.devconsole.push.PushInput
+import io.devconsole.remoteconfig.RemoteConfigProvider
import io.devconsole.socket.SocketRecorder
import io.devconsole.state.StateProvider
import kotlinx.coroutines.flow.StateFlow
@@ -43,6 +44,19 @@ interface DevConsoleFacadeProvider {
*/
fun registerStateProvider(provider: StateProvider): Boolean
+ /**
+ * Registers a Remote Config source after [initialize]. Safe to call late -- unlike feature
+ * flags, providers here are read on demand rather than snapshotted at startup, so there is no
+ * race with a dashboard that already read an earlier list. Returns false if the runtime is
+ * disabled or [CaptureCategory.STATE] is off.
+ *
+ * Abstract, not defaulted, like every other member here: the compiler refusing to build a
+ * facade that misses a member is what guarantees full/no-op parity (see
+ * `NoopFacadeProviderContractTest`). A default would let the no-op facade silently inherit
+ * "registered nothing" for a capture-gated method instead of stating it deliberately.
+ */
+ fun registerRemoteConfigProvider(provider: RemoteConfigProvider): Boolean
+
/**
* The endpoint of the running server, or null when it is not running. [DevConsoleState.Running]
* carries no payload, so without this a host that loses its [StartResult.Started] -- to an
diff --git a/sdk/api/src/test/kotlin/io/devconsole/api/RemoteConfigConfigurationTest.kt b/sdk/api/src/test/kotlin/io/devconsole/api/RemoteConfigConfigurationTest.kt
new file mode 100644
index 0000000..cde2109
--- /dev/null
+++ b/sdk/api/src/test/kotlin/io/devconsole/api/RemoteConfigConfigurationTest.kt
@@ -0,0 +1,67 @@
+/**
+ * @author Md. Asaduzzaman Nur
+ * @since 13/08/26
+ */
+package io.devconsole.api
+
+import io.devconsole.remoteconfig.RemoteConfigFetchInfo
+import io.devconsole.remoteconfig.RemoteConfigProvider
+import io.devconsole.remoteconfig.RemoteConfigSnapshot
+import org.junit.Assert.assertEquals
+import org.junit.Assert.assertFalse
+import org.junit.Assert.assertTrue
+import org.junit.Test
+
+class RemoteConfigConfigurationTest {
+ private fun provider(id: String): RemoteConfigProvider =
+ object : RemoteConfigProvider {
+ override val id: String = id
+
+ override fun snapshot(): RemoteConfigSnapshot =
+ RemoteConfigSnapshot(id, emptyList(), RemoteConfigFetchInfo.unknown())
+ }
+
+ @Test
+ fun `defaults to no remote config providers`() {
+ assertTrue(DevConsoleConfig().remoteConfigProviders.isEmpty())
+ }
+
+ @Test
+ fun `carries providers supplied through the additive setter`() {
+ val config = DevConsoleConfig().withRemoteConfigProviders(listOf(provider("firebase")))
+
+ assertEquals(listOf("firebase"), config.remoteConfigProviders.map { it.id })
+ }
+
+ @Test
+ fun `the java builder accumulates providers`() {
+ val config =
+ DevConsoleConfig
+ .builder()
+ .addRemoteConfigProvider(provider("firebase"))
+ .addRemoteConfigProvider(provider("configcat"))
+ .build()
+
+ assertEquals(listOf("firebase", "configcat"), config.remoteConfigProviders.map { it.id })
+ }
+
+ /** The additive fields survive every other `with…` copy, or a config silently loses providers. */
+ @Test
+ fun `providers survive an unrelated policy copy`() {
+ val config =
+ DevConsoleConfig()
+ .withRemoteConfigProviders(listOf(provider("firebase")))
+ .withCaptureCategories(CaptureCategory.all())
+ .withCrashPolicy(CrashPolicy())
+
+ assertEquals(listOf("firebase"), config.remoteConfigProviders.map { it.id })
+ }
+
+ @Test
+ fun `runtime equivalence distinguishes differing providers`() {
+ val base = DevConsoleConfig().withRemoteConfigProviders(listOf(provider("firebase")))
+
+ assertFalse(base.runtimeEquivalentTo(DevConsoleConfig()))
+ assertTrue(base.runtimeEquivalentTo(base.withRemoteConfigProviders(base.remoteConfigProviders)))
+ }
+}
diff --git a/sdk/facade-shared/src/main/kotlin/io/devconsole/DevConsole.kt b/sdk/facade-shared/src/main/kotlin/io/devconsole/DevConsole.kt
index fe46e32..84beae7 100644
--- a/sdk/facade-shared/src/main/kotlin/io/devconsole/DevConsole.kt
+++ b/sdk/facade-shared/src/main/kotlin/io/devconsole/DevConsole.kt
@@ -18,6 +18,7 @@ import io.devconsole.mocks.MockEngine
import io.devconsole.network.NetworkTransactionRecorder
import io.devconsole.push.PushEvent
import io.devconsole.push.PushInput
+import io.devconsole.remoteconfig.RemoteConfigProvider
import io.devconsole.socket.SocketRecorder
import io.devconsole.state.StateProvider
import kotlinx.coroutines.CoroutineScope
@@ -187,6 +188,14 @@ object DevConsole {
@JvmStatic
fun registerStateProvider(provider: StateProvider): Boolean = this.provider.registerStateProvider(provider)
+ /**
+ * Registers a Remote Config source after [initialize], for a client built lazily through DI.
+ * Returns false when the runtime is disabled or the STATE capture category is off.
+ */
+ @JvmStatic
+ fun registerRemoteConfigProvider(provider: RemoteConfigProvider): Boolean =
+ this.provider.registerRemoteConfigProvider(provider)
+
/** Address of the running server, or null when it is not running. Survives activity recreation. */
@JvmStatic
fun endpoint(): BrowserEndpoint? = provider.endpoint()
diff --git a/sdk/full/api/full.api b/sdk/full/api/full.api
index c39e91f..7440361 100644
--- a/sdk/full/api/full.api
+++ b/sdk/full/api/full.api
@@ -14,6 +14,7 @@ public final class io/devconsole/DevConsole {
public static final fun networkRecorder ()Lio/devconsole/network/NetworkTransactionRecorder;
public static final fun open (Landroid/content/Context;)Lio/devconsole/api/InspectorOpenResult;
public static final fun recordPush (Lio/devconsole/push/PushInput;)Lio/devconsole/push/PushEvent;
+ public static final fun registerRemoteConfigProvider (Lio/devconsole/remoteconfig/RemoteConfigProvider;)Z
public static final fun registerStateProvider (Lio/devconsole/state/StateProvider;)Z
public static final fun socketRecorder ()Lio/devconsole/socket/SocketRecorder;
public static final fun startBrowser (Lio/devconsole/api/StartRequest;Lkotlin/coroutines/Continuation;)Ljava/lang/Object;
diff --git a/sdk/full/src/main/kotlin/io/devconsole/FullInspectorDataSource.kt b/sdk/full/src/main/kotlin/io/devconsole/FullInspectorDataSource.kt
index f90f9e2..5d4d889 100644
--- a/sdk/full/src/main/kotlin/io/devconsole/FullInspectorDataSource.kt
+++ b/sdk/full/src/main/kotlin/io/devconsole/FullInspectorDataSource.kt
@@ -33,6 +33,9 @@ import io.devconsole.network.NetworkTransactionQuery
import io.devconsole.push.InMemoryPushStore
import io.devconsole.push.PushEvent
import io.devconsole.push.PushStore
+import io.devconsole.remoteconfig.RemoteConfigRegistry
+import io.devconsole.security.RedactionEngine
+import io.devconsole.security.RedactionPolicy
import io.devconsole.server.api.DatabaseExecResult
import io.devconsole.server.api.DatabaseInspector
import io.devconsole.server.api.DatabaseListingData
@@ -85,6 +88,8 @@ import io.devconsole.ui.compose.InspectorPreferenceEntryUi
import io.devconsole.ui.compose.InspectorPreferenceFileUi
import io.devconsole.ui.compose.InspectorPushUi
import io.devconsole.ui.compose.InspectorQueryResultUi
+import io.devconsole.ui.compose.InspectorRemoteConfigEntryUi
+import io.devconsole.ui.compose.InspectorRemoteConfigUi
import io.devconsole.ui.compose.InspectorRetentionUi
import io.devconsole.ui.compose.InspectorSessionUi
import io.devconsole.ui.compose.InspectorSnapshot
@@ -120,6 +125,17 @@ internal class FullInspectorDataSource(
private val timelineSupplier: () -> Timeline? = { null },
private val featureFlagsSupplier: () -> FeatureFlagProvider? = { null },
private val stateRegistry: StateRegistry? = null,
+ /**
+ * Remote Config sources, read on demand. Null on a build where no host provider was registered,
+ * which reads as "no remote config" rather than as an error.
+ */
+ private val remoteConfigRegistry: RemoteConfigRegistry? = null,
+ /**
+ * The host's live [RedactionEngine], supplied so [readRemoteConfig] does not rebuild one (and
+ * recompile every text pattern) on each snapshot. Null on a build that wires no engine, where
+ * one is constructed from the active policy as before.
+ */
+ private val redactionEngine: () -> RedactionEngine? = { null },
private val preferencesInspector: PreferencesInspector? = null,
private val fileInspector: FileInspector? = null,
private val databaseInspector: DatabaseInspector? = null,
@@ -342,6 +358,7 @@ internal class FullInspectorDataSource(
crashes = if (CaptureCategory.CRASHES in categories) readCrashes() else emptyList(),
featureFlags = if (stateOn) readFeatureFlags() else emptyList(),
stateProviders = if (stateOn) readStateProviders() else emptyList(),
+ remoteConfig = if (stateOn) readRemoteConfig(config) else emptyList(),
preferenceFiles =
if (inspectionOn) preferencesInspector?.files().orEmpty().map { it.toUi() } else emptyList(),
fileRoots = if (inspectionOn) fileInspector?.roots().orEmpty() else emptyList(),
@@ -410,6 +427,35 @@ internal class FullInspectorDataSource(
return provider.flags().map { flag -> flag.toUi(provider.value(flag.key), overrides.containsKey(flag.key)) }
}
+ /**
+ * Redacts here rather than trusting the caller: this is the in-process path the Compose
+ * inspector reads, and it never passes through the server's redaction boundary.
+ */
+ private fun readRemoteConfig(config: DevConsoleConfig?): List {
+ val registry = remoteConfigRegistry ?: return emptyList()
+ val policy = config?.redactionPolicy ?: RedactionPolicy.default()
+ val redacting = RedactingRemoteConfig(redactionEngine() ?: RedactionEngine(policy), policy)
+ return registry.snapshots().map { snapshot ->
+ InspectorRemoteConfigUi(
+ id = snapshot.providerId,
+ entries =
+ redacting.apply(snapshot.entries).map { entry ->
+ InspectorRemoteConfigEntryUi(
+ key = entry.key,
+ value = entry.value,
+ source = entry.source.wireName,
+ redacted = entry.redacted,
+ truncated = entry.truncated,
+ )
+ },
+ lastFetchEpochMs = snapshot.fetchInfo.lastFetchEpochMs,
+ status = snapshot.fetchInfo.status.wireName,
+ minimumFetchIntervalSeconds = snapshot.fetchInfo.minimumFetchIntervalSeconds,
+ unavailableReason = snapshot.unavailableReason,
+ )
+ }
+ }
+
private fun readStateProviders(): List {
val registry = stateRegistry ?: return emptyList()
return registry.providerIds().mapNotNull { id ->
diff --git a/sdk/full/src/main/kotlin/io/devconsole/PlatformFacadeProvider.kt b/sdk/full/src/main/kotlin/io/devconsole/PlatformFacadeProvider.kt
index 8bf606b..4dbec8b 100644
--- a/sdk/full/src/main/kotlin/io/devconsole/PlatformFacadeProvider.kt
+++ b/sdk/full/src/main/kotlin/io/devconsole/PlatformFacadeProvider.kt
@@ -44,6 +44,9 @@ import io.devconsole.push.PushRecorder
import io.devconsole.push.PushSimulationCallback
import io.devconsole.push.PushSimulator
import io.devconsole.push.PushStore
+import io.devconsole.remoteconfig.RemoteConfigProvider
+import io.devconsole.remoteconfig.RemoteConfigRegistry
+import io.devconsole.remoteconfig.RemoteConfigSnapshot
import io.devconsole.security.RedactionEngine
import io.devconsole.security.RedactionPolicy
import io.devconsole.server.api.BrowserPrincipal
@@ -171,6 +174,7 @@ internal class PlatformFacadeProvider : DevConsoleFacadeProvider {
private val inMemoryPushStore = InMemoryPushStore()
private val pushStore = TeeingPushStore(inMemoryPushStore, captureBridge, liveCaptureLock)
private val stateRegistry = StateRegistry()
+ private val remoteConfigRegistry = RemoteConfigRegistry()
private val mockEngineInstance = MockEngine(emptyList()).withOutcomeSink(::recordMockOutcome)
/** Handed back by [mockEngine] instead of [mockEngineInstance] while MOCKS is off. Never mutated. */
@@ -693,7 +697,18 @@ internal class PlatformFacadeProvider : DevConsoleFacadeProvider {
// Apply the host's policy at the shared capture engine so every recorder redacts by it.
redaction.updatePolicy(config.redactionPolicy)
if (config.capturesCategory(CaptureCategory.STATE)) {
- config.stateProviders.forEach(stateRegistry::register)
+ // Cleared first, not merged into: both registries reject a duplicate id, so on a
+ // stop() -> initialize(configB) carrying a *replacement* provider under the same id
+ // (a fresh FirebaseRemoteConfigAdapter over a new client, say) the registration would
+ // be refused and every surface would keep reading through the torn-down original --
+ // silently, since safely{}'s result is discarded here. Configured providers are owned
+ // by the config, so the new config's set is the whole truth.
+ stateRegistry.clear()
+ remoteConfigRegistry.clear()
+ // A duplicate id *within one config*, or from a host that both configured and
+ // late-registered a provider, must not take down initialize(); it is simply ignored.
+ config.stateProviders.forEach { provider -> safely { stateRegistry.register(provider) } }
+ config.remoteConfigProviders.forEach { provider -> safely { remoteConfigRegistry.register(provider) } }
}
featureFlags = SessionFeatureFlags(config.featureFlags)
buildOrReconfigureServerEngine(
@@ -738,6 +753,12 @@ internal class PlatformFacadeProvider : DevConsoleFacadeProvider {
timelineSupplier = { cachedTimeline },
featureFlagsSupplier = { if (::featureFlags.isInitialized) featureFlags else null },
stateRegistry = stateRegistry,
+ remoteConfigRegistry = remoteConfigRegistry,
+ // The one engine PlatformFacadeProvider keeps current via updatePolicy, rather than
+ // a fresh one per snapshot(): constructing a RedactionEngine recompiles the whole
+ // textPatterns set, which is why redactionValidationError() guards it at all. This
+ // also keeps the in-process path on the exact engine the HTTP path redacts with.
+ redactionEngine = { redaction },
preferencesInspector = gatedPreferencesInspector,
fileInspector = gatedFileInspector,
databaseInspector = gatedDatabaseInspector,
@@ -905,6 +926,15 @@ internal class PlatformFacadeProvider : DevConsoleFacadeProvider {
socketStore = socketStore,
pushStore = pushStore,
stateRegistry = stateRegistry,
+ // Redacted here, not in the route: the Compose inspector reads the same registry
+ // in-process and never crosses the HTTP boundary, so this is the shared boundary both
+ // surfaces go through.
+ // `activeConfig`, not this call's `config`: createServerEngine runs once, while
+ // reconfigure() handles every later initialize() and carries no snapshot supplier of
+ // its own -- so capturing the parameter would pin the route to the first config's
+ // redaction policy and STATE gate for the process's life, while FullInspectorDataSource
+ // (which reads the same live field) moved on. Same field, two surfaces, one answer.
+ remoteConfigSnapshots = { redactedRemoteConfigSnapshots(activeConfig) },
featureFlags = featureFlags,
featureFlagsEditable = featureFlagsEditable,
mockEngine = mockEngineInstance,
@@ -1111,6 +1141,20 @@ internal class PlatformFacadeProvider : DevConsoleFacadeProvider {
override fun registerStateProvider(provider: StateProvider): Boolean =
categoryEnabled(CaptureCategory.STATE) && safely { stateRegistry.register(provider) }
+ @Synchronized
+ override fun registerRemoteConfigProvider(provider: RemoteConfigProvider): Boolean =
+ categoryEnabled(CaptureCategory.STATE) && safely { remoteConfigRegistry.register(provider) }
+
+ /**
+ * Empty when the STATE category is off, so the dashboard route cannot outflank the host's gate.
+ * A null config means initialize() has not landed yet, which reads the same way: nothing to serve.
+ */
+ private fun redactedRemoteConfigSnapshots(config: DevConsoleConfig?): List {
+ if (config == null || !config.capturesCategory(CaptureCategory.STATE)) return emptyList()
+ val redacting = RedactingRemoteConfig(redaction, config.redactionPolicy)
+ return remoteConfigRegistry.snapshots().map { it.copy(entries = redacting.apply(it.entries)) }
+ }
+
/** Late registration must never throw into the host; a rejected duplicate just returns false. */
private inline fun safely(block: () -> Unit): Boolean = runCatching(block).isSuccess
diff --git a/sdk/full/src/main/kotlin/io/devconsole/RedactingRemoteConfig.kt b/sdk/full/src/main/kotlin/io/devconsole/RedactingRemoteConfig.kt
new file mode 100644
index 0000000..eb2da03
--- /dev/null
+++ b/sdk/full/src/main/kotlin/io/devconsole/RedactingRemoteConfig.kt
@@ -0,0 +1,68 @@
+/**
+ * @author Md. Asaduzzaman Nur
+ * @since 13/08/26
+ */
+package io.devconsole
+
+import io.devconsole.remoteconfig.RemoteConfigEntry
+import io.devconsole.security.RedactionEngine
+import io.devconsole.security.RedactionPolicy
+
+/**
+ * The one redaction boundary for Remote Config values.
+ *
+ * It sits in `:sdk:full` rather than in `:sdk:server-ktor` on purpose: the Compose inspector reads
+ * the registry in-process through [FullInspectorDataSource] and never crosses the HTTP boundary, so
+ * redacting at the route would protect the browser and leave the on-device surface showing raw
+ * secrets. Applying it here means the JSON serializer and the Compose renderer both receive
+ * already-redacted entries and neither needs to know redaction exists.
+ */
+internal class RedactingRemoteConfig(
+ private val redaction: RedactionEngine,
+ policy: RedactionPolicy = RedactionPolicy.default(),
+) {
+ private val sensitiveNames: Set = policy.sensitiveFieldNames.mapTo(mutableSetOf(), String::lowercase)
+
+ private val collapsedNames: Set = sensitiveNames.mapTo(mutableSetOf()) { it.collapseSeparators() }
+
+ private val replacement: String = policy.replacement
+
+ fun apply(entries: List): List = entries.map(::redact)
+
+ /**
+ * The key is deliberately never redacted: knowing *which* value was withheld is the point of the
+ * view, and the key name is what the host typed into the Remote Config console, not a secret.
+ */
+ private fun redact(entry: RemoteConfigEntry): RemoteConfigEntry =
+ if (isSensitive(entry.key)) {
+ entry.copy(value = replacement, redacted = true)
+ } else {
+ // Still run the value through the engine: a non-sensitive key can hold a bearer token,
+ // and the engine's text patterns are what catch that.
+ val scrubbed = redaction.redactText(entry.value)
+ if (scrubbed == entry.value) entry else entry.copy(value = scrubbed, redacted = true)
+ }
+
+ /**
+ * Matches separator-insensitively, which the raw policy does not.
+ * [RedactionPolicy.sensitiveFieldNames] is an HTTP-header list (`api-key`, `apikey`) compared by
+ * exact lowercased name, but Remote Config keys are written snake_case or camelCase. Without
+ * this, `api_key` -- the likeliest name for a secret accidentally shipped through Remote Config
+ * -- would not match the policy's `api-key` and would be displayed in full.
+ */
+ private fun isSensitive(key: String): Boolean {
+ val lowered = key.lowercase()
+ return lowered in sensitiveNames || lowered.collapseSeparators() in collapsedNames
+ }
+
+ private companion object {
+ /**
+ * `.` as well as `-`/`_`: dotted keys are an ordinary Remote Config naming style (the
+ * sample's own flags use `compose_sample.show_order_history`), and without it `api.key`
+ * matches neither `api-key` nor `apikey` and is shown in full.
+ */
+ private val SEPARATORS = Regex("[-_.]")
+
+ fun String.collapseSeparators(): String = replace(SEPARATORS, "")
+ }
+}
diff --git a/sdk/full/src/test/kotlin/io/devconsole/RemoteConfigInspectorTest.kt b/sdk/full/src/test/kotlin/io/devconsole/RemoteConfigInspectorTest.kt
new file mode 100644
index 0000000..b8d8d6f
--- /dev/null
+++ b/sdk/full/src/test/kotlin/io/devconsole/RemoteConfigInspectorTest.kt
@@ -0,0 +1,226 @@
+/**
+ * @author Md. Asaduzzaman Nur
+ * @since 13/08/26
+ */
+package io.devconsole
+
+import io.devconsole.api.CaptureCategory
+import io.devconsole.api.DevConsoleConfig
+import io.devconsole.mocks.MockEngine
+import io.devconsole.network.InMemoryNetworkTransactionStore
+import io.devconsole.network.NetworkCursorCodec
+import io.devconsole.remoteconfig.RemoteConfigEntry
+import io.devconsole.remoteconfig.RemoteConfigFetchInfo
+import io.devconsole.remoteconfig.RemoteConfigFetchStatus
+import io.devconsole.remoteconfig.RemoteConfigProvider
+import io.devconsole.remoteconfig.RemoteConfigRegistry
+import io.devconsole.remoteconfig.RemoteConfigSnapshot
+import io.devconsole.remoteconfig.RemoteConfigSource
+import io.devconsole.security.RedactionEngine
+import io.devconsole.security.RedactionPolicy
+import org.junit.Assert.assertEquals
+import org.junit.Assert.assertFalse
+import org.junit.Assert.assertNull
+import org.junit.Assert.assertTrue
+import org.junit.Test
+
+class RemoteConfigInspectorTest {
+ private fun registryWith(vararg entries: RemoteConfigEntry): RemoteConfigRegistry =
+ RemoteConfigRegistry().apply {
+ register(
+ object : RemoteConfigProvider {
+ override val id: String = "firebase"
+
+ override fun snapshot(): RemoteConfigSnapshot =
+ RemoteConfigSnapshot(
+ providerId = "firebase",
+ entries = entries.toList(),
+ fetchInfo =
+ RemoteConfigFetchInfo(
+ lastFetchEpochMs = 1_755_043_200_000L,
+ status = RemoteConfigFetchStatus.SUCCESS,
+ minimumFetchIntervalSeconds = 3600L,
+ ),
+ )
+ },
+ )
+ }
+
+ private fun entry(
+ key: String,
+ value: String,
+ ) = RemoteConfigEntry(key = key, value = value, source = RemoteConfigSource.REMOTE)
+
+ private fun source(
+ config: DevConsoleConfig,
+ registry: RemoteConfigRegistry,
+ ) = FullInspectorDataSource(
+ InMemoryNetworkTransactionStore(NetworkCursorCodec("network-cursor-key-1234567890".encodeToByteArray())),
+ MockEngine(emptyList()),
+ configSupplier = { config },
+ remoteConfigRegistry = registry,
+ )
+
+ private fun enabledConfig() = DevConsoleConfig().withCaptureCategories(CaptureCategory.all())
+
+ @Test
+ fun `exposes remote config entries with their source`() {
+ val snapshot = source(enabledConfig(), registryWith(entry("checkout_v2", "true"))).snapshot()
+
+ val provider = snapshot.remoteConfig.single()
+ assertEquals("firebase", provider.id)
+ assertEquals("checkout_v2", provider.entries.single().key)
+ assertEquals("true", provider.entries.single().value)
+ assertEquals(RemoteConfigSource.REMOTE.wireName, provider.entries.single().source)
+ }
+
+ @Test
+ fun `carries fetch metadata onto the ui model`() {
+ val provider = source(enabledConfig(), registryWith(entry("k", "v"))).snapshot().remoteConfig.single()
+
+ assertEquals(1_755_043_200_000L, provider.lastFetchEpochMs)
+ assertEquals(RemoteConfigFetchStatus.SUCCESS.wireName, provider.status)
+ assertEquals(3600L, provider.minimumFetchIntervalSeconds)
+ assertNull(provider.unavailableReason)
+ }
+
+ @Test
+ fun `disabling the state category empties remote config`() {
+ val config = DevConsoleConfig().withCaptureCategories(CaptureCategory.all() - CaptureCategory.STATE)
+
+ val snapshot = source(config, registryWith(entry("checkout_v2", "true"))).snapshot()
+
+ assertTrue(snapshot.remoteConfig.isEmpty())
+ }
+
+ /**
+ * The Compose surface reads in-process and never crosses the HTTP boundary, so redaction applied
+ * only in the server would leave this path exposed.
+ */
+ @Test
+ fun `redacts a sensitive key on the in-process compose path`() {
+ val snapshot = source(enabledConfig(), registryWith(entry("api_key", "super-secret"))).snapshot()
+
+ val redacted =
+ snapshot.remoteConfig
+ .single()
+ .entries
+ .single()
+ assertEquals(RedactionPolicy.default().replacement, redacted.value)
+ assertTrue(redacted.redacted)
+ }
+
+ @Test
+ fun `keeps the key readable so you can see which value was withheld`() {
+ val snapshot = source(enabledConfig(), registryWith(entry("api_key", "super-secret"))).snapshot()
+
+ assertEquals(
+ "api_key",
+ snapshot.remoteConfig
+ .single()
+ .entries
+ .single()
+ .key,
+ )
+ }
+
+ @Test
+ fun `leaves an ordinary value untouched`() {
+ val snapshot = source(enabledConfig(), registryWith(entry("checkout_v2", "true"))).snapshot()
+
+ val plain =
+ snapshot.remoteConfig
+ .single()
+ .entries
+ .single()
+ assertEquals("true", plain.value)
+ assertFalse(plain.redacted)
+ }
+
+ @Test
+ fun `surfaces an unavailable provider rather than dropping it`() {
+ val registry =
+ RemoteConfigRegistry().apply {
+ register(
+ object : RemoteConfigProvider {
+ override val id: String = "firebase"
+
+ override fun snapshot(): RemoteConfigSnapshot = error("firebase exploded")
+ },
+ )
+ }
+
+ val provider = source(enabledConfig(), registry).snapshot().remoteConfig.single()
+
+ assertEquals("firebase exploded", provider.unavailableReason)
+ assertTrue(provider.entries.isEmpty())
+ }
+
+ @Test
+ fun `a null registry yields no remote config rather than failing`() {
+ val plain =
+ FullInspectorDataSource(
+ InMemoryNetworkTransactionStore(
+ NetworkCursorCodec("network-cursor-key-1234567890".encodeToByteArray()),
+ ),
+ MockEngine(emptyList()),
+ configSupplier = { enabledConfig() },
+ )
+
+ assertTrue(plain.snapshot().remoteConfig.isEmpty())
+ }
+
+ @Test
+ fun `redaction is applied by the shared boundary both surfaces read`() {
+ val entries =
+ redactingBoundary().apply(
+ listOf(entry("access_token", "raw"), entry("checkout_v2", "true")),
+ )
+
+ assertEquals(RedactionPolicy.default().replacement, entries.first().value)
+ assertTrue(entries.first().redacted)
+ assertEquals("true", entries.last().value)
+ assertFalse(entries.last().redacted)
+ }
+
+ /**
+ * The stock policy is an HTTP-header list matched by exact name, but Remote Config keys are
+ * written snake_case and camelCase -- so `api_key` must still match the policy's `api-key`.
+ */
+ @Test
+ fun `matches sensitive names across separator styles`() {
+ val entries =
+ redactingBoundary().apply(
+ // `api.key` included: dotted keys are an ordinary Remote Config naming style (the
+ // sample's own flags use `compose_sample.show_order_history`), and collapsing only
+ // `-`/`_` left it matching neither `api-key` nor `apikey`, shown in full.
+ listOf(
+ entry("api_key", "raw"),
+ entry("apiKey", "raw"),
+ entry("API-KEY", "raw"),
+ entry("api.key", "raw"),
+ ),
+ )
+
+ assertTrue(entries.all { it.redacted })
+ assertTrue(entries.all { it.value == RedactionPolicy.default().replacement })
+ }
+
+ @Test
+ fun `a bearer token inside an ordinary value is still scrubbed`() {
+ val entries = redactingBoundary().apply(listOf(entry("welcome_banner", "Bearer abc123def")))
+
+ assertTrue(entries.single().redacted)
+ assertFalse(entries.single().value.contains("abc123def"))
+ }
+
+ @Test
+ fun `a separator-free ordinary key is not over-redacted`() {
+ val entries = redactingBoundary().apply(listOf(entry("checkout_v2", "true"), entry("monkey", "yes")))
+
+ assertTrue(entries.none { it.redacted })
+ }
+
+ private fun redactingBoundary() =
+ RedactingRemoteConfig(RedactionEngine(RedactionPolicy.default()), RedactionPolicy.default())
+}
diff --git a/sdk/noop/api/noop.api b/sdk/noop/api/noop.api
index b3fa416..0fa96f0 100644
--- a/sdk/noop/api/noop.api
+++ b/sdk/noop/api/noop.api
@@ -14,6 +14,7 @@ public final class io/devconsole/DevConsole {
public static final fun networkRecorder ()Lio/devconsole/network/NetworkTransactionRecorder;
public static final fun open (Landroid/content/Context;)Lio/devconsole/api/InspectorOpenResult;
public static final fun recordPush (Lio/devconsole/push/PushInput;)Lio/devconsole/push/PushEvent;
+ public static final fun registerRemoteConfigProvider (Lio/devconsole/remoteconfig/RemoteConfigProvider;)Z
public static final fun registerStateProvider (Lio/devconsole/state/StateProvider;)Z
public static final fun socketRecorder ()Lio/devconsole/socket/SocketRecorder;
public static final fun startBrowser (Lio/devconsole/api/StartRequest;Lkotlin/coroutines/Continuation;)Ljava/lang/Object;
diff --git a/sdk/noop/src/main/kotlin/io/devconsole/PlatformFacadeProvider.kt b/sdk/noop/src/main/kotlin/io/devconsole/PlatformFacadeProvider.kt
index dddfb69..523fa18 100644
--- a/sdk/noop/src/main/kotlin/io/devconsole/PlatformFacadeProvider.kt
+++ b/sdk/noop/src/main/kotlin/io/devconsole/PlatformFacadeProvider.kt
@@ -25,6 +25,7 @@ import io.devconsole.push.InMemoryPushStore
import io.devconsole.push.PushEvent
import io.devconsole.push.PushInput
import io.devconsole.push.PushRecorder
+import io.devconsole.remoteconfig.RemoteConfigProvider
import io.devconsole.security.RedactionEngine
import io.devconsole.security.RedactionPolicy
import io.devconsole.socket.InMemorySocketStore
@@ -89,6 +90,8 @@ internal class PlatformFacadeProvider : DevConsoleFacadeProvider {
override fun registerStateProvider(provider: StateProvider): Boolean = false
+ override fun registerRemoteConfigProvider(provider: RemoteConfigProvider): Boolean = false
+
override fun endpoint(): BrowserEndpoint? = null
override fun accessInfo(): AccessInfo? = null
diff --git a/sdk/remote-config-firebase-noop/api/remote-config-firebase-noop.api b/sdk/remote-config-firebase-noop/api/remote-config-firebase-noop.api
new file mode 100644
index 0000000..270f7c1
--- /dev/null
+++ b/sdk/remote-config-firebase-noop/api/remote-config-firebase-noop.api
@@ -0,0 +1,8 @@
+public final class io/devconsole/remoteconfig/firebase/FirebaseRemoteConfigAdapter : io/devconsole/remoteconfig/RemoteConfigProvider {
+ public fun (Ljava/lang/Object;)V
+ public fun (Ljava/lang/Object;Ljava/lang/String;)V
+ public synthetic fun (Ljava/lang/Object;Ljava/lang/String;ILkotlin/jvm/internal/DefaultConstructorMarker;)V
+ public fun getId ()Ljava/lang/String;
+ public fun snapshot ()Lio/devconsole/remoteconfig/RemoteConfigSnapshot;
+}
+
diff --git a/sdk/remote-config-firebase-noop/build.gradle.kts b/sdk/remote-config-firebase-noop/build.gradle.kts
new file mode 100644
index 0000000..d6ec1b8
--- /dev/null
+++ b/sdk/remote-config-firebase-noop/build.gradle.kts
@@ -0,0 +1,11 @@
+plugins {
+ id("devconsole.android.library")
+ id("devconsole.quality")
+ id("devconsole.publishing")
+}
+
+android { namespace = "io.devconsole.remoteconfig.firebase.noop" }
+
+dependencies {
+ api(project(":sdk:remote-config"))
+}
diff --git a/sdk/remote-config-firebase-noop/src/main/kotlin/io/devconsole/remoteconfig/firebase/FirebaseRemoteConfigAdapter.kt b/sdk/remote-config-firebase-noop/src/main/kotlin/io/devconsole/remoteconfig/firebase/FirebaseRemoteConfigAdapter.kt
new file mode 100644
index 0000000..b275288
--- /dev/null
+++ b/sdk/remote-config-firebase-noop/src/main/kotlin/io/devconsole/remoteconfig/firebase/FirebaseRemoteConfigAdapter.kt
@@ -0,0 +1,31 @@
+/**
+ * @author Md. Asaduzzaman Nur
+ * @since 13/08/26
+ */
+package io.devconsole.remoteconfig.firebase
+
+import io.devconsole.remoteconfig.RemoteConfigFetchInfo
+import io.devconsole.remoteconfig.RemoteConfigProvider
+import io.devconsole.remoteconfig.RemoteConfigSnapshot
+
+/**
+ * Protected-build adapter: does not reflect on or read the supplied Firebase instance.
+ *
+ * It reports `disabled-build` rather than an empty config, because "this build cannot show you
+ * Remote Config" and "this app has no Remote Config values" are different answers, and silently
+ * returning the second would be a misleading debugging tool.
+ */
+class FirebaseRemoteConfigAdapter
+ @JvmOverloads
+ constructor(
+ @Suppress("UNUSED_PARAMETER") remoteConfig: Any,
+ override val id: String = "firebase",
+ ) : RemoteConfigProvider {
+ override fun snapshot(): RemoteConfigSnapshot =
+ RemoteConfigSnapshot(
+ providerId = id,
+ entries = emptyList(),
+ fetchInfo = RemoteConfigFetchInfo.unknown(),
+ unavailableReason = "disabled-build",
+ )
+ }
diff --git a/sdk/remote-config-firebase-noop/src/test/kotlin/io/devconsole/remoteconfig/firebase/FirebaseRemoteConfigAdapterNoopTest.kt b/sdk/remote-config-firebase-noop/src/test/kotlin/io/devconsole/remoteconfig/firebase/FirebaseRemoteConfigAdapterNoopTest.kt
new file mode 100644
index 0000000..836b410
--- /dev/null
+++ b/sdk/remote-config-firebase-noop/src/test/kotlin/io/devconsole/remoteconfig/firebase/FirebaseRemoteConfigAdapterNoopTest.kt
@@ -0,0 +1,62 @@
+/**
+ * @author Md. Asaduzzaman Nur
+ * @since 13/08/26
+ */
+package io.devconsole.remoteconfig.firebase
+
+import io.devconsole.remoteconfig.RemoteConfigFetchStatus
+import org.junit.Assert.assertEquals
+import org.junit.Assert.assertFalse
+import org.junit.Assert.assertNull
+import org.junit.Assert.assertTrue
+import org.junit.Test
+
+class FirebaseRemoteConfigAdapterNoopTest {
+ private class SpyRemoteConfig {
+ var touched: Boolean = false
+
+ fun getAll(): Map {
+ touched = true
+ return emptyMap()
+ }
+
+ fun getInfo(): Any {
+ touched = true
+ return Any()
+ }
+ }
+
+ @Test
+ fun `reports no entries in a protected build`() {
+ assertTrue(FirebaseRemoteConfigAdapter(SpyRemoteConfig()).snapshot().entries.isEmpty())
+ }
+
+ @Test
+ fun `labels itself a disabled build rather than pretending config is simply empty`() {
+ assertEquals("disabled-build", FirebaseRemoteConfigAdapter(SpyRemoteConfig()).snapshot().unavailableReason)
+ }
+
+ @Test
+ fun `never reflects on the supplied firebase instance`() {
+ val spy = SpyRemoteConfig()
+
+ FirebaseRemoteConfigAdapter(spy).snapshot()
+
+ assertFalse(spy.touched)
+ }
+
+ @Test
+ fun `reports no fetch metadata`() {
+ val fetch = FirebaseRemoteConfigAdapter(SpyRemoteConfig()).snapshot().fetchInfo
+
+ assertEquals(RemoteConfigFetchStatus.UNKNOWN, fetch.status)
+ assertNull(fetch.lastFetchEpochMs)
+ assertNull(fetch.minimumFetchIntervalSeconds)
+ }
+
+ @Test
+ fun `keeps the same id contract as the enabled adapter`() {
+ assertEquals("firebase", FirebaseRemoteConfigAdapter(SpyRemoteConfig()).id)
+ assertEquals("rc-staging", FirebaseRemoteConfigAdapter(SpyRemoteConfig(), "rc-staging").id)
+ }
+}
diff --git a/sdk/remote-config-firebase/api/remote-config-firebase.api b/sdk/remote-config-firebase/api/remote-config-firebase.api
new file mode 100644
index 0000000..3cd1bda
--- /dev/null
+++ b/sdk/remote-config-firebase/api/remote-config-firebase.api
@@ -0,0 +1,15 @@
+public final class io/devconsole/remoteconfig/firebase/FirebaseRemoteConfigAdapter : io/devconsole/remoteconfig/RemoteConfigProvider {
+ public static final field LAST_FETCH_STATUS_FAILURE I
+ public static final field LAST_FETCH_STATUS_NO_FETCH_YET I
+ public static final field LAST_FETCH_STATUS_SUCCESS I
+ public static final field LAST_FETCH_STATUS_THROTTLED I
+ public static final field VALUE_SOURCE_DEFAULT I
+ public static final field VALUE_SOURCE_REMOTE I
+ public static final field VALUE_SOURCE_STATIC I
+ public fun (Ljava/lang/Object;)V
+ public fun (Ljava/lang/Object;Ljava/lang/String;)V
+ public synthetic fun (Ljava/lang/Object;Ljava/lang/String;ILkotlin/jvm/internal/DefaultConstructorMarker;)V
+ public fun getId ()Ljava/lang/String;
+ public fun snapshot ()Lio/devconsole/remoteconfig/RemoteConfigSnapshot;
+}
+
diff --git a/sdk/remote-config-firebase/build.gradle.kts b/sdk/remote-config-firebase/build.gradle.kts
new file mode 100644
index 0000000..23661f1
--- /dev/null
+++ b/sdk/remote-config-firebase/build.gradle.kts
@@ -0,0 +1,12 @@
+plugins {
+ id("devconsole.android.library")
+ id("devconsole.quality")
+ id("devconsole.publishing")
+}
+android {
+ namespace = "io.devconsole.remoteconfig.firebase"
+ defaultConfig { consumerProguardFiles("consumer-rules.pro") }
+}
+// `api`, not `implementation`: the adapter implements the public RemoteConfigProvider interface and
+// hosts must name that type to hand the adapter to DevConsoleConfig.
+dependencies { api(project(":sdk:remote-config")) }
diff --git a/sdk/remote-config-firebase/consumer-rules.pro b/sdk/remote-config-firebase/consumer-rules.pro
new file mode 100644
index 0000000..5420daa
--- /dev/null
+++ b/sdk/remote-config-firebase/consumer-rules.pro
@@ -0,0 +1 @@
+-keep class io.devconsole.internal.enabled.RemoteConfigFirebaseCaptureMarker { *; }
diff --git a/sdk/remote-config-firebase/src/main/kotlin/io/devconsole/internal/enabled/RemoteConfigFirebaseCaptureMarker.kt b/sdk/remote-config-firebase/src/main/kotlin/io/devconsole/internal/enabled/RemoteConfigFirebaseCaptureMarker.kt
new file mode 100644
index 0000000..757c128
--- /dev/null
+++ b/sdk/remote-config-firebase/src/main/kotlin/io/devconsole/internal/enabled/RemoteConfigFirebaseCaptureMarker.kt
@@ -0,0 +1,9 @@
+/**
+ * @author Md. Asaduzzaman Nur
+ * @since 13/08/26
+ */
+package io.devconsole.internal.enabled
+
+internal object RemoteConfigFirebaseCaptureMarker {
+ const val SIGNATURE = "DEVCONSOLE_ENABLED_REMOTE_CONFIG_FIREBASE_V1"
+}
diff --git a/sdk/remote-config-firebase/src/main/kotlin/io/devconsole/remoteconfig/firebase/FirebaseRemoteConfigAdapter.kt b/sdk/remote-config-firebase/src/main/kotlin/io/devconsole/remoteconfig/firebase/FirebaseRemoteConfigAdapter.kt
new file mode 100644
index 0000000..6c99df5
--- /dev/null
+++ b/sdk/remote-config-firebase/src/main/kotlin/io/devconsole/remoteconfig/firebase/FirebaseRemoteConfigAdapter.kt
@@ -0,0 +1,155 @@
+/**
+ * @author Md. Asaduzzaman Nur
+ * @since 13/08/26
+ */
+package io.devconsole.remoteconfig.firebase
+
+import io.devconsole.remoteconfig.RemoteConfigEntry
+import io.devconsole.remoteconfig.RemoteConfigFetchInfo
+import io.devconsole.remoteconfig.RemoteConfigFetchStatus
+import io.devconsole.remoteconfig.RemoteConfigProvider
+import io.devconsole.remoteconfig.RemoteConfigSnapshot
+import io.devconsole.remoteconfig.RemoteConfigSource
+import java.lang.reflect.Method
+
+// Deliberately not the exception's message: the throw is swallowed inside `call`. Kept a private
+// top-level const rather than a companion one, which would compile to a public static field.
+private const val UNREADABLE_REASON = "Firebase Remote Config could not be read reflectively"
+
+/**
+ * Optional Firebase bridge with no Firebase compile-time dependency. Consumers pass a
+ * `com.google.firebase.remoteconfig.FirebaseRemoteConfig`; reflection keeps Firebase absent
+ * everywhere else, exactly as `FirebaseRemoteMessageAdapter` does for Cloud Messaging.
+ */
+class FirebaseRemoteConfigAdapter
+ @JvmOverloads
+ constructor(
+ private val remoteConfig: Any,
+ override val id: String = "firebase",
+ ) : RemoteConfigProvider {
+ override fun snapshot(): RemoteConfigSnapshot {
+ // `getAll` returning a non-Map is how a non-Firebase object, or a getAll that blew up
+ // (R8, a renamed method), reaches us. Reporting that as an empty-but-fine snapshot would
+ // make both surfaces say "this provider has not completed a fetch yet" -- a confident
+ // claim about a provider we never got an answer out of, and exactly the confusion the
+ // no-op twin exists to avoid. An unavailableReason says we could not read it instead.
+ val all =
+ remoteConfig.call("getAll") as? Map<*, *>
+ ?: return RemoteConfigSnapshot(
+ providerId = id,
+ entries = emptyList(),
+ fetchInfo = RemoteConfigFetchInfo.unknown(),
+ unavailableReason = UNREADABLE_REASON,
+ )
+ return RemoteConfigSnapshot(
+ providerId = id,
+ entries = readEntries(all),
+ fetchInfo = readFetchInfo(),
+ )
+ }
+
+ /**
+ * Sorted by key: Firebase hands back an unordered map, and an inspector whose rows reshuffle
+ * on every refresh is unreadable when you are watching one key.
+ */
+ private fun readEntries(all: Map<*, *>): List =
+ all.entries
+ .mapNotNull { (key, value) ->
+ val name = key as? String ?: return@mapNotNull null
+ RemoteConfigEntry(
+ key = name,
+ value = value?.call("asString") as? String ?: "",
+ source = sourceOf(value),
+ )
+ }.sortedBy(RemoteConfigEntry::key)
+
+ private fun sourceOf(value: Any?): RemoteConfigSource =
+ when ((value?.call("getSource") as? Number)?.toInt()) {
+ sourceRemote -> RemoteConfigSource.REMOTE
+ sourceDefault -> RemoteConfigSource.DEFAULT
+ sourceStatic -> RemoteConfigSource.STATIC
+ else -> RemoteConfigSource.UNKNOWN
+ }
+
+ private fun readFetchInfo(): RemoteConfigFetchInfo {
+ val info = remoteConfig.call("getInfo") ?: return RemoteConfigFetchInfo.unknown()
+ return RemoteConfigFetchInfo(
+ lastFetchEpochMs = (info.call("getFetchTimeMillis") as? Number)?.toLong()?.takeIf { it > 0 },
+ status = statusOf(info),
+ minimumFetchIntervalSeconds =
+ (
+ info
+ .call("getConfigSettings")
+ ?.call("getMinimumFetchIntervalInSeconds") as? Number
+ )?.toLong(),
+ )
+ }
+
+ private fun statusOf(info: Any): RemoteConfigFetchStatus =
+ when ((info.call("getLastFetchStatus") as? Number)?.toInt()) {
+ statusSuccess -> RemoteConfigFetchStatus.SUCCESS
+ statusNoFetchYet -> RemoteConfigFetchStatus.NO_FETCH_YET
+ statusFailure -> RemoteConfigFetchStatus.FAILURE
+ statusThrottled -> RemoteConfigFetchStatus.THROTTLED
+ else -> RemoteConfigFetchStatus.UNKNOWN
+ }
+
+ /**
+ * Resolved once per adapter rather than per `when` evaluation: these sat inside the branch
+ * conditions, so every entry's source and every fetch-status read re-ran a `getField`
+ * lookup. Still prefers the constant declared on the supplied Firebase class over the
+ * literal fallback, so a future renumbering in the Firebase SDK cannot silently mis-badge
+ * every row.
+ */
+ private fun constant(
+ name: String,
+ fallback: Int,
+ ): Int = runCatching { remoteConfig.javaClass.getField(name).getInt(null) }.getOrDefault(fallback)
+
+ private val sourceStatic by lazy { constant("VALUE_SOURCE_STATIC", VALUE_SOURCE_STATIC) }
+ private val sourceDefault by lazy { constant("VALUE_SOURCE_DEFAULT", VALUE_SOURCE_DEFAULT) }
+ private val sourceRemote by lazy { constant("VALUE_SOURCE_REMOTE", VALUE_SOURCE_REMOTE) }
+ private val statusSuccess by lazy { constant("LAST_FETCH_STATUS_SUCCESS", LAST_FETCH_STATUS_SUCCESS) }
+ private val statusNoFetchYet by lazy {
+ constant("LAST_FETCH_STATUS_NO_FETCH_YET", LAST_FETCH_STATUS_NO_FETCH_YET)
+ }
+ private val statusFailure by lazy { constant("LAST_FETCH_STATUS_FAILURE", LAST_FETCH_STATUS_FAILURE) }
+ private val statusThrottled by lazy { constant("LAST_FETCH_STATUS_THROTTLED", LAST_FETCH_STATUS_THROTTLED) }
+
+ /**
+ * `Class.getMethods()` allocates a fresh defensive copy on every call and this then linear-
+ * scans it, which at a few hundred keys ran twice per entry (`asString`, `getSource`) on
+ * every inspector refresh and every dashboard poll. Cached per receiver *class*, not per
+ * receiver: the map's values are `FirebaseRemoteConfigValue` instances, one per key, all of
+ * the same class. A null result is cached too -- a name that is absent stays absent.
+ */
+ private val methodCache = HashMap, String>, Method?>()
+
+ private fun Any.call(name: String): Any? =
+ runCatching {
+ val key = javaClass to name
+ val method =
+ synchronized(methodCache) {
+ if (methodCache.containsKey(key)) {
+ methodCache[key]
+ } else {
+ javaClass.methods
+ .firstOrNull { it.name == name && it.parameterCount == 0 }
+ .also { methodCache[key] = it }
+ }
+ }
+ method?.invoke(this)
+ }.getOrNull()
+
+ private companion object {
+ // Verified against firebase-android-sdk's FirebaseRemoteConfig.java. LAST_FETCH_STATUS_SUCCESS
+ // is -1, not 0 -- treating "negative" as unknown would mislabel every successful fetch.
+ const val VALUE_SOURCE_STATIC = 0
+ const val VALUE_SOURCE_DEFAULT = 1
+ const val VALUE_SOURCE_REMOTE = 2
+ const val LAST_FETCH_STATUS_SUCCESS = -1
+ const val LAST_FETCH_STATUS_NO_FETCH_YET = 0
+ const val LAST_FETCH_STATUS_FAILURE = 1
+ const val LAST_FETCH_STATUS_THROTTLED = 2
+ }
+ }
diff --git a/sdk/remote-config-firebase/src/test/kotlin/io/devconsole/remoteconfig/firebase/FirebaseRemoteConfigAdapterTest.kt b/sdk/remote-config-firebase/src/test/kotlin/io/devconsole/remoteconfig/firebase/FirebaseRemoteConfigAdapterTest.kt
new file mode 100644
index 0000000..5f11b26
--- /dev/null
+++ b/sdk/remote-config-firebase/src/test/kotlin/io/devconsole/remoteconfig/firebase/FirebaseRemoteConfigAdapterTest.kt
@@ -0,0 +1,234 @@
+/**
+ * @author Md. Asaduzzaman Nur
+ * @since 13/08/26
+ */
+package io.devconsole.remoteconfig.firebase
+
+import io.devconsole.remoteconfig.RemoteConfigFetchStatus
+import io.devconsole.remoteconfig.RemoteConfigSource
+import org.junit.Assert.assertEquals
+import org.junit.Assert.assertNotNull
+import org.junit.Assert.assertNull
+import org.junit.Assert.assertTrue
+import org.junit.Test
+
+/**
+ * Drives the adapter with plain Kotlin stand-ins whose method names match Firebase's, the same
+ * technique `FirebaseRemoteMessageAdapterTest` uses -- so the real Firebase SDK never enters this
+ * module's test classpath, which is the whole point of the reflection bridge.
+ */
+class FirebaseRemoteConfigAdapterTest {
+ private class FakeValue(
+ private val value: String,
+ val source: Int,
+ ) {
+ fun asString(): String = value
+ }
+
+ private class FakeSettings(
+ val minimumFetchIntervalInSeconds: Long,
+ )
+
+ private class FakeInfo(
+ val fetchTimeMillis: Long,
+ val lastFetchStatus: Int,
+ val configSettings: FakeSettings = FakeSettings(3600L),
+ )
+
+ private class FakeRemoteConfig(
+ private val all: Map,
+ private val info: FakeInfo = FakeInfo(FETCH_TIME, SUCCESS),
+ ) {
+ fun getAll(): Map = all
+
+ fun getInfo(): FakeInfo = info
+ }
+
+ @Test
+ fun `maps firebase value sources onto the vendor-neutral enum`() {
+ val adapter =
+ FirebaseRemoteConfigAdapter(
+ FakeRemoteConfig(
+ mapOf(
+ "fromServer" to FakeValue("a", VALUE_SOURCE_REMOTE),
+ "fromDefaults" to FakeValue("b", VALUE_SOURCE_DEFAULT),
+ "fromNowhere" to FakeValue("c", VALUE_SOURCE_STATIC),
+ ),
+ ),
+ )
+
+ val bySource = adapter.snapshot().entries.associate { it.key to it.source }
+
+ assertEquals(RemoteConfigSource.REMOTE, bySource["fromServer"])
+ assertEquals(RemoteConfigSource.DEFAULT, bySource["fromDefaults"])
+ assertEquals(RemoteConfigSource.STATIC, bySource["fromNowhere"])
+ }
+
+ @Test
+ fun `an unrecognised source integer reads as unknown rather than being guessed`() {
+ val adapter = FirebaseRemoteConfigAdapter(FakeRemoteConfig(mapOf("k" to FakeValue("v", 99))))
+
+ assertEquals(
+ RemoteConfigSource.UNKNOWN,
+ adapter
+ .snapshot()
+ .entries
+ .single()
+ .source,
+ )
+ }
+
+ @Test
+ fun `reads the value through asString`() {
+ val adapter =
+ FirebaseRemoteConfigAdapter(FakeRemoteConfig(mapOf("k" to FakeValue("hello", VALUE_SOURCE_REMOTE))))
+
+ assertEquals(
+ "hello",
+ adapter
+ .snapshot()
+ .entries
+ .single()
+ .value,
+ )
+ }
+
+ /** Firebase's LAST_FETCH_STATUS_SUCCESS is -1, so a "negative means unknown" guess breaks every success. */
+ @Test
+ fun `fetch status success is the negative constant`() {
+ val adapter = fetchInfoAdapter(FakeInfo(FETCH_TIME, SUCCESS))
+
+ assertEquals(RemoteConfigFetchStatus.SUCCESS, adapter.snapshot().fetchInfo.status)
+ }
+
+ @Test
+ fun `maps the remaining fetch statuses`() {
+ assertEquals(
+ RemoteConfigFetchStatus.NO_FETCH_YET,
+ fetchInfoAdapter(FakeInfo(FETCH_TIME, NO_FETCH_YET)).snapshot().fetchInfo.status,
+ )
+ assertEquals(
+ RemoteConfigFetchStatus.FAILURE,
+ fetchInfoAdapter(FakeInfo(FETCH_TIME, FAILURE)).snapshot().fetchInfo.status,
+ )
+ assertEquals(
+ RemoteConfigFetchStatus.THROTTLED,
+ fetchInfoAdapter(FakeInfo(FETCH_TIME, THROTTLED)).snapshot().fetchInfo.status,
+ )
+ }
+
+ @Test
+ fun `an unrecognised fetch status reads as unknown`() {
+ assertEquals(
+ RemoteConfigFetchStatus.UNKNOWN,
+ fetchInfoAdapter(FakeInfo(FETCH_TIME, 77)).snapshot().fetchInfo.status,
+ )
+ }
+
+ /** Firebase reports -1 for "no fetch yet"; rendering that raw would date the fetch to 1969. */
+ @Test
+ fun `a negative fetch time reads as never fetched rather than an epoch sentinel`() {
+ val adapter = fetchInfoAdapter(FakeInfo(-1L, NO_FETCH_YET))
+
+ assertNull(adapter.snapshot().fetchInfo.lastFetchEpochMs)
+ }
+
+ @Test
+ fun `a real fetch time is carried through`() {
+ val adapter = fetchInfoAdapter(FakeInfo(FETCH_TIME, SUCCESS))
+
+ assertEquals(FETCH_TIME, adapter.snapshot().fetchInfo.lastFetchEpochMs)
+ }
+
+ @Test
+ fun `reads the minimum fetch interval from the nested config settings`() {
+ val adapter = fetchInfoAdapter(FakeInfo(FETCH_TIME, SUCCESS, FakeSettings(43_200L)))
+
+ assertEquals(43_200L, adapter.snapshot().fetchInfo.minimumFetchIntervalSeconds)
+ }
+
+ @Test
+ fun `entries are sorted by key so a refresh does not reshuffle the table`() {
+ val adapter =
+ FirebaseRemoteConfigAdapter(
+ FakeRemoteConfig(
+ mapOf(
+ "zeta" to FakeValue("z", VALUE_SOURCE_REMOTE),
+ "alpha" to FakeValue("a", VALUE_SOURCE_REMOTE),
+ "mid" to FakeValue("m", VALUE_SOURCE_REMOTE),
+ ),
+ ),
+ )
+
+ assertEquals(listOf("alpha", "mid", "zeta"), adapter.snapshot().entries.map { it.key })
+ }
+
+ @Test
+ fun `an object that is not firebase shaped yields an unavailable snapshot instead of throwing`() {
+ val snapshot = FirebaseRemoteConfigAdapter(Any()).snapshot()
+
+ assertTrue(snapshot.entries.isEmpty())
+ assertEquals(RemoteConfigFetchStatus.UNKNOWN, snapshot.fetchInfo.status)
+ assertNull(snapshot.fetchInfo.lastFetchEpochMs)
+ // The assertion this test was named for. Without it, "unavailable" was true of nothing a
+ // user could see: an empty snapshot with a null reason renders on both surfaces as "this
+ // provider has not completed a fetch yet", which is a claim about a fetch we never made.
+ assertNotNull(snapshot.unavailableReason)
+ }
+
+ @Test
+ fun `a remote config whose getAll throws is unavailable rather than silently empty`() {
+ val exploding =
+ object {
+ fun getAll(): Map = error("firebase exploded")
+ }
+
+ val snapshot = FirebaseRemoteConfigAdapter(exploding).snapshot()
+
+ assertTrue(snapshot.entries.isEmpty())
+ assertNotNull(snapshot.unavailableReason)
+ }
+
+ @Test
+ fun `a readable config reports no unavailable reason`() {
+ val snapshot = FirebaseRemoteConfigAdapter(FakeRemoteConfig(mapOf("k" to FakeValue("v", 2)))).snapshot()
+
+ assertNull(snapshot.unavailableReason)
+ assertTrue(snapshot.entries.isNotEmpty())
+ }
+
+ @Test
+ fun `a remote config whose getAll throws does not propagate`() {
+ val exploding =
+ object {
+ fun getAll(): Map = error("firebase exploded")
+
+ fun getInfo(): FakeInfo = FakeInfo(FETCH_TIME, SUCCESS)
+ }
+
+ assertTrue(FirebaseRemoteConfigAdapter(exploding).snapshot().entries.isEmpty())
+ }
+
+ @Test
+ fun `defaults its provider id to firebase and honours an explicit one`() {
+ assertEquals("firebase", FirebaseRemoteConfigAdapter(FakeRemoteConfig(emptyMap())).id)
+ assertEquals("rc-staging", FirebaseRemoteConfigAdapter(FakeRemoteConfig(emptyMap()), "rc-staging").id)
+ assertEquals(
+ "rc-staging",
+ FirebaseRemoteConfigAdapter(FakeRemoteConfig(emptyMap()), "rc-staging").snapshot().providerId,
+ )
+ }
+
+ private fun fetchInfoAdapter(info: FakeInfo) = FirebaseRemoteConfigAdapter(FakeRemoteConfig(emptyMap(), info))
+
+ private companion object {
+ const val VALUE_SOURCE_STATIC = 0
+ const val VALUE_SOURCE_DEFAULT = 1
+ const val VALUE_SOURCE_REMOTE = 2
+ const val SUCCESS = -1
+ const val NO_FETCH_YET = 0
+ const val FAILURE = 1
+ const val THROTTLED = 2
+ const val FETCH_TIME = 1_755_043_200_000L
+ }
+}
diff --git a/sdk/remote-config/api/remote-config.api b/sdk/remote-config/api/remote-config.api
new file mode 100644
index 0000000..730f608
--- /dev/null
+++ b/sdk/remote-config/api/remote-config.api
@@ -0,0 +1,108 @@
+public final class io/devconsole/remoteconfig/RemoteConfigEntry {
+ public fun (Ljava/lang/String;Ljava/lang/String;Lio/devconsole/remoteconfig/RemoteConfigSource;ZZ)V
+ public synthetic fun (Ljava/lang/String;Ljava/lang/String;Lio/devconsole/remoteconfig/RemoteConfigSource;ZZILkotlin/jvm/internal/DefaultConstructorMarker;)V
+ public final fun component1 ()Ljava/lang/String;
+ public final fun component2 ()Ljava/lang/String;
+ public final fun component3 ()Lio/devconsole/remoteconfig/RemoteConfigSource;
+ public final fun component4 ()Z
+ public final fun component5 ()Z
+ public final fun copy (Ljava/lang/String;Ljava/lang/String;Lio/devconsole/remoteconfig/RemoteConfigSource;ZZ)Lio/devconsole/remoteconfig/RemoteConfigEntry;
+ public static synthetic fun copy$default (Lio/devconsole/remoteconfig/RemoteConfigEntry;Ljava/lang/String;Ljava/lang/String;Lio/devconsole/remoteconfig/RemoteConfigSource;ZZILjava/lang/Object;)Lio/devconsole/remoteconfig/RemoteConfigEntry;
+ public fun equals (Ljava/lang/Object;)Z
+ public final fun getKey ()Ljava/lang/String;
+ public final fun getRedacted ()Z
+ public final fun getSource ()Lio/devconsole/remoteconfig/RemoteConfigSource;
+ public final fun getTruncated ()Z
+ public final fun getValue ()Ljava/lang/String;
+ public fun hashCode ()I
+ public fun toString ()Ljava/lang/String;
+}
+
+public final class io/devconsole/remoteconfig/RemoteConfigFetchInfo {
+ public static final field Companion Lio/devconsole/remoteconfig/RemoteConfigFetchInfo$Companion;
+ public fun (Ljava/lang/Long;Lio/devconsole/remoteconfig/RemoteConfigFetchStatus;Ljava/lang/Long;)V
+ public final fun component1 ()Ljava/lang/Long;
+ public final fun component2 ()Lio/devconsole/remoteconfig/RemoteConfigFetchStatus;
+ public final fun component3 ()Ljava/lang/Long;
+ public final fun copy (Ljava/lang/Long;Lio/devconsole/remoteconfig/RemoteConfigFetchStatus;Ljava/lang/Long;)Lio/devconsole/remoteconfig/RemoteConfigFetchInfo;
+ public static synthetic fun copy$default (Lio/devconsole/remoteconfig/RemoteConfigFetchInfo;Ljava/lang/Long;Lio/devconsole/remoteconfig/RemoteConfigFetchStatus;Ljava/lang/Long;ILjava/lang/Object;)Lio/devconsole/remoteconfig/RemoteConfigFetchInfo;
+ public fun equals (Ljava/lang/Object;)Z
+ public final fun getLastFetchEpochMs ()Ljava/lang/Long;
+ public final fun getMinimumFetchIntervalSeconds ()Ljava/lang/Long;
+ public final fun getStatus ()Lio/devconsole/remoteconfig/RemoteConfigFetchStatus;
+ public fun hashCode ()I
+ public fun toString ()Ljava/lang/String;
+ public static final fun unknown ()Lio/devconsole/remoteconfig/RemoteConfigFetchInfo;
+}
+
+public final class io/devconsole/remoteconfig/RemoteConfigFetchInfo$Companion {
+ public final fun unknown ()Lio/devconsole/remoteconfig/RemoteConfigFetchInfo;
+}
+
+public final class io/devconsole/remoteconfig/RemoteConfigFetchStatus : java/lang/Enum {
+ public static final field FAILURE Lio/devconsole/remoteconfig/RemoteConfigFetchStatus;
+ public static final field NO_FETCH_YET Lio/devconsole/remoteconfig/RemoteConfigFetchStatus;
+ public static final field SUCCESS Lio/devconsole/remoteconfig/RemoteConfigFetchStatus;
+ public static final field THROTTLED Lio/devconsole/remoteconfig/RemoteConfigFetchStatus;
+ public static final field UNKNOWN Lio/devconsole/remoteconfig/RemoteConfigFetchStatus;
+ public static fun getEntries ()Lkotlin/enums/EnumEntries;
+ public final fun getWireName ()Ljava/lang/String;
+ public static fun valueOf (Ljava/lang/String;)Lio/devconsole/remoteconfig/RemoteConfigFetchStatus;
+ public static fun values ()[Lio/devconsole/remoteconfig/RemoteConfigFetchStatus;
+}
+
+public abstract interface class io/devconsole/remoteconfig/RemoteConfigProvider {
+ public abstract fun getId ()Ljava/lang/String;
+ public abstract fun snapshot ()Lio/devconsole/remoteconfig/RemoteConfigSnapshot;
+}
+
+public final class io/devconsole/remoteconfig/RemoteConfigRegistry {
+ public static final field Companion Lio/devconsole/remoteconfig/RemoteConfigRegistry$Companion;
+ public static final field MAX_VALUE_LENGTH I
+ public fun ()V
+ public final fun clear ()V
+ public final fun providerIds ()Ljava/util/List;
+ public final fun register (Lio/devconsole/remoteconfig/RemoteConfigProvider;)V
+ public final fun snapshot (Ljava/lang/String;)Lio/devconsole/remoteconfig/RemoteConfigSnapshot;
+ public final fun snapshots ()Ljava/util/List;
+}
+
+public final class io/devconsole/remoteconfig/RemoteConfigRegistry$Companion {
+}
+
+public final class io/devconsole/remoteconfig/RemoteConfigSnapshot {
+ public fun (Ljava/lang/String;Ljava/util/List;Lio/devconsole/remoteconfig/RemoteConfigFetchInfo;Ljava/lang/String;)V
+ public synthetic fun (Ljava/lang/String;Ljava/util/List;Lio/devconsole/remoteconfig/RemoteConfigFetchInfo;Ljava/lang/String;ILkotlin/jvm/internal/DefaultConstructorMarker;)V
+ public final fun component1 ()Ljava/lang/String;
+ public final fun component2 ()Ljava/util/List;
+ public final fun component3 ()Lio/devconsole/remoteconfig/RemoteConfigFetchInfo;
+ public final fun component4 ()Ljava/lang/String;
+ public final fun copy (Ljava/lang/String;Ljava/util/List;Lio/devconsole/remoteconfig/RemoteConfigFetchInfo;Ljava/lang/String;)Lio/devconsole/remoteconfig/RemoteConfigSnapshot;
+ public static synthetic fun copy$default (Lio/devconsole/remoteconfig/RemoteConfigSnapshot;Ljava/lang/String;Ljava/util/List;Lio/devconsole/remoteconfig/RemoteConfigFetchInfo;Ljava/lang/String;ILjava/lang/Object;)Lio/devconsole/remoteconfig/RemoteConfigSnapshot;
+ public fun equals (Ljava/lang/Object;)Z
+ public final fun getEntries ()Ljava/util/List;
+ public final fun getFetchInfo ()Lio/devconsole/remoteconfig/RemoteConfigFetchInfo;
+ public final fun getProviderId ()Ljava/lang/String;
+ public final fun getUnavailableReason ()Ljava/lang/String;
+ public fun hashCode ()I
+ public fun toString ()Ljava/lang/String;
+}
+
+public final class io/devconsole/remoteconfig/RemoteConfigSource : java/lang/Enum {
+ public static final field Companion Lio/devconsole/remoteconfig/RemoteConfigSource$Companion;
+ public static final field DEFAULT Lio/devconsole/remoteconfig/RemoteConfigSource;
+ public static final field OVERRIDE Lio/devconsole/remoteconfig/RemoteConfigSource;
+ public static final field REMOTE Lio/devconsole/remoteconfig/RemoteConfigSource;
+ public static final field STATIC Lio/devconsole/remoteconfig/RemoteConfigSource;
+ public static final field UNKNOWN Lio/devconsole/remoteconfig/RemoteConfigSource;
+ public static final fun fromWireName (Ljava/lang/String;)Lio/devconsole/remoteconfig/RemoteConfigSource;
+ public static fun getEntries ()Lkotlin/enums/EnumEntries;
+ public final fun getWireName ()Ljava/lang/String;
+ public static fun valueOf (Ljava/lang/String;)Lio/devconsole/remoteconfig/RemoteConfigSource;
+ public static fun values ()[Lio/devconsole/remoteconfig/RemoteConfigSource;
+}
+
+public final class io/devconsole/remoteconfig/RemoteConfigSource$Companion {
+ public final fun fromWireName (Ljava/lang/String;)Lio/devconsole/remoteconfig/RemoteConfigSource;
+}
+
diff --git a/sdk/remote-config/build.gradle.kts b/sdk/remote-config/build.gradle.kts
new file mode 100644
index 0000000..7b77444
--- /dev/null
+++ b/sdk/remote-config/build.gradle.kts
@@ -0,0 +1,5 @@
+plugins {
+ id("devconsole.kotlin.jvm")
+ id("devconsole.quality")
+ id("devconsole.publishing")
+}
diff --git a/sdk/remote-config/src/main/kotlin/io/devconsole/remoteconfig/RemoteConfig.kt b/sdk/remote-config/src/main/kotlin/io/devconsole/remoteconfig/RemoteConfig.kt
new file mode 100644
index 0000000..a6d5a46
--- /dev/null
+++ b/sdk/remote-config/src/main/kotlin/io/devconsole/remoteconfig/RemoteConfig.kt
@@ -0,0 +1,107 @@
+/**
+ * @author Md. Asaduzzaman Nur
+ * @since 13/08/26
+ */
+package io.devconsole.remoteconfig
+
+/**
+ * Where a Remote Config value actually came from. This -- not the value itself -- is what makes a
+ * config problem diagnosable: a key serving an in-app [DEFAULT] because the fetch was throttled
+ * looks identical to one the server published, until you can see the source.
+ */
+enum class RemoteConfigSource(
+ val wireName: String,
+) {
+ /** Fetched from the server and activated. */
+ REMOTE("remote"),
+
+ /** An in-app default (e.g. Firebase's `setDefaultsAsync`); no server value is active. */
+ DEFAULT("default"),
+
+ /** Set nowhere -- the provider's static fallback for an unknown key. */
+ STATIC("static"),
+
+ /** A locally applied override sitting on top of whatever the provider resolved. */
+ OVERRIDE("override"),
+
+ /** The provider could not attribute the value. Never guessed at. */
+ UNKNOWN("unknown"),
+ ;
+
+ companion object {
+ @JvmStatic
+ fun fromWireName(value: String?): RemoteConfigSource? =
+ entries.firstOrNull { it.wireName.equals(value, ignoreCase = true) }
+ }
+}
+
+/**
+ * One Remote Config key as it stands on the device right now.
+ *
+ * [value] is a `String` because Remote Config is string-typed at the source -- reading a key as a
+ * long or a boolean is an interpretation the *reader* applies, so storing a parsed type here would
+ * record information the server never sent.
+ */
+data class RemoteConfigEntry(
+ val key: String,
+ val value: String,
+ val source: RemoteConfigSource,
+ /** True when [value] was withheld by redaction, so a surface can badge it rather than show it. */
+ val redacted: Boolean = false,
+ /** True when [value] was cut to [RemoteConfigRegistry.MAX_VALUE_LENGTH]. */
+ val truncated: Boolean = false,
+)
+
+/** Outcome of the provider's most recent fetch attempt. */
+enum class RemoteConfigFetchStatus(
+ val wireName: String,
+) {
+ SUCCESS("success"),
+ NO_FETCH_YET("no_fetch_yet"),
+ FAILURE("failure"),
+ THROTTLED("throttled"),
+ UNKNOWN("unknown"),
+}
+
+/**
+ * Fetch metadata for a provider. [lastFetchEpochMs] is null -- never a sentinel like `-1` or `0` --
+ * when no fetch has happened, so a surface cannot render "never fetched" as a 1970 timestamp.
+ */
+data class RemoteConfigFetchInfo(
+ val lastFetchEpochMs: Long?,
+ val status: RemoteConfigFetchStatus,
+ val minimumFetchIntervalSeconds: Long?,
+) {
+ companion object {
+ /** What a provider that failed or cannot report reads as; never a confident status. */
+ @JvmStatic
+ fun unknown(): RemoteConfigFetchInfo =
+ RemoteConfigFetchInfo(
+ lastFetchEpochMs = null,
+ status = RemoteConfigFetchStatus.UNKNOWN,
+ minimumFetchIntervalSeconds = null,
+ )
+ }
+}
+
+/**
+ * Everything one provider can currently report. A non-null [unavailableReason] means [entries] is
+ * empty because the provider could not be read -- a state the surfaces show explicitly rather than
+ * rendering as "no config".
+ */
+data class RemoteConfigSnapshot(
+ val providerId: String,
+ val entries: List,
+ val fetchInfo: RemoteConfigFetchInfo,
+ val unavailableReason: String? = null,
+)
+
+/**
+ * A host-facing source of Remote Config values. Implement this to inspect a provider DevConsole
+ * ships no adapter for; [snapshot] is called on demand, when a surface asks, and is never polled.
+ */
+interface RemoteConfigProvider {
+ val id: String
+
+ fun snapshot(): RemoteConfigSnapshot
+}
diff --git a/sdk/remote-config/src/main/kotlin/io/devconsole/remoteconfig/RemoteConfigRegistry.kt b/sdk/remote-config/src/main/kotlin/io/devconsole/remoteconfig/RemoteConfigRegistry.kt
new file mode 100644
index 0000000..b0ff6f8
--- /dev/null
+++ b/sdk/remote-config/src/main/kotlin/io/devconsole/remoteconfig/RemoteConfigRegistry.kt
@@ -0,0 +1,94 @@
+/**
+ * @author Md. Asaduzzaman Nur
+ * @since 13/08/26
+ */
+package io.devconsole.remoteconfig
+
+/**
+ * Holds the host's registered [RemoteConfigProvider]s and normalizes what they return.
+ *
+ * Normalization lives here rather than in each adapter so that a host-written provider inherits the
+ * same value cap and the same never-throw guarantee as the adapters DevConsole ships, instead of
+ * having to remember them.
+ */
+class RemoteConfigRegistry {
+ /**
+ * Guarded by [lock] on every access, read included. Late registration is a documented path
+ * (`DevConsole.registerRemoteConfigProvider`), and the readers are the Ktor thread and the
+ * inspector's dispatcher -- so a host registering a provider from a post-fetch listener while
+ * the dashboard polls would otherwise throw `ConcurrentModificationException` straight out of
+ * the read path, into the host app. That is the one outcome [read]'s own doc promises not to
+ * cause. A `ConcurrentHashMap` would drop the insertion order surfaces list providers in, so
+ * the readers copy under the lock and iterate outside it instead.
+ */
+ private val lock = Any()
+ private val providers = linkedMapOf()
+
+ fun register(provider: RemoteConfigProvider) {
+ require(provider.id.isNotBlank()) { "Remote config provider id must not be blank" }
+ synchronized(lock) {
+ require(provider.id !in providers) { "Duplicate remote config provider: ${provider.id}" }
+ providers[provider.id] = provider
+ }
+ }
+
+ /** Drops every registration. Called when a session ends so a re-`initialize()` starts clean. */
+ fun clear() {
+ synchronized(lock) { providers.clear() }
+ }
+
+ fun providerIds(): List = synchronized(lock) { providers.keys.toList() }
+
+ /** Null for an unknown id; a provider that throws yields an unavailable snapshot, never an exception. */
+ fun snapshot(id: String): RemoteConfigSnapshot? = synchronized(lock) { providers[id] }?.let { read(id, it) }
+
+ /**
+ * The copy is taken under the lock and read outside it: [read] calls into host code, which may
+ * be slow or may itself register a provider, and neither should happen with the lock held.
+ */
+ fun snapshots(): List =
+ synchronized(lock) { providers.toList() }.map { (id, provider) -> read(id, provider) }
+
+ /**
+ * A debugging tool that crashes the app it exists to observe is worse than no tool, so a
+ * provider that throws is reported as unavailable rather than propagated to the host.
+ */
+ private fun read(
+ id: String,
+ provider: RemoteConfigProvider,
+ ): RemoteConfigSnapshot =
+ runCatching { provider.snapshot().normalized(id) }
+ .getOrElse { failure ->
+ RemoteConfigSnapshot(
+ providerId = id,
+ entries = emptyList(),
+ fetchInfo = RemoteConfigFetchInfo.unknown(),
+ unavailableReason =
+ failure.message?.takeIf(String::isNotBlank)
+ ?: failure.javaClass.simpleName,
+ )
+ }
+
+ /**
+ * Forces the registered id onto the result: the registry's own key is what every surface
+ * addresses a provider by, so a provider reporting a different [RemoteConfigSnapshot.providerId]
+ * must not produce a snapshot nothing can look up again.
+ */
+ private fun RemoteConfigSnapshot.normalized(id: String): RemoteConfigSnapshot =
+ copy(providerId = id, entries = entries.map { it.capped() })
+
+ private fun RemoteConfigEntry.capped(): RemoteConfigEntry =
+ if (value.length <= MAX_VALUE_LENGTH) {
+ this
+ } else {
+ copy(value = value.take(MAX_VALUE_LENGTH), truncated = true)
+ }
+
+ companion object {
+ /**
+ * Values longer than this are cut. One pathological config value (a base64 blob, an inlined
+ * JSON document) must not bloat every snapshot response on a phone-hosted server.
+ */
+ const val MAX_VALUE_LENGTH: Int = 8 * 1024
+ }
+}
diff --git a/sdk/remote-config/src/test/kotlin/io/devconsole/remoteconfig/RemoteConfigRegistryTest.kt b/sdk/remote-config/src/test/kotlin/io/devconsole/remoteconfig/RemoteConfigRegistryTest.kt
new file mode 100644
index 0000000..9bb770a
--- /dev/null
+++ b/sdk/remote-config/src/test/kotlin/io/devconsole/remoteconfig/RemoteConfigRegistryTest.kt
@@ -0,0 +1,243 @@
+/**
+ * @author Md. Asaduzzaman Nur
+ * @since 13/08/26
+ */
+package io.devconsole.remoteconfig
+
+import org.junit.Assert.assertEquals
+import org.junit.Assert.assertNotNull
+import org.junit.Assert.assertNull
+import org.junit.Assert.assertTrue
+import org.junit.Test
+import java.util.concurrent.CopyOnWriteArrayList
+import java.util.concurrent.CountDownLatch
+
+class RemoteConfigRegistryTest {
+ @Test
+ fun `snapshot returns the registered provider's entries`() {
+ val registry = RemoteConfigRegistry()
+ registry.register(provider("firebase", entry("checkout_v2", "true", RemoteConfigSource.REMOTE)))
+
+ val snapshot = registry.snapshot("firebase")
+
+ assertNotNull(snapshot)
+ assertEquals(listOf("checkout_v2"), snapshot!!.entries.map { it.key })
+ assertEquals(RemoteConfigSource.REMOTE, snapshot.entries.single().source)
+ }
+
+ @Test
+ fun `unknown provider id reads as null rather than throwing`() {
+ assertNull(RemoteConfigRegistry().snapshot("absent"))
+ }
+
+ @Test
+ fun `duplicate provider id is rejected`() {
+ val registry = RemoteConfigRegistry()
+ registry.register(provider("firebase"))
+
+ val failure = runCatching { registry.register(provider("firebase")) }.exceptionOrNull()
+
+ assertTrue(failure is IllegalArgumentException)
+ }
+
+ @Test
+ fun `blank provider id is rejected`() {
+ val failure = runCatching { RemoteConfigRegistry().register(provider(" ")) }.exceptionOrNull()
+
+ assertTrue(failure is IllegalArgumentException)
+ }
+
+ @Test
+ fun `a provider that throws degrades to an unavailable snapshot instead of propagating`() {
+ val registry = RemoteConfigRegistry()
+ registry.register(
+ object : RemoteConfigProvider {
+ override val id: String = "broken"
+
+ override fun snapshot(): RemoteConfigSnapshot = error("firebase exploded")
+ },
+ )
+
+ val snapshot = registry.snapshot("broken")
+
+ assertNotNull(snapshot)
+ assertEquals("firebase exploded", snapshot!!.unavailableReason)
+ assertTrue(snapshot.entries.isEmpty())
+ }
+
+ @Test
+ fun `an unavailable snapshot reports no confident fetch status`() {
+ val registry = RemoteConfigRegistry()
+ registry.register(
+ object : RemoteConfigProvider {
+ override val id: String = "broken"
+
+ override fun snapshot(): RemoteConfigSnapshot = error("boom")
+ },
+ )
+
+ val fetch = registry.snapshot("broken")!!.fetchInfo
+
+ assertEquals(RemoteConfigFetchStatus.UNKNOWN, fetch.status)
+ assertNull(fetch.lastFetchEpochMs)
+ assertNull(fetch.minimumFetchIntervalSeconds)
+ }
+
+ @Test
+ fun `a throwable with no message falls back to its class name`() {
+ val registry = RemoteConfigRegistry()
+ registry.register(
+ object : RemoteConfigProvider {
+ override val id: String = "broken"
+
+ // Deliberately not error(): that always attaches a message, and a *message-less*
+ // throwable is precisely the case this test covers.
+ @Suppress("UseCheckOrError")
+ override fun snapshot(): RemoteConfigSnapshot = throw IllegalStateException()
+ },
+ )
+
+ assertEquals("IllegalStateException", registry.snapshot("broken")!!.unavailableReason)
+ }
+
+ @Test
+ fun `an oversized value is truncated by the registry rather than by each provider`() {
+ val registry = RemoteConfigRegistry()
+ val oversized = "x".repeat(RemoteConfigRegistry.MAX_VALUE_LENGTH + 100)
+ registry.register(provider("firebase", entry("blob", oversized, RemoteConfigSource.REMOTE)))
+
+ val stored = registry.snapshot("firebase")!!.entries.single()
+
+ assertEquals(RemoteConfigRegistry.MAX_VALUE_LENGTH, stored.value.length)
+ assertTrue(stored.truncated)
+ }
+
+ @Test
+ fun `a value at the cap is not marked truncated`() {
+ val registry = RemoteConfigRegistry()
+ val exact = "x".repeat(RemoteConfigRegistry.MAX_VALUE_LENGTH)
+ registry.register(provider("firebase", entry("blob", exact, RemoteConfigSource.REMOTE)))
+
+ val stored = registry.snapshot("firebase")!!.entries.single()
+
+ assertEquals(exact, stored.value)
+ assertTrue(!stored.truncated)
+ }
+
+ @Test
+ fun `snapshots returns every provider in registration order`() {
+ val registry = RemoteConfigRegistry()
+ registry.register(provider("firebase"))
+ registry.register(provider("configcat"))
+
+ assertEquals(listOf("firebase", "configcat"), registry.snapshots().map { it.providerId })
+ assertEquals(listOf("firebase", "configcat"), registry.providerIds())
+ }
+
+ @Test
+ fun `a provider reporting an id different from its registration keeps the registered id`() {
+ val registry = RemoteConfigRegistry()
+ registry.register(
+ object : RemoteConfigProvider {
+ override val id: String = "firebase"
+
+ override fun snapshot(): RemoteConfigSnapshot =
+ RemoteConfigSnapshot(
+ providerId = "something-else",
+ entries = emptyList(),
+ fetchInfo = unknownFetch(),
+ )
+ },
+ )
+
+ assertEquals("firebase", registry.snapshot("firebase")!!.providerId)
+ }
+
+ private fun unknownFetch() =
+ RemoteConfigFetchInfo(
+ lastFetchEpochMs = null,
+ status = RemoteConfigFetchStatus.UNKNOWN,
+ minimumFetchIntervalSeconds = null,
+ )
+
+ @Test
+ fun `clear drops every registration so the same id can be registered again`() {
+ val registry = RemoteConfigRegistry()
+ registry.register(provider("firebase", entry("k", "old", RemoteConfigSource.REMOTE)))
+
+ registry.clear()
+ // The point of clear(): re-registering the same id must be accepted, not refused as a
+ // duplicate. A stop() -> initialize() carrying a replacement adapter under the same id
+ // would otherwise leave every surface reading through the torn-down original.
+ registry.register(provider("firebase", entry("k", "new", RemoteConfigSource.REMOTE)))
+
+ assertEquals(listOf("firebase"), registry.providerIds())
+ val reread = registry.snapshots().single()
+ assertEquals("new", reread.entries.single().value)
+ }
+
+ /**
+ * Registering while reading is a documented path (`DevConsole.registerRemoteConfigProvider`
+ * from a post-fetch listener) and the readers are the Ktor thread and the inspector's
+ * dispatcher, so an unguarded `LinkedHashMap` would throw `ConcurrentModificationException`
+ * into the host app -- the one thing the read path promises never to do.
+ */
+ @Test
+ fun `registering while snapshots is iterating does not throw into the reader`() {
+ val registry = RemoteConfigRegistry()
+ repeat(INITIAL_PROVIDERS) { i ->
+ registry.register(provider("p$i", entry("k", "v", RemoteConfigSource.REMOTE)))
+ }
+ val failures = CopyOnWriteArrayList()
+ val start = CountDownLatch(1)
+
+ val writer =
+ Thread {
+ start.await()
+ repeat(LATE_PROVIDERS) { i ->
+ runCatching { registry.register(provider("late$i", entry("k", "v", RemoteConfigSource.REMOTE))) }
+ }
+ }
+ val reader =
+ Thread {
+ start.await()
+ repeat(READ_ROUNDS) {
+ runCatching { registry.snapshots() }.onFailure(failures::add)
+ }
+ }
+ writer.start()
+ reader.start()
+ start.countDown()
+ writer.join()
+ reader.join()
+
+ assertTrue("reader saw ${failures.firstOrNull()}", failures.isEmpty())
+ }
+
+ private companion object {
+ const val INITIAL_PROVIDERS = 20
+ const val LATE_PROVIDERS = 200
+ const val READ_ROUNDS = 200
+ }
+
+ private fun entry(
+ key: String,
+ value: String,
+ source: RemoteConfigSource,
+ ) = RemoteConfigEntry(key = key, value = value, source = source)
+
+ private fun provider(
+ id: String,
+ vararg entries: RemoteConfigEntry,
+ ): RemoteConfigProvider =
+ object : RemoteConfigProvider {
+ override val id: String = id
+
+ override fun snapshot(): RemoteConfigSnapshot =
+ RemoteConfigSnapshot(
+ providerId = id,
+ entries = entries.toList(),
+ fetchInfo = unknownFetch(),
+ )
+ }
+}
diff --git a/sdk/server-ktor/api/server-ktor.api b/sdk/server-ktor/api/server-ktor.api
index 2282e23..6b53a6e 100644
--- a/sdk/server-ktor/api/server-ktor.api
+++ b/sdk/server-ktor/api/server-ktor.api
@@ -35,6 +35,7 @@ public final class io/devconsole/server/ktor/DevConsoleModuleConfig {
public final fun getPushSimulator ()Lio/devconsole/push/PushSimulator;
public final fun getPushStore ()Lio/devconsole/push/PushStore;
public final fun getRedactionPolicy ()Lio/devconsole/security/RedactionPolicy;
+ public final fun getRemoteConfigSnapshots ()Lkotlin/jvm/functions/Function0;
public final fun getRetainedCaptures ()Lio/devconsole/storage/api/RetainedCaptureQuery;
public final fun getScreenshotCapture ()Lkotlin/jvm/functions/Function1;
public final fun getSdkHealth ()Lkotlin/jvm/functions/Function0;
@@ -75,6 +76,7 @@ public final class io/devconsole/server/ktor/DevConsoleModuleConfig {
public final fun setPushSimulator (Lio/devconsole/push/PushSimulator;)V
public final fun setPushStore (Lio/devconsole/push/PushStore;)V
public final fun setRedactionPolicy (Lio/devconsole/security/RedactionPolicy;)V
+ public final fun setRemoteConfigSnapshots (Lkotlin/jvm/functions/Function0;)V
public final fun setRetainedCaptures (Lio/devconsole/storage/api/RetainedCaptureQuery;)V
public final fun setScreenshotCapture (Lkotlin/jvm/functions/Function1;)V
public final fun setSdkHealth (Lkotlin/jvm/functions/Function0;)V
@@ -103,8 +105,8 @@ public final class io/devconsole/server/ktor/EventStreamHub$Companion {
public final class io/devconsole/server/ktor/KtorLocalServerEngine : io/devconsole/server/api/LocalServerEngine {
public fun ()V
- public fun (Lio/devconsole/server/api/SessionAuthority;Lio/devconsole/server/api/SessionCodeAuthority;Lkotlin/jvm/functions/Function0;Lkotlin/jvm/functions/Function0;Lio/devconsole/network/NetworkTransactionStore;Lio/devconsole/socket/SocketStore;Lio/devconsole/push/PushStore;Lio/devconsole/state/StateRegistry;Lio/devconsole/state/SessionFeatureFlags;ZLio/devconsole/mocks/MockEngine;ZLio/devconsole/api/CaptureRuleEngine;ZLio/devconsole/server/api/PreferencesInspector;ZLio/devconsole/server/api/DatabaseInspector;ZLio/devconsole/server/api/FileInspector;ZLio/devconsole/timeline/Timeline;ZLjava/util/Set;ZLio/devconsole/security/RedactionPolicy;Lio/devconsole/push/PushSimulator;Lio/devconsole/server/api/CommandAuditLog;Lio/devconsole/timeline/TimelineAnnotations;Lio/devconsole/composer/ComposerCollectionStore;Lio/devconsole/composer/ComposerExecutor;Lio/devconsole/storage/api/EvidenceStore;Lkotlin/jvm/functions/Function0;Lkotlin/jvm/functions/Function1;Lkotlin/jvm/functions/Function1;Lkotlin/jvm/functions/Function1;Lkotlin/jvm/functions/Function0;)V
- public synthetic fun (Lio/devconsole/server/api/SessionAuthority;Lio/devconsole/server/api/SessionCodeAuthority;Lkotlin/jvm/functions/Function0;Lkotlin/jvm/functions/Function0;Lio/devconsole/network/NetworkTransactionStore;Lio/devconsole/socket/SocketStore;Lio/devconsole/push/PushStore;Lio/devconsole/state/StateRegistry;Lio/devconsole/state/SessionFeatureFlags;ZLio/devconsole/mocks/MockEngine;ZLio/devconsole/api/CaptureRuleEngine;ZLio/devconsole/server/api/PreferencesInspector;ZLio/devconsole/server/api/DatabaseInspector;ZLio/devconsole/server/api/FileInspector;ZLio/devconsole/timeline/Timeline;ZLjava/util/Set;ZLio/devconsole/security/RedactionPolicy;Lio/devconsole/push/PushSimulator;Lio/devconsole/server/api/CommandAuditLog;Lio/devconsole/timeline/TimelineAnnotations;Lio/devconsole/composer/ComposerCollectionStore;Lio/devconsole/composer/ComposerExecutor;Lio/devconsole/storage/api/EvidenceStore;Lkotlin/jvm/functions/Function0;Lkotlin/jvm/functions/Function1;Lkotlin/jvm/functions/Function1;Lkotlin/jvm/functions/Function1;Lkotlin/jvm/functions/Function0;IILkotlin/jvm/internal/DefaultConstructorMarker;)V
+ public fun (Lio/devconsole/server/api/SessionAuthority;Lio/devconsole/server/api/SessionCodeAuthority;Lkotlin/jvm/functions/Function0;Lkotlin/jvm/functions/Function0;Lio/devconsole/network/NetworkTransactionStore;Lio/devconsole/socket/SocketStore;Lio/devconsole/push/PushStore;Lio/devconsole/state/StateRegistry;Lkotlin/jvm/functions/Function0;Lio/devconsole/state/SessionFeatureFlags;ZLio/devconsole/mocks/MockEngine;ZLio/devconsole/api/CaptureRuleEngine;ZLio/devconsole/server/api/PreferencesInspector;ZLio/devconsole/server/api/DatabaseInspector;ZLio/devconsole/server/api/FileInspector;ZLio/devconsole/timeline/Timeline;ZLjava/util/Set;ZLio/devconsole/security/RedactionPolicy;Lio/devconsole/push/PushSimulator;Lio/devconsole/server/api/CommandAuditLog;Lio/devconsole/timeline/TimelineAnnotations;Lio/devconsole/composer/ComposerCollectionStore;Lio/devconsole/composer/ComposerExecutor;Lio/devconsole/storage/api/EvidenceStore;Lkotlin/jvm/functions/Function0;Lkotlin/jvm/functions/Function1;Lkotlin/jvm/functions/Function1;Lkotlin/jvm/functions/Function1;Lkotlin/jvm/functions/Function0;)V
+ public synthetic fun (Lio/devconsole/server/api/SessionAuthority;Lio/devconsole/server/api/SessionCodeAuthority;Lkotlin/jvm/functions/Function0;Lkotlin/jvm/functions/Function0;Lio/devconsole/network/NetworkTransactionStore;Lio/devconsole/socket/SocketStore;Lio/devconsole/push/PushStore;Lio/devconsole/state/StateRegistry;Lkotlin/jvm/functions/Function0;Lio/devconsole/state/SessionFeatureFlags;ZLio/devconsole/mocks/MockEngine;ZLio/devconsole/api/CaptureRuleEngine;ZLio/devconsole/server/api/PreferencesInspector;ZLio/devconsole/server/api/DatabaseInspector;ZLio/devconsole/server/api/FileInspector;ZLio/devconsole/timeline/Timeline;ZLjava/util/Set;ZLio/devconsole/security/RedactionPolicy;Lio/devconsole/push/PushSimulator;Lio/devconsole/server/api/CommandAuditLog;Lio/devconsole/timeline/TimelineAnnotations;Lio/devconsole/composer/ComposerCollectionStore;Lio/devconsole/composer/ComposerExecutor;Lio/devconsole/storage/api/EvidenceStore;Lkotlin/jvm/functions/Function0;Lkotlin/jvm/functions/Function1;Lkotlin/jvm/functions/Function1;Lkotlin/jvm/functions/Function1;Lkotlin/jvm/functions/Function0;IILkotlin/jvm/internal/DefaultConstructorMarker;)V
public fun bindAddressChanged ()Z
public final fun getStreamHub ()Lio/devconsole/server/ktor/EventStreamHub;
public final fun reconfigure (Lio/devconsole/state/SessionFeatureFlags;ZLjava/util/Set;ZLio/devconsole/security/RedactionPolicy;ZZZZZZ)V
diff --git a/sdk/server-ktor/build.gradle.kts b/sdk/server-ktor/build.gradle.kts
index 50b8644..9afa7af 100644
--- a/sdk/server-ktor/build.gradle.kts
+++ b/sdk/server-ktor/build.gradle.kts
@@ -21,6 +21,7 @@ dependencies {
implementation(project(":sdk:composer"))
implementation(project(":sdk:push"))
implementation(project(":sdk:state"))
+ implementation(project(":sdk:remote-config"))
implementation(project(":sdk:export"))
implementation(project(":sdk:storage-api"))
implementation("io.ktor:ktor-server-core:3.0.3")
diff --git a/sdk/server-ktor/src/main/kotlin/io/devconsole/server/ktor/DevConsoleKtorModule.kt b/sdk/server-ktor/src/main/kotlin/io/devconsole/server/ktor/DevConsoleKtorModule.kt
index 2b77233..0bd529f 100644
--- a/sdk/server-ktor/src/main/kotlin/io/devconsole/server/ktor/DevConsoleKtorModule.kt
+++ b/sdk/server-ktor/src/main/kotlin/io/devconsole/server/ktor/DevConsoleKtorModule.kt
@@ -51,6 +51,8 @@ import io.devconsole.push.PushEvent
import io.devconsole.push.PushInput
import io.devconsole.push.PushSimulator
import io.devconsole.push.PushStore
+import io.devconsole.remoteconfig.RemoteConfigEntry
+import io.devconsole.remoteconfig.RemoteConfigSnapshot
import io.devconsole.security.RedactionEngine
import io.devconsole.security.RedactionPolicy
import io.devconsole.server.api.BindingMode
@@ -214,6 +216,13 @@ class DevConsoleModuleConfig {
var stateRegistry: StateRegistry = StateRegistry()
var stateMutationsEnabled: Boolean = false
+ /**
+ * Remote Config snapshots, **already redacted** by the caller. `:sdk:full` owns that boundary
+ * because the Compose inspector reads the same registry in-process without passing through here,
+ * so redacting at this route would protect only the browser.
+ */
+ var remoteConfigSnapshots: () -> List = { emptyList() }
+
/** Reads (file/entry listing) always work; [preferencesEditable] mirrors `EditingCapabilities.preferences`. */
var preferencesInspector: PreferencesInspector? = null
var preferencesEditable: Boolean = false
@@ -316,6 +325,7 @@ fun Application.devConsoleModule(
val featureFlags = config.featureFlags
val featureFlagsEditable = config.featureFlagsEditable
val stateRegistry = config.stateRegistry
+ val remoteConfigSnapshots = config.remoteConfigSnapshots
val stateMutationsEnabled = config.stateMutationsEnabled
val preferencesInspector = config.preferencesInspector
val preferencesEditable = config.preferencesEditable
@@ -1526,6 +1536,22 @@ fun Application.devConsoleModule(
}
call.respondText("{\"data\":[$flags]}", contentType = io.ktor.http.ContentType.Application.Json)
}
+ get("/api/v1/remote-config") {
+ if (sessionAuthority.bearerSession(call.request.headers[HttpHeaders.Authorization]) ==
+ null
+ ) {
+ call.respondText("{\"code\":\"AUTH_REQUIRED\"}", status = HttpStatusCode.Unauthorized)
+ return@get
+ }
+ // Remote Config sits under the same "state" category as state providers and feature
+ // flags -- it is the same kind of data, so it is gated the same way.
+ if (!categoryEnabled("state")) {
+ call.respondCategoryDisabled("state")
+ return@get
+ }
+ val providers = remoteConfigSnapshots().joinToString(",") { it.json() }
+ call.respondText("{\"data\":[$providers]}", contentType = io.ktor.http.ContentType.Application.Json)
+ }
post("/api/v1/flags/{key}") {
val session = sessionAuthority.bearerSession(call.request.headers[HttpHeaders.Authorization])
val expectedOrigin = "http://${call.request.headers[HttpHeaders.Host].orEmpty()}"
@@ -3415,6 +3441,8 @@ class KtorLocalServerEngine(
private val socketStore: SocketStore = InMemorySocketStore(),
private val pushStore: PushStore = InMemoryPushStore(),
private val stateRegistry: StateRegistry = StateRegistry(),
+ /** Already-redacted Remote Config snapshots; see [DevConsoleModuleConfig.remoteConfigSnapshots]. */
+ private val remoteConfigSnapshots: () -> List = { emptyList() },
featureFlags: SessionFeatureFlags = SessionFeatureFlags(emptyList()),
featureFlagsEditable: Boolean = false,
private val mockEngine: MockEngine = MockEngine(emptyList()),
@@ -3595,6 +3623,7 @@ class KtorLocalServerEngine(
this.socketStore = this@KtorLocalServerEngine.socketStore
this.pushStore = this@KtorLocalServerEngine.pushStore
this.stateRegistry = this@KtorLocalServerEngine.stateRegistry
+ this.remoteConfigSnapshots = this@KtorLocalServerEngine.remoteConfigSnapshots
this.featureFlags = configuration.featureFlags
this.featureFlagsEditable = configuration.featureFlagsEditable
this.mockEngine = this@KtorLocalServerEngine.mockEngine
@@ -4465,6 +4494,27 @@ private fun CaptureRule.json(): String =
"\"pathPrefix\":${pathPrefix?.let { "\"${it.escapeJson()}\"" } ?: "null"}," +
"\"enabled\":$enabled}"
+/**
+ * Wire names deliberately differ from the Kotlin field names -- `providerId` serializes as `id` and
+ * `fetchInfo` as `fetch` -- and these names, not the Kotlin ones, are the stable contract the
+ * dashboard reads. Keys and values originate in the host's Remote Config console, so both are
+ * escaped. `lastFetchEpochMs` is emitted as literal `null` for a never-fetched provider rather than
+ * as a sentinel number, so the dashboard can render "never" instead of a 1970 date.
+ */
+private fun RemoteConfigSnapshot.json(): String {
+ val rows = entries.joinToString(",") { it.json() }
+ return "{\"id\":\"${providerId.escapeJson()}\"," +
+ "\"fetch\":{\"lastFetchEpochMs\":${fetchInfo.lastFetchEpochMs ?: "null"}," +
+ "\"status\":\"${fetchInfo.status.wireName}\"," +
+ "\"minimumFetchIntervalSeconds\":${fetchInfo.minimumFetchIntervalSeconds ?: "null"}}," +
+ "\"unavailableReason\":${unavailableReason?.let { "\"${it.escapeJson()}\"" } ?: "null"}," +
+ "\"entries\":[$rows]}"
+}
+
+private fun RemoteConfigEntry.json(): String =
+ "{\"key\":\"${key.escapeJson()}\",\"value\":\"${value.escapeJson()}\"," +
+ "\"source\":\"${source.wireName}\",\"redacted\":$redacted,\"truncated\":$truncated}"
+
/**
* Rule ids, hosts, and paths are user-supplied, so every string field is escaped. [stats] comes
* from [MockEngine.stats] rather than [MockRule] itself -- hit counts live in the engine's side
diff --git a/sdk/server-ktor/src/main/resources/devconsole-web/dashboard.css b/sdk/server-ktor/src/main/resources/devconsole-web/dashboard.css
index d915e63..8a416e8 100644
--- a/sdk/server-ktor/src/main/resources/devconsole-web/dashboard.css
+++ b/sdk/server-ktor/src/main/resources/devconsole-web/dashboard.css
@@ -1062,6 +1062,13 @@ body.detail-zoom .split-shell.collapse-detail { grid-template-columns: 1fr; }
.card-row-k { font-size: 11.5px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.card-row-v { font-family: var(--font-mono); font-size: 12.5px; overflow-wrap: anywhere; }
.card-row-tag { font-family: var(--font-mono); font-size: 9.5px; font-weight: 700; letter-spacing: 0.06em; padding: 2px 8px; border-radius: 99px; border: 1px solid var(--border-strong); white-space: nowrap; }
+/* A row that opens a detail window is a real