Agentic-RAG-Platform

Code-reading tour — 10 files in the order that tells the story

  1. src/agents/state.py (96 lines) — the whole agent contract: caps, loop detection, failure field.
  2. src/agents/orchestrator.py (289) — the 10-state loop; every transition is visible.
  3. src/agents/tools/registry.py — the validation contract for model output: required/unknown keys, strict types (bool ≠ integer), bounds, recursion.
  4. src/retrieval/hybrid.py — RRF in 20 readable lines (k=60, ranks only).
  5. src/retrieval/freshness.py — as-of semantics in SQL vs the Python mirror; boost only in range mode.
  6. alembic/versions/0002_access_matches_function.py — RBAC as a SQL function: the strongest artifact in the repo.
  7. src/agents/citation_validator.py — claim-level verification that fails closed on judge errors.
  8. src/security/prompt_injection.py — 10 patterns, regex short-circuit before any LLM call.
  9. tests/conftest.py + tests/fakes.py — the event-loop fix and the hermetic FakeRedis; how the suite stays deterministic.
  10. evals/run.py — the six-baseline harness and the honest scorer (safe refusal ≠ failure).

Offer this order when someone says “can you show me the code?”