Skip to content

feat: Populate OpenFeature flag metadata from the LaunchDarkly evaluation reason - #33

Open
kinyoklion wants to merge 2 commits into
mainfrom
devin/1793803366-php-flag-metadata
Open

kinyoklion wants to merge 2 commits into
mainfrom
devin/1793803366-php-flag-metadata

Conversation

@kinyoklion

@kinyoklion kinyoklion commented Nov 4, 2026 •

Copy link
Copy Markdown
Member

OpenFeature PHP SDK 2.4.0 (released 2026-11-04) added flag metadata to ResolutionDetails/EvaluationDetails. This populates it with the OFP-defined keys so LaunchDarkly reason details (experiment membership, matched rule, failed prerequisite, Big Segments status) are visible through OpenFeature.

  • ResolutionDetailsConverter now always sets metadata, containing only the OFP 3.3.1 keys (variationIndex, inExperiment, ruleIndex, ruleId, prerequisiteKey, bigSegmentsStatus); each key is omitted when not applicable (OFP 3.3.2), and no other keys are added (OFP 3.3.3). For default values the metadata is an empty array.
  • Minimum dependency versions raised to what the feature needs: open-feature/sdk ^2.0 → ^2.4 (ResolutionDetailsBuilder::withMetadata is new in 2.4.0) and launchdarkly/server-sdk ^6.2 → ^6.4 (EvaluationReason::bigSegmentsEvaluationStatus() is new in 6.4.0).
  • README: the "Flag metadata" matrix row previously said the OpenFeature PHP SDK had no metadata; it is now ✅ with a new "Flag Metadata" section documenting the keys.

Requirements

  • I have added test coverage for new or changed functionality
  • I have followed the repository's pull request submission guidelines
  • I have validated my changes against all supported platform versions (validated locally on PHP 8.3; CI covers the matrix)

Related issues

Found by the weekly OpenFeature provider audit. Spec: OFP section 3.3 in launchdarkly/sdk-specs.

Implementation details
  • bigSegmentsStatus uses the BigSegmentsEvaluationStatus enum's string value (HEALTHY, STALE, NOT_CONFIGURED, STORE_ERROR).
  • inExperiment is only present when true.
  • New tests/ResolutionDetailsConverterTest.php covers fallthrough, experiment fallthrough, rule match, prerequisite failed, Big Segments status, error/default and off-without-variation cases, plus an end-to-end provider evaluation with TestData rule matching.
  • One test line carries a @phpstan-ignore-next-line because the LaunchDarkly SDK documents FlagBuilder::ifMatch's variadic values as array, though it takes individual values.
  • make check (php-cs-fixer, phpstan level 8, phpunit: 46 tests) passes locally. The hello-openfeature-php-server example run against this branch returned {"variationIndex":0,"ruleIndex":0,"ruleId":"…"} for a rule-matched flag.

Link to Devin session: https://app.devin.ai/sessions/4697c1407a49413caaaf2a623231755a

Open in Devin Desktop: https://app.devin.ai/desktop/session/4697c1407a49413caaaf2a623231755a?variant=devin
Requested by: @kinyoklion

…tion reason

Co-Authored-By: Ryan Lamb <4955475+kinyoklion@users.noreply.github.com>
@devin-ai-integration

Copy link
Copy Markdown
Contributor

I'll fix CI failures and address comments from users with write access. I'll skip comments containing "(aside)".

  • Disable automatic comment, CI, and merge conflict monitoring

@kinyoklion
kinyoklion marked this pull request as ready for review November 4, 2026 20:51
@kinyoklion
kinyoklion requested a review from a team as a code owner November 4, 2026 20:51

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes using default effort and found 1 potential issue.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, have a team admin enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit aca7cff. Configure here.

Comment thread src/ResolutionDetailsConverter.php Resolved
Co-Authored-By: Ryan Lamb <4955475+kinyoklion@users.noreply.github.com>

This branch has not been deployed

No deployments
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