
Security News
Ruby's Bundler 4.0.18 Extends Cooldown to bundle lock and bundle cache
The supply chain control that delays freshly published gems now covers lockfile generation and gem vendoring in Ruby projects.
@valv/clickhouse
Advanced tools
ClickHouse adapter for valv — row-level security and access control for AI agents
ClickHouse adapter for valv — row-level security and policy enforcement for AI agents querying ClickHouse.
npm install @valv/clickhouse @valv/core @clickhouse/client
import { createClient } from "@clickhouse/client"
import { createValv } from "@valv/clickhouse"
const ch = createClient({ url: process.env.CLICKHOUSE_URL })
const valv = createValv(ch, {
database: "analytics",
defaultPolicy: "deny-all",
})
valv.policy("events", (ctx) => ({
read: { tenant_id: ctx.tenant!.id },
aggregate: { tenant_id: ctx.tenant!.id },
write: false,
delete: false,
}))
const tools = await valv.tools.vercel(ctx)
// pass tools to generateText / streamText as usual
Valv reads column and table comments to pick up schema metadata. Add them to your
CREATE TABLE statements:
CREATE TABLE orders
(
id UUID DEFAULT generateUUIDv4(),
tenant_id String,
status Enum8('pending'=1, 'shipped'=2, 'delivered'=3)
COMMENT '@valv:description "Current order status"',
total Int64 COMMENT '@valv:description "Order total in cents"',
notes Nullable(String) COMMENT '@valv:sensitive'
)
ENGINE = MergeTree
ORDER BY (tenant_id, id)
COMMENT '@valv:description "Customer orders"';
The @valv:sensitive tag strips the field from every schema, argument, and result
the LLM sees — enforcement happens at introspection time, not in the prompt.
id columnThe core builder routes get_, update, and delete tool calls through a filter
on the field literally named id. If your table uses a different primary key name
(e.g. event_id), those three operations will not match rows correctly. Name the
primary key id, or accept that only query_ and aggregate_ are useful on that
table.
ClickHouse has no foreign-key metadata, so introspection produces no relations.
The include parameter and relation policies are unavailable. For cross-table
joins, run an aggregate on each table separately and correlate in the agent.
ClickHouse is an append-optimised OLAP engine. Updates and deletes are implemented as:
| operation | SQL | behavior |
|---|---|---|
create | INSERT INTO … FORMAT JSONEachRow | immediate |
update | ALTER TABLE … UPDATE … WHERE … | synchronous (mutations_sync=2); returns { ok: true } |
delete | DELETE FROM … WHERE … | lightweight delete; returns { ok: true } |
Both update and delete require a WHERE clause — the adapter throws if the
resolved query carries no filters. Since the policy engine always injects the row
filter before the adapter sees it, a deny-all-default setup with no explicit read
predicate will throw rather than silently mutate the whole table.
mutations_sync: 2 makes ALTER … UPDATE wait for the mutation to complete before
returning. On large tables this may be slow; consider setting update: false in
policies for high-cardinality tables and relying on INSERT for time-series append
patterns instead.
createValv(client, {
database: "analytics", // defaults to currentDatabase()
defaultPolicy: "deny-all",
onQuery: ({ toolName, resource, durationMs, error }) => { ... },
})
If you need to wire the adapter into an existing Valv instance:
import { ClickHouseAdapter } from "@valv/clickhouse"
import { Valv } from "@valv/core"
const valv = new Valv({
adapter: new ClickHouseAdapter(ch, { database: "analytics" }),
defaultPolicy: "deny-all",
})
FAQs
ClickHouse adapter for valv — row-level security and access control for AI agents
The npm package @valv/clickhouse receives a total of 12 weekly downloads. As such, @valv/clickhouse popularity was classified as not popular.
We found that @valv/clickhouse demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 2 open source maintainers collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Security News
The supply chain control that delays freshly published gems now covers lockfile generation and gem vendoring in Ruby projects.

Security News
During a UK cyber test, a Mythos 5 agent used sockpuppets, social engineering, and prompt injection to try to get a maintainer to merge malware.

Company News
Socket is now in the AWS Security Hub Extended plan. Adopt it through AWS, apply committed spend, and block malicious open source packages.