Skip to content

feat(bitbucket): wire DX Core 4 'code review pickup time' signals#57

Merged
trick77 merged 2 commits into
masterfrom
feat/dx-pickup-time-reviewer-events
May 17, 2026
Merged

feat(bitbucket): wire DX Core 4 'code review pickup time' signals#57
trick77 merged 2 commits into
masterfrom
feat/dx-pickup-time-reviewer-events

Conversation

@trick77
Copy link
Copy Markdown
Owner

@trick77 trick77 commented May 17, 2026

Summary

The README cited DX Core 4 'code review pickup time' as derivable, but the inputs were incomplete:

  • Only `pr:comment:added` was subscribed → silent approvals and `needs_work` flips never showed up; noergler's instant comment drove every PR's pickup time toward 0.
  • For reviewer-activity events the parser used `pullRequest.author` (the opener) as `author`, so the `author != pr_opener` filter could never fire.

This PR:

  1. Adds `pr:reviewer:approved`, `pr:reviewer:needs_work`, `pr:reviewer:updated` to the Bitbucket onboarding event list.
  2. Parser change: for comment + reviewer:* events the row's `author` is the actor (the reviewer), not `pullRequest.author`. PR-lifecycle events keep existing semantics.
  3. Adds `noergler` to the example `automation` config so its review comments get `is_automated=true` and drop out of the metric. README explicitly notes that every review-time bot needs its handle in the config.
  4. README query for "Time to first review" updated to the DX-canonical `MIN(occurred_at) WHERE event_type IN (…four events…) AND author != pr_opener AND NOT is_automated` form.

Test plan

  • `pytest` — 195 passed (4 new tests: actor-as-author for reviewer:approved, comment:added, regression guard pr:merged keeps PR opener, noergler detection picks up config entry)
  • `ruff check` + `ruff format --check` — clean
  • `pyright src` — 0 errors
  • After merge: re-run `bitbucket_onboarding.py` on a test repo, confirm Bitbucket fires the three new events when a reviewer approves/requests changes/updates status

trick77 added 2 commits May 17, 2026 11:59
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 []).
@trick77 trick77 merged commit 536186e into master May 17, 2026
2 checks passed
@trick77 trick77 deleted the feat/dx-pickup-time-reviewer-events branch May 17, 2026 10:04
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.

1 participant