Air-Gapped RAG. Zero Cost & Zero Leaks.
RagOn (rag-on) freely shares Aldeon’s complete production RAG architecture: inspect hybrid BM25 + 3-gram math live in X-Ray mode, generate 7-file cross-stack starter kits, and audit your corpus client-side with strict Zero-Leak security.
Replicate RagOn Into Any Product in Seconds
Pick your target stack, language mode, and synthesis strategy to generate all 7 production files (Corpus, Guardrails, Hybrid Engine, API Route, UI Widget, CI Security Test, and SKILL.md) or download the standalone CLI scaffolder.
// src/lib/rag/ragCorpus.ts — Air-Gapped Compile-Time Corpus for MyRagProduct
// Zero runtime disk reads, zero secrets, internal-only citation routes.
export interface RagCitation {
label: { en: string; pt: string };
route: `/${string}`; // Enforced internal web/app path only
}
export interface RagKnowledgeChunk {
id: string;
scope: 'myragproduct' | 'billing' | 'security';
category: 'overview' | 'pricing' | 'features' | 'security';
title: { en: string; pt: string };
content: { en: string; pt: string };
keywords: string[];
citations: RagCitation[];
followUps: { en: string[]; pt: string[] };
}
export const WEB_RAG_CORPUS: RagKnowledgeChunk[] = [
{
id: 'myragproduct-overview',
scope: 'myragproduct',
category: 'overview',
title: { en: 'MyRagProduct Platform Overview', pt: 'Visão Geral do MyRagProduct' },
content: {
en: 'MyRagProduct runs with strict tenant isolation, TLS 1.3 encryption, and zero cross-app tracking.',
pt: 'O MyRagProduct opera com isolamento estrito, criptografia TLS 1.3 e zero rastreamento cruzado.',
},
keywords: ['myragproduct', 'overview', 'security', 'privacy'],
citations: [{ label: { en: 'Product Home', pt: 'Página Inicial' }, route: '/' }],
followUps: {
en: ['What are MyRagProduct pricing plans?', 'How does MyRagProduct protect privacy?'],
pt: ['Quais são os planos do MyRagProduct?', 'Como o MyRagProduct protege os dados?'],
},
},
];Inspect exactly how every query is guarded, scored, and grounded
Test grounded queries, mixed PT/EN phrases, prompt injections, or external web probes over the sanitized OrbitDesk demo corpus and inspect BM25 + 3-gram math live.
Audit your RAG corpus JSON before deploying to production
Paste your corpus JSON below. Validation runs 100% locally in browser memory (zero network requests), flagging keys, emails, workstation paths, and untrusted external citation URLs.
How rag-on guarantees zero secret leaks and zero hallucinations
Air-Gapped Compile-Time Corpus
Public web RAG routes never read raw workspace markdown or private databases from disk.
FNV-1a Hashed Guardrails
Internal blocklist tokens are checked via one-way 32-bit FNV-1a hashes so zero secrets ship in client JS.
Strict Grounding Threshold
Queries below score 4.2 or without strong lexical anchors trigger deterministic refusal instead of guessing.
10-Rule Output Redaction Shield
Every emitted string passes XSS stripping and 10 structural regex rules before returning JSON.
How RagOn works under the hood (and how to replicate it anywhere)
Every request executes a deterministic 6-stage pipeline guaranteeing sub-2ms edge latency and zero LLM inference cost by default.
Phase 1: Curate an Air-Gapped Bilingual Corpus
Author deterministic chunks with internal-only citations and follow-up chips.
Replace brittle PDF scrapers with a versioned, TypeScript-typed array of knowledge chunks containing EN/PT titles, concise facts, domain keywords, internal `/route` citations, and curated follow-up prompts.
Chunk = { id, scope, category, title, content, keywords[], citations[/route], followUps[] }Production RAG failure modes prevented deterministically
Cleartext Internal Blocklist Literals Bundled Into Client JS
Inspecting compiled client assets reveals internal project IDs or usernames inside guardrail regexes.
Writing literal internal project slugs or developer handles directly inside client-imported guardrail files.
Offline fallback widgets import the RAG engine on the client, bundling every literal regex constant into public JS chunks.
Replace cleartext internal strings with structural regex patterns plus one-way FNV-1a 32-bit token hashes verified by CI.
const RESTRICTED_HASHES = new Set(['1794d565', 'bf959e2f']);
const isRestricted = (tok: string) => RESTRICTED_HASHES.has(fnv1a32Hex(tok.toLowerCase()));Accented Unicode Characters Bypassing ASCII Regex Guardrails
Queries like "ignorar instruções" or "previsão do tempo" slip past English or unaccented regex rules.
Testing raw user input directly against ASCII-only regular expressions without Unicode normalization.
Accented characters (ç, ã, õ, é) fail literal ASCII pattern boundaries like /instrucoes/.
Normalize every query with NFD decomposition and strip combining marks ([\u0300-\u036f]) prior to security and retrieval checks.
const norm = raw.normalize('NFD').replace(/[\u0300-\u036f]/g, '').toLowerCase().trim();Pure Keyword Match Failing on Typos and Morphological Variants
Users typing "precing" or "sincroniza" receive false out-of-scope refusals despite valid corpus docs.
Relying solely on exact space-delimited word equality without subword similarity or synonym expansion.
Exact token sets miss single-character typos and Portuguese/English cross-lingual stems.
Combine field-weighted BM25 with character 3-gram cosine similarity (4.0x body + 4.5x title/keywords) and a bilingual synonym table.
const score = bm25Score + anchorBonus + cos3(qTris, doc.allTris) * 4.0 + cos3(qTris, doc.titleTris) * 4.5;Returning Best-Match Chunk Regardless of Grounding Score
Off-topic questions like "Explain quantum chromodynamics" return an unrelated product overview.
Taking rankedDocs[0] unconditionally without enforcing a minimum score or strong anchor threshold.
Trigram cosine and stopword noise can produce tiny non-zero scores (> 0.1) for completely unrelated queries.
Enforce MIN_RAG_SCORE >= 4.2 and strongAnchors >= 1 (plus >= 2 matchedConcepts when unscoped), refusing cleanly otherwise.
if (!top || top.score < 4.2 || top.strongAnchors < 1) return buildSafeRefusal(lang);Eagerly Importing Chat Corpus & Drawer Into Initial Route Bundle
Every marketing landing page downloads +30 KB gz of chat UI and corpus data before First Contentful Paint.
Statically importing the full ChatDrawer and RAG corpus inside the root HTML layout component.
Static top-level imports force Vite/Rollup to include interactive chat chunks in the critical hydration path.
Mount a tiny launcher in root useEffect and dynamically React.lazy() the drawer only when opened or triggered.
const LazyDrawer = lazy(() => import('./RagChatDrawer'));
// Render <LazyDrawer /> only after hasLoadedDrawer becomes truePublic Edge Caching on Dynamic POST /api/chat Responses
CDN intermediaries or shared browsers cache personalized refusal or rate-limit responses.
Omitting Cache-Control headers or reusing public s-maxage headers on chat API endpoints.
Without explicit no-store directives, proxies and browser back/forward caches can serve stale API payloads.
Attach Cache-Control: private, no-store, max-age=0 to every 200, 405, 429, and 500 response from /api/chat.
return Response.json(payload, { headers: { 'Cache-Control': 'private, no-store, max-age=0' } });UI Loanwords Flipping Portuguese Replies Into English
A user asking "Quais features e pricing o app tem?" receives an English answer despite PT grammar.
Counting English technical nouns equal to English grammar words during language detection.
Bilingual users mix UI words ("pricing", "offline", "account") inside Portuguese syntax ("Quais", "como").
Weight Portuguese function words (+3.0) and diacritics (+3.5) higher than English tech loanwords (+1.5).
if (PT_FUNCTION_WORDS.has(tok)) ptScore += 3;
else if (EN_TECH_HINTS.has(tok)) enScore += 1.5;Unescaped User Input Inside Optional Hybrid LLM Prompts
Crafted user queries break out of prompt delimiters and hijack optional LLM synthesis instructions.
Interpolating raw user queries directly into system or context prompt strings without XML escaping.
Unescaped < or > characters allow attackers to inject synthetic closing tags like </user_query>.
Wrap retrieved context in <grounded_context> XML tags, escape user input via escapePromptXml(), and run redactChatOutput() post-LLM.
const prompt = `<grounded_context>${escapePromptXml(ctx)}</grounded_context>
<user_query>${escapePromptXml(query)}</user_query>`;