Bug writeups section (benchmark 30).
(q, bug_count)
| 1440 | |
| 1441 | |
| 1442 | def check_writeups(q, bug_count): |
| 1443 | """Bug writeups section (benchmark 30).""" |
| 1444 | print("[Bug Writeups]") |
| 1445 | if bug_count <= 0: |
| 1446 | return |
| 1447 | |
| 1448 | writeups_dir = _resolve_artifact_path(q, "writeups") |
| 1449 | writeup_count = 0 |
| 1450 | writeup_diff_count = 0 |
| 1451 | empty_diff_writeups = [] |
| 1452 | sentinel_writeups = [] |
| 1453 | if writeups_dir.is_dir(): |
| 1454 | writeup_files = sorted(p for p in writeups_dir.glob("BUG-*.md") if p.is_file()) |
| 1455 | writeup_count = len(writeup_files) |
| 1456 | for wf in writeup_files: |
| 1457 | try: |
| 1458 | text = wf.read_text(encoding="utf-8", errors="replace") |
| 1459 | except OSError: |
| 1460 | continue |
| 1461 | # Presence test uses the same regex as the content test so the |
| 1462 | # two can never disagree on whether a fence exists. Case-insensitive |
| 1463 | # match accepts ```diff / ```Diff / ```DIFF uniformly — operators |
| 1464 | # routinely uppercase the fence tag and the gate must not silently |
| 1465 | # skip those writeups (the content non-emptiness check would then |
| 1466 | # never fire, producing a confusing "no inline fix diffs" FAIL on a |
| 1467 | # writeup that visibly contains a unified diff). |
| 1468 | if _WRITEUP_DIFF_BLOCK_RE.search(text): |
| 1469 | writeup_diff_count += 1 |
| 1470 | if not _writeup_diff_is_non_empty(text): |
| 1471 | empty_diff_writeups.append(wf.name) |
| 1472 | if any(s in text for s in _WRITEUP_TEMPLATE_SENTINELS): |
| 1473 | sentinel_writeups.append(wf.name) |
| 1474 | |
| 1475 | if writeup_count >= bug_count: |
| 1476 | pass_(f"{writeup_count} writeup(s) for {bug_count} bug(s)") |
| 1477 | elif writeup_count > 0: |
| 1478 | fail(f"{writeup_count} writeup(s) for {bug_count} bug(s) — all confirmed bugs require writeups (SKILL.md line 1454)") |
| 1479 | else: |
| 1480 | fail(f"No writeups for {bug_count} confirmed bug(s)") |
| 1481 | |
| 1482 | if writeup_count > 0: |
| 1483 | if writeup_diff_count >= writeup_count: |
| 1484 | pass_(f"All {writeup_diff_count} writeup(s) have inline fix diffs") |
| 1485 | elif writeup_diff_count > 0: |
| 1486 | fail(f"Only {writeup_diff_count}/{writeup_count} writeup(s) have inline fix diffs (all require section 6 diff)") |
| 1487 | else: |
| 1488 | fail("No writeups have inline fix diffs (section 6 'The fix' must include a ```diff block)") |
| 1489 | |
| 1490 | # Non-empty-diff content check. A ```diff fence with no `+`/`-` body |
| 1491 | # is a template stub — the legacy presence-only check let these pass. |
| 1492 | if empty_diff_writeups: |
| 1493 | preview = ", ".join(empty_diff_writeups[:5]) |
| 1494 | suffix = f" (+{len(empty_diff_writeups) - 5} more)" if len(empty_diff_writeups) > 5 else "" |
| 1495 | fail( |
| 1496 | f"{len(empty_diff_writeups)} writeup(s) have empty ```diff blocks " |
| 1497 | f"(fence present, no +/- lines): {preview}{suffix}" |
| 1498 | ) |
| 1499 | else: |
no test coverage detected