fix(mp2): aligned tables and ASCII boxes are layout, not context stuffing - #322
Open
Mark2Mac wants to merge 1 commit into
Open
fix(mp2): aligned tables and ASCII boxes are layout, not context stuffing#322Mark2Mac wants to merge 1 commit into
Mark2Mac wants to merge 1 commit into
Conversation
…fing
MP2's repetition pattern `(.{2,20}?)\1{20,}` already has a guard for a single
character repeated, but it exempts whitespace explicitly, so any run built from
spaces still matches. That is most of what real projects contain: aligned
markdown tables, ASCII boxes, horizontal rules, and UI code that pads columns.
The guard is extended in the same spirit: a unit made only of whitespace and
alignment characters (dashes, bars, colons, box drawing U+2500-U+257F) repeats
because something is being *lined up*, not because context is being displaced.
It is not a blanket exemption. Above 400 characters layout stops being a
plausible explanation — nobody reads a table row or a box that wide — so a long
run is still reported even when it is pure filler. Repetition of *content* is
untouched.
Measured on 25 real files drawn from a corpus of 65 skill/plugin units, all of
which had MP2 findings:
MP2 findings 95 -> 3
The three survivors come from MP2's *other* patterns (prose about exceeding the
context window), not from the repetition pattern, and are outside this change.
Tests: an aligned table, an ASCII box and a padded column produce nothing; a
whitespace run wider than the layout limit, and repeated content, still do.
Full suite: 1565 passed, 14 skipped, 6 xfailed.
Signed-off-by: Mark2Mac <Mark2Mac@users.noreply.github.com>
rng1995
approved these changes
Jul 31, 2026
rng1995
left a comment
Collaborator
There was a problem hiding this comment.
[Automated SkillSpector Review]
Approved. The MP2 exemption is narrowly limited to short runs made only of whitespace/alignment characters; repeated content and long whitespace stuffing remain detected. The new table, box, padded-column, long-run, and repeated-content cases cover both sides of the boundary, and the focused pattern suite passes (244 tests).
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The problem
MP2(context window stuffing) matches(.{2,20}?)\1{20,}— a short unit repeated twenty times or more. There is already a guard for the obvious false positive:A run of one repeated character is skipped — but whitespace is explicitly exempted from that skip, so any unit containing a space still matches. In practice that is most formatting a real project contains:
An aligned table, an ASCII box, a padded column. None of them displaces anything.
The change
The existing guard's reasoning, extended to the case it misses: a unit made only of whitespace and alignment characters — dashes, bars, colons, dots, box drawing
U+2500–U+257F— repeats because something is being lined up.It is deliberately not a blanket exemption. Above 400 characters layout stops being a plausible explanation, so a long run is still reported even when it is pure filler:
"testo" + " " * 800"lorem " * 60(repeated content)Measured effect
25 real files taken from a corpus of 65 skill/plugin units, every one of which had MP2 findings:
The three survivors come from MP2's other patterns — prose that talks about exceeding the context window — not from the repetition pattern. They are a different question and this PR does not touch them.
Tests
Five new cases alongside the existing
test_mp2_separator_not_flagged: aligned table, ASCII box and padded column produce nothing; a whitespace run past the layout width, and repeated content, still do.Full suite:
1565 passed, 14 skipped, 6 xfailed.