Skip to content

Commit 2801bec

Browse files
fix(reporting): a name repeated for one tool id is not ambiguous (#364)
Ambiguity is two tools answering to a name, not two catalog rows. Marking a repeated row ambiguous pushed a resolvable name-only finding back into its own heading for no reason. Co-Authored-By: Claude Opus 5 <[email protected]>
1 parent 244471c commit 2801bec

2 files changed

Lines changed: 30 additions & 2 deletions

File tree

‎src/agents_shipgate/core/findings/subject_rollup.py‎

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -353,8 +353,10 @@ def _tool_id_by_name(report: ReadinessReport) -> dict[str, str]:
353353
name = str(row.get("name") or "").strip()
354354
if not tool_id or not name:
355355
continue
356-
# None marks a name that more than one tool answers to.
357-
seen[name] = None if name in seen else str(tool_id)
356+
# None marks a name that more than one *tool* answers to. A name
357+
# repeated for one id is one tool listed twice, which resolves.
358+
previous = seen.get(name, str(tool_id))
359+
seen[name] = str(tool_id) if previous == str(tool_id) else None
358360
return {name: tool_id for name, tool_id in seen.items() if tool_id}
359361

360362

‎tests/test_subject_rollup.py‎

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1024,6 +1024,32 @@ def test_a_finding_carrying_only_a_name_joins_that_tools_group():
10241024
}
10251025

10261026

1027+
def test_one_tool_listed_twice_is_not_an_ambiguous_name():
1028+
"""Ambiguity is two *tools* answering to a name, not two rows.
1029+
1030+
Marking a repeated catalog row ambiguous would push a resolvable finding
1031+
back into its own heading for no reason.
1032+
"""
1033+
1034+
unkeyed = Finding(
1035+
check_id="SHIP-BASELINE-INTEGRITY-MISMATCH",
1036+
title="create_refund baseline entry does not match",
1037+
severity="high",
1038+
category="baseline",
1039+
recommendation="re-save the baseline",
1040+
tool_id=None,
1041+
tool_name="create_refund",
1042+
agent_id="agent:p/a",
1043+
)
1044+
row = {"tool_id": "tool_v2_aaaa", "name": "create_refund", "provider": "stripe"}
1045+
report = _report_with(
1046+
[unkeyed], catalog=[row, dict(row)], agent={"id": "agent:p/a", "name": "a"}
1047+
)
1048+
1049+
(group,) = roll_up_findings(report)
1050+
assert group.subject == "create_refund [stripe]"
1051+
1052+
10271053
def test_an_ambiguous_name_is_left_unresolved_rather_than_guessed():
10281054
"""Two tools can share a name across sources.
10291055

0 commit comments

Comments
 (0)