Somewhat contrived example perhaps, but for a top level assignment like this:
cache_duration_seconds := 60 * 60 * 24 * 30
Does OPA recognize the value as constant and persist it between requests, or is it going to be calculated per invocation?
OPA will memoize the value generated by the rule and cache it for the duration of the policy query. In other words, in this case, if cache_duration_seconds
is referenced multiple times in the policy, it will be computed once and then re-used at each location. The next time the policy is queried, the value be computed again.