Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
116 changes: 116 additions & 0 deletions packages/cli/src/commands/review/compose-review.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7342,6 +7342,18 @@ describe('composeReview — fixedFindings', () => {
// An inline link's DESTINATION is raw characters, so a backtick in it
// is not a delimiter either.
['see [x](a`b) <details>` here', 'see [x](a`b) &lt;details>` here'],
// A reference link's LABEL is not: MEASURED against cmark-gfm, a
// backtick inside `[a`b][c]`, `[x][a`b]`, `[a`b]` or a link
// reference definition's own label is an ordinary code-span
// delimiter, and the tag it pairs over is code. Ordinary text is
// what this pass already reads them as, so nothing special is
// needed — the rows are here because two audits reasoned the other
// way and neither could build a counterexample (#9940 review,
// rounds 11 and 12).
['see [a`b][c] and <details>` here', 'see [a`b][c] and <details>` here'],
['see [x][a`b] <details>` here', 'see [x][a`b] <details>` here'],
['see [a`b] <details>` here', 'see [a`b] <details>` here'],
['[a`b]: /u <details>` here', '[a`b]: /u <details>` here'],
// …and the `_` rule reaches the LAST label too, not only the one
// before it: `http://a.b_c` does not link, so the backticks pair and
// the tag between them is live.
Expand Down Expand Up @@ -7413,6 +7425,110 @@ describe('composeReview — fixedFindings', () => {
);
});

it('every model-written channel reaches the escape as ONE line — the invariant the per-line escape rests on (#9940 review, round 12 reverse audit)', () => {
// `escapeTagOpeners` models CommonMark INLINE structure only. That is
// correct exactly while every channel folds its text to a line before
// it, and that fold lives at five sites, not one — `ingestEntryList`
// for the entry channels, the `\s+` normalisation for downgrade
// reasons, `collapseEntry` for the disclosures, `scriptLintGate`'s own
// push, and compose's refusal of a line break in a ruling note's `by`.
// `scriptLintGate` is the proof that a SIXTH channel can appear and be
// missed: it joins `bodyCriticals` after `ingestEntryList` has run, and
// for a while it did not fold. This case is the guard for the next one
// — it drives every channel and asserts the CONSEQUENCE, so a new
// channel that skips the fold reddens here instead of rendering a
Comment thread
wenshao marked this conversation as resolved.
Resolved
// literal `&amp;lt;` to a reviewer.
const multiline = [
'the retry helper\n<div class="w"> and `x\nnever clears it',
'the retry helper\r\n<div class="w"> and `x\r\nnever clears it',
'the retry helper\r<div class="w"> and `x\rnever clears it',
];
const carries = (body: string, where: string, escapes = true) => {
const lines = body
.split('\n')
.filter(
(l) =>
l.includes('retry helper') && !l.includes('qwen-review-ledger'),
);
// ONE rendered line, the tag inert, and no `&amp;lt;` — the signature
// of an escape that ran inside a fence the fold should have closed.
expect([where, lines.length]).toEqual([where, 1]);
expect([where, body.includes('&amp;lt;')]).toEqual([where, false]);
Comment thread
wenshao marked this conversation as resolved.
Resolved
// Inert by ESCAPE on the prose channels; the deferral line is a code
// span, where the renderer already holds the tag and an escape would
// show the reader a literal `&lt;`.
expect([
where,
escapes
? lines[0]!.includes('&lt;div class="w">')
: /^- `[^`]*<div class="w">[^`]*`$/.test(lines[0]!),
]).toEqual([where, true]);
};
for (const text of multiline) {
carries(
composeReview(base({ bodyCriticals: [text, 'blocker two'] })).body,
'bodyCriticals',
);
carries(
composeReview(base({ cannotTellCriticals: [text] })).body,
'cannotTellCriticals',
);
carries(
composeReview(
base({
suggestionsInline: 1,
suggestionsDroppedAsDuplicates: [text],
}),
).body,
'suggestionsDroppedAsDuplicates',
);
carries(
composeReview(base({ uncoverableChunks: [text] })).body,
'uncoverableChunks',
);
carries(
composeReview(base({ unreviewedDimensions: [text] })).body,
'unreviewedDimensions',
);
carries(
composeReview(
base({
suggestionsInline: 1,
deferredSuggestions: [
{
file: 'a.ts',
line: 1,
source: 'review',
severity: 'Suggestion',
title: text,
},
],
}),
).body,
'deferredSuggestions',
false,
);
// A ruling note's `by` does not fold — it REFUSES, because the note
// is one posted line and a folded `by` would misquote the author.
expect(() =>
composeReview(base({ fixedFindings: [{ id: 'R1-2', by: text }] })),
).toThrow(/must be ONE non-empty line/);
}
// A quoted FENCE is refused rather than folded on the two Critical
// channels: folding it would join the delimiters onto one line and
// silently change what the author quoted.
const fenced =
'the retry helper\n```\n<div class="w">\n```\nnever clears it';
for (const input of [
{ bodyCriticals: [fenced, 'blocker two'] },
{ cannotTellCriticals: [fenced] },
]) {
expect(() => composeReview(base(input))).toThrow(
/quotes a code fence its one-line render cannot carry/,
);
}
});

it('a raw `<![CDATA[ … > … <details> … ]]>` does not fold the rest of the body away (#9940 review, round 10 reverse audit)', () => {
// The unit rows pin the escape; this pins what the escape is FOR. The
// HTML parser closes the bogus comment at the first `>`, so under the
Expand Down
17 changes: 17 additions & 0 deletions packages/cli/src/commands/review/lib/review-footer.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1078,9 +1078,26 @@ describe('the review footer and the regex that strips it', () => {
'q <!--the auth check at line 40 is missing',
'q <![CDATA[the auth check at line 40 is missing',
'q <?the auth check at line 40 is missing',
// A `<?` whose span leaves prose behind it: what it hides ends at
// the first `>`, so the sentence after that still counts.
'q <?x?> the auth check at line 40 is missing',
'<?x> the auth check at line 40 is missing',
]) {
expect([body, rendersAsNothing(body)]).toEqual([body, false]);
}
// These arms are POSITION-BLIND on purpose, and `&nbsp;<?x>` is the
// shape where that shows: mid-line a `<?` with no `?>` forms nothing
// in the renderer, so its characters are VISIBLE and calling the
// body empty is wrong. The split that would fix it was measured and
// REVERTED — being right about it needs the block structure this
// module does not model, and the half-measure cost more bodies than
// it saved. Pinned so the boundary is a decision on the record
// rather than something the next audit rediscovers; the numbers are
// on `rendersAsNothing` (#9940 review, round 12 reverse audit).
for (const body of ['&nbsp;<?x>', '<?x>', '<?php echo 1 ?>']) {
expect([body, rendersAsNothing(body)]).toEqual([body, true]);
}
expect(rendersAsNothing('q <?x>')).toBe(false);
});

it('still counts real content wearing the same shapes', () => {
Expand Down
23 changes: 23 additions & 0 deletions packages/cli/src/commands/review/lib/review-footer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -902,6 +902,29 @@ function linkRefDefLines(lines: string[], i: number): number {
* toward the verdict, and re-promotes as an unanswerable blocker. This is a
* judgment projection, not a sanitizer, so it is deliberately fence-blind: a
* quotation of scaffolding is still not a finding.
*
* Two further blind spots are DECISIONS, not gaps, and both were measured
* against cmark-gfm and an HTML parser before being left alone (#9940
* review, round 12 reverse audit):
*
* FOLDS. A body whose prose sits inside a `<details>` renders as a
* collapsed triangle — one click from readable, not invisible — and an arm
* that deleted the fold's content would delete a quoted `` `<details>` ``
* too, which is the shape a review OF THIS FILE writes. That trade loses a
* real finding to catch a readable one, so a fold that hides an inline
* comment's whole text posts, and counts.
*
* BLOCK CONTEXT. The `<!` and `<?` arms hide the same span wherever the
* opener stands, though the renderer does not: mid-line a `<?` without its
* `?>` forms nothing and its characters are VISIBLE, while at a line's
* content start it is an HTML block. Splitting the two was tried and
* REVERTED — being right about it needs the block structure this module
Comment thread
wenshao marked this conversation as resolved.
Resolved
* deliberately does not model. Measured on a prose-weighted corpus of
* 30 000 bodies: the split alone traded 121 → 116 bodies wrongly called
* empty for 1426 → 1730 wrongly called visible, and teaching it the
* container prefixes (so `><?…` reads as a block) then needs the
* container's EXTENT as well — without it, 121 → 3594. The arms stay
* position-blind until something in this module knows where a block ends.
*/
/**
* The `<!` family and `<?`, taken as ONE left-to-right decision.
Expand Down
Loading