Skip to content

feat(enrichment): flag PRs significantly behind the default branch#2725

Closed
jaso0n0818 wants to merge 1 commit into
JSONbored:mainfrom
jaso0n0818:feat/stale-branch-signal
Closed

feat(enrichment): flag PRs significantly behind the default branch#2725
jaso0n0818 wants to merge 1 commit into
JSONbored:mainfrom
jaso0n0818:feat/stale-branch-signal

Conversation

@jaso0n0818

Copy link
Copy Markdown
Contributor

What

A new local REES analyzer, staleBranch, that flags a PR whose head is significantly behind the repo's current
default branch — a staleness risk GitHub's own PR page doesn't summarize as a number (it only shows an
"out-of-date" badge, not how far).

Detection (structured GitHub repo + compare API fields only — a bounded, documented schema)

  • Fetches the repo's current default_branch, then compares it against the PR's head via the GitHub compare API.
  • Flags when behind_by >= 100 commits.

Why it is bounded / merge-safe

It reads only documented fields from the GitHub repo API (default_branch) and the compare API (behind_by) and
compares a single number against a fixed threshold — never diff, commit, or file content. There is no
text/YAML/code parsing, so there are no ambiguous-syntax edge cases. Fail-safe throughout: a missing token,
missing head SHA, malformed repo slug, a missing/non-numeric behind_by, or either fetch failing all yield no
finding rather than an error (the repo-info fetch failing short-circuits before ever calling compare). Mirrors
the existing blame-link / approval-integrity / ci-check-signals analyzers' structure (same header/fetch
helper shape, same ScanOptions/fail-safe conventions, a pure reducer separated from the network entrypoint).

Value

A branch far behind the current default branch is more likely to hide a subtle semantic conflict that a clean
mergeable check alone would miss — the merge itself can be mechanically clean while the combined result is
still wrong. Surfacing how far behind (not just "out of date") gives a reviewer a concrete signal for whether a
rebase is worth requesting before merge.

Tests

review-enrichment/test/stale-branch.test.ts covers: the pure evaluateStaleBranch reduction (the threshold's
boundary in both directions, the identical/ahead cases, and fail-closed on a missing/non-numeric/negative
behind_by), plus the network entrypoint's fail-safe paths (no token, no head SHA, malformed repo slug, the
repo-info fetch failing without ever calling compare, a repo response missing default_branch, the compare fetch
failing) and the exact two-request URL shape. Analyzer metadata is regenerated and committed.

No linked issue

No linked issue because this is a net-new analyzer; there is no tracking issue to link.

@loopover-orb

loopover-orb Bot commented Jul 3, 2026

Copy link
Copy Markdown
Contributor

Important

🟪🟪🟪🟪🟪🟪🟪🟪🟪🟪🟪🟪

🔍 Gittensory is reviewing…

AI analysis is in progress. This comment will update when the review is complete.

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

@loopover-orb loopover-orb Bot added gittensor gittensor:feature Gittensor-scored feature linked to a feature issue — scores a 0.25x multiplier. labels Jul 3, 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.

Not something we need, closing.

@JSONbored JSONbored closed this Jul 3, 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.

2 participants