Commit ff7af18
feat: OPA/Rego and Cedar policy portability
Add pluggable policy backend support to both Agent OS and AgentMesh:
Agent OS (PolicyEvaluator):
- ExternalPolicyBackend protocol for pluggable backends
- OPABackend: remote OPA server, local opa CLI, built-in Rego evaluator
- CedarBackend: cedarpy bindings, cedar CLI, built-in permit/forbid parser
- load_rego() and load_cedar() convenience methods
- YAML rules checked first, then external backends in registration order
- Fail-closed on errors, audit entries include backend metadata
AgentMesh (PolicyEngine):
- CedarEvaluator mirroring existing OPAEvaluator pattern
- load_cedar() method on PolicyEngine
- Cedar evaluated after YAML and Rego, before defaults
- CedarDecision dataclass with evaluation_ms tracking
Both backends support three modes:
1. Embedded engine (cedarpy / opa CLI) - fastest
2. Remote server (OPA REST API)
3. Built-in fallback - zero external deps, common patterns only
Tests: 29 Agent OS + 21 AgentMesh = 50 new tests, all passing
Existing 39 policy tests unaffected
Also:
- Optional deps: pip install agent-governance-toolkit[cedar]
- README: OPA/Cedar usage examples
- Comparison doc: OPA/Cedar marked as shipped (was 'planned')
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>1 parent f8f6a1d commit ff7af18
File tree
11 files changed
+1841
-5
lines changed- packages
- agent-compliance
- agent-mesh
- src/agentmesh/governance
- tests
- agent-os
- docs
- src/agent_os/policies
- tests
11 files changed
+1841
-5
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
144 | 144 | | |
145 | 145 | | |
146 | 146 | | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
| 163 | + | |
| 164 | + | |
| 165 | + | |
| 166 | + | |
| 167 | + | |
| 168 | + | |
| 169 | + | |
| 170 | + | |
| 171 | + | |
| 172 | + | |
| 173 | + | |
| 174 | + | |
| 175 | + | |
| 176 | + | |
| 177 | + | |
| 178 | + | |
| 179 | + | |
| 180 | + | |
| 181 | + | |
| 182 | + | |
| 183 | + | |
| 184 | + | |
| 185 | + | |
| 186 | + | |
| 187 | + | |
| 188 | + | |
| 189 | + | |
| 190 | + | |
| 191 | + | |
| 192 | + | |
| 193 | + | |
| 194 | + | |
| 195 | + | |
| 196 | + | |
147 | 197 | | |
148 | 198 | | |
149 | 199 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
38 | 38 | | |
39 | 39 | | |
40 | 40 | | |
| 41 | + | |
| 42 | + | |
41 | 43 | | |
42 | 44 | | |
43 | 45 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
25 | 25 | | |
26 | 26 | | |
27 | 27 | | |
| 28 | + | |
28 | 29 | | |
29 | 30 | | |
30 | 31 | | |
| |||
64 | 65 | | |
65 | 66 | | |
66 | 67 | | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
67 | 71 | | |
68 | 72 | | |
69 | 73 | | |
| |||
0 commit comments