Skip to content

test+fix(#6959): close single-quote attr gap + 13 regression tests for the canonical detector - #6970

Merged
jsboige merged 1 commit into
mainfrom
feature/test-detect-svg-decimal-commas
Jul 17, 2026
Merged

jsboige merged 1 commit into
mainfrom
feature/test-detect-svg-decimal-commas

Conversation

@jsboige

@jsboige jsboige commented Jul 17, 2026

Copy link
Copy Markdown
Owner

Summary

Targeted follow-up to the canonical detector #6959 (per ai-01's close-as-duplicate guidance on #6968: « rouvre en PR ciblée qui teste le détecteur pluriel canonique »). Two complementary deliverables:

  1. Tests: scripts/tests/test_detect_svg_decimal_commas.py (13 tests) — the canonical detector had zero test coverage on main. Covers the full public API (detect_svg / detect_cell / scan_notebook).
  2. Bug fix the tests surfaced: the detector only matched double-quoted SVG coordinate attributes. Single-quoted attrs bypassed it — a real gap.

The gap (the tests revealed it)

_POINTS_RE and _COORD_ATTR_RE matched only points="..." / cx="...". But single-quoted attrs are equally valid SVG, and some C# builders emit them:

// MGS-15 (#6960) source -> single-quote output
pts.Append($"<circle cx='{px:F1}' cy='{py:F1}' .../>");  // -> cx='170,9' on fr-FR

A decimal-comma bug in a single-quoted coord would have bypassed the #6965 CI gate entirely. The detector was written/tested against Infer-17 (double-quote); MGS-15 (single-quote) was outside its test set.

Firsthand before fix: cx="170,9" → detected ✓, cx='170,9' → NOT detected ✗.

Fix (minimal, 9+/5-)

Both regexes accept either quote via a backreference:

_POINTS_RE   = re.compile(r"...\bpoints\s*=\s*([\"'])(.*?)\1", re.IGNORECASE)
_COORD_ATTR_RE = {a: re.compile(rf"\b{a}\s*=\s*([\"'])(.*?)\1") for a in _COORD_ATTRS}

Consumers read group(2) (the value; group(1) is the opening quote). After fix: single-quote cx='170,9' and points='70,0,334,4' → detected; double-quote unchanged.

Validation (real, evidence-cited)

  • 13/13 tests pass (pre-fix, 4 failed — they revealed the gap; post-fix, green).
  • Repo-wide re-scan post-fix: 0 defects = 0 new false positives (clean SVGs use decimal-dot in either quote style; Graphviz uses double-quote + integer coords).
  • Detection logic unchanged (the precise >2 parts points check + \d,\d coord check); only the quote-delimiter acceptance broadened.

Files

File Role
scripts/tests/test_detect_svg_decimal_commas.py NEW — 13 regression tests for the canonical detector API
scripts/notebook_tools/detect_svg_decimal_commas.py FIX — single-quote attr support (closes CI-gate bypass)

See #6959 (canonical detector), #6965 (CI gate), #6946/#6960 (the original decimal-comma incidents). Verdict SOTA-OK: a targeted test+fix that hardens an existing tool, not a parallel detector.

The canonical detector (#6959) only matched double-quoted SVG coordinate
attributes (points="...", cx="..."). Single-quoted attrs are equally
valid SVG, and some C# builders emit them: MGS-15 (#6960) uses
<circle cx='{px:F1}'> -> cx='170,9' (single-quote). A decimal-comma bug
in a single-quoted coord would BYPASS the #6965 CI gate entirely.

Fix: _POINTS_RE and _COORD_ATTR_RE now accept either quote via a
backreference ((["'])(.*?)\1), consumers read group(2) (the value).
Minimal (9+/5- on the detector). Confirmed firsthand: single-quote
cx='170,9' and points='70,0,334,4' now detected; double-quote unchanged.

Add scripts/tests/test_detect_svg_decimal_commas.py (13 tests) covering
the canonical API (detect_svg / detect_cell / scan_notebook): the two bug
signatures, the Graphviz legit-integer NON-FP case, list-blob handling,
file-level scan + error path. These tests revealed the single-quote gap
(failing pre-fix), now green -- they lock both the detection and the fix.

Repo-wide re-scan post-fix: 0 defects (0 new false positives -- clean
SVGs use decimal-dot in either quote style, Graphviz uses double-quote +
integer coords). Follows ai-01's close-as-duplicate guidance on #6968
('reopen as a targeted PR testing the plural canonical detector').

Co-Authored-By: Claude-Code <noreply@anthropic.com>
@jsboige
jsboige merged commit b122955 into main Jul 17, 2026
11 checks passed
jsboige added a commit that referenced this pull request Jul 17, 2026
…g.py (#6799 canon)

34 deterministic tests covering scan_notebook, _STRIP_RE, _build_regex,
_src_lines, ACCENT_PAIRS dictionary self-consistency, and main() exit
codes. Mirror pattern of test_detect_svg_empty_display.py (L633-L1* canon:
defense-in-depth tests for cluster detectors in #6927 chain) and
test_detect_solution_leaks.py (existing sibling).

Why a test file for a one-shot detector?
  - 5 detectors in scripts/notebook_tools/ lack direct unit tests:
    detect_accent_stripping.py (this PR), detect_blank_figures.py,
    detect_ascii_workaround.py, detect_solution_leaks.py (HAS tests),
    detect_svg_decimal_commas.py (PR #6970 in flight).
  - Detector is core to registre #2876 (accents FR); ~22 PRs accumulated
    since 2026-03 on manual restoration. A test suite locks the
    detection contract so future dictionary edits don't regress the
    zero-FP discipline (G.1 c.539: dictionary excludes ~22 words that
    would otherwise generate mass false positives: complete, ou, la,
    valeur, niveau, exemple, fonction, etc.).

Coverage:
  - TestSrcLines (7): nbformat source-as-str vs source-as-list semantics
  - TestStripRegex (8): boundary, case-insensitive, plural-first, FP-proneness,
    accented-form idempotency, _build_regex repeatability
  - TestScanNotebook (8): clean / md-stripped / code-stripped / multi-hit /
    multi-line / multi-cell / nbformat-list / unreadable
  - TestAccentPairs (6): dictionary hygiene (lowercase keys, unique,
    suggestions differ from keys, accents present, FP-prone excluded)
  - TestMainExitCodes (5): --check exit 0/1, missing file exit 2,
    non-check mode exit 0, --json valid output

Verification:
  - 34/34 PASS in 0.23s
  - Full test suite: 2200 PASS (was 2166, +34), zero regressions

Closes gap in test coverage for partition-mienne OWNDOC (#2876 / #3801
axe-2 SOTA enforcement). See #6971 (companion detector tests, same
canon) for parallel precedent.

Co-Authored-By: Claude-Code <noreply@anthropic.com>
jsboige added a commit that referenced this pull request Jul 17, 2026
…g.py (#6799 canon) (#6973)

34 deterministic tests covering scan_notebook, _STRIP_RE, _build_regex,
_src_lines, ACCENT_PAIRS dictionary self-consistency, and main() exit
codes. Mirror pattern of test_detect_svg_empty_display.py (L633-L1* canon:
defense-in-depth tests for cluster detectors in #6927 chain) and
test_detect_solution_leaks.py (existing sibling).

Why a test file for a one-shot detector?
  - 5 detectors in scripts/notebook_tools/ lack direct unit tests:
    detect_accent_stripping.py (this PR), detect_blank_figures.py,
    detect_ascii_workaround.py, detect_solution_leaks.py (HAS tests),
    detect_svg_decimal_commas.py (PR #6970 in flight).
  - Detector is core to registre #2876 (accents FR); ~22 PRs accumulated
    since 2026-03 on manual restoration. A test suite locks the
    detection contract so future dictionary edits don't regress the
    zero-FP discipline (G.1 c.539: dictionary excludes ~22 words that
    would otherwise generate mass false positives: complete, ou, la,
    valeur, niveau, exemple, fonction, etc.).

Coverage:
  - TestSrcLines (7): nbformat source-as-str vs source-as-list semantics
  - TestStripRegex (8): boundary, case-insensitive, plural-first, FP-proneness,
    accented-form idempotency, _build_regex repeatability
  - TestScanNotebook (8): clean / md-stripped / code-stripped / multi-hit /
    multi-line / multi-cell / nbformat-list / unreadable
  - TestAccentPairs (6): dictionary hygiene (lowercase keys, unique,
    suggestions differ from keys, accents present, FP-prone excluded)
  - TestMainExitCodes (5): --check exit 0/1, missing file exit 2,
    non-check mode exit 0, --json valid output

Verification:
  - 34/34 PASS in 0.23s
  - Full test suite: 2200 PASS (was 2166, +34), zero regressions

Closes gap in test coverage for partition-mienne OWNDOC (#2876 / #3801
axe-2 SOTA enforcement). See #6971 (companion detector tests, same
canon) for parallel precedent.

Co-authored-by: Claude-Code <noreply@anthropic.com>
@jsboige
jsboige deleted the feature/test-detect-svg-decimal-commas branch September 2, 2026 13:15
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