Skip to content

perf(gate): intersect changed lines via smaller-side lookup in js gate - #2071

Open
seonghobae wants to merge 1 commit into
mainfrom
autoresearch/20260910-js-gate-intersect
Open

perf(gate): intersect changed lines via smaller-side lookup in js gate#2071
seonghobae wants to merge 1 commit into
mainfrom
autoresearch/20260910-js-gate-intersect

Conversation

@seonghobae

@seonghobae seonghobae commented Sep 10, 2026

Copy link
Copy Markdown
Contributor

Summary

Smaller-side lookup for Istanbul changed-line intersection in scripts/ci/javascript_coverage_gate.py: small spans probe the changed set (O(span)), large spans scan it (O(C)). Same semantics, ~96% faster on synthetic 2000x2000.

Metric (KPI: mean <=0.055s, >=40% down + guardrails)

  • Baseline (main f578d8d): changed_metric_counts 2000x2000 5x mean=0.0924s (stdev 0.0113); intersects micro 2000 calls 0.0845s
  • Exact-head (ba07a8c): 5x mean=0.0034s; micro 0.0019s (~96% down)
  • Independent repeats: 0.0054 / 0.0213 / 0.0028, all below baseline
  • Equivalence: statements (2000,2000) assert held every run

Guardrails (all GREEN, exact-head)

  • Targeted: 26 passed (tests/test_javascript_coverage_gate.py, +1 new small-span test)
  • Full suite: 3032 passed, 1 skipped, 21 subtests passed
  • Coverage: 100% (13216 stmts / 5340 branch; changed file 261/120)
  • Interrogate: 100%
  • No open-PR contention: touched files absent from 20-PR name-only census (codeql_sarif_gate/filter_gitleaks/scheduler/router untouched)

Change (15+/8-, 2 files)

  • scripts/ci/javascript_coverage_gate.py: _range_intersects_changed() helper + 4 call sites (intersects + 3x changed_metric_counts)
  • tests/test_javascript_coverage_gate.py: test_small_span_intersection_uses_membership_lookup (covers span<len branch)

Gap linkage

  • G-04 queue hygiene (gate overhead down), G-09 green CI with accuracy (output equivalence asserted). Control-plane only; no product/Buyer/DB/UX scope. Figma N/A.

Verification

  • Commands: PYTHONPATH=. .venv/bin/python /tmp/baseline_js_gate.py; pytest tests/test_javascript_coverage_gate.py; coverage run -m pytest tests; coverage report; interrogate
  • results.tsv experiment 6 keep (untracked, local only)

Summary by CodeRabbit

  • 리팩터링

    • 코드 실행 범위와 변경된 줄의 교차 여부 판정을 공통 로직으로 정리했습니다.
    • 기존과 동일한 교차 판정 동작을 유지하면서 작은 범위를 우선 확인하도록 개선했습니다.
  • 테스트

    • 실행 범위가 변경된 줄과 교차하는 경우와 교차하지 않는 경우를 검증하는 테스트를 추가했습니다.

@coderabbitai

coderabbitai Bot commented Sep 10, 2026

Copy link
Copy Markdown

Review Change StackReview Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Advanced

Run ID: e76937f9-dc26-4b27-aac4-1dc9030d7dfd

📥 Commits

Reviewing files that changed from the base of the PR and between f578d8d and ba07a8c.

📒 Files selected for processing (2)
  • scripts/ci/javascript_coverage_gate.py
  • tests/test_javascript_coverage_gate.py

Included review availability: Your plan provides up to 1 included review per hour; 0 remain after this review.


📝 Walkthrough

Walkthrough

커버리지 게이트가 범위 길이와 변경 라인 수 중 더 작은 쪽을 순회하도록 공통 헬퍼를 사용합니다. Statement, function, branch 검사에 헬퍼를 적용하고 작은 범위의 교차 여부 테스트를 추가합니다.

Changes

커버리지 범위 교차 검사

Layer / File(s) Summary
교차 검사 헬퍼 통합
scripts/ci/javascript_coverage_gate.py
_range_intersects_changed를 추가했습니다. intersects와 statement, function, branch 필터링이 공통 헬퍼를 사용합니다.
교차 검사 동작 테스트
tests/test_javascript_coverage_gate.py
작은 범위가 변경 라인과 교차하는 경우와 교차하지 않는 경우를 검증합니다.

Estimated code review effort: 2 (Simple) | ~10 minutes

Merge Risk: ⚪ Minimal · up to ba07a

This change optimizes changed-line coverage intersection while preserving statement, function, and branch results. Existing tests cover intersecting and non-intersecting short ranges, with no current merge-blocking risk identified.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 71.43% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 7 functions across 2 files. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed 제목은 변경된 줄과 범위의 교집합을 더 작은 쪽에서 조회하도록 최적화한 핵심 변경을 정확하고 간결하게 설명합니다.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
  • Fix all pre-merge checks with AI
✨ Finishing Touches 💡 1
📝 Generate docstrings 💡
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch autoresearch/20260910-js-gate-intersect

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

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