learntodriveai.dev/Machine Learning/Cloud RAG: Multi-Index Retrieval, Life-Safety Guardrails, and Authored AI Infrastructure
Machine Learning·Project 18·7 units

Cloud RAG: Multi-Index Retrieval, Life-Safety Guardrails, and Authored AI Infrastructure.

**Project:** P18

§ Brief

You're designing a cloud RAG system for Tariq Al-Rashid at the Jordan Civil Defense Directorate in Amman. The directorate maintains over 4,200 operational documents -- protocols, chemical hazard sheets, building codes, playbooks, post-incident reports -- that field commanders need during active emergencies, and manual lookup currently delays life-safety decisions.

The discipline skills: per-class chunking across five document classes, multi-index retrieval over pgvector, class-conditional re-ranking with confidence gates, compression that respects what cannot be lost, query-class-conditional transformation, a four-piece life-safety guardrail layer, deployment on a second cloud platform with Kubernetes only where it earns its complexity, bilingual evaluation, and the retrieval-vs-fine-tuning diagnostic.

The AI-direction lesson: the infrastructure you author is itself a directing act. Memory tells AI what constraints to follow; a skill tells it how to perform a workflow; a hook makes a check fire deterministically; a phase-scoped MCP set changes what's connected as the workflow phase changes. Choosing the right mechanism for each constraint is the new register, and the encodings persist across sessions and tools.

Your Role

RAG-engineering and AI-infrastructure architect on a regulatory-grade system in a life-safety domain. The 5-second ceiling, zero-fabrication rule, classification enforcement, bilingual operation, and offline-capable field deployment come from Tariq's memo and the directorate's regulations. You handle the system architecture, the chunkers and indexes, the routing and re-rank and compression policies, the guardrail layer, the deployment split, the first authored skill, the hooks, the phase-scoped MCP design, and the three RAG-maintenance agents.

You own the established surface end to end; the guidance you get is on the new terrain only. Marcus Webb is on call -- consulted expert, not architect.

What's New

Last time you built a hybrid production system for Ana Beatriz Costa at Banco Horizonte -- a classical fraud model and an LLM customer-service component on one stack, with routing in front and component-scoped agents. Architecture-as-context, verification at composition boundaries, and delegation by scope are part of how you work.

This time the components don't split across paradigms -- they're five document classes that share a shape but need different treatment. The system has six services on two surfaces, three indexes routed by a class-classifier, a re-ranker that fires only when it earns its latency, and a generation layer wrapped in guardrails that refuse rather than guess. The new directing register is the infrastructure itself: a SKILL.md you author, hooks you configure, phase-scoped MCP connectivity you design, and Claude Code running as an MCP server for cross-tool review.

The hard parts are spread thin. AI's first chunker will be one for the whole corpus, and the chemical sheets will lose their detonation temperatures. Its first re-ranker will fire on every query. Its first compression will treat ammonium nitrate's critical numbers as compressible. Its first guardrail layer will let a synthesised procedure read as authoritative. Its first deployment script will copy AWS patterns onto Azure. Each is a different catch on a domain where fabrication is unacceptable.

Tools

  • Claude Code -- primary AI agent; memory extended with RAG rules; first authored skill in skills/rag-eval/; hooks in .claude/hooks/; configured as an MCP server with two read-only review capabilities (familiar, new register)
  • Codex CLI -- operational-handoff pass; connects to Claude Code via MCP (familiar)
  • Anthropic SDK -- generation against Claude Haiku or Sonnet (familiar)
  • Python, pandas, FastAPI, Pydantic, Docker Compose, MLflow, pytest, Git/GitHub -- familiar; pytest extended with chunker-fidelity, retrieval-precision, grounding, cross-language, and end-to-end tests
  • sentence-transformers + cross-encoder re-ranker -- multilingual bi-encoder and class-conditional re-ranker (new)
  • pgvector on Postgres -- three indexes, one per document class group (new at this register)
  • Azure ML, Azure CLI, Kubernetes / kubectl -- second cloud platform; managed endpoints plus a small Kubernetes deployment for the three index services (new)
  • SKILL.md (agentskills.io) and hooks -- first authored skill and first hooks (new)

Materials

You receive:

  • memo.md -- Tariq's formal memorandum with the requirement and five constraints
  • regulatory-requirements.md -- classification, document-lifecycle, audit-log, offline-deployment, and cross-language requirements, each mapped to the architectural decision it forces
  • A corpus/ directory -- bilingual sample with five subdirectories (protocols/, hazards/, codes/, playbooks/, reports/), classification-level tags throughout
  • An evaluation-queries/ directory -- held-out bilingual query set with class labels and ground-truth references, plus two disjoint training sets
  • docker-compose.yml skeleton with six services and TODO integration points
  • An azure-ml-skeleton/ directory -- endpoint and deployment templates, managed-identity notes, and Kubernetes manifests for the three index services
  • A skills/_template/ and hooks/_examples/ -- SKILL.md template plus pre-commit and save-time hook examples
  • .mcp-phases.template.md -- connectivity record template, three phases pre-headed
  • CLAUDE.md and AGENTS.md carried forward -- universal rules plus an empty "RAG-and-infrastructure rules" section and three agent placeholders
  • .env.example with the six service URLs and the Azure block

When you need Azure ML, Kubernetes selectivity, or hook setup, the senior-colleague chat is one click away.

Materials

View all →
Corpus/
mdcodes/code_000.mdmdcodes/code_001.mdmdcodes/code_002.mdmdcodes/code_003.mdmdcodes/code_004.mdmdcodes/code_005.mdmdcodes/code_006.mdmdcodes/code_007.mdmdcodes/code_008.mdmdcodes/code_009.mdmdcodes/code_010.mdmdcodes/code_011.mdmdcodes/code_012.mdmdcodes/code_013.mdmdcodes/code_014.mdmdcodes/code_015.mdmdcodes/code_016.mdmdcodes/code_017.mdmdcodes/code_018.mdmdcodes/code_019.mdmdcodes/code_020.mdmdcodes/code_021.mdmdcodes/code_022.mdmdcodes/code_023.mdmdcodes/code_024.mdmdcodes/code_025.mdmdcodes/code_026.mdmdcodes/code_027.mdmdcodes/code_028.mdmdcodes/code_029.mdmdhazards/hazard_000.mdmdhazards/hazard_001.mdmdhazards/hazard_002.mdmdhazards/hazard_003.mdmdhazards/hazard_004.mdmdhazards/hazard_005.mdmdhazards/hazard_006.mdmdhazards/hazard_007.mdmdhazards/hazard_008.mdmdhazards/hazard_009.mdmdhazards/hazard_010.mdmdhazards/hazard_011.mdmdhazards/hazard_012.mdmdhazards/hazard_013.mdmdhazards/hazard_014.mdmdhazards/hazard_015.mdmdhazards/hazard_016.mdmdhazards/hazard_017.mdmdhazards/hazard_018.mdmdhazards/hazard_019.mdmdhazards/hazard_020.mdmdhazards/hazard_021.mdmdhazards/hazard_022.mdmdhazards/hazard_023.mdmdhazards/hazard_024.mdmdhazards/hazard_025.mdmdhazards/hazard_026.mdmdhazards/hazard_027.mdmdhazards/hazard_028.mdmdhazards/hazard_029.mdmdhazards/hazard_030.mdmdhazards/hazard_031.mdmdhazards/hazard_032.mdmdhazards/hazard_033.mdmdhazards/hazard_034.mdmdhazards/hazard_035.mdmdhazards/hazard_036.mdmdhazards/hazard_037.mdmdhazards/hazard_038.mdmdhazards/hazard_039.mdmdhazards/hazard_040.mdmdhazards/hazard_041.mdmdhazards/hazard_042.mdmdhazards/hazard_043.mdmdhazards/hazard_044.mdmdplaybooks/playbook_000.mdmdplaybooks/playbook_001.mdmdplaybooks/playbook_002.mdmdplaybooks/playbook_003.mdmdplaybooks/playbook_004.mdmdplaybooks/playbook_005.mdmdplaybooks/playbook_006.mdmdplaybooks/playbook_007.mdmdplaybooks/playbook_008.mdmdplaybooks/playbook_009.mdmdplaybooks/playbook_010.mdmdplaybooks/playbook_011.mdmdplaybooks/playbook_012.mdmdplaybooks/playbook_013.mdmdplaybooks/playbook_014.mdmdplaybooks/playbook_015.mdmdplaybooks/playbook_016.mdmdplaybooks/playbook_017.mdmdplaybooks/playbook_018.mdmdplaybooks/playbook_019.mdmdprotocols/protocol_000.mdmdprotocols/protocol_001.mdmdprotocols/protocol_002.mdmdprotocols/protocol_003.mdmdprotocols/protocol_004.mdmdprotocols/protocol_005.mdmdprotocols/protocol_006.mdmdprotocols/protocol_007.mdmdprotocols/protocol_008.mdmdprotocols/protocol_009.mdmdprotocols/protocol_010.mdmdprotocols/protocol_011.mdmdprotocols/protocol_012.mdmdprotocols/protocol_013.mdmdprotocols/protocol_014.mdmdprotocols/protocol_015.mdmdprotocols/protocol_016.mdmdprotocols/protocol_017.mdmdprotocols/protocol_018.mdmdprotocols/protocol_019.mdmdprotocols/protocol_020.mdmdprotocols/protocol_021.mdmdprotocols/protocol_022.mdmdprotocols/protocol_023.mdmdprotocols/protocol_024.mdmdprotocols/protocol_025.mdmdprotocols/protocol_026.mdmdprotocols/protocol_027.mdmdprotocols/protocol_028.mdmdprotocols/protocol_029.mdmdprotocols/protocol_030.mdmdprotocols/protocol_031.mdmdprotocols/protocol_032.mdmdprotocols/protocol_033.mdmdprotocols/protocol_034.mdmdREADME.mdmdreports/report_000.mdmdreports/report_001.mdmdreports/report_002.mdmdreports/report_003.mdmdreports/report_004.mdmdreports/report_005.mdmdreports/report_006.mdmdreports/report_007.mdmdreports/report_008.mdmdreports/report_009.mdmdreports/report_010.mdmdreports/report_011.mdmdreports/report_012.mdmdreports/report_013.mdmdreports/report_014.mdmdreports/report_015.mdmdreports/report_016.mdmdreports/report_017.mdmdreports/report_018.mdmdreports/report_019.mdmdreports/report_020.mdmdreports/report_021.mdmdreports/report_022.mdmdreports/report_023.mdmdreports/report_024.md