Repository navigation
Document fail-closed AND flag gating - #314
Merged
Merged
Conversation
Replace the kill-switch sample, which could enable a flag from one side, with the fail-closed per-param recipe. The combined result source is UNKNOWN, chosen by the strategy. Two generated flags with the same name are not this mechanism. No API change.
Keep the fail-closed recipe and put the two-flag statement in one place so callers do not treat a duplicate key as the gating mechanism.
There was a problem hiding this comment.
🟡 Changes recommended
The release warning omits localFlags with default = true, whose generated R8 assumptions can bypass the remote gate, and should recommend remoteFlags to preserve runtime AND gating.
1 open issue
What changed in this PR
Documents how to use the existing ValueResolutionStrategy for per-flag, fail-closed local AND remote gating, addressing #296 without changing runtime APIs or default resolution.
Changes:
- Replaces the previous gating example with a selected-key recipe requiring both provider values to be explicitly true.
- Adds tests for missing and false values, combined-source caching, and delegation to default resolution.
- Records the documentation clarification and distinguishes it from same-name flag isolation.
| File | Description |
|---|---|
core/src/commonTest/kotlin/dev/androidbroadcast/featured/ValueResolutionStrategyTest.kt |
Tests the AND recipe, caching, and default delegation. |
core/src/commonMain/kotlin/dev/androidbroadcast/featured/ValueResolutionStrategy.kt |
Documents the recipe, source semantics, and usage constraints. |
CHANGELOG.md |
Records the guidance update without an API change. |
Review effort: Balanced
Comment on lines
+37
to
+39
| * the build rejects that duplicate. Do not AND two accessors. If the guarded client code must | ||
| * remain in release binaries, do not declare that one flag as a `localFlags` boolean with | ||
| * `default = false`: those flags are release-stripped. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

Closes #296
Type of change
Checklist
./gradlew spotlessCheckpassesNotes for reviewers
Issue #296 asks how to enable a feature only when a local gate and a remote rollout are both explicitly true.
ValueResolutionStrategyalready expresses that. This does not add a combinator, flag container, or DSL, and it does not changeValueResolutionStrategy.Default.The published recipe is fail-closed and per-param. A selected boolean is true only when
localValue?.value == true && remoteValue?.value == true. A missing, failed, or false side stays false.defaultValueis not the client gate, so a flag whose default is false can still become true when both provider values are true. Other keys delegate toValueResolutionStrategy.Defaultand keep that candidate's source.The combined result, true or false, is
ConfigValue.Source.UNKNOWN, chosen by the strategy. The library does not stamp a combined source.getValuewrites every non-DEFAULTsource into the snapshot, sogetValueCachedseesUNKNOWN.Two generated flags with the same name are not the AND. Same-name isolation is a separate task (#294). The build already rejects a duplicate key in
localFlagsandremoteFlags.README already links the wiki, so this does not paste a second copy of the sample there.
Wiki commit with the same recipe, source, and two-flag statement: https://github.com/AndroidBroadcast/Featured.wiki/commit/215d77d3b6500c8048bfe72d1ec92cd6a6a28680
./gradlew :core:testis not a task on this KMP module. Ran:core:jvmTest --tests dev.androidbroadcast.featured.ValueResolutionStrategyTest(21 tests, 0 failures),:core:koverVerify(line coverage 98.5437%, gate 90%), andspotlessCheck.