Skip to content

feat(enrichment): history analyzer — author track record, similar past PRs, linked-issue alignment #1478

Description

@JSONbored

Context

History analyzer for the review-enrichment service (REES). Depends on the scaffold. Surfaces public-safe historical context the engine deliberately doesn't compute: the engine's getSubmitterReputation is INTERNAL-only AI-spend routing and never surfaced, and linked-issue BODIES aren't fed to the model. This analyzer queries the GitHub API (using the short-lived request githubToken) for author track record in THIS repo, similar past PRs touching the same files, and whether the diff covers the linked issue's stated requirement.

Requirements

  • Use the optional short-lived githubToken from the request ONLY for GitHub fetches; hold in-memory for the request, NEVER log or cache it. If absent, degrade gracefully (still return a partial brief).
  • Author context (public-safe): prior merged/closed PR counts IN THIS repo via GitHub Search, account age, first-time-contributor flag, prior overlap with the changed area. Do NOT surface trust scores / reward values / internal reputation.
  • Similar past PRs: search closed PRs touching the same files → 'this area was previously changed in #N (merged/reverted)', surfacing revert/regression history.
  • Linked-issue alignment: fetch the linked issue title+body+acceptance-criteria (passed in the request envelope) → 'does the diff satisfy the stated requirement' context (diffCovers: full|partial|none).
  • Own sub-budget; GitHub rate-limit/error degrades independently (analyzerStatus.history:'degraded', partial:true).

Deliverables

  • review-enrichment/src/analyzers/history.ts: GitHub Search/API calls → history block { author:{priorMergedInRepo,priorClosedInRepo,accountAgeDays,firstTimeContributor}, similarPastPrs:[{number,title,outcome,overlapPaths}], linkedIssueAlignment:{issue,statedRequirement,diffCovers} }.
  • Register in brief.ts (gated by enrichment.analyzers), render in render.ts, add history to analyzerStatus.

Acceptance criteria

  • For a repeat contributor, prior merged/closed counts + account age + first-time flag are populated; for a first-timer the flag is set.
  • A PR touching a file previously reverted surfaces that past PR with outcome:'reverted'.
  • The linked-issue alignment reports full|partial|none; a PR with no linked issue omits the block.
  • Absent/expired githubToken or a rate-limit degrades the history analyzer only; the rest of the brief still ships. No trust/reward/internal-reputation value appears anywhere. Unit tests cover author context, similar-PR detection, alignment, and the no-token/degrade path. npm audit --audit-level=moderate clean.

Parent: #1029

Metadata

Metadata

Assignees

Labels

maintainer-onlyWork to be completed solely by jsonbored - yields no gittensor points.

Projects

Status
Todo

Relationships

None yet

Development

No branches or pull requests

Issue actions