Skip to content

feat(enrichment): add revert-recurrence detector#3647

Merged
loopover-orb[bot] merged 1 commit into
JSONbored:mainfrom
e11734937-beep:feat/revert-recurrence-analyzer
Jul 5, 2026
Merged

feat(enrichment): add revert-recurrence detector#3647
loopover-orb[bot] merged 1 commit into
JSONbored:mainfrom
e11734937-beep:feat/revert-recurrence-analyzer

Conversation

@e11734937-beep

Copy link
Copy Markdown
Contributor

Closes #1514 (part of #1499).

What

Adds a history-class review-enrichment analyzer, revertRecurrence, that flags a changed file when the PR re-introduces added lines in a region a prior revert commit removed — a signal the change may be re-treading a path that was already reverted or hot-fixed out. This is heavy/external/historical analysis the no-checkout claude --print reviewer cannot do.

How

For each changed file (bounded to the first 5 informative paths — lockfiles/generated/binaries skipped):

  1. Read the file's recent commit history via the GitHub commits API (?path=, 15 commits).
  2. Detect revert commits by message — GitHub's Revert "<title> (#N)" subject or a hand-written This reverts commit <sha> body.
  3. Fetch each revert commit's patch (global cap of 10 detail lookups) and intersect the reverted old-file removed line-ranges with this PR's added new-file line-ranges.
  4. Report one finding per file: the file, a re-introduced line, a short revert-SHA prefix, and the reverted PR number when the message names one — never file contents.

Distinct from churn-hotspot (#1513, defect density) and history (#1478, author track record): this intersects the PR's added lines with a specific past revert's removed lines.

Fail-safe: any missing token / invalid slug / non-200 / thrown fetch / aborted signal degrades that lookup (or the whole scan) to [], never throwing. Bounded fan-out throughout (5 files / 15 commits / 10 revert lookups / 25 findings).

Wiring

Registry descriptor (category history, cost github-heavy, balanced/deep profiles), render section, types.ts, UI rees-analyzers.ts docs, refreshed analyzer-metadata.json, and both analyzer-name lists (enrichment-analyzer-names.ts, analyzer-registry.test.ts). Metadata is drift-checked.

Tests

New test/revert-recurrence.test.ts unit-covers the pure helpers (isRevertCommit, revertedPrNumber, diffLineRanges, rangesOverlap, firstOverlap) and the scanner: overlap hit, body-style revert without PR number, no-revert (no detail fetch), non-overlapping revert, wrong-file revert, missing-sha skip, empty-add skip, lockfile/binary skip, token/slug guards, the revert-lookup cap, fetch/detail fail-safe, aborted signal, and the public-safe render block. Full REES suite green; root + UI typecheck, UI lint (0 errors), and coverage all pass, with src/review/enrichment-analyzer-names.ts at 100%.

Adds a history-class review-enrichment analyzer (JSONbored#1514, part of JSONbored#1499) that
flags a changed file when the PR re-introduces added lines in a region a prior
revert commit removed - a signal the change may be re-treading a path that was
already reverted or hot-fixed out.

For each changed file it reads recent commit history, detects revert commits
(Revert "..." subject or a "This reverts commit <sha>" body), fetches each
revert commit patch, and intersects the reverted old-file line ranges with the
PR added new-file line ranges. Reports only the file, a re-introduced line, a
short revert-SHA prefix, and the reverted PR number when named - never file
contents. Bounded fan-out (5 files / 15 commits / 10 revert lookups / 25
findings); fail-safe on missing token, invalid slug, fetch error, or abort.

Wires the descriptor into the registry, render, types, UI docs, refreshed
metadata, and the analyzer-name lists, with full unit coverage.
@e11734937-beep
e11734937-beep requested a review from JSONbored as a code owner July 5, 2026 22:14
@superagent-security

Copy link
Copy Markdown
Contributor

Superagent didn't find any vulnerabilities or security issues in this PR.

@codecov

codecov Bot commented Jul 5, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 93.13%. Comparing base (39431cc) to head (3679f39).

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #3647   +/-   ##
=======================================
  Coverage   93.13%   93.13%           
=======================================
  Files         314      314           
  Lines       32005    32005           
  Branches    11725    11725           
=======================================
  Hits        29807    29807           
  Misses       1552     1552           
  Partials      646      646           
Files with missing lines Coverage Δ
src/review/enrichment-analyzer-names.ts 100.00% <ø> (ø)
🚀 New features to boost your workflow:
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@loopover-orb loopover-orb Bot added the gittensor:priority Maintainer-selected Gittensor priority — scores a 1.5x multiplier. label Jul 5, 2026
@loopover-orb

loopover-orb Bot commented Jul 5, 2026

Copy link
Copy Markdown
Contributor

Warning

🟨🟨🟨🟨🟨🟨🟨🟨🟨🟨🟨🟨

⏸️ Gittensory review result - manual review recommended

Review updated: 2026-07-05 22:21:00 UTC

10 files · 1 AI reviewer · no blockers · readiness 62/100 · CI green · clean

⏸️ Suggested Action - Manual Review

Review summary
Adds a new bounded, fail-safe history-class analyzer (revertRecurrence) that intersects a PR's added line-ranges with the removed-line ranges of prior revert commits touching the same file, fetched via the GitHub commits/commit-detail APIs. The diff/overlap parsing logic is correct and well covered by pure-function unit tests, wiring across registry/types/render/metadata/UI docs/analyzer-name lists is complete and consistent, and all fan-out is bounded (5 files / 15 commits / 10 detail lookups / 25 findings) with fail-safe degradation to [] on any missing token, invalid slug, or fetch error. The PR closes issue #1514 as required, and no correctness defect is evident on the reachable path.

Nits — 6 non-blocking
  • review-enrichment/src/analyzers/revert-recurrence.ts: the overlap check compares old-file line numbers from a historical revert commit against new-file line numbers from the current PR diff, which can drift if the file was edited between the revert and this PR — worth a one-line comment noting this is a best-effort heuristic (already partially covered by the descriptor's `notes` field, but not in the code itself).
  • review-enrichment/src/analyzers/revert-recurrence.ts:175: the `512 * 1024` maxBytes and other numeric literals (7-char SHA prefix, etc.) could be named constants for consistency with the file's existing MAX_* constants.
  • review-enrichment/src/analyzers/revert-recurrence.ts: nesting in the main scan loop (probe → commit → revert-detail → overlap) is fairly deep; consider extracting the per-commit revert-check into a small helper for readability.
  • review-enrichment/test/revert-recurrence.test.ts: solid coverage of the pure helpers and fail-safe paths; consider adding a case where two different files each produce a finding to confirm MAX_FINDINGS/ordering across files, though this is minor given the existing per-file cap test.
  • Consider factoring the per-commit revert-check (sha/message validation → detail fetch → overlap) out of the nested loop in revert-recurrence.ts into a small named function to reduce nesting depth and ease future maintenance.
  • Readiness score is below the configured threshold — Use the readiness panel as advisory maintainer context; the score does not block this PR.
Signal Result Evidence
Code review ✅ No blockers 1 reviewer
Linked issue ✅ Linked #1514
Related work ⚠️ 2 scoped overlaps Top overlaps are listed below; lower-confidence bulk is hidden.
Change scope ❌ 8/20 High review scope from cached public metadata (1 linked issue).
Validation posture ❌ 5/25 Preflight is holding this PR: the review lane is unavailable, so it is not ready for automated review.
Contributor workload ✅ 10/10 Author activity: 41 registered-repo PR(s), 20 merged, 0 issue(s).
Contributor context ✅ Confirmed Gittensor contributor e11734937-beep; Gittensor profile; 41 PR(s), 0 issue(s).
Gate result ✅ Passing No configured blocker found.
Review context
  • Author: e11734937-beep
  • Role context: outside_contributor
  • Public audience mode: oss maintainer
  • Lane context: Repository registration is not available in the local Gittensory cache.
  • Public profile languages: not available
  • Official Gittensor activity: 41 PR(s), 0 issue(s).
  • Related work: Titles/paths share 5 meaningful terms. (issue #1514, issue #1509)
  • Related work: Titles/paths share 5 meaningful terms. (issue #1514, issue #1516)
Contributor next steps
  • Review top overlaps.
  • Add a concise scope and risk note.
  • Await review-lane availability.
  • Refresh registry data or choose a registered active repo.
  • Check active issues and PRs before submitting.
Signal definitions
  • Related work = same linked issue, overlapping active PRs, or title/path similarity.
  • Change scope = cached public metadata such as size labels, draft state, and review-burden hints.
  • Validation posture = whether the PR provides enough public validation/test evidence for maintainer review.
  • Contributor workload = public contributor activity and cleanup pressure, not a repo-wide quality failure.
  • Contributor context = public GitHub/Gittensor identity context; non-Gittensor status is not a blocker.

🟩 Safe / merged · 🟦 Advisory · 🟨 Held for review · 🟥 Blocked / closed


💰 Earn for open-source contributions like this. Gittensor lets GitHub contributors earn for the work they already do — register to start earning →.

Checked by Gittensory, a quiet PR intelligence layer for OSS maintainers.

  • Re-run Gittensory review

@loopover-orb loopover-orb Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Gittensory approves — the gate is satisfied and CI is green.

@loopover-orb
loopover-orb Bot merged commit bd33453 into JSONbored:main Jul 5, 2026
9 checks passed
@loopover-orb loopover-orb Bot added gittensor:feature Gittensor-scored feature linked to a feature issue — scores a 0.25x multiplier. and removed gittensor:priority Maintainer-selected Gittensor priority — scores a 1.5x multiplier. labels Jul 5, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

gittensor:feature Gittensor-scored feature linked to a feature issue — scores a 0.25x multiplier.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

feat(enrichment): Revert-recurrence detector

1 participant