Commit afcf7a5
feat(core): add get_policy_async to GovernancePolicyProvider protocol
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>1 parent 651a7dd commit afcf7a5
2 files changed
Lines changed: 45 additions & 2 deletions
File tree
- packages/uipath-core
- src/uipath/core/governance
- tests/governance
Lines changed: 22 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
135 | 135 | | |
136 | 136 | | |
137 | 137 | | |
138 | | - | |
139 | | - | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
140 | 149 | | |
141 | 150 | | |
142 | 151 | | |
143 | 152 | | |
144 | 153 | | |
145 | 154 | | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
| 163 | + | |
| 164 | + | |
| 165 | + | |
146 | 166 | | |
147 | 167 | | |
148 | 168 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
18 | 18 | | |
19 | 19 | | |
20 | 20 | | |
| 21 | + | |
21 | 22 | | |
22 | 23 | | |
23 | 24 | | |
24 | 25 | | |
25 | 26 | | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
26 | 31 | | |
27 | 32 | | |
28 | 33 | | |
| |||
141 | 146 | | |
142 | 147 | | |
143 | 148 | | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
| 163 | + | |
| 164 | + | |
| 165 | + | |
| 166 | + | |
144 | 167 | | |
145 | 168 | | |
146 | 169 | | |
| |||
0 commit comments