Skip to content

Commit 85f8fda

Browse files
hhan2024Codex GPT-6
andcommitted
fix(ffe): address dependent flag review feedback
Return Rust-owned evaluation snapshots and consume borrowed views in C with bailout-safe cleanup. Separate root exposure control from prerequisite deferral, and lazily encode shared attributes only for immediate exposure recording. Document requested-flag metric control and the root-only ExposureHook contract. Cover retained snapshots, native deferral controls, customer hook behavior, and actual dependent-flag RC capability selection and delivery. Environment: Datadog workspace Co-Authored-By: Codex GPT-6 <noreply@localhost>
1 parent d165174 commit 85f8fda

12 files changed

Lines changed: 495 additions & 398 deletions

File tree

‎components-rs/common.h‎

Lines changed: 26 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -534,6 +534,8 @@ typedef struct ddog_DslString ddog_DslString;
534534
*/
535535
typedef struct ddog_FfeCdnConfig ddog_FfeCdnConfig;
536536

537+
typedef struct ddog_FfeEvaluation ddog_FfeEvaluation;
538+
537539
typedef struct ddog_FfeFeatures ddog_FfeFeatures;
538540

539541
/**
@@ -599,6 +601,30 @@ typedef struct ddog_DsmIdentity {
599601
ddog_CharSlice base_hash;
600602
} ddog_DsmIdentity;
601603

604+
/**
605+
* All slices and features are borrowed until ddog_ffe_evaluation_drop.
606+
* NULL slices mean absent strings; non-NULL empty slices mean empty strings.
607+
*/
608+
typedef struct ddog_FfeResultView {
609+
ddog_CharSlice value_json;
610+
ddog_CharSlice variant;
611+
ddog_CharSlice allocation_key;
612+
int32_t reason;
613+
int32_t error_code;
614+
int32_t serial_id;
615+
bool has_serial_id;
616+
bool do_log;
617+
bool observe_full_evaluation_data;
618+
bool valid;
619+
const struct ddog_FfeFeatures *features;
620+
} ddog_FfeResultView;
621+
622+
typedef struct ddog_FfeDependencyView {
623+
ddog_CharSlice key;
624+
struct ddog_FfeResultView result;
625+
bool exposure_eligible;
626+
} ddog_FfeDependencyView;
627+
602628
typedef struct ddog_FfeFeature {
603629
ddog_CharSlice key;
604630
/**
@@ -611,23 +637,6 @@ typedef struct ddog_FfeFeature {
611637
uintptr_t destinations_count;
612638
} ddog_FfeFeature;
613639

614-
typedef struct ddog_FfeResult {
615-
_zend_string * value_json;
616-
_zend_string * variant;
617-
_zend_string * allocation_key;
618-
int32_t reason;
619-
int32_t error_code;
620-
int32_t serial_id;
621-
bool has_serial_id;
622-
bool do_log;
623-
bool observe_full_evaluation_data;
624-
bool valid;
625-
/**
626-
* NULL when the selected split has no features. Release with ddog_ffe_features_drop.
627-
*/
628-
struct ddog_FfeFeatures *features;
629-
} ddog_FfeResult;
630-
631640
typedef struct ddog_FfeAttribute {
632641
ddog_CharSlice key;
633642
int32_t value_type;
@@ -636,8 +645,6 @@ typedef struct ddog_FfeAttribute {
636645
bool bool_value;
637646
} ddog_FfeAttribute;
638647

639-
typedef void (*ddog_FfeDependencyCallback)(void*, ddog_CharSlice, struct ddog_FfeResult, bool);
640-
641648
/**
642649
* Flags selecting which Remote Config products/capabilities to subscribe to.
643650
*

‎components-rs/datadog.h‎

Lines changed: 21 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -296,6 +296,18 @@ void ddog_ffe_cdn_config_drop(struct ddog_FfeCdnConfig*);
296296
*/
297297
struct ddog_Endpoint *ddog_ffe_evp_endpoint_new(ddog_CharSlice site, ddog_CharSlice api_key);
298298

299+
struct ddog_FfeResultView ddog_ffe_evaluation_result(const struct ddog_FfeEvaluation *evaluation);
300+
301+
uintptr_t ddog_ffe_evaluation_dependencies_count(const struct ddog_FfeEvaluation *evaluation);
302+
303+
/**
304+
* An out-of-range index returns an invalid result and an empty key.
305+
*/
306+
struct ddog_FfeDependencyView ddog_ffe_evaluation_dependency_get(const struct ddog_FfeEvaluation *evaluation,
307+
uintptr_t index);
308+
309+
void ddog_ffe_evaluation_drop(struct ddog_FfeEvaluation *evaluation);
310+
299311
uintptr_t ddog_ffe_features_count(const struct ddog_FfeFeatures *features);
300312

301313
/**
@@ -311,21 +323,15 @@ ddog_CharSlice ddog_ffe_features_destination(const struct ddog_FfeFeatures *feat
311323
uintptr_t index,
312324
uintptr_t destination);
313325

314-
void ddog_ffe_features_drop(struct ddog_FfeFeatures *features);
315-
316-
struct ddog_FfeResult ddog_ffe_evaluate(ddog_CharSlice flag_key,
317-
int32_t expected_type,
318-
ddog_CharSlice targeting_key,
319-
const struct ddog_FfeAttribute *attributes,
320-
uintptr_t attributes_count);
321-
322-
struct ddog_FfeResult ddog_ffe_evaluate_with_dependencies(ddog_CharSlice flag_key,
323-
int32_t expected_type,
324-
ddog_CharSlice targeting_key,
325-
const struct ddog_FfeAttribute *attributes,
326-
uintptr_t attributes_count,
327-
ddog_FfeDependencyCallback callback,
328-
void *callback_context);
326+
/**
327+
* Build an owned snapshot; conversion to Zend values happens in C after return.
328+
* Release with ddog_ffe_evaluation_drop, including if C bails out consuming it.
329+
*/
330+
struct ddog_FfeEvaluation *ddog_ffe_evaluate(ddog_CharSlice flag_key,
331+
int32_t expected_type,
332+
ddog_CharSlice targeting_key,
333+
const struct ddog_FfeAttribute *attributes,
334+
uintptr_t attributes_count);
329335

330336
void ddog_init_remote_config(struct ddog_RemoteConfigFlags flags);
331337

0 commit comments

Comments
 (0)