Skip to content

feat: Rego WASM governance — wire models, platform service, CLI bootstrap - #1807

Draft
evanbijoy251 wants to merge 5 commits into
mainfrom
feat/rego-evaluator
Draft

evanbijoy251 wants to merge 5 commits into
mainfrom
feat/rego-evaluator

Conversation

@evanbijoy251

@evanbijoy251 evanbijoy251 commented Jul 10, 2026 •

Copy link
Copy Markdown

Summary

End-to-end plumbing for the Rego/WASM governance evaluator across three packages:

uipath-core — wire models + feature flag

  • HookBundle and AllPoliciesResponse Pydantic models for the /all-policies/{tenant_id} endpoint, alongside PolicyResponse
  • REGO_FEATURE_FLAG = "EnablePythonGovernanceRegoEvaluator" and is_rego_enabled() mirroring the existing GOVERNANCE_FEATURE_FLAG / is_governance_enabled() pattern exactly

uipath-platform — GovernanceService methods

  • retrieve_all_policies() / retrieve_all_policies_async() — GET /{org}/agenticgovernance_/api/v1/all-policies/{tenant_id}
  • download_bundle() / download_bundle_async() — plain httpx GET to pre-signed CDN URLs (no platform auth)

uipath (CLI) — governance bootstrap wiring

  • GovernanceBootstrap.rego_evaluator field added
  • wrap_runtime() passes it to UiPathGovernedRuntime
  • resolve_governance() calls build_rego_evaluator_async(sdk.governance) when is_rego_enabled() — no background threads, same inline pattern as the native evaluator

Commits

  1. feat: add Rego wire models and feature flag to core — uipath-core 0.5.31
  2. feat: add retrieve_all_policies and download_bundle to GovernanceService — uipath-platform 0.2.7
  3. feat: wire Rego evaluator into governance CLI bootstrap

Dependencies

Depends on UiPath/uipath-runtime-python#feat/rego-evaluator-v2 for RegoEvaluator and build_rego_evaluator_async.

Test plan

  • uv run pytest packages/uipath-platform/tests/services/test_governance_service.py — 59 tests pass
  • UIPATH_FEATURE_EnablePythonGovernanceRegoEvaluator=true uipath run agent.py triggers Rego bootstrap
  • Missing UIPATH_ORGANIZATION_ID / UIPATH_TENANT_ID → ValueError from retrieve_all_policies
  • CDN 4xx → httpx.HTTPStatusError from download_bundle

Generated with Claude Code

Development Packages

uipath

[project]
dependencies = [
  # Exact version (copy-paste ready):
  "uipath==2.13.10.dev1018077236",

  # Any version from this PR (uncomment to use a range instead):
  # "uipath>=2.13.10.dev1018070000,<2.13.10.dev1018080000",
]

[[tool.uv.index]]
name = "testpypi"
url = "https://test.pypi.org/simple/"
publish-url = "https://test.pypi.org/legacy/"
explicit = true

[tool.uv.sources]
uipath = { index = "testpypi" }
uipath-platform = { index = "testpypi" }
uipath-core = { index = "testpypi" }

[tool.uv]
override-dependencies = ["uipath-platform==0.2.7.dev1018077236", "uipath-core==0.5.31.dev1018077236"]

uipath-core

[project]
dependencies = [
  # Exact version (copy-paste ready):
  "uipath-core==0.5.31.dev1018077236",

  # Any version from this PR (uncomment to use a range instead):
  # "uipath-core>=0.5.31.dev1018070000,<0.5.31.dev1018080000",
]

[[tool.uv.index]]
name = "testpypi"
url = "https://test.pypi.org/simple/"
publish-url = "https://test.pypi.org/legacy/"
explicit = true

[tool.uv.sources]
uipath-core = { index = "testpypi" }

evanbijoy251 and others added 3 commits July 10, 2026 11:54
Adds HookBundle and AllPoliciesResponse Pydantic wire models for
the /all-policies/{tenant_id} endpoint alongside PolicyResponse.
Adds REGO_FEATURE_FLAG / is_rego_enabled() mirroring the existing
GOVERNANCE_FEATURE_FLAG / is_governance_enabled() pattern.
Bumps uipath-core to 0.5.31.

Generated with Claude Code

Co-Authored-By: Claude <noreply@anthropic.com>
Adds retrieve_all_policies() / retrieve_all_policies_async() to fetch
WASM bundle metadata from /all-policies/{tenant_id}, and
download_bundle() / download_bundle_async() for CDN downloads
(no platform auth — pre-signed URLs). Re-exports HookBundle and
AllPoliciesResponse from uipath.platform.governance.
Bumps uipath-platform to 0.2.7.

Generated with Claude Code

Co-Authored-By: Claude <noreply@anthropic.com>
Adds REGO_FEATURE_FLAG gate to resolve_governance(): when
EnablePythonGovernanceRegoEvaluator is on, calls
build_rego_evaluator_async(sdk.governance) and passes the result
into GovernanceBootstrap.wrap_runtime() → UiPathGovernedRuntime.
Mirrors the native evaluator bootstrap pattern exactly.

Generated with Claude Code

Co-Authored-By: Claude <noreply@anthropic.com>
@github-actions github-actions Bot added test:uipath-langchain Triggers tests in the uipath-langchain-python repository test:uipath-runtime test:uipath-integrations labels Jul 10, 2026
@evanbijoy251 evanbijoy251 added the build:dev Create a dev build from the pr label Jul 10, 2026
evanbijoy251 and others added 2 commits July 12, 2026 23:17
The /all-policies endpoint does not take a tenant_id URL segment —
the target tenant is resolved from the x-uipath-internal-tenantid
header that _build_org_scoped_request already injects.

Generated with Claude Code

Co-Authored-By: Claude <noreply@anthropic.com>
The top-level `from uipath.runtime.governance.rego import RegoEvaluator`
in _governance_bootstrap.py caused an ImportError during test collection
when the installed uipath-runtime predates the rego submodule.

Guard it with TYPE_CHECKING (annotations are strings via
`from __future__ import annotations`) so it's only evaluated by type
checkers, not at runtime.

Add three tests covering the previously-uncovered Rego bootstrap path
in resolve_governance (is_rego_enabled → build_rego_evaluator_async:
success, returns None, raises). Also update the wrap_runtime test to
patch UiPathGovernedRuntime with a forward-compatible subclass so the
test is not gated on the dependency version.

Generated with Claude Code

Co-Authored-By: Claude <noreply@anthropic.com>
@sonarqubecloud

Copy link
Copy Markdown

This branch has not been deployed

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

Labels

build:dev Create a dev build from the pr test:uipath-integrations test:uipath-langchain Triggers tests in the uipath-langchain-python repository test:uipath-runtime

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant