Preserve copied-evidence boundaries when reading feedback fields

Keep the original Markdown declaration flags while extracting the complete selection. Copied code, quotations and raw HTML neither supply nor veto feedback metadata; retain the complete-field and mutable-consumer checks alongside that existing safety rule.

Contract-Neutral: Preserve existing silent metadata authority and copied-evidence boundaries; no product subsystem, dependency, wire or rendered application change.
Change-source: pulse-maintainer
This commit is contained in:
pulse-triage[bot]
2026-11-01 05:34:41 +00:00
parent adf41432ad
commit a54948c574
2 changed files with 26 additions and 5 deletions

View File

@@ -185,7 +185,7 @@ function firstFieldValue(lines, start = 0) {
return "";
}
function extractSectionValues(body, heading, followingHeadings = [], report = parseReportMarkdown(body)) {
function extractSectionValues(body, heading, followingHeadings = [], report = parseReportMarkdown(body), declarationsOnly = false) {
if (!body) return [];
const lines = report.lines;
const pattern = new RegExp(`^${escapeRegExp(heading)}$`, "i");
@@ -200,7 +200,8 @@ function extractSectionValues(body, heading, followingHeadings = [], report = pa
boundary.test(lines[end].heading))))) {
end += 1;
}
values.push(lines.slice(start + 1, end).map((line) => line.text).join("\n").trim());
values.push(lines.slice(start + 1, end).map((line) =>
!declarationsOnly || line.declaration ? line.text : "").join("\n").trim());
// A deeper, form-named subheading is part of this value, not another
// declaration. Only resume at the boundary that ended the field.
start = end - 1;
@@ -433,7 +434,9 @@ function classifyFeedbackSelection(feedbackType, report) {
}
function classifyV6FeedbackType(body, report = parseReportMarkdown(body)) {
const classes = extractSectionValues(body, "Feedback type", [], report)
// Preserve the report's original block context. Re-lexing copied code or a
// quote as bare field text could let examples supply or veto a selection.
const classes = extractSectionValues(body, "Feedback type", [], report, true)
.map(value => classifyFeedbackSelection(value, report));
// Repeated declarations must agree on the metadata category. Choosing the
// first can invent a bug and its version requirements from contradictory or

View File

@@ -498,8 +498,6 @@ test("feedback classification examines the complete field instead of its first l
"Documentation issue\nBug / regression",
"Bug / regression\nThis is a question, not a selected form option.",
"Documentation issue\n\nBug / regression",
"Bug / regression\n\n> Documentation issue",
"Bug / regression\n\n```text\nDocumentation issue\n```",
"Bug / regression\n\n![context](https://example.invalid/synthetic.png)",
"Bug / regression\n\n- Documentation issue",
]) {
@@ -526,6 +524,26 @@ test("a complete single choice retains wrapping, hidden comments and shared refe
}
});
test("copied blocks cannot supply or contradict a feedback selection", () => {
for (const copied of [
"> Documentation issue",
"```text\nDocumentation issue\n```",
" Documentation issue",
"<div>Documentation issue</div>",
]) {
for (const newline of ["\n", "\r\n"]) {
for (const selection of [`Bug / regression\n\n${copied}`, `${copied}\n\nBug / regression`]) {
const body = `### Feedback type\n${selection}\n\n### Pulse version\nunknown`
.replaceAll("\n", newline);
assert.equal(triage.internals.classifyV6FeedbackType(body), "bug", selection);
}
const body = `### Feedback type\n${copied}\n\n### Pulse version\nunknown`
.replaceAll("\n", newline);
assert.equal(triage.internals.classifyV6FeedbackType(body), null, copied);
}
}
});
for (const action of ["opened", "edited", "reopened"]) {
test(`${action} ambiguous field content cannot invent labels or lose independent topic review`, async () => {
for (const alreadyBug of [false, true]) {