PythiloLesson 9 of 12 · progress kept in this browser

Practice in Lab: Project: assemble and verify a permission-scoped RAG response →

Project: assemble and verify a permission-scoped RAG response

A RAG response combines several boundaries: authorized retrieval, bounded context construction and verification of the returned evidence references. This project actually ranks and packs text, then validates a saved provider response against only the admitted context. The response is deliberately supplied as an input fixture so the exercise runs offline without credentials. Exact quotation catches invented spans but cannot prove that a claim follows from the quote. Treat retrieved text as untrusted data and evaluate real model behavior separately before operating such a pipeline.

chunks = [('a','python python'),('b','python tools')]
budget, used, admitted = 2, 0, []
for key,text in chunks:
    cost = len(text.split())
    if used+cost <= budget:
        admitted.append(key)
        used += cost
print(admitted, used)
Your task

Use the secure_bm25 contract with k1=1.2,b=.75 over authorized documents. Request has exactly tenant,roles,query,k,word_budget (nonnegative integer). Visit top-k ranked chunks, admitting whole text only when its whitespace-word count fits remaining budget, skipping oversized chunks. output is a saved provider-output fixture with exactly claims: a list of closed records text,source,start,end,quote. Require nonempty claim text, a source in admitted context, valid integer code-point offsets, and exact quoted text. Return context_ids,words,claims,joined answer and abstained. Empty claims mean abstention. No model inference or semantic entailment judgment is implemented.