How to Configure Haystack ClickHouse Approval

Published
Length
3 min read

Luis Felipe Dias

All posts

You set up haystack clickhouse approval by pairing database role limits with pipeline review steps. This setup pauses AI queries until a person checks and approves the database action. Teams build AI apps with Haystack to search and summarize large datasets in ClickHouse. Most teams start by giving the Haystack app a single shared database user. When that user has broad permissions, one bad prompt can read or change sensitive tables. A strong review flow stops risky queries before they hit your

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 clickhouse approval by pairing database role limits with pipeline review steps. This setup pauses AI queries until a person checks and approves the database action. Teams build AI apps with Haystack to search and summarize large datasets in ClickHouse. Most teams start by giving the Haystack app a single shared database user. When that user has broad permissions, one bad prompt can read or change sensitive tables. A strong review flow stops risky queries before they hit your database.

How to set up haystack clickhouse approval with native controls

Your first step is locking down what the Haystack service account can do in ClickHouse. ClickHouse manages users, roles, row policies, settings profiles, and quotas as SQL access entities. To turn on SQL access control, an admin sets a storage directory on the server. At least one admin user also needs access management permissions turned on. That admin can then create a dedicated user for the Haystack app. Remember that a ClickHouse user can only grant privileges that they already hold themselves.

When creating the Haystack user, the admin sets the login method and allowed client hosts. The admin also assigns default roles and user settings for that account. Instead of granting full table read rights, teams should use column-level read grants. ClickHouse lets admins grant read rights on specific columns in a table. The Haystack user can then query only those approved columns. If the app runs a wildcard query for all columns, ClickHouse refuses the request. It returns no data unless the table holds only the granted columns. Admins can also grant rights across tables that share a name prefix.

Why native roles alone do not complete an approval flow

ClickHouse access rules decide who logs in and which columns they can read. Still, database roles do not pause a running query to ask a human for approval. Once a user has permission on a column, every valid query runs right away. Haystack pipelines can generate complex queries based on user prompts. A query might follow column rules but still scan too much data at once. It might also pull sensitive fields like emails, phone numbers, card numbers, or national IDs.

To build a true approval step in Haystack, developers often write custom pipeline nodes. The pipeline pauses when the model writes a query for ClickHouse. The app sends a message to a team chat channel and waits for a reply. Writing and maintaining this custom pause logic takes time away from core product work. Each app team ends up building its own review state machine and logging tools. If the app holds raw database credentials, a bug in the code can bypass reviews.

Approval Chains & Escalation + ClickHouse Access Management: architecture patterns and best practices

Continue reading? Get the full guide.

Free. No spam. Unsubscribe anytime.

What to check before approving AI database queries

A good review setup checks three things before a query runs on ClickHouse. First, it checks the exact statement the Haystack pipeline wants to run. Reviewers need to see which tables and columns the model asked for. Second, it checks who triggered the pipeline run in the first place. Knowing the end user helps the reviewer decide if the request makes sense. Third, the setup needs to protect private data in the query results. Data masking rewrites matched fields like emails or card numbers in the results. Combining tight ClickHouse column grants with per-query review keeps your data safe.

Check ClickHouse queries and result columns on the wire

ClickHouse users and row policies decide who connects. They do not check each statement on the wire or redact sensitive string columns in query results. With hoop.dev, you run an open-source proxy, a sidecar for your ClickHouse. It reads ClickHouse's native TCP protocol before queries run while ClickHouse stays in charge of login and grants.

Multi-statement queries and table mutations are split and checked by hoop.dev guardrails. Banned actions are refused with a native ClickHouse error. On returned rows, hoop.dev data masking rewrites String and FixedString columns that match your rules. The audit trail logs each query, table, and verdict. See the MIT-licensed source on GitHub.

Frequently asked questions

Does ClickHouse have a built-in human approval queue for queries?

No, ClickHouse does not pause queries for human sign-off. It checks user roles, host limits, and column grants right when the query arrives. If the user has the right permissions, the database runs the statement right away.

What happens if Haystack runs a wildcard query on restricted ClickHouse columns?

ClickHouse blocks the query and returns no data at all. When a user only has grants on specific columns, wildcard queries fail. The query only works if the user asks for the allowed column names directly.

How can teams protect sensitive fields returned to Haystack pipelines?

Teams can restrict which columns the Haystack user can read using ClickHouse SQL grants. They can also use data masking to rewrite emails, phone numbers, and card numbers in results.

The query runs. The emails stay hidden.