Skip to content

stewards: a requested reviewer is the owner's delegation (BB-327) - #358

Merged
trotterdylan merged 3 commits into
mainfrom
bb/bb-327-requested-reviewer-is-a-delegation-on-own-thr_k53ww52id8
Nov 14, 2026
Merged

trotterdylan merged 3 commits into
mainfrom
bb/bb-327-requested-reviewer-is-a-delegation-on-own-thr_k53ww52id8

Conversation

@trotterdylan

Copy link
Copy Markdown
Collaborator

Implements BB-327. A requested reviewer on an owner-lane pull request is the owner's delegation: while they are outstanding the plugin files no approve-pr item and the lane waits on them, their APPROVED review meets the owner lane, and the viewer's own approval stays an override. A delegate who requested changes is re-solicited once per approved head.

Note: merging this moves the pin and stages a restart for every developer's server (Restart now, or in the 03:00–05:00 ET quiet window).

Sibling PR: #357 (this is stacked on bb/bb-325-…; the base PR is the scheduling answer).

Classification

owner-reviewed: gate.ts, approvals.ts and approvals-store.ts are the SELF_WIDENING_PATHS; the reviewer escalates with approver=owner.

What changes

  • gate.ts: delegateState reads the requested reviewers that are users other than the viewer and not bots, and each delegate's latest review. The gate is met by the viewer's unsigned approval or a delegate's APPROVED review; a delegate's later changes-requested revokes it. delegatePending makes needsOwnerApproval false while a delegate is outstanding, and missing names them (approval needed from arashout). The BB-279 base-change rule uses the delegate's approval time too. delegatesToReRequest offers a changes-requested delegate once the latest bb-review marker approves a new head with green checks.
  • approvals-store.ts: pull_requesters remembers every login seen in the request list per (binding, URL), so a delegate's approval still counts after GitHub drops them; reviewer_requests records each (binding, URL, login, head) re-request so a repeated look does not re-request.
  • approvals.ts: syncPullApproval remembers the live request list; while a delegate is outstanding it files no approve-pr need and keeps one escalation routed to the steward with a meanwhile naming the delegate; it re-requests a changes-requested delegate via the new GithubWriter.requestReviewers (gh pr edit --add-reviewer's API) and records it; the resolution and approvalRef name the delegate's review.
  • github.ts: requestReviewers (POST /pulls/{n}/requested_reviewers).
  • assessed-gate.ts / assessment.ts: thread the remembered requesters and re-request records into the stored assessment (BB-322), so every merge-gate surface reads the same delegate-aware gate and the fingerprint invalidates when either record changes.
  • server.ts: assessBinding reads the two records; bb stewards gate prints delegate-review … by <login> and the merge summary names the delegate.
  • store.ts: the two migration groups (append-only) and setEscalationMeanwhile.

A team request whose display name is a valid login shape is indistinguishable in the snapshot (github-watcher flattens Team { name } into requestedReviewers); membership lookup is out of scope, and the login-shape filter excludes the obvious team names. A team cannot submit a review, so it can never satisfy the gate.

Testing

  • cd bb-plugins/plugins/stewards && npm install --include=dev --legacy-peer-deps --no-audit --no-fund && npm run typecheck: pass.
  • npm test: pass (1815 tests; the full suite, not only the CI matrix). New coverage in gate.test.ts and approvals.test.ts for criteria 1–9: outstanding-delegate gate and missing, delegate approval and approvalRef, viewer override, changes-requested revocation, remembered-set approval, the once-per-head re-request and its record, bots/teams/viewer not counting, and the no-request lane unchanged.
  • read-counts.test.ts baseline updated 185 → 191 (two store reads per own pull for the two records), explained in the test.

@trotterdylan

Copy link
Copy Markdown
Collaborator Author

Independent review running in bb thread @thread:thr_858qjtmzkt.

— from bb thread thr_k53ww52id8

@trotterdylan
trotterdylan force-pushed the bb/bb-325-ended-binding-takes-no-new-writes-thr_vz27wus6md branch from 7747588 to c82bee0 Compare November 14, 2026 18:23
@trotterdylan

Copy link
Copy Markdown
Collaborator Author

Review round 1 (Claude Opus 5.5, at 0b85b73)

Owner review required: yes. This PR changes gate.ts, approvals.ts and approvals-store.ts, which are self-widening, so it is the owner's whatever the decide list says. It is also substantial (two new tables, plus an owner-reviewed trigger), and BB-327's binding records no spec approval (approval none), so the reason is also product. @trotterdylan, this one needs your approval. The escalation is binding: a project-steward bb-approval will not meet the gate. Your unsigned approval will.

Product

This adds a second approver to the owner lane: any user login that is or was a requested reviewer on the PR. That covers lanes where the reviewer set approver=owner and the product reason, as well as the plain decide-list owner lane. Nothing in the stewards plugin, its DESIGN.md or its skills already lets anyone other than the viewer meet the owner lane, so this does not overlap an existing feature. Its scope matches the ticket. One thing to decide knowingly: the plugin cannot tell who made a request. A request added by any thread posting as you (a worker or steward running gh pr edit --add-reviewer) delegates your approval the same way your own request does.

Blockers

  1. gate.ts:258 (isUserLogin): criterion 8 fails for this org's teams. github-watcher flattens a Team request to its name (github-watcher/github.ts:398). Every bitcomplete team name is login-shaped: bitcomplete, krftwrk, client-proto-lab, and so on. So a team-only request becomes an outstanding "delegate" that can never review. The approve-pr item is never filed, and the PR waits forever on "approval needed from bitcomplete". The test only covers "Platform Team". The query already selects __typename. Have the watcher emit a team as something isUserLogin rejects, for example ... on Team { combinedSlug }, which gives org/slug. Then add a test with a single-word team name.
  2. gate.ts:303-320: a COMMENTED review after an APPROVED one drops the approval. The snapshot is built from reviews(last: 50), and delegateState reads each delegate's latest review of any state. Replying to a review thread on GitHub creates a COMMENTED review, so a delegate who approves and then answers an inline comment loses the approval and becomes outstanding again. GitHub itself keeps the approval in that case (latestOpinionatedReviews). Pick the latest review whose state is approved, changes requested or dismissed, and ignore commented. Add a test for approve-then-comment.
  3. gate.ts:611: one delegate's approval merges over another delegate's "changes requested". approved = owner.approved || delegate.approval !== null takes the newest delegate approval and ignores changesRequested. If you request reviews from A and B, A approves and B requests changes, the gate is met and the plugin merges. The rule asks for latest-wins per delegate, so B's open "changes requested" should hold the lane. The viewer's own approval stays the override. Fix: count a delegate approval only when changesRequested is empty, and add a test.
  4. approvals.ts:432-447: criterion 2's "the binding's status reads blocked" is not met, and the new escalation is decidable by the wrong party.
    • The sidebar reads blocked only for a hold or an open stuck escalation (sidebar.ts:278, server.ts:9761). A route-steward approval escalation is neither, so the row reads quiet or running.
    • Route steward lists it in the ticket steward's wake as "(approval, with you): Approve …". Resolving an approve-decline approval escalation with any non-approving words takes the isDecline path (server.ts:12193). That path posts a declined bb-approval marker on the PR, delivers a decline to the parked worker and records declinedPrHeadSha. That is a PR approval decision this binding's steward has never been given.
    • Fix: make the wait undecidable by the steward (refuse resolve on it, or don't use an approve-decline escalation for it), and make the row read blocked on the delegate, for example "waiting on arashout's review". Criterion 10's status line follows from the same change; today only the wake's missing names the delegate. Add tests for both.
  5. approvals-store.ts:160 / gate.ts:276-279: a withdrawn request still counts as a delegate's approval. The ticket says "the owner ends a delegation by removing the login from the request list while they have no submitted review". Here the remembered row stays, so if that person later submits an APPROVED review anyway, delegateState finds them in the remembered set and the gate is met. Fix: when syncPullApproval sees a remembered login that is no longer live and has no review, forget it. A delegate who submits has a review by the time GitHub drops them, so they are never forgotten that way. Add a test.
  6. server.ts:9320: the merge comment credits the owner for a delegate's approval. When reason === "product" (or escalated) and a delegate approved, mergeSummary prints "approved by the requested reviewer X, the owner acked the product" (or "escalated by the reviewer to the owner"). The owner did neither. Say who acked from ownerApproved vs delegateApproved.

Tested

— from bb thread thr_858qjtmzkt

@trotterdylan
trotterdylan force-pushed the bb/bb-327-requested-reviewer-is-a-delegation-on-own-thr_k53ww52id8 branch from 0b85b73 to 0931fe0 Compare November 14, 2026 18:44
@trotterdylan
trotterdylan changed the base branch from bb/bb-325-ended-binding-takes-no-new-writes-thr_vz27wus6md to main November 14, 2026 18:44
@trotterdylan

Copy link
Copy Markdown
Collaborator Author

Round 1 addressed at 0931fe0 (rebased onto main now that #357 merged; PR retargeted to main).

  1. Teams — fixed at the source: github-watcher/github.ts now emits ... on Team { combinedSlug } (org/slug) and parses it; isUserLogin rejects it, so a team is never a delegate. Updated the github-watcher tests and added a gate test with bitcomplete/backend.
  2. COMMENTED after APPROVED — delegateState now ignores commented reviews when picking a delegate's latest opinion, as GitHub's latestOpinionatedReviews does. Added an approve-then-comment test.
  3. Two delegates — a delegate approval now meets the lane only while no delegate has an open changes-requested; the viewer's approval is still the override. Added a test (A approves, B requests changes → not met).
  4. Blocked and not the steward's to decide — added isDelegateWait (an approval escalation routed to steward); the sidebar/board stuck set and the board's stuck list include it (the row reads blocked, Waiting on the requested reviewer: …), and steward_update { resolve } refuses it with "waits on the requested reviewer … do not resolve it". Added a server.test.ts test asserting stuck: true, needsUser: false, the refusal, and that the escalation stays open.
  5. Withdrawn request — syncPullApproval now forgets a remembered requester who is no longer live and has no review (forgetPullRequester); a delegate who has reviewed stays. Added tests for both.
  6. Merge comment — mergeSummary only adds the product/escalation clause when the owner approved; a delegate's approval is credited as "approved by the requested reviewer X", not the owner.

Tested after the rebase: plugins/stewards typecheck + full suite pass (1825 tests), and plugins/github-watcher typecheck + suite pass (106 tests). Note the PR now touches plugins/github-watcher as well as plugins/stewards (the team/combinedSlug contract fix); the steward has been told.

— from bb thread thr_k53ww52id8

@trotterdylan

Copy link
Copy Markdown
Collaborator Author

Review round 2 (Claude Opus 5.5, at 0931fe0)

Owner review required: yes. The PR edits self-widening files (gate.ts, approvals.ts, approvals-store.ts), and it is substantial (new tables) with no approved spec on BB-327, so the reason is also product. @trotterdylan, this one needs your approval. The escalation is binding: a project-steward bb-approval will not meet the gate. Your unsigned approval will. What you are approving is in round 1's Product section: any requested user reviewer, including one added by a thread posting as you, can now meet the owner lane, and that includes approver=owner and product PRs. The github-watcher change is a small contract change: a team in requestedReviewers now reads as org/slug instead of its display name.

Suggestions

  • approvals.ts:440: when the owner withdraws the request, the escalation moves back to them but keeps the delegate's meanwhile. The needsOwnerApproval branch reroutes the delegate wait to user, but it still reads "Waiting: approval from arashout (a requested reviewer), not the owner." Reset it to the owner text with setEscalationMeanwhile when rerouting.

Resolved since round 1

  • Blocker 1 (teams): resolved. github-watcher emits combinedSlug, and both suites test it.
  • Blocker 2 (comment after an approval): resolved. COMMENTED reviews are skipped, with a test.
  • Blocker 3 (one delegate merging over another's changes request): resolved. delegateApproved requires that no delegate has changes requested, with a test.
  • Blocker 4 (status, and the steward deciding the wait): resolved. isDelegateWait marks the row blocked in the sidebar and on the board, and steward_update refuses to resolve it. A server test covers both. No worker-raised escalation can be an approval routed to the steward, so the predicate catches only this wait.
  • Blocker 5 (withdrawn request): resolved. A requester the owner removed before they reviewed is forgotten, with tests.
  • Blocker 6 (merge comment): resolved.
  • The rebase onto main after stewards: an ended binding takes no new question, forward or report (BB-325) #357 merged changed only the context in assessed-gate.ts and assessment.ts.

Tested

  • Ran: in plugins/stewards and plugins/github-watcher at 0931fe0, npm install && npm run typecheck && npm test: typecheck passes in both; 1825 stewards tests and 106 github-watcher tests pass.

— from bb thread thr_858qjtmzkt

@trotterdylan

Copy link
Copy Markdown
Collaborator Author

Round 2 suggestion taken at 7bdfc7f: when a delegation ends and the wait moves back to the owner, syncPullApproval now resets the escalation's meanwhile to the owner text with setEscalationMeanwhile. Added an approvals test. Stewards suite: 1826 pass.

— from bb thread thr_k53ww52id8

@trotterdylan

Copy link
Copy Markdown
Collaborator Author

Approved 7bdfc7f from the Stewards page

@trotterdylan
trotterdylan merged commit d377a3e into main Nov 14, 2026
22 checks passed
@trotterdylan

Copy link
Copy Markdown
Collaborator Author

Merged: owner-reviewed lane, reviewer approved 0931fe0, checks green, approved by the owner, the owner acked the product.
since then: the head moved to 7bdfc7f
merge commit d377a3e
Note: merging this moves the pin and stages a restart for every developer's server (Restart now, or in the 03:00–05:00 ET quiet window).
dispatched bb-server.yaml on bitcomplete/bb-gate@main

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