Before evaluating an answer, identify what the application was given and which component produced each result. You will run one fictional loan question through small local functions, then select a plausible but incorrect response. The different outputs will help you locate a failure without confusing successful execution with correct behavior.
The supplied task and its boundaries
Alderwick Equipment Desk lends equipment for at most seven days per loan. The question is “How long may I keep the tripod on loan-041?” The fictional record says that loan exists, its item is a tripod and its status is open. There are no real borrowers, accounts or equipment behind these records.
A corpus is a collection of documents. Retrieval selects documents from
that collection for a request. Here retrieval is a fixed lookup of document ID
loan-period, chosen for this one supplied question. It is not a vector database,
semantic search or relevance-ranking model. The tool lookup_loan reads a
local dictionary; it cannot contact a lending service or change a loan.
The model adapter accepts a question, selected documents and the loan result.
It selects a course-authored response named baseline or unsupported. These
names identify fixture profiles, not real model releases. It does not interpret
the context or generate fresh text. Changing a prompt or policy file cannot
cause this adapter to reason differently.

Figure: both lookup results feed the replay boundary. The arrows show data
dependencies, not simultaneous execution; run performs the policy lookup,
then the loan lookup. “Context” means the question, documents and loan passed
to the adapter. The dashed box selects prepared text. The outer box is actual
Python execution, and the final arrow is a returned result, not a network call.
Prepare a small scenario directory
Use the marked ~/ai-eval-practice directory and environment from
local setup. The verified command route
is macOS/zsh ARM64 with CPython 3.12. This task uses only Python's standard
library; no network, model, Collector process, database or reservation runs.
It creates a scenario directory and later overwrites only its generated
input-inventory.json file. Source files and existing setup remain in place.
Run one line at a time from your zsh terminal; stop on an error:
cd "$HOME/ai-eval-practice"
.venv/bin/python -c 'import sys; print(sys.executable)'
mkdir scenario
Confirm the interpreter is inside your practice .venv. If scenario already
exists, inspect it and resume with your earlier course files; do not overwrite
unrelated work. Save the following complete files inside scenario using a
plain text editor. Their names are literal filenames, not placeholders.
policy.json: the intended rules
{
"policy_version": "desk-policy-1",
"max_loan_days": 7,
"missing_loan_behavior": "Say the loan was not found; do not invent its status.",
"answer_mode_allowed_tools": ["lookup_loan"],
"reservation_rule": "Reservations require a separate confirmed workflow; the answer path cannot create one."
}
policy_version names the fictional rule revision. max_loan_days is a numeric
reference value. answer_mode_allowed_tools lists the operation permitted in
this answer path. Reservations require a separate confirmed workflow; this
question must not create one. The JSON records intended behavior; loading it
does not automatically enforce those rules on an answer.
corpus.json: readable evidence with stable IDs
[
{
"doc_id": "loan-period",
"revision": "1",
"policy_version": "desk-policy-1",
"text": "Alderwick equipment may be borrowed for at most seven days per loan."
},
{
"doc_id": "missing-loan",
"revision": "1",
"policy_version": "desk-policy-1",
"text": "If a loan record cannot be found, say it was not found. Do not invent a loan status."
},
{
"doc_id": "reservation-policy",
"revision": "1",
"policy_version": "desk-policy-1",
"text": "An answer to a loan question cannot create a reservation. Use a separate confirmed reservation workflow."
}
]
Each document has a stable ID, revision, policy version and text. loan-period
contains the seven-day rule. The other two passages supply rules for later
missing-record and tool-policy examples. A citation to an ID is useful only
if the document's text supports the claim. A document existing in this file
does not mean the application selected it for a particular request.
loans.json: the fictional read-tool input
{
"loan-041": {
"loan_id": "loan-041",
"item": "tripod",
"status": "open"
}
}
The outer key supports a lookup by loan ID. The record supplies an item and
status, not a new lending policy. In particular, open does not grant fourteen
days or authorize a reservation. Later tasks will check missing and malformed
inputs; this first request uses the supplied existing record.
Read the actual application
The program uses list and dictionary comprehensions, compact ways to build
a collection by looping. In retrieve_policy, [doc for doc in corpus if doc["doc_id"] == "loan-period"] means: start an empty list, visit each document,
and append it only when its ID matches. The dictionary comprehension in
input_inventory visits each filename and stores its hash under that name.
These expressions perform the same kind of work as the explicit loops you
already know.
Path(__file__).resolve().parent identifies the directory containing this
program. Reading its fixtures relative to that directory prevents an unrelated
current directory from silently supplying a different policy.json.
.read_text(encoding="utf-8") decodes bytes into characters for JSON parsing;
.read_bytes() keeps the exact stored bytes for hashing. See the
byte-hash bridge
if needed before continuing.
Save this complete file as scenario/desk.py:
"""Original synthetic scenario: real local functions, authored replay answers."""
import hashlib
import json
from pathlib import Path
import sys
ROOT = Path(__file__).resolve().parent
RESPONSES = {
"baseline": {
"answer": "The tripod on loan-041 may be borrowed for at most seven days.",
"max_days": 7,
"evidence_ids": ["loan-period"],
"loan_id": "loan-041"
},
"unsupported": {
"answer": "The tripod on loan-041 may be borrowed for at most fourteen days.",
"max_days": 14,
"evidence_ids": ["loan-period"],
"loan_id": "loan-041"
}
}
def read_json(name):
return json.loads((ROOT / name).read_text(encoding="utf-8"))
def retrieve_policy(corpus):
# Fixed lookup for the one supplied question, not a search/ranking model.
return [doc for doc in corpus if doc["doc_id"] == "loan-period"]
def lookup_loan(loan_id, loans):
# A local dictionary read; no database or external lending system.
return loans.get(loan_id)
def replay_answer(candidate, question, documents, loan):
# Context is passed across the boundary but does not generate these answers.
if candidate not in RESPONSES:
raise ValueError("Choose baseline or unsupported")
supplied = RESPONSES[candidate]
return {"answer": supplied["answer"], "max_days": supplied["max_days"],
"evidence_ids": list(supplied["evidence_ids"]), "loan_id": supplied["loan_id"]}
def input_inventory():
return {"origin": "course-authored-synthetic", "adapter_mode": "synthetic-replay",
"policy_version": read_json("policy.json")["policy_version"],
"sha256": {name: hashlib.sha256((ROOT / name).read_bytes()).hexdigest()
for name in ["policy.json", "corpus.json", "loans.json", "desk.py"]}}
def run(candidate="baseline"):
question = "How long may I keep the tripod on loan-041?"
documents = retrieve_policy(read_json("corpus.json"))
loan = lookup_loan("loan-041", read_json("loans.json"))
response = replay_answer(candidate, question, documents, loan)
return {"adapter_mode": "synthetic-replay", "candidate": candidate,
"question": question, "retrieved_ids": [d["doc_id"] for d in documents],
"loan_result": loan, "response": response}
def main():
candidate = sys.argv[1] if len(sys.argv) > 1 else "baseline"
result = run(candidate)
(ROOT / "input-inventory.json").write_text(json.dumps(input_inventory(), indent=2) + "\n")
print(json.dumps(result, indent=2))
if __name__ == "__main__":
main()
Follow the functional blocks:
RESPONSESstores authored seven-day and fourteen-day payloads. Both citeloan-periodand nameloan-041. A plausible citation can accompany an incorrect claim.read_jsondecodes a named fixture. Successful JSON decoding establishes readable syntax, not correct field types or a truthful answer. Those need checks we will add later.retrieve_policyreturns the selected document list.lookup_loanuses dictionary.get: a missing ID returnsNonerather than raisingKeyError. This is a read only tool function, not an external service integration.replay_answerchecks the fixture name and returns its stored fields. It copies the evidence-ID list into a new list, so modifying a returned list does not mutate the stored fixture. The question, documents and loan are accepted to expose the future model boundary; they do not generate this text.input_inventoryhashes the four source files and labels their synthetic origin. It is an input inventory, not a complete run record or model provenance report. Candidate selection is a command argument, so the same source hashes can produce different candidate outputs.runsupplies the fixed question and tool ID, gathers the two results and returns both the boundary evidence and response. The default candidate isbaseline.maintakes an optional candidate fromsys.argv[1], the first command-line argument after the script name. It writes the input inventory beside the sources and prints the result. The main guard prevents those effects when another Python file imports these functions.
Nothing here reserves equipment or sends telemetry. Printing these synthetic records is part of inspecting the fixture. Later instrumentation will teach which fields can safely enter telemetry; do not substitute real customer data.
Run, compare and explain
From the practice root, run each command separately:
.venv/bin/python scenario/desk.py baseline
.venv/bin/python scenario/desk.py unsupported
Both commands should print JSON and exit successfully. Inspect these values in the result; the table is an expected summary, not a live provider report:
| Result field | baseline | unsupported |
|---|---|---|
adapter_mode | synthetic-replay | synthetic-replay |
retrieved_ids | ["loan-period"] | ["loan-period"] |
loan_result.status | open | open |
response.max_days | 7 | 14 |
response.evidence_ids | ["loan-period"] | ["loan-period"] |
The fourteen-day answer contradicts the selected seven-day passage even though the document ID looks relevant and all functions completed. This program has no answer-quality gate yet. A successful process exit therefore proves only that this execution completed without an unhandled exception.
Open scenario/input-inventory.json. It records course-authored-synthetic,
synthetic-replay, desk-policy-1 and a 64-character SHA-256 string for each
source. Repeating either candidate without edits preserves these hashes.
Saving a file with different whitespace changes that file's digest; the digest
cannot tell whether its meaning changed. A version name such as desk-policy-1
is a declared label; the hash identifies the exact bytes that were present.
For a small guided variation, make a copy of your policy.json outside the
scenario as a backup. Add a blank line at its end, rerun baseline and inspect
the inventory. Only the policy-file hash should change; the authored answer
remains seven days. Restore the exact original file from your backup and rerun
to restore its digest. This illustrates byte identity, not a policy experiment.
Keep the backup only if useful; do not alter lending values to make the wrong
fixture appear correct.
| Different result | Diagnosis and next safe check |
|---|---|
FileNotFoundError for a fixture | Check the four saved files beside desk.py; the program reads from that source directory |
JSONDecodeError | Inspect JSON quotes, commas and brackets; decoding failure precedes response checking |
| “Choose baseline or unsupported” | Use exactly one of the two supplied fixture names |
Both profiles show the same max_days | Compare the command argument and the two stored response payloads |
| All hashes change unexpectedly | Check which copied source files, editor formatting or line endings changed; do not infer a semantic change from hashes alone |
Resume and reset
After closing the terminal, return to the practice root and run the same explicit interpreter/command. No process persists between these runs. To regenerate the inventory, rerun the program; it overwrites that file without appending records. Keep all four source files and the resulting inventory for later lessons. For a reset, restore edited source from the supplied contents and regenerate the inventory. Remove only your generated inventory or temporary backup if no longer needed; do not delete setup or source files to fix a wrong response.
Check Your Understanding
The unsupported profile selected loan-period, returned the correct fictional
loan record and cited loan-period, but answered fourteen days. Where is the
visible contradiction? Which boundary should you inspect first? Would rerunning
this fixture with different prompt wording establish that the prompt fixes it?
Answer and Reasoning
Hint 1
Read the selected passage's text as well as its ID. Compare that rule with both the numeric field and the sentence in the returned response.
Hint 2
The diagram marks the component that selects authored text. It accepts context without using that context to generate an answer.
Explained solution
The selected document permits at most seven days; both the response sentence and
max_days: 14 claim fourteen. Inspect the response/adapter boundary first: in
this supplied case it selected the wrong authored payload while the relevant
passage and expected loan result were available. That is a bounded diagnosis,
not proof that retrieval is always correct or that a real model caused the error.
Changing prompt wording cannot establish a fix because this replay adapter does not generate from the question or instructions. Changing its stored response would change the fixture. A real prompt comparison needs fresh outputs from a documented model run and suitable checks. Here the useful evidence is that process success and citation presence can coexist with a policy contradiction.
Sources and next use
The policy, records and replay answers are original fictional course inputs. Datasheets for Datasets motivates documenting data origins and use; this small inventory applies that idea without claiming to be a complete datasheet. CheckList supports behavior-focused checks. The next task will turn these observations into an explicit application contract. Python documents the JSON conversion, path operations and byte hashing used here.