refactor(core): drop AdapterRegistry + BaseAdapter; keep EvaluatorProtocol#1761
refactor(core): drop AdapterRegistry + BaseAdapter; keep EvaluatorProtocol#1761viswa-uipath wants to merge 1 commit into
Conversation
There was a problem hiding this comment.
Pull request overview
This PR removes the adapter-registry plumbing from uipath-core (adapter base class, registry singleton, and related tests) while preserving EvaluatorProtocol as the remaining contract for framework governance integrations. It also bumps uipath-core’s version and refreshes workspace lockfiles to reflect the new core version and updated uv lock metadata.
Changes:
- Deleted
BaseAdapter/AdapterRegistry/ singleton helpers (and their tests), leaving onlyEvaluatorProtocolunderuipath.core.adapters. - Updated
uipath.core.adapterspublic exports/documentation accordingly. - Bumped
uipath-coreto0.5.23and refresheduv.lockfiles across packages.
Reviewed changes
Copilot reviewed 6 out of 9 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| packages/uipath/uv.lock | Refresh lock metadata and update editable uipath-core version reference to 0.5.23. |
| packages/uipath-platform/uv.lock | Refresh lock metadata and update editable uipath-core version reference to 0.5.23. |
| packages/uipath-core/uv.lock | Update uipath-core package version entry to 0.5.23 in the lock. |
| packages/uipath-core/tests/adapters/test_registry.py | Remove tests for deleted adapter registry behavior. |
| packages/uipath-core/tests/adapters/test_base.py | Remove tests for deleted adapter base/proxy behavior. |
| packages/uipath-core/src/uipath/core/adapters/registry.py | Delete adapter registry + entry-point discovery implementation. |
| packages/uipath-core/src/uipath/core/adapters/base.py | Delete adapter base class and governed proxy base. |
| packages/uipath-core/src/uipath/core/adapters/init.py | Trim exports to only EvaluatorProtocol and update docstring. |
| packages/uipath-core/pyproject.toml | Bump package version from 0.5.22 to 0.5.23. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Unblocks architecture-review §2.4 on the uipath-runtime side. The prescription there is to hoist the policy fetch from the runtime-layer ``PolicyLoader`` (which today spins a daemon thread inside an async runtime and blocks on ``threading.Event.wait(timeout=10s)``) up to the async host: the CLI calls ``await provider.get_policy_async(ctx)`` itself, builds the ``PolicyIndex``, and passes the resolved index + mode into ``GovernanceRuntime``. The runtime collapses to a pure, synchronous-to-construct decorator — no thread, no Event, no ``is_conversational`` in the ctor. For that to type-check on the runtime side, the structural ``GovernancePolicyProvider`` Protocol in uipath-core needs to declare ``get_policy_async``. The concrete platform provider (``UiPathPlatformGovernanceProvider``) already implements it; the contract was just lying about what providers expose. Changes - ``GovernancePolicyProvider`` now declares both ``get_policy`` and ``async get_policy_async``. Both required (the platform impl ships both today, and the doc's recommended caller path is the async variant — sync stays for non-event-loop callers like integration tests and CLI tools). - ``_FakePolicyProvider`` in the conformance tests grew the async method and a separate ``async_calls`` recorder. - New ``test_policy_round_trip_async`` exercises the async path via ``@pytest.mark.asyncio`` and pins that the two entry points are independent (calling one doesn't touch the other's recorder). Verified - uipath-core: ruff clean, mypy clean (45 source files), 32 governance tests passed. - uipath-platform: protocol-conformance tests still pass (9 passed) — ``UiPathPlatformGovernanceProvider`` already exposed ``get_policy_async``, so the now-stricter protocol still accepts it structurally. No version bump — rides on the unreleased 0.5.23 that already carries PR #1761's §1.1 (adapter-registry deletion) and §1.2 (typed EvaluatorProtocol returns). Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
🚨 Heads up:
|
cb498ce to
903c35b
Compare
Unblocks architecture-review §2.4 on the uipath-runtime side. The prescription there is to hoist the policy fetch from the runtime-layer ``PolicyLoader`` (which today spins a daemon thread inside an async runtime and blocks on ``threading.Event.wait(timeout=10s)``) up to the async host: the CLI calls ``await provider.get_policy_async(ctx)`` itself, builds the ``PolicyIndex``, and passes the resolved index + mode into ``GovernanceRuntime``. The runtime collapses to a pure, synchronous-to-construct decorator — no thread, no Event, no ``is_conversational`` in the ctor. For that to type-check on the runtime side, the structural ``GovernancePolicyProvider`` Protocol in uipath-core needs to declare ``get_policy_async``. The concrete platform provider (``UiPathPlatformGovernanceProvider``) already implements it; the contract was just lying about what providers expose. Changes - ``GovernancePolicyProvider`` now declares both ``get_policy`` and ``async get_policy_async``. Both required (the platform impl ships both today, and the doc's recommended caller path is the async variant — sync stays for non-event-loop callers like integration tests and CLI tools). - ``_FakePolicyProvider`` in the conformance tests grew the async method and a separate ``async_calls`` recorder. - New ``test_policy_round_trip_async`` exercises the async path via ``@pytest.mark.asyncio`` and pins that the two entry points are independent (calling one doesn't touch the other's recorder). Verified - uipath-core: ruff clean, mypy clean (45 source files), 32 governance tests passed. - uipath-platform: protocol-conformance tests still pass (9 passed) — ``UiPathPlatformGovernanceProvider`` already exposed ``get_policy_async``, so the now-stricter protocol still accepts it structurally. No version bump — rides on the unreleased 0.5.23 that already carries PR #1761's §1.1 (adapter-registry deletion) and §1.2 (typed EvaluatorProtocol returns). Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
61acf18 to
296d587
Compare
…tocol Delete the AdapterRegistry / BaseAdapter / GovernedAgentBase plumbing from uipath-core plus the uipath.governance.adapters entry-point group and the get_adapter_registry / reset_adapter_registry helpers. Keep EvaluatorProtocol — the one contract framework plugins still consume. The adapter registry was a second plugin-discovery system keyed on the same fact (which framework is active) that UiPathRuntimeFactoryRegistry already resolves statically. It existed to support an open-PR pattern where the runtime layer would sniff the framework off an opaque agent; that approach is being abandoned in favor of framework plugins wiring governance at their own native seam, so the registry becomes dead weight. Grep across the monorepo confirms zero remaining consumers outside the deleted files. Companion changes landing in the same PR ---------------------------------------- - EvaluatorProtocol returns are typed as AuditRecord (was an untyped list); the trace_id field is dropped from AuditRecord and the protocol since per-evaluation trace ids aren't part of the contract. - GovernancePolicyProvider grows get_policy_async so async hosts can fetch the policy pack without thread-pool offloading. - GovernanceService self-resolves the compensation trace_id when the caller leaves it empty (same fallback chain track_event uses). Lets the runtime layer stay env-free; new tests cover both fill and no-source branches. Version bumps and pins ---------------------- - uipath-core 0.5.22 → 0.5.24 - uipath-platform 0.1.7x → 0.1.79; pin raised to uipath-core>=0.5.24 - uipath is unchanged (no source-level edits in this PR); its uv.lock refreshes only to pick up the bumped uipath-core / uipath-platform versions Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
296d587 to
c1ae046
Compare
|
Rebase of the guardrail-compensation series onto feat/governance-audit's
tip. Brings up the native governance layer in one squash:
- In-runtime policy evaluator (native/evaluator.py): rule + check +
condition matching with VADER sentiment / chardet / regex / entropy
/ incident / commitment operators. Honors per-check action overrides
and cross-rule aggregation. Instance-scoped with explicit deps
(AuditManager + GuardrailCompensator) injected by the host.
- Native package exports (native/__init__.py): build_policy_index_from_yaml
+ GovernanceEvaluator + GuardrailCompensator + CheckContext + PolicyIndex.
- GuardrailCompensator (native/guardrail_compensation.py): bounded
ThreadPoolExecutor + BoundedSemaphore per runtime, contextvars
propagation, weakref-tracked process-level atexit. Delegates HTTP /
auth / URL / trace correlation to the injected
GovernanceCompensationProvider.
- Drop PolicyLoader: host fetches policy asynchronously via
GovernancePolicyProvider and hands the resolved PolicyIndex to
UiPathGovernedRuntime at construction.
- Trace correlation: AuditEvent / AuditRecord no longer carry trace_id;
OTel-backed sinks resolve from the live span via the
AuditManager's captured contextvars snapshot.
- testpypi dev pin (pyproject.toml): uipath-core
0.5.24.dev1017610000..0.5.24.dev1017620000 from PR
UiPath/uipath-python#1761 (AdapterRegistry deletion +
AuditRecord.trace_id field drop).
Tests: 346 passed + 1 skipped, ruff + mypy clean.
Pre-rebase tip preserved at backup-guardrail-pre-audit-rebase-2026-06-28
for reference.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Rebase of the guardrail-compensation series onto feat/governance-audit's
tip. Brings up the native governance layer in one squash:
- In-runtime policy evaluator (native/evaluator.py): rule + check +
condition matching with VADER sentiment / chardet / regex / entropy
/ incident / commitment operators. Honors per-check action overrides
and cross-rule aggregation. Instance-scoped with explicit deps
(AuditManager + GuardrailCompensator) injected by the host.
- Native package exports (native/__init__.py): build_policy_index_from_yaml
+ GovernanceEvaluator + GuardrailCompensator + CheckContext + PolicyIndex.
- GuardrailCompensator (native/guardrail_compensation.py): bounded
ThreadPoolExecutor + BoundedSemaphore per runtime, contextvars
propagation, weakref-tracked process-level atexit. Delegates HTTP /
auth / URL / trace correlation to the injected
GovernanceCompensationProvider.
- Drop PolicyLoader: host fetches policy asynchronously via
GovernancePolicyProvider and hands the resolved PolicyIndex to
UiPathGovernedRuntime at construction.
- Trace correlation: AuditEvent / AuditRecord no longer carry trace_id;
OTel-backed sinks resolve from the live span via the
AuditManager's captured contextvars snapshot.
- testpypi dev pin (local dev only): uipath-core + uipath-platform
pinned to the testpypi dev builds from PR
UiPath/uipath-python#1761 (AdapterRegistry deletion +
AuditRecord.trace_id field drop) via ``[tool.uv]
override-dependencies`` + ``[tool.uv.sources]``. The wheel-baked
``[project.dependencies]`` constraint stays at the canonical
``uipath-core>=0.5.22,<0.6.0`` so consumer workspaces that don't
configure testpypi (notably uipath-python's CI matrix) resolve
cleanly against published versions.
Tests: 346 passed + 1 skipped, ruff + mypy clean.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>



Summary
AdapterRegistry/BaseAdapter/GovernedAgentBaseplumbing fromuipath-core, plus theuipath.governance.adaptersentry-point group andget_adapter_registry/reset_adapter_registryhelpersEvaluatorProtocol— the one contract framework plugins still consumeuipath-coreto0.5.23and refresh the threeuv.lockfilesWhy
The adapter registry was a second plugin-discovery system keyed on the same fact (which framework is active) that
UiPathRuntimeFactoryRegistryalready resolves statically. It existed to support an open-PR pattern where the runtime layer would sniff the framework off an opaque agent — that approach is being abandoned in favor of framework plugins wiring governance at their own native seam (callback handlers / hook lists), so the registry becomes dead weight.The only known external consumer is the unmerged
uipath-langchainPR #899, which is being reshaped to consumeEvaluatorProtocoldirectly through its factory. A grep across the monorepo (.py/.toml/.md/.rst/.json) forAdapterRegistry/BaseAdapter/GovernedAgentBase/get_adapter_registry/reset_adapter_registryreturns zero hits outside the deleted files.Changes
packages/uipath-core/src/uipath/core/adapters/base.pypackages/uipath-core/src/uipath/core/adapters/registry.pypackages/uipath-core/tests/adapters/test_base.pypackages/uipath-core/tests/adapters/test_registry.pypackages/uipath-core/src/uipath/core/adapters/__init__.py— exports trimmed toEvaluatorProtocolpackages/uipath-core/pyproject.toml—0.5.22 → 0.5.23uv.lockfiles for the workspaceNet diff: −962 LOC.
Test plan
uv run ruff check src/ tests/— cleanuv run mypy src/— clean (45 source files)uv run pytest— 230 passed, 1 skipped inuipath-coreuipath/uipath-platformpackagesuipath-langchainPR chore: validate required files on push #899 reshape (see below)Coordination
Downstream
uipath-runtime-pythonanduipath-langchain-pythonare not yet merged, so no shipped consumer breaks. Merge order if this lands first:uipath-runtime-pythonadds optionalevaluatorkwarg to the factory protocol — pendinguipath-langchain-pythonPR chore: validate required files on push #899 reshaped to factory-drivenGovernanceCallbackHandlerwiring (and to subclasslangchain_core.callbacks.BaseCallbackHandlerproperly) — pending🤖 Generated with Claude Code
Development Packages
uipath
uipath-core
uipath-platform