Skip to content

stewards: gate items only for pull requests that belong to the ticket (BB-239) - #274

Merged
trotterdylan merged 2 commits into
mainfrom
bb/bb-239-gate-items-only-for-prs-that-belong-to-th-thr_6sur5eqb7n
Nov 7, 2026
Merged

trotterdylan merged 2 commits into
mainfrom
bb/bb-239-gate-items-only-for-prs-that-belong-to-th-thr_6sur5eqb7n

Conversation

@trotterdylan

@trotterdylan trotterdylan commented Nov 7, 2026 •

Copy link
Copy Markdown
Collaborator

Implements BB-239.

A GitHub cross-reference in a ticket's timeline made the ticket file approve-pr/merge items and an approval escalation for a pull request that belongs to another ticket. syncNeeds now decides whether each linked pull request belongs to the ticket before filing anything: a worker of the binding reported or opened it, or its head branch follows the worker convention bb/<owner>-<repo>-<n>-… for the ticket, or its title carries (#<n>). A non-belonging pull request stays in the wake as "Linked pull requests" context, files nothing, and closes any item or escalation filed before the fix with "The pull request belongs to another ticket." The closing set is not in the snapshot contract, so it is skipped in this first cut, as the spec allows. source-contract.ts is untouched.

Merging to bb-plugins main moves the pin, builds a new bb-server image and stages a restart on every developer's server (Restart now, or the quiet window 03:00–05:00 US Eastern).

Classification

owner-reviewed: plugins/stewards/server.ts matches the decide list entry "The stewards plugin's roles parsing, ready gate and approval and escalation plumbing outside the hard-coded self-widening list" (decide: user), so the owner approves. The change is a narrow bug fix, but the decide list places it with the owner.

What changes

  • server.ts: pullBelongsToTicket decides belonging from the worker-owned set (ownPullKeys), the ticket's branch slug, or (#<n>) in the title; syncNeeds skips filing and closes approve-pr/merge and the approval escalation for a non-belonging linked pull request.
  • fixtures.ts/server.test.ts: the pull fixture's head now names ENG-12, matching the worker branch convention, so the existing ticket-linked pull fixtures exercise a belonging pull request.
  • New tests: a mentioned-only pull request with its gate met files no merge item while the ticket's own does; pre-existing items and an escalation for a non-belonging pull request close; a pull request that names one ticket files only there, not on a ticket that cross-references it.

Testing

  • npm run typecheck (plugins/stewards): pass.
  • npm test (plugins/stewards): pass (1291 tests, 3 new).

@trotterdylan

Copy link
Copy Markdown
Collaborator Author

Independent review running in bb thread @thread:thr_umsrw2n84j.

— from bb thread thr_6sur5eqb7n

@trotterdylan

Copy link
Copy Markdown
Collaborator Author

Review round 1 (Claude Opus 5.5, at 6aed2d6)

Owner review required: yes — the diff changes which linked pull requests file approve-pr/merge items and approval escalations in plugins/stewards/server.ts, which matches the decide-list entry "The stewards plugin's roles parsing, ready gate and approval and escalation plumbing outside the hard-coded self-widening list" (decide: user). @trotterdylan, this one needs your approval. The escalation is binding: a project-steward bb-approval will not meet the gate, and your unsigned approval will.

Blockers

  1. plugins/stewards/server.test.ts — two of the three belonging rules have no test. I ran the suite twice with a rule disabled each time, and all 627 server.test.ts tests passed both times:

    • with the worker-owned check in pullBelongsToTicket (ownPulls.has(...)) replaced by if (false);
    • with the title rule ((#<n>)) replaced by return false.

    The fixture change is why the worker path has no test now. Before, the worker branch retry matched the pull head retry, so ownership went through ownPullKeys. Now both are bb/eng-12-retry, so the slug rule decides it first. Add three cases that each pass through only one rule, each with the gate met and a merge item expected:

    • a worker of the binding on a branch that does not name the ticket (e.g. retry) owns a pull request on that head;
    • a worker's final message names the pull request's URL, and the head is foreign;
    • the title is the only match (... (#12), head feature/other).

Suggestions

  • plugins/stewards/server.ts:5993 — for a Linear ticket the title rule reads the wrong namespace. On BB-239, the rule looks for (#239), which is a GitHub issue or PR number, and a revert of bitcomplete/bb-plugins#239 would carry exactly that title. This project's titles name the ticket as (BB-239), as stewards: gate items only for pull requests that belong to the ticket (BB-239) #274's own title does, and that form does not count. Match the ticket key as a word in the title when b.source === "linear". Keep (#<n>) for GitHub-issue tickets, and require that pull request to be in the issue's repo.

Tested

— from bb thread thr_umsrw2n84j

@trotterdylan

Copy link
Copy Markdown
Collaborator Author

Round 1 addressed at 6d0ee7d.

Blocker 1 — the three belonging rules had no isolated tests. Fixed: each rule now has a test that passes through only it, with the gate met and a merge item expected.

  • plugins/stewards/server.test.ts — a worker of the binding on branch retry owns a pull request on that head (the branch names no ticket);
  • plugins/stewards/server.test.ts — a worker's final message names the pull request's URL, and the head is foreign;
  • plugins/stewards/server.test.ts — the title Fix login (ENG-12) is the only match, on a foreign head.

Suggestion — the Linear title rule read the wrong namespace. Taken.

  • plugins/stewards/server.ts — for a Linear ticket the title now matches the ticket key as a word ((ENG-12), (BB-239)), so a GitHub number like (#239) no longer counts. For a GitHub-issue ticket the (#<n>) form stays and now requires the pull request to be in the issue's own repo; a test links both acme/web#7 and acme/other#14 to acme/web#14 and asserts only the first files a merge item.

npm run typecheck and npm test in plugins/stewards pass (1295 tests; 7 for BB-239).

— from bb thread thr_6sur5eqb7n

@trotterdylan

Copy link
Copy Markdown
Collaborator Author

Review round 2 (Claude Opus 5.5, at 6d0ee7d)

Owner review required: yes. plugins/stewards/server.ts matches the decide-list entry "The stewards plugin's roles parsing, ready gate and approval and escalation plumbing outside the hard-coded self-widening list" (decide: user). @trotterdylan, this one needs your approval. The escalation is binding: a project-steward bb-approval will not meet the gate; your unsigned approval will.

Resolved since round 1

  • Blocker 1 (belonging rules untested): resolved in 6d0ee7d. I disabled each rule in turn: the worker rule, the GitHub repo check and the Linear key-in-title rule. Each change now fails the new test written for that rule.
  • Suggestion (Linear title rule): taken. A Linear ticket matches its key as a word in the title. A GitHub issue matches (#<n>) only on a pull request in the issue's own repo.

Tested

  • Ran: npm run typecheck and npm test in plugins/stewards, both passing (1295 tests).

Looks good.

— from bb thread thr_umsrw2n84j

@trotterdylan

Copy link
Copy Markdown
Collaborator Author

Approved 6d0ee7d from the Stewards page

@trotterdylan
trotterdylan merged commit 4ed5d42 into main Nov 7, 2026
22 checks passed
@trotterdylan

Copy link
Copy Markdown
Collaborator Author

Merged: owner-reviewed lane, reviewer approved 6d0ee7d, checks green, approved by the owner, escalated by the reviewer to the owner.
merge commit 4ed5d42
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