From b29b708fb87203849e6ac99502d0ed409d9c19c5 Mon Sep 17 00:00:00 2001 From: Krzysztof kuhy Rudnicki Date: Sun, 22 Nov 2026 17:12:58 +0100 Subject: [PATCH] Match the todo server's note title in dedup The real server lists a new note as " todos: ", so the exact-title check never found the open task and a repeat failure would have filed a duplicate. Seen while filing the one real verification task. The fake server now titles notes the same way. Todo: 85af719b Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> --- steam_backlog_enforcer/_todo_filing.py | 11 +++++++++-- steam_backlog_enforcer/tests/_fake_todo_mcp.py | 17 ++++++++++++++++- 2 files changed, 25 insertions(+), 3 deletions(-) diff --git a/steam_backlog_enforcer/_todo_filing.py b/steam_backlog_enforcer/_todo_filing.py index 9d8f940..68c3a49 100644 --- a/steam_backlog_enforcer/_todo_filing.py +++ b/steam_backlog_enforcer/_todo_filing.py @@ -142,10 +142,17 @@ def _parse(ctype: str, body: str) -> dict[str, Any]: def _open_task(listing: str, title: str) -> str | None: - """The id of an open task in *listing* titled exactly *title*.""" + """The id of an open task in *listing* titled *title*. + + The server lists a new note as ``<repo name> todos: <title>``, so the + title matches exactly or as that suffix. + """ for row in listing.splitlines(): parts = row.split("\t") - if len(parts) >= _COLUMNS and re.sub(r"^#+\s*", "", parts[4].strip()) == title: + if len(parts) < _COLUMNS: + continue + listed = re.sub(r"^#+\s*", "", parts[4].strip()) + if listed == title or listed.endswith(f": {title}"): return parts[0] return None diff --git a/steam_backlog_enforcer/tests/_fake_todo_mcp.py b/steam_backlog_enforcer/tests/_fake_todo_mcp.py index aa2ffe9..3eaf562 100644 --- a/steam_backlog_enforcer/tests/_fake_todo_mcp.py +++ b/steam_backlog_enforcer/tests/_fake_todo_mcp.py @@ -42,8 +42,18 @@ class FakeTodo(ThreadingHTTPServer): """Answer one tool call the way the real server words it.""" self.calls.append(name) if name == "list_tasks": + # The real server titles a new note "<repo name> todos: <title>". rows = [ - f"{t['id'][:8]}\ttodo\t{t['priority']}\t{t['repo']}\t{t['title']}\tclaude" + "\t".join( + ( + t["id"][:8], + "todo", + t["priority"], + t["repo"], + _listed(t), + "claude", + ) + ) for t in self.tasks if t["repo"] == args.get("repo") ] @@ -55,6 +65,11 @@ class FakeTodo(ThreadingHTTPServer): return f"added {task['id']}\n{task['id'][:8]}\ttodo\tmedium\t{task['repo']}" +def _listed(task: dict[str, Any]) -> str: + """The title list_tasks shows for *task*, as the real server words it.""" + return f"{task['repo'].split('/')[-1]} todos: {task['title']}" + + class _Handler(BaseHTTPRequestHandler): server: FakeTodo