Skip to content

feat(enrichment): PR history analyzer + engine context passthrough#1701

Closed
kiannidev wants to merge 6 commits into
JSONbored:mainfrom
kiannidev:feat/1697-history-analyzer-passthrough
Closed

feat(enrichment): PR history analyzer + engine context passthrough#1701
kiannidev wants to merge 6 commits into
JSONbored:mainfrom
kiannidev:feat/1697-history-analyzer-passthrough

Conversation

@kiannidev

@kiannidev kiannidev commented Jun 28, 2026

Copy link
Copy Markdown
Contributor

Summary

  • Add REES history analyzer: parses linked issues from PR body, classifies author tier (newcomer/established), fetches issue state when a GitHub token is available
  • Extend enrichment-wire to POST author, body, and githubToken to REES
  • Resolve installation token in runAiReviewForAdvisory via resolveEnrichmentGithubToken (same best-effort pattern as grounding/RAG)

Fixes #1697

Validation

cd review-enrichment && npm test
npx vitest run test/unit/enrichment-wire.test.ts test/unit/enrichment-wiring.test.ts

Test plan

  • Linked issue parsing (default repo + explicit org/repo#N)
  • Author tier classification from merged PR search count
  • Graceful degradation without token (body parsing only)
  • Engine POST includes author/body/token; wiring test asserts processor path

Add REES history analyzer for author track record and linked-issue alignment.
Pass author, body, and installation token through enrichment-wire so webhook
reviews can run historical analysis during the AI review path.

Fixes JSONbored#1697

Co-authored-by: Cursor <[email protected]>
@kiannidev kiannidev requested a review from JSONbored as a code owner June 28, 2026 23:26
@dosubot dosubot Bot added the size:L This PR changes 100-499 lines, ignoring generated files. label Jun 28, 2026
@codecov

codecov Bot commented Jun 28, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 95.48%. Comparing base (a39a340) to head (64aabc6).
✅ All tests successful. No failed tests found.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1701      +/-   ##
==========================================
- Coverage   95.58%   95.48%   -0.10%     
==========================================
  Files         204      207       +3     
  Lines       22295    22493     +198     
  Branches     8053     8124      +71     
==========================================
+ Hits        21310    21477     +167     
- Misses        408      430      +22     
- Partials      577      586       +9     
Files with missing lines Coverage Δ
review-enrichment/src/analyzers/codeowners.ts 64.83% <100.00%> (ø)
src/queue/processors.ts 88.23% <100.00%> (+0.09%) ⬆️
src/review/codeowners-prefetch.ts 100.00% <100.00%> (ø)
src/review/enrichment-prefetch.ts 100.00% <100.00%> (ø)
src/review/enrichment-wire.ts 100.00% <100.00%> (ø)
🚀 New features to boost your workflow:
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Exercise null author/body, missing installation id, allowlist-off path,
and installation-token resolution in enrichment wiring tests.

Fixes JSONbored#1697

Co-authored-by: Cursor <[email protected]>
Comment thread src/review/enrichment-wire.ts Outdated
@superagent-security superagent-security Bot added the pr:flagged PR flagged for review by security analysis. label Jun 28, 2026
@gittensory-orb

gittensory-orb Bot commented Jun 28, 2026

Copy link
Copy Markdown

Warning

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

⏸️ Gittensory review — held for maintainer review

17 files · 1 AI reviewer · no blockers · readiness 55/100 · CI green · dirty

⏸️ Held for maintainer review — Large change — held for manual review; Touches a guarded path — held for manual review

Review summary
This change correctly moves GitHub-backed enrichment into the engine-side prefetch path and keeps raw credentials out of the REES request body. The new history analyzer, CODEOWNERS passthrough contract, and processor wiring are coherent with the stated security model. The main concern is prompt quality/noise: the history path now emits an author-history section even when it has no actual history or linked-issue signal.

Signal Result Evidence
Code review ✅ No blockers 1 reviewer
Linked issue ✅ Linked #1697
Related work ⚠️ 3 scoped overlaps Top overlaps are listed below; lower-confidence bulk is hidden.
Review load ❌ 8/20 Readiness component derived from cached public PR metadata and labels.
Validation evidence ❌ 5/25 Cached preflight status is hold.
Open PR queue ❌ 3/10 15 open PR(s), 11 likely reviewable, 4 unlinked.
Contributor context ✅ Confirmed Gittensor contributor kiannidev; Gittensor profile; 3290 PR(s), 50 issue(s).
Gate result ⚠️ Not blocking Advisory; not blocking this PR.
Nits — 9 non-blocking
  • nit: review-enrichment/src/analyzers/history.ts:50 returns an unknown-only history object when there are no linked issues, which makes renderBrief add a low-value "No linked issues detected" section for ordinary PRs with only an author.
  • nit: src/review/enrichment-prefetch.ts:191 has the same unknown-only history behavior as the REES fallback, so the noisy section is produced on the normal engine-prefetch path too.
  • nit: src/review/codeowners-prefetch.ts:36 catches aborted fetches and continues trying fallback CODEOWNERS locations, which can spend extra work after the caller has already cancelled the analyzer budget.
  • nit: review-enrichment/src/types.ts:113 adds RevertRecurrenceFinding in a PR about history/prefetch without wiring it into BriefFindings, so either remove it from this PR or include the analyzer contract that uses it.
  • Change review-enrichment/src/analyzers/history.ts:50 and src/review/enrichment-prefetch.ts:191 to return null when both linkedIssues is empty and mergedPrCount is null, unless you explicitly want a rendered no-signal section.
  • PR author also opened the linked issue — Link an issue that was opened by a different contributor, or provide a rationale for why this self-authored issue represents genuine discovery work.
  • Readiness score is below the configured threshold — Use the readiness panel as advisory maintainer context; the score does not block this PR.
  • Large change — held for manual review — Split this into smaller, focused PRs, or a maintainer reviews and merges it manually.
  • Touches a guarded path — held for manual review — A maintainer must review and merge this change.
Review context
Contributor next steps
  • Review top overlaps.
  • Add scope summary.
  • Fix blocker.
  • Expect slower review.
  • 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.
  • Review load = cached public PR metadata such as size labels, changed paths, and preflight status.
  • Open PR queue = repo-wide review pressure; it is not a PR quality failure.
  • Contributor context = public GitHub/Gittensor identity context; non-Gittensor status is not a blocker.
Review details

Generated from public PR metadata and the diff. Advisory only; deterministic signals remain authoritative.

This change correctly moves GitHub-backed enrichment into the engine-side prefetch path and keeps raw credentials out of the REES request body. The new history analyzer, CODEOWNERS passthrough contract, and processor wiring are coherent with the stated security model. The main concern is prompt quality/noise: the history path now emits an author-history section even when it has no actual history or linked-issue signal.

Nits (5)

  • nit: review-enrichment/src/analyzers/history.ts:50 returns an unknown-only history object when there are no linked issues, which makes renderBrief add a low-value "No linked issues detected" section for ordinary PRs with only an author.
  • nit: src/review/enrichment-prefetch.ts:191 has the same unknown-only history behavior as the REES fallback, so the noisy section is produced on the normal engine-prefetch path too.
  • nit: src/review/codeowners-prefetch.ts:36 catches aborted fetches and continues trying fallback CODEOWNERS locations, which can spend extra work after the caller has already cancelled the analyzer budget.
  • nit: review-enrichment/src/types.ts:113 adds RevertRecurrenceFinding in a PR about history/prefetch without wiring it into BriefFindings, so either remove it from this PR or include the analyzer contract that uses it.
  • Change review-enrichment/src/analyzers/history.ts:50 and src/review/enrichment-prefetch.ts:191 to return null when both linkedIssues is empty and mergedPrCount is null, unless you explicitly want a rendered no-signal section.

🟩 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

@gittensory-orb gittensory-orb Bot added gittensor Gittensor contributor context gittensor:feature Gittensor-scored feature linked to a feature issue - worth 1.25x multiplier. labels Jun 28, 2026
… to REES

Move history GitHub API calls into enrichment-prefetch.ts so installation
tokens stay in the engine process. REES receives structured prefetch findings
only; githubToken is removed from the enrich wire contract.

Fixes JSONbored#1697

Co-authored-by: Cursor <[email protected]>
@superagent-security superagent-security Bot removed the pr:flagged PR flagged for review by security analysis. label Jun 28, 2026
kiannidev and others added 2 commits June 29, 2026 01:42
Engine-side CODEOWNERS scan restores the prefetch contract without sending
tokens to REES; expanded prefetch unit tests cover abort signals and branches.

Co-authored-by: Cursor <[email protected]>
@dosubot dosubot Bot added size:XL This PR changes 500-999 lines, ignoring generated files. and removed size:L This PR changes 100-499 lines, ignoring generated files. labels Jun 28, 2026
@superagent-security superagent-security Bot removed the size:XL This PR changes 500-999 lines, ignoring generated files. label Jun 28, 2026
…n try

Relocate engine-side CODEOWNERS fetch/match into src/review so vitest
covers the patch; wrap prefetch in buildReviewEnrichment's fail-safe try.

Co-authored-by: Cursor <[email protected]>
@dosubot dosubot Bot added the size:XL This PR changes 500-999 lines, ignoring generated files. label Jun 28, 2026
@superagent-security superagent-security Bot removed the size:XL This PR changes 500-999 lines, ignoring generated files. label Jun 28, 2026

@JSONbored JSONbored left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

Please fix merge conflicts before resubmitting - please note, these enrichment PRs tend to overlap so I suggest only submitting one at a time, or ensure you build them in a way where they won't cause merge conflicts.

This branch has conflicts that must be resolved
Use the [web editor](https://github.com/JSONbored/gittensory/pull/1701/conflicts) or the command line to resolve conflicts before continuing.

review-enrichment/src/brief.ts
review-enrichment/src/render.ts
review-enrichment/src/types.ts

@JSONbored JSONbored closed this Jun 29, 2026
@kiannidev

Copy link
Copy Markdown
Contributor Author

Hi, @JSONbored
Please reopen this PR so that I can resolve conflicts.

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 - worth 1.25x multiplier. gittensor Gittensor contributor context

Projects

None yet

Development

Successfully merging this pull request may close these issues.

feat(enrichment): PR history analyzer + engine context passthrough

2 participants