Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ description = "Runtime abstractions and interfaces for building agents and autom
readme = { file = "README.md", content-type = "text/markdown" }
requires-python = ">=3.11"
dependencies = [
"uipath-core>=0.5.22, <0.6.0",
"uipath-core>=0.5.25, <0.6.0",
"pyyaml>=6.0, <7.0",
"vaderSentiment>=3.3.2, <4.0",
"chardet>=5.2.0, <8.0",
Expand Down
45 changes: 45 additions & 0 deletions src/uipath/runtime/governance/native/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
"""Native UiPath governance policy evaluator.

YAML-defined rules evaluated in-process at each agent lifecycle hook.
The host fetches the policy pack via the
:class:`GovernancePolicyProvider` protocol and compiles it into a
:class:`PolicyIndex` with :func:`build_policy_index_from_yaml` *before*
constructing :class:`GovernanceRuntime` — so the runtime layer never
performs I/O at construction time.

This subpackage owns:

- :class:`GovernanceEvaluator` – the evaluator implementation.
- :func:`build_policy_index_from_yaml` – pure YAML → :class:`PolicyIndex`
compiler.
- The native policy model: :class:`Rule`, :class:`Check`,
:class:`Condition`, :class:`PolicyIndex`.

Shared output types (``Action``, ``AuditRecord``, …) live in
:mod:`uipath.core.governance`.
"""

from ._yaml_to_index import build_policy_index_from_yaml
from .evaluator import GovernanceEvaluator
from .models import (
Check,
CheckContext,
Condition,
PolicyIndex,
PolicyPack,
Rule,
Severity,
)

__all__ = [
"GovernanceEvaluator",
"build_policy_index_from_yaml",
# Native policy model
"Check",
"CheckContext",
"Condition",
"PolicyIndex",
"PolicyPack",
"Rule",
"Severity",
]
26 changes: 11 additions & 15 deletions src/uipath/runtime/governance/native/_yaml_to_index.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
"""Runtime YAML → PolicyIndex parser.

Mirrors the shape produced by ``packs/compile_packs.py`` but builds the
PolicyIndex directly from parsed YAML data rather than generating Python
source. Used by :mod:`uipath.runtime.governance.native.loader` to
compile the YAML body returned by the registered policy provider into
an in-memory index at startup.
Builds a :class:`PolicyIndex` directly from parsed YAML data. The host
calls this to compile the YAML body returned by
:meth:`GovernancePolicyProvider.get_policy_async` into an in-memory
index, then hands the index to :class:`GovernanceRuntime`.

Accepts either a single YAML document (one pack) or a multi-document
stream (``---``-separated packs). Unknown check types and malformed
Expand Down Expand Up @@ -208,12 +207,9 @@ def _build_check(
) -> Check | None:
"""Build one Check from a YAML check entry.

Supports the same check types as ``compile_packs.py``: explicit
conditions, regex, budget, tool_allowlist, parameter_validation,
rate_limit, field_regex, sentiment_concern, data_quality_score,
incident_taxonomy, commitment_extractor, plus ``guardrail_fallback``
(reads the rule-level ``mapped_to_uipath`` / ``policy_enabled`` flags
threaded in from ``_build_rule``).
The ``guardrail_fallback`` branch reads the rule-level
``mapped_to_uipath`` / ``policy_enabled`` flags threaded in from
:func:`_build_rule`. Unknown check types are skipped.
"""
conditions: list[Condition] = []
message = ""
Expand Down Expand Up @@ -383,10 +379,10 @@ def _build_check(
# Centralized guardrail compensating control. The on/off state
# lives at the RULE level (mapped_to_uipath / policy_enabled),
# threaded in from ``_build_rule``; ``validator`` names which
# guardrail check the server should run on behalf of the agent.
# The condition matches only when the guardrail is mapped to
# UiPath but disabled — see the ``guardrail_fallback`` operator
# in :class:`GovernanceEvaluator`.
# guardrail check the compensating call should run. The
# condition matches only when the guardrail is mapped to UiPath
# but disabled — see the ``guardrail_fallback`` operator in
# :class:`GovernanceEvaluator`.
conditions.append(
Condition(
operator="guardrail_fallback",
Expand Down
Loading
Loading