Group duplicate bug reports in a backlog.
Done by an agent. Checked twice.
A backlog where every repeat report points at the earliest report of the same bug, with the count you can close.
Real files in
- bug_backlog.csv
A bug backlog of 44 reports for a staff scheduling app, filed over four weeks by support, testers and customers. Many describe the same bug in different words.. 45 lines, 9 KB.
Sample data written by Atris. Not a real company.
Three steps
- 1.Read every report in full
- 2.Decide which reports are the same bug
- 3.Write the result
Claude Sonnet 5.5, 47 seconds. No web. It never saw the check.
Checked twice
- Passed: 44 of 44 reports appear once in groups.csv
- Passed: 10 of 10 duplicate groups equal the groups marked by hand before the run, with 0 other groups made
- Passed: 17 of 17 reports with no duplicate are left on their own
- Passed: 10 of 10 groups keep the earliest report as the original
- Passed: 17 of 17 duplicates point at the original of their own group
- Passed: summary.md states reports read 44, duplicate groups 10, duplicates to close 17, distinct bugs left 27 and all four equal the counts in groups.csv
- Passed: 44 of 44 reports carry a bug name and 10 of 10 groups use one name on all their rows
- Passed: 18 of 18 numbers written in bug names are found in the reports they describe
- Passed: 10 of 10 group lines in summary.md give the original first, then the bug name and the duplicates that groups.csv holds
Second review by Claude Opus 5.5: pass.
Then we broke a copy of the output 5 ways on purpose. The check caught 5.
Reports read: 44 Duplicate groups: 10 Duplicates to close: 17 Distinct bugs left: 27 - G1: original BUG-2101; Exporting the weekly schedule to CSV gives start and end times one hour earlier than the schedule screen shows (since the Nov 1 clock change). Duplicates: BUG-2110, BUG-2128, BUG-2140 - G2: original BUG-2143; Tapping the emailed password reset link right away shows 'This link has expired'. Duplicates: BUG-2102, BUG-2119 - G3: original BUG-2103; The Clock in button stays greyed out on site when location permission is set to 'only while using the app'. Duplicates: BUG-2121, BUG-2141 - G4: original BUG-2104; The labor cost report total leaves out the overtime hours that show in the overtime column. Duplicates: BUG-2116, BUG-2134 - G5: original BUG-2106; Approving a half day (0.5) time off request deducts a full day from the balance. Duplicates: BUG-2126, BUG-2138 - G6: original BUG-2107; Approving a shift swap adds the new person but leaves the original person on the shift too. Duplicates: BUG-2122, BUG-2144 - G7: original BUG-2108; Assigning a shift sends the employee the same push notification twice. Duplicates: BUG-2131
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 47 seconds. Run 1 passed the check but not the second review. 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
- I re-read all 44 reports and grouped them myself. I got the same 10 groups. For example, G1 is BUG-2101, BUG-2110, BUG-2128 and BUG-2140: CSV export times one hour early. Look-alikes are correctly kept apart: BUG-2105 (PDF cuts off Sunday), BUG-2112 (reset email never arrives), BUG-2115 (swap alert not sent), BUG-2124 (wrong currency symbol), BUG-2125 (email late).
- I checked that each original is the earliest report. BUG-2143 (2026-10-30) comes before BUG-2102 (2026-11-02) in G2. In G6, BUG-2107 and BUG-2144 were both filed on 2026-11-04, so the lower ID, BUG-2107, is the original. Every duplicate_of value points at its group's original.
- groups.csv has 44 rows, one per bug_id, in bug_id order. Roles: 10 original, 17 duplicate, 17 single.
- The summary numbers match my recount: 44 read, 10 groups, 17 to close, 27 distinct (44 - 17 = 27). The group lines list the correct originals and duplicate IDs.
What this run does not show
- The check holds the right groups as a list marked by hand before the run, so it cannot judge a grouping it was not told about.
- The sample reports were written for this run with clearer duplicates than a real backlog holds.
- Run 1 failed the second review over a vague bug name, so this pass is run 2 after the flow was made clearer.
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 5 of 5. 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
# Group duplicate bug reports in a backlog function: product for: the product manager who keeps the bug backlog clean goal: Every report is either one of a kind or tied to the earliest report of the same bug, so each bug is worked once. ## 1. Read every report in full Read input/bug_backlog.csv. Read the description as well as the title. Titles can be vague or misleading. Some fields are blank. A blank field is not a reason to join or split reports. Use the text that is there. ## 2. Decide which reports are the same bug Two reports are the same bug when the same action leads to the same wrong result. Rules: - A different device, app version, reporter or choice of words does not make a different bug. - A different wrong result is a different bug, even in the same part of the product. - The same part of the product is not enough. Two reports about one screen can be two bugs. - When you are not sure, keep the reports apart. Closing a real bug as a duplicate costs more than leaving two open. Put reports of the same bug in one group. In each group the original is the report with the earliest reported_on. When two share that date, the lower bug_id is the original. ## 3. Write the result Write output/groups.csv with columns bug_id,group,role,duplicate_of,bug_name. One row per report in the input, in bug_id order. group is G1, G2 and so on for a group of two or more reports and empty for a report on its own. role is `original`, `duplicate` or `single`. duplicate_of is the original's bug_id on a `duplicate` row and empty on every other row. bug_name is one plain sentence that says what action gives what wrong result. Write it from the description on every row, a report on its own included. Never copy a vague title. A group uses the same sentence on each of its rows. Write output/summary.md. Start with these four lines, each with its number: `Reports read: `, `Duplicate groups: `, `Duplicates to close: `, `Distinct bugs left: `. Then one line per group: the group, the original's bug_id, the bug name and the duplicate ids. ## Done looks like - Every report appears once in groups.csv. - Every group has one original, which is its earliest report. Its duplicates point at it. - The four numbers in summary.md equal the counts in groups.csv.
input/bug_backlog.csv · 45 lines, 9 KB
bug_id,reported_on,source,platform,app_version,area,title,description BUG-2101,2026-11-02,support,web,5.3.0,Schedule,CSV export shows shifts an hour early,"Exported the weekly schedule to CSV on Monday. Every start and end time in the file is one hour earlier than what the schedule screen shows. Started after the clocks changed on Nov 1." BUG-2102,2026-11-02,qa,ios,5.3.0,Login,Reset password link expired right away,"Tapped Forgot password, got the email within a minute, tapped the link and the page says 'This link has expired'. Tried three times." BUG-2103,2026-11-03,customer,android,5.2.4,Clock in,"Can't clock in, button disabled","At the store, location is on, but the Clock in button stays grey and does nothing. Location permission is set to 'Only while using the app'." BUG-2104,2026-11-03,support,web,5.3.0,Reports,Labor cost report missing overtime,"The labor cost report total for last week is lower than what we paid. Regular hours are there but overtime hours are not added into the total." BUG-2105,2026-11-03,qa,web,5.3.0,Schedule,Export broken,"PDF export of the weekly schedule cuts off the Sunday column. The other six days print fine." BUG-2106,2026-11-04,customer,ios,5.3.0,Time off,Half day leave deducts 1 full day,"I asked for a half day off on Friday. It was approved and my balance went down by a whole day." BUG-2107,2026-11-04,support,web,5.3.0,Swaps,Swap approved but both people still on shift,"Manager approved a shift swap. The new person was added to the shift but the person who gave it away is still on it too." BUG-2108,2026-11-04,customer,android,5.3.0,Notifications,Got two pushes for the same shift,"When my manager assigns me a shift I get the same push notification twice, a few seconds apart." BUG-2109,2026-11-05,qa,web,5.3.0,Staff,Staff search can't find names with accents,"Typing Jose in the staff search does not return José. Typing the accented letter works." BUG-2110,2026-11-05,support,,5.3.0,Schedule,Exported schedule times wrong after clock change,"Customer says the spreadsheet they download from the schedule page has all shifts 1 hour off since the weekend. On screen the times are right." BUG-2111,2026-11-05,customer,ios,5.3.0,Settings,Dark mode text unreadable on availability screen,"In dark mode the day labels on the availability screen are dark grey on black." BUG-2112,2026-11-06,customer,web,5.3.0,Login,Password reset email never arrives,"My email address has a plus sign in it. I never receive the reset email at all. Other emails from the app arrive." BUG-2113,2026-11-06,qa,ios,5.3.0,Shift details,Crash when opening a shift that has a long note,"Open any shift whose note is longer than about 500 characters. The app closes straight away. Shifts with short notes open fine." BUG-2114,2026-11-06,support,web,5.3.0,Schedule,Dragging a shift copies it instead of moving it,"In Safari, dragging a shift from Tuesday to Wednesday leaves the shift on Tuesday and also creates it on Wednesday." BUG-2115,2026-11-09,customer,android,5.3.0,Swaps,Swap request notification not sent to manager,"I asked to swap a shift two days ago. My manager says she never got any alert about it. The request shows as pending." BUG-2116,2026-11-09,customer,web,5.3.0,,Report wrong,"Total wages on the labor cost report are lower than our payroll figure. Looking closer, the overtime column has hours but they are left out of the total at the bottom." BUG-2117,2026-11-09,support,ios,5.3.1,Time off,Time off balance does not carry over into the new year,"Customer previewed January and the leftover days from this year are not added to next year's balance, though carry over is switched on." BUG-2118,2026-11-10,qa,android,5.3.1,Calendar,Calendar shows 24 hour times when phone is set to 12 hour,"Phone is set to a 12 hour clock. The calendar view shows 17:00 instead of 5:00 PM." BUG-2119,2026-11-10,customer,ios,5.3.1,Login,Forgot password link says expired, BUG-2120,2026-11-10,customer,web,5.3.1,Billing,Typo on billing page,"The billing page says 'You will recieve an invoice'. Receive is spelled wrong." BUG-2121,2026-11-11,support,android,5.3.1,Clock in,Clock in greyed out at the store,"Two staff at the same shop report the Clock in button is greyed out even though they are standing inside. Both have location allowed only while the app is in use." BUG-2122,2026-11-11,customer,web,5.3.1,Schedule,Double booked after swap,"After my swap was approved the schedule shows me and my coworker both on the Saturday shift. Only she should be on it now." BUG-2123,2026-11-11,qa,android,5.3.1,Staff,Invite link for new staff opens a blank page,"On Android Chrome the invite link in the welcome email opens a white page. It works on desktop." BUG-2124,2026-11-12,support,web,5.3.1,Reports,Labor cost report shows wrong currency symbol,"The Canada location's labor cost report shows a US dollar total with no CA marker. The numbers themselves are right." BUG-2125,2026-11-12,customer,ios,5.3.1,Notifications,Email about new shift arrives hours late,"I get the email telling me about a new shift three or four hours after it was assigned. The push arrives on time." BUG-2126,2026-11-12,customer,android,5.3.1,Time off,PTO balance wrong after half day request,"Balance dropped by 1.0 after a 0.5 day request was approved." BUG-2127,2026-11-13,qa,android,5.3.1,Shift details,App closes when I tap a shift with a long note,"The same shift opens on the web. On Android the app shuts as soon as the details screen starts to load. The note on that shift is several paragraphs." BUG-2128,2026-11-13,support,web,5.3.1,Schedule,Schedule download off by 1h,"The CSV a manager downloaded from the schedule has each shift starting an hour before the time shown in the app." BUG-2129,2026-11-16,customer,web,5.3.1,Locations,Closed store still in the location list,"We closed our Elm Street shop in September and archived it. It still shows in the location dropdown when building a schedule." BUG-2130,2026-11-16,customer,ios,5.3.1,Clock in,Clock in saves the wrong location name,"We have two shops in the same building. When I clock in at one, the timesheet shows the other shop's name." BUG-2131,2026-11-16,support,ios,5.3.1,Notifications,Duplicate notification when a shift is assigned,"Several staff at one customer get two identical push alerts for each newly assigned shift." BUG-2132,2026-11-17,qa,web,5.3.2,Staff,Searching Zoe does not return Zoë,"Staff list search ignores people whose names have an accented letter unless you type the accent." BUG-2133,2026-11-17,customer,web,5.3.2,Profile,Profile photo upload fails with no message,"Photos over 2 MB do not upload. The spinner stops and nothing happens. No error is shown." BUG-2134,2026-11-18,customer,web,5.3.2,Reports,Overtime hours not in cost total,"Our labor cost total for the week of Nov 9 leaves out 14 overtime hours. The hours show in their own column." BUG-2135,2026-11-18,support,web,5.3.2,Schedule,Shift duplicated after drag to a new day,"Manager moved a shift by dragging it to Friday in Safari and now has the same shift on both days." BUG-2136,2026-11-19,customer,ios,5.3.2,Clock in,Clock out button missing after shift was edited,"My manager changed my end time during my shift. After that the Clock out button was gone and I had to ask her to end it for me." BUG-2137,2026-11-19,customer,android,5.3.2,Email,Weekly summary email shows last week's dates,"The Monday summary email lists the right shifts but the heading shows the dates of the week before." BUG-2138,2026-11-20,support,ios,5.3.2,Time off,"Requested 0.5 day, balance dropped by 1","Three employees at one customer. Each asked for a half day and each lost a full day from their balance." BUG-2139,2026-11-20,qa,web,5.3.2,Availability,Recurring availability lost after editing one day,"Set availability to repeat weekly, then edit a single Wednesday. All the other weeks go back to blank." BUG-2140,2026-11-23,customer,web,5.3.2,Schedule,Times in the spreadsheet export do not match the screen,"Screen says 9:00 to 17:00. The exported CSV says 8:00 to 16:00 for the same shift. Same for every row." BUG-2141,2026-11-23,customer,ios,5.3.2,Clock in,Clock in button inactive even though I am on site,"Button is grey. I am in the shop. Location is allowed while using the app." BUG-2142,2026-11-24,support,web,5.3.2,Open shifts,Open shifts page slow with many staff,"A customer with 320 staff waits 20 seconds or more for the open shifts page to load." BUG-2143,2026-10-30,support,web,5.3.0,Login,"Cannot reset password, link invalid","Imported late from the support inbox. Customer clicked the reset link seconds after the email came and got an expired message." BUG-2144,2026-11-04,support,web,5.3.0,Swaps,Approving a swap does not remove the original employee,"Imported late from the support inbox. After approval both names are on the shift."
output/groups.csv · written by the agent, 45 lines
bug_id,group,role,duplicate_of,bug_name BUG-2101,G1,original,,Exporting the weekly schedule to CSV gives start and end times one hour earlier than the schedule screen shows (since the Nov 1 clock change). BUG-2102,G2,duplicate,BUG-2143,Tapping the emailed password reset link right away shows 'This link has expired'. BUG-2103,G3,original,,The Clock in button stays greyed out on site when location permission is set to 'only while using the app'. BUG-2104,G4,original,,The labor cost report total leaves out the overtime hours that show in the overtime column. BUG-2105,,single,,Exporting the weekly schedule to PDF cuts off the Sunday column. BUG-2106,G5,original,,Approving a half day (0.5) time off request deducts a full day from the balance. BUG-2107,G6,original,,Approving a shift swap adds the new person but leaves the original person on the shift too. BUG-2108,G7,original,,Assigning a shift sends the employee the same push notification twice. BUG-2109,G8,original,,"Searching staff without the accent (e.g. Jose, Zoe) does not return names with accented letters (José, Zoë)." BUG-2110,G1,duplicate,BUG-2101,Exporting the weekly schedule to CSV gives start and end times one hour earlier than the schedule screen shows (since the Nov 1 clock change). BUG-2111,,single,,"Viewing the availability screen in dark mode shows day labels in dark grey on black, unreadable." BUG-2112,,single,,Requesting a password reset for an email address containing a plus sign never delivers the reset email. BUG-2113,G9,original,,Opening a shift with a very long note (about 500+ characters) crashes the mobile app. BUG-2114,G10,original,,"Dragging a shift to another day in Safari copies it instead of moving it, leaving it on both days." BUG-2115,,single,,"Requesting a shift swap does not send any notification to the manager, so the request sits pending unseen." BUG-2116,G4,duplicate,BUG-2104,The labor cost report total leaves out the overtime hours that show in the overtime column. BUG-2117,,single,,Previewing January with carry over switched on does not add leftover time off days to next year's balance. BUG-2118,,single,,Viewing the calendar with the phone set to a 12 hour clock shows 24 hour times (17:00 instead of 5:00 PM). BUG-2119,G2,duplicate,BUG-2143,Tapping the emailed password reset link right away shows 'This link has expired'. BUG-2120,,single,,The billing page text misspells 'receive' as 'recieve'. BUG-2121,G3,duplicate,BUG-2103,The Clock in button stays greyed out on site when location permission is set to 'only while using the app'. BUG-2122,G6,duplicate,BUG-2107,Approving a shift swap adds the new person but leaves the original person on the shift too. BUG-2123,,single,,Opening the staff invite link from the welcome email in Android Chrome shows a blank white page. BUG-2124,,single,,The labor cost report for the Canada location shows totals in US dollars with no CA marker. BUG-2125,,single,,"Assigning a new shift sends the email about it three to four hours late, while the push arrives on time." BUG-2126,G5,duplicate,BUG-2106,Approving a half day (0.5) time off request deducts a full day from the balance. BUG-2127,G9,duplicate,BUG-2113,Opening a shift with a very long note (about 500+ characters) crashes the mobile app. BUG-2128,G1,duplicate,BUG-2101,Exporting the weekly schedule to CSV gives start and end times one hour earlier than the schedule screen shows (since the Nov 1 clock change). BUG-2129,,single,,"Building a schedule lists an archived, closed location (Elm Street) in the location dropdown." BUG-2130,,single,,Clocking in at one of two shops in the same building records the other shop's name on the timesheet. BUG-2131,G7,duplicate,BUG-2108,Assigning a shift sends the employee the same push notification twice. BUG-2132,G8,duplicate,BUG-2109,"Searching staff without the accent (e.g. Jose, Zoe) does not return names with accented letters (José, Zoë)." BUG-2133,,single,,Uploading a profile photo over 2 MB fails silently with no error message. BUG-2134,G4,duplicate,BUG-2104,The labor cost report total leaves out the overtime hours that show in the overtime column. BUG-2135,G10,duplicate,BUG-2114,"Dragging a shift to another day in Safari copies it instead of moving it, leaving it on both days." BUG-2136,,single,,"After a manager edits the end time during a shift, the Clock out button disappears for the employee." BUG-2137,,single,,The Monday weekly summary email shows the right shifts but the previous week's dates in the heading. BUG-2138,G5,duplicate,BUG-2106,Approving a half day (0.5) time off request deducts a full day from the balance. BUG-2139,,single,,Editing a single day of weekly repeating availability blanks the other weeks. BUG-2140,G1,duplicate,BUG-2101,Exporting the weekly schedule to CSV gives start and end times one hour earlier than the schedule screen shows (since the Nov 1 clock change). BUG-2141,G3,duplicate,BUG-2103,The Clock in button stays greyed out on site when location permission is set to 'only while using the app'. BUG-2142,,single,,Loading the open shifts page for a customer with 320 staff takes 20 seconds or more. BUG-2143,G2,original,,Tapping the emailed password reset link right away shows 'This link has expired'. BUG-2144,G6,duplicate,BUG-2107,Approving a shift swap adds the new person but leaves the original person on the shift too.
output/summary.md · written by the agent, 17 lines
Reports read: 44 Duplicate groups: 10 Duplicates to close: 17 Distinct bugs left: 27 - G1: original BUG-2101; Exporting the weekly schedule to CSV gives start and end times one hour earlier than the schedule screen shows (since the Nov 1 clock change). Duplicates: BUG-2110, BUG-2128, BUG-2140 - G2: original BUG-2143; Tapping the emailed password reset link right away shows 'This link has expired'. Duplicates: BUG-2102, BUG-2119 - G3: original BUG-2103; The Clock in button stays greyed out on site when location permission is set to 'only while using the app'. Duplicates: BUG-2121, BUG-2141 - G4: original BUG-2104; The labor cost report total leaves out the overtime hours that show in the overtime column. Duplicates: BUG-2116, BUG-2134 - G5: original BUG-2106; Approving a half day (0.5) time off request deducts a full day from the balance. Duplicates: BUG-2126, BUG-2138 - G6: original BUG-2107; Approving a shift swap adds the new person but leaves the original person on the shift too. Duplicates: BUG-2122, BUG-2144 - G7: original BUG-2108; Assigning a shift sends the employee the same push notification twice. Duplicates: BUG-2131 - G8: original BUG-2109; Searching staff without the accent (e.g. Jose, Zoe) does not return names with accented letters (José, Zoë). Duplicates: BUG-2132 - G9: original BUG-2113; Opening a shift with a very long note (about 500+ characters) crashes the mobile app. Duplicates: BUG-2127 - G10: original BUG-2114; Dragging a shift to another day in Safari copies it instead of moving it, leaving it on both days. Duplicates: BUG-2135 Notes: BUG-2119 has no description, so it was grouped on its title alone (forgot password link says expired). BUG-2143 is the original of G2 because it was reported 2026-10-30, earlier than BUG-2102. Kept apart on purpose: BUG-2105 (PDF export cuts Sunday, not a time shift), BUG-2112 (reset email never arrives), BUG-2115 (swap notification, not the double booking), BUG-2125 (email late, not duplicate push), BUG-2124 (currency symbol, not missing overtime), BUG-2130 and BUG-2136 (other Clock in problems).
check.py · the check, written before the run
"""Compares the agent's duplicate groups with groups marked by hand, and recomputes originals and counts."""
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)
bugs = {r["bug_id"]: r for r in csv.DictReader((root/"input/bug_backlog.csv").open())}
# Marked by hand before the run, from reading every report: the reports that describe the same bug.
KEY = [[2101, 2110, 2128, 2140], [2102, 2119, 2143], [2107, 2122, 2144], [2113, 2127], [2106, 2126, 2138],
[2108, 2131], [2104, 2116, 2134], [2109, 2132], [2114, 2135], [2103, 2121, 2141]]
key = {frozenset(f"BUG-{n}" for n in g) for g in KEY}
key_singles = set(bugs) - {b for g in key for b in g}
path = root/"output/groups.csv"
if not path.exists():
say(False, "output/groups.csv was not written"); sys.exit(1)
rows = list(csv.DictReader(path.open()))
ids = [(r.get("bug_id") or "").strip() for r in rows]
once = sum(1 for b in bugs if ids.count(b) == 1)
say(once == len(bugs) and len(rows) == len(bugs), f"{once} of {len(bugs)} reports appear once in groups.csv")
got = {}
for r in rows:
g = (r.get("group") or "").strip()
if g: got.setdefault(g, set()).add((r.get("bug_id") or "").strip())
groups = {frozenset(v) for v in got.values()}
extra = len(groups - key)
say(len(groups & key) == len(key) and extra == 0,
f"{len(groups & key)} of {len(key)} duplicate groups equal the groups marked by hand before the run, with {extra} other groups made")
by_id = {(r.get("bug_id") or "").strip(): r for r in rows}
alone = sum(1 for b in key_singles if b in by_id and not (by_id[b].get("group") or "").strip() and (by_id[b].get("role") or "").strip() == "single")
say(alone == len(key_singles), f"{alone} of {len(key_singles)} reports with no duplicate are left on their own")
orig_ok = dup_ok = dups = 0
for g, members in got.items():
known = [b for b in members if b in bugs]
first = min(known, key=lambda b: (bugs[b]["reported_on"], b)) if known else None
originals = [b for b in members if (by_id[b].get("role") or "").strip() == "original"]
orig_ok += originals == [first]
for b in members - set(originals):
dups += 1
dup_ok += (by_id[b].get("role") or "").strip() == "duplicate" and (by_id[b].get("duplicate_of") or "").strip() == first
say(bool(got) and orig_ok == len(got), f"{orig_ok} of {len(got)} groups keep the earliest report as the original")
say(dups > 0 and dup_ok == dups, f"{dup_ok} of {dups} duplicates point at the original of their own group")
summary = (root/"output/summary.md").read_text() if (root/"output/summary.md").exists() else ""
want = {"Reports read": len(rows), "Duplicate groups": len(got), "Duplicates to close": dups, "Distinct bugs left": len(rows) - dups}
stated = {}
for label in want:
m = re.search(re.escape(label) + r":\D{0,4}(\d+)", summary)
stated[label] = int(m.group(1)) if m else None
say(stated == want, "summary.md states " + ", ".join(f"{label.lower()} {stated[label]}" for label in want) + " and all four equal the counts in groups.csv")
# Stricter lines added after the run: names and the group lines of the summary are compared with the table and the reports.
name_of = lambda b: " ".join((by_id[b].get("bug_name") or "").split())
named = sum(1 for b in by_id if len(name_of(b).split()) >= 4)
one_name = sum(1 for members in got.values() if len({name_of(b) for b in members}) == 1)
say(named == len(rows) and one_name == len(got), f"{named} of {len(rows)} reports carry a bug name and {one_name} of {len(got)} groups use one name on all their rows")
digits = lambda s: re.findall(r"\d+(?:\.\d+)?", s)
nums = nums_ok = 0
for b in by_id:
mates = next((m for m in got.values() if b in m), {b})
src = set(digits(" ".join(bugs[x]["title"] + " " + bugs[x]["description"] for x in mates if x in bugs)))
for x in digits(name_of(b)):
nums += 1; nums_ok += x in src
say(nums_ok == nums, f"{nums_ok} of {nums} numbers written in bug names are found in the reports they describe")
glines = {}
for line in summary.splitlines():
m = re.match(r"^\W*(G\d+)\b", line)
if m: glines.setdefault(m.group(1), []).append(" ".join(line.split()))
def line_ok(g, members):
if len(glines.get(g, [])) != 1: return False
line = glines[g][0]
found = re.findall(r"BUG-\d+", line)
originals = [b for b in members if (by_id[b].get("role") or "").strip() == "original"]
return len(originals) == 1 and found[:1] == originals and set(found) == set(members) and len(found) == len(members) \
and name_of(originals[0]).rstrip(".") in line
lined = sum(1 for g, members in got.items() if line_ok(g, members))
say(bool(got) and lined == len(got) and len(glines) == len(got), f"{lined} of {len(got)} group lines in summary.md give the original first, then the bug name and the duplicates that groups.csv holds")
sys.exit(0 if ok else 1)
bug_backlog.csv: sample data written by Atris. Fingerprint 04262aa289a2.
groups.csv: written by the agent. Fingerprint 1d4ec5d0bab7.
summary.md: written by the agent. Fingerprint a7ef751a81f3.