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-m06(lab.faults,lab.agent,lab.retry,lab.ledger,lab.trials,lab.budget,lab.report) are allowed. Every task, student, run and number in the questions is fictional (simulated) data; none describes a real model, vendor or product. The quiz's own data: seed 23, operation keyq-op-9, the six hand-built runs of t02 in Q4, the made-up tasksqa,qb,qcand the casesg1tog3. In the code,F,A,RT,LG,T,B,Rarelab.faults,lab.agent,lab.retry,lab.ledger,lab.trials,lab.budget,lab.report;DPisRT.DEFAULT_POLICY.
Part A - Multiple choice (1 point/question)
Q1. Task t02 (return B004, then send a notice), configuration safe, seed 23, with the plan:
plan = [{"kind": "timeout", "target": "send_notice", "on": [1, 3], "effect": "after", "delay_ms": 3400},
{"kind": "tool_error", "target": "send_notice", "on": [2, 3]}]
The attempts of the send_notice call and the end state are:
- A. Attempts: TIMEOUT, TRANSIENT, TRANSIENT, duplicate; every rule fired; the ledger holds one notice
- B. Attempts: TIMEOUT, TRANSIENT, TIMEOUT, duplicate; every rule fired; the ledger holds one notice
- C. Attempts: TIMEOUT, TRANSIENT, TIMEOUT; out of attempts, outcome
loud_failure - D. Attempts: TRANSIENT, TIMEOUT, TIMEOUT, ok; the ledger holds two equal notices
Q2. Which policy does RT.validate_policy accept (return [])?
- A.
{**DP, "max_attempts": 11, "jitter": "full"} - B.
{**DP, "retry_on": ["TRANSIENT", "IDEMPOTENCY_CONFLICT"]} - C.
{**DP, "timeout_ms": 0, "base_ms": 300} - D.
{**DP, "max_attempts": 4, "reuse_key": False}
Q3. A task runs 12 times and succeeds 8 times. With k = 4:
- A. pass@4 = 494/495 and pass^4 = 14/99
- B. pass@4 = 1 and pass^4 = 14/99
- C. pass@4 = 494/495 and pass^4 = 16/81 (plug-in)
- D. pass@4 = 80/81 and pass^4 = 16/81
Q4. Six hand-built runs of t02 (configuration safe, seed 23, trials 0 to 5, well-formed run_id, all finished) have tokens [1500, 1500, 1520, 1480, 1500, 1490], costs [24, 25, 24, 26, 24, 24] cu and latencies [2300, 2500, 2450, 2600, 2550, 5200] ms. Budget {"max_tokens": 1520, "max_cost": 25, "p50_ms": 2500, "p95_ms": 5000}. B.check_budget returns for t02:
- A.
overis['OVER_COST', 'OVER_P50', 'OVER_P95'], with the warningP95_IS_MAX:t02 - B.
overis['OVER_TOKENS', 'OVER_COST', 'OVER_P95'], with no warning at all - C.
overis['OVER_COST', 'OVER_P95'], with the warningP95_IS_MAX:t02 - D.
overis['OVER_P95'], because ceilings apply to the mean run only
Q5. A report is built with R.build_report from 4 real runs of t04 (safe, seed 23), then edited in two places: its only fault row says "config": "naive", and the key t04 in budgets["rows"] is renamed to t01 (the row's content is kept). R.validate_report returns:
- A.
['BUDGET_PROBLEMS', 'CONFIG_MISMATCH'], because the budget lacks t04 - B.
['CONFIG_MISMATCH'], because the budget went throughcheck_budget - C.
[]; the gate will read both changes as findings - D.
['BUDGET_TASKS_DIFFER', 'CONFIG_MISMATCH']
Part B - True/False (1 point/question)
Q6. A.parse_action('{"args": {"book": "B003"}}') returns the error code NOT_JSON, because the action text lacks the tool field.
Q7. T.wilson(0, 5) has a lower bound of 0 and an upper bound above 0.4: five runs that all failed are still consistent with a task that succeeds more than 40% of the time.
Q8. With method="nist", the p50 of a list with an even number of values is the mean of the two middle values; for [2200, 2900, 2400, 3100, 2600, 2750] it is 2675.0, while the nearest rank gives 2600.
Part C - Calculation (3 points/question)
Q9. One operation called directly, without the agent:
from lab.clock import SimClock
from lab.tools import Library
pol = {**DP, "max_attempts": 3, "base_ms": 250, "cap_ms": 1000, "timeout_ms": 2000}
plan = [{"kind": "timeout", "target": "borrow_book", "on": [1, 2, 3], "effect": "after", "delay_ms": 4000}]
lib, clock = Library(), SimClock()
resp, att = RT.call(lib, "borrow_book", {"student": "S0107", "book": "B001"}, pol, clock, F.Injector(plan), "q-op-9")
Give (a) the result of each attempt, resp, and clock.now split into timeout waiting and backoff (1 point); (b) the number of rows in lib.ledger, the cu spent, and what student S0107 really has after the operation (1 point); (c) run it again with {**pol, "reuse_key": False} on a new Library: the number of rows in the ledger, the result of LG.duplicates, and why the caller sees only TIMEOUT on all three attempts although the server did different things (1 point).
Q10. Three made-up tasks run 15 times each: counts = {"qa": (15, 15), "qb": (15, 12), "qc": (15, 9)}. Give (a) pass^3 of each task and the pass^3 value of T.curve(counts, [3]), as fractions (1 point); (b) the pass@3 of T.curve and why it is close to 1 although qc succeeds only 9 times out of 15 (1 point); (c) with n = 15, the smallest number of successes c for pass^3 ≥ 0.5, and the Wilson lower bound of that c (1 point).
Part D - Analysis (3 points/question)
Q11. Task t01 (search, look at B005, borrow B005), seed 23, with the plan:
plan = [{"kind": "timeout", "target": "get_book", "on": [1], "effect": "before", "delay_ms": 3800},
{"kind": "rate_limit", "target": "borrow_book", "on": [1], "retry_after_ms": 1000}]
Give (a) the outcome of A.classify and F.unfired_rules for the four configurations naive, ignore_errors, retry_new_key, safe (1 point); (b) for safe: latency_ms, B.breakdown and the milliseconds caused by the two injected faults (1 point); (c) run safe with policy={**A.CONFIGS["safe"]["policy"], "timeout_ms": 4000}: the new latency, why a longer timeout makes this run slower, and what the naive run can say about the rate-limit fault (1 point).
Q12. A mutant of R.gate compares the target with the rounded pass^k value of the table, float(T.fmt(T.pass_hat_k(n, c, k))), instead of the exact fraction. A team's cases are three valid reports, one task each, with k = 2, min_pass_hat_k 0.6, min_wilson_low 0 and every other section clean: g1 (n, c) = (20, 16), g2 (20, 15), g3 (10, 8). Give (a) the cases whose decision differs between R.gate and the mutant (1 point); (b) whether these cases kill the mutant (1 point); (c) show that the case (67, 52) kills it: the exact pass^2, the value printed in the table, the decision under R.gate and under the mutant, and a real situation the case describes (1 point).