# OPA Rego 策略评估

## Rego DSL

Open Policy Agent (OPA) 的官方 DSL，用于声明式策略评估。例：

```rego
package eu_ai_act_high_risk

default allow = false

allow if {
    has_human_oversight
    has_risk_mitigation_doc
    not violates_prohibited_practice
}
```

## 实现

`baby-modules/opa-policy/` — Rust crate, 包含 mini-Rego evaluator (W1-W4 开发完成)

不依赖完整 OPA WASM runtime（避免 5MB binary 包）。Sub-set Rego 足够覆盖 EU AI Act / NIST RMF 模板需求。

## 链上 vs 链下

* **链上**: PolicyRegistry 仅存 policyHash + contentURI
* **链下**: agent runtime 调 baby-opa-policy 评估
* **绑定**: PoBRegistry.submitBatchWithPolicy 强制 batch 引用 configured policyHash

详见 [PolicyRegistry 确权](/registries-que-quan/policy-registry.md) + [L2-W1\~W4 devlog](https://github.com/leeleeEcho/babyDriver_Layer2/blob/main/docs/devlog/2026-Q2/README.md) (4 周开发记录)。


---

# 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/algorithms/opa-rego-policy-evaluation.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.
