How to Configure Haystack CockroachDB Permissions

Published
Length
3 min read

Luis Felipe Dias

All posts

You set up haystack cockroachdb permissions by creating a custom database role for your AI app. Then you grant that role read or write rules on specific tables and schemas. Many teams rush this step and give their pipeline full admin rights instead. Broad roles let one bad prompt or buggy script alter or delete production tables. Scoping roles down to exact tables keeps your core data safe during automated runs. How haystack cockroachdb permissions work in practice Haystack pipelines often ne

Your coding agents run with your access.

Claude Code reaches prod with a developer's credentials, and approval prompts get clicked through. hoop.dev checks every query, masks sensitive data, and holds risky changes for a human.

You set up haystack cockroachdb permissions by creating a custom database role for your AI app. Then you grant that role read or write rules on specific tables and schemas. Many teams rush this step and give their pipeline full admin rights instead. Broad roles let one bad prompt or buggy script alter or delete production tables. Scoping roles down to exact tables keeps your core data safe during automated runs.

How haystack cockroachdb permissions work in practice

Haystack pipelines often need a database to store text chunks, metadata, and chat history. CockroachDB handles these workloads well because it scales across nodes and uses standard SQL rules. To link the two tools, you first create a dedicated user role inside the database. You should never reuse a human admin account or a root key for an app.

CockroachDB uses role-based rules to control what each user account can do after login. You can group rules into a parent role and assign your app user to it. For a simple search pipeline, the app role only needs read rights on document tables. If the pipeline also indexes new files, the role needs insert and update rights too.

You can separate these duties by creating two distinct database roles for your AI workflows. One role runs the ingestion jobs and holds write rights on the target vector tables. The second role serves the query pipeline and holds read-only rights on those same tables. This split stops a user-facing query bot from changing or wiping out stored data.

Setting up secure logins and network rules

Role rules only work well when you pair them with strong login checks. CockroachDB supports client certificates and password logins over TLS to verify who is calling. Using client certificates is safer than putting static passwords into your app config files. Your ops team generates a certificate for the Haystack service and loads it at runtime.

You should also limit where the app can log in from at the network level. Set up IP allowlists in your database cluster so only your app servers can reach it. Even if a key leaks, an outside machine cannot open a session with the cluster. Rotate your database keys and certificates on a set schedule to reduce risk from old files.

AI Agent Permissions + End-to-End Encryption: architecture patterns and best practices

Continue reading? Get the full guide.

Free. No spam. Unsubscribe anytime.

Where native database roles fall short for AI apps

Native database roles do a great job of deciding who can log into the cluster. They also block a read-only role from running drop or delete commands on a table. Still, table rules are all-or-nothing once the session starts and a query runs.

If your Haystack app has read rights on a customer table, it can read every column. The database role does not rewrite sensitive fields like emails, phone numbers, or card numbers. A prompt injection or a loose retrieval step can pull raw national IDs into model context. Also, standard database logs often show the shared app user instead of the human who triggered the run. Teams need finer controls that inspect queries in flight and tie actions to real user identities.

Add runtime guardrails and masking beside your databases and APIs

Login rules, role grants, and CI checks govern who connects to your stack. Yet any allowed script, engineer, or AI agent still runs commands with the full scope of its role. For workloads on Postgres, MySQL, SQL Server, MongoDB, ClickHouse, Kubernetes, SSH, or internal HTTP services, hoop.dev sits beside the service as an open-source proxy, a sidecar for your database or API.

Before a query runs, hoop.dev guardrails check the statement against your rules. An AI Analyzer you configure can score intent or hold risky calls for human review. Next, hoop.dev data masking rewrites sensitive fields in responses, and each verdict is logged per listener. Explore the MIT-licensed project on GitHub.

Frequently asked questions

What minimum rights does a Haystack query pipeline need in CockroachDB?

A query pipeline only needs connect rights on the database and select rights on the target tables. It does not need rights to create tables, change schemas, or delete rows.

Should ingestion jobs and query pipelines share the same database role?

No, you should create separate roles for ingestion jobs and user-facing query pipelines. Give write rights only to the ingestion role, and keep the query role read-only.

Can native CockroachDB roles hide sensitive columns in query results?

Native roles can block a user from reading a table, but they do not mask values inside results. To rewrite emails or card numbers in flight, you need query inspection and data masking rules.

The query runs. The emails stay hidden.