Skip to content

fix(pr-management-stats): correct contributor timeline engagement - #2016

Merged
potiuk merged 2 commits into
apache:mainfrom
MakerFlyFly:fix/pr-stats-contributor-engagement-upstream
Nov 9, 2026
Merged

potiuk merged 2 commits into
apache:mainfrom
MakerFlyFly:fix/pr-stats-contributor-engagement-upstream

Conversation

@MakerFlyFly

@MakerFlyFly MakerFlyFly commented Nov 6, 2026 •

Copy link
Copy Markdown
Contributor

Summary

  • Keep contributor PRs in the untriaged backlog when their only engagement is their author's own label or draft-state event.
  • Limit the filter to LabeledEvent, ReadyForReviewEvent, and ConvertToDraftEvent; preserve collaborator activity, closure actors, ready-label behavior, and label timestamps.
  • Make the reduced closed-PR fixture retain an explicitly supplied timeline and verify the dashboard metrics and written JSON sidecars. Include the identical generated dependency copy required by the plugin packaging hook.

Type of change

  • Python package (tools/pr-management/)

Test plan

  • On original upstream b6ccd434, six contributor regression cases fail and the other 30 targeted cases pass.
  • With the fix, all 116 stats tests pass.
  • Full affected package: 795 tests and 15 subtests pass on Linux with Python 3.12.12.
  • Full-package Ruff, format check, and Mypy pass.
  • The four changed file blobs match the contributor-reviewed final patch.
  • prek run --all-files --skip workspace-pytest passes, including lychee and the generated-plugin check.
  • Scoped workspace pytest passes for both affected members: tools/pr-management has 795 passed and 15 subtests; plugins has 114 passed and one container-permission probe skipped. Commit hooks were not bypassed.
  • Magpie pre-first-PR: ready, zero blocking and advisory findings.

RFC-AI-0004 compliance

This corrects deterministic classification without adding fetched fields, configuration, dependencies, or service access.

Linked issues

Closes #2015.

Notes for reviewers

The PR is one commit based on upstream main@b6ccd434.
The four reviewed source/test blobs are unchanged; a fifth file is the generated magpie-security-tools copy of the classifier, byte-for-byte identical to the reviewed source.
A currently draft PR remains outside the untriaged non-draft counts.

The label case is defensive input coverage; ordinary external authors need repository triage permission to apply labels.
Closed-PR assertions deliberately retain legacy behavior within this repair's scope; they do not endorse contributor self-closure as maintainer engagement.
Strict actor authorization and comment/review engagement policy remain unchanged.

Suggested labels: bug, family:pr-management, family:tools, capability:stats, capability:fix, substrate:analytics.

Was generative AI tooling used to co-author this PR?

  • Yes — OpenAI Codex (GPT-6) assisted with implementation, tests, and drafting.
  • The contributor reviewed the final implementation before upstream submission.
  • The commit carries Generated-by: Codex (GPT-6).

Do not treat contributors' own label and draft-state events as maintainer
engagement. Keep collaborator activity and closure signals unchanged so
existing coverage and ready-label metrics retain their behavior.

Cover the backlog counts, recommendations, closed-query shape, and written
JSON sidecars with regression tests.

Keep the generated magpie-security-tools dependency copy in sync.

Generated-by: Codex (GPT-6)

@Kaap10 Kaap10 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

LGTM! Thank you for the clean fix and thorough test coverage.

  • Accurately addresses #2015 by ensuring contributor self-events (ReadyForReviewEvent, ConvertToDraftEvent, LabeledEvent) do not falsely trigger maintainer engagement.
  • Safely handles casing discrepancies and deleted user accounts with (author or "").lower().
  • Preserves maintainer actions on contributor PRs and collaborator self-events.
  • Full test suite passes cleanly with parity across both tool locations.

- reference.py (tool and plugin copy): name the open-PR timeline types
  AUTHOR_SELF_EVENT_TYPES next to OPEN_PRS_QUERY and use it in the
  engagement filter.
- test_engagement.py: take EVENT_TYPES from reference instead of
  re-declaring it.

Generated-by: Claude Opus 5

@potiuk potiuk left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Narrow, correct fix — a contributor's own ready-for-review, draft or label events no longer count as maintainer engagement, so their PRs stay in the untriaged backlog — with thorough regression tests and the plugin copy in sync. Rather than ask for another round over one small point, I pushed a fixup to your branch in ed03515:

  • tools/pr-management/src/pr_management/stats/reference.py (and the identical plugin copy): the event types the engagement filter excludes are now a named constant, AUTHOR_SELF_EVENT_TYPES, next to OPEN_PRS_QUERY, whose itemTypes list it mirrors — so a future change to the query and the filter are seen together.
  • tools/pr-management/tests/stats/test_engagement.py: EVENT_TYPES now comes from that constant instead of re-declaring the tuple.

Thanks for the careful fix!


This review was drafted by an AI-assisted tool and
confirmed by an Apache Magpie maintainer. The maintainer
approving this PR has read the findings and signed off. If
something feels off, please reply on the PR and a maintainer
will follow up.

More on how Apache Magpie handles maintainer review:
Contributing guide.

@potiuk
potiuk merged commit be594bb into apache:main Nov 9, 2026
11 of 13 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

family:tools tools/* substrate:analytics Tool substrate: read-only metrics / dashboards / renderers

Projects

None yet

Development

Successfully merging this pull request may close these issues.

pr-management stats counts contributor draft changes as engagement

3 participants