Skip to content

feat: Add EvaluationOptions structure#120

Open
NeaguGeorgiana23 wants to merge 24 commits into
mainfrom
evaluation_options
Open

feat: Add EvaluationOptions structure#120
NeaguGeorgiana23 wants to merge 24 commits into
mainfrom
evaluation_options

Conversation

@NeaguGeorgiana23

Copy link
Copy Markdown
Contributor

This PR

  • Introduces the EvaluationOptions structure to enable per-invocation hook registration and evaluation hints according to the OpenFeature Hooks specification 4.5.1.
  • Adds unit tests for EvaluationOptions in test/evaluation_options_test.cpp to ensure proper container initialization, ordering preservation, safe downcasting, hint storage, and copy/move semantics.

Related Issues

Fixes #111

NeaguGeorgiana23 and others added 23 commits July 7, 2026 13:19
Signed-off-by: NeaguGeorgiana23 <neagugeorgiana@google.com>
Signed-off-by: NeaguGeorgiana23 <neagugeorgiana@google.com>
Signed-off-by: NeaguGeorgiana23 <neagugeorgiana@google.com>
Signed-off-by: NeaguGeorgiana23 <neagugeorgiana@google.com>
Signed-off-by: NeaguGeorgiana23 <neagugeorgiana@google.com>
Signed-off-by: NeaguGeorgiana23 <neagugeorgiana@google.com>
Signed-off-by: NeaguGeorgiana23 <neagugeorgiana@google.com>
Signed-off-by: NeaguGeorgiana23 <neagugeorgiana@google.com>
Signed-off-by: NeaguGeorgiana23 <neagugeorgiana@google.com>
Signed-off-by: NeaguGeorgiana23 <neagugeorgiana@google.com>
Signed-off-by: NeaguGeorgiana23 <neagugeorgiana@google.com>
Signed-off-by: NeaguGeorgiana23 <neagugeorgiana@google.com>
Signed-off-by: NeaguGeorgiana23 <neagugeorgiana@google.com>
Signed-off-by: NeaguGeorgiana23 <neagugeorgiana@google.com>
Signed-off-by: NeaguGeorgiana23 <neagugeorgiana@google.com>
Signed-off-by: NeaguGeorgiana23 <neagugeorgiana@google.com>
Signed-off-by: NeaguGeorgiana23 <neagugeorgiana@google.com>
Signed-off-by: NeaguGeorgiana23 <neagugeorgiana@google.com>
Signed-off-by: NeaguGeorgiana23 <neagugeorgiana@google.com>
Signed-off-by: NeaguGeorgiana23 <115723925+NeaguGeorgiana23@users.noreply.github.com>
Signed-off-by: NeaguGeorgiana23 <neagugeorgiana@google.com>
@NeaguGeorgiana23
NeaguGeorgiana23 requested review from a team as code owners July 15, 2026 12:25
@coderabbitai

coderabbitai Bot commented Jul 15, 2026

Copy link
Copy Markdown

Review Change Stack

Warning

Review limit reached

@NeaguGeorgiana23, you've reached your PR review limit, so we couldn't start this review.

Next review available in: 53 minutes

Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available.
You're only billed for reviews past your plan's rate limits ($0.25/file).

How can I continue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews.

How do review limits work?

CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability.

For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window.

Please refer docs for additional details.

Review details
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 10588e50-6941-4f90-a21e-921cbe9fd232

📥 Commits

Reviewing files that changed from the base of the PR and between 06bd51c and b362223.

📒 Files selected for processing (1)
  • test/evaluation_options_test.cpp
📝 Walkthrough

Walkthrough

Adds C++ APIs for hook lifecycle callbacks, evaluation options, and typed flag evaluation details. Bazel targets expose the new components, while GoogleTest coverage validates construction, lifecycle behavior, hints, polymorphism, and supported value types.

Changes

Hook and Evaluation APIs

Layer / File(s) Summary
Evaluation options and hook ownership
openfeature/base_hook.h, openfeature/evaluation_options.h, openfeature/BUILD, test/evaluation_options_test.cpp, test/BUILD
Adds polymorphic BaseHook storage and EvaluationOptions fields for hooks and HookHints, with tests for ordering, casting, hints, and copy/move behavior.
Flag evaluation details
openfeature/flag_evaluation_details.h, openfeature/flag_evaluation_details.cpp, openfeature/BUILD, test/flag_evaluation_details_test.cpp, test/BUILD
Adds typed flag-key and resolution-detail construction for supported value types, explicit template instantiations, and constructor/accessor tests.
Hook lifecycle interface and validation
openfeature/hook.h, openfeature/hook.cpp, openfeature/BUILD, test/hook_test.cpp, test/BUILD
Adds typed Before, After, Error, and Finally callbacks, common aliases, explicit instantiations, Bazel wiring, and lifecycle tests. Updates hook_context_test dependencies.

Estimated code review effort: 3 (Moderate) | ~30 minutes

Sequence Diagram(s)

sequenceDiagram
  participant EvaluationContext
  participant HookContext
  participant Hook
  participant FlagEvaluationDetails
  HookContext->>Hook: Before with context and hints
  Hook-->>EvaluationContext: optional updated context
  HookContext->>Hook: After with evaluation details
  HookContext->>Hook: Error with exception
  HookContext->>Hook: Finally with evaluation details
  FlagEvaluationDetails-->>Hook: flag key and resolution data
Loading

Possibly related PRs

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 14.71% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Linked Issues check ✅ Passed The PR delivers EvaluationOptions and related hook support referenced by #111.
Out of Scope Changes check ✅ Passed The changes stay focused on hook and evaluation-options data structures.
Title check ✅ Passed The title clearly summarizes the main change: adding the EvaluationOptions structure.
Description check ✅ Passed The description is directly related to the changeset and matches the new EvaluationOptions tests and hook registration support.

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@NeaguGeorgiana23 NeaguGeorgiana23 changed the title Evaluation options feat: Add EvaluationOptions structure Jul 15, 2026
Signed-off-by: NeaguGeorgiana23 <neagugeorgiana@google.com>

@coderabbitai coderabbitai 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.

🧹 Nitpick comments (4)
test/evaluation_options_test.cpp (1)

5-9: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low value

Include <utility> for std::move.

std::move is used on line 112, which strictly requires the <utility> header. Although it compiles currently due to transitive includes from other standard library headers, it's best practice to explicitly include the required headers.

♻️ Proposed fix
 `#include` <any>
 `#include` <memory>
 `#include` <string>
+#include <utility>
 `#include` <vector>
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@test/evaluation_options_test.cpp` around lines 5 - 9, Add the standard
<utility> header to the includes in evaluation_options_test.cpp so the std::move
usage in the test is explicitly supported, without changing the surrounding test
logic.
openfeature/flag_evaluation_details.cpp (1)

1-12: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low value

Include <utility> for std::move.

The code uses std::move extensively, which is defined in <utility>. While it may compile due to transitive inclusions from <string> or <optional>, it is best practice to include it explicitly.

♻️ Proposed fix
 `#include` <string>
 `#include` <string_view>
+#include <utility>
 
 `#include` "openfeature/error_code.h"
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@openfeature/flag_evaluation_details.cpp` around lines 1 - 12, Update the
includes in flag_evaluation_details.cpp to explicitly add the standard <utility>
header required by the std::move usages, leaving the existing includes and
implementation unchanged.
openfeature/flag_evaluation_details.h (1)

25-26: 🚀 Performance & Scalability | 🔵 Trivial | ⚡ Quick win

Optimize constructor by taking resolution_details by value.

The wrapping constructor currently takes ResolutionDetails<T> by const&, which forces an internal copy of potentially expensive fields (like strings and the generic T mapping). Taking the argument by value and using std::move allows the compiler to optimize out copies when an rvalue is passed.

  • openfeature/flag_evaluation_details.h#L25-L26: Change the parameter to take by value: ResolutionDetails<T> resolution_details.
  • openfeature/flag_evaluation_details.cpp#L25-L29: Change the parameter to take by value and move it into the base constructor: : ResolutionDetails<T>(std::move(resolution_details)).
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@openfeature/flag_evaluation_details.h` around lines 25 - 26, Update the
FlagEvaluationDetails constructor in openfeature/flag_evaluation_details.h lines
25-26 to accept ResolutionDetails<T> by value, and update its definition in
openfeature/flag_evaluation_details.cpp lines 25-29 to accept the same value
parameter and move it into the ResolutionDetails<T> base constructor.
openfeature/hook.h (1)

35-36: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Use const HookContext<T>& in Before for consistency.

The ctx parameter is passed by non-const reference in Before, but by const reference in After, Error, and Finally. Since any shared mutable state between stages should be managed internally (e.g. via a shared pointer to HookData), const HookContext<T>& is sufficient for all stages and provides a safer, consistent API contract.

  • openfeature/hook.h#L35-L36: Change the parameter to const HookContext<T>& ctx.
  • test/hook_test.cpp#L28-L29: Update the overridden TrackingHook::Before signature to match const HookContext<T>& ctx.
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@openfeature/hook.h` around lines 35 - 36, Change the Before method in
openfeature/hook.h at lines 35-36 to accept const HookContext<T>&, matching the
const contract used by After, Error, and Finally. Update the
TrackingHook::Before override in test/hook_test.cpp at lines 28-29 to use the
same const reference signature.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Nitpick comments:
In `@openfeature/flag_evaluation_details.cpp`:
- Around line 1-12: Update the includes in flag_evaluation_details.cpp to
explicitly add the standard <utility> header required by the std::move usages,
leaving the existing includes and implementation unchanged.

In `@openfeature/flag_evaluation_details.h`:
- Around line 25-26: Update the FlagEvaluationDetails constructor in
openfeature/flag_evaluation_details.h lines 25-26 to accept ResolutionDetails<T>
by value, and update its definition in openfeature/flag_evaluation_details.cpp
lines 25-29 to accept the same value parameter and move it into the
ResolutionDetails<T> base constructor.

In `@openfeature/hook.h`:
- Around line 35-36: Change the Before method in openfeature/hook.h at lines
35-36 to accept const HookContext<T>&, matching the const contract used by
After, Error, and Finally. Update the TrackingHook::Before override in
test/hook_test.cpp at lines 28-29 to use the same const reference signature.

In `@test/evaluation_options_test.cpp`:
- Around line 5-9: Add the standard <utility> header to the includes in
evaluation_options_test.cpp so the std::move usage in the test is explicitly
supported, without changing the surrounding test logic.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: da405df6-b178-4523-a0ba-a41108057819

📥 Commits

Reviewing files that changed from the base of the PR and between b7e65b5 and 06bd51c.

📒 Files selected for processing (11)
  • openfeature/BUILD
  • openfeature/base_hook.h
  • openfeature/evaluation_options.h
  • openfeature/flag_evaluation_details.cpp
  • openfeature/flag_evaluation_details.h
  • openfeature/hook.cpp
  • openfeature/hook.h
  • test/BUILD
  • test/evaluation_options_test.cpp
  • test/flag_evaluation_details_test.cpp
  • test/hook_test.cpp

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.

Hook data structures

1 participant