Skip to content

:hedgehog: PostHog is the leading platform for building self-driving products. Our developer tools – AI observability, analytics, session replay, flags, experiments, error tracking, logs, and more – capture all the context agents need to diagnose problems, uncover opportunities, and ship fixes. Steer it all from Slack, web, desktop, or the MCP.

chore(flags): document feature_enrollment, drop stale super_groups (#86901)

posthog[bot]6ec3d64f6d7b
diff --git a/docs/internal/feature-flags/feature-enrollment.md b/docs/internal/feature-flags/feature-enrollment.md
new file mode 100644
index 000000000000..98fc672025e5
--- /dev/null
+++ b/docs/internal/feature-flags/feature-enrollment.md
@@ -0,0 +1,125 @@
+# Feature enrollment
+
+## What it is
+
+Feature enrollment is a feature flag evaluation mechanism that controls opt-in to early access features.
+It is a flag-level boolean marker, `filters.feature_enrollment`.
+When it is `true`, the flag matcher checks the person property `$feature_enrollment/{flag_key}`.
+
+The matcher evaluates enrollment **before** holdout groups and **before** the release condition loop.
+When the person is enrolled, the matcher returns a match at once and never checks the rollout percentage.
+So an early access flag needs **no release condition** to serve enrolled people.
+
+Enrollment takes effect on the **next flag reload**, with no wait for event ingestion.
+The client SDK (posthog-js) sends `$feature_enrollment/{flag_key}` as a request property override.
+The matcher merges request overrides ahead of the database, so the flag is live on the very next `/flags` call.
+
+## What it is used for
+
+Feature enrollment powers the early access feature (EAF) system.
+When a person opts in through the UI, PostHog sets a person property like `$feature_enrollment/my-feature` to the value `"true"` (stored as a string, not a boolean).
+
+PostHog enables enrollment only for features in **active stages**: Alpha, Beta, and General Availability.
+The Concept stage lets people register interest, but does not enable enrollment: PostHog does not set `feature_enrollment` on the flag, so opted-in people are not served through the enrollment shortcut.
+
+Concept turns off the enrollment shortcut, not the flag's normal release-condition evaluation.
+A flag auto-created for the feature starts at `rollout_percentage: 0`, so it serves nobody until the feature reaches an active stage.
+A flag you link yourself keeps its own release conditions, and those still run: a linked flag already rolled out to everyone keeps matching people while the feature sits in Concept.
+Demoting a feature back to Concept clears the enrollment marker but leaves the release conditions in place, so a flag previously rolled out to all stays at 100%.
+
+Example flow:
+
+1. A product team creates an early access feature "New Dashboard" in Alpha stage, linked to feature flag `new-dashboard`.
+2. PostHog sets `filters.feature_enrollment` to `true` on the flag (only because it is in an active stage).
+3. A person opts in through the early access features UI.
+4. posthog-js sets `$feature_enrollment/new-dashboard` to `"true"` on the person and sends it as a request override.
+5. On the next `/flags` call, the matcher sees the property and the person gets the feature.
+6. The matcher never checks the release conditions for this person.
+
+If the feature were in Concept stage instead, steps 3-4 would still happen (the person can register interest), but step 2 would not.
+The enrollment shortcut would stay off, so enrollment would not serve the flag to opted-in people.
+The flag's normal release conditions still apply: an auto-created flag sits at `rollout_percentage: 0` and serves nobody, but a linked flag keeps evaluating its own conditions.
+
+## How it is stored
+
+Enrollment is a single boolean in the feature flag's `filters` JSON field:
+
+```json
+{
+ "groups": [
+ {
+ "properties": [],
+ "rollout_percentage": 100
+ }
+ ],
+ "feature_enrollment": true
+}
+```
+
+The enrollment property key is **derived from the flag key** (`$feature_enrollment/{flag_key}`), so the flag stores no property structure.
+
+### Legacy `super_groups`
+
+Enrollment used to be a `filters.super_groups` block — an array of condition sets, each with a `$feature_enrollment/{flag_key}` property.
+The `feature_enrollment` boolean replaced it as the enrollment mechanism.
+
+The **flag matcher** no longer evaluates `super_groups`.
+The Rust `FlagFilters` struct keeps unknown keys in its `extra` map, so `super_groups` round-trips through the cache but is never read during matching.
+
+But `super_groups` is **not** fully removed. Stored values persist, and compatibility code outside the matcher still reads them:
+
+- The backfill migrations (`1076_backfill_feature_enrollment`, `1078_backfill_feature_enrollment_fix`) only add `feature_enrollment = true`; they do not strip `super_groups`. The key is removed only opportunistically, when a flag is next saved (`api/feature_flag.py`), so rows nobody has edited still carry it.
+- Python still reads it for behavior: `group_cohort_restriction_blocker` (`facade/filters.py`) and `is_unconditionally_fully_rolled_out` (`persisted_flags.py`) treat its presence as a blocker, and the experiment freeze-exposure control renders that blocker as a user-facing message. The resource-transfer visitors walk `("groups", "super_groups")` to collect and rewrite cohort and action ids, and `flags_cache._GROUP_LEVEL_LIST_KEYS` lists it for cache-drift comparison.
+- The frontend still declares `super_groups` on `FeatureFlagFilters` (`frontend/src/types.ts`) and reads it: the experiment freeze-exposure guard checks it, and the flag AI context copies its value and count.
+
+Do not add new `super_groups` — write `feature_enrollment` instead. New writes are steered to the marker:
+
+- The Python filters schema lists `super_groups` in `LEGACY_UNKNOWN_FILTER_KEYS`.
+- `set_feature_enrollment` (the facade transform) drops any `super_groups` key when it writes the marker.
+
+## The enrollment property
+
+The matcher reads `$feature_enrollment/{flag_key}` from the person properties (request overrides first, then the database).
+
+| Property value | Result |
+| --------------------------- | ------------------------------------------------------------ |
+| `"true"` (string) or `true` | Enrolled — the flag returns a match at once. |
+| Any other present value | Opted out — the flag returns no match at once. |
+| Absent | Not decided — evaluation falls through to normal conditions. |
+
+`FlagFilters::is_enrolled` in `rust/feature-flags/src/flags/flag_filters.rs` defines the "enrolled" values.
+An opted-out person (property `"false"`) does **not** fall through to the release conditions. The flag returns no match right away.
+
+## Evaluation
+
+`get_match` in `rust/feature-flags/src/flags/flag_matching.rs` evaluates enrollment first:
+
+1. If `filters.feature_enrollment` is not `true`, the matcher skips this step.
+2. The matcher derives the enrollment key with `FlagFilters::enrollment_key(flag_key)`.
+3. The matcher reads the person properties. Enrollment is always person-level, even for group-based flags.
+4. If the person **has** the enrollment property, the matcher returns at once with the reason `SuperConditionValue`. The match is `true` when the value means enrolled, and `false` otherwise.
+5. If the person does **not** have the property, evaluation falls through to holdout groups and then the release conditions.
+
+The match reason keeps the legacy name `SuperConditionValue` (score 6, the highest priority) — see the reason table in [flag-evaluation-engine.md](flag-evaluation-engine.md).
+
+## Constraints
+
+The serializer and API enforce constraints that the boolean alone does not express:
+
+- Early access features cannot attach to group-based flags.
+- Early access features cannot have multivariate variants.
+
+These constraints live in validation code.
+
+## Key files
+
+| Component | Path |
+| ------------------ | ---------------------------------------------------------------------------------- |
+| Python model | `products/feature_flags/backend/models/feature_flag.py` (`has_feature_enrollment`) |
+| Filters transform | `products/feature_flags/backend/facade/filters.py` (`set_feature_enrollment`) |
+| Filters validation | `products/feature_flags/backend/api/filters_schema.py` |
+| Rust evaluation | `rust/feature-flags/src/flags/flag_matching.rs` (`get_match`) |
+| Rust helpers | `rust/feature-flags/src/flags/flag_filters.rs` (`enrollment_key`, `is_enrolled`) |
+| Rust model | `rust/feature-flags/src/flags/flag_models.rs` (`FlagFilters.feature_enrollment`) |
+| Early access API | `products/early_access_features/backend/api.py` |
+| Frontend types | `frontend/src/types.ts` (`FeatureFlagFilters.feature_enrollment`) |
diff --git a/docs/internal/feature-flags/flag-evaluation-engine.md b/docs/internal/feature-flags/flag-evaluation-engine.md
index 3824452efc8d..39f9b77fead2 100644
--- a/docs/internal/feature-flags/flag-evaluation-engine.md
+++ b/docs/internal/feature-flags/flag-evaluation-engine.md
@@ -1,6 +1,6 @@
# Flag evaluation engine
-The Rust feature flags service evaluates flags using a deterministic, hash-based algorithm. This document covers the full evaluation pipeline: dependency resolution, condition matching, rollout hashing, variant selection, super groups, holdout groups, and experience continuity.
+The Rust feature flags service evaluates flags using a deterministic, hash-based algorithm. This document covers the full evaluation pipeline: dependency resolution, condition matching, rollout hashing, variant selection, feature enrollment, holdout groups, and experience continuity.
## Architecture overview
@@ -68,7 +68,7 @@ pub struct FlagFilters {
pub multivariate: Option<MultivariateFlagOptions>, // variant definitions
pub aggregation_group_type_index: Option<i32>, // None=person, 0=project, 1=org, etc.
pub payloads: Option<serde_json::Value>, // variant key -> payload map
- pub super_groups: Option<Vec<FlagPropertyGroup>>, // early access feature gate
+ pub feature_enrollment: Option<bool>, // early access feature gate
pub holdout_groups: Option<Vec<FlagPropertyGroup>>, // holdout/control conditions
}
```
@@ -115,10 +115,10 @@ pub enum CompiledRegex {
Regex patterns are compiled once per request rather than on every `match_property()` call.
-**Entry point:** `FeatureFlagList::prepare_regexes()` is called in `fetch_and_filter()` (in `handler/flags.rs`) immediately after flag list construction, before any evaluation begins.
+**Entry point:** `FeatureFlagList::prepare_regexes_in_place()` is called in `PreparedFlags::seal()` (in `flags/feature_flag_list.rs`) when the flag list is constructed, before any evaluation begins.
- `PropertyFilter::prepare_regex()` — compiles the filter's value as a regex with `backtrack_limit(10_000)` for `Regex`/`NotRegex` operators. No-op for other operators or when `compiled_regex` is already `Some` (idempotent). Stores `CompiledRegex::Compiled` on success or `CompiledRegex::InvalidPattern` on failure. If `value` is `None`, leaves `compiled_regex` as `None` (fallback path).
-- `FeatureFlagList::prepare_regexes()` — walks all flags → `filters.groups` and `filters.super_groups` → property filters, calling `prepare_regex()` on each.
+- `FeatureFlagList::prepare_regexes_in_place()` — walks all flags → `filters.groups` → property filters, calling `prepare_regex()` on each.
The fallback on-the-fly compilation path (`compiled_regex: None`) is retained for cohort property filters (constructed dynamically in `cohort_operations.rs`, not from the flag cache) and for test code that constructs `PropertyFilter` directly.
@@ -147,10 +147,10 @@ The `get_match` function in `rust/feature-flags/src/flags/flag_matching.rs` eval
│ No
▼
┌────────────────────────────┐
-│ Evaluate super_groups │──── Match ──▶ return result (SuperConditionValue)
+│ Evaluate feature_enrollment│──── Has property ──▶ return result (SuperConditionValue)
│ (early access gate) │
└────────────────────────────┘
- │ No match / not applicable
+ │ No property / not applicable
▼
┌────────────────────────────┐
│ Evaluate holdout_groups │──── In holdout ──▶ true + holdout variant
@@ -280,18 +280,20 @@ A condition group can specify a `variant` field that overrides the computed vari
Each variant (or `"true"` for boolean flags) can have a JSON payload stored in `filters.payloads`. The payload is included in the evaluation result.
-## Super groups (early access features)
+## Feature enrollment (early access features)
-Super groups act as a gate for early access enrollment. Defined in `filters.super_groups`.
+Feature enrollment acts as a gate for early access opt-in. Enabled by the boolean `filters.feature_enrollment`.
### Evaluation
-1. Only the first super group is evaluated
-2. Checks if the person has any property mentioned in the super condition (typically `$feature_enrollment/{flag_key}`)
-3. If the person has the property, the super condition is evaluated and its result is returned immediately (reason: `SuperConditionValue`)
+1. Only runs when `filters.feature_enrollment` is `true`
+2. Derives the enrollment key `$feature_enrollment/{flag_key}` and reads it from the person properties (request overrides first, then the database)
+3. If the person has the property, the result is returned immediately (reason: `SuperConditionValue`): `true` when the value means enrolled, `false` otherwise
4. If the person does not have the property, evaluation falls through to normal conditions
-Super groups take the highest priority in match reasons (score: 6).
+Feature enrollment takes the highest priority in match reasons (score: 6). The reason keeps the legacy name `SuperConditionValue`.
+
+See [feature-enrollment.md](feature-enrollment.md) for the full design, including the removed `super_groups` representation.
## Holdout groups
@@ -304,7 +306,7 @@ Holdout groups exclude users from experiments to serve as a baseline. Defined in
3. If the user's hash falls within the holdout percentage, they are in the holdout and the flag returns `true` with a holdout variant (default: `"holdout"`)
4. If the user is outside the holdout, normal condition evaluation proceeds
-Holdout evaluation happens after super groups but before normal conditions.
+Holdout evaluation happens after feature enrollment but before normal conditions.
## Flag dependencies
@@ -428,7 +430,7 @@ Each evaluation result includes a reason explaining why the flag matched or didn
| Reason | Score | Meaning |
| ----------------------- | ----- | ------------------------------------------------- |
-| `SuperConditionValue` | 6 | Matched via super group (early access) |
+| `SuperConditionValue` | 6 | Matched via feature enrollment (early access) |
| `HoldoutConditionValue` | 5 | In holdout group |
| `ConditionMatch` | 4 | Matched a condition group + rollout |
| `NoGroupType` | 3 | Group flag but no group key provided |
diff --git a/docs/internal/feature-flags/super-groups.md b/docs/internal/feature-flags/super-groups.md
deleted file mode 100644
index eb4bf8a4c5cd..000000000000
--- a/docs/internal/feature-flags/super-groups.md
+++ /dev/null
@@ -1,171 +0,0 @@
-# Super groups
-
-## What they are
-
-Super groups are a feature flag evaluation mechanism that controls enrollment in early access features. Despite the name suggesting "groups of users," they're actually a single person-level property check that determines whether someone has opted into an early access feature.
-
-When a super group condition matches, it takes precedence over all regular feature flag conditions—hence "super." The evaluation returns immediately without checking other conditions.
-
-## What they're used for
-
-Super groups power the early access feature (EAF) system. When users opt into an early access feature through the UI, PostHog sets a person property like `$feature_enrollment/my-feature` with the value `"true"` (stored as a string, not a boolean). The super group condition checks for this property.
-
-Super groups are only added to feature flags for early access features in **active stages**: Alpha, Beta, and General Availability. The Concept stage allows users to register interest, but does not add super groups – the feature flag remains disabled for opted-in users until the feature is promoted to an active stage.
-
-Example flow:
-
-1. Product team creates an early access feature "New Dashboard" in Alpha stage linked to feature flag `new-dashboard`
-2. PostHog automatically adds a super group to the flag checking `$feature_enrollment/new-dashboard` (only because it's in an active stage)
-3. User opts in via the early access features UI
-4. PostHog sets `$feature_enrollment/new-dashboard` to `"true"` on their person
-5. On next flag evaluation, super group matches → user sees the feature
-6. Regular rollout conditions are never checked for this user
-
-If the feature were in Concept stage instead, steps 3-4 would still occur (user can register interest), but step 2 would not – no super group would be added, so the feature flag would remain disabled.
-
-Note: The condition uses `["true"]` (an array) because property filters in PostHog always expect array values for the `exact` operator, even for single values.
-
-This allows opted-in users to see features regardless of percentage rollouts, geography targeting, or other conditions on the flag.
-
-## How they are stored
-
-Super groups are stored in the feature flag's `filters` JSON field alongside regular conditions:
-
-```json
-{
- "groups": [
- {
- "properties": [...],
- "rollout_percentage": 50
- }
- ],
- "super_groups": [
- {
- "properties": [
- {
- "key": "$feature_enrollment/new-dashboard",
- "type": "person",
- "operator": "exact",
- "value": ["true"]
- }
- ],
- "rollout_percentage": 100
- }
- ]
-}
-```
-
-### Data type used
-
-Super groups use the same `FeatureFlagGroupType` as regular conditions:
-
-```typescript
-interface FeatureFlagGroupType {
- properties?: AnyPropertyFilter[]
- rollout_percentage?: number | null
- variant?: string | null
- users_affected?: number
- sort_key?: string | null
- description?: string | null
-}
-```
-
-## Why this causes confusion
-
-### The name doesn't match the purpose
-
-"Super groups" suggests:
-
-- A group-based targeting concept (like "premium users" or "beta testers")
-- Something related to PostHog's group analytics feature
-- A collection of users
-
-What it actually is:
-
-- A single person property check
-- Specifically for `$feature_enrollment/{flag_key}` properties
-- An enrollment gate, not a targeting mechanism
-
-A clearer name would be `enrollment_condition` or `early_access_gate`.
-
-### The type allows more than is supported
-
-Using `FeatureFlagGroupType` implies you can:
-
-- Add multiple properties (in practice, there's never more than one)
-- Use any property key (only `$feature_enrollment/*` makes sense)
-- Use different operators (only `exact` with `["true"]` is meaningful)
-- Set different rollout percentages (it's always 100% for enrolled users)
-
-The Django code that creates super groups always produces exactly one property, and only for features in `ActiveStage` (Alpha, Beta, GA):
-
-```python
-# From products/early_access_features/backend/api.py
-super_conditions = lambda feature_flag_key: [
- {
- "properties": [
- {
- "key": f"$feature_enrollment/{feature_flag_key}",
- "type": "person",
- "operator": "exact",
- "value": ["true"],
- },
- ],
- "rollout_percentage": 100,
- },
-]
-```
-
-While the type system allows an array of properties, this is the only code path that creates super groups, so there's always exactly one property in practice.
-
-### It's not group-based at all
-
-This is the most confusing aspect. PostHog has a separate "groups" feature for company-level / account-level analytics. Super groups have nothing to do with that:
-
-| Concept | What it means |
-| ------------------- | ------------------------------------------------ |
-| PostHog groups | Company/account-level entities for B2B analytics |
-| Feature flag groups | Release condition sets (targeting rules) |
-| Super groups | Early access enrollment checks |
-
-Three unrelated uses of "group" in feature flags.
-
-### Constraints not enforced by the type
-
-The serializer and API enforce constraints that the type doesn't express:
-
-- Early access features can't attach to group-based flags
-- Early access features can't have multivariate variants
-- Super groups only support person properties
-
-These constraints live in validation code, not the type system, making the valid configurations unclear from the schema alone.
-
-### A clearer alternative would be
-
-A dedicated type that reflects what super groups actually do:
-
-```typescript
-interface EarlyAccessEnrollment {
- featureFlagKey: string // The key checked in $feature_enrollment/{key}
- enabled: boolean // Always true when present
-}
-```
-
-Or even simpler, a boolean flag on the feature flag model:
-
-```python
-class FeatureFlag(models.Model):
- has_early_access_enrollment = models.BooleanField(default=False)
-```
-
-The enrollment property key can be derived from the flag key, eliminating the need for a separate structure.
-
-## Key files
-
-| Component | Path |
-| ----------------- | ------------------------------------------------------------------------ |
-| Python evaluation | `posthog/models/feature_flag/flag_matching.py` |
-| Rust evaluation | `rust/feature-flags/src/flags/flag_matching.rs` |
-| Early access API | `products/early_access_features/backend/api.py` |
-| Frontend types | `frontend/src/types.ts` |
-| Frontend logic | `frontend/src/scenes/feature-flags/featureFlagReleaseConditionsLogic.ts` |