refactor(governance): deprecate is_governance_enabled, drop CLI caller#1793
refactor(governance): deprecate is_governance_enabled, drop CLI caller#1793viswa-uipath wants to merge 1 commit into
Conversation
There was a problem hiding this comment.
Pull request overview
This PR removes the is_governance_enabled() feature-flag gate from uipath-core and stops the CLI governance bootstrap (resolve_governance) from short-circuiting based on that flag, relying instead on backend policy responses and existing error-handling to keep governance optional.
Changes:
- Deleted
is_governance_enabled()fromuipath-coregovernance config and removed it from package exports/tests. - Removed the
is_governance_enabledimport and early-return gate fromuipathCLI governance bootstrap. - Updated CLI tests to no longer monkeypatch the feature-flag gate.
Reviewed changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| packages/uipath/tests/cli/test_governance_bootstrap.py | Removes tests/stubs that depended on the feature-flag gate in CLI bootstrap. |
| packages/uipath/src/uipath/_cli/_governance_bootstrap.py | Removes the feature-flag short-circuit so governance resolution proceeds to backend policy fetch. |
| packages/uipath-core/tests/governance/test_config.py | Removes tests for is_governance_enabled() and keeps only the constant stability check. |
| packages/uipath-core/src/uipath/core/governance/config.py | Removes the gate function and leaves only GOVERNANCE_FEATURE_FLAG. |
| packages/uipath-core/src/uipath/core/governance/init.py | Stops exporting is_governance_enabled from the public governance surface. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
The CLI run/debug bootstrap no longer gates on the `EnablePythonGovernanceChecker` flag; `resolve_governance` always fetches policy and lets the backend-supplied enforcement mode decide. `is_governance_enabled()` is kept for backward compatibility — external agents may still gate their own evaluator wiring on the flag — but now emits a DeprecationWarning and reads the flag exactly as before. It will be removed in a future major release. Only the CLI caller (the `if not is_governance_enabled(): return None` gate) is removed. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
946db81 to
aa321af
Compare
🚨 Heads up:
|
|
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 4 out of 4 changed files in this pull request and generated 1 comment.
Comments suppressed due to low confidence (1)
packages/uipath/src/uipath/_cli/_governance_bootstrap.py:103
- The
try/exceptwrapsUiPath()construction and provider setup as well as the actualget_policy_asynccall, so exceptions from SDK/provider initialization will be reported as a “policy fetch failed”. That message is misleading now that this code path always runs; consider making the message cover bootstrap/setup failures (or narrowing thetryto only the fetch).
try:
sdk = UiPath()
provider = UiPathPlatformGovernanceProvider(service=sdk.governance)
response = await provider.get_policy_async(context)
except Exception as exc:
console.warning(
f"Governance policy fetch failed - continuing without governance: {exc}"
)
return None
| with pytest.warns(DeprecationWarning): | ||
| is_governance_enabled() | ||
|
|



Summary
The CLI
run/debuggovernance bootstrap no longer gates on theEnablePythonGovernanceCheckerfeature flag.resolve_governancealways fetches policy and lets the backend-supplied enforcement mode decide whether governance runs.is_governance_enabled()is a released public symbol (uipath-core0.5.18, tagv2.11.0) and external agents may still gate their own evaluator wiring on the flag, so it is kept for backward compatibility rather than removed:uipath-core:is_governance_enabled()now emits aDeprecationWarningbut otherwise reads the flag exactly as before (same resolution order, same off-by-default behavior). Export and signature are unchanged. It will be removed in a future major release.uipath: removed theis_governance_enabledimport and theif not is_governance_enabled(): return Nonegate at the top ofresolve_governancein_cli/_governance_bootstrap.py— the only in-SDK caller.Why deprecate instead of hardcoding
return FalseHardcoding
return Falsewould silently break external callers that gate on the flag — they'd skip governance even when the operator setUIPATH_FEATURE_EnablePythonGovernanceChecker=true. A silent behavior change is worse than a loud one. Keeping the original flag-reading behavior preserves correct semantics; the warning signals the migration path.Testing
packages/uipath-core:pytest tests/governance/test_config.py— 6 passed (existing behavior tests now assert theDeprecationWarning; added a dedicated deprecation test)packages/uipath:pytest tests/cli/test_governance_bootstrap.py— 16 passed🤖 Generated with Claude Code