Repository navigation
fix: clarify evaluation context propagation between hook stages - #465
CloudedKarma wants to merge 4 commits into
Conversation
Signed-off-by: CloudedKarma <117319672+CloudedKarma@users.noreply.github.com>
Signed-off-by: CloudedKarma <117319672+CloudedKarma@users.noreply.github.com>
Signed-off-by: CloudedKarma <117319672+CloudedKarma@users.noreply.github.com>
Signed-off-by: CloudedKarma <117319672+CloudedKarma@users.noreply.github.com>
|
No actionable comments were generated in the recent review. Walkthrough
Merge Risk:
|
This PR
Clarifies how evaluation context updates returned by before hooks are merged and propagated throughout the hook evaluation lifecycle.
The existing wording leaves ambiguity regarding when context updates must be merged and which evaluation context subsequent hook stages should receive. This can result in implementations passing the original evaluation context to subsequent hooks while only providing the accumulated context to the provider during flag resolution.
This PR:
Updates Requirement 4.3.4 to require incremental merging of evaluation context before subsequent hook invocations or flag resolution.
Updates Requirement 4.3.5 to require subsequent before, after, error, and finally hooks to receive the current merged evaluation context in dynamic-context implementations.
Clarifies context preservation when a before hook returns no evaluation context.
Clarifies that updates returned by previously completed before hooks remain available when a subsequent before hook terminates abnormally.
References existing evaluation context merge precedence and multi-provider context isolation documentation.
Preserves the existing requirement identifiers.
Regenerates specification.json.
Six Gherkin conformance scenarios have been added to cover:
Incremental evaluation context accumulation across multiple before hooks.
Context propagation to error and finally hooks following failed flag resolution.
Context preservation when a before hook returns no evaluation context.
Preservation of previously returned context when a subsequent before hook fails.
Context preservation when an after hook fails.
Isolation of hook-generated context updates between evaluations.
Related Issues
Related to #329.
Related pull request: #459.
Notes
A separate local proof-of-concept implementation was created using the Python SDK to investigate the reported behavior and validate the proposed requirements.
Five of the six proposed conformance scenarios failed against the original Python SDK implementation. After implementing incremental context merging and propagation in the local reference implementation, all six scenarios passed.
Additional tests verified:
Targeting-key and attribute precedence.
Context propagation across API, client, invocation, and provider hook registration levels.
Before, after, and finally hook execution ordering.
Hook data isolation.
Preservation of original evaluation contexts.
Synchronous and asynchronous client evaluation behavior.
The Python SDK proof-of-concept implementation is not included in this specification pull request.
I am aware of the overlapping proposal in #459. This contribution provides an alternative approach by clarifying the existing requirements and supplying additional conformance scenarios and local implementation evidence.
The following pre-existing validation issues were identified in the upstream baseline and left unchanged to avoid unrelated modifications:
25 violations from the local recursive Markdown linting command.
Four existing specification parser unit test failures.
Existing Prettier formatting inconsistencies unrelated to the proposed changes.
All testing was performed locally on Windows. GitHub Actions validation remains pending.
Follow-up Tasks
Coordinate implementation of the new Gherkin step definitions across applicable SDKs.
Determine the preferred approach for filtering unsupported conformance scenarios.
Confirm the preferred organization of the normative requirements, including whether to clarify existing requirements or introduce a new requirement identifier.
Coordinate any necessary SDK implementation changes.
The six new scenarios use a proposed @hook-context-propagation capability tag alongside the applicable specification requirement tags. This enables selective execution or exclusion but does not automatically configure existing SDK runners to skip unsupported scenarios.
Multi-provider context isolation is referenced in the proposed wording but has not been independently tested.
The asynchronous tests exercise the asynchronous client evaluation lifecycle using a synchronous recording provider through the SDK's asynchronous adapter. Native asynchronous providers and concurrent asynchronous evaluations were not independently tested.
Maintainer feedback on the proposed wording, error-path behavior, and conformance test integration would be appreciated before this PR is considered ready for merging.
How to test
The specification changes can be validated using the repository's existing Makefile targets:
make parse
make lint
make markdown-toc
git diff --check
The generated specification.json and table of contents should remain synchronized.
The new conformance scenarios can be selected in a compatible Behave test environment using:
behave --tags="@hook-context-propagation"
The corresponding step definitions must be implemented in the SDK test runner before executing these scenarios.
The following results were obtained using the separate local Python SDK proof of concept and specification validation tools: