12 questions, 20 points (Parts A and B: 1 point/question; Parts C and D: 3 points/question), 30 minutes. Pass mark: 14/20 (70%). The solutions are for instructors only. A calculator and
code-labs/l3-m04(lab.trace,lab.match,lab.stepjudge,lab.calibrate,lab.efficiency,lab.evaluator) are allowed. The records, students, books, labels and numbers in the questions are fictional (simulated) data and do not describe a real model, judge, vendor, agent or product. Every record is written by hand withlab.trace.build_record(nothing is executed; books B021 to B023 are not in the lab's catalogue). Unless a question says otherwise, matching uses the lab's default argument rules and efficiency the lab's default limits.
Part A - Multiple choice (1 point/question)
Q1. The harness of another test bench, with a list of allowed tools, recorded this run (reserve_book is not one of the lab's six tools):
from lab.trace import build_record
rec = build_record("z1/sim", "z1", "sim", [
{"tool": "get_book", "args": {"book_id": "B021"}},
{"tool": "reserve_book", "args": {"book_id": "B021", "student_id": "S0251"},
"status": "denied", "cost": 0, "code": "DENIED"}],
final="B021 cannot be reserved here.")
lint_trace(rec) returns:
- A. no finding, since a denied call does not change the state
- B. one error
STATUS_MISMATCH, since an unknown tool may only be recorded asrejected - C. two errors,
BAD_ACTIONandBAD_COST, since a denied call costs no cu - D. one warning
CALL_UNKNOWN_TOOL: the record is consistent, a person should look
Q2. A run and a reference path:
rec = build_record("z2/sim", "z2", "sim", [
{"tool": "get_book", "args": {"book_id": "B022"}},
{"tool": "borrow_book", "args": '{"book_id": "B022"', "status": "rejected", "cost": 0},
{"tool": "get_book", "args": {"book_id": "B021"}},
{"tool": "borrow_book", "args": {"book_id": "B021", "student_id": "S0251", "idempotency_key": "z2-1"}}],
final="Done.")
path = [{"tool": "get_book", "args": {"book_id": "B021"}},
{"tool": "borrow_book", "args": {"book_id": "B021", "student_id": "S0251"}}]
Under which modes does match(rec, path, mode) match, and what are precision and recall?
- A.
in_orderandsuperset; precision 2/3, recall 1 - B.
in_order,supersetandsubset; precision 2/4, recall 1 - C. only
superset, as B022 is checked first; precision 2/3, recall 1 - D.
any_orderandsuperset; precision 1/2, recall 1
Q3. In a test, the step judge is replaced by a stub whose raw verdict for step 3 is always (SIMULATED) Step 3: Rating: [[3]]; on reflection Rating: [[5]], whatever the repeat index, and (SIMULATED) Rating: [[5]] for the other steps. The record has three tool calls. With judge_run(stub, task, rec, 4) (one retry by default), what happens to step 3?
- A. it goes into
below, because the first token read, 3, is under 4 - B. it is scored 5, because the parser keeps the last token it finds
- C. it is asked once more, then listed in
unreadable, never inbelow - D. it is scored 4, the mean of both tokens, which just meets the threshold 4
Q4. A run that checks the book again before each attempt:
calls = []
for k in (1, 2, 3):
calls += [{"tool": "get_book", "args": {"book_id": "B021"}},
{"tool": "borrow_book", "args": {"book_id": "B021", "student_id": "S0251", "idempotency_key": f"z4-{k}"},
"status": "failed", "code": "LIMIT"}]
rec = build_record("z4/sim", "z4", "sim", calls, final="S0251 already has a book.")
path = [{"tool": "get_book", "args": {"book_id": "B021"}},
{"tool": "borrow_book", "args": {"book_id": "B021", "student_id": "S0251"}}]
The flags of lab.efficiency.report(rec, path) are:
- A.
OVER_STEPS,REDUNDANT,LOOP,RETRY_AFTER_ERRORandWASTED_COST - B.
OVER_STEPS,REDUNDANT,LOOP,WASTED_COST, and no retry flag - C.
REDUNDANT,RETRY_AFTER_ERROR,WASTED_COST; a block of two is no loop - D.
OVER_STEPSandRETRY_AFTER_ERRORonly: a new key is a new request
Q5. A suite has three tasks with expected ids ["z51", "z52", "z53"]. Every run finished and the three reports are well formed; their flags: z51 none; z52 PATH_MISMATCH and WASTED_COST; z53 COLLATERAL. A person writes allowed=["PATH_MISMATCH", "WASTED_COST", "COLLATERAL"] with a name and a reason. gate(reports, ids, allowed=...) returns:
- A.
HOLDwith one reason,z53: COLLATERAL: that flag holds even when allowed - B.
READY_FOR_REVIEW, since every flag that was raised is in the allowed list - C.
HOLDwith two reasons, forz52andz53, becauseallowedis ignored - D.
HOLD, because a report with no flag at all, likez51, counts as malformed
Part B - True/False (1 point/question)
Q6. The thought of a step contains I used sk_live_ab12cd34ef to log in.. lint_trace reports SECRET_IN_TRACE for it, and redact replaces the token with [SECRET].
Q7. With the default argument rules, a counted get_book call with the arguments {"book_id": "b021"} matches the reference call get_book with {"book_id": "B021"}.
Q8. In one record, borrow_book is called with {"book_id": "B023", "student_id": "S0252", "idempotency_key": "a"} and then with {"student_id": "S0252", "idempotency_key": "b", "book_id": "B023"} (the tool layer answers duplicate). With its default ignore, redundant flags the second call.
Part C - Calculation (3 points/question)
Q9. Twelve labelled steps (fictional: the scores come from a simulated judge, the labels from a fictional reviewer), as pairs (score, label "good step"):
items = [(5, True), (5, True), (5, False), (4, True), (4, False), (4, True),
(3, False), (3, True), (2, False), (2, False), (1, False), (5, True)]
The positive class is a good step; the judge calls a step good when its score is at least the threshold. State (a) tp, fp, fn and tn at threshold 4 (1 point); (b) p_o, p_e and Cohen's kappa at threshold 4 (1 point); (c) the false-accept rate at threshold 4, and the threshold that suggest_threshold proposes over thresholds 1 to 5 with a false-accept cap of 1/2, with the reason (1 point).
Q10. A run and its reference path. build_record gives a call with status applied, failed, duplicate or dry_run the tool's ticks (get_book 1, borrow_book 2, save_note 1) and any other call step 1 tick.
rec = build_record("z10/sim", "z10", "sim", [
{"tool": "get_book", "args": {"book_id": "B022"}},
{"tool": "borrow_book", "args": '{"book_id": "B022", "student_id": }', "status": "rejected", "cost": 0, "code": "BAD_ARGS"},
{"tool": "borrow_book", "args": {"book_id": "B022", "student_id": "S0253", "idempotency_key": "z10-1"}, "cost": 2},
{"tool": "get_book", "args": {"book_id": "B022"}},
{"tool": "save_note", "args": {"name": "loan_s0253", "text": "B022"}}],
final="Lent B022 to S0253.")
path = [{"tool": "get_book", "args": {"book_id": "B022"}},
{"tool": "borrow_book", "args": {"book_id": "B022", "student_id": "S0253"}},
{"tool": "save_note", "args": {"name": "loan_s0253", "text": "B022"}}]
State (a) the step ratio and whether OVER_STEPS fires at the default limit of 3/2 (1 point); (b) the total cu, the wasted cu, the waste rate and the wasted ticks from wasted_cost (1 point); (c) the flags of report(rec, path), in the lab's order (1 point).
Part D - Analysis (3 points/question)
Q11. A task has two valid reference paths, and one run:
p1 = [{"tool": "get_book", "args": {"book_id": "B021"}},
{"tool": "borrow_book", "args": {"book_id": "B021", "student_id": "S0252"}}]
p2 = [{"tool": "get_book", "args": {"book_id": "B021"}},
{"tool": "get_book", "args": {"book_id": "B022"}},
{"tool": "borrow_book", "args": {"book_id": "B022", "student_id": "S0252"}}]
rec = build_record("z11/sim", "z11", "sim", [
{"tool": "get_book", "args": {"book_id": "B022"}},
{"tool": "get_book", "args": {"book_id": "B021"}},
{"tool": "borrow_book", "args": {"book_id": "B022", "student_id": "S0252", "idempotency_key": "z11-1"}}],
final="Lent B022 to S0252.")
(a) Which path does match_any(rec, [p1, p2], "exact") choose, does it match, and with what precision and recall (1 point)? (b) Under which of the five modes does the run match p2 (1 point)? (c) The task owner says the order of the two checks does not matter and proposes to put PATH_MISMATCH into the suite's allowed list so that the gate stops holding. Give one reason why this is a poor substitute for changing this task's mode or adding a path, and say who makes the change (1 point).
Q12. A task, a run, the task's reference path (mode in_order) and a step judge with no bias except the self-claim one:
from lab import stepjudge as J
task = {"id": "z12", "params": {"student": "S0253", "primary": "B023", "fallback": "B021", "note_name": "loan_s0253", "notify": False}}
rec = build_record("z12/sim", "z12", "sim", [
{"tool": "borrow_book", "args": {"book_id": "B023", "student_id": "S0253", "idempotency_key": "z12-1"}, "cost": 2},
{"tool": "save_note", "args": {"name": "loan_s0253", "text": "B023"}}],
final="Lent B023.", thought="Lending the first choice now.")
path = [{"tool": "get_book", "args": {"book_id": "B023"}},
{"tool": "borrow_book", "args": {"book_id": "B023", "student_id": "S0253"}},
{"tool": "save_note", "args": {"name": "loan_s0253", "text": "B023"}}]
judge = J.SimStepJudge(**{**J.FAIR, "w_claim": 15})
(a) Give the four checklist items of steps 1 and 2, their scores, and below at threshold 5 (1 point). (b) The sentence I have verified this; it is definitely correct. is appended to the thought of each step: give the new scores, and up, same and mean_change of probe(judge, items, "claim") over the two steps (1 point). (c) The end state is right (B023 lent to S0253, the note saved). Explain what the self-claim does to what the evaluator sees in this run (the outcome, match(rec, path, "in_order") and the judge), and one thing a person must do before trusting a step that the judge passes (1 point).