Conversation
…/clear scopes
disable/2 and clear/2 had no catch-all clause, so an unsupported scope
(e.g. disable(:f, schedule: ...) or clear(:f, nonsense: true)) raised a
FunctionClauseError surfaced as a telemetry exception rather than a clean
result. Add catch-all clauses returning {:error, :unsupported_scope}, and
accept the requires: {parent, required} tuple form in clear/2 for symmetry
with enable/2 (the required state is not part of the prerequisite gate's
slot id, so it clears the same gate as the bare-atom form).
The Redis serializer encoded only a rule gate's constraint list and
hardcoded enabled: true on read, dropping the enabled flag — diverging
from the Ecto adapter, which persists it in its own column. Encode rule
gates as {"enabled": bool, "constraints": [...]} to match. decode_rule/1
also reads the legacy bare-array format (as enabled: true) so existing
Redis data round-trips unchanged.
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.
Three correctness/robustness fixes surfaced by a review of the Tier 1 features on
main. No behavior change for existing valid call sites.Fixes
1.
disable/2no longer crashes on grant-only scopesdo_disable/2had no catch-all, sodisable(:f, schedule: ...),when:,for_segment:,requires:,variant:,rule:,boolean:raisedFunctionClauseError(surfaced as a telemetry exception) instead of a clean result. Now returns{:error, :unsupported_scope}. Grant-only gates are removed viaclear/2— the docstring now says so.2.
clear/2accepts therequires: {parent, required}tupleenable/2accepts bothrequires: parentandrequires: {parent, required}, butclear/2only had the bare-atom clause, so the tuple form raised. Added the tuple clause (delegates to the bare-atom form, since the required state isn't part of the prerequisite gate's slot id) plus a catch-all returning{:error, :unsupported_scope}for symmetry.3. Redis dropped a rule gate's
enabledflag on round-tripThe Redis serializer encoded only a rule gate's constraint list and hardcoded
enabled: trueon read — diverging from the Ecto adapter, which persistsenabledin its own column. Rule gates now serialize as{"enabled": bool, "constraints": [...]}.decode_rule/1also reads the legacy bare-array format (asenabled: true), so existing Redis data round-trips unchanged.Not changed (deliberate, documented behavior)
Constraint("007" == "7") — documented and tested.:containsis string-substring only — documented.Verification
mix test: 394 passed (81 doctests, 8 properties, 305 tests); 13 redis-tagged excluded (no live Redis — the new rule-serializer tests are pure and ran). Written test-first (red → green).mix format --check-formatted: cleanmix credo --strict: no issuesmix assay(Dialyzer): 0 errors