Commit d3dc020
authored
feat(pip): add PolicyClient for RFC-005 PDP integration (Option B) (#10)
* feat(pip): add PolicyClient for RFC-005 PDP integration via gRPC
Option B architecture: delegates all PDP decision logic to Go core's
EvaluatePolicyDecision RPC. Python SDK handles obligation execution
(context-dependent) and response propagation.
New files:
- capiscio_mcp/pip.py: PolicyClient, PIPConfig, PolicyResult, Obligation
- PolicyClient.evaluate() builds request, calls gRPC, parses response
- PolicyResult.execute_obligations() dispatches to registered handlers
- PolicyResult.allowed/denied/pdp_error convenience properties
- tests/test_pip.py: 23 tests covering:
- PolicyResult properties (allowed/denied/pdp_error)
- Obligation dataclass and execution
- PIPConfig defaults and custom values
- PolicyClient gRPC integration (mock): allow, deny, observe, cache,
break-glass, obligations, bad JSON, request field fidelity
Proto updates:
- Regenerated gen/ stubs from capiscio-core feature/rfc005-pdp-rpc proto
(adds EvaluatePolicyDecision RPC + 6 new message types)
- Updated hand-written stubs with matching dataclasses for IDE support
* fix: align proto with capiscio-core breakglass_public_key (bytes)
- Regenerated proto stubs from capiscio-core main (PR #43 merged)
- PolicyConfig.breakglass_public_key_path (string) → breakglass_public_key (bytes)
- Updated PIPConfig, PolicyClient.evaluate(), and tests
- Fixed regenerated grpc stub import path
* fix: address PR review comments
- Remove Obligation.id (MCPObligation proto has no id field)
- Validate json.loads returns dict before using as params
- Downgrade grpcio version check from RuntimeError to RuntimeWarning
- Update tests to match proto shape (no id field on obligations)1 parent c8f65fa commit d3dc020
6 files changed
Lines changed: 909 additions & 43 deletions
File tree
- capiscio_mcp
- _proto
- capiscio/v1
- gen/capiscio/v1
- tests
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
177 | 177 | | |
178 | 178 | | |
179 | 179 | | |
| 180 | + | |
| 181 | + | |
| 182 | + | |
| 183 | + | |
| 184 | + | |
| 185 | + | |
| 186 | + | |
| 187 | + | |
| 188 | + | |
| 189 | + | |
| 190 | + | |
| 191 | + | |
| 192 | + | |
| 193 | + | |
| 194 | + | |
| 195 | + | |
| 196 | + | |
| 197 | + | |
| 198 | + | |
| 199 | + | |
| 200 | + | |
| 201 | + | |
| 202 | + | |
| 203 | + | |
| 204 | + | |
| 205 | + | |
| 206 | + | |
| 207 | + | |
| 208 | + | |
| 209 | + | |
| 210 | + | |
| 211 | + | |
| 212 | + | |
| 213 | + | |
| 214 | + | |
| 215 | + | |
| 216 | + | |
| 217 | + | |
| 218 | + | |
| 219 | + | |
| 220 | + | |
| 221 | + | |
| 222 | + | |
| 223 | + | |
| 224 | + | |
| 225 | + | |
| 226 | + | |
| 227 | + | |
| 228 | + | |
| 229 | + | |
| 230 | + | |
| 231 | + | |
| 232 | + | |
| 233 | + | |
| 234 | + | |
| 235 | + | |
| 236 | + | |
| 237 | + | |
| 238 | + | |
| 239 | + | |
| 240 | + | |
| 241 | + | |
| 242 | + | |
| 243 | + | |
| 244 | + | |
| 245 | + | |
| 246 | + | |
| 247 | + | |
| 248 | + | |
| 249 | + | |
| 250 | + | |
| 251 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
44 | 44 | | |
45 | 45 | | |
46 | 46 | | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
47 | 59 | | |
48 | 60 | | |
49 | 61 | | |
| |||
87 | 99 | | |
88 | 100 | | |
89 | 101 | | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
90 | 110 | | |
91 | 111 | | |
92 | 112 | | |
| |||
0 commit comments