Skip to content

Conversation

@ohall-m
Copy link

@ohall-m ohall-m commented Dec 8, 2025

This patch begins storing a PreviousState on ExperimentEnrollment when it is of type EnrollmentStatus::Enrolled. It also introduces PreviousState::GeckoPref to hold Gecko original preference values for Gecko pref based experiments.

The public APIs it opens are registerPreviousGeckoPrefStates and getPreviousState.

The goal of this patch is to appropriately store the original Gecko preference value to help when exiting an experiment.

Current idea is that it will be set similarly as unenrollForGeckoPref in this patch D257390, but for the positive case. Bug 2003370 will use this to properly consume these values when appropriate.

Pull Request checklist

  • Breaking changes: This PR follows our breaking change policy
    • This PR follows the breaking change policy:
      • This PR has no breaking API changes, or
      • There are corresponding PRs for our consumer applications that resolve the breaking changes and have been approved
  • Quality: This PR builds and tests run cleanly
    • Note:
      • For changes that need extra cross-platform testing, consider adding [ci full] to the PR title.
      • If this pull request includes a breaking change, consider cutting a new release after merging.
  • Tests: This PR includes thorough tests or an explanation of why it does not
  • Changelog: This PR includes a changelog entry in CHANGELOG.md or an explanation of why it does not need one
    • Any breaking changes to Swift or Kotlin binding APIs are noted explicitly
  • Dependencies: This PR follows our dependency management guidelines
    • Any new dependencies are accompanied by a summary of the due diligence applied in selecting them.

@ohall-m ohall-m force-pushed the 1997373 branch 5 times, most recently from ae5eaf6 to 181a21d Compare December 8, 2025 23:56
@ohall-m
Copy link
Author

ohall-m commented Dec 9, 2025

Hi @jeddai and @freshstrangemusic ,

Please take a look at this when you have a chance! I don't have the right repo access to request in the Reviewers panel.

@jeddai jeddai added nimbus Nimbus, the experimentation platform. rust Pull requests that update Rust code labels Dec 9, 2025
Copy link
Author

@ohall-m ohall-m left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for all the thoughtful comments! Really appreciate all of the rust explanations especially.

I have a couple of ToDos I marked in the comments that I'm still working through. I'm submitting the comments on what has changed to help keep the changes organized for now.

@ohall-m
Copy link
Author

ohall-m commented Dec 10, 2025

First draft comments should be addressed now, thanks!

Comment on lines 140 to 153
#[derive(Deserialize, Serialize, Debug, Clone, Hash, Eq, PartialEq)]
#[cfg(feature = "stateful")]
pub struct PreviousGeckoPrefState {
pub original_values: Vec<OriginalGeckoPref>,
pub feature_id: String,
pub variable: String,
}

#[derive(Deserialize, Serialize, Debug, Clone, Hash, Eq, PartialEq, uniffi::Enum)]
#[cfg(feature = "stateful")]
pub enum PreviousState {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Upon further reflection, im not sure this warrants being an enum. I think we should remove the variants and just have the PreivousGeckoPrefState in the enrollment.

Copy link
Author

@ohall-m ohall-m Dec 19, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Works for me! That would simplify a lot of checking.

(Still have this change ToDo.)

Comment on lines 374 to 375
.and_modify(|st| st.original_values.push(original_gecko_pref.clone()))
.or_insert_with(|| PreviousGeckoPrefState {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why would there be more than one "original gecko pref state" per experiment slug?

Copy link
Author

@ohall-m ohall-m Dec 19, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I pulled the conception of multiple gecko pref states from this construct pub type MapOfFeatureIdToPropertyNameToGeckoPrefState = HashMap<String, HashMap<String, GeckoPrefState>>;, but I'm not confident if I'm fully understanding the relationships here.

LMK, if you think multiple gecko pref states are possible! If not, I think just a singular gecko pref makes sense. It was mostly that section of code that made me wonder if it was possible. (I also don't have a strong picture of the hierarchy of experiment slug > feature > variable.)

#[derive(Deserialize, Serialize, Debug, Clone, Hash, Eq, PartialEq)]
#[cfg(feature = "stateful")]
pub struct PreviousGeckoPrefState {
pub original_values: Vec<OriginalGeckoPref>,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is this a Vec? Shouldn't it just be an OriginalGeckoPref ?

This patch begins storing a `PreviousState` on `ExperimentEnrollment` when it is of type `EnrollmentStatus::Enrolled`.
It also introduces `PreviousState::GeckoPref` to hold Gecko original preference values
for Gecko pref based experiments.

The public APIs it opens are `registerPreviousGeckoPrefStates` and `getPreviousState`.
@mergify mergify bot dismissed freshstrangemusic’s stale review December 19, 2025 20:55

The pull request has been modified, dismissing previous reviews.

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

Labels

nimbus Nimbus, the experimentation platform. rust Pull requests that update Rust code

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants