How do I enforce ACL-before-retrieval in an enterprise RAG pipeline?
Direct answer
Enforce ACL-before-retrieval by attaching explicit group lists to every rule node at ingest and filtering out unauthorized nodes before candidate scoring runs. Mackerel evaluates caller groups in Rust prior to scoring, ensuring restricted documents never appear in results, rankings, or trace.considered counts.
Why standard retrieval breaks here
- Post-retrieval filtering drops unauthorized chunks after top-k search, leaving an empty or degraded result set when restricted rules dominate the top hits.
- Passing raw group filters into vector metadata requires fragile synchronization across separate document and IAM stores.
- Leaking the existence or count of restricted policies (such as active litigation holds) violates internal legal and security boundaries.
How Mackerel solves it
Rule-level ACL declarations
Declare acl: ['legal'] or acl: ['security'] directly on each rule node via POST /v1/corpora/{slug}/rules or MCP.
Pre-scoring visibility gate
Mackerel drops every rule whose acl does not intersect the caller's groups array before lexical or model scoring runs.
Verifiable trace counts
Automated tests can prove isolation by comparing trace.considered with and without a restricted group.
Verify ACL isolation in TypeScript
const denied = await fetch("https://api.runmackerel.com/v1/search", {
method: "POST",
headers: {
Authorization: `Bearer ${process.env.MACKEREL_API_KEY}`,
"Content-Type": "application/json",
"X-Mackerel-ZDR": "true",
},
body: JSON.stringify({
corpus: "demo_sops",
query: "What is our litigation hold retention rule for Slack messages?",
groups: [],
}),
}).then((r) => r.json());
const allowed = await fetch("https://api.runmackerel.com/v1/search", {
method: "POST",
headers: {
Authorization: `Bearer ${process.env.MACKEREL_API_KEY}`,
"Content-Type": "application/json",
"X-Mackerel-ZDR": "true",
},
body: JSON.stringify({
corpus: "demo_sops",
query: "What is our litigation hold retention rule for Slack messages?",
groups: ["legal"],
}),
}).then((r) => r.json());
console.log(denied.trace.considered < allowed.trace.considered);ACL-before-retrieval is included on every tier at no extra cost ($2.00 per 1,000 Flash searches, $0.50 free starter credits).
Frequently asked questions
- Where should caller groups come from in a Next.js or Vercel AI SDK app?
- Read the user's groups from your verified server-side session or identity provider (such as WorkOS, Okta, or Entra ID) inside your API route and pass them into Mackerel's groups array.
- What happens if groups is omitted?
- Only rules with an empty or unrestricted acl are visible. Any rule tagged with specific ACL groups is automatically excluded before scoring.