Skip to content

Fold Whitespace in pr_review.py reply --match - #1974

Merged
ptr727 merged 1 commit into
developfrom
feature/auto-1877
Sep 28, 2026
Merged

ptr727 merged 1 commit into
developfrom
feature/auto-1877

Conversation

@ptr727

@ptr727 ptr727 commented Sep 28, 2026

Copy link
Copy Markdown
Owner

Summary

matching_threads() compared --match against a thread's raw, uncollapsed body, while describe() prints that same body collapsed to single spaces before showing it as an unresolved: line in a NO_MATCH refusal. A pattern copied verbatim from that printed line could still return NO_MATCH whenever it spanned a line break, tab, or run of spaces the raw body still carried, the same shape of failure #1299 and #1878 already fixed for a moved line and for typographic punctuation.

  • matching_threads() now folds whitespace to a single space on both sides of the compare, the same collapse describe() applies, so a pattern copied from a printed unresolved: line matches the thread it was copied from.
  • The 120-character display cutoff describe() applies is left as is, per the issue's own suggestion, and is now documented on describe() as a display limit rather than a matching concern.

Closes on promotion: #1877

Test plan

  • python3 -m unittest tests.test_pr_review — 442 tests pass
  • uvx ruff format --check scripts/pr_review.py tests/test_pr_review.py / uvx ruff check scripts/pr_review.py tests/test_pr_review.py
  • uvx mypy (full configured file set) — no issues
  • Manually confirmed the new regression test fails against the pre-fix implementation and passes against the fix
  • Local adversarial review pass recorded against develop — no findings

🤖 Generated with Claude Code

`matching_threads()` compared `--match` against a thread's raw, uncollapsed body, while
`describe()` prints that same body collapsed to single spaces before showing it as an
`unresolved:` line. A pattern copied verbatim from that printed line could still return
`NO_MATCH` whenever it spanned a line break, tab, or run of spaces the raw body still carried,
the same shape of failure #1299 and #1878 fixed for a fix push moving the line and for
typographic punctuation.

`matching_threads()` now folds whitespace to a single space on both sides of the compare, the
same collapse `describe()` applies, so a pattern copied from a printed `unresolved:` line
matches the thread it was copied from. The 120-character display cutoff `describe()` applies
stays as is, now documented on `describe()` as a display limit rather than a matching one.

Closes on promotion: #1877

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Copilot AI lite review requested due to automatic review settings September 28, 2026 05:29
@coderabbitai

coderabbitai Bot commented Sep 28, 2026

Copy link
Copy Markdown

Important

  • 🔍 Trigger review

This repository does not receive automatic reviews because it has fewer than 10 stars.

⚙️ Run configuration

Configuration used: Repository: ptr727/ProjectTemplate/.coderabbit.yaml

Review profile: CHILL

Plan: Advanced

Run ID: bead0764-9013-4dae-899d-e8cfaa5702eb


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@codecov

codecov Bot commented Sep 28, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
⚠️ Please upload report for BASE (develop@6d8e7cf). Learn more about missing BASE report.

Additional details and impacted files
@@            Coverage Diff             @@
##             develop    #1974   +/-   ##
==========================================
  Coverage           ?   55.42%           
==========================================
  Files              ?       16           
  Lines              ?     7249           
  Branches           ?        0           
==========================================
  Hits               ?     4018           
  Misses             ?     3231           
  Partials           ?        0           
Flag Coverage Δ
python-3.13 55.42% <100.00%> (?)

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot review overview

🟢 Approval recommended

The change is narrowly scoped, behaviorally consistent with existing output (describe()), and includes a targeted regression test covering the reported failure mode.

Review effort: Lite
Findings: None

What changed in this PR

This PR aligns reply --match selection behavior with what pr_review.py prints for unresolved threads by folding all whitespace runs (including newlines/tabs) to single spaces on both the --match pattern and candidate thread bodies, preventing NO_MATCH when the pattern was copied directly from the printed unresolved: line.

Changes:

  • Normalize whitespace in matching_threads() via a shared fold function (whitespace collapse + typographic fold + case normalization) before substring comparison.
  • Clarify describe()'s 120-character truncation as a display-only cutoff, not part of matching behavior.
  • Add a regression test ensuring a pattern copied from the printed unresolved line matches a body containing newlines and repeated spaces.
File Description
scripts/​pr_review.py Collapses whitespace during --match selection to match the describe() display form and updates docstring wording about truncation.
tests/​test_pr_review.py Adds a regression test that copies a describe()-rendered snippet and verifies reply --match selects the intended thread.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

@ptr727
ptr727 merged commit 2462619 into develop Sep 28, 2026
11 checks passed
@ptr727
ptr727 deleted the feature/auto-1877 branch September 28, 2026 05:32
ptr727 added a commit that referenced this pull request Sep 28, 2026
… and Setup Tooling (#2000)

## Summary

Promotes develop to main, carrying the 16 pull requests merged to
develop since #1943.

- **Wait-loop guard (requirement 7):**
[#1999](#1999) credits a
comparison bound only inside a `[`, `[[`, or `test` invocation, and
[#1996](#1996) reconciles
the requirement's README count and diagram with its hook.
- **Registry:**
[#1994](#1994) and
[#1976](#1976) record
Vantage-Config's line endings and description.
- **Scripts and tooling:**
- [#1988](#1988) and
[#1972](#1972) harden
`ruleset_id()`.
- [#1974](#1974) and
[#1949](#1949) fix
`pr_review.py` `reply --match` and `wait`.
- [#1969](#1969),
[#1964](#1964),
[#1954](#1954) and
[#1951](#1951) fix
host-setup tool shadowing, shims, hook ownership and dpkg ownership
checks.
- **Gates and audit:**
- [#1980](#1980) triages a
path collision.
- [#1967](#1967) and
[#1962](#1962) tighten
sha-pin and version-literal checks.
- [#1956](#1956) keeps a
folded `if:` visible to the interface audit.

Closes #1636
Closes #1639
Closes #1948
Closes #1971
Closes #1718
Closes #1934
Closes #1877
Closes #1880
Closes #1865
Closes #1889
Closes #1966
Closes #1906
Closes #1935
Closes #1901
Closes #1905
Closes #1866
Closes #1897

🤖 Generated with [Claude Code](https://claude.com/claude-code)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants