Module L3-M01 exercises: An agent architecture map with risk annotations for HocVui Assistant v2, from classification, a stop-condition test suite and a pattern comparison to a redacted trace

Study time
≈ 4 h (estimate)
Updated
2026-11-04
Draft · reviewed by AI, not yet by a person. Content may change. English translation: AI-assisted, not human-reviewed.
On this page

Estimated time: ~4 hours for someone who has finished the five independent exercises of L01-L05 (an estimate, not yet measured with real learners). Main tools: lab.classify, lab.tools, lab.loop, lab.planning, lab.trace, lab.archmap in code-labs/l3-m01. Every system, tool, policy, task, cost (cu, a pseudo cost unit) and result in the lab is simulated (deterministic functions written by the lab author): no model calls, no API key needed, and tools run only inside a temporary sandbox directory.

Main hands-on assignment

Business context

The HocVui team (fictional) is about to give HocVui Assistant a tool that sends a student's note to a teacher, so the new version is called HocVui Assistant v2. The previous owner left one line in the ticket: "this agent is safe, it has a step limit". That line does not say whether the agent is a workflow or an agent in which sense, which limit stops what, how the two planning patterns differ, whether the trace is enough to answer "what did it do", and how the new tool changes the risk map. You need to build an agent architecture map with risk annotations for v2 and the accompanying verification products: a workflow-or-agent label with reasons, a stop-condition test suite, a comparison of three patterns on the same tasks, a linted trace with secrets redacted, and one person's decision; then answer: what does this map tell you, and what does it not yet prove?

Problem to solve

A label can be wrong about what it says; a step limit does not catch semantic repetition and can leave a half-finished state; two patterns compared on nine tasks chosen by the question setter are not evidence about a real model; a trace that is clean under lint can still contain a tool that stored a raw secret; a map that passes the validator can still drift away from the code. Your job is to measure each part separately under the fixed configuration below, state what each part does not prove, and leave the final decision to one named person. Lints and validators only flag; the loop guard and the limits lint stop the run (fail closed); nothing approves.

Input data

The data is in code-labs/l3-m01/data/ (systems.json, tasks.json, kb.json, arch_example.json) and is fictional; do not edit lab/, data/ or exercises/. The v2 map starts from arch_example.json (HocVui Assistant) and adds one tool and one node.

The fixed configuration (so every submission is reproducible and comparable):

Item Value
Classification (Task 1) The 12 systems in systems.json (lab.classify); the two unclear cases are read with your own function
Ten tool calls (Task 1) Run in order, on ONE temporary sandbox (Sandbox) with call_tool: (1) calc {"expression": "(15+25)*3"}; (2) calc {"expression": "2**3"}; (3) calc {"expression": "1/0"}; (4) lookup {"key": " Số Chẵn "} (Vietnamese for "Even Number"); (5) notes_add {"name": "ban_nhap_2", "text": "ok"}; (6) notes_add {"name": "Ban-nhap", "text": "ok"}; (7) notes_read {"name": "chua_co"}; (8) tool name Notes_read with {"name": "ban_nhap_2"}; (9) calc {"expression": true}; (10) calc with raw parameters {"expression": "5", "expression": "6"}
Stop scenarios (Task 2) Ten scenarios with the Scripted policy (or a class that raises an error), each step costing 2 cu for the model call and 1 cu for calc or an unknown tool: (1) two calc then final, max_steps 9; (2) three calc then final, max_steps 4; (3) four calc then final, max_steps 4; (4) calc forever, budget 13, max_steps 9; (5) like (4), budget 14; (6) three unknown tools then final, error_limit 3; (7) two unknown tools, one calc, two unknown tools, final, error_limit 3; (8) five identical calc calls, loop_threshold 3; (9) action {"kind": "dance"}; (10) a policy that raises RuntimeError. The full_steps table for budgets 12, 13, 14, 15 and 40 (calc forever, max_steps 9). Loop guard checks with threshold 2: two calls {"expression": "2+3"} that differ in spaces, two calls 2+3 and 3+2, two parameter sets {"n": 1} and {"n": 1.0}, and four identical calls with state fingerprints f0, f1, f0, f1
Pattern comparison (Task 3) PL.run_task for the three patterns on the nine tasks in tasks.json, ten seeds p0 to p9; slip probability 0 and 1/5 with the default limits (8 steps, 40 cu); plus one run with probability 0 and max_steps 3
Trace (Task 4) react on t05 with Tracer("as-trace") (one transient error then success); a Scripted policy calling notes_add with the name lien_he and the text gọi cô Hoa hs07@lop5a.example, khóa sk-QWERTYUIO987, header Bearer z9x8c7v6b5 ("call Ms Hoa", "key") then final, with Tracer("as-secret"); four trace corruptions (see Task 4); three inputs for the blind spots of redact: name at example dot com, {"pass": "abc12345"}, gọi 0903 111 222 ("call")
Map (Task 5) arch_map.json = arch_example.json plus the node share_note (tool, permission network, approval human, side_effect true, observed_by trace_store), the node teacher_inbox (environment, untrusted), three edges (orchestrator->share_note, share_note->orchestrator, share_note->teacher_inbox) and at least two new risks (one for share_note, one for the edge share_note->teacher_inbox, both scoring 6 or more); stop_conditions 8 steps and 40 cu

Tasks

  1. Classification and the tool layer (L01). Write the function agent_properties_missing(spec) in mine.py: for a spec in which the model decides the next step, the sorted list of agent properties the spec lacks among (tools_chosen_by, repeats, feedback_to_model); [] means complete; ValueError when the spec is invalid (check_spec), does not use an LLM, or the code decides the next step. Report classify.md: the labels of the 12 systems with reasons and the count per label; for the two unclear cases, the missing list; a table of the ten calls (tool, raw parameters, ok, error code, content), the total cost, the number of write effects and the notebooks left in the sandbox; what this step does not prove.
  2. A stop-condition test suite (L02). Write the function full_steps(budget, tool_cost, max_steps, model_cost=2) in mine.py: the number of full steps (one model call and one tool call) that fit the budget and max_steps; ValueError when a parameter is not a real integer from 1 up (True, floats and 0 are rejected). Report stop_suite.md: a table of the ten scenarios (stop reason, steps, cost, tool calls, errors); the full_steps table next to the number of tool calls that actually ran; the loop guard check table (the allow result of each call and how to read it); three lint_limits lines; what this step does not prove.
  3. Comparing three patterns (L03). Write the function cost_per_success(runs) in mine.py: runs is a list of {"success": bool, "used": int}; return a Fraction (total cost of all runs divided by the number of successes), None when no run succeeds, ValueError when the list is empty. Report patterns.md: three tables (no slips; slip 1/5; no slips with max_steps 3) with the number of runs, success rate, model calls, average cost and cost per success (a fraction plus a decimal rounded half up using integers, no floats); each pattern's failing tasks with no slips and with max_steps 3; what this step does not prove.
  4. Traces and sensitive data (L04). Write the function report_mismatches(records, claimed_steps, claimed_reason) in mine.py: the sorted list of STEPS (the number of step spans differs from the claimed steps) and REASON (the stop_reason attribute of the run span differs from the claimed reason); ValueError when the trace does not have exactly one root run span. Report trace.md: the span tree, trace_id, summarize and the two lints of the react run on t05; the report_mismatches result for three claims (correct; one step overcounted; wrong stop reason); for the notebook write with a secret: the arguments attribute of the tool span, the raw notebook content in the sandbox and the conclusion; a table of four trace corruptions (a parent that does not exist on the third span, an end before the start on the third span, the second span never ended, password still in the attributes of the fourth span) with the lint_trace codes; a table of the three blind spots of redact; what this step does not prove.
  5. Architecture map and risks (L05). Write the function untested_risk_ids(m) in mine.py: the sorted ids of the risks whose test is empty or starts with untested (whitespace stripped, case-insensitive). Write arch_map.json per the configuration table and review.json (reviewed_by, decision, accepted_untested, reason from one person, not ci, bot or gate). Report map.md: the map size, validate_map and the declared-test coverage; the risk table by score; the list of risks with no test; the edges across the trust boundary with the risks pointing at them; the table of tool nodes against TOOL_SPECS; six map corruptions, one rule at a time (remove observed_by from calc, remove max_steps, share_note loses approval, the edge kb_content->lookup loses mitigation, remove the risk of the edge share_note->teacher_inbox, the risk of share_note loses all controls) with the validate_map codes; the person's decision; what this step does not prove.
  6. Reproduction. Write build_agent_map.py that generates the five reports in reports/ (every number comes from lab and mine, none typed by hand) and test_build_agent_map.py that checks the constraints AC1-AC5 on the text of the reports you generate. Write notes/decisions.md with exactly five entries: Classification and tools, Stop conditions, Pattern comparison, Traces and sensitive data, What the map does not check. The last entry answers: how far the map, the validator and these lints can be trusted, and what they cannot yet be used for.

Deliverables

agent_map/
  __init__.py                    (file rỗng)
  mine.py                        (Nhiệm vụ 1 đến 5: agent_properties_missing, full_steps, cost_per_success, report_mismatches, untested_risk_ids)
  arch_map.json                  (Nhiệm vụ 5)
  review.json                    (Nhiệm vụ 5)
  build_agent_map.py             (Nhiệm vụ 6; chạy: python -m agent_map.build_agent_map)
  test_build_agent_map.py        (Nhiệm vụ 6; chạy: python -m pytest agent_map)
  notes/
    decisions.md                 (năm mục: Phân loại và tool, Điều kiện dừng, So sánh mẫu, Trace và dữ liệu nhạy cảm, Điều bản đồ không kiểm)
  reports/                       (sinh bởi build_agent_map.py)
    classify.md                  (Nhiệm vụ 1)
    stop_suite.md                (Nhiệm vụ 2)
    patterns.md                  (Nhiệm vụ 3)
    trace.md                     (Nhiệm vụ 4)
    map.md                       (Nhiệm vụ 5)

Put the agent_map/ folder in code-labs/l3-m01 so that import lab works. Run from the lab folder. Use relative imports inside the package (from . import mine) so the tests run wherever the package is placed. Do not create or edit any file under .github/; run every tool only inside the temporary sandbox directory.

Acceptance criteria (required)

# Criterion How to check
AC1 agent_properties_missing is correct at the edges (on the data/systems.json systems where the model decides the next step, the result is [] if and only if lab.classify gives agent; three properties missing at once; ValueError for code that decides, no LLM, an invalid spec and the value 1 in place of True); classify.md has 12 label lines (by the rule rewritten in plain code), the line "Số theo nhãn: agent 3, not_llm_system 1, single_call 1, unclear 2, workflow 5." (Vietnamese for "Count per label"; keep this line exactly as written), two unclear lines (s09 missing feedback_to_model, repeats, tools_chosen_by; s10 missing repeats), ten call lines with the error codes -, -, DIV_ZERO, -, -, BAD_NAME, NOT_FOUND, UNKNOWN_TOOL, BAD_ARGUMENTS, BAD_JSON, a total cost of 12 cu, one write effect, the notebooks left ['ban_nhap_2'], and the what-it-does-not-prove part says the spec is self-declared python -m pytest agent_map; rewrite the classification rule in plain code (6 lines) and compare it with the 12 labels; derive each call's error code by hand in the check order of L01 §5.1, then compare with the report
AC2 full_steps is correct at the edges (12, 14 and 15 cu with calc give 4, 4, 5 steps; 40 cu is blocked by max_steps 9; budget 2 gives 0; a 2 cu tool and a 3 cu model change the result; ValueError for True, 0, floats, negative numbers); stop_suite.md has ten correct scenario lines (final 3 steps 8 cu; final 4 steps 11 cu; max_steps 4 steps 12 cu; budget 4 steps 12 cu; budget 5 steps 14 cu with only 4 tool calls; error_limit 3 steps 9 cu; final 6 steps 17 cu; loop_detected 3 steps 8 cu; two policy_error lines 1 step 2 cu), five full_steps table lines, four loop guard check lines (caught at the second call for the same parameters with different spaces; missed for 2+3 then 3+2 and for 1 then 1.0; [True, True, False, False] for a changing state), three lint lines, and the what-it-does-not-prove part says final does not mean the answer is correct python -m pytest agent_map; compute each scenario by hand from the price per step (3 cu per calc step) and the rule that the budget is checked before spending; compare the full_steps column with the tool calls that ran
AC3 cost_per_success is correct at the edges (no success gives None; the total cost of the failed runs too divided by the number of successes; an empty list gives ValueError); patterns.md has the configuration line (9 tasks, 10 seeds p0 to p9, limits 8 steps and 40 cu, slip probability 0 or 1/5, max_steps 3), three tables with exactly the simulation's numbers (no slips: direct 1/3, plan_execute 7/9, react 1; average cost 2, 73/9, 64/9; cost per success 6, 73/7, 64/9), each pattern's failing tasks (direct: t02, t03, t04, t07, t08, t09; plan_execute: t05, t06; react: none; at max_steps 3: direct as before, plan_execute: t03, t04, t05, t06, react: t04, t06), and the what-it-does-not-prove part says the difference is a consequence of how the simulated policies are written and that success and cost must be reported together python -m pytest agent_map; derive by hand each task's cost for the no-slip column (react: 5, 5, 8, 12, 8, 11, 5, 5, 5; plan_execute: 7, 7, 10, 14, 7, 7, 7, 7, 7); recount the slip columns and max_steps 3 with PL.run_task
AC4 report_mismatches is correct at the edges (correct; only the step count wrong; only the reason wrong; both; two run spans or none gives ValueError); trace.md has exactly the 9-line span tree of react on t05 (run [1-21] ok through model [17-19] ok final; the thought event is written before the model span closes), summarize (3 steps, 2 tool spans, 1 error, 20 ticks, final), two empty lints, three claims giving [], ['STEPS'], ['REASON'], the arguments attribute redacted in all three places, the raw notebook content, the sentence saying the tool stored sensitive data, the codes of the four trace corruptions (ORPHAN_SPAN:sp-003; CLOCK_BACKWARDS:sp-003 together with EVENT_OUTSIDE_SPAN:sp-003; UNENDED_SPAN:sp-002; SENSITIVE_LEFT:sp-004.attributes.password), the three blind spots of redact all unchanged, and the what-it-does-not-prove part says a structural lint does not know the content and the clock is a logical counter python -m pytest agent_map; count the spans and ticks of the tree by hand (each start or end of a span, an event or a log adds one tick); rewrite the redaction pattern with re and check the three blind spots
AC5 untested_risk_ids is correct at the edges (untested: in capitals and with leading whitespace, an empty test, a missing test key; combined with the number of risks it gives the right lab.archmap coverage); arch_map.json passes validate_map, has share_note and teacher_inbox as in the configuration table, at least 10 risks with unique ids, one risk pointing at edge:share_note->teacher_inbox, at least two risks scoring 6 or more with a control, every untested: entry has a reason of three words or more, every declared test has a real function in tests/, the tool nodes other than share_note match TOOL_SPECS, declared-test coverage not below 1/2; map.md has a risk table in the right order (score descending, then id), the list of untested risks, three boundary edges with their risks, four "matches" lines and a share_note line "not comparable" (Vietnamese "không so được"), six validate_map codes for the six corruptions, the sentence that the accepted list matches, and the what-it-does-not-prove part; review.json has reviewed_by as one person, a decision, a reason of ten words or more and accepted_untested equal to exactly untested_risk_ids python -m pytest agent_map; run validate_map, risk_table, test_coverage; recompute the scores (severity times likelihood) and the list of edges across the trust boundary with code of your own; the grader reads the decision against the rubric
AC6 Rerunning python -m agent_map.build_agent_map produces exactly the five reports (byte for byte, for example with diff), with no timestamp, Python version or CR character; every report has a Cấu hình: line (Vietnamese for "Configuration:"; keep this label exactly as written) and says it is a simulation; python -m pytest agent_map passes; notes/decisions.md has all five entries in the right order, every fraction in it appears in the reports, and the last entry names what the map does not check run twice and compare; the grader reads decisions.md against the rubric

Grading rubric (100 points)

Dimension 0 1 2 3 Weight
Classification and tools (AC1) Does not meet AC1 Has labels but no reasons or no missing list for the two unclear cases Meets AC1; reads s10 correctly as missing only a real loop and s09 as missing all three properties As level 2, and states that the label says only who decides the next step and not the risk level, that the spec is self-declared, that Notes_read is rejected at the name check before the parameters, and that only one of the ten calls writes to the sandbox 15
Stop conditions (AC2) Does not meet AC2 Has the scenario table but no hand calculation or no edges Meets AC2; reads correctly that final at the last step differs from max_steps right after it, and that budget 14 differs from 15 As level 2, and explains why budget 14 gives 5 steps started but only 4 tool calls run (the fifth step has only a model call), the loop guard check missing 2+3 then 3+2, and that stopping midway leaves a half-finished state 20
Pattern comparison (AC3) Does not meet AC3 The table has only one number (success or cost) Meets AC3; reports success and cost together, with the numerator and denominator As level 2, and states that ten seeds are not 90 pieces of evidence, that the difference is a consequence of how the policies are written, that max_steps 3 changes both patterns (plan_execute 5/9, react 7/9) and that it recommends no pattern 15
Traces and sensitive data (AC4) Does not meet AC4 Has a trace but no lint or the claims are not checked Meets AC4; the trace is lint-clean and report_mismatches catches the wrong claims As level 2, and states that the tool stored the raw copy even though the trace is clean, the three blind spots of redact, that the lint does not know the content, and that the difference of two ticks is not real time 15
Risk map (AC5) Does not meet AC5 The map does not pass the validator or the decision says ci Meets AC5; the decision has a name, a reason and an accepted-risk list that matches As level 2, and states that coverage 1/2 counts only declared tests, that share_note is not in the lab so its permission is only a claim, that the eight risk categories have no "data leaving the sandbox" category, and that risks with no test are work for later modules 20
Reproduction and notes (AC6) Does not meet AC6 Reports typed by hand or not saying they are simulated A script generates every report, a rerun gives identical files, and tests run on the text of the reports As level 2, and the tests catch deliberate faults (change the seed prefix, change 1/5 to 1/4, swap two of the calls, remove approval from share_note, remove the risk of the edge share_note->teacher_inbox, change the reviewer to ci), and decisions.md is honest that every number is simulated 15

Each dimension's score = (level reached / 3) × weight. Mapping to the module: practical = Classification and tools + Stop conditions + Reproduction and notes (50); applied QA analysis = Pattern comparison + Traces and sensitive data + Risk map (50).

Hints

Hint 1: classification and toolsUse `check_spec` to validate the spec before reading the three fields; a spec is an `agent` exactly when all three properties are present, so `[]` and the label `agent` go together. For the ten calls, follow the check order of L01 §5.1: exact name match, strict JSON (a duplicate key is `BAD_JSON`), correct keys and correct types (`true` is not a string), and only then the tool body. `Notes_read` never reaches the parameter step. Call `call_tool` on the same `Sandbox` so the write effects and the remaining notebooks belong to all ten calls.
Hint 2: stop scenariosEach step checks the budget **before** spending: a step starts when `used + 2` still fits, a tool call runs when `used + tool price` still fits. With budget 14: four steps use 12, the fifth step starts (12 + 2 = 14) but `calc` would push the total to 15 so it does not run. A `final` at exactly the `max_steps` step is still `final` because the final answer is considered before `max_steps`. The loop guard counts over the whole run per (call key, state fingerprint): use **one** `LoopGuard` for the whole sequence of calls, do not create a new one for each call.
Hint 3: pattern comparison`cost_per_success` divides the total cost of all runs (the failed ones too) by the number of successes; use `Fraction` and return `None` when there is no success. To round a decimal using integers, compute `(x * 100 * 2 + 1) // 2` and then divide by 100. Keep the seeds, limits and tasks fixed for every pattern; changing `max_steps` is a different comparison, recorded separately. The no-slip table can be checked by hand: each step is a 2 cu model call plus a tool of 1 or 2 cu.
Hint 4: trace`report_mismatches` counts spans named `step`, not tools; the `stop_reason` attribute is on the `run` span. For the secret, read `sb.notes_dir` to see the raw copy and read the `arguments` attribute of the tool span to see the redacted one. Do each trace corruption on a **deep copy** so the corruptions do not accumulate. Do not put the Python version or a timestamp in the report.
Hint 5: mapStart with `copy.deepcopy` of `arch_example.json`. Run `validate_map` after each addition: `share_note` needs `approval`, a risk pointing at it (`SIDE_EFFECT_TOOL_NO_RISK`) and a risk pointing at the edge `edge:share_note->teacher_inbox` (an edge between a trusted and an untrusted node). A score of 6 or more needs at least one control. An `untested:` entry needs a concrete reason, and weigh the coverage of 1/2 before declaring more untested risks. The `accepted_untested` list is signed by the person who decides; for it to match `untested_risk_ids` you must compute that list, not type it by hand.
Hint 6: check your own testsOnce the tests are green, try changing the seed prefix `p`, changing 1/5 to 1/4, swapping two calls among the ten, removing `approval` from `share_note`, deleting the risk of the edge `share_note->teacher_inbox`, setting `reviewed_by` to `ci`, or letting `build_agent_map.py` write a timestamp: if the tests stay green, they are only comparing the report with itself. A good test compares against a number **derived independently** (a hand calculation, a rule rewritten in plain code), not against the output of the function under test.

Independent challenge (practical challenge)

Less guidance. No lab data is needed for tasks 1 and 5 beyond the lab's functions (lab.classify, lab.tools, lab.archmap) or hand calculation from the tables below; task 3 uses lab.planning with data/tasks.json; task 2 uses lab.loop with the Scripted policy; task 4 uses lab.trace and your report_mismatches function. Submit one file challenge.md.

Context: SachMo (fictional) is a class library assistant: it finds books by topic and records borrowed books on a slip. A team of two wants an architecture map of SachMo before writing tests, after they already have the HocVui toolkit. The rule for every comparison: every rate and average cost is computed as a fraction (no floats); a value exactly at the edge is handled by the lab's rule (a budget used up exactly is valid, a loop guard threshold is the count at which it rejects, final at the last step is still final). The systems, tasks and names below are fictional data and do not describe a real system or person.

Tasks:

  1. Classification. Six systems (fields in the order uses_llm, next_step_chosen_by, branch_by_model, tools_chosen_by, repeats, feedback_to_model): Z1 (true, code, true, code, no, false) "the model picks one of three request types and then code runs a fixed path"; Z2 (true, model, false, model, until_model_signal, true) "the model picks a book-search tool, reads the result and reports when done"; Z3 (true, code, false, none, no, false) "one model call fills in the slip"; Z4 (true, model, false, code, until_model_signal, true) "the model decides the next step but code always chooses the tool"; Z5 (false, code, false, code, no, false) "a weekly report by script"; Z6 (true, model, false, model, until_code_condition, false) "the model picks tools and loops until code stops it, but tool results are only written to the log, not fed back to the model". (a) The label of each system and, for the unclear cases, the agent_properties_missing list. (b) The smallest one-field change that turns Z4 and Z6 into agent. (c) Nine calls in order on one sandbox: calc {"expression": "7*(8+2)"}; lookup {"key": "SỐ chẵn"}; notes_add with name muon_sach_1 and a text of 201 x characters; notes_read {"name": ""}; calc {"expression": "10**9"}; calc {"expression": "12*3"} (full-width digits); lookup {"key": "số"}; notes_add {"name": "a", "text": "x", "extra": 1}; notes_add {"name": "muon_sach_1", "text": "Nam mượn 2 sách"} ("Nam borrowed two books"): the error code or ok of each call, the total number of write effects and the notebooks left.

  2. Stop conditions. Six Scripted scenarios (each step is a 2 cu model call, calc 1 cu, notes_add 2 cu, an unknown tool 1 cu): (a) three calc then final, max_steps 3; (b) eight different calc, budget 20, max_steps 9; (c) notes_add with three different names n1, n2, n3 then final, budget 11, max_steps 9; (d) two unknown tools, one calc, two unknown tools, final, error_limit 2; (e) six identical calc calls {"expression": "4*4"}, loop_threshold 4; (f) action plan then one calc then final, max_steps 2. For each scenario: (stop reason, steps, cost) and the notebooks left. Then: lint_limits for (5, 1), (0, 0) and (4, 10, 3, 1); and LoopGuard(3) with the following seven calc calls (key, fingerprint): {"expression": "2+2"} f0; {"expression": "3+3"} f0; {"expression":"2+2"} f0; {"expression": "2+2"} f1; {"expression": "3+3"} f0; {"expression":"2+2"} f0; {"expression": "2+2"} f0: the index (from 1) of the first call that is rejected and why the fourth call is not.

  3. Plans and patterns. (a) The lint_plan codes of six plans (each step lists tool and JSON parameters): K1 lookup {"key": "diện tích hình vuông"} ("area of a square"), calc {"expression": "7*7"}, notes_add {"name": "dt", "text": "{calc} và {lookup}"} ("and"); K2 calc {"expression": "2+2"} twice then notes_add {"name": "kq", "text": "{calc}"}; K3 tool browser {"url": "x"} then calc {"expression": "1+1"}; K4 seven calc steps {"expression": "1+1"}, 2+2, ... 7+7; K5 notes_add {"name": "a", "text": "{lookup}"} then lookup {"key": "số chẵn"} ("even number"); K6 calc {"expression": "1+1"} then notes_add {"name": "a", "text": "{sum}"}; plus the code of a one-step plan whose parameters are {"expression": "1+1" (missing }). (b) compare_patterns on three tasks t01, t05, t08, six seeds c0 to c5, slip probability 0 and 1/3, default limits, then probability 0 with max_steps 2: each pattern's success rate and average cost (fractions), success by task. (c) Each pattern's cost per success in the first comparison (no slips) and in the max_steps 2 comparison, with None if there is no success; why direct is cheapest on this task set and why that does not make it the choice; and two sentences for the SachMo product owner (someone who just wants to hear "which pattern to use") stating what is known and what is not.

  4. Trace. The following six records are a simulated trace of a two-step run (corrupted in three places):

    {"type": "span", "trace_id": "tr-508e5f0e", "span_id": "sp-001", "parent_id": null, "name": "run", "kind": "run", "start": 1, "end": 12, "status": "ok", "attributes": {"task": "c", "max_steps": 8, "budget": 40, "stop_reason": "final", "steps": 2, "used": 5}, "events": []}
    {"type": "span", "trace_id": "tr-508e5f0e", "span_id": "sp-002", "parent_id": "sp-001", "name": "step", "kind": "step", "start": 2, "end": 7, "status": "ok", "attributes": {"step": 1}, "events": []}
    {"type": "span", "trace_id": "tr-508e5f0e", "span_id": "sp-003", "parent_id": "sp-002", "name": "model", "kind": "model", "start": 3, "end": 4, "status": "ok", "attributes": {"cost": 2, "action": "tool_call"}, "events": []}
    {"type": "span", "trace_id": "tr-508e5f0e", "span_id": "sp-004", "parent_id": "sp-009", "name": "tool", "kind": "tool", "start": 5, "end": 6, "status": "ok", "attributes": {"tool.name": "calc", "arguments": "{\"expression\": \"9+9\"}", "cost": 1, "api_key": "k-1234"}, "events": []}
    {"type": "span", "trace_id": "tr-508e5f0e", "span_id": "sp-005", "parent_id": "sp-001", "name": "step", "kind": "step", "start": 8, "end": 11, "status": "ok", "attributes": {"step": 2}, "events": []}
    {"type": "span", "trace_id": "tr-508e5f0e", "span_id": "sp-006", "parent_id": "sp-005", "name": "model", "kind": "model", "start": 10, "end": 9, "status": "ok", "attributes": {"cost": 2, "action": "final"}, "events": []}
    

    (a) The lint_trace codes. (b) The smallest fix for each code that keeps the ids, names and number of records, then lint_trace after the fix. (c) report_mismatches for three claims: (2, final), (3, final), (2, max_steps). (d) Point out what a clean lint after the fix still does not say about this trace (two things) and why k-1234 being redacted does not mean the secret was never stored somewhere else.

  5. Map. The SachMo map (8 nodes, 10 edges, 3 risks, stop_conditions with only max_steps 10). Nodes: reader (human, untrusted); orchestrator (orchestrator, trusted); model (model, trusted, observed_by log_store); find_book (tool, trusted, read, observed_by log_store); loan_add (tool, trusted, write, side_effect true, approval none_sandbox_only, no sandboxed, observed_by log_store); catalog (external_content, untrusted); loan_sheet (environment, trusted); log_store (observability, trusted). Edges (none has a mitigation): reader->orchestrator, orchestrator->model, model->orchestrator, orchestrator->find_book, find_book->orchestrator, orchestrator->loan_add, loan_add->orchestrator, loan_add->loan_sheet, catalog->find_book, orchestrator->log_store. Risks: K1 (target loan_add, excessive_agency, severity 2, likelihood 3, one control, test tests/test_loan.py::test_rows_stay_in_the_sheet); K2 (target model, silent_failure, 3 and 3, no control, test untested: no end-state oracle yet); K3 (target edge:reader->orchestrator, direct_prompt_injection, 2 and 2, one control, empty test). (a) The validate_map codes and the declared-test coverage. (b) The list of smallest changes that make validate_map return empty (one change per line). (c) The declared-test coverage after your changes if K1 keeps its real test, K3 and every new risk is untested: with a reason; which risk should get a test first and why. (d) Three sentences for the SachMo product owner: what the map tells you, what it does not yet prove, what to do before adding a real write tool; and which person decides to accept a risk with no test.

Challenge rubric (100 points, pass at ≥ 70):

Dimension 0 1 2 3 Weight
Classification (task 1) Missing One of (a) to (c) correct All three correct, including the missing list of the two unclear cases and the error codes of the nine calls As level 2, and states clearly that Z4 and Z6 each lack exactly one property, that the lookup call số returns a "did you mean" hint and not a name error, and that only one call writes to the sandbox 15
Stop conditions (task 2) Missing Two scenarios or fewer correct All six scenarios, three lint lines and the index of the rejected call correct As level 2, and states clearly why final at step 4 of scenario (a) does not happen (step three already reached max_steps), that plan costs one step with no tool (scenario (f)), and that the fourth loop guard call is not blocked because the fingerprint changes 25
Plans and patterns (task 3) Missing One of (a) to (c) correct All three correct, including None for plan_execute at max_steps 2 As level 2, and states clearly that direct is cheapest because the three small tasks were chosen in advance, that 18 runs are not 18 pieces of evidence, and that the two sentences for the product owner promise nothing the simulation does not prove 20
Trace (task 4) Missing Two of (a) to (d) correct All four correct As level 2, and states clearly that a clean lint does not know the content of the tool or whether the tool really ran, and that the secret may still be in the tool, the notebook or elsewhere 20
Map (task 5) Missing Two of (a) to (d) correct All four correct, including coverage 1/3 before and 1/4 after As level 2, and states that K2 with score 9 should get a test first, that coverage counts only declared tests, and that a person and not the validator accepts the risk 20

Rules

  • Do not use real data or real APIs in your submission. The systems, tools, tasks, costs and every number in the lab are simulated; do not infer the behaviour of a real model, vendor, framework or product.
  • Do not edit lab/, data/ or exercises/. Propose changes in notes/decisions.md.
  • Every tool runs only in the lab's temporary sandbox directory; do not run shell commands, network access or files outside it. Every real-world effect needs a person to approve it.
  • Do not change the seeds, limits, budgets, edges or task lists after seeing the results in order to reach a wanted conclusion; if you change them, record the reason and the results from before the change.
  • Every number in a report comes from a script; state the configuration (tasks, seeds, limits, slip probability). Do not let a lint, validator or loop guard stand in for reading the reports and the trace.
  • Lints and validators only flag; the loop guard and the limits lint stop the run; a person reviews and decides the thresholds and every real-world effect. Do not create or edit any automatically running workflow.