Skip to content

fix(quality): inherited Python hooks were counted as dead overrides - #237

Open
qinghuanandejiangshi wants to merge 1 commit into
redhat-et:mainfrom
qinghuanandejiangshi:feature/20260916-quality-delta-clean-tree
Open

qinghuanandejiangshi wants to merge 1 commit into
redhat-et:mainfrom
qinghuanandejiangshi:feature/20260916-quality-delta-clean-tree

Conversation

@qinghuanandejiangshi

Copy link
Copy Markdown

Removing redundant direct callers from Python subclasses reported inherited hooks as new dead code, even though the parent still called them through self or cls. The regression exercises 30 subclasses at runtime: all 60 hooks remain callable, but the previous quality delta reported them as regressions.

Use direct class ownership, the parser's first-parameter bindings, and the existing inheritance graph as conservative liveness evidence. Snapshot and delta share the same eligibility rule; the quality snapshot cache scheme advances to retire the old dead sets. This does not add precise call-graph edges or exempt every test method.

The gate keeps unrelated and sibling orphans visible, rejects nested-function and second-parameter receiver lookalikes, and reports the hooks again when the inherited calls are removed. It also covers sidecar, HEAD, cached HEAD, and committed-range baselines.

Refs #228. This addresses the inherited-hook false positives only. I have not reproduced the separate unchanged-working-tree mismatch on the current baseline, so that part remains open.

Validation on macOS:

  • The new regression fails against an independently built, verified 30f14a274 binary and passes with this change.
  • Development and G1 sanitizer builds completed; sanitizer full-repository scan has no diagnostic output, emits valid XML, and passes qualitycheck.
  • Determinism gate: baseline plus three comparisons match; nested filtering and long-path XML checks pass. The Python fixture also produces identical quality deltas across cold/warm/warm/cold caches.
  • portablebuildcheck and the quality semantic fingerprint gate pass; snapshot scheme is 12.
  • Self quality delta has gating=0 without added acknowledgements. It still reports two new-function complexity findings (18 and 22), one minor parameter-count finding, and four minor churn findings.
  • Full suite: 632 gates, 629 passed, 3 skipped, 0 failed; tree_writes=0 (38m 40s, six workers). The skipped gates were argvdiffcheck, the baseline arm of editchecknotecheck, and g1freshcheck (the sanitizer build lives outside the checkout). Follow-up runs passed editchecknotecheck against the verified HEAD binary and g1freshcheck using a temporary link to the external sanitizer build (removed afterward).

The optional argvdiffcheck follow-up exits 1: 643/645 vectors match stdout, stderr and exit status; the only two differences are --version (with/without a corpus), whose built_from value is 30f14a274 versus 30f14a274+dirty. Both its differential and tree-mutation controls pass. This is recorded as a failed comparison, not folded into the full-suite pass count.

@coderabbitai

coderabbitai Bot commented Sep 16, 2026

Copy link
Copy Markdown

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: a70f5a0f-7de0-4720-993b-f0ff8129b86e

📥 Commits

Reviewing files that changed from the base of the PR and between 30f14a2 and e5708a9.

📒 Files selected for processing (4)
  • src/quality.h
  • test/qschemetrip.hash
  • test/qschemetripcheck.sh
  • test/qualitycheck.sh

Included review availability: Your plan provides up to 8 included reviews per hour; 7 remain after this review.


📝 Summary

Summary by CodeRabbit

  • Bug Fixes

    • Improved Python dead-code analysis to recognize methods reachable through inherited self and cls dispatch.
    • Prevents valid override methods from being incorrectly reported as dead code.
    • Applies consistently to baseline, working-tree, and quality-delta comparisons.
  • Tests

    • Added coverage for inherited dispatch across multi-level inheritance, sibling overrides, nested packages, and unrelated classes.
    • Verified results across snapshot, cached, and committed-range quality checks.

Walkthrough

This change adds Python inherited self/cls dispatch detection to dead-code analysis. Snapshot and delta checks exclude reachable overrides, qsnap metadata is updated, and end-to-end tests cover inheritance and dispatch removal.

Changes

Python dispatch liveness

Layer / File(s) Summary
Dispatch analysis
src/quality.h
Adds helpers that identify Python receiver calls, walk descendant classes, and return sorted method IDs for possible overrides. isDeadCandidate treats those IDs as live.
Quality integration and cache scheme
src/quality.h, test/qschemetrip.hash, test/qschemetripcheck.sh
Snapshot and delta computations pass the dispatch set to dead-code classification. The qsnap scheme manifest and fixture hash are updated for the new semantic behavior.
Dispatch liveness validation
test/qualitycheck.sh
Adds fixtures and assertions for inherited dispatch, unrelated methods, sibling and nested classes, multiple delta modes, and dispatch removal.

Priority: ⬇️ Low

Estimated code review effort: 4 (Complex) | ~45 minutes

Change: Bug fix

Suggested reviewers: joyful-ii-v-i

Sequence Diagram(s)

sequenceDiagram
  participant computeSnapshot
  participant pythonDispatchedMethodIds
  participant isDeadCandidate
  computeSnapshot->>pythonDispatchedMethodIds: build dispatch NodeIds from IngestResult and Graph
  pythonDispatchedMethodIds-->>computeSnapshot: return sorted Python override IDs
  computeSnapshot->>isDeadCandidate: evaluate symbols with pythonDispatchIds
  isDeadCandidate-->>computeSnapshot: return live or dead classification
  participant computeDelta
  computeDelta->>pythonDispatchedMethodIds: build dispatch NodeIds
  pythonDispatchedMethodIds-->>computeDelta: return sorted Python override IDs
  computeDelta->>isDeadCandidate: evaluate working-tree symbols
  isDeadCandidate-->>computeDelta: return live or dead classification
Loading

Merge Risk: ⚪ Minimal · up to e5708

The inherited Python dispatch fix is mergeable based on the verified implementation contracts and available coverage.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 50.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 6 functions across 3 files. (1 skipped: 1… Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and concisely describes the main fix: inherited Python hooks were incorrectly classified as dead overrides.
Description check ✅ Passed The description directly explains the inherited Python hook liveness fix, implementation approach, regression coverage, and validation results.
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.
Full details: Docstring Coverage

Explanation

Docstring coverage is 50.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 6 functions across 3 files. (1 skipped: 1 unsupported.)

  • Fix all pre-merge checks with AI
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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