From 42c51e20a8a7e71c67cd85706738f4e8970bcac8 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 21 Sep 2026 12:26:44 +0000 Subject: [PATCH 1/3] Bump codecov/codecov-action from 7.1.0 to 7.1.1 in the actions-deps group (#1728) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Bumps the actions-deps group with 1 update: [codecov/codecov-action](https://github.com/codecov/codecov-action). Updates `codecov/codecov-action` from 7.1.0 to 7.1.1
Release notes

Sourced from codecov/codecov-action's releases.

v7.1.1

What's Changed

Full Changelog: https://github.com/codecov/codecov-action/compare/v7.1.0...v7.1.1

Commits

[![Dependabot compatibility score](https://dependabot-badges.githubapp.com/badges/compatibility_score?dependency-name=codecov/codecov-action&package-manager=github_actions&previous-version=7.1.0&new-version=7.1.1)](https://docs.github.com/en/github/managing-security-vulnerabilities/about-dependabot-security-updates#about-compatibility-scores) Dependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting `@dependabot rebase`. [//]: # (dependabot-automerge-start) [//]: # (dependabot-automerge-end) ---
Dependabot commands and options
You can trigger Dependabot actions by commenting on this PR: - `@dependabot rebase` will rebase this PR - `@dependabot recreate` will recreate this PR, overwriting any edits that have been made to it - `@dependabot show ignore conditions` will show all of the ignore conditions of the specified dependency - `@dependabot ignore major version` will close this group update PR and stop Dependabot creating any more for the specific dependency's major version (unless you unignore this specific dependency's major version or upgrade to it yourself) - `@dependabot ignore minor version` will close this group update PR and stop Dependabot creating any more for the specific dependency's minor version (unless you unignore this specific dependency's minor version or upgrade to it yourself) - `@dependabot ignore ` will close this group update PR and stop Dependabot creating any more for the specific dependency (unless you unignore this specific dependency or upgrade to it yourself) - `@dependabot unignore ` will remove all of the ignore conditions of the specified dependency - `@dependabot unignore ` will remove the ignore condition of the specified dependency and ignore conditions
Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- .github/workflows/validate-task.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/validate-task.yml b/.github/workflows/validate-task.yml index 25f55246d..d0375e325 100644 --- a/.github/workflows/validate-task.yml +++ b/.github/workflows/validate-task.yml @@ -347,7 +347,7 @@ jobs: # Report-only: fail_ci_if_error is false so a Codecov hiccup or an absent token never fails the gate. - name: Upload coverage to Codecov step if: hashFiles('**/*Tests*.csproj') != '' - uses: codecov/codecov-action@0b35c9ecc4f0529d0eb674914510c22f85b196b4 # v7.1.0 + uses: codecov/codecov-action@303a32d7a59b442fa8d48b6a1cc6825c09c847a5 # v7.1.1 with: directory: ./coverage fail_ci_if_error: false @@ -414,7 +414,7 @@ jobs: hashFiles('pyproject.toml') != '' && hashFiles('tests/**') != '' && (hashFiles('uv.lock') != '' || hashFiles('requirements*.txt') != '') continue-on-error: true - uses: codecov/codecov-action@0b35c9ecc4f0529d0eb674914510c22f85b196b4 # v7.1.0 + uses: codecov/codecov-action@303a32d7a59b442fa8d48b6a1cc6825c09c847a5 # v7.1.1 with: token: ${{ secrets.CODECOV_TOKEN }} files: ./coverage.xml From f9b53ef3841c494253d6dacd375116528d87d919 Mon Sep 17 00:00:00 2001 From: Pieter Viljoen Date: Mon, 21 Sep 2026 06:55:01 -0700 Subject: [PATCH 2/3] Read the Coverage Marker Inside a Sentence, and the Two Copilot Finding Shapes (#1726) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Fixes #1722. Fixes #1701. Two digest-reader defects in `scripts/pr_review.py`, each of which blocks a Merge Gate over a review the script could not read rather than over anything wrong with the pull request. They land together because they are the same class of defect in the same file, and one review round over both costs less than two. ## The coverage marker is read within its line, #1722 `is_coverage_line` and `read_coverage` both matched the `fleet-review` marker with `fullmatch`, so it counted only where it occupied its whole line. One of Copilot's two overview formats ends a prose sentence with it instead, and there the digest reported `coverage=unstated` about a round that stated full coverage in plain sight. Requesting another review does not clear it, the next round stating coverage the same way. Both sites are widened, and that matters rather than being belt and braces: `is_coverage_line` is the collector, `coverage_statements` returns only the lines it accepted, and `read_coverage` therefore never saw the line at all. **The anchor was doing one more job than the issue credits it with.** An HTML comment renders invisibly, so a body that wants a marker seen has to quote it, and `coverage_statements` already strips a fenced block and an inline code span ahead of every reader. A blockquote is the third such convention, and the line anchor was excluding one for free, because `>` is not whitespace. That exclusion is now explicit, and it runs to the blank line that closes the quotation rather than to the end of the line opening it, since a line carrying no `>` under one that does is still inside it. Continuation carries paragraph text only, so a line opening its own block ends the quotation above it, which of the three coverage spellings leaves only the reviewer's own sentence quotable. A line carrying both a prose count and a disagreeing marker is refused. Two readings that disagree leave unanswered which one the round meant, which is the case `read_coverage` already returns None for, and refusing it blocks rather than passing. ## The two unread Copilot summary shapes, #1701 `Previously missed (N)` and a severity badge rendered as an inline `picture` element were both reported as unrecognized, and an unrecognized shape blocks the gate on its own. **The issue's open question is settled.** It could not tell whether `(N)` was Copilot's placeholder or the script's substitution, and said a second repository's review would be needed. It is the script's: the live body carries `Previously missed (1)`, and `normal` reduces every count to `(N)` exactly as it does for the suppressed heading beside it. The badge carries its severity only in the `img` `alt`. Every other part is a versioned icon URL, and the set has already been bumped once, so `normal` reduces a badge to that text and nothing keys on the markup. A finding entry cannot be vetted the way a section heading is, its title differing on every finding, so the badge identifies the shape and a stated count separates a section heading from a finding's title. **Vetting the heading alone would have been the wrong fix.** It would have silenced the section while hiding the findings inside it, which is the reverse hazard the issue names. Those entries raise no inline thread, which is a suppressed finding's exact shape, so the section is read the same way: counted across every round, split by head, and printed whole with its severity as a word. It is kept apart from `suppressed=` because the two take different answers, one a finding the reviewer withheld and one it raised outright against code the branch never touched. No exit code rides on it. `pr-review-conduct`'s Merge Gate item 3 enumerates the no-thread finding classes by digest field and now names this one, since an agent working that gate otherwise has no instruction covering a field the digest prints. `scripts/README.md` documents it beside `suppressed=`. ## Review record Five adversarial passes ran before this opened, raising 24 findings between them. The two fixes above were sound from the first pass; every round after it was repairing the machinery built around them. Of note, because the branch's own theme is this defect class: - A badge whose `img` had lost its `alt`, which icon-set drift produces, paired with the next entry's badge and deleted a finding's title and text from the only place those findings appear. - Reading a quoted heading as a raised section, which is reachable from this pull request's own test bodies. - A section anchor that matched anywhere in a line, so the sentence `restores a guard previously missed (2) rounds ago` fabricated a section on a clean round. - Spelling that anchor's whitespace as `\s`, which is Unicode-aware and so overlapped the non-ASCII alternative beside it, making the leading run ambiguous and the parse exponential in it. Twenty-six non-breaking spaces took six seconds. - Two fail-opens on quoted content, a lone closing tag and a tab indent, each letting a quoted coverage line read as the round's own. - `FLEET_REVIEW`'s own leading `\s*`, which the whole-line spelling needed and a search does not, quadratic in the whitespace run it sits in. Each is held by a case that fails without its fix. ## Known residual The section anchor still admits non-ASCII punctuation, so an em dash opening a sentence can read as the section heading. It is narrower than every earlier spelling, which admitted ASCII punctuation too, and closing it means a class of non-ASCII symbols rather than the whole of non-ASCII. A sibling section heading stating no count does not bound a block, which is recorded in `sibling_heading`'s own docstring: the requirement is strictly narrowing, and every vetted heading states a count, so a body reaching it also reports `shapes=UNRECOGNIZED` and tells its reader not to believe the fields beside it. Out of scope and filed separately: #1725, `FLEET_REVIEW` opening on `\s*` means a four-space-indented marker, which is a Markdown code block and so a quotation, reads as a stated coverage line. ## Verification 1641 tests pass. Ruff, mypy, `prose_lint.py`, `repo_gate.py --check eol`, `spec/validate.py` and `build_dist.py --check` are green. Checked against the live review bodies the issues name: the round that was blocking reads `unrecognized=0 coverage=full` with its previously-missed finding surfaced, and the one round still reading `unstated` genuinely carries no coverage statement of any kind. The `comments` label is set because the change adds comment lines deliberately, this file recording the reasoning for each reader beside it rather than in a commit nobody reads next to the code. 🤖 Generated with [Claude Code](https://claude.com/claude-code) --- .agents/skills/pr-review-conduct/SKILL.md | 7 +- .../.source-digests/pr-review-conduct | 2 +- .../skills/pr-review-conduct/SKILL.md | 7 +- .github/skills/pr-review-conduct/SKILL.md | 7 +- scripts/README.md | 2 + scripts/pr_review.py | 387 ++++++++++++-- scripts/tests/test_pr_review.py | 494 ++++++++++++++++++ 7 files changed, 865 insertions(+), 41 deletions(-) diff --git a/.agents/skills/pr-review-conduct/SKILL.md b/.agents/skills/pr-review-conduct/SKILL.md index cbfc433d2..0086d0e9e 100644 --- a/.agents/skills/pr-review-conduct/SKILL.md +++ b/.agents/skills/pr-review-conduct/SKILL.md @@ -74,7 +74,12 @@ visible comments, routinely still carries a finding nobody has answered. Treatin alone reports a clean pass while they stand. The same holds for CodeRabbit's own "outside diff range" comments (`cr_outside_diff` in `pr_review.py`'s digest) and for Qodo's comment-only findings (`qodo_open`): neither opens a `reviewThreads` entry either, so - give each one the same triage the low-confidence findings above already get. Qodo's own + give each one the same triage the low-confidence findings above already get. Copilot's own + section for findings against code the pull request did not change, `Previously missed` in the + review body and `previously_missed` in the digest, is a fourth such class and takes that same + triage. It raises no thread for the same reason the others do not, and a finding it holds is + raised outright rather than withheld, so "the branch did not touch that code" is a reason to + decline one with evidence rather than a reason to leave it unanswered. Qodo's own `Resolved`/`Dismissed` self-tracked badge is a fast pre-triage signal, not a substitute for reading the finding, spot-verify against `gh pr diff` rather than trusting it outright. Copilot's second review-body format states its own finding total, which the digest reads as diff --git a/.claude-plugin/fleet-skills/.source-digests/pr-review-conduct b/.claude-plugin/fleet-skills/.source-digests/pr-review-conduct index c902359c7..ab126c732 100644 --- a/.claude-plugin/fleet-skills/.source-digests/pr-review-conduct +++ b/.claude-plugin/fleet-skills/.source-digests/pr-review-conduct @@ -1 +1 @@ -69eadaf779a1ca01 +69c45b60e15f8124 diff --git a/.claude-plugin/fleet-skills/skills/pr-review-conduct/SKILL.md b/.claude-plugin/fleet-skills/skills/pr-review-conduct/SKILL.md index cbfc433d2..0086d0e9e 100644 --- a/.claude-plugin/fleet-skills/skills/pr-review-conduct/SKILL.md +++ b/.claude-plugin/fleet-skills/skills/pr-review-conduct/SKILL.md @@ -74,7 +74,12 @@ visible comments, routinely still carries a finding nobody has answered. Treatin alone reports a clean pass while they stand. The same holds for CodeRabbit's own "outside diff range" comments (`cr_outside_diff` in `pr_review.py`'s digest) and for Qodo's comment-only findings (`qodo_open`): neither opens a `reviewThreads` entry either, so - give each one the same triage the low-confidence findings above already get. Qodo's own + give each one the same triage the low-confidence findings above already get. Copilot's own + section for findings against code the pull request did not change, `Previously missed` in the + review body and `previously_missed` in the digest, is a fourth such class and takes that same + triage. It raises no thread for the same reason the others do not, and a finding it holds is + raised outright rather than withheld, so "the branch did not touch that code" is a reason to + decline one with evidence rather than a reason to leave it unanswered. Qodo's own `Resolved`/`Dismissed` self-tracked badge is a fast pre-triage signal, not a substitute for reading the finding, spot-verify against `gh pr diff` rather than trusting it outright. Copilot's second review-body format states its own finding total, which the digest reads as diff --git a/.github/skills/pr-review-conduct/SKILL.md b/.github/skills/pr-review-conduct/SKILL.md index cbfc433d2..0086d0e9e 100644 --- a/.github/skills/pr-review-conduct/SKILL.md +++ b/.github/skills/pr-review-conduct/SKILL.md @@ -74,7 +74,12 @@ visible comments, routinely still carries a finding nobody has answered. Treatin alone reports a clean pass while they stand. The same holds for CodeRabbit's own "outside diff range" comments (`cr_outside_diff` in `pr_review.py`'s digest) and for Qodo's comment-only findings (`qodo_open`): neither opens a `reviewThreads` entry either, so - give each one the same triage the low-confidence findings above already get. Qodo's own + give each one the same triage the low-confidence findings above already get. Copilot's own + section for findings against code the pull request did not change, `Previously missed` in the + review body and `previously_missed` in the digest, is a fourth such class and takes that same + triage. It raises no thread for the same reason the others do not, and a finding it holds is + raised outright rather than withheld, so "the branch did not touch that code" is a reason to + decline one with evidence rather than a reason to leave it unanswered. Qodo's own `Resolved`/`Dismissed` self-tracked badge is a fast pre-triage signal, not a substitute for reading the finding, spot-verify against `gh pr diff` rather than trusting it outright. Copilot's second review-body format states its own finding total, which the digest reads as diff --git a/scripts/README.md b/scripts/README.md index 7b0758811..b4b07bcc6 100644 --- a/scripts/README.md +++ b/scripts/README.md @@ -215,6 +215,8 @@ The timeout path prints the full digest for the same reason, as a bare `PENDING` The digest also reports the **suppressed findings** a review body collapses into a `
` block. Those reach no review thread, so a loop that polls threads alone reports a clean pass while they stand, and the [merge gate][governance] counts them as outstanding findings either way. `suppressed=N` counts findings rather than blocks, reading the `(N)` the heading carries, since one body holds one block per round and counting blocks reports two findings as one. It covers **every** round rather than the current head, because a suppressed finding has no resolved state for a push to retire: head-scoping read "superseded by a push" as "answered", and a finding nobody replied to left the digest the moment the branch moved, so the run reported zero. That is how four rounds went unanswered across three pull requests in one day, each found by the maintainer rather than by this script. The summary line splits the count as `suppressed=N (on_head=N earlier=N)` and each block is marked with the round that raised it, since a finding on an older round may since be moot and deciding that is the reader's call rather than one the count should make for them. Each block prints whole where a thread body truncates, because a thread can be re-read at its id and a suppressed finding cannot, and it prints under a marker naming what closing it takes: no thread exists to reply on or resolve, so the answer goes in the PR conversation. +The digest reports the **previously missed findings** the second body format collapses under a counted heading of its own, findings the round raises against code the pull request did not change. They are the suppressed section's structural twin, a counted heading wrapping entries that open no inline thread, so `previously_missed=N (on_head=N earlier=N)` is read, counted, split and printed exactly as `suppressed=` is and for the same reasons, and the [merge gate][governance] counts them as outstanding findings the same way. They are counted apart rather than folded into that field because the two take different answers: a suppressed finding is one the reviewer chose to withhold, and this one it raised outright, so the fact that the branch never touched the code is a reason to decline one with evidence rather than a reason to leave it unanswered. No exit code rides on the field, as none rides on `suppressed=`, and it is printed where a round raised one or the `reviews` window was cut, so a repository whose reviewer never raises one sees no permanent zero while a window that could be hiding a round still says so, as `cr_outside_diff=` does and with the same trailing `+`. Each entry's severity arrives as a theme-switched `picture` element whose only textual carrier is its `img` `alt`, the rest being icon URLs that carry a version the set has already bumped once, so the badge is reduced to that text before the block prints and nothing here keys on the markup around it. + Copilot's reviews arrive in two body formats. None of the ten bodies read here in the second carried a `Suppressed comments` heading, so the reading above found nothing in it, and that format states its own finding total instead, as a count per severity that is summed across the badges the line pairs them with, since reading its first number alone reported two findings for a round stating two of one severity and three of another. The markup is masked to one sentinel before any count is read, a badge carrying digits of its own in its attributes, and a run of more than four digits is an identifier rather than a count, which is the second guard under a mask that can terminate early on a bracket a URL carries itself. Every count the mask left is then summed, rather than each being paired with markup beside it, since which side of a count that markup sits on and whether the severity carries any is presentation rather than structure: a bold split, a bare prose split, and a reference-style link each read as one severity under a paired reading. Summing overstates and never understates, which is the direction chosen deliberately, and its named cost is that a line stating a total and then its context, `12 findings across 4 files`, sums to sixteen. A shortfall overstated prints a block a reader checks against the body and blocks no merge, where one suppressed closes the gate on findings nobody answered. `overview=T/M` reports that total beside the number of review threads the round actually opened, `?` for `T` where no total is found in the overview preamble, since a total absent and a total of zero are different readings. A `?` covers a round stating no total, a round stating one only after its first collapsed section, and a round stating one as a bullet, that last blocking at exit 43 as an unvetted metadata label. None of them says the round withheld nothing. `M` comes from the API rather than the review's prose: that format enumerates the findings it opened threads for, and the anchor each entry links is the database id of that thread's own comment, so the threads are the same set already structured. Reading the enumeration instead took six attempts and four of them cancelled a shortfall by counting something that was not an entry, which needs a Markdown parser to tell apart rather than a line scan. A total larger than the thread count is findings raised where polling threads cannot see them, and a `FINDINGS WITH NO THREAD` block follows naming the shortfall. A thread past the hundred `reviewThreads` reads would count in `M` too, so a cut page overstates the shortfall and `threads=` carries the trailing `+` that says so. The comparison holds while the round's enumeration lists what that round raised, and a format listing findings still open from earlier rounds states a total `M` undercounts, which is a shortfall to confirm against the body rather than to act on from the number. The field is present only where the round covering the head is written in that format, and it is head-scoped where `suppressed=` is not, because a total is one round's statement about one diff and the push that changes that diff raises a round stating its own, where a suppressed block carries the finding text an answer is still owed to. `comment` posts one answer in the pull request conversation. A suppressed finding has no thread, so this is the path that records its disposition. The command reads the pull request node ID in the same run and exposes no ID argument. It confirms the returned comment URL and exact body before it reports success. A missing target exits `65`, and an unconfirmed response exits `66`. An unconfirmed response may still have landed, so its output tells the reader to inspect the conversation before retrying. diff --git a/scripts/pr_review.py b/scripts/pr_review.py index 3a23920e2..cce050b5e 100755 --- a/scripts/pr_review.py +++ b/scripts/pr_review.py @@ -265,6 +265,27 @@ # The alternation is the runbook's, since the heading wording has changed once already. # Matching one phrasing alone reports zero on a review that has them. SUPPRESSED = re.compile(r"Suppressed comments|low confidence", re.IGNORECASE) +# The second overview format's own section for a finding against code the pull request did not change. +# Anchored to the opening of its line, past whatever markup a heading wears, rather than matched anywhere in it. +# The wording is ordinary English, so a body-wide match reads a sentence such as `restores a guard previously missed (2) rounds ago` as this section. +# `marker_blocks` accepts a line on a count alone, which is what lets that sentence through, so the anchor is what separates a heading from prose naming one. +# The opener admits heading markup and anything outside ASCII, and nothing else. +# An emoji is what this format already puts on its verdict headings, and a spelling that admitted no such character read a heading wearing one as no section at all. +# That failure is silent rather than loud, the heading itself being vetted and `normal` dropping the emoji before the comparison, so the digest reports every shape read while the findings reach nobody. +# Widened to any non-word character instead, ordinary punctuation opened the run and a sentence such as `- Previously missed (2) findings were re-raised` became the section, printing the prose around it as the finding. +# Punctuation is what prose opens with and markup is what a heading opens with, so the class is the markup rather than the complement of a word. +# The whitespace is spelled out rather than taken from `\s`, which is Unicode-aware and so overlaps the non-ASCII alternative on every non-ASCII space. +# Two alternatives able to consume the same character make the run ambiguous, and the parse then doubles per character of it on a line that does not go on to say this, which is a hang rather than a slow read. +# A body carrying 30 non-breaking spaces in a line took minutes, and every alternative here now opens on a character the others cannot. +# An emphasis marker is admitted only where no space follows it, which is what tells `**Previously missed (1)**` from the list item `* Previously missed (2) findings`. +# A bullet is the one prose opener that is also heading markup, and `marker_blocks` accepts a line on a count alone, so the list item read as the section and printed the prose around it as findings. +# One character per iteration rather than a run of them, since a repeated group that can split a run of stars more than one way is ambiguous and parses exponentially in it. +# What this still admits is non-ASCII punctuation, an em dash or a typographic quote opening a sentence, which reads that sentence as the section. +# It is narrower than the spelling before it, which admitted ASCII punctuation as well, and the remedy for the rest is a class of non-ASCII symbols rather than the whole of non-ASCII. +PREVIOUSLY_MISSED = re.compile( + r"^(?:]*>|[ \t>#]|[*_](?![ \t])|[^\x00-\x7f])*Previously missed\b", + re.IGNORECASE, +) # CodeRabbit's own equivalent, collapsed into the review body like `SUPPRESSED` rather than raised as an inline comment. CR_OUTSIDE_DIFF = re.compile(r"Outside diff range comments", re.IGNORECASE) # A refusal declines the round as a formal review carrying the head and no threads. @@ -314,10 +335,52 @@ # That one keeps the text requirement, since the name alone does not say the line states coverage. COVERAGE_BULLET = re.compile(r"\s*[-*]\s*\*\*Files reviewed:", re.IGNORECASE) COVERAGE_SENTENCE = re.compile(r"\s*Copilot\b", re.IGNORECASE) +# A blockquote marker (`>` per line, Markdown's own quoting convention) sits in front of every line CodeRabbit wraps its outside-diff section in. +# `HEADING`'s `\s*` does not match `>`, so a heading under one reads as prose without this stripped first. +# Read by two callers for opposite purposes, which is why it is defined here rather than beside either. +# `marker_blocks` strips it to find a heading underneath, and `coverage_statements` refuses the line outright. +# A quoted marker is a quotation whichever convention quotes it, and the coverage reader has no use for what a blockquote carries. +BLOCKQUOTE = re.compile(r"^>+\s?") +# The severity the second overview format now renders as a theme-switched `picture` element. +# Its only textual carrier is the `img` `alt`, every other part being a URL that changes with the icon set. +# The set is versioned in those URLs and has already been bumped once, so matching them would pin this reader to one revision. +# Reduced to the `alt` text rather than dropped, since the severity is the half of a finding entry worth reading. +# Either quoting is read, both being valid HTML and the attribute's own spelling being exactly the kind of presentation this reader exists not to depend on. +# Read in one only, a change of quoting leaves the badge unreduced, which prints two icon URLs per finding and can report the entry as a shape nothing here knows. +# Neither gap may cross a `picture` tag, or one match spans from the first element to a later element's `img`. +# An entry whose own `img` carries no `alt`, which the icon set drifting is exactly how to get, then pairs with the next entry's. +# Everything between, that entry's title and its whole finding text, is replaced by the later severity and lost from the only place these findings appear. +# Bounded, such an entry keeps its markup and reads as an unrecognized shape, which is the failure that reports itself. +SEVERITY_BADGE = re.compile( + r"]*>(?:(?!]*\salt=(?:\"([^\"]*)\"|'([^']*)')[^>]*>" + r"(?:(?!", + re.DOTALL | re.IGNORECASE, +) +# What is left of a finding entry's own heading once the badge above is reduced to its text. +# A finding entry cannot be vetted the way a section heading is, its title being different on every finding. +# The badge is therefore what identifies the shape, and the title after it is free text by design. +# The severity alone does not separate the two, a section being free to name one in its own heading. +# Every vetted section heading here states its count and a finding's title states none, so the absence of one is the other half of the test. +# Without it a section this has no reader for is vetted on its first word, which turns a shape that reports itself into one that is silently passed over. +SEVERITY_TEXT = re.compile(r"(?:critical|high|medium|low)\s+severity\b", re.IGNORECASE) +# The count as `normal` leaves it rather than as the heading wrote it. +# `normal` rewrites every `(\d+)` to `(N)` before a marker is ever compared, so a reader keyed on the digits finds none and reads every section heading as carrying no count. +NORMALIZED_COUNT = re.compile(r"\((?:\d+|N)\)") # Ask the reviewer for a stable coverage shape instead of adapting only to changing prose. # Keep the prose readers for reviews made before the marker shipped. +# Searched within its line rather than matched as the whole of one, because the reviewer writes it both ways. +# It carries no whitespace of its own at either end, which a search has no use for and pays for: an unanchored run of `\s*` is quadratic in the whitespace run it sits in. +# Left in place from the spelling that matched a whole line, a line of 16000 spaces took half a second and 65000 took nine, where the marker itself is what a search is looking for. +# The instruction it is emitted from asks only that the body end with it, and one of the two overview formats ends a prose sentence with it instead. +# Anchored to the whole line, that format read as a round stating no coverage at all, over a body carrying the counts in plain sight. +# The anchor was never what made the marker trustworthy: an HTML comment renders invisibly, so a body that wants one seen has to quote it, and a quotation is refused before this is ever consulted. +# That refusal is `coverage_statements`, which drops a fenced block, an inline code span, and a blockquoted line, in that order, ahead of every reader here. +# The digit runs are matched unbounded and judged in `read_coverage` rather than bounded here, which is the difference between a line this cannot believe and a line that is not a statement at all. +# Bounded here, a marker stating a count longer than any review states stopped matching, so the line left the gate silently and a round carrying one read as full on whatever else it said. +# `int` also raises on a run past 4300 digits, so the judgment has to happen somewhere, and the place that can answer `unvetted` is the reader rather than the pattern. FLEET_REVIEW = re.compile( - r"\s*\s*", + r"", re.IGNORECASE, ) # The count pair itself, in the two spellings the corpus carries. @@ -375,7 +438,7 @@ # A body is read for these rather than trusted, because every reader below keys on one of them. # A heading this script has no spelling for is a section it will not find, reported as absent. # That is the shape of all three failures already on record here, each caught after it landed. -# The lists are small because the output is regular: 10 headings, 9 summaries and 4 labels. +# The lists are small because the output is regular: 10 headings, 10 summaries and 4 labels. # Two overview formats are carried rather than one, the second arriving after that measurement. # Its own markers are listed beside the first's, since a round in either format can land next. # Counts are normalized to `(N)` and non-ASCII is dropped before comparing, and `unvetted` folds letter case at the comparison itself. @@ -403,6 +466,7 @@ "Review details", "Suppressed comments (N)", "Comments suppressed due to low confidence (N)", + "Previously missed (N)", } VETTED_LABELS = {"Files reviewed", "Comments generated", "Review effort level", "Review effort"} # Inline emphasis around a marker is presentation rather than identity. @@ -458,6 +522,15 @@ r"|!?\[[^\[\]]*(?:\[[^\[\]]*\][^\[\]]*)*\]\([^()]*(?:\([^()]*\)[^()]*)*\)" r"|!?\[[^\[\]]*\]\[[^\[\]]*\]" ) +# What opens a block of its own, and so ends a blockquote rather than continuing it. +# Markdown's lazy continuation carries paragraph text only, which of the three coverage spellings is the reviewer's own sentence alone. +# The bullet spelling and the marker each open a block, so each is the round's own line again however the lines above it are quoted. +# Read as continuations they reported `unstated` over a round stating full coverage, which blocks a merge on a satisfied item. +# A bare `<` is not one of these, an inline tag opening a line of prose leaving that line paragraph text. +# A tag standing alone is not one either, though it looks like it should be: only some tag names open a block that can interrupt a paragraph, and a lone `` is not among them, so accepting any of them read a quoted line as this round's own. +# No coverage spelling opens with a tag in any case, the bullet opening on its marker and the sentence on the reviewer's name, so the alternative bought nothing and is dropped rather than narrowed to a list of tag names. +# The caller also holds the four-space bound, an indented line being a code block, which cannot interrupt a paragraph and so cannot end a quotation either. +STARTS_BLOCK = re.compile(r"[-*+]\s|#{1,6}\s|" +# The badge the second overview format renders a severity as, quoted from a live review body. +# The icon URLs are the corpus's own, since the version in them is what a reader must not key on. +BADGE = ( + '' + '' +) +MISSED_TITLE = "Overstates I2C bus requirement for all board templates" + + +def previously_missed( + count: str = "(1)", + title: str = MISSED_TITLE, + finding: str = "`OPERATIONS.md:220`\n\nThe last sentence is too broad.", + badge: str = BADGE, +) -> str: + """The section as the live format writes it: a counted heading wrapping badge-led entries. + + Quoted from a review body rather than invented, since the nesting is the half of the shape a + reader gets wrong: the section is one `
` and each finding is another inside it. + """ + return ( + f"{OVERVIEW}\n{COVERED}\n\n
\n" + f"Previously missed {count}\n\n" + "In code that hasn't changed since last review\n\n" + f"
\n{badge} {title}\n\n{finding}\n
\n
\n" + ) + + class TestCoverage(GqlCase): """The round that covered the head and read part of the diff, which is a clean pass elsewhere. @@ -1668,6 +1883,203 @@ def test_a_human_review_carrying_a_coverage_line_is_not_the_reviewer_s_round(sel ) self.assertIn("coverage=full", out) + def test_the_marker_is_read_where_the_reviewer_puts_it_inside_a_sentence(self) -> None: + """The second overview format ends a prose sentence with the marker rather than giving it + a line, and read only as the whole of a line that round stated no coverage at all. + + The instruction the marker is emitted from asks that the body end with it and says nothing + about a line of its own, so both placements are the reviewer following it. The counts are + identical either way, and it was only ever the anchoring that differed. + """ + for label, line in ( + ("alone on its line", MARKER), + ("ending a prose sentence", f"The changes are internally consistent, with {MARKER}"), + ("with text either side", f"Consistent, {MARKER} as measured."), + ): + with self.subTest(case=label): + self.assertTrue(pr_review.is_coverage_line(line)) + self.assertEqual((8, 8), pr_review.read_coverage(line)) + out = self.digest_for( + review(body=f"{OVERVIEW}\nThe changes are internally consistent, with {MARKER}") + ) + self.assertIn("coverage=full", out) + # The digest says it could read every shape, which is what separates this from a round defaulting to full because it parsed nothing. + self.assertIn("shapes=ok", out) + + def test_a_quoted_marker_is_not_this_round_stating_its_coverage(self) -> None: + """Reading the marker within its line costs the exclusion the line anchor gave for free. + + A `>` is not whitespace, so a blockquoted marker used to fail the anchor without anything + having to refuse it. It is refused deliberately now, beside the fence and the span that + were always refused, because a body quoting a coverage line is not a body stating one and + this pull request's own review is as able to quote one as any other. + """ + for label, body in ( + ("in a fenced block", f"```text\n{MARKER}\n```"), + ("in an inline code span", f"The marker `{MARKER}` is quoted."), + ("blockquoted", f"> {MARKER}"), + ("blockquoted and indented", f" > {MARKER}"), + ("blockquoted twice", f">> {MARKER}"), + ): + with self.subTest(case=label): + self.assertEqual([], pr_review.coverage_statements(body)) + # The same marker outside a quotation is still read, which is what says the guard is narrow. + self.assertEqual( + [f"Prose about the change. {MARKER}"], + pr_review.coverage_statements(f"Prose about the change. {MARKER}"), + ) + + def test_a_line_stating_both_readings_and_disagreeing_is_refused(self) -> None: + """Reading the marker within its line is what lets one line carry both readings. + + Two readings that disagree leave unanswered which one the round meant, which is the case + `read_coverage` already returns None for, and refusing the line blocks rather than passing. + + Taking the worse of the two instead reads an impossible pair as the better one, since a + negative shortfall is never the larger, so a marker claiming it read more files than the + pull request changed cleared the gate outright beside a prose count that disagreed. + """ + prose = "Copilot reviewed 2 out of 3 changed files in this pull request." + overstated = "" + self.assertIsNone(pr_review.read_coverage(f"{prose} {overstated}")) + self.assertIn( + "coverage=UNVETTED", self.digest_for(review(body=f"{OVERVIEW}\n{prose} {overstated}")) + ) + # An impossible pair beside a readable one is the case that passed, so it is held by name. + for label, line in ( + ("the bullet spelling", "- **Files reviewed:** 4/4 changed files "), + ("the sentence spelling", f"{prose[:-1]}. "), + ): + with self.subTest(case=label): + impossible = f"{line}" + self.assertIsNone(pr_review.read_coverage(impossible)) + self.assertEqual(pr_review.UNVETTED, pr_review.coverage_of({"body": impossible})[0]) + # Agreeing on one line is no contradiction, so the counts read straight through. + agreed = "" + self.assertEqual((2, 3), pr_review.read_coverage(f"{prose} {agreed}")) + + def test_a_blockquote_continues_through_prose_and_ends_at_a_new_block(self) -> None: + """Markdown's lazy continuation carries paragraph text, and a line opening its own block + ends the quotation above it rather than joining it. + + Of the three spellings read here only the reviewer's own sentence is paragraph text. Read + as though the bullet and the marker were continuations too, a round stating full coverage + under a quoted note reported no coverage at all, which blocks a merge on a satisfied item. + """ + sentence = "Copilot reviewed 4 out of 4 changed files in this pull request." + # Paragraph text under a quotation is inside it, so it is not this round's own statement. + self.assertEqual( + [], pr_review.coverage_statements(f"> Quoting the reviewer:\n{sentence}\n") + ) + # A blank line closes the quotation, so the same sentence after one is the round's own. + self.assertEqual( + [sentence], pr_review.coverage_statements(f"> Quoting the reviewer:\n\n{sentence}\n") + ) + # Each of the two block openers ends the quotation wherever it sits. + for label, line in ( + ("the marker", MARKER), + ("the bullet spelling", "- **Files reviewed:** 4/4 changed files"), + ): + with self.subTest(case=label): + body = f"> [!NOTE]\n> Reviewed with Copilot.\n{line}\n" + self.assertEqual([line], pr_review.coverage_statements(body)) + self.assertEqual(pr_review.FULL, pr_review.coverage_of({"body": body})[0]) + # A marker carrying its own `>` is still the quotation rather than a block of its own. + self.assertEqual([], pr_review.coverage_statements(f"> {MARKER}\n")) + # An indented line is a code block, so its `>` is text rather than a quotation's marker. + # Opening a quotation on one swallowed every line to the next blank one, and a statement among them read as none stated at all, which blocks a merge on a satisfied item. + for label, quoted_line in (("four spaces", " > prompt"), ("one tab", "\t> prompt")): + with self.subTest(case=label): + body = f"Some prose.\n\n{quoted_line}\n{sentence}\n" + self.assertEqual([sentence], pr_review.coverage_statements(body)) + self.assertEqual(pr_review.FULL, pr_review.coverage_of({"body": body})[0]) + # What opens a block is a shape rather than any line starting with a tag character. + # An indented line is a code block and an inline tag leaves its line paragraph text, so neither interrupts a paragraph and neither ends the quotation above it. + for label, line in ( + ("indented four spaces", f" {MARKER}"), + # A tab is four columns of indentation and so the same code block, which a count of characters reads as one column and lets through. + ("indented one tab", f"\t{MARKER}"), + ("opening on an inline tag", f"see {MARKER}"), + # Only some tag names open a block that can interrupt a paragraph, and this is not one. + ("a lone closing tag", ""), + ): + with self.subTest(case=label): + sentence = "Copilot reviewed 3 out of 3 changed files in this pull request." + body = f"> Quoting the reviewer's own body:\n{line}\n{sentence}\n" + self.assertEqual([], pr_review.coverage_statements(body)) + self.assertEqual(pr_review.UNSTATED, pr_review.coverage_of({"body": body})[0]) + + def test_a_long_whitespace_run_does_not_slow_the_read(self) -> None: + """The marker carries no whitespace of its own at either end, a search having no use for it. + + Left in place from the spelling that matched a whole line, the unanchored run is quadratic + in the whitespace it sits in, so a body carrying a long one took seconds to read where the + marker itself is the only thing a search is looking for. + """ + start = time.monotonic() + self.assertEqual([], pr_review.coverage_statements(" " * 65526 + "\n")) + self.assertLess(time.monotonic() - start, 1.0) + # Dropping the runs changes no reading, the marker being what either spelling matched. + self.assertEqual((8, 8), pr_review.read_coverage(MARKER)) + self.assertEqual((8, 8), pr_review.read_coverage(f" {MARKER}\t ")) + self.assertEqual([MARKER], pr_review.coverage_statements(f"{MARKER}\r\n")) + + def test_a_count_longer_than_any_review_states_is_refused_rather_than_unseen(self) -> None: + """`int` raises above 4300 digits, so an unbounded run crashed the digest rather than + reporting a line it could not believe. + + Refusing it in the pattern instead is the other failure: the line stops being a coverage + statement at all, so it leaves the gate silently and a round carrying one reads as full on + whatever else its body says. It stays a statement, and the reader is what refuses it. + """ + for digits in (5, 4400): + with self.subTest(digits=digits): + huge = "" + # A statement, rather than a line nothing here sees. + self.assertTrue(pr_review.is_coverage_line(huge)) + self.assertEqual([huge], pr_review.coverage_statements(huge)) + # And one this cannot believe, which blocks rather than passing. + self.assertIsNone(pr_review.read_coverage(huge)) + self.assertEqual(pr_review.UNVETTED, pr_review.coverage_of({"body": huge})[0]) + # The prose spellings carry counts too, and guarding only the marker left each of them crashing the digest rather than refusing the line. + for label, line in ( + ( + "the sentence spelling", + "Copilot reviewed {n} out of {n} changed files in this pull request.", + ), + ("the bullet spelling", "- **Files reviewed:** {n}/{n} changed files"), + ): + with self.subTest(case=label): + huge = line.format(n="9" * 4400) + self.assertTrue(pr_review.is_coverage_line(huge)) + self.assertIsNone(pr_review.read_coverage(huge)) + self.assertEqual(pr_review.UNVETTED, pr_review.coverage_of({"body": huge})[0]) + self.assertEqual((9999, 9999), pr_review.read_coverage(line.format(n="9999"))) + # The bound at its own edge rather than only well past it. + # A 4400-digit run is refused whatever the bound is, so it pins nothing upward. + self.assertIsNone(pr_review.read_coverage(line.format(n="99999"))) + # A heading stating one falls to the floor a block carries rather than crashing. + for run in ("9" * 4400, "99999"): + with self.subTest(digits=len(run)): + self.assertEqual( + 1, pr_review.finding_count(f"Suppressed comments ({run})") + ) + # A count the bound admits is read rather than floored, which is the other side of it. + self.assertEqual( + 9999, pr_review.finding_count("Suppressed comments (9999)") + ) + # A round carrying one does not read as full on the strength of another line. + good = "Copilot reviewed 4 out of 4 changed files in this pull request." + huge = "" + self.assertEqual( + pr_review.UNVETTED, pr_review.coverage_of({"body": f"{good}\n{huge}\n"})[0] + ) + # Four digits is a count a review could state, and it reads. + self.assertEqual( + (9999, 9999), + pr_review.read_coverage(""), + ) + class TestUnrecognizedShapes(GqlCase): """A shape this script has no reader for blocks, rather than being read past. @@ -1950,6 +2362,88 @@ def test_every_round_is_read_rather_than_the_head_s(self) -> None: self.assertIn("shapes=UNRECOGNIZED", out) self.assertIn(f"(round {OLD[:8]})", out) + def test_the_previously_missed_heading_is_a_vetted_section_rather_than_a_block(self) -> None: + """A live round carrying it blocked every gate on the pull request until it was read. + + The heading states its own count, which `normal` reduces to `(N)` exactly as it does for + the suppressed heading beside it, so the list holds the reduced spelling rather than one + number the next round would not carry. + """ + self.assertEqual([], pr_review.unrecognized_in(previously_missed())) + # The count in the heading is the round's, so a different one is the same shape. + self.assertEqual([], pr_review.unrecognized_in(previously_missed(count="(4)"))) + # The vetted spelling carries its count, as the suppressed heading beside it does, and every measured round writes one. + # A spelling that drops it is a wording this has not seen, so it blocks rather than being vetted ahead of the evidence for it. + self.assertEqual( + ["summary: Previously missed"], + pr_review.unrecognized_in(previously_missed(count="")), + ) + + def test_a_finding_entry_is_recognized_by_its_badge_rather_than_by_its_title(self) -> None: + """A title differs on every finding, so vetting one by text blocks on each new finding. + + The severity is the part that does not differ, and the badge carrying it renders as a + theme-switched `picture` whose only textual carrier is the `img` `alt`. Keyed on anything + else, the entry reads as an unknown section and stops the gate for presentation alone. + """ + self.assertEqual([], pr_review.unrecognized_in(previously_missed())) + for severity in ("Low", "Medium", "High", "Critical"): + with self.subTest(severity=severity): + badge = BADGE.replace('alt="Low severity"', f'alt="{severity} severity"') + self.assertEqual([], pr_review.unrecognized_in(previously_missed(badge=badge))) + + def test_the_badge_reduces_to_its_alt_text_rather_than_to_its_icon_urls(self) -> None: + """The URLs carry a version the icon set has already bumped once, and the `alt` does not. + + Reduced the other way round, every rebuild of the icon set would present as a new shape. + """ + self.assertEqual( + f"Low severity {MISSED_TITLE}", pr_review.normal(f"{BADGE} {MISSED_TITLE}") + ) + bumped = BADGE.replace("low-v2", "low-v9") + self.assertEqual( + f"Low severity {MISSED_TITLE}", pr_review.normal(f"{bumped} {MISSED_TITLE}") + ) + + def test_a_section_that_is_genuinely_unknown_still_blocks_beside_them(self) -> None: + """Recognizing these two is not widening the gate to whatever wears a `
`.""" + body = previously_missed().replace("Previously missed (1)", "Speculative rewrites (1)") + self.assertIn("summary: Speculative rewrites (N)", pr_review.unrecognized_in(body)) + # The case that matters is a section heading opening on a severity, which is the one word a finding entry is recognized by. + # Named without one, this test never reaches the boundary it exists to hold. + # A section this has no reader for would then be vetted on its first word while its findings reach no digest at all. + severity_led = previously_missed().replace( + "Previously missed (1)", "High severity findings (2)" + ) + self.assertIn( + "summary: High severity findings (N)", pr_review.unrecognized_in(severity_led) + ) + # What separates the two is the count, which every section heading here states and a finding's own title does not. + self.assertTrue(pr_review.finding_entry(f"Low severity {MISSED_TITLE}")) + self.assertFalse(pr_review.finding_entry("High severity findings (N)")) + + def test_a_badge_missing_its_alt_does_not_swallow_the_next_entry(self) -> None: + """The icon set drifting is exactly how an entry loses its `alt`, and the two unbounded + gaps then pair the first element's opening with a later element's `img`. + + Everything between is replaced by the later severity, so one entry's title and its whole + finding text vanish from the only place these findings appear. Bounded, the entry keeps + its markup and reads as an unrecognized shape, which is a failure that reports itself. + """ + stripped = BADGE.replace(' alt="Low severity"', "") + fused = pr_review.normal(f"{stripped} Title A {BADGE} Title B") + self.assertIn("Title A", fused) + self.assertIn("Title B", fused) + # A single-quoted `alt` is valid HTML and the same drift, so it is read rather than merely kept from reaching past its own element. + # Asserting only the second left this passing because the badge was not matched at all, which is the regression it was meant to hold. + single = BADGE.replace('alt="Low severity"', "alt='Low severity'") + self.assertEqual( + f"Low severity {MISSED_TITLE}", pr_review.normal(f"{single} {MISSED_TITLE}") + ) + self.assertIn("Title A", pr_review.normal(f"{single} Title A {BADGE} Title B")) + # The digest prints the word rather than the markup, whichever quoting the badge carries. + self.assertNotIn("", pr_review.normal(f"{single} {MISSED_TITLE}")) + class TestCoverageCarriesForward(GqlCase): """An earlier round's coverage statement stands until something changes it. From d14feede38077b234dc2a8213ae9628013438e2b Mon Sep 17 00:00:00 2001 From: Pieter Viljoen Date: Mon, 21 Sep 2026 07:22:11 -0700 Subject: [PATCH 3/3] Make the Backtracking Cases Reach What They Guard, and Fail Rather Than Hang (#1731) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Answers a finding raised on the `develop -> main` promotion pull request #1730: two unit tests assert a wall-clock bound via `time.monotonic()` and are prone to CI flakiness. A promotion pull request's head is `develop`, so the fix lands here first. The finding is correct about the flake risk. Checking it found that neither case worked, each broken in its own way, so the flakiness was the least of it. ## The quadratic case guarded nothing `coverage_statements` skips a blank line before any reader sees it, and a line of 65526 spaces strips to empty, so the case measured a blank-line skip rather than the pattern it names. Restoring the marker's outer `\s*` runs left the whole file green. The run now carries a character of its own, which takes it to the reader: about 2.7 milliseconds as written, about 5.7 seconds with the runs restored. ## The exponential case could not report what it caught Its bound is read after the call returns, and at a run of 40 the ambiguous spelling parses for hours, so the suite hangs and the assertion is never reached. Measuring that directly timed out at 300 seconds. The cost doubles per character, so the input size is what decides whether a regression is reported or is merely fatal. The size is 28 rather than the first one that clears the bound. At 26 a regression takes about five seconds against a three second ceiling, and a runner twice this host's speed would let one through; at 28 it takes about twenty seconds, which is bounded and has headroom on the side that matters. ## What makes the bound safe Not the clock, the margin under it. The readings as written are about 17 microseconds and 2.7 milliseconds against a three second ceiling, so a runner would have to be thousands of times slower to reach it. The ceiling is stated once as `BACKTRACK_BOUND` so the two cases cannot drift apart. Each regression was restored in a scratch copy to confirm the case reports rather than hangs: ```text exponential anchor -> CAUGHT in 20.6s AssertionError: 20.48 not less than 3.0 quadratic marker runs -> CAUGHT in 5.8s AssertionError: 5.70 not less than 3.0 ``` ## Correction carried in the commit message An earlier draft said the quadratic run took about nine seconds before the fix. That holds on no committed tree: the spelling before it used `fullmatch`, which backtracks linearly and reads the same input in about 3 milliseconds. The nine second state was an intermediate no commit carries. Tests only. No production code changes, and the full suite is green at 1641. 🤖 Generated with [Claude Code](https://claude.com/claude-code) --- scripts/tests/test_pr_review.py | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) diff --git a/scripts/tests/test_pr_review.py b/scripts/tests/test_pr_review.py index 8b45f6aca..9d027972d 100755 --- a/scripts/tests/test_pr_review.py +++ b/scripts/tests/test_pr_review.py @@ -45,6 +45,10 @@ # The shape 28 of the 333 measured bodies carry: an overview, and no count of what was read. # A body of no text at all is not one of the shapes, and the reader now says so, correctly. OVERVIEW = "## Pull request overview\n\nThe change is narrow.\n" +# The wall-clock ceiling the two backtracking cases read, stated once so they cannot drift apart. +# Each case sizes its own input so that a regression finishes and trips this rather than running long enough to hang the suite. +# Three seconds against readings of microseconds and milliseconds, which is the margin that makes a loaded runner a non-issue rather than the clock being trusted. +BACKTRACK_BOUND = 3.0 def review( @@ -1132,12 +1136,17 @@ def test_prose_naming_the_section_is_not_the_section(self) -> None: self.assertNotIn("previously_missed=", out) self.assertNotIn("PREVIOUSLY MISSED", out) # A sentence opening on punctuation rather than on a word is the same prose, and the fixture above happens to put a word first, so it held while these did not. - # A run of non-ASCII whitespace used to be parseable two ways, which doubled the parse per character and hung the read rather than slowing it. + # A run of non-ASCII whitespace used to be parseable two ways, which doubled the parse per character. + # The run is sized so a regression fails rather than hangs, which is the half of this a wall clock cannot do on its own. + # The bound is read after the call returns, so at 40 characters a regression runs for hours and this never reaches its own assertion. + # At 28 the same regression takes about twenty seconds and the bound trips, where the reader as written takes microseconds. + # The size is chosen for headroom on the catch side rather than the first one that clears the bound: the cost doubles per character, so 26 sits at about five seconds and a runner twice this host's speed would let a regression pass. + # That is the margin the bound rests on rather than the wall clock being reliable: roughly five orders of magnitude, against a CI runner that would have to be tens of thousands of times slower to flake. start = time.monotonic() self.assertEqual( - [], pr_review.previously_missed_blocks(f"{OVERVIEW}\n{chr(0xA0) * 40}aligned note\n") + [], pr_review.previously_missed_blocks(f"{OVERVIEW}\n{chr(0xA0) * 28}aligned note\n") ) - self.assertLess(time.monotonic() - start, 1.0) + self.assertLess(time.monotonic() - start, BACKTRACK_BOUND) for opener in ("- ", "* ", "+ ", "...", "(", '"'): with self.subTest(opener=opener): line = f"{opener}Previously missed (2) findings were re-raised this round." @@ -2016,9 +2025,13 @@ def test_a_long_whitespace_run_does_not_slow_the_read(self) -> None: in the whitespace it sits in, so a body carrying a long one took seconds to read where the marker itself is the only thing a search is looking for. """ + # Quadratic rather than exponential, so a regression returns rather than hanging. + # The run carries a character of its own, since a line of nothing but spaces strips to empty and is skipped as blank before any reader sees it. + # Sized without one this asserted a bound over an input that never reached the pattern, so restoring the runs left it green and it guarded nothing. + # Measured with the character: about 2.7 milliseconds as written and about 5.7 seconds with the runs restored. start = time.monotonic() - self.assertEqual([], pr_review.coverage_statements(" " * 65526 + "\n")) - self.assertLess(time.monotonic() - start, 1.0) + self.assertEqual([], pr_review.coverage_statements(" " * 65526 + "x\n")) + self.assertLess(time.monotonic() - start, BACKTRACK_BOUND) # Dropping the runs changes no reading, the marker being what either spelling matched. self.assertEqual((8, 8), pr_review.read_coverage(MARKER)) self.assertEqual((8, 8), pr_review.read_coverage(f" {MARKER}\t "))