| 2352 | // category or severity has no rank and no enum membership, so it falls through |
| 2353 | // to the normal inline path (visible), never dropped. |
| 2354 | function routeComment(comment, policy) { |
| 2355 | if (!policy || (!policy.routeBySeverity && !policy.routeByCategory)) { |
| 2356 | return { routed: false }; |
| 2357 | } |
| 2358 | const catRaw = comment && comment.category != null ? String(comment.category).trim().toLowerCase() : ""; |
| 2359 | const sevRaw = comment && comment.severity != null ? String(comment.severity).trim().toLowerCase() : ""; |
| 2360 | const catKnown = catRaw !== "" && CATEGORIES.includes(catRaw); |
| 2361 | const sevKnown = sevRaw !== "" && SEVERITY_RANK.has(sevRaw); |
| 2362 | |
| 2363 | if (policy.routeBySeverity && sevKnown && SEVERITY_RANK.get(sevRaw) <= policy.severityRank) { |
| 2364 | return { routed: true, reason: `Routed to summary (severity ${sevRaw}${catKnown ? ` · category ${catRaw}` : ""})` }; |
| 2365 | } |
| 2366 | if (policy.routeByCategory && catKnown && policy.categories.has(catRaw)) { |
| 2367 | return { routed: true, reason: `Routed to summary (category ${catRaw}${sevKnown ? ` · severity ${sevRaw}` : ""})` }; |
| 2368 | } |
| 2369 | return { routed: false }; |
| 2370 | } |
| 2371 | |
| 2372 | // ---- Formatting helpers (ported verbatim) ---- |
| 2373 | |