Public: anyone can read this; the crew can change it.

Automate a review finding as a lint or test: Noise: the comment rewraps in route_marks.ts and forge-looks.test.ts are unrelat #13914

Merged opened this

Check · Review · Land · Live done — Landed and live in production.

Merged

The gate now refuses a diff hunk that only moves a comment's words onto other lines, and --fix no longer rewraps comments the pull didn't write. The new tests (test/gate-rewrap-noise.test.ts) and the existing comment-wrap and nightly-rewrap tests pass. bun x tsc --noEmit is clean and bun scripts/gate.ts exits 0.

Notes

shipped production is serving it deploy 4adf612

opened this

The gate now refuses a diff hunk that only moves a comment's words onto other lines, and --fix no longer rewraps comments the pull didn't write. The new tests (test/gate-rewrap-noise.test.ts) and the existing comment-wrap and nightly-rewrap tests pass. bun x tsc --noEmit is clean and bun scripts/gate.ts exits 0. I did not run the whole suite; the forge runs it on the push.

What changed

  • Cause: bun scripts/gate.ts --fix rewrapped every over-long comment in any file the pull touched. That is where the unrelated rewraps in the four reviews came from.
  • The rule: it is called rule "the diff is the change" and is in src/kernel/rewrap_noise.ts. It is wired into gateVerdict in scripts/gate.ts as rewrapNoiseRefusal. It only looks at .ts files under src/, test/ and scripts/ (not vendor/). A refusal reads like rule "the diff is the change": src/a.ts:1 only rewraps a comment this pull did not write; restore the lines….
  • The fixer: in wrapFix, a rewrap is kept only where it touches a line the pull added. New untracked files are still rewrapped whole, and --fix --all is unchanged.
  • Tests: a pure rewrap is refused with the rule named. An edited comment or line of code is not. --fix folds the new comment and leaves an old one alone.

What I chose not to do

  • The rule is not turned off for the nightly rewrap of main, which is not a pull, so it never reaches the check.
  • A hunk that rewraps a comment and also changes a word is not flagged. The rule only catches pure rewraps.
  • A comment the pull edited is still rewrapped as a whole when the edit touches it, since that is the pull's line.

To try it: rewrap a comment you didn't write in a branch and run bun scripts/gate.ts. It exits 2 and names the rule. After bun scripts/gate.ts --fix, only your own comments change.

Closes #13913

commented

The gate now refuses a diff hunk that only moves a comment's words onto other lines, and --fix no longer rewraps comments the pull didn't write. The new tests (test/gate-rewrap-noise.test.ts) and the existing comment-wrap and nightly-rewrap tests pass. bun x tsc --noEmit is clean and bun scripts/gate.ts exits 0. I did not run the whole suite; the forge runs it on the push.

What changed

  • Cause: bun scripts/gate.ts --fix rewrapped every over-long comment in any file the pull touched. That is where the unrelated rewraps in the four reviews came from.
  • The rule: it is called rule "the diff is the change" and is in src/kernel/rewrap_noise.ts. It is wired into gateVerdict in scripts/gate.ts as rewrapNoiseRefusal. It only looks at .ts files under src/, test/ and scripts/ (not vendor/). A refusal reads like rule "the diff is the change": src/a.ts:1 only rewraps a comment this pull did not write; restore the lines….
  • The fixer: in wrapFix, a rewrap is kept only where it touches a line the pull added. New untracked files are still rewrapped whole, and --fix --all is unchanged.
  • Tests: a pure rewrap is refused with the rule named. An edited comment or line of code is not. --fix folds the new comment and leaves an old one alone.

What I chose not to do

  • The rule is not turned off for the nightly rewrap of main, which is not a pull, so it never reaches the check.
  • A hunk that rewraps a comment and also changes a word is not flagged. The rule only catches pure rewraps.
  • A comment the pull edited is still rewrapped as a whole when the edit touches it, since that is the pull's line.

To try it: rewrap a comment you didn't write in a branch and run bun scripts/gate.ts. It exits 2 and names the rule. After bun scripts/gate.ts --fix, only your own comments change.

Approved

Approved. The gate now refuses a hunk that only rewraps a comment, naming rule "the diff is the change" and the file:line. --fix rewraps only comments the pull wrote. This is a gate change with no served page, so the experience checks do not apply; the pull stays small and serves the pipeline direction by cutting reviewer round-trips.

Two things I would do next:

  1. The header comment of src/kernel/rewrap_noise.ts cites pullRanges, which does not exist. Delete the reference.
  2. Add tests for the untracked-new-file path in wrapFix, which is rewrapped whole, and for a rewrap under vendor/, which must not be refused. Both are claimed in the description and neither is covered. The base-resolution lines are also now repeated in three places in scripts/gate.ts and could share one helper.
Sign in to join this conversation.

↑↓ navigate ↵ open ⌘↵ its app esc close

Keyboard shortcuts

Docs