You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
feat(flagd): extract evaluator into api, core, and testkit packages (#377)
* feat: extract flagd evaluator into api, core, and testkit packages
Split the flagd evaluation logic from the provider into three
independent packages under tools/, mirroring the Java SDK contrib
architecture (PRs #1696 and #1742):
- openfeature-flagd-api: Evaluator Protocol defining the contract
for flag evaluation implementations
- openfeature-flagd-core: Reference implementation with FlagdCore
class, targeting engine, and custom operators (fractional, sem_ver,
starts_with, ends_with)
- openfeature-flagd-api-testkit: Compliance test suite bundling
gherkin feature files from the test-harness evaluator directory
The provider's InProcessResolver now delegates to FlagdCore via an
adapter pattern, keeping connector code (FileWatcher, GrpcWatcher)
unchanged. Old provider modules (flags.py, targeting.py, custom_ops.py)
are thin re-exports from the core package for backward compatibility.
Also updates the test-harness submodule from v2.11.1 to v3.5.0.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Signed-off-by: Simon Schrottner <simon.schrottner@gmail.com>
* fix: update flagd-core to match upstream fractional v2 and Python 3.10
- Implement fractional v2 bucketing algorithm (unsigned hash, integer
arithmetic with bit-shift instead of percentage-based float)
- Add MAX_WEIGHT_SUM overflow guard
- Add negative weight clamping (max(0, weight))
- Add explicit bool-as-weight rejection
- Support non-string variant types (str|float|int|bool|None)
- Extract _resolve_bucket_by helper
- Bump mmh3 dependency to >=5.0.0,<6.0.0
- Drop Python 3.9: update requires-python to >=3.10 for all tools packages
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Signed-off-by: Simon Schrottner <simon.schrottner@gmail.com>
* fix: resolve CI failures - lint, typing, and protobuf v1 revert
- Fix ruff violations: UP007 (modern type unions), N818 (rename
FlagStoreException to FlagStoreError), FURB171 (simplify membership
test), PERF401 (use list comprehension), S101 (allow assert in steps)
- Add py.typed marker files for PEP 561 compliance
- Revert protobuf evaluation.v2 imports/config back to v1
- Run ruff format on all affected files
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Signed-off-by: Simon Schrottner <simon.schrottner@gmail.com>
* fix: revert schemas and spec submodules to main
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Signed-off-by: Simon Schrottner <simon.schrottner@gmail.com>
* fix: revert grpc resolvers to upstream main (keep evaluation.v2)
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Signed-off-by: Simon Schrottner <simon.schrottner@gmail.com>
* chore: remove allFlags.json test artifact
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Signed-off-by: Simon Schrottner <simon.schrottner@gmail.com>
* style: format test_in_process.py
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Signed-off-by: Simon Schrottner <simon.schrottner@gmail.com>
* ci: add tools packages to CI workflow
- Add tools/openfeature-flagd-{api,core,api-testkit} to build matrix
- Replace project.scripts with poe tasks to match CI expectations
- Add poethepoet dev dependency to all tools packages
- Remove obsolete scripts.py files
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Signed-off-by: Simon Schrottner <simon.schrottner@gmail.com>
* test: skip fractional-v1 tests in flagd-core (v2 algorithm)
flagd-core implements the v2 fractional bucketing algorithm, so v1
test expectations don't match. Deselect @fractional-v1 tagged tests.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Signed-off-by: Simon Schrottner <simon.schrottner@gmail.com>
* fix: add testkit smoke tests and fix empty test collection
The testkit is a test library, not a test suite. CI's `poe cov` failed
with "no data collected" because tests/ was empty. Add smoke tests to
verify the testkit can be imported and returns valid data.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Signed-off-by: Simon Schrottner <simon.schrottner@gmail.com>
* style: fix import sorting in testkit smoke test
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Signed-off-by: Simon Schrottner <simon.schrottner@gmail.com>
* fix: add type annotations to testkit step definitions
Fix mypy errors: add return types, parameter types, use ErrorCode enum
instead of string, and cast Mapping to dict for indexed assignment.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Signed-off-by: Simon Schrottner <simon.schrottner@gmail.com>
* style: simplify error_code conditional (SIM or)
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Signed-off-by: Simon Schrottner <simon.schrottner@gmail.com>
* fix: address review feedback from Gemini and internal review
- Accept str | dict in Evaluator protocol and FlagdCore, eliminating
the dict->JSON->dict roundtrip in _FlagStoreAdapter
- Fix ReferenceError handler: use exception instance, not class, and
log flag.targeting instead of the function object
- Escape evaluator names in $ref regex replacement (re.escape)
- Fix backward-compat FlagStore to emit changed_keys, not all keys
- Fix README import paths (was api.testkit, should be testkit)
- Add content to flagd-core CHANGELOG.md
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Signed-off-by: Simon Schrottner <simon.schrottner@gmail.com>
* fix: generate testkit features from test-harness submodule at build time
Replace vendored feature/flag files with a hatch build hook that copies
them from the test-harness submodule's evaluator/ directory. Files are
gitignored and generated fresh on each build via force_include.
Also:
- Update test-harness submodule to v3.5.0 (adds @fractional-v1/v2 tags)
- Add fractional-v1 deselect to provider pytest.ini
- Remove redundant flags.py re-export from testkit
- Address review feedback (dict passthrough, ReferenceError fix, etc.)
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Signed-off-by: Simon Schrottner <simon.schrottner@gmail.com>
* style: remove unused noqa directive in hatch_build.py
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Signed-off-by: Simon Schrottner <simon.schrottner@gmail.com>
* fix: sync test-harness files to source tree for dev and CI testing
The hatch build hook includes files in sdist/wheel via force_include,
but tests run from the source tree. Add a sync script that copies
files from the test-harness submodule, called by poe before test/cov.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Signed-off-by: Simon Schrottner <simon.schrottner@gmail.com>
* fix: run testkit sync before flagd-core tests
flagd-core e2e tests depend on testkit feature files which are
generated from the test-harness submodule, not checked in.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Signed-off-by: Simon Schrottner <simon.schrottner@gmail.com>
* fix: add comment for Gherkin escape handling in testkit utils
Explain why the replace('\"', '"') is needed — pytest-bdd preserves
backslash escapes from Gherkin table cells.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Signed-off-by: Simon Schrottner <simon.schrottner@gmail.com>
* fix: restore FlagStore.update() return type to match supertype
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Signed-off-by: Simon Schrottner <simon.schrottner@gmail.com>
---------
Signed-off-by: Simon Schrottner <simon.schrottner@gmail.com>
Co-authored-by: Claude Sonnet 4.6 <noreply@anthropic.com>
0 commit comments