refactor(server,cli): shared payload-discriminator helper, single-read digest reuse, DOT label escaping

This commit is contained in:
2026-06-12 19:23:05 +04:00
parent 4422aa8b7a
commit 75703ec0c8
4 changed files with 27 additions and 14 deletions
@@ -44,14 +44,16 @@ fun renderEventRows(rows: List<EventRow>): String {
return (listOf(header) + lines).joinToString("\n")
}
private fun String.dotEscape(): String = replace("\\", "\\\\").replace("\"", "\\\"")
fun renderDot(rows: List<EventRow>): String = buildString {
appendLine("digraph session {")
rows.forEach { r ->
appendLine(""""${r.eventId}" [label="${r.type} #${r.sequence}"]""")
appendLine(""""${r.eventId.dotEscape()}" [label="${r.type.dotEscape()} #${r.sequence}"]""")
}
rows.forEach { r ->
r.causationId?.let { causation ->
appendLine(""""${r.eventId}" -> "$causation"""")
appendLine(""""${r.eventId.dotEscape()}" -> "${causation.dotEscape()}"""")
}
}
append("}")