feat(enrichment): blame-to-PR regression linker analyzer (#2034)#2620
Conversation
) New REES github-light analyzer: for files a PR modifies/deletes, resolves which prior PR most recently introduced that region and surfaces it, giving the reviewer instant context on what the change is altering. Bounded + fail-safe. - types.ts: BlameLinkFinding ({ file, line, introducedByPr?, introducedByShaPrefix? }) + blameLink? key on BriefFindings (sha prefix only, never contents). - analyzers/blame-link.ts: firstTouchedOldLine() parses the patch for a representative modified/deleted old line; per file, reads the path's most recent base-branch commit and maps it to its PR via the commit->PR association API. Strict maxFilesProbed (6) + maxLookups (12) caps; emits partial on cap; skips added files and pure additions; no-token/bad-slug/fetch-error -> no finding. - registry.ts: descriptor (category history, cost github-light, requires files+github-token) with an inline render(). - render.ts: dispatch the blameLink section via renderDescriptorSection. - Regenerated analyzer-metadata.json, .env.example, and the UI metadata; added blameLink to the registry meta-test's expected list. - test/blame-link.test.ts: resolved PR, sha-only fallback, unresolvable (no finding), added/pure-addition skip, file-probe cap, token-absent skip. review-enrichment test suite: 400/400 pass.
|
Warning 🟨🟨🟨🟨🟨🟨🟨🟨🟨🟨🟨🟨 ⏸️ Gittensory review result - manual review recommendedReview updated: 2026-07-02 23:16:50 UTC
⏸️ Suggested Action - Manual Review Review summary Nits — 5 non-blocking
Review context
Contributor next steps
Signal definitions
🟩 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.
|
…parser (JSONbored#2034) firstTouchedOldLine treated a `\ No newline at end of file` marker line as a context line, wrongly advancing the old-file line counter. Skip it as metadata (like the stray ---/+++ headers). Added a test covering the marker. review-enrichment: 400/400 pass.
…ONbored#2034) Address review nits: - Handle removed files without requiring a patch: status === "removed" now blames via the file path alone (anchored to line 1), so a deleted file with a binary/truncated diff is no longer silently skipped despite the analyzer claiming to cover deletes. - Render the coordinate explicitly as `(old line N)` instead of `file:line`, which read like a current line — the value is the OLD-file line. - Give the commit→PR association call its own diagnostics subcall ("github-commit-pulls") instead of sharing "github-commits", for precise per-subcall diagnostics (shared endpoint budget unchanged). - Tests: a shifted-hunk case pinning the old-line semantics (+ its render) and a patchless removed-file case. review-enrichment: 402/402 pass.
…tighter cap test (JSONbored#2034) Final review nits (all non-blocking): - Render says the file "was most recently touched by" instead of "introduced by" a specific line — accurate to the file-level path-history lookup this does. - Give the commit→PR association call its own endpointCategory ("github-commit-pulls") for precise rate attribution (loop-level MAX_LOOKUPS still bounds the total). - Cap test now asserts exactly 12 fetch calls and that files past the probe cap (f6..f9) are never queried, pinning the bound. review-enrichment: 402/402 pass.
…t line origin (JSONbored#2034) Resolve the reviewer's false-attribution concern: the analyzer only does a file-level latest-commit lookup, so it must not word its result as introducing a specific line. Make the claim match the behavior (no line-aware blame added). - Rename BlameLinkFinding.introducedBy{Pr,ShaPrefix} → lastTouchedBy{Pr,ShaPrefix}; the `line` field is now documented as a pointer to where THIS PR changes the file, not a line attributed to the PR. - Reframe type doc, analyzer docstring, descriptor title/docs, and the rendered section as "last PR to touch each file — file-level context, bounded scan". - Harden firstTouchedOldLine: only a space-prefixed context line advances the old cursor; additions, the `\` marker, and malformed/extended text no longer count, so a garbled patch fails closed. - Tests: rename fields; add a false-attribution regression (latest file commit touched a different region than the changed line → reported file-level, never attributed to the line) and a malformed-patch fail-closed case. review-enrichment: 403/403 pass.
…SONbored#2034) A renamed file lives under its OLD path in the base tree, so blame-link now looks up commit history via `previousPath` for status === "renamed" (falling back to line 1 when a pure rename carries no usable patch), while still displaying the new path to the reviewer. Also trims the rendered section title (was em-dash-heavy and longer than neighboring headings). - Test: a renamed file is probed under its old path and rendered as the new path. review-enrichment: 404/404 pass.
…-`/`---` content (JSONbored#2034) The previous hardening added a `!startsWith("---")` guard to firstTouchedOldLine, but inside a hunk that wrongly skips a real deletion whose CONTENT begins with two hyphens (git renders a deleted `--x` line as `---x`). File headers only appear before a hunk, which the inHunk flag already excludes, so the guard was both wrong and unnecessary — dropped it. Added assertions for `---`/`--`-content deletions. review-enrichment: 404/404 pass.
Closes #2034 (part of #1499).
New REES github-light analyzer: for files a PR modifies or deletes, it resolves which prior PR most recently introduced that region and surfaces it — giving the reviewer instant context on what the change is altering. Not per-line blame (no checkout/blame API): it attributes each touched file's most recent base-branch commit and maps it to its PR. Bounded and fail-safe.
Deliverables
review-enrichment/src/types.ts—BlameLinkFinding({ file, line, introducedByPr?, introducedByShaPrefix? }, SHA prefix only, never contents) +blameLink?onBriefFindings.review-enrichment/src/analyzers/blame-link.ts—firstTouchedOldLine()parses the unified-diff patch for a representative modified/deleted old line; per file it reads the path's most recent commit onbaseShaand maps it to a PR via the commit→PR association API (injectedfetch). StrictmaxFilesProbed(6) +maxLookups(12) caps; emits partial on cap; skips added files & pure additions (nothing to blame); no-token / bad-slug / fetch-error → no finding, never throws.registry.ts— descriptor (category: history,cost: github-light,requires: ['files','github-token']) with an inlinerender().render.ts— dispatches theblameLinksection viarenderDescriptorSection.analyzer-metadata.json,.env.example, and the UI metadata; addedblameLinkto the registry meta-test's expected list.test/blame-link.test.ts— resolved originating PR (+ brief render), SHA-only fallback, unresolvable line (no finding), added/pure-addition skip, file-probe cap, and token-absent skip; plus purefirstTouchedOldLinecases.Validation
Full
review-enrichmentsuite (build + sourcemaps +metadata --check+node:test):Includes the 7 blame-link tests and the "generated analyzer metadata matches the runtime registry and profiles" check, so the metadata/
.env/UI regeneration is consistent with the descriptor.