PlanOut programs are just sets of assignments with some conditions imposed on top of them. If we generate the dependencies between variables in a PlanOut program, we can use this information to determine which contrasts are valid.
All PlanOut programs can be converted into graphs.

Yellow nodes indicate that the variable is defined outside the program and that its value is not known until runtime. Rectangular nodes are random variables that are the direct result of random operators. Circular nodes are deterministic. Ellipsoid nodes are random variables through the flow of data.

userid is the only variable that’s external to the program. To reason about its role, we must observe it. All variables defined in the consequent depend on the variables in the guard. This is why there is an edge from specific_goal to ratings_per_user_goal.

When devising possible estimators for PlanOut programs, we want to know:

Under what conditions is a variable in a PlanOut program (conditionally)
uncorrelated with the users’ potential outcomes?

What are the valid causal contrasts for the DAG?

Given that userid has sufficiently high cardinality, we have complete information about the joint probability distribution of group_size, ratings_per_user, and rating_per_user_goal. We want to look at changes to the script that could change constrain our understanding of the distribution of variables.

Note that question (1) is not completely trivial: this example illustrates that it is not so simple as detecting assignment from random operators. Since sums and products of random variables are also random variables, and since control flow can define random variables, determining whether a node is an ellipsoid in this graph is non trivial.

When is a variable a random variable?

Sums and products of random variables

What if ratings_goal were instead defined to be 2 * group_size? It would still be a an random variable, and we would still know the full joint probability distribution. In fact, if any of a node’s parents is a random variable, then that node is itself a random variable.

Since assignment in the consequent and subsequent of an if-statement depends on the guard, we can use the same conditions as for arithmetic operators to infer that group_size is a random variable.

In all of these cases, we have the full joint probability distribution available, enabling us to compare any subset of the factors. All assignments use the same unit of randomization (userid), so a simple difference of means for any conditions is valid.