Skip to content

refactor(governance): deprecate is_governance_enabled, drop CLI caller#1793

Open
viswa-uipath wants to merge 1 commit into
mainfrom
chore/remove-is-governance-enabled
Open

refactor(governance): deprecate is_governance_enabled, drop CLI caller#1793
viswa-uipath wants to merge 1 commit into
mainfrom
chore/remove-is-governance-enabled

Conversation

@viswa-uipath

@viswa-uipath viswa-uipath commented Jul 6, 2026

Copy link
Copy Markdown
Contributor

Summary

The CLI run / debug governance bootstrap no longer gates on the EnablePythonGovernanceChecker feature flag. resolve_governance always fetches policy and lets the backend-supplied enforcement mode decide whether governance runs.

is_governance_enabled() is a released public symbol (uipath-core 0.5.18, tag v2.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 a DeprecationWarning but 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 the is_governance_enabled import and the if not is_governance_enabled(): return None gate at the top of resolve_governance in _cli/_governance_bootstrap.py — the only in-SDK caller.

Why deprecate instead of hardcoding return False

Hardcoding return False would silently break external callers that gate on the flag — they'd skip governance even when the operator set UIPATH_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 the DeprecationWarning; added a dedicated deprecation test)
  • packages/uipath: pytest tests/cli/test_governance_bootstrap.py — 16 passed
  • Ruff lint + format clean on all changed files

🤖 Generated with Claude Code

Copilot AI review requested due to automatic review settings July 6, 2026 15:54
@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 6, 2026

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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() from uipath-core governance config and removed it from package exports/tests.
  • Removed the is_governance_enabled import and early-return gate from uipath CLI 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.

Comment thread packages/uipath-core/src/uipath/core/governance/config.py
Comment thread packages/uipath-core/tests/governance/test_config.py
Comment thread packages/uipath-core/src/uipath/core/governance/__init__.py
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>
@viswa-uipath viswa-uipath force-pushed the chore/remove-is-governance-enabled branch from 946db81 to aa321af Compare July 6, 2026 17:39
@viswa-uipath viswa-uipath changed the title refactor(governance): remove is_governance_enabled feature-flag gate refactor(governance): deprecate is_governance_enabled, drop CLI caller Jul 6, 2026
@github-actions

github-actions Bot commented Jul 6, 2026

Copy link
Copy Markdown

🚨 Heads up: uipath-integrations cross-tests are FAILING 🚨

Your changes may break one or more integrations in uipath-integrations-python:

  • uipath-openai-agents
  • uipath-google-adk
  • uipath-agent-framework
  • uipath-llamaindex
  • uipath-pydantic-ai

⚠️ These checks are NOT enforced by branch protection rules. Please review the failures before merging.

🔍 Inspect the failed run →

@sonarqubecloud

sonarqubecloud Bot commented Jul 6, 2026

Copy link
Copy Markdown

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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/except wraps UiPath() construction and provider setup as well as the actual get_policy_async call, 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 the try to 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

Comment on lines +34 to +36
with pytest.warns(DeprecationWarning):
is_governance_enabled()

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

Labels

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.

2 participants