Skip to Content
Recodocs

The host owns the status

Code chooses every step, and the API keeps a cited id only when this retrieval returned it. A caller can also pass extra_evidence, which the API does not expose. The models only fill the answer and review schemas.

8 min read

Retrieval finds text that may answer a question. Grounding requires the answer to be supported by what was retrieved; authority determines whether the assistant may make a commitment at all. This test separates those three questions.

A presenter asks, "Can you guarantee replacement by noon?" There is no loop in which a model picks an action or a tool. In test_assistant_cannot_make_commitment_even_if_model_calls_it_answered the fixture writer still returns a claim, and the fixture reviewer marks it supported, with documentary_answer_available true and required_record set to general_documentation. Engine.ask returns insufficient_evidence and trace.commitment_requested is true. The code then uses a fixed explanation: this assistant can explain documented commitments, but cannot make a new guarantee. The six PDFs are synthetic.

The claim is that code chooses every step and derives the status. The API keeps a cited id only when this retrieval returned it; a caller can also pass extra_evidence, which the API does not expose. The writer and the reviewer fill two schemas. They do not choose the next step.

The argument

  1. The order is code. ask retrieves, then generate_reviewed calls the writer, calls the reviewer, and validates. Provider describes each call as one pipeline step chosen by code.
  2. Status is answer_status. Conflicts win. A commitment, a record other than general_documentation, or a false documentary flag becomes insufficient_evidence.
  3. The API keeps a cited id only when this retrieval returned it. A caller can also pass extra_evidence, which the API does not expose. Title, version, page and passage text are copied from the approved corpus. A kept invented id raises Fault; an unsupported claim on an already insufficient result is discarded and no citation is shown.
  4. The named tests assert those guards with a fixture provider that returns fixed answers and reviews.

Who is allowed to decide

rag_demo/runtime.py is a fixed pipeline. Operations has one worker. A second question while one is running raises busy ("Wait for the current answer."). The same request id and text return the existing operation, including a failure. A different question on that id is conflict. No method on that class asks a model which route to take.

What the workflow is allowed to decideA session question enters a dashed pipeline. Inside, in order, are retrieval, the writer schema, the reviewer schema, and answer_status. A commitment or an individual-record question cannot become answered. SQLite returns passage ids. Codex fills the two schemas. The host returns a status or a fault.SessionBearer on /v1One question at a time.Extra fields are 422.Cannot be answeredCommitmentcustomer_agreementcertificate, bookingFixed stepsEngine.askRetrieveFTS5 + vectors, sixWriterAnswer schemaReviewerReview schemaanswer_statuscode derives statusIndexSQLite FTS5 + vectorsSix approved PDFs.Porter tokenizer.Read-only at runtime.Schema fillsWriter gpt-6-lunaReviewer gpt-6-solLocal bge-small embed.No tool list.30 s, no retries.questionstatusreadidsschemas
Code names every step. The models only fill Answer and Review.

The dashed box is Engine.ask. The rows are the calls, in order: Retrieve, Writer, Reviewer, then answer_status. A question goes in. Passage ids come back from the index. The schema calls go out and come back as Answer schema and Review schema. The host emits a status. A failed check raises Fault. There is no tool list on either schema.

Outside the box, SessionGuard requires Authorization: Bearer and the session key on every /v1 route. GET /health, /docs and /openapi.json are public. Question sets extra='forbid'. The question is 1 to 1500 characters, and a POST larger than 8192 bytes is "Question request exceeds 8 KB." test_input_boundary sends a blank, 1501 characters, request id ../outside, a command field, and 9000 bytes. All are rejected, and the fixture calls stay 0.

The writer default is gpt-6-luna (DEMO_MODEL). The reviewer default is gpt-6-sol (DEMO_REVIEW_MODEL). Both use medium reasoning, prompt version democo-grounding-v17, a 6,000-token ceiling, and a 30-second timeout. The query embedding is local BAAI/bge-small-en-v1.5 at revision 5c38ec7c405ec4b44b94cc5a9bb96e735b38267a, with the hub offline and local_files_only=True. The README counts three calls per question, one at a time: local embedding, Codex generation, Codex evidence review, and 30 calls per session (DEMO_MODEL_CALL_LIMIT). There are no automatic transport retries. The budget is a presenter safety limit. test_budget_prevents_extra_provider_call sets the limit to 3, finishes one ask, and asserts the next ask raises Fault while calls stays 3.

Retrieval is code. Index.retrieve takes the top 12 vector neighbours and up to 12 FTS5 hits, fuses them with reciprocal rank fusion at rank constant 60, and keeps six passages. The stage attribute is selected_by workflow. Follow-ups retrieve again. Only product identifiers from earlier user questions are added, and only when the new question names none. Earlier answer text is never indexed. test_followup_retrieves_again_with_user_context_only asks "What about its warranty?" after "G200 offline?" with a stored result containing "invented previous answer". The embed string contains Product context: G200 and does not contain that sentence.

The orange card is labeled Cannot be answered: Commitment, customer_agreement, and certificate or booking. COMMITMENT_REQUEST matches, case-insensitively, can, could, will, or would, then you or we, then up to two words, then guarantee, promise, commit, or assure. answer_status also returns insufficient_evidence for customer_agreement, third_party_certificate, or service_booking, even when documentary_answer_available is true. test_general_corpus_cannot_resolve_individual_records performs that rewrite and asserts the status. The comment on answer_status says model answerability cannot expand this code-owned authority. test_corpus_has_six_two_page_pdfs_and_exact_manifest asserts six documents, twelve chunks, fictional, and two pages each. An unapproved document, a bad PDF hash, or a chunk missing from its page raises before a question runs.

configured_app attaches an answer cache. scope_decision admits only a standalone G200 offline explanation. That rule is host code. The semantic shadow only observes: a candidate is never served.

What a passage can prove

The reviewer's booleans are inputs. The status is the first match in answer_status.

How answer_status choosesConflicts are checked first and yield conflicting evidence. Otherwise a commitment, a record other than general documentation, or a false documentary flag yields insufficient evidence. The remaining case is answered. A citation id absent from this retrieval raises invalid_citation and shows nothing.answer_statusfirst match wins1conflictsany pairconflicting_evidence2else ifcommitment, other record, or no document answerinsufficient_evidence3elsegeneral_documentation and supportedansweredCitation gate, after statusid not in this retrieval, such as warranty:99:1invalid_citation
Conflicts outrank answerability. A missing passage id shows no answer.

If review.conflicts is non-empty, the status is conflicting_evidence before documentary_answer_available is read. Otherwise the status is insufficient_evidence when the documentary flag is false, the commitment pattern matches, or required_record is not general_documentation. The remaining case is answered: general_documentation and a true documentary flag. Separately, a kept claim id must sit in byid. test_fabricated_citation_fails_closed cites warranty:99:1 and expects Fault.

The pages behind the real ids are in corpus/documents.json. The G200 manual says firmware 2.4 supports a maximum of 64 Modbus TCP devices, and that IP54 does not mean waterproof. The compatibility matrix says the same firmware supports a maximum of 32, that both documents are approved with the same effective date, and that neither supersedes the other. Both records use 2026-09-01. The matrix says not to infer precedence from a version number, and to refer an unresolved difference to product engineering before promising a limit. It lists G100 firmware 1.8 at 16 devices. The warranty exclusions include liquid ingress, and say an IP rating does not override that exclusion. The service policy says no four-hour replacement guarantee is stated, and that an initial response is not a resolution, an engineer arrival, or a replacement-delivery commitment.

Once status is chosen, the explanation is a fixed string. Insufficient evidence says the retrieved documents do not establish the requested commitment or information. A conflict says the approved sources disagree and no documented precedence resolves the difference. A matched commitment replaces the gap sentence with the guarantee refusal from the opening. The conflict next step is to escalate the conflicting specification before making a commitment. Those strings are not another model call.

Citation metadata is copied from the corpus. For each kept id the host writes document_id, title, version, page, and the chunk passage. The README says these checks prove provenance, not semantic entailment. Support is claim_assessments: one row per claim, indexes from zero, each with supported. A broken index list raises invalid_answer. An unsupported claim on any status other than insufficient_evidence raises unsupported_answer and displays nothing. When the status is already insufficient, the runtime clears the claims and the citations, sets rejected_claims_discarded, and does not call the provider again. test_rejected_gap_claim_is_discarded_without_retry_or_citation asks "Is this third-party device certified?", supplies an invented id and a review of third_party_certificate with supported false, and asserts empty claims, empty citations, the words "do not establish", the discard flag, and engine.calls == 3.

A conflict pair must be two ids in this retrieval, from two different approved documents, and both ids must appear on the kept claims. Otherwise the host raises invalid_citation. test_keyword_search_matches_inflected_policy_terms asserts that FTS5 price returns service:2:1, using the Porter tokenizer. That service page says pricing and customer-specific terms are outside this corpus.

The turn in the conflict test

test_conflict_requires_the_specific_reviewed_pair is one decision with the model replaced. The question is "Which limit?" Retrieval is stubbed to chunks whose document is g200 or compatibility. The review always records topic "Device limit", first id g200:2:1, second id compatibility:1:1, the claim supported, and documentary_answer_available true. The corpus test expects twelve chunks across six two-page documents, and build_index numbers ids as document, page, and passage, so those ids are the manual's device-limit page (64) and the matrix's first page (32).

The conflict test, both branchesThe test asks which limit. Retrieval is stubbed to the G200 manual and the compatibility matrix. When the claim cites g200 colon 2 colon 1 and compatibility colon 1 colon 1, and the review names that pair, the status is conflicting evidence. When the claim cites compatibility colon 2 colon 1 instead, the host raises a fault.QuestionWhich limit?Retrieveg200, matrixClaimcites the pairReviewDevice limitStatusconflictCited pair keptg200:2:1 and compatibility:1:1Wrong page of the same doccompatibility:2:1 → Faulttest_conflict_requires_the_specific_reviewed_pair. The fixture marks the claim supported.
The pair must be the two passage ids the review named.

On the passing branch the fixture claim reads "The sources disagree." and cites g200:2:1 and compatibility:1:1. Both ids of the review pair are in the used set. answer_status sees a non-empty conflict list and returns conflicting_evidence even though the fixture said a documentary answer was available. The test asserts that status.

On the other branch the claim cites compatibility:2:1, the matrix protocols page, instead of compatibility:1:1. The id is a real page of the right document. It still fails, because the review's second id is not among the claim ids, and Engine.ask raises Fault. The test comment says that wrong passage cannot substantiate its limit. The fixed conflict explanation is what the code attaches for this status. The test asserts the status or the fault, not that sentence.

The one check to copy

Copy the membership test. byid maps this retrieval's passages, plus extra_evidence when a caller passed it. extra_evidence can be added only by evaluation code, and the comment says the API never exposes that argument. Each remaining claim needs text, at least one id, and every id inside the map. test_fabricated_citation_fails_closed aims a claim at warranty:99:1 and expects Fault.

for claim in answer.claims:
    if not claim.text.strip() or not claim.evidence_ids or any(k not in byid for k in claim.evidence_ids):
        raise Fault('invalid_citation', 'The model cited evidence that was not retrieved. No answer was displayed.', 502)

Answer.claims is already capped at two. The cap limits what the writer may propose. It does not decide what is shown. An answered status with no claims raises invalid_answer. The commitment pattern and the required_record enum are host checks: the host matches the commitment pattern on the question and interprets the reviewer's required_record after the schema is filled.

Close

On the noon guarantee, the fixture was allowed to mark the claim supported, and the status was still insufficient_evidence. On "Which limit?", a supported account of the disagreement stayed conflicting_evidence only when the claim cited both ids the review named. On warranty:99:1, nothing was displayed. The writer filled Answer. The reviewer filled Review, including which record the question requires. The host chose the step, the status, and the ids that could appear. With no conflict, when the reviewer classifies the question as an individual agreement, a third-party certificate, or a service booking, the status is insufficient_evidence even if documentary_answer_available is true. A new passage must not widen that authority by itself.

How is this page?

Last updated on