Skip to content

test(mp2): lock the layout-span guard against regressions - #342

Open
Mark2Mac wants to merge 1 commit into
NVIDIA:mainfrom
Mark2Mac:test/mp2-layout-guard
Open

test(mp2): lock the layout-span guard against regressions#342
Mark2Mac wants to merge 1 commit into
NVIDIA:mainfrom
Mark2Mac:test/mp2-layout-guard

Conversation

@Mark2Mac

@Mark2Mac Mark2Mac commented Aug 4, 2026

Copy link
Copy Markdown
Contributor

Why

_is_layout_only_span() is the guard that keeps MP2 from reporting alignment — table rules, padded columns, box edges — as context window stuffing. It has no test.

The only layout case in the suite today is:

def test_mp2_separator_not_flagged(self) -> None:
    assert not any(f.rule_id == "MP2" for f in mp_mod.analyze("=" * 80, ...))

That one never reaches the helper: a run of a single character with no whitespace is skipped by the older guard just above it. Stub _is_layout_only_span to return False and the whole suite still passes.

How much it is carrying

Measured on 4406 files from 65 real skill/plugin units, comparing the analyzer before the helper landed with main today:

MP2 findings   279 -> 4

The four survivors are from MP2's prose patterns ("exceed context window" and friends), not from (.{2,20}?)\1{20,}. So the helper accounts for 275 of 279 findings and nothing pins its behaviour.

What this adds

Three cases that are each reported when the helper is stubbed out, which is what makes them regressions rather than restatements of the guard above them:

case with helper helper stubbed
"- " * 40 — dash rule ok MP2
"| " * 40 — padded columns ok MP2
"│ " * 30 — box edge + padding ok MP2

And one for the other side, so the exemption cannot quietly widen: "- " * 200 exceeds _MAX_LAYOUT_ONLY_SPAN and is still reported.

No source change. 255 passed in the touched file, ruff check and ruff format --check clean at 0.15.19.

Context

This replaces #322, which I closed. That PR proposed its own layout guard, and the measurement above is what retired it: on today's main it removes zero findings, because _is_layout_only_span already covers the same ground. The tests are the part that turned out to be worth keeping.

`_is_layout_only_span()` is what keeps MP2 from reporting alignment as context
stuffing, and it has no test. The only layout case covered today is `"=" * 80`,
which never reaches the helper — the older single-character guard skips it first.

Measured on a corpus of 4406 files from 65 skill/plugin units, comparing the
analyzer before the helper landed with `main` today:

  MP2 findings   279 -> 4

The four survivors come from MP2's prose patterns ("exceed context window"), not
from the repetition pattern. So the helper is carrying 275 of 279 findings, with
nothing pinning its behaviour.

The three cases added here are each reported when the helper is stubbed out, which
is what makes them regressions rather than restatements of the guard above them:
a dash rule, a run of padded columns, and a box edge with padding. The fourth test
locks the other side, `_MAX_LAYOUT_ONLY_SPAN`: past that width layout stops being a
plausible explanation and the run is reported again.

No source change.

Signed-off-by: Mark2Mac <Mark2Mac@users.noreply.github.com>
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.

1 participant