How to Configure Haystack CockroachDB Read Only Access

Published
Length
3 min read

Luis Felipe Dias

All posts

You set up haystack cockroachdb read only access by creating a restricted database role. Then you pass that role into your Haystack retriever pipeline. Many engineering teams start by sharing a default admin account during early testing. If a model generates a bad query, broad permissions allow unintended data changes. A dedicated read role stops the pipeline from writing or deleting records. How to set up haystack cockroachdb read only access First, an admin creates a new user role inside th

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 read only access by creating a restricted database role. Then you pass that role into your Haystack retriever pipeline. Many engineering teams start by sharing a default admin account during early testing. If a model generates a bad query, broad permissions allow unintended data changes. A dedicated read role stops the pipeline from writing or deleting records.

How to set up haystack cockroachdb read only access

First, an admin creates a new user role inside the CockroachDB cluster. The admin grants only the select privilege on the target tables and schemas. Next, the team revokes any default write permissions on public schemas. The admin also checks default privileges for any future tables created later.

On the AI side, Haystack uses document stores and query components to fetch context. Engineers store the read role credentials in a secret manager. When the Haystack pipeline starts, the database component loads those credentials to log in. Every SQL query that the pipeline runs now inherits the database role limits. If the pipeline sends an insert or drop statement, the database rejects it.

What native read roles solve and where gaps remain

Database roles are the right foundation for securing AI pipelines. They stop accidental table drops and block unauthorized writes at the storage engine. They also help teams separate human user traffic from automated bot queries.

Still, static database roles only decide who can log in to the cluster. They do not inspect what individual queries return in flight. A read role still reads every column in an allowed table by default. If that table holds emails, phone numbers, or card numbers, the query fetches them. The raw text then flows directly into the language model prompt.

Static credentials also create key rotation work for the platform team. Every Haystack worker needs the database password stored in its local environment. Also, native database logs only show the shared service account name. When ten different pipelines share one read role, teams cannot trace specific requests. You also cannot require a quick human check before a heavy query runs.

Auditor Read-Only Access + Customer Support Access to Production: architecture patterns and best practices

Continue reading? Get the full guide.

Free. No spam. Unsubscribe anytime.

Why query-level controls matter for AI retrieval

AI pipelines behave differently than standard backend services. A traditional app runs fixed query templates written by developers. A Haystack agent can build dynamic SQL queries based on user prompts. Even with read permissions, a bad query can scan millions of rows. It can also pull national IDs or card numbers from customer tables.

To keep live data safe, teams need controls that operate on each query. Masking rules can rewrite emails and phone numbers in query results before delivery. Row limits and approval checks can stop huge table scans before they start. Tying each pipeline run to a clear identity makes auditing simple and fast.

Check database and API queries on the wire

Identity tools, roles, and network rules decide who opens a session. Setup alone cannot check what each query does or mask sensitive values in a response once a session starts. When workflows touch Postgres, MySQL, SQL Server, MongoDB, ClickHouse, Kubernetes APIs, SSH, or internal HTTP APIs, hoop.dev runs beside those services as an open-source proxy, a sidecar for your Postgres or API. It inspects requests coming in and results going back on the wire.

Your login details and client tools stay as they are while hoop.dev guardrails refuse bad deletes or drops before they run. On responses, hoop.dev data masking rewrites matched sensitive values in memory. Furthermore, hoop.dev holds SOC 2 Type II, is MIT licensed, and writes every query and decision to an audit trail that generates evidence for HIPAA, GDPR, and PCI DSS. See the source on GitHub.

Frequently asked questions

Can a Haystack SQL retriever modify data in CockroachDB?

Yes, if the database account has write permissions on the schema. Using a role with only select rights stops the database from running changes.

Does a CockroachDB read role hide sensitive columns from Haystack?

No, standard table select grants allow the user to read all columns by default. You need column-level grants, database views, or result masking to protect specific fields.

How do we track which Haystack pipeline ran a slow query?

With native roles, you must create a separate database user for each pipeline. You can also add query tags or route traffic through an auditing layer.

The query runs. The emails stay hidden.