feat(bitbucket): wire DX Core 4 'code review pickup time' signals#57
Merged
Conversation
The README cites DX Core 4 'code review pickup time' as a derivable metric but the inputs weren't all present: - Only `pr:comment:added` was subscribed. DX defines pickup as the first ANY reviewer action — silent approvals and `needs_work` flips never showed up, and the bot comment noergler posts seconds after pr:opened would have driven every PR's pickup-time to ~0. - For reviewer-activity events the parser was filling `author` from `pullRequest.author` (the PR opener) instead of `actor` (the reviewer). That meant the `author != pr_opener` filter couldn't ever fire. This PR: - Adds `pr:reviewer:approved`, `pr:reviewer:needs_work`, and `pr:reviewer:updated` to the Bitbucket onboarding event list. Together with the existing `pr:comment:added` they cover every reviewer action Bitbucket DC emits. - Teaches the parser that comment / reviewer events are reviewer-activity: it now picks `actor` (the human or bot performing the action) over `pullRequest.author` for those event types only. PR-lifecycle events (opened / merged / from_ref_updated / deleted) keep the existing PR author semantics; a regression test pins this. - Adds a `noergler` entry to the example automation config so `detect_automation_source` flags noergler's instant review comment as `is_automated=true`. The existing `NOT is_automated` filter in pickup-time queries then strips it. The README explicitly calls out that every review-time bot needs a matching automation entry. Tests cover: actor-as-author for `pr:reviewer:approved` and `pr:comment:added`, regression guard that `pr:merged` still attributes to the PR opener (not the merger), and that the config detection picks up the noergler entry.
- Subscribe pr:reviewer:unapproved and add it to the pickup-time query.
The parser already treated it as reviewer activity but the event was
never delivered (not in REQUIRED_WEBHOOK_EVENTS) and never queried, so
the parser branch was dead. A retracted approval is reviewer engagement
too — same actor-wins rule applies.
- New tests/fixtures/bitbucket_pr_comment_added.json so the comment-route
test doesn't reuse the reviewer:approved fixture with a swapped eventKey
(which left a stale REVIEWER 'participant' block in the payload).
- New test for pr:reviewer:unapproved (actor-as-author).
- New test for the edge case where pullRequest.author is an empty block:
the actor-wins path covers it cleanly, no None author.
branch_prefixes:[] vs missing key concern (raised in review) confirmed
to be semantically identical in config.py: tuple(cfg.get("branch_prefixes") or []).
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
The README cited DX Core 4 'code review pickup time' as derivable, but the inputs were incomplete:
This PR:
Test plan