const VERSION_LABEL_PREFIX = "affects-"; const NEEDS_VERSION_LABEL = "needs-version-info"; const RETEST_LABEL = "needs-retest-on-latest"; const NEEDS_DECOMPOSITION_LABEL = "needs-decomposition"; const BUG_LABEL = "bug"; const DOCS_LABEL = "documentation"; const ENHANCEMENT_LABEL = "enhancement"; function escapeRegExp(value) { return String(value || "").replace(/[.*+?^${}()|[\]\\]/g, "\\$&"); } // Use the same locked GFM lexer as Pulse's Markdown surfaces, without // rendering or executing any issue content. Only top-level declarations count. const { Lexer, lexer } = require("marked"); // Keep one immutable Markdown snapshot per classification decision. Reports can // contain long copied logs; reparsing that body for each field adds work without // adding evidence. Never share this context across reports or event revisions. function parseReportMarkdown(body) { const tokens = lexer(String(body || ""), { gfm: true }); return { lines: projectDeclarationLines(tokens), links: tokens.links }; } function lexFieldValue(value, report) { // Reference links can be defined anywhere in the report. Extracting a field // must not discard that context and turn visible declarations into missing // versions or invented topics. Use only the locked parser's definitions; // destinations are never fetched or treated as declaration text. const fieldLexer = new Lexer({ gfm: true }); // Field lexing can add definitions. Do not let it mutate the shared report // definitions or change the meaning of a sibling field. fieldLexer.tokens.links = Object.assign(Object.create(null), report.links); return fieldLexer.lex(value); } function inlineProjection(tokens) { return (tokens || []).map((token) => { const raw = token.raw || ""; // Keep line positions when removing hidden comments. A comment inside a // code span is a literal, not an HTML token, and remains evidence. if (token.type === "html" && /^