fix(hermes): make triage session titles unique

This commit is contained in:
jenkins 2026-08-13 00:56:51 -03:00
parent 37ac5ff11f
commit 33df446a68
3 changed files with 9 additions and 6 deletions

View File

@ -30,14 +30,14 @@ TRIAGE_PARENT_TITLE = "Automated triage"
TRIAGE_MESSAGE_PREFIX = "A static-analysis finding, not a build failure."
def _triage_title(message: str) -> str:
def _triage_title(message: str, session_id: str) -> str:
"""Create a concise label from Ariadne's stable incident contract."""
match = re.search(r"for incident ([^\s]+)\.", message)
if not match:
return "Automated triage run"
return f"Automated triage run · {session_id[-8:]}"
parts = match.group(1).split("/")
label = " · ".join(parts[1:3]) if len(parts) >= 3 else match.group(1)
return f"Sonar · {label}"
return f"Sonar · {label} · {session_id[-8:]}"
def migrate_triage_group(connection: sqlite3.Connection) -> int:
@ -75,7 +75,7 @@ def migrate_triage_group(connection: sqlite3.Connection) -> int:
WHERE id = ?
AND parent_session_id IS NULL
""",
(TRIAGE_PARENT, _triage_title(str(message or "")), session_id),
(TRIAGE_PARENT, _triage_title(str(message or ""), session_id), session_id),
)
changed += cursor.rowcount
return changed

View File

@ -96,7 +96,7 @@ RUNS_AFTER = ''' run_id = f"run_{uuid.uuid4().hex}"
if incident and parent_session_id == default_parent:
parts = incident.group(1).split("/")
label = " · ".join(parts[1:3]) if len(parts) >= 3 else incident.group(1)
db.set_session_title(session_id, f"Sonar · {label}")
db.set_session_title(session_id, f"Sonar · {label} · {session_id[-8:]}")
# Approval queues gate host-side tool execution and must be isolated
'''

View File

@ -1101,7 +1101,10 @@ def test_automated_triage_sessions_are_grouped_without_touching_interactive_runs
"SELECT parent_session_id FROM sessions WHERE id = 'interactive-run'"
).fetchone()
assert parent == (module.TRIAGE_PARENT_TITLE,)
assert triage == (module.TRIAGE_PARENT, "Sonar · bstein_home · python:S2208")
assert triage == (
module.TRIAGE_PARENT,
"Sonar · bstein_home · python:S2208 · iage-run",
)
assert interactive == (None,)