#9269·opa

v2: Add `v2` rego-version to Go API

Author: johanfyllingCreated Sep 25, 2026Updated Sep 25, 2026

The programmatic Go equivalent to importing rego.v2 in Rego.

The Rego-version for a module/bundle is declared through the ast.RegoVersion enum; where we need to introduce RegoV2 to represent v2.

RegoV2: The module has v2 enabled by default; no rego.v2 and future.keywords.* imports required.


Open question: do we also need a RegoV1CompatV2?

When introducing the v1 rego-version, added syntactic strictness required a transitional RegoV0CompatV1 Rego-version to enforce that the module is compatible with both v0 and v1 versions. v2 is additive, and the syntax isn't changed beyond introducing new reserved keywords (keyword restriction limits available rule/func/var names). If we don't need to provide an upgrade path on the scale of v1, then the transitional RegoV1CompatV2 would be redundant.