Design discussion: OPA policy integration for agent model and tool calls

Abierto
#14 0 comentarios 0 reacciones 0 asignados Ver en GitHub

Los mantenedores suelen responder en 1 día

Nadie ha tomado este issue todavía.

Evaluación

Dificultad
5/5
Tiempo estimado
Más de una semana
Aptitud para principiantes
8/100
Tipo de issue
Nueva funcionalidad
Claridad
Necesita aclaración
Estado de actividad
Activo
Stack tecnológico
go, kubernetes

Línea de trabajo

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.

Escrito por el modelo de indexación a partir del texto del issue.

Descripción

needs: discussion 💬 type: exploration 🔮

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

  1. 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.
  2. 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?
  3. 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.
  4. 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?
  5. Does anything about OPA running inside Tapas worry you, compared with a separate OPA service?
Lenguaje dominante
Go
Estrellas
5
Forks
0
Merge medio
21 h 13 min
PR fusionados (30 d)
53

Preparar el entorno

Primeros pasos

  1. Lee el issue completo y luego la guía de contribución del proyecto.
  2. Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
  3. Haz un fork del repositorio y trabaja en una rama.
  4. Abre un pull request que haga referencia al número del issue.

Más de nebari-dev/tapas

Todos los issues de nebari-dev/tapas

Issues similares

Más issues de Go

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.