Skip to content

feat: Add environment ID support for hooks. - #594

Draft
kinyoklion wants to merge 8 commits into
mainfrom
devin/1786559619-cpp-hook-environment-id
Draft

kinyoklion wants to merge 8 commits into
mainfrom
devin/1786559619-cpp-hook-environment-id

Conversation

@kinyoklion

@kinyoklion kinyoklion commented Aug 12, 2026 •

Copy link
Copy Markdown
Member

Summary

Server SDK: the X-LD-EnvID response header now reaches EvaluationSeriesContext / TrackSeriesContext, for both FDv1 and FDv2 data systems.

  • The environment ID rides the data payload into the store: SDKDataSet::environment_id (FDv1 Init) and ChangeSet::environment_id (FDv2 Apply).
  • MemoryStore retains it while applying the payload — absent/empty values leave a previously reported ID in place — and reports nothing before initialization.
  • IDataSystem::EnvironmentId() is what ClientImpl passes into the hook contexts (std::nullopt for offline/lazy load).
  • Only successful responses count; errors and missing headers leave the value untouched.

Screenshots and a staging preview don't apply: SDK-internal data path, no UI.

Implementation details

FDv1 polling attaches the header of a successful response to the parsed data set; FDv1 streaming attaches the connection's header to the put payload it hands to the destination; the FDv1 fallback adapter stamps it onto the change sets it synthesizes for FDv2, retaining it for subsequent partials.

// FDv1 polling
poll_result->environment_id = ReadEnvironmentId(res.Headers());
sink_->Init(std::move(*poll_result));

// FDv2 polling / streaming
cs->change_set.environment_id = ReadEnvironmentId(res.Headers());

kEnvironmentIdHeader and the ReadEnvironmentId overloads (HTTP result and Beast headers) live in data_systems/environment_id_header.hpp and are shared by all four data sources.

Verified with harness hooks/evaluation/provides the environment ID (default + polling) against both v2.39.0 (FDv1) and v3.2.0-alpha.6 (FDv2), plus the server unit suite and the full v3 contract suite.

Link to Devin session: https://app.devin.ai/sessions/bfe54128e2804a96bb100e6120e9a3ef
Requested by: @kinyoklion

Loading
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant