> Agent-ready spec from Diff of the Day (2026-11-29, idea 4). Give this file to your coding agent (Claude Code, Codex, Cursor) and ask it to build the P0 requirements first.

# Spec: Duplicate-report triage for issue trackers

## Problem Statement
Donald Knuth paused errata for reports sent after 25 Nov 2026: LLM-assisted readers now send reports faster than he can verify them, and random sampling showed most recent ones repeat issues already reported. Open-source maintainers see the same flood in their issue trackers. A tool that groups likely duplicates before a human reads them would give that time back.

## Goals
- Group new issues with likely duplicates among open and closed issues, with a similarity score.
- Reach at least 80% precision on duplicates on a labelled sample from your repo.
- Process 1,000 issues in under five minutes on a laptop.
- Never close or edit issues automatically.

## Non-Goals
- Auto-closing: a person decides.
- Fixing the reported bugs: triage only.
- Judging whether a report is AI-written: duplicates matter, authorship does not.

## User Stories
- As a maintainer, I want a list of today's new issues with their closest existing matches so that I read each problem once.
- As a maintainer, I want a confidence score so that I check high scores first.
- As a contributor, I want a suggested link to the existing issue so that I can add details there.
- Edge case: as a maintainer, I want issues with very short text marked as unsure, so that they are not wrongly grouped.

## Requirements
### P0 (must have)
1. **Importer**: read issues from a JSON export or the GitHub REST API with a read-only token from an environment variable.
2. **Embedding index** of title plus body for all issues, stored locally.
   - [ ] Re-running only embeds new or edited issues.
3. **Matcher**: top three matches per new issue above a threshold.
   - [ ] On a labelled set of 50 pairs, precision is printed.
4. **Report**: Markdown table of new issue, best match, score.

### P1 (nice to have)
- Draft a polite comment pointing to the original, saved as a file for a human to post.
- Cluster view for bursts of similar reports.

### P2 (future)
- Run as a scheduled job and post the report to a discussion.

## Success Metrics
- Leading: precision of at least 80% on your labelled sample.
- Lagging: time to first response on new issues drops in the month after.

## Open Questions
- Local embedding model or a hosted API? (you)

## Timeline
Two evenings.

## Agent Instructions
- **Suggested stack**: Python 3.12, a small local embedding model, SQLite for the index.
- **Build order**: importer with fixtures → index → matcher with precision test → report.
- **Safety**: read-only token; never write to the tracker in v1; keep the token out of logs.
- **Done when**: the report lists matches for a real week of issues and precision is printed.

## Sources
- Knuth, Moratorium: https://www-cs-faculty.stanford.edu/~knuth/moratorium.html
