Uh oh!
There was an error while loading. Please reload this page.
feat: Evaluate custom targets in the feature flags runtime client - #1674
feat: Evaluate custom targets in the feature flags runtime client#1674stanleyphu wants to merge 2 commits into
Conversation
Greptile SummaryThe PR extends local feature-flag evaluation to support typed built-in and custom target contexts while retaining legacy context support.
Confidence Score: 5/5The PR appears safe to merge. No blocking failure remains. Important Files Changed
|
stanleyphu
commented
Aug 13, 2026
/devin review |
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
- Classify context shape by value shape, not key presence: unset keys and scalar extras on a legacy context no longer trip hybrid rejection - Normalize the context once per getAllFlags call so an invalid context warns once, not once per flag - Drop the incorrect claim that hybrid contexts fail to compile
| users: FlagTarget[]; | ||
| organizations: FlagTarget[]; | ||
| /** Absent until the API's custom-targets rollout flag is enabled. */ | ||
| custom_targets?: FlagCustomTarget[]; |
There was a problem hiding this comment.
💭 I wonder if it makes sense to roll this out only after custom-targets rollout is enabled to avoid the optional state for custom_targets?
There was a problem hiding this comment.
The plan is to have the flag enabled when this is released, but I think we'll still need to keep this optional to avoid things breaking if we have to disable the flag for any reason?
Summary
Teaches the feature flags runtime client to evaluate the
targets.custom_targetscollection that the API now includes in theGET /sdk/feature-flagspoll payload behind thefeature-flags-custom-targetsrollout flag (workos/workos#68135). This is stage 4 of the Custom Targeting Hilltop rollout plan: ship the runtime contract before typed target management or docs.Typed evaluation context
isEnabled/getAllFlagsnow accept the Hilltop's direct target-type context map alongside the existing legacy shape:Per the Hilltop's pre-commitments:
TypedEvaluationContext's index signature makes any key acceptable to the union). Shape detection is by value, not key presence: unset keys and scalar extra fields on a legacy context are ignored, preserving today's behavior for callers passing wider objects.Evaluation semantics aligned with the Hilltop
enabled: falseis treated as not present (falls through to the flag default) instead of forcing the flag off. This field value is reserved for future disabled overrides, per the Hilltop's Forward compatibility for disabled overrides. The API only ever writesenabled: truetoday, so this is not an observable behavior change — but it does replace the previous user-over-organization short-circuit, which only mattered forenabled: falserows that cannot exist.Change detection
hasEntryChangednow also diffscustom_targets, so a poll cycle where only a custom rule changed emits thechangeevent.Compatibility
targets.custom_targetsis optional in the payload types: polls against servers with the rollout flag off (or older servers) behave exactly as before.Test plan
npx jest src/feature-flags— 93 tests passing, including new coverage for: exact custom matches, built-in types via the typed form,enabled: falsetreated as absent (including the default-true proof), hybrid-context rejection, unset-key and scalar-extra-field handling, once-per-call warnings in getAllFlags, invalid type/ID warnings, malformed context safety, and a change event fired when only custom targets differ.npm run build(tsdown + attw + publint) andnpx eslint src/feature-flagsclean.feature-flags-custom-targetsrollout flag enabled, add a custom rule in the dashboard, and confirmisEnabled(slug, { <type>: { id } })flips accordingly.🤖 Generated with Claude Code