# L2 — 策略引擎 OPA

## 设计

* **链上**：`PolicyRegistry` 存 policyHash + 元数据
* **链下**：`baby-opa-policy` Rust crate (mini-Rego evaluator) 评估 policy against BehaviorSpec context
* **绑定**：`PoBRegistry.submitBatchWithPolicy()` 强制 batch.policyHash 等于 PoBRegistry.configuredPolicyHash

## 真链 e2e (chain 391)

3 case 全绿：

* **Compliant**: 满足 EU AI Act 5 项要求 → allow
* **Denied**: 缺少 human\_oversight → deny
* **NonCompliant**: 触发 prohibited\_practice (social\_scoring) → deny

详见：[PolicyRegistry 确权](/registries-que-quan/policy-registry.md) + [Rego 算法](/algorithms/opa-rego-policy-evaluation.md) + [EU AI Act 模板](/protocol-mechanics/regulatory-anchor.md) + [L2 OPA SDK e2e devlog](https://github.com/leeleeEcho/babyDriver_Layer2/blob/main/docs/devlog/2026-Q2/2026-04-30-DAY-SUMMARY.md)。


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://yellowpaper.axblade.io/protocol-mechanics/policy-engine-opa.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
