Skip to content

feat(issue-discovery): precise post-merge edit detection upgrade#434

Merged
anderdc merged 6 commits intoentrius:testfrom
corevibe555:feature/issue-402-post-merge-edit-detection
Apr 16, 2026
Merged

feat(issue-discovery): precise post-merge edit detection upgrade#434
anderdc merged 6 commits intoentrius:testfrom
corevibe555:feature/issue-402-post-merge-edit-detection

Conversation

@corevibe555
Copy link
Copy Markdown
Contributor

@corevibe555 corevibe555 commented Apr 15, 2026

Closes #402

Summary

Replaces the issue.updated_at anti-gaming logic in issue discovery scoring with precise timeline-based detection for body and title edits only. The old check false-positived on any activity (bot comments, label changes, reactions, stale-bots), silently demoting legitimate solved issues to closed_count and unfairly cutting miner credibility in active repos.

Body edit and title edit both should be checked.
This is because title and body are connected.
If title change allowed, it's possible to confuse the reviewer by changing title.
From the purpose of this feature from doc: https://docs.gittensor.io/issue-discovery.html, title is important to define scope, it's possible to inflate by just changing title.

Related Issues

Closes #402

Type of Change

  • New feature / enhancement (anti-gaming precision upgrade)
  • Bug fix
  • Refactor
  • Documentation
  • Other

Testing

Added: tests/validator/test_issue_discovery_post_merge_edit.py — 3 cases:

  1. Benign updated_at bump after merge (bot activity) → issue stays solved.
  2. Real body edit after merge → issue demoted to closed, no score.
  3. Body edit before merge → ignored, stays solved.

Results: 3/3 new tests pass. Broader existing suite (66 validator tests) still green. Pre-existing tree_sitter import errors in unrelated test modules are not affected by this change.

Manual testing

  1. Create an issue on open source repo. in my case, created one issue here: https://github.com/corevibe555/corevibe555/issues
  2. Create a new branch and create PR, mention "Closes rehaul weights #3" in PR description, merge PR
  3. If you go to issues list, the issue is closed.
  4. The best way to see updated_at is changed is adding a comment, so please add a new comment to that closed issue rehaul weights #3, see the screenshot.
  5. Change title case, attached screenshot
  6. Change body case, attached screenshot

Before adding comment
graphql-before-add-comment-to-closed-issue

After adding commment
graphql-after-add-comment-to-closed-issue

After changing title
graphql-after-title-change

After chaing body
graphql-after-body-change

Checklist

  • Code follows project style
  • Self-review completed (follow-up noted: body_or_title_edited_at is not persisted to DB — fine today since scoring re-fetches from GraphQL each run, but worth revisiting if any code path reconstructs Issue from storage)
  • Comments explain non-obvious why, not what
  • New tests added and passing
  • No schema/migration changes required (updated_at column preserved)
  • Documentation update pending — issue_discovery/issue-discovery-rewards.md still describes the updated_at proxy as current behavior; should be updated in a follow-up doc PR or this one if preferred

@corevibe555 corevibe555 force-pushed the feature/issue-402-post-merge-edit-detection branch from 7a98b6a to 4adaf12 Compare April 15, 2026 01:12
@corevibe555 corevibe555 changed the title [WIP] feat(issue-discovery): precise post-merge edit detection (#402) feat(issue-discovery): precise post-merge edit detection (#402) Apr 15, 2026
authorAssociation
userContentEdits(last: 1) {
nodes { editedAt }
}
Copy link
Copy Markdown
Contributor Author

@corevibe555 corevibe555 Apr 15, 2026

Choose a reason for hiding this comment

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

To get last body edit, first:1 will return newest edit time, proved by manual testing

nodes {
... on RenamedTitleEvent { createdAt }
}
}
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

To get last title edit time of the issue.

@corevibe555 corevibe555 force-pushed the feature/issue-402-post-merge-edit-detection branch 2 times, most recently from 5ac412c to a4af442 Compare April 15, 2026 01:52
@corevibe555 corevibe555 changed the title feat(issue-discovery): precise post-merge edit detection (#402) feat(issue-discovery): precise post-merge edit detection upgrade Apr 15, 2026
@corevibe555
Copy link
Copy Markdown
Contributor Author

@anderdc Would you review this PR?
This is critical feature enhancement.

@anderdc anderdc closed this Apr 15, 2026
@anderdc anderdc reopened this Apr 15, 2026
Copy link
Copy Markdown
Collaborator

@anderdc anderdc left a comment

Choose a reason for hiding this comment

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

A couple things to address:

Delete the spec file

issue_discovery/issue-discovery-rewards.md is a planning doc that was used to guide implementation. It shouldn't live in the repo long-term. Please delete it in this PR or a follow-up.

Clean up the tests

The tests cover the right scenarios but need some cleanup:

  • _make_issue has datetime = None defaults — these should be Optional[datetime] = None
  • Lazy import of _DiscovererData inside _run() — no reason for this in a test file, just import at the top
  • _merged_at() is a function returning a constant — just make it a module-level constant
  • Make sure the tests are actually exercising the new code path — right now they test _collect_issues_from_prs (a private function) directly. That's fine for now, but double check the assertions are meaningful and not just passing because of default values or skipped branches

@anderdc
Copy link
Copy Markdown
Collaborator

anderdc commented Apr 15, 2026

failing ci

@corevibe555 corevibe555 force-pushed the feature/issue-402-post-merge-edit-detection branch 2 times, most recently from 01614b9 to f5c2e94 Compare April 15, 2026 22:41
@corevibe555 corevibe555 requested a review from anderdc April 15, 2026 22:52
@corevibe555
Copy link
Copy Markdown
Contributor Author

@anderdc Updated the PR. Would you review again? Thanks

corevibe555 and others added 6 commits April 16, 2026 04:39
Replace the noisy updated_at proxy with timeline-based detection for
body and title edits only. updated_at fires on any activity (bot
comments, labels, reactions), silently demoting legitimate solved
issues to closed_count in active repos.

- GraphQL: fetch userContentEdits + RenamedTitleEvent alongside
  existing closingIssuesReferences (no extra round trip)
- Issue.body_or_title_edited_at: max(last body edit, last rename)
- scoring.py: anti-gaming check now uses body_or_title_edited_at
- Tests: benign updated_at bump ignored, real body edit demotes,
  pre-merge edits ignored

fix

fix

fix

fix
userContentEdits is reverse-chronological on GitHub, so last:1 returned
the oldest body edit and the check never fired on subsequent edits.
first:1 returns the newest. timelineItems is chronological, so last:1
stays correct for title renames.
- Optional[datetime] on _make_issue defaults (fixes pyright)
- Hoist _DiscovererData / defaultdict imports to module level
- Replace _merged_at() function with MERGED_AT constant
- Delete issue_discovery/issue-discovery-rewards.md planning doc
@corevibe555 corevibe555 force-pushed the feature/issue-402-post-merge-edit-detection branch from bd162f0 to f297b9d Compare April 16, 2026 01:39
Copy link
Copy Markdown
Collaborator

@anderdc anderdc left a comment

Choose a reason for hiding this comment

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

Solid upgrade. The updated_at proxy was a known false-positive source (bot comments, labels, reactions demoting legitimate solved issues). The timeline-based approach is precise and well-tested.

  • GraphQL pagination is correct: first:1 for reverse-chronological userContentEdits, last:1 for chronological timelineItems
  • Null handling is robust throughout the parsing chain
  • Tests cover the three key cases: benign activity ignored, real post-merge edit caught, pre-merge edit ignored
  • CI green: pyright, ruff, tests all pass

@anderdc anderdc merged commit 07b0cb4 into entrius:test Apr 16, 2026
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Feature] Post-merge edit detection upgrade

2 participants