Flagsmith / Flagsmith/flagsmith
Index segment references to dependent flags
- Dominant language
- Python
- Stars
- 6.6k
- Forks
- 567
- Avg merge
- 1d 13h
- Merged PRs (30d)
- 121
Description
Add a dependency index model:
```
SegmentFlagReference(segment, prerequisite_feature, rule_path)
```
### Acceptance criteria
- [x] Creating a segment with `$.flags` conditions creates one index row per referenced feature.
- [x] Conditions nested in ALL/ANY/NONE rules at any depth are indexed, with a `rule_path` that points to the originating condition.
- [x] Editing a segment to add, change or remove a `$.flags` condition updates the index to match.
- [x] Deleting or soft-deleting a segment removes its index rows.
- [ ] Publishing a new segment version updates the index row.
- [x] ~A condition referencing a non-existent feature name does not break indexing.~
> Decided to reject referencing unknown features, as that would lead to a stale index if the prerequisite feature is created at a later moment. Therefore, **a feature needs to exist prior to being made a prerequisite.**
> -- Evandro
- [x] Indexing adds no measurable latency to segment writes on a project with a realistic segment count.
- [x] Attempting to persist a condition that would close a cycle against live versions any of the project's environment via any amount of nodes raises a validation error that would translate to a user-facing 400 with `code: circular_dependency` and a `path` naming each feature + segment.
Contributor guide
Assessment
This issue has not been assessed yet.