This feature is currently in beta and requires enablement. Contact us on
Slack to get access.
Policy Preview Overview (Growth Plan)
Policy Preview is a beta CL feature that benchmarks query performance for a candidate policy — a new or modified policy you’re testing — and compares it to your current production policy. Use this tool to test policy changes during development or enforce performance checks in CI pipelines.Requirements
- Growth plan subscription
- Oso Cloud CLI, version >= 0.35.0
- A candidate policy to compare against your deployed policy
- A list of queries to benchmark
Quick Start
- Create a query manifest (e.g.
queries.yaml)
-
Create a candidate policy with your proposed changes
You can use a single .polar file (e.g.
candidate.polar) or multiple .polar files (e.g.policies/*.polar). - Run the preview
- Define failure thresholds
| Flag | Description |
|---|---|
-f,--fail-on-regression-percent | Fail if any query is slower by this percentage (e.g., 20 for 20%) |
-i,--ignore-changes-under-ms | Ignore regressions smaller than this threshold in milliseconds (e.g., 10) |
--max-duration-ms | Fail if any query exceeds this absolute duration in milliseconds (e.g., 750) |
--max-regression-ms | Fail if any query slows down by more than this many milliseconds (e.g., 200) |
- It times out with the candidate policy but not the current one, or
- It times out with both policies.
Query Manifest Reference
The manifest file defines the queries to execute during policy preview. It supports the following query types: The query structure is similar to the HTTP API, with two additional required fields:name and query_type.
Manifest Structure
Query Types
Authorize Query
List Query
Actions Query
Evaluate Query
predicate: Array where first element is predicate name, the rest are variable namesconstraints: Map of variable names to constraint definitionstype: Entity type for the variableids(optional): List of IDs to test
- All variables in
predicateorcallsmust be defined inconstraints
calls: Array of predicate calls formatted likepredicate
Output Format
Policy Preview outputs results in a formatted table comparing baseline and candidate performance, showing regressions, improvements, and failures:Best Practices
Create Representative Query Sets
Include queries that represent:- Common authorization paths
- Edge cases
- Performance-critical queries
- Recently changed policy rules
Troubleshooting
”Feature not enabled” error
Policy Preview must be enabled. Contact us on Slack to gain access.YAML parsing errors
Check your manifest structure. Common issues include:- Missing required fields
- Incorrect indentation
- Unknown fields
Limitations
- Context facts are not currently supported in query manifests