Repository navigation
Collapse Whitespace Before Pinning a Sentence in the Docstring Tests - #1733
Conversation
Closes #1714. Four contract tests pin a sentence against the raw text of `pr_review.py`'s module docstring. That docstring is hand-wrapped near 100 columns, so adding a word earlier in a paragraph moves the wrap, splits a pinned sentence across two lines, and fails a test that makes no claim about the edit. `flowed_text` collapses whitespace runs before the match, so those four assertions pin the docstring's words rather than its line breaks. ## What the issue assumed, and what is actually exposed #1714 names three assertions reading `.github/copilot-instructions.md` and one shape in `spec/validate.py`. Neither is exposed. That runbook and `GOVERNANCE.md` are one logical paragraph per line, longest lines 989 and 3483 characters. A paragraph there is already a single line, so an edit cannot rewrap a neighboring one, and those assertions are left reading raw. Collapsing them would also have cost something: it joins paragraphs, headings and fenced blocks into one line, letting a needle match across a boundary it should not cross. `spec/validate.py`'s `\.github/skills/[A-Za-z0-9_-]+/SKILL\.md` carries no whitespace and its character class excludes whitespace, so no rewrap can split a match. Run over the runbook rewrapped at 40, 60, 80 and 100 columns it returned the identical result each time. Unchanged. ## The coverage marker reads raw, and that is its subject `read_coverage` runs once per line, so a marker split over two lines yields no coverage statement at all and the round reads as stating no coverage. Being one line is what that assertion is for, and it sits in a fenced block besides. The reason is now written beside it, because collapsing it looked like an improvement until the per-line reader was checked. ## Nothing enforces the docstring's wrap `pyproject.toml` sets `line-length = 100`, but the lint selection is ruff's default set plus `I`, which excludes E501, and the formatter does not reflow docstring prose. Measured: a 206-character docstring line passes `ruff check`, and `ruff format` changes only the placement of its closing quotes. The wrap is a hand convention, which is exactly why an editor rewraps it by hand and the raw pin breaks. ## Left for their own issues #1732 covers a regex pinning a phrase inside a `#` comment, where a rewrap interleaves the continuation's `#` and collapsing cannot help. Two further assertions pinning a whitespace-bearing needle against wrappable code rather than prose are recorded there too. Verified: 1641 tests pass, ruff format and check, mypy, prose_lint against the diff, the eol gate, and spec/validate.py all clean.
|
Understand this PR’s impact Explore downstream dependencies and potential security impact with Blast Radius. No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Repository: ptr727/ProjectTemplate/.coderabbit.yaml Review profile: CHILL Plan: Advanced Run ID: 📒 Files selected for processing (1)
Included review availability: Your plan provides up to 1 included review per hour; 0 remain after this review. 📝 WalkthroughWalkthroughThe PR adds a shared skill-path constant and a whitespace-normalization helper. Documentation contract tests use normalized docstrings for prose assertions and raw text for the machine-readable coverage marker. ChangesContract Test Resilience
Priority: ⬇️ Low Estimated code review effort: 1 (Trivial) | ~5 minutes 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches 💡 1📝 Generate docstrings 💡
🧪 Generate unit tests (beta)
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. Comment |
|
@coderabbitai review |
✅ Action performedReview finished.
|
There was a problem hiding this comment.
Copilot review overview
🟢 Approval recommended
The change is narrowly scoped to test robustness, preserves the layout-sensitive marker check, and introduces no functional behavior changes.
Review effort: Lite
Findings: None
What changed in this PR
This PR hardens scripts/pr_review.py docstring contract tests by collapsing whitespace before matching pinned sentences, so harmless rewrapping of the docstring does not cause unrelated test failures.
Changes:
- Add
flowed_text()helper to normalize whitespace for docstring substring assertions. - Update the affected contract tests to match against flowed docstring text rather than raw line breaks.
- Keep the machine-readable coverage marker assertion intentionally raw (with added inline rationale) and centralize the skill path as
CODE_REVIEW_SKILL.
| File | Description |
|---|---|
| scripts/tests/test_pr_review.py | Introduces whitespace-flowing helper and uses it in docstring contract assertions while preserving the raw, per-line coverage marker check. |
💡 Configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Closes #1714. Promotes one change, #1733, merged to `develop` as c556d2f. Four contract tests pinned a sentence against the raw text of `pr_review.py`'s module docstring. That docstring is hand-wrapped near 100 columns, so adding a word earlier in a paragraph moves the wrap, splits a pinned sentence across two lines, and fails a test that makes no claim about the edit. `flowed_text` collapses whitespace runs before the match, so those four assertions pin the docstring's words rather than its line breaks. ## What #1714 asked for, and what was actually wrong The issue named three assertions reading `.github/copilot-instructions.md` and one shape in `spec/validate.py`. Neither turned out to be exposed, so the change is aimed at what is. That runbook and `GOVERNANCE.md` are one logical paragraph per line, longest lines 989 and 3483 characters, so an edit cannot rewrap a neighboring line and those assertions keep reading raw. Collapsing them would have cost something rather than being merely redundant, since it joins paragraphs, headings and fenced blocks into one line and lets a needle match across a boundary it should not cross. `spec/validate.py`'s `\.github/skills/[A-Za-z0-9_-]+/SKILL\.md` carries no whitespace and its character class excludes whitespace, so no rewrap can split a match. Run over the runbook rewrapped at 40, 60, 80 and 100 columns it returned the identical result each time. That half of the issue is disproved rather than deferred. The coverage-marker assertion reads raw deliberately, and the reason is now written beside it: `read_coverage` runs once per line, so a marker split over two lines yields no coverage statement at all. An earlier revision of the branch collapsed it, which passed the test while making it blind to exactly the shape the parser cannot read. ## Follow-on work #1732 holds the siblings that collapsing cannot fix: a regex pinning a phrase inside a `#` comment, where a rewrap interleaves the continuation's `#`, plus two assertions pinning a whitespace-bearing needle against wrappable code rather than prose. ## Verification On the feature pull request: 1641 tests pass, and `ruff format --check`, `ruff check`, `mypy`, `prose_lint.py` against the diff, the `eol` gate and `spec/validate.py` are all clean. Two local strict review rounds ran before the push. Copilot reviewed the head with `reviewed=1 changed=1 findings=0`, and CodeRabbit reviewed `d14feede..afe631e` with no actionable comments. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
…ch (#1736) Two operational readings learned by hitting them while driving #1733, moved out of a private note and into the tree, where the next run reads them and where a reviewer can argue with them. ## A watcher cannot infer one digest field's spelling from another's `scripts/README.md` said nothing about how `pr_review.py status` spells its states, and it is the file someone writing a watcher reads. `review_on_head` renders `yes` against `NO`, so a pattern written for `YES` waits out its whole bound over a review that landed, and a watcher that cannot fire reads exactly like a review that has not landed. The paragraph states that hazard and the remedy, read a real line before writing the pattern, rather than listing what each field can print. That shape was chosen the hard way. Three revisions of this branch tried the listing and each was wrong in a different cell: - that upper-case marks a state which blocks a merge, which `merge=CLEAN` and `answered_outside_review=yes` falsify from opposite directions - that a `carried:` prefix can precede any coverage value, though the carry runs only over an unstated reading and skips unstated rounds, so `carried:unstated` cannot be rendered - that `NO` means "before a review lands", though a refusal on the head and a stale round both print it and want opposite responses A list that keeps being wrong in a new place is the wrong shape for the fact. ## A watch's exit status does not survive a pipe `merge-and-release` step 6 gives the bounded watch command and leaves how to read its result to the reader. Without `pipefail`, `gh run watch ... | tail` reports whether `tail` succeeded rather than whether the run did. The rule is scoped to that condition rather than stated absolutely, because `GOVERNANCE.md` "Shells" requires `pipefail` on every committed bash script and multi-line `run:` block, so inside one the pipe is safe and an absolute ban would rest on a reason its reader can see does not apply. ## What was dropped, and why it matters An earlier revision added a third note offering a tree-object comparison as a way to clear a rate-limited reviewer on a promotion pull request. It is deleted rather than repaired, because it **fails open**. Measured on a constructed two-feature promotion: the promotion head's tree equals the last feature head's tree whenever that branch was current with `develop`, while the promotion's diff carries the earlier feature as well. The equal-tree branch therefore fires and clears a wait over content that reviewer never read, and the "unequal trees settle nothing" escape hatch never runs. The same bullet already says an advisory reviewer blocks nothing, so the case needed no new answer at all. ## Verification 1641 tests pass. `ruff format --check`, `ruff check`, `mypy`, `prose_lint.py` against the diff, the `eol` gate and `spec/validate.py` are clean. `build_dist.py --check` reports the generated trees current. Two local strict review rounds ran before the push, raising nine findings between them, every one of which is fixed or deleted here. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
Promotes one change, #1736, merged to `develop` as 0f3e9a1. Two operational readings from the #1733 drive, moved out of a private note and into the tree, where the next run reads them and a reviewer can argue with them. ## A watcher cannot infer one digest field's spelling from another's `scripts/README.md` said nothing about how `pr_review.py status` spells its states, and it is the file someone writing a watcher reads. `review_on_head` renders `yes` against `NO`, so a pattern written for `YES` waits out its whole bound over a review that landed, and a watcher that cannot fire reads exactly like a review that has not landed. The paragraph states the hazard and the remedy rather than listing what each field prints. That shape was chosen the hard way: three revisions tried the listing and each was wrong in a different cell, once claiming upper-case marks a merge-blocking state (which `merge=CLEAN` and `answered_outside_review=yes` falsify from opposite directions), once offering a `carried:` prefix on any coverage value (`carried:unstated` is unreachable), and once glossing `NO` as "before a review lands" (a refusal on the head and a stale round both print it and want opposite responses). ## A watch's exit status does not survive a pipe `merge-and-release` step 6 gives the bounded watch command and left how to read its result to the reader. Without `pipefail`, `gh run watch ... | tail` reports whether `tail` succeeded rather than whether the run did. The rule is scoped to that condition rather than absolute, since `GOVERNANCE.md` "Shells" requires `pipefail` on every committed bash script and multi-line `run:` block, so inside one the pipe is safe. ## What was dropped An earlier revision offered a tree-object comparison for clearing a rate-limited reviewer on a promotion. It is deleted rather than repaired, because it fails open: on a constructed two-feature promotion the promotion head's tree equals the last feature head's tree whenever that branch was current with `develop`, while the promotion diff carries the earlier feature too, so the check clears a wait over content that reviewer never read. ## Verification On the feature pull request: 1641 tests pass, and `ruff format --check`, `ruff check`, `mypy`, `prose_lint.py` against the diff, the `eol` gate, `spec/validate.py` and `build_dist.py --check` are all clean. Two local strict review rounds ran before the push, raising nine findings between them, each fixed or deleted. Copilot reviewed the head with `reviewed=5 changed=5 findings=0`. CodeRabbit was rate limited and is advisory, so it blocks nothing. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
Addresses #1714. The closing reference sits on the
develop -> mainpromotion pull request, since a closing keyword on adevelop-targeted pull request does not register.Four contract tests pin a sentence against the raw text of
pr_review.py's module docstring. That docstring is hand-wrapped near 100 columns, so adding a word earlier in a paragraph moves the wrap, splits a pinned sentence across two lines, and fails a test that makes no claim about the edit.flowed_textcollapses whitespace runs before the match, so those four assertions pin the docstring's words rather than its line breaks.The issue's own premise did not survive checking
#1714 names three assertions reading
.github/copilot-instructions.md, and one shape inspec/validate.py. Neither is exposed, and the change is aimed differently as a result.That runbook and
GOVERNANCE.mdare one logical paragraph per line, longest lines 989 and 3483 characters. A paragraph there is already a single line, so an edit cannot rewrap a neighboring one. Those assertions keep reading raw. Collapsing them would also have cost something rather than being merely redundant: it joins paragraphs, headings and fenced blocks into one line, so a needle could match across a boundary it should not cross.spec/validate.py's\.github/skills/[A-Za-z0-9_-]+/SKILL\.mdcarries no whitespace and its character class excludes whitespace, so no rewrap can split a match. Run over the runbook rewrapped at 40, 60, 80 and 100 columns it returned the identical result each time. Left unchanged.The coverage marker reads raw, and that is its subject
read_coverageruns once per line, so a marker split over two lines yields no coverage statement at all and the round reads as stating no coverage. Being one line is what that assertion is for, and it sits in a fenced block besides. An earlier revision of this branch collapsed it, which passed the test while making it blind to exactly the shape the parser cannot read. The reason is now written beside the assertion.Nothing enforces the docstring's wrap
pyproject.tomlsetsline-length = 100, but the lint selection is ruff's default set plusI, which excludes E501, and the formatter does not reflow docstring prose. Measured: a 206-character docstring line passesruff check, andruff formatchanges only the placement of its closing quotes. The wrap is a hand convention, which is exactly why an editor rewraps it by hand and the raw pin breaks.Left for their own issues
#1732 covers a regex pinning a phrase inside a
#comment, where a rewrap interleaves the continuation's#and collapsing cannot help. Two further assertions pinning a whitespace-bearing needle against wrappable code rather than prose are recorded on that issue as well.Verification
1641 tests pass.
ruff format --check,ruff check,mypy,prose_lint.pyagainst the diff, theeolgate, andspec/validate.pyare all clean. Two local strict review rounds ran against this branch; the second found six findings, and every one of them is either fixed here or filed on #1732.The
commentslabel is set because the change adds two comment lines at the coverage-marker assertion.🤖 Generated with Claude Code
Summary by CodeRabbit