Skip to content

Collapse Whitespace Before Pinning a Sentence in the Docstring Tests - #1733

Merged
ptr727 merged 1 commit into
developfrom
feature/flowed-runbook-assertions
Sep 21, 2026
Merged

ptr727 merged 1 commit into
developfrom
feature/flowed-runbook-assertions

Conversation

@ptr727

@ptr727 ptr727 commented Sep 21, 2026 •

Copy link
Copy Markdown
Owner

Addresses #1714. The closing reference sits on the develop -> main promotion pull request, since a closing keyword on a develop-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_text collapses 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 in spec/validate.py. Neither is exposed, and the change is aimed differently as a result.

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. 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\.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. Left 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. 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.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 on that issue as well.

Verification

1641 tests pass. 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 against this branch; the second found six findings, and every one of them is either fixed here or filed on #1732.

The comments label is set because the change adds two comment lines at the coverage-marker assertion.

🤖 Generated with Claude Code

Summary by CodeRabbit

  • Tests
    • Improved contract checks for code review documentation, including consistent handling of whitespace in prose.
    • Preserved exact matching for layout-sensitive and machine-readable content.
    • Centralized the referenced code review guidance path to make validation more consistent.

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.
Copilot AI lite review requested due to automatic review settings September 21, 2026 15:10
@ptr727 ptr727 added the comments Permits the comment lines the pull request adds or edits, which the prose gate otherwise refuses label Sep 21, 2026
@coderabbitai

coderabbitai Bot commented Sep 21, 2026 •

Copy link
Copy Markdown

Review Change StackReview Change Stack

Understand this PR’s impact

Explore downstream dependencies and potential security impact with Blast Radius.

View blast radius →

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

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

Review profile: CHILL

Plan: Advanced

Run ID: 5b7c9fe0-99b7-43b2-a33d-8de1a7fec758

📥 Commits

Reviewing files that changed from the base of the PR and between d14feed and afe631e.

📒 Files selected for processing (1)
  • scripts/tests/test_pr_review.py

Included review availability: Your plan provides up to 1 included review per hour; 0 remain after this review.


📝 Walkthrough

Walkthrough

The 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.

Changes

Contract Test Resilience

Layer / File(s) Summary
Documentation contract assertions
scripts/tests/test_pr_review.py
Adds CODE_REVIEW_SKILL and flowed_text. Updates documentation assertions to normalize whitespace, uses the shared skill path, and preserves raw matching for the coverage marker.

Priority: ⬇️ Low

Estimated code review effort: 1 (Trivial) | ~5 minutes

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 71.43% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 7 functions across 1 files. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly describes the main change: collapsing whitespace before matching sentences in docstring tests.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
  • Fix all pre-merge checks with AI
✨ Finishing Touches 💡 1
📝 Generate docstrings 💡
  • Commit to this branch
  • Create a new PR
🧪 Generate unit tests (beta)
  • Commit to this branch
  • Create a new PR

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.

@ptr727

ptr727 commented Sep 21, 2026

Copy link
Copy Markdown
Owner Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Sep 21, 2026 •

Copy link
Copy Markdown
✅ Action performed

Review finished.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

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 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.

@ptr727
ptr727 merged commit c556d2f into develop Sep 21, 2026
9 checks passed
@ptr727
ptr727 deleted the feature/flowed-runbook-assertions branch September 21, 2026 15:14
ptr727 added a commit that referenced this pull request Sep 21, 2026
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)
ptr727 added a commit that referenced this pull request Sep 21, 2026
…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)
ptr727 added a commit that referenced this pull request Sep 21, 2026
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)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

comments Permits the comment lines the pull request adds or edits, which the prose gate otherwise refuses

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants