Skip to content

Add feature-flag engine with targeting and rollout#276

Merged
JE-Chen merged 1 commit into
devfrom
feat/feature-flags
Jun 21, 2026
Merged

Add feature-flag engine with targeting and rollout#276
JE-Chen merged 1 commit into
devfrom
feat/feature-flags

Conversation

@JE-Chen

@JE-Chen JE-Chen commented Jun 21, 2026

Copy link
Copy Markdown
Member

Summary

decision_table is a one-shot DMN evaluator and ab_locator measures locator outcomes — neither is a product feature-flag store with sticky percentage rollout. This adds an OpenFeature-shaped flag engine.

  • FlagStore.from_dict / from_file — load flag definitions.
  • evaluate_flag(store, key, context){value, variant, reason} with reasons TARGETING_MATCH / SPLIT / DEFAULT / DISABLED / ERROR.
  • is_enabled(...) boolean shortcut; percentage_bucket / assign_variant for direct use.

Targeting operators: eq/ne/lt/le/gt/ge/in/not_in/contains/semver_*. Percentage rollout is a consistent-hash bucket of sha256("{key}.{salt}.{context_key}"), so a subject is sticky (always the same variant). Kill switch via enabled: false. Pure stdlib (hashlib+re+json), deterministic.

Five-layer wiring

  • Headless core: je_auto_control/utils/feature_flags/
  • Facade: re-exported from __init__.py + __all__
  • Executor: AC_evaluate_flag, AC_flag_enabled
  • MCP: ac_evaluate_flag, ac_flag_enabled
  • Script Builder: "Feature Flag: Evaluate" / "Feature Flag: Enabled?" under Flow

Tests & docs

  • test/unit_test/headless/test_feature_flags_batch.py (12 tests: targeting, rollout SPLIT, kill switch, unknown, sticky ~50% distribution, semver)
  • v68 feature docs (EN + Zh) + toctree
  • What's-new in all three READMEs

Lint clean: ruff / pylint / bandit / radon.

decision_table is one-shot DMN and ab_locator is locator A/B; neither is
a product feature-flag store with sticky percentage rollout. Add an
OpenFeature-shaped engine: targeting rules, weighted variants, a kill
switch, and consistent-hash bucketing so a subject always lands in the
same variant. Pure stdlib and deterministic. Wired through the facade,
AC_evaluate_flag/AC_flag_enabled executor commands, MCP tools and the
Script Builder.
@codacy-production

Copy link
Copy Markdown

Up to standards ✅

🟢 Issues 0 issues

Results:
0 new issues

View in Codacy

🟢 Metrics 60 complexity · 1 duplication

Metric Results
Complexity 60
Duplication 1

View in Codacy

NEW Get contextual insights on your PRs based on Codacy's metrics, along with PR and Jira context, without leaving GitHub. Enable AI reviewer
TIP This summary will be updated as you push new changes.

@JE-Chen JE-Chen merged commit 0f138c0 into dev Jun 21, 2026
16 checks passed
@JE-Chen JE-Chen deleted the feat/feature-flags branch June 21, 2026 01:12
@sonarqubecloud

Copy link
Copy Markdown

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant