Write product requirements from interview notes.
Done by an agent. Checked twice.
A requirements page where every requirement cites the interview notes behind it and disagreements stay open questions.
Real files in
- brief.md
The one-paragraph brief for a round of customer interviews about letting customers move their own appointments. 6 lines, 427 bytes. - A_dispatcher.md
Notes from an interview with a dispatcher, 9 numbered notes. 14 lines, 1 KB. - B_owner.md
Notes from an interview with a small business owner, 7 numbered notes. 12 lines, 679 bytes. - C_office_manager.md
Notes from an interview with an office manager, 8 numbered notes. 13 lines, 936 bytes. - D_technician.md
Notes from an interview with a lead technician, 6 numbered notes. 11 lines, 768 bytes. - E_service_lead.md
Notes from an interview with a customer service lead, 8 numbered notes, one with numbers that do not add up. 13 lines, 904 bytes. - F_operations.md
Notes from an interview with an operations manager, 8 numbered notes. 13 lines, 910 bytes.
Sample data written by Atris. Not a real company.
Three steps
- 1.Read the brief and every note
- 2.Write requirements only from the notes
- 3.Write the page and its tables
Claude Sonnet 5.5, 1 min 37 s. No web. It never saw the check.
Checked twice
- Passed: 16 of 16 requirements cite at least one note and 31 of 31 cited note ids exist in the interview files
- Passed: 16 of 16 priorities equal the priority worked out again from how many interviews the cited notes come from
- Passed: 16 of 16 quotes appear word for word in the note they name
- Passed: 2 of 2 numbers written in requirements appear in a note that requirement cites
- Passed: 7 of 7 needs marked by hand before the run are covered by one requirement that cites all their notes
- Passed: 3 of 3 problems marked by hand are listed as open questions: two disagreements between interviews and one note whose numbers do not add up
- Passed: prd.md lists 16 of 16 requirement ids and 93 of 93 note ids it cites are real
- Passed: 16 of 16 requirements run R-01 onward in must, should, could order and prd.md lists 16 of 16 with the priority and note ids of requirements.csv
- Passed: prd.md carries 4 of 4 open questions with their notes and 17 of 17 numbers on lines that cite notes are found in those notes, the brief or the open question the line restates
Second review by Claude Opus 5.5: pass.
Then we broke a copy of the output 6 ways on purpose. The check caught 6.
- **R-01** (must) Customer can move their own appointment online without phoning the office. Notes: A-02, B-01, C-03, E-01, F-02. Quote from E-01: "Let customers move their own appointment online." - **R-02** (must) The move link works without the customer signing in or creating an account. Notes: A-03, B-03, E-02. Quote from A-03: "The link has to work without signing in." - **R-03** (must) The system offers a new slot only when a technician with the right skill, certification or license for that job is free for it. Notes: A-05, D-03, F-04. Quote from F-04: "The system must only offer a slot when a tech with the right license is free for it." - **R-04** (should) The customer can open the move page from a link in their confirmation message on a phone, with no app to install. Notes: A-02, E-02. Quote from E-02: "It has to work from the confirmation message on a phone." - **R-05** (should) The office is alerted immediately when a customer moves a job. Notes: A-07, C-05. Quote from A-07: "I need an alert the moment a customer moves a job, or the board is wrong and I do not know it." - **R-06** (should) The assigned technician gets a message on their phone immediately when one of their jobs is moved. Notes: C-05, D-02. Quote from D-02: "I need a message on my phone when one of my jobs moves." - **R-07** (should) A booking can be moved by the customer at most 2 times; after that the move goes to a person in the office. Notes: B-04, E-06. Quote from E-06: "Cap it at 2 reschedules per booking." - **R-08** (should) When the customer has used a technician before, that technician's open slots are shown first, then the other technicians' slots. Notes: C-07, E-08. Quote from E-08: "Show the same tech first, then the others." - **R-09** (should) The system offers only times when a technician is already working in the customer's area that day. Notes: D-05, F-05. Quote from D-05: "Only offer times when a tech is already working in that area."
How this was run
An AI agent on Claude Sonnet 5.5 was given a folder with the files below and a three-step flow, and nothing else. It had no web access and never saw the check. The check was written before the run and made stricter after it. It works the answer out again from the input files. Then Claude Opus 5.5 reviewed the result against the inputs. The input files are sample data written by Atris, with the problems a real week has planted in them.
Run 2 of 2 on 1 December 2026. The agent took 1 min 37 s. Run 1 did not pass the check. Each run starts clean. Between runs the written flow was made clearer, or a check was corrected or made stricter. Nobody edits the output.
What the second review verified
- Recounted interviews per requirement. R-01 cites A-02, B-01, C-03, E-01 and F-02, which is 5 interviews, so it is correctly a must. R-04 through R-09 each cite exactly 2 interviews and are should. R-10 cites only C-02 and C-03, which is 1 interview, so it is correctly a could. All 16 priorities match the rule.
- Looked up every quote in its named note. For example, R-03's quote "The system must only offer a slot when a tech with the right license is free for it." appears word for word in F-04, and R-12's "...at least 14 days after the first..." appears word for word in C-08. The bundled check.py also confirms 16 of 16 quotes.
- Redid the E-03 maths. A quarter of 400 is 100, not the 150 the note states. The worker correctly lists this as an open question instead of using it as fact.
- Accounted for all 44 notes. The two disagreements between interviews (A-06 '24 hours' vs E-04 '2 hours'; B-05 email vs C-06 text) and the B-06 fee question are open questions, not requirements. The 7 off-topic notes (A-04, A-08, B-02, B-07, C-04, D-04, F-03) are listed as out of scope. Background notes (A-01, C-01, D-01, E-05, E-07, F-01) are named. The numbers in the PRD (60, 5, 70, 40, 25, 30 and 3) all match their cited notes.
What this run does not show
- The check holds 7 shared needs and 3 problems marked by hand, one of which was marked wrongly and corrected after run 1.
- Whether each requirement is worded so a tester could check it is judged only by the second review.
- A number worked out inside an open question, such as a quarter of 400, is not recomputed by the check.
Would the check catch a wrong answer?
A check that cannot fail proves nothing. After the run we took a copy of the output, broke it one small way at a time and ran the check again. It caught 6 of 6. The check was made stricter after the first try at this, and the same untouched output was graded again.
Open every file
flow.md · the three steps the agent followed
# Write product requirements from interview notes function: product for: the product manager who turns customer interviews into a plan goal: The team has one requirements page where every requirement traces to what a customer actually said. ## 1. Read the brief and every note Read input/brief.md, then every file in input/interviews/. Each note has an id such as A-04. The letter names the interview. Sort the notes: which ones answer the brief's question, which ones are about something else, which ones disagree with another interview. ## 2. Write requirements only from the notes A requirement is one thing the product must do, written so a tester could check it. Rules: - Every requirement cites every note that supports it. No note, no requirement. - Notes from different interviews that ask for the same thing support one requirement, not several. - priority is `must` when the cited notes come from 3 or more interviews, `should` when they come from 2 and `could` when they come from 1. - Each requirement carries one quote, copied word for word from one of its cited notes. - Keep the numbers the notes give, written as digits. Never write a number that is not in a cited note. - When two interviews want opposite things, do not pick a side. List it as an open question with both note ids. - When the numbers inside one note do not agree with each other, do not repeat them as fact. List that note as an open question too. - A note about another topic than the brief's question gets no requirement. Name it under out of scope. ## 3. Write the page and its tables Write output/requirements.csv with columns req_id,requirement,priority,notes,quote,quote_note. req_id runs R-01, R-02 and so on. notes lists the cited note ids separated by `;`. quote_note is the id of the note the quote came from. Order the rows must first, then should, then could. Write output/open_questions.csv with columns question,notes. notes lists the note ids separated by `;`. Write output/prd.md with these sections: Problem, Who it is for, Requirements, Open questions, Out of scope. List every requirement with its req_id, priority and note ids. Cite a note id for every fact. ## Done looks like - Every requirement cites at least one real note and its priority follows the interview count. - Every quote can be found word for word in the note it names. - Disagreements between interviews are open questions, not requirements.
input/brief.md · 6 lines, 427 bytes
# Discovery brief: customers move their own appointments Product: Fieldnest, a booking and dispatch tool for home service companies. Question for this round: what must be true for a customer to move an appointment without phoning the office? Six interviews were held with people at six customer companies between 2026-11-09 and 2026-11-18. Each note in the interview files has an id such as A-04. The letter is the interview.
input/interviews/A_dispatcher.md · 14 lines, 1 KB
# Interview A Who: Dana Okafor, dispatcher Company: Harlan Heating and Air, 12 technicians Date: 2026-11-09 - [A-01] We run about 60 jobs a day in winter. I build the board the evening before. - [A-02] About a third of my calls are people moving an appointment. They should be able to do that from a link without calling us. - [A-03] Nobody remembers a password for their heating company. The link has to work without signing in. - [A-04] Your price per seat went up 15 percent this year. I want that on the record. - [A-05] The new slot has to be one a tech with the right skill can take. Do not offer a gas boiler job to someone who only does air conditioning. - [A-06] Nobody should be able to move a job inside 24 hours of the slot. By then the van is loaded and the route is set. - [A-07] I need an alert the moment a customer moves a job, or the board is wrong and I do not know it. - [A-08] The colors on the dispatch board are hard to tell apart. Different topic, I know. - [A-09] If a customer moves a job, the old slot should open up for someone else right away.
input/interviews/B_owner.md · 12 lines, 679 bytes
# Interview B Who: Miguel Sorensen, owner Company: Sorensen Appliance Repair, 3 technicians Date: 2026-11-10 - [B-01] I answer the phone myself. Every call about moving a job pulls me off a repair. - [B-02] We still write quotes on paper. That is fine for us. - [B-03] No login. Most of my customers are over 70 and will not create an account. - [B-04] Some people move the same job four times. After 2 moves they should have to call me. - [B-05] Do not send texts. I pay per message and customers ignore them. Email only. - [B-06] If they move it inside the cutoff I want to charge my 25 dollar call out fee. - [B-07] I like the product. It paid for itself in the first month.
input/interviews/C_office_manager.md · 13 lines, 936 bytes
# Interview C Who: Priya Halloran, office manager Company: Brightside Pest Control, 8 technicians Date: 2026-11-12 - [C-01] Two of us cover the phones. Mondays are the worst. - [C-02] Most changes come in after we close at 5. People leave a voicemail and we call back the next morning, sometimes too late. - [C-03] Let the customer pick a new time online themselves, any hour of the day. That would clear most of the voicemail. - [C-04] I would like invoices to go out automatically after a visit. Separate request, I suppose. - [C-05] The tech's phone and the office both need to hear about a change straight away. - [C-06] Customers want a text with the new time. They do not read email from us. - [C-07] Our customers ask for the same tech every time. Offer that tech's open slots first. - [C-08] Treatments come in a series. The second visit must stay at least 14 days after the first, so do not let them move it closer than that.
input/interviews/D_technician.md · 11 lines, 768 bytes
# Interview D Who: Tom Vesely, lead technician Company: Cedar Ridge Plumbing, 6 technicians Date: 2026-11-13 - [D-01] I see my jobs on my phone in the morning. I rarely check again after that. - [D-02] Twice last month I drove to a house and nobody was home because the job had been moved. I need a message on my phone when one of my jobs moves. - [D-03] Only 2 of us are certified for gas work. A moved gas job must land on one of us, not on whoever is free. - [D-04] The app logo looks dated. - [D-05] If a customer picks a slot when I am across town I lose an hour driving. Only offer times when a tech is already working in that area. - [D-06] Parts matter too. If the part for a job arrives Thursday the customer should not be able to move the job to Wednesday.
input/interviews/E_service_lead.md · 13 lines, 904 bytes
# Interview E Who: Aiko Lindqvist, customer service lead Company: Northbank Garage Doors, 20 technicians Date: 2026-11-16 - [E-01] Let customers move their own appointment online. Our own survey says they hate waiting on hold for it. - [E-02] It has to work from the confirmation message on a phone. No account and no app to install. - [E-03] We take about 400 calls a week and a quarter of them are reschedules, so about 150 calls a week. - [E-04] Customers must be able to move a job up to 2 hours before the slot. Life happens. A whole day of notice is not realistic. - [E-05] My team is measured on hold time. Anything that cuts calls helps. - [E-06] Cap it at 2 reschedules per booking. After that it goes to a person on my team. - [E-07] We tried a chatbot last year and customers disliked it. - [E-08] Repeat customers get attached to their technician. Show the same tech first, then the others.
input/interviews/F_operations.md · 13 lines, 910 bytes
# Interview F Who: Reggie Mbeki, operations manager Company: Tallpine Electric, 30 technicians Date: 2026-11-18 - [F-01] We have 30 techs across 3 depots. Routing is the whole game for us. - [F-02] Customers rescheduling on their own, without a call to the office, would save my dispatchers hours a week. - [F-03] Please add a dark theme to the dispatch board. - [F-04] Licensing is strict in our trade. The system must only offer a slot when a tech with the right license is free for it. - [F-05] Keep moved jobs near where a crew already is that day. A slot that sends a van 40 minutes each way is not a real slot. - [F-06] Let each company set its own cutoff for how late a customer can move a job. Ours would differ by job type. - [F-07] Ask the customer why they are moving it. A short list of reasons is enough. I want to see patterns. - [F-08] Give me a weekly count of customer reschedules per depot.
output/open_questions.csv · written by the agent, 5 lines
question,notes How late may a customer move a job? Dispatcher A wants no moves inside 24 hours of the slot; service lead E wants moves allowed up to 2 hours before the slot. F-06 asks for a company-set cutoff but gives no value.,A-06;E-04;F-06 What happens to a move inside the cutoff: blocked outright (A-06) or allowed with a 25 dollar call out fee (B-06)?,A-06;B-06 "Which channel carries the customer's new-time message: email only (B-05, customers ignore texts) or text (C-06, customers do not read email)?",B-05;C-06 "Note E-03 says about 400 calls a week and a quarter are reschedules, but also says that is about 150 calls a week. A quarter of 400 is 100, so the figures disagree. The call volume is not used as fact until E confirms.",E-03
output/prd.md · written by the agent, 59 lines
# Product requirements: customers move their own appointments (Fieldnest) ## Problem - Customers phone the office to move appointments: about a third of one dispatcher's calls (A-02), and every such call pulls an owner off a repair (B-01). - Changes arrive after the office closes at 5; voicemails are returned the next morning, sometimes too late (C-02). - Customers dislike waiting on hold to reschedule (E-01), and one operations manager expects self-service rescheduling to save dispatchers hours a week (F-02). - When a job moves and the technician is not told, the technician can drive to an empty house (D-02), and the dispatch board goes wrong unnoticed (A-07). - Question for this round (brief): what must be true for a customer to move an appointment without phoning the office? ## Who it is for - Customers of home service companies who need to move a booked job (A-02, E-01). Some are over 70 and will not create an account (B-03). - Office staff and dispatchers who take reschedule calls and keep the board right (A-02, A-07, C-01). - Technicians whose jobs get moved (D-02). - Operations managers who need routing and reporting on reschedules (F-05, F-08). ## Requirements Priority: must = cited notes come from 3 or more interviews, should = 2, could = 1. The letter in a note id is the interview. Full table with quotes: requirements.csv. - **R-01** (must) Customer can move their own appointment online without phoning the office. Notes: A-02, B-01, C-03, E-01, F-02. Quote from E-01: "Let customers move their own appointment online." - **R-02** (must) The move link works without the customer signing in or creating an account. Notes: A-03, B-03, E-02. Quote from A-03: "The link has to work without signing in." - **R-03** (must) The system offers a new slot only when a technician with the right skill, certification or license for that job is free for it. Notes: A-05, D-03, F-04. Quote from F-04: "The system must only offer a slot when a tech with the right license is free for it." - **R-04** (should) The customer can open the move page from a link in their confirmation message on a phone, with no app to install. Notes: A-02, E-02. Quote from E-02: "It has to work from the confirmation message on a phone." - **R-05** (should) The office is alerted immediately when a customer moves a job. Notes: A-07, C-05. Quote from A-07: "I need an alert the moment a customer moves a job, or the board is wrong and I do not know it." - **R-06** (should) The assigned technician gets a message on their phone immediately when one of their jobs is moved. Notes: C-05, D-02. Quote from D-02: "I need a message on my phone when one of my jobs moves." - **R-07** (should) A booking can be moved by the customer at most 2 times; after that the move goes to a person in the office. Notes: B-04, E-06. Quote from E-06: "Cap it at 2 reschedules per booking." - **R-08** (should) When the customer has used a technician before, that technician's open slots are shown first, then the other technicians' slots. Notes: C-07, E-08. Quote from E-08: "Show the same tech first, then the others." - **R-09** (should) The system offers only times when a technician is already working in the customer's area that day. Notes: D-05, F-05. Quote from D-05: "Only offer times when a tech is already working in that area." - **R-10** (could) The customer can move the appointment at any hour of the day, including after the office has closed. Notes: C-02, C-03. Quote from C-03: "Let the customer pick a new time online themselves, any hour of the day." - **R-11** (could) When a customer moves a job, the old slot is released for other bookings right away. Notes: A-09. Quote from A-09: "If a customer moves a job, the old slot should open up for someone else right away." - **R-12** (could) For a treatment series, the customer cannot move the second visit closer than 14 days after the first. Notes: C-08. Quote from C-08: "The second visit must stay at least 14 days after the first, so do not let them move it closer than that." - **R-13** (could) The customer cannot move a job to a date before the parts for that job arrive. Notes: D-06. Quote from D-06: "If the part for a job arrives Thursday the customer should not be able to move the job to Wednesday." - **R-14** (could) Each company can set its own cutoff for how late a customer can move a job, and the cutoff can differ by job type. Notes: F-06. Quote from F-06: "Let each company set its own cutoff for how late a customer can move a job." - **R-15** (could) The customer is asked why they are moving the job and picks from a short list of reasons. Notes: F-07. Quote from F-07: "Ask the customer why they are moving it." - **R-16** (could) The system reports a weekly count of customer reschedules per depot. Notes: F-08. Quote from F-08: "Give me a weekly count of customer reschedules per depot." Gaps the notes leave open: - No note says how near is "near" for the area requirement; F-05 only gives the example of a van driving 40 minutes each way as not a real slot. - No note gives cutoff values beyond A-06 and E-04 (see open questions). ## Open questions - How late may a customer move a job? Dispatcher A wants no moves inside 24 hours of the slot; service lead E wants moves allowed up to 2 hours before the slot. F-06 asks for a company-set cutoff but gives no value. Notes: A-06, E-04, F-06. - What happens to a move inside the cutoff: blocked outright (A-06) or allowed with a 25 dollar call out fee (B-06)? Notes: A-06, B-06. - Which channel carries the customer's new-time message: email only (B-05, customers ignore texts) or text (C-06, customers do not read email)? Notes: B-05, C-06. - Note E-03 says about 400 calls a week and a quarter are reschedules, but also says that is about 150 calls a week. A quarter of 400 is 100, so the figures disagree. The call volume is not used as fact until E confirms. Notes: E-03. Neither side of a disagreement was chosen; none of these became a requirement. ## Out of scope Notes about another topic than customers moving appointments; no requirement written: - A-04 (seat price increase), A-08 (dispatch board colors), B-02 (paper quotes), B-07 (general praise), C-04 (automatic invoices), D-04 (app logo), F-03 (dark theme for the dispatch board). Background notes on the topic that carry no requirement of their own: - A-01 (about 60 jobs a day in winter), C-01 (two people cover phones), D-01 (technician checks jobs on phone in the morning), E-05 (team measured on hold time), F-01 (30 techs across 3 depots). - E-07: a chatbot was tried and customers disliked it. No requirement written because the note asks for nothing; worth weighing before choosing any chat-based design.
output/requirements.csv · written by the agent, 17 lines
req_id,requirement,priority,notes,quote,quote_note R-01,Customer can move their own appointment online without phoning the office.,must,A-02;B-01;C-03;E-01;F-02,Let customers move their own appointment online.,E-01 R-02,The move link works without the customer signing in or creating an account.,must,A-03;B-03;E-02,The link has to work without signing in.,A-03 R-03,"The system offers a new slot only when a technician with the right skill, certification or license for that job is free for it.",must,A-05;D-03;F-04,The system must only offer a slot when a tech with the right license is free for it.,F-04 R-04,"The customer can open the move page from a link in their confirmation message on a phone, with no app to install.",should,A-02;E-02,It has to work from the confirmation message on a phone.,E-02 R-05,The office is alerted immediately when a customer moves a job.,should,A-07;C-05,"I need an alert the moment a customer moves a job, or the board is wrong and I do not know it.",A-07 R-06,The assigned technician gets a message on their phone immediately when one of their jobs is moved.,should,C-05;D-02,I need a message on my phone when one of my jobs moves.,D-02 R-07,A booking can be moved by the customer at most 2 times; after that the move goes to a person in the office.,should,B-04;E-06,Cap it at 2 reschedules per booking.,E-06 R-08,"When the customer has used a technician before, that technician's open slots are shown first, then the other technicians' slots.",should,C-07;E-08,"Show the same tech first, then the others.",E-08 R-09,The system offers only times when a technician is already working in the customer's area that day.,should,D-05;F-05,Only offer times when a tech is already working in that area.,D-05 R-10,"The customer can move the appointment at any hour of the day, including after the office has closed.",could,C-02;C-03,"Let the customer pick a new time online themselves, any hour of the day.",C-03 R-11,"When a customer moves a job, the old slot is released for other bookings right away.",could,A-09,"If a customer moves a job, the old slot should open up for someone else right away.",A-09 R-12,"For a treatment series, the customer cannot move the second visit closer than 14 days after the first.",could,C-08,"The second visit must stay at least 14 days after the first, so do not let them move it closer than that.",C-08 R-13,The customer cannot move a job to a date before the parts for that job arrive.,could,D-06,If the part for a job arrives Thursday the customer should not be able to move the job to Wednesday.,D-06 R-14,"Each company can set its own cutoff for how late a customer can move a job, and the cutoff can differ by job type.",could,F-06,Let each company set its own cutoff for how late a customer can move a job.,F-06 R-15,The customer is asked why they are moving the job and picks from a short list of reasons.,could,F-07,Ask the customer why they are moving it.,F-07 R-16,The system reports a weekly count of customer reschedules per depot.,could,F-08,Give me a weekly count of customer reschedules per depot.,F-08
check.py · the check, written before the run
"""Traces every requirement back to the interview notes: ids, priorities, quotes and numbers."""
import csv, re, sys
from pathlib import Path
root = Path(sys.argv[1]); ok = True
def say(passed, text):
global ok; ok = ok and passed; print(("PASS " if passed else "FAIL ") + text)
notes = {}
for f in sorted((root/"input/interviews").glob("*.md")):
for m in re.finditer(r"^- \[([A-Z]-\d\d)\] (.+)$", f.read_text(), re.M):
notes[m.group(1)] = " ".join(m.group(2).split())
# Marked by hand before the run: needs raised in two or more interviews, with the notes that ask for each.
# Corrected after run 1: telling the office (A-07, C-05) and telling the technician (C-05, D-02) are two
# different asks, and the flow says a requirement is one thing. The first key wrongly asked for one
# requirement citing all three notes.
NEEDS = [["A-02", "C-03", "E-01", "F-02"], ["A-05", "D-03", "F-04"], ["A-07", "C-05"], ["C-05", "D-02"],
["B-04", "E-06"], ["C-07", "E-08"], ["A-03", "B-03", "E-02"]]
# Marked by hand: two pairs of notes that want opposite things, and one note whose own numbers do not add up.
PROBLEMS = [["A-06", "E-04"], ["B-05", "C-06"], ["E-03"]]
rp = root/"output/requirements.csv"
if not rp.exists():
say(False, "output/requirements.csv was not written"); sys.exit(1)
reqs = list(csv.DictReader(rp.open()))
ids = lambda s: [x.strip().strip("[]") for x in re.split(r"[;,]", s or "") if x.strip()]
for r in reqs: r["n"] = ids(r.get("notes"))
cited = [n for r in reqs for n in r["n"]]
real = sum(1 for r in reqs if r["n"] and all(n in notes for n in r["n"]))
say(bool(reqs) and real == len(reqs), f"{real} of {len(reqs)} requirements cite at least one note and {sum(1 for n in cited if n in notes)} of {len(cited)} cited note ids exist in the interview files")
def want_priority(r):
k = len({n[0] for n in r["n"] if n in notes})
return "must" if k >= 3 else "should" if k == 2 else "could"
pri = sum(1 for r in reqs if (r.get("priority") or "").strip().lower() == want_priority(r))
say(bool(reqs) and pri == len(reqs), f"{pri} of {len(reqs)} priorities equal the priority worked out again from how many interviews the cited notes come from")
def quote_ok(r):
q, qn = " ".join((r.get("quote") or "").split()).strip("\"' "), (r.get("quote_note") or "").strip().strip("[]")
return len(q.split()) >= 3 and qn in r["n"] and qn in notes and q in notes[qn]
quoted = sum(1 for r in reqs if quote_ok(r))
say(bool(reqs) and quoted == len(reqs), f"{quoted} of {len(reqs)} quotes appear word for word in the note they name")
nums = nums_ok = 0
for r in reqs:
src = set(re.findall(r"\d+(?:\.\d+)?", " ".join(notes.get(n, "") for n in r["n"])))
for x in re.findall(r"\d+(?:\.\d+)?", r.get("requirement") or ""):
nums += 1; nums_ok += x in src
say(nums > 0 and nums_ok == nums, f"{nums_ok} of {nums} numbers written in requirements appear in a note that requirement cites")
covered = sum(1 for need in NEEDS if any(set(need) <= set(r["n"]) for r in reqs))
say(covered == len(NEEDS), f"{covered} of {len(NEEDS)} needs marked by hand before the run are covered by one requirement that cites all their notes")
qp = root/"output/open_questions.csv"
qrows = [set(ids(r.get("notes"))) for r in csv.DictReader(qp.open())] if qp.exists() else []
flagged = sum(1 for p in PROBLEMS if any(set(p) <= q for q in qrows))
say(flagged == len(PROBLEMS), f"{flagged} of {len(PROBLEMS)} problems marked by hand are listed as open questions: two disagreements between interviews and one note whose numbers do not add up")
prd = (root/"output/prd.md").read_text() if (root/"output/prd.md").exists() else ""
listed = sum(1 for r in reqs if (r.get("req_id") or "?").strip() in prd)
prd_ids = [x for x in re.findall(r"\b[A-Z]-\d\d\b", prd) if not x.startswith("R-")]
fake = [x for x in prd_ids if x not in notes]
say(bool(prd) and listed == len(reqs) and bool(prd_ids) and not fake, f"prd.md lists {listed} of {len(reqs)} requirement ids and {len(prd_ids) - len(fake)} of {len(prd_ids)} note ids it cites are real")
# Stricter lines added after the run: the table's own order and the page are compared with the table and the notes.
rid = lambda r: (r.get("req_id") or "").strip()
pri_of = lambda r: (r.get("priority") or "").strip().lower()
rank = {"must": 0, "should": 1, "could": 2}
run_ok = sum(1 for i, r in enumerate(reqs) if rid(r) == f"R-{i + 1:02d}" and (i == 0 or rank.get(pri_of(reqs[i - 1]), 9) <= rank.get(pri_of(r), 9)))
plines = [" ".join(l.split()) for l in prd.splitlines() if l.strip()]
note_ids = lambda s: [x for x in re.findall(r"\b[A-Z]-\d\d\b", s) if not x.startswith("R-")]
def on_page(r):
mine = [l for l in plines if re.search(r"\b" + re.escape(rid(r)) + r"\b", l)]
return any(set(note_ids(l)) == set(r["n"]) and re.search(r"\b" + pri_of(r) + r"\b", l.lower()) for l in mine)
paged = sum(1 for r in reqs if on_page(r))
ghost = set(re.findall(r"\bR-\d\d\b", prd)) - {rid(r) for r in reqs}
say(bool(reqs) and run_ok == len(reqs) and paged == len(reqs) and not ghost,
f"{run_ok} of {len(reqs)} requirements run R-01 onward in must, should, could order and prd.md lists {paged} of {len(reqs)} with the priority and note ids of requirements.csv")
qtab = [r for r in csv.DictReader(qp.open())] if qp.exists() else []
qpaged = sum(1 for q in qtab if any(set(ids(q.get("notes"))) <= set(note_ids(l)) for l in plines))
digits = lambda s: re.findall(r"\d+(?:\.\d+)?", re.sub(r"\b[A-Z]-\d\d\b", " ", s))
brief = set(digits((root/"input/brief.md").read_text()))
pn = pn_ok = 0
for l in plines:
cited = [n for n in note_ids(l) if n in notes]
if not cited: continue
src = set(digits(" ".join(notes[n] for n in cited))) | brief
for q in qtab: # a line that restates an open question may carry the numbers that question works out
if set(ids(q.get("notes"))) <= set(cited): src |= set(digits(q.get("question") or ""))
for x in digits(l):
pn += 1; pn_ok += x in src
say(qpaged == len(qtab) and pn > 0 and pn_ok == pn,
f"prd.md carries {qpaged} of {len(qtab)} open questions with their notes and {pn_ok} of {pn} numbers on lines that cite notes are found in those notes, the brief or the open question the line restates")
sys.exit(0 if ok else 1)
brief.md: sample data written by Atris. Fingerprint f7d4cdb392c6.
A_dispatcher.md: sample data written by Atris. Fingerprint f52bdf69cccc.
B_owner.md: sample data written by Atris. Fingerprint 61db49f69131.
C_office_manager.md: sample data written by Atris. Fingerprint ff8c09d3a4f7.
D_technician.md: sample data written by Atris. Fingerprint 6ecb4e3bba83.
E_service_lead.md: sample data written by Atris. Fingerprint dfef7a2c1c8c.
F_operations.md: sample data written by Atris. Fingerprint 1caaeb8cfff3.
open_questions.csv: written by the agent. Fingerprint 893e04a60cdc.
prd.md: written by the agent. Fingerprint d4d966963f41.
requirements.csv: written by the agent. Fingerprint b4a26bfb16d6.