← Back to Pull requests

Add unit tests for scripts/rtl_ltr_linter.py #13431

Open
jmenezes-cyber opened this pull request with 78 lines diff across 1 files
View on GitHub
jmenezes-cyber jmenezes-cyber commented on Aug 28, 2026 14:32 UTC
Author

Summary

scripts/rtl_ltr_linter.py (the RTL/LTR Markdown linter run in CI) currently has no automated test coverage. This PR adds a small pytest suite for it:

  • is_rtl_filename() — filename-based direction detection

  • split_by_span() — nested <span dir="..."> context splitting

  • load_config() — default configuration values

  • A regression test for #12500: a line containing both an opening and a closing <div dir="..."> tag must not leave the block-context stack unbalanced (which would otherwise trigger a false "unclosed div" error on later lines).
  • I verified the regression test is meaningful: reproducing the old (pre-fix) single-match-then-continue logic described in #12500 makes this new test fail, while it passes against the current main code.

    Test plan

  • pip install python-bidi PyYAML pytest

  • pytest scripts/test_rtl_ltr_linter.py -v — all 10 tests pass locally

  • Confirmed the regression test fails against a simulated pre-fix version of lint_file(), and passes against current main
  • Diff: 78 lines (+78 / -0) across 1 files Reviewer: None requested Review duration: 46956m
    All Vouch review confidence checks passed
    Residual risk 0.28 = Change Risk (0.48) × (1 − Review Confidence (0.42)). Review depth and reviewer attention state are adequate.
    Model 1 · Change Risk (XGBoost)
    Score: 0.48 · 78 lines diff across 1 files
    0.48
    Model 2 · Review Depth (DistilBERT)
    Depth Score: 0.02 · 1 substantive comment(s)
    0.02
    Model 3 · Review Timing & Attention
    Session adequacy: 100% · Reviewer familiarity: 10%
    42%
    Bedrock Claude 3 · Risk Narration
    (disconnected)
    Groq
    Groq Risk Narration
    AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
    Model 1 · Change Risk Attribution
    SHAP Weights
    Shallow Review Depth shallow_review_depth
    0.344
    Diff Size diff_size
    0.261
    No Reviewer Assigned no_reviewer_assigned
    0.120
    Real PR Conversation Timeline
    1 item
    "Review active on #13431"
    general weight: 0.35
    Reviewers
    None requested
    Assignees
    jmenezes-cyber jmenezes-cyber
    Labels
    risk: low confidence: 42.2% reviewed
    Vouch Risk Breakdown
    AI-powered review risk analysis
    Change Risk
    Change Risk · Model 1 (XGBoost)
    Predicted defect probability (0.00–1.00) based on diff churn, modified sensitive files, and author risk history.
    Score: 48.1% (MEDIUM) · Higher = larger blast radius
    48.1%
    Review Confidence
    Review Confidence · Models 2 & 3
    Scrutiny score (0.00–1.00) combining DistilBERT semantic review depth with reviewer familiarity and session dwell time.
    Score: 42.2% · Lower = rushed or shallow review
    42.2%
    Residual Risk
    Residual Risk · Core Equation
    Residual = Change × (1 − Confidence)
    Unmitigated risk surviving review. ≥ 0.65 triggers an automated re-queue to protect production.
    Score: 27.8% · Safe to merge
    27.8%