Design discussion: OPA policy integration for agent model and tool calls
メンテナーはふだん 1 日以内に返信
まだ誰も着手していません。
評価
- 難易度
- 5/5
- 見積もり時間
- 1週間以上
- 初心者へのやさしさ
- 8/100
- issue の種類
- 機能追加
- 明瞭さ
- 説明が足りない
- 活発さ
- 活発
- 技術スタック
- go, kubernetes
調査の方向性
This is a design proposal, not a task: it asks for agreement on the input and decision format between Tapas and the rules, and lists five open questions for a meeting. Read the boundary section and the questions, and note that Tapas's own authorization lives in internal/authz, which the rules may not override. There is no code change to start from yet, so wait for the discussion to settle before picking up any part of it.
索引モデルが issue の本文から書いたものです。
説明
This is a starting point for discussing how Open Policy Agent fits into Tapas for the Intelligence Hub. It covers the shape of the system and where the boundaries sit, not how to build it. Everything here is a proposal.
What we want
Every action an agent takes gets checked against company rules before it happens. Rules are written in Rego, live in git, and can be changed without redeploying Tapas. A rule can allow an action, block it with a plain-English reason, or hold it until a person approves the exact action. Every decision is recorded.
Two kinds of agent traffic need checking:
- Model calls: what an agent sends to a model. Example rule: no US Social Security numbers go to an outside AI vendor.
- Tool calls: what an agent asks a connector (Slack, Gmail, Greenhouse, Frames) to do. Example rules: only the recruiting group can read from Greenhouse; sending email needs the owner's approval.
The shape
flowchart LR
client["Claude / Codex / Collab<br/>(person's laptop)"]
subgraph cluster["Nebari cluster"]
subgraph tapas["Tapas gateway"]
mg["Model gateway"]
tg["Tool gateway"]
mcp["MCP endpoint<br/>(for outside clients)"]
opa[("OPA<br/>embedded")]
log[("Decision log")]
plans["Approvals<br/>(plans)"]
end
agent["Agent pod<br/>(holds no credentials)"]
rules["Rules ConfigMap"]
lsp["llm-serving-pack"]
frames["Frames, our own connectors"]
end
gitops[("GitOps repo<br/>rules/")]
vendors["Vendor MCP servers<br/>Slack, Notion, HubSpot, Greenhouse"]
models["AI vendors and<br/>self-hosted models"]
client -- MCP --> mcp
mcp --> agent
agent -- model calls --> mg
agent -- tool calls --> tg
mg --> lsp --> models
tg --> vendors
tg --> frames
mg & tg & mcp -. ask .-> opa
opa -.-> log
tg -- needs approval --> plans
gitops -- ArgoCD --> rules -- mounted, reloaded --> opa
- Tapas is the only way out for an agent. Model calls and tool calls both go through the gateway. Agents never hold a model key, a vendor token or a Keycloak token, so they can't go around it.
- OPA runs inside Tapas as a library, not as a separate service. Nothing extra to deploy, no "OPA is down" case. Another hub component that wants the same rules can run its own OPA on the same rules.
- Rules come from the GitOps repo. ArgoCD syncs them into a ConfigMap mounted into the gateway, and Tapas reloads them when the mount changes. A merged PR is live in about a minute.
Where checks happen
| Checkpoint | What is checked | Possible outcomes |
|---|---|---|
| Model request | the prompt an agent sends to a model | allow, deny |
| Model response | the answer coming back | see open questions |
| Tool call | which connector and tool, with what arguments | allow, deny, needs approval |
| Tool result | what a connector returns to the agent | allow, deny |
| MCP response | what Tapas returns to an outside client such as Claude desktop (that content goes to the client's vendor) | allow, deny |
| Memory write | what would be stored in a person's memory (mem0) | allow, deny |
Every checkpoint asks OPA the same kind of question, so one rule can apply across several checkpoints ("no SSNs leave for an outside vendor" covers model requests, MCP responses and memory writes).
The boundary between Tapas and the rules
This is the part we need to agree on first, since it lets the two sides be built in parallel.
flowchart LR
subgraph tapasSide["Tapas (Amit)"]
collect["Gather who, where, what"]
detect["Detectors<br/>(SSN, card numbers, secrets)"]
enforce["Enforce the decision<br/>block / forward / hold"]
end
subgraph rulesSide["Rules (Chuck)"]
lib["Shared Rego library"]
rego["Company rules<br/>with plain-English titles"]
end
collect --> input["Input document"]
detect --> input
input --> rego
lib --> rego
rego --> decision["Decision"]
decision --> enforce
What Tapas sends (the input). One document per check, the same shape at every checkpoint:
- who: the agent's owner and their groups; later, the person talking to the agent if that's someone else
- which agent: the agent and its template, and whether it's a scheduled run
- where: the checkpoint, and the destination (which model, or which connector and tool)
- what: the content (messages, tool arguments or results), normalized so a rule never cares whether the request was in OpenAI or Anthropic format
- findings: what the detectors spotted and where
What comes back (the decision). Allow, deny, or needs approval, with the title and message of each rule that fired, and the revision of the rules that decided.
Ground rules on each side:
- Detectors find things; rules decide. A detector never blocks anything on its own.
- Every rule carries a plain-English title and description in Rego's
# METADATA. The UI shows them as the rule list, and the same text is the message a person sees when a rule blocks them. CI fails a rule without them. - Rules write into two namespaces: one for the rules from git, and one kept empty for rules admins will later edit in a Tapas UI. Tapas collects decisions from both.
- If rules can't be loaded or evaluated, Tapas refuses the call. It fails closed.
- OPA only restricts. Who may use an app or template is still decided by Tapas's own authorization (
internal/authz), and a rule can't grant what that refuses.
How a rule goes live
sequenceDiagram
participant Dev as Rule author
participant Git as GitOps repo
participant CI as CI
participant Argo as ArgoCD
participant Tapas as Tapas gateway
Dev->>Git: PR adds or edits a rule
Git->>CI: opa test, METADATA check
CI-->>Git: pass
Dev->>Git: merge
Git->>Argo: sync
Argo->>Tapas: ConfigMap updated, mount changes
Tapas->>Tapas: reload rules (keep the old ones if the new ones fail)
Note over Tapas: decisions now carry the new revision
How a held tool call works
sequenceDiagram
participant Agent
participant Tapas as Tapas tool gateway
participant OPA
participant Owner as Agent's owner (browser)
participant Gmail as Connector
Agent->>Tapas: send this email
Tapas->>OPA: input (tool call)
OPA-->>Tapas: needs approval: "Email sends need a person's OK"
Tapas-->>Agent: pending, id X
Owner->>Tapas: approve X
Tapas->>Gmail: the exact stored call, once, as the owner
Agent->>Tapas: status of X?
Tapas-->>Agent: applied, with the result
The agent never makes the approved call itself, so nothing can change between approval and sending. This builds on the propose-and-approve flow Tapas already has for its own actions.
Who owns what
| Area | Owner |
|---|---|
| The input and decision format, the rule namespaces | Amit and Chuck, together, first |
| Calling OPA at each checkpoint and enforcing the decision; reloading rules; the decision log; the rule list and decision APIs; holding and applying approved tool calls | Amit (Tapas) |
| The Rego library, the default rules and their tests, CI in the GitOps repo, the rules ConfigMap | Chuck |
| Detectors (a self-contained package in Tapas) | Chuck |
| Screens for the rule list, the decision log and approvals | Johnny and Nat |
Not in the first version
- Rewriting content (redaction). A matching rule blocks.
- Filtering parts of a tool result.
- Approvers other than the agent's owner.
- Editing rules in the Tapas UI (the second namespace is kept for it).
Questions for the meeting
- Should a rule be able to block a model's answer, or only log it? Answers stream, so blocking means holding the whole answer or cutting the stream partway.
- Rules check the owner's groups, and Tapas only refreshes those when the person signs in. Do we refresh them from Keycloak when an agent acts on the person's behalf, so rules see current groups?
- How do we test the boundary? One idea: a shared set of example input documents that Tapas's tests produce and the Rego tests consume, so neither side drifts.
- Does the input above carry enough for the rules we expect in the first month? Anything that needs outside facts, such as time of day or spend so far?
- Does anything about OPA running inside Tapas worry you, compared with a separate OPA service?
- 主要言語
- Go
- スター
- 5
- フォーク
- 0
- 平均マージ
- 21時間 13分
- マージ済み PR(30日)
- 53
環境構築
- Dockerfile または Docker Compose ファイルあり
- プルリクエストのテンプレートなし
- コントリビューションガイドを読む
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
nebari-dev/tapas のほかの issue
-
難易度 2/5 1〜3時間 初心者へのやさしさ 82/100
nebari-dev/tapas#124 ·
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
nebari-dev/tapas#121 ·
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 84/100
nebari-dev/tapas#32 ·
メンテナーはふだん 1 日以内に返信
-
Suggest saving a memory when a chat message holds something worth remembering対応中かも @jbouder が今日担当しました。 オープン
難易度 5/5 1週間以上 初心者へのやさしさ 25/100
nebari-dev/tapas#137 ·
メンテナーはふだん 1 日以内に返信
-
難易度 4/5 3〜5日 初心者へのやさしさ 54/100
nebari-dev/tapas#136 ·
メンテナーはふだん 1 日以内に返信
nebari-dev/tapas の issue をすべて見る
似ている issue
-
area: pipeline priority: low type: bug
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 82/100
prime-radiant-inc/evener#8335 ·
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 74/100
-
ui: OnTextKey on SearchField never sees keys (it does not reach the inner input)対応中かも @szluyu99 が今日担当しました。 オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 76/100
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 76/100