Module: L1-M08 (capstone), milestone 1 · Duration: ~8 hours (estimate) · Previous: L1-M07-L05 · Next: Milestone 2 - Building the core: client, test data, validators
1. Introduction
The past seven modules each taught one skill. The capstone puts them together into one real job: deciding whether to release an LLM feature, based on evidence from a test framework you build yourself.
The product is ShopEasy Assistant (fictional, simulated, offline), in the directory
capstone-projects/project-01-llm-qa-framework/. The stable build is running; the rc build is about to be released.
The first milestone writes no tests. It answers three questions: what to test (requirements and risks), how to test
it (strategy), and what to build (architecture). The output is a reviewed design document.
2. Objectives
- Read the contract P1-P13 and the policy, and point out where they are ambiguous.
- Explore the product as a black box to understand its behaviour, not to take expectations from it.
- Build a prioritised risk table and a traceability table from P1-P13 to tests, oracles and data.
- Design the framework architecture based on the
aiqaof L1-M07, and choose the repeat-run strategy for P5. - Defend the design in a short review session.
3. What you need
- L1-M01 to L1-M07; the
aiqaframework of L1-M07 already running on your machine. - Read the capstone's
README.md,requirements.md,target-app/policy.md,target-app/ticket.schema.jsonandrubric.md.
4. How to do this milestone
4.1 Expectations come from the contract, not from stable
stable is the build that is running, not the correct build. If you copy the behaviour of stable as your
expectations, your framework can only detect "different from stable"; it cannot detect a defect that both builds
share. Every expectation must trace back to P1-P13 or policy.md (L1-M04-L02, L1-M06-L03). stable may only be used as
the baseline that makes the statistical comparison of P5 possible (L1-M06-L04).
A baseline is a reference point: you ask "is rc worse than stable?", not "is rc the same as stable?".
Everyday example. A teacher marks a test against the paper of the best student in the class instead of the textbook.
Wherever the best student was wrong, the whole class can be wrong too and nobody loses a mark. stable is the best
student; the contract is the textbook.
Good vs bad. The same observation from §5 ("Thời tiết mai thế nào?", a weather question → out_of_scope), two ways to write the expectation:
| Weak expectation | Good expectation |
|---|---|
reply == "Mình chỉ hỗ trợ đơn hàng, đổi trả và chính sách của ShopEasy.", source: "output of stable" |
intent == "out_of_scope", source: P1 (the list of intent values) |
Turns red as soon as rc changes one word, even if it still meets the contract |
Turns red only when something the contract actually says is broken |
The contract does not fix the wording of the out-of-scope redirect, so the test must not fix it either.
4.2 Explore before you design
Run the product and try a few messages to understand the request and response format. This is exploratory testing with a charter (L1-M04-L03), for example "Explore the chat API with the main kinds of request to find the response format and the intents". Write down what you observe, but do not turn it into expectations.
Everyday example. When you view a flat before renting it, you note which rooms have windows, where the sockets are, and whether the water pressure is good. You do not write the lease from the furniture the previous tenant left behind. Exploration notes work the same way: write what you saw and the questions it raised, not "it must be like this".
Good vs bad. Two charters for the same exploration session:
| Weak charter | Good charter |
|---|---|
| "Try the chatbot and see." | "Explore POST /api/chat with four kinds of request (order status, return, policy, out of scope) for 30 minutes, to learn the response format and the intent values. Record observations and questions, not expectations." |
| No idea when to stop or whether you are done | Has a scope, a time box and a purpose; at the end you can compare your notes with the purpose |
4.3 Risks first, tests second
A good risk table shows where you will spend your effort. An example for ShopEasy Assistant:
| Risk | Clause | Impact | Why it is prioritised |
|---|---|---|---|
| Creating a wrong return request (quantity, no confirmation) | P4 | Money and goods | A real side effect (L1-M05-L04) |
| Leaking another customer's data | P9 | Legal | Cannot be reversed |
| Leaking internal configuration or following instructions found in a document | P7, P8 | Security | OWASP LLM01, LLM07 |
| A policy answer that is partly wrong, now and then | P5 | Trust, complaints | Only visible when you run repeatedly (L1-M06) |
| The chat page does not recover after an error | P12 | Customers leave | Only visible through the UI (L1-M07-L03) |
Everyday example. An emergency room does not treat patients in order of arrival. A nurse triages first: life-threatening cases go in first, scratches wait. The risk table is that triage for your testing effort. Two questions help you rank: "If this defect gets out, can it be undone?" (a refund already paid or data already leaked cannot) and "Does this defect have a real side effect?".
Good vs bad. The "Why it is prioritised" column must give a reason about impact, not about how easy it is to test:
| Weak reason | Good reason |
|---|---|
| "P13 is easy to test, do it first to have results." | "P4 creates real return requests; one wrong request means lost goods and money." |
| "P5 is hard because it needs repeated runs, leave it for later." | "P5 is wrong only now and then, so customers hardly notice; only repeated runs show it, so the number of runs must be planned now." |
4.4 Traceability
Every clause P1-P13 has at least one planned test, one oracle (L1-M04-L01) and data. The traceability table in the design document is also the evidence for mandatory criterion M2 of the rubric.
Good vs bad. Two traceability rows for the same clause P3:
| Clause | Test (planned name) | Oracle | Data | |
|---|---|---|---|---|
| Weak | P3 | test_order |
same as stable |
- |
| Good | P3 | test_p3_known_and_unknown_order |
reply matches the two sample sentences of P3; tool lookup_order; a lower-case order ID also works (P3) |
cases.json, 3 cases |
The weak row does not say what the test checks, takes its expectation from stable (§4.1) and has no data. The good row
tells a reviewer when the test will turn red. The extra exercise in §8.1 checks the two most common mistakes in this table with code.
4.5 Architecture
Start from aiqa (L1-M07), following starter/README.md. The decisions to record:
- How the product is started in tests: a fixture creates
TargetServer(build).start()on a random port and stops it after theyield. - How the build is chosen: an environment variable (for example
TARGET_BUILD), read in the configuration (L1-M07-L02). - One client for the product's API (F3), so that tests do not scatter HTTP calls.
- Data and oracles as files, every case with a source (F4).
- Repeat-run for P5: the number of runs, the seed (
X-Test-Seed,X-Test-Run), the threshold and the statistical test, with a reason based on power (L1-M06-L04).
Everyday example. A coffee shop has one order counter: every customer orders there, and the counter writes the table number and prints the ticket. When prices change, the shop updates the price board at the counter only. The framework's client is that counter: the timeout, the test headers and the handling of HTTP errors live in one place, not spread over 50 tests.
Worked example: how many runs does P5 need? P5 requires a 95% Wilson lower bound ≥ 0.9 with ≥ 50 runs. Before you
choose a number of runs, see how strict that threshold is. Save the code below as vd_l01.py (standard library only)
and run python vd_l01.py:
from math import sqrt
def wilson_low(k, n, z=1.959963984540054):
p = k / n
return (p + z * z / (2 * n) - z * sqrt(p * (1 - p) / n + z * z / (4 * n * n))) / (1 + z * z / n)
for n in (20, 30, 35, 50):
print(f"{n}/{n} pass -> lower bound {wilson_low(n, n):.3f}")
print(f"49/50 pass -> lower bound {wilson_low(49, 50):.3f}")
for n in (50, 100, 200):
allowed = max(f for f in range(n) if wilson_low(n - f, n) >= 0.9)
print(f"{n} runs: at most {allowed} failures keep the bound >= 0.9")
Output (copied from a real run on Python 3.14.6 and 3.12.3, Linux, 2026-11-06; both versions print the same):
20/20 pass -> lower bound 0.839
30/30 pass -> lower bound 0.886
35/35 pass -> lower bound 0.901
50/50 pass -> lower bound 0.929
49/50 pass -> lower bound 0.895
50 runs: at most 0 failures keep the bound >= 0.9
100 runs: at most 4 failures keep the bound >= 0.9
200 runs: at most 11 failures keep the bound >= 0.9
- With 20 or 30 runs, even when every run passes, the lower bound stays below 0.9: that number of runs can never prove P5, however good the product is.
- From 35 runs, an all-pass series gets above 0.9. P5 sets a floor of 50 runs.
- At exactly 50 runs, one failure (49/50) already pulls the lower bound down to 0.895: 50 runs means "no failure allowed".
- 100 runs allow 4 failures, 200 runs allow 11. More runs take more time, but one rare failure no longer fails the whole clause. This is a design decision: write the number you choose and your reason in section 5 of the design document.
This example is only about the threshold of P5. The comparison with stable still needs a power argument (how many
runs it takes to detect a drop you care about), as in L1-M06-L04.
5. Hands-on: explore the product
cd academy-content/capstone-projects/project-01-llm-qa-framework
python explore.py stable --health
python explore.py stable "Đơn SE1001 sao rồi?" "Trả 1 cái đơn SE1003 vì hàng hỏng" "Chính sách hoàn tiền?" "Thời tiết mai thế nào?"
python explore.py stable --classify "Tôi muốn hoàn tiền đơn SE1003"
Output (copied from a real run, 2026-10-31):
{"status": "ok", "build": "stable"}
> Đơn SE1001 sao rồi?
200 {"intent": "order_status", "reply": "Đơn SE1001: đang giao.", "tool_calls": [{"name": "lookup_order", "args": {"order_id": "SE1001"}, "outcome": "ok"}], "build": "stable"}
> Trả 1 cái đơn SE1003 vì hàng hỏng
200 {"intent": "return", "reply": "Bạn xác nhận trả 1 sản phẩm của đơn SE1003 nhé?", "tool_calls": [{"name": "create_return", "args": {"order_id": "SE1003", "quantity": 1, "reason": "damaged"}, "outcome": "needs_approval"}], "build": "stable"}
> Chính sách hoàn tiền?
200 {"intent": "faq", "reply": "Thời hạn đổi trả là 30 ngày, tính từ khi nhận hàng.", "tool_calls": [], "build": "stable"}
> Thời tiết mai thế nào?
200 {"intent": "out_of_scope", "reply": "Mình chỉ hỗ trợ đơn hàng, đổi trả và chính sách của ShopEasy.", "tool_calls": [], "build": "stable"}
{"category": "refund", "priority": 3, "order_id": "SE1003", "summary": "Tôi muốn hoàn tiền đơn SE1003", "needs_human": false}
The messages and replies are in Vietnamese and stay as the product sends them: an order-status question and its reply ("being delivered"), a return request that stops for confirmation, a refund-policy question whose reply states the return period, and an out-of-scope weather question that is redirected.
What you can read from it: the response has intent, reply, tool_calls (each call has an outcome) and build; a return
request without approve stops at needs_approval; an out-of-scope question is redirected. These observations help you design
tests. They do not prove that stable is correct.
6. The QA view
- What can go wrong at this milestone: writing tests before you know the risks; expectations copied from
stable; a traceability table with missing clauses; not deciding the number of runs for P5 in advance; an architecture where tests call HTTP directly. - Design review: ask one person (a classmate, an instructor) to read it for 20 minutes, and record their comments and how you handled them in section 8 of the template.
7. A realistic scenario
Scenario (fictional): "everything ran and a bug still got through". A team wrote 300 tests for a chatbot in two weeks, most of them for policy questions. There was no test for the return flow with a side effect, because nobody built a risk table. The first bug in production was a return request created twice.
8. Deliverable of milestone 1
docs/design.mdfollowingdesign-doc.template.md: scope, risks, traceability P1-P13, architecture, strategy (repeat-run, UI, tests moved over from the labs), CI and report, questions for the product owner, review result.- Exploration notes (charter, time, observations).
Criteria: every clause P1-P13 appears in the traceability table; the number of runs for P5 has a reason; there are at least two questions for the product owner (hint: P5 accepts a Wilson lower bound of 0.9, which means the true pass rate may be only about 90% (1 wrong answer in 10) and still pass. Is that threshold acceptable for an answer about the refund policy?).
8.1 Extra exercise: check the traceability table with code (20-30 minutes)
Problem: The two most common mistakes in a traceability table are a missing clause and a row whose expectation has no valid source (§4.1, §4.4). Reading 13 clauses by eye, it is easy to miss one; a small function checks it every time you edit the table.
Task: in the capstone folder, open exercises/test_m1_extra_trace.py. The file exercises/data/m1_plan.json is a
learner's draft traceability table (11 rows).
- TODO 1: write
source_ok(source): a source is valid when it names a clause P1-P13, a sectionpolicy §1-policy §7orticket.schema.json, and does not mentionstable. - TODO 2: write
uncovered(cases): the clauses that no row with a valid source covers, in the order P1, P2, ..., P13. - For each row of the draft with a bad source, rewrite the source from
requirements.mdorpolicy.md.
Run: python -m pytest exercises/test_m1_extra_trace.py. Before you start, the tests fail with TODO 1.
Acceptance criteria: 13 tests pass; you can explain why a clause whose only rows have a bad source still counts as not traced.
Hint: P14 is not a clause. Is the order of sorted(["P10", "P2"]) the order you need?
8.2 Real-world scenario: the booking assistant of a restaurant chain
Context (fictional): The restaurant chain BếpNhà is about to release a new version of its chat assistant. The contract has five clauses:
- B1: booking through the tool
create_booking(date, time, 1-12 people); created only after the customer confirms. - B2: cancelling through the tool
cancel_booking, only for a booking of the customer who is chatting. - B3: questions about allergens are answered from the ingredient table; when unsure, the assistant advises asking a member of staff. Stability: ≥ 50 runs, 95% Wilson lower bound ≥ 0.95.
- B4: opening hours 10:00-22:00 every day.
- B5: never reveal another customer's phone number or name.
Your task: write (a) a prioritised risk table with 5 rows, (b) two complete traceability rows for the two clauses you rank highest, (c) the number of runs for B3 with an argument in numbers, (d) three questions for the product owner.
A good answer has:
- Every risk has a clause, an impact and a reason for its priority; the order is explained by impact and by whether the damage can be undone (§4.3).
- Every risk names the test technique it needs (one case, many cases, repeated runs, UI), not just "functional test".
- Both traceability rows have a test name, an oracle and data, and the oracle points to a clause, not to the behaviour of the old version (§4.1, §4.4).
- The number of runs for B3 is derived from B3's threshold with a calculation you can run, as in the example in §4.5.
- Every question for the product owner points to something the contract does not say and can be answered with yes/no or a number.
9. Self-check questions
0/16 done · Results are kept in this browser only.
P01 · Short answer
Why must you not take expectations from the behaviour of stable? Where is stable legitimately used?
P02 · Short answer
Which risk in table 4.3 would you test first, and why?
P03 · Short answer
For P5, how many runs do you need to detect a drop in the pass rate that you consider worrying (for example 10 percentage points)? Argue from L1-M06-L04.
P04 · Short answer
Why does the framework need one client for the API instead of HTTP calls in each test?
P05 · Short answer
Name one ambiguity in P1-P13 and the question you would send to the product owner.
P07 · Match
P09 · Recall
Lesson: L1-M06-L04P10 · True or false
P12 · Multiple choice
P13 · True or false
P14 · Select all that apply
P15 · Fill in the blank
P16 · Apply now
Do the extra exercise of §8.1 in the capstone folder: exercises/test_m1_extra_trace.py with the data exercises/data/m1_plan.json.
10. Summary
- Milestone 1 answers "what to test, how to test it, what to build" before any test is written.
- Expectations come from the contract and the policy;
stableis only the baseline for P5. - Output: a design document with risks, traceability, architecture and strategy, reviewed.
11. References
The capstone reuses the sources of the earlier modules; see references.md of this module.