Permission-Aware RAG: End-to-End Testing with the SpiceDB Testcontainer
RAG pipelines leak data when the retriever ignores permissions, so retrieved chunks can be post-filtered through SpiceDB, a Zanzibar-style ReBAC engine, before they reach the LLM. Testcontainers spins up a real, disposable SpiceDB instance per test, which keeps permission tests reproducible with no mocks or manual Docker setup. The walkthrough is in Go: it starts the container, loads a document schema with owner and viewer relations, writes relationships for three users, calls CheckPermission on each retrieved document, and asserts that each user only gets documents they can read. A community Python module supports the same pattern.
Related posts
- Partial data dumps using Postgres Row Level Security
Supabase mediumAdeptPostgres Row Level Security can produce a seed.sql containing only safe, non-customer rows: create a restricted `exporter` role, attach RLS select policies that filter which rows it can see, then run `pg_dump --data-only --enable-row-security` as that role. Example policies filter by hardcoded IDs, email domain, recency (e.g. last two months of analytics events), or an `is_exportable` flag column. Alternatives include fully masked database copies (Snaplet) and copy-on-write database forking (Database Lab Engine on ZFS).
- Using an AI Assistant to Script Tools
Docker mediumAdeptInstead of feeding large datasets like Pylint violation JSON through an LLM to transform them into SQL INSERT statements, the assistant can be prompted to write a JavaScript program that performs the transformation, then run it through a tool call. The tool is defined in YAML and backed by a minimal Docker container with no network, host filesystem, GPU or shell access, only shared volumes and Node.js. Having the model generate tools this way limits how much data goes into the context window and lets repeated tasks run without going back to the LLM.
- Modelling Authorization for a Social Network with Postgres RLS and Drizzle ORM
Neon mediumAdept
Postgres Row-Level Security can express the full authorization model for a Twitter-like social network, defined with Drizzle ORM's crudPolicy and pgPolicy helpers and the pg_session_jwt extension's auth.user_id(). Profiles, posts and comments get simple policies: public reads, owner-only writes. Private chats need more care: participants can only see other participants of their own chats, a self-referential rule RLS can't express without recursion errors, so it lives in a view made read-only by adding DISTINCT. Takeaways are that raw-SQL RLS is error-prone, testing policies is hard, schemas exposed to the frontend need careful design beyond policies (e.g. unique constraints), and this work shouldn't be trusted to an LLM.
- Creating AI agent solutions for warehouse data access and security
Meta Engineering mediumAdeptMeta is reworking access control for its offline data warehouse around a multi-agent system. Data-user agents suggest less-restricted alternatives, enable low-risk exploration and draft permission requests. Data-owner agents follow owner-written SOPs to process requests and proactively configure access rules. The warehouse hierarchy is exposed to LLMs as a text folder structure, with context management (automatic, static, dynamic) and explicit role-based or implicit activity-inferred intention. In the partial data preview flow, an LLM judges requests using user activity, query shape and resource metadata, bounded by daily data-access budgets and a rule-based risk guardrail, with daily evals on historical requests and an owner feedback loop.
- Banque des Territoires (CDC Group) x Polyconseil x Hugging Face: Enhancing a Major French Environmental Program with a Sovereign Data Solution
Hugging Face easyNoviceBanque des Territoires, Polyconseil and Hugging Face built a sovereign RAG application that drafts sourced email replies for the EduRénov school-renovation program from its internal documentation. Agents edit and validate the drafts, and that feedback is collected for future fine-tuning and RLHF. The system is a modular monolith in hexagonal architecture, with the LLM, embedding model and retrieval method swappable through configuration. LLM calls are offloaded to Hugging Face Text Generation Inference on GPUs at SecNumCloud-qualified NumSpot, currently running Mistral-7B-Instruct-v0.3, with CroissantLLM under evaluation and RAGAS used for evaluation.