Skip to content

[Bug] issues.solved_by_pr can become stale when PR closing references change after merge #59

@jonathanchang31

Description

@jonathanchang31

Summary

issues.solved_by_pr can remain stale when a PR’s closing references change after initial merge-time linkage.

Problem

In FetchProcessor.handlePrMetadata():

  • when PR is MERGED, it sets solved_by_pr = prNumber for all current closingIssueNumbers
  • but there is no cleanup path for previously linked issues if:
    • PR linkage changes on later edited events (close keywords removed/changed),
    • PR is reopened / transitions away from merged semantics,
    • solving relationship should move to another PR

IssueHandler only clears solved_by_pr when an issue is reopened (state = OPEN), which does not address stale closed issues.

Expected behavior

solved_by_pr should reflect current canonical solver linkage:

  • remove stale mappings when PR no longer closes an issue
  • avoid leaving closed issues permanently linked to outdated PRs

Actual behavior

solved_by_pr is write-only on merge linkage and can become stale indefinitely.

Why this matters

Downstream scoring APIs use solved_by_pr/solving_pr to attribute issue-solving credit. Stale links can misattribute rewards and produce inconsistent validator/miner views.

Reproduction idea

  1. Create PR A with Fixes #123, merge it.
  2. Metadata job sets issue #123.solved_by_pr = A.
  3. Edit PR A body to remove/alter closing reference (or otherwise make linkage stale).
  4. Trigger pull_request.edited metadata refresh.
  5. Observe closingIssueNumbers on PR changes, but issues.solved_by_pr remains pointing to A.

Inspection points

  • packages/das/src/queue/fetch.processor.ts (handlePrMetadata)
  • packages/das/src/webhook/handlers/issue.handler.ts (only clears on OPEN issues)
  • packages/das/src/api/miners/miners.service.ts (solving_pr resolution from issues.solved_by_pr)

Suggested fix direction

On each PR metadata refresh:

  1. read prior linked issue set for that PR
  2. compute diff against new closingIssueNumbers
  3. for removed links currently pointing to this PR, clear solved_by_pr
  4. for added/current links, set solved_by_pr = prNumber when PR is merged

Optionally enforce stronger invariants with periodic reconciliation/backfill.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions