Skip to content

feat: hook execution lifecycle - #136

Open
NeaguGeorgiana23 wants to merge 2 commits into
mainfrom
hook_execution_lifecycle
Open

feat: hook execution lifecycle#136
NeaguGeorgiana23 wants to merge 2 commits into
mainfrom
hook_execution_lifecycle

Conversation

@NeaguGeorgiana23

Copy link
Copy Markdown
Contributor

This PR

  • Implements the complete OpenFeature Hook Execution Lifecycle in ClientAPIaccording to Section 4 of the OpenFeature specification.
  • Introduces HookSupport to encapsulate hook aggregation and stage execution helpers:
    • CollectHooks: Aggregates hooks across API, Client, Invocation, and Provider tiers in FIFO precedence order while filtering out nullptr entries.
    • CreateHookDataMap: Creates HookData instances per unique hook to persist stage data across an evaluation.
    • ExecuteBeforeHooks: Executes before hooks in forward order (API $\to$ Client $\to$ Invocation $\to$ Provider), supporting evaluation context mutation and error short-circuiting.
    • ExecuteAfterHooks: Executes after hooks in reverse order (Provider $\to$ Invocation $\to$ Client $\to$ API), transforming the result into error details if a hook throws.
    • ExecuteErrorHooks: Executes error hooks in reverse order upon abnormal execution (in before, resolution, or after stages), catching and suppressing exceptions per Requirement 4.4.4.
    • ExecuteFinallyHooks: Unconditionally executes finally hooks in reverse order, catching and suppressing exceptions per Requirement 4.4.3.
  • Adds const T* GetAs(const std::string& key) const overload to HookData for const-safe access to stored hook state.
  • Updates ClientAPI::EvaluateFlag evaluate flags cleanly via HookSupport.
  • Adds unit tests in test/client_api_test.cpp and test/hook_data_test.cpp covering hook execution order, hint propagation, type filtering, exception handling, and provider lifecycle status routing (kNotReady, kFatal, kError, kStale).

Related Issues

Fixes #135

Notes

  • Hook execution conforms to OpenFeature evaluation rules (Requirement 4.4.2), running before hooks from least specific to most specific (API $\to$ Client $\to$ Invocation $\to$ Provider) and after/error/finally in reverse order.
  • In accordance with Requirements 4.4.3 and 4.4.4, any exceptions thrown inside error or finally hooks are safely caught and swallowed to guarantee evaluation completes.

Signed-off-by: NeaguGeorgiana23 <neagugeorgiana@google.com>
Signed-off-by: NeaguGeorgiana23 <neagugeorgiana@google.com>
@NeaguGeorgiana23
NeaguGeorgiana23 requested review from a team as code owners August 28, 2026 14:56
@coderabbitai

coderabbitai Bot commented Aug 28, 2026

Copy link
Copy Markdown

Important

  • 🔍 Trigger review

This repository does not receive automatic reviews because it has fewer than 10 stars.

⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: cd370f8c-0330-49ec-b0cf-237f89434f9f


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

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.

Update FlagEvaluation flow

1 participant