Skip to content

stewards: lease only the linked pull requests still open (BB-4) - #24

Merged
trotterdylan merged 1 commit into
mainfrom
bb/bb-4-lease-only-open-linked-prs-thr_gjq9micxec
Oct 19, 2026
Merged

trotterdylan merged 1 commit into
mainfrom
bb/bb-4-lease-only-open-linked-prs-thr_gjq9micxec

Conversation

@trotterdylan

@trotterdylan trotterdylan commented Oct 19, 2026 •

Copy link
Copy Markdown
Collaborator

Implements BB-4. Before this change, a ticket binding leased every pull request in its linkedPulls until the ticket ended, so closed and merged PRs stayed watched. Now the github interest set leases only the linked PRs that are still open, based on the PR snapshots the binding already stores. It is pushed again when a reconcile changes which linked PRs are open.

Merging this moves the bb-plugins pin, which builds a new bb-server image and stages a restart for every developer's server. Each server restarts when its owner presses Restart now, or in the 03:00–05:00 US Eastern quiet window.

Classification

no-review: a narrow bug fix in a live plugin (stewards). The interest set is now what it was meant to be: leases for open PRs only. Nothing user-facing changes. The cross-repo contract (source-contract.ts) is untouched, and there is no migration, setting or dependency.

What changes

  • sendInterest (plugins/stewards/server.ts) used to lease every key in a ticket's lastSnapshot.entity.linkedPulls. It now goes through a new leasedPulls(b) helper. The helper drops a linked key when its snapshot in lastSnapshot.pulls is closed or merged, matching keys case-insensitively. A linked key with no snapshot yet (not read yet, a failed read, or past the five-PR read cap) stays leased. That way a new PR is watched before its first read, and a transient read failure doesn't drop a watch.
  • Re-push after reconcile. reconcileBinding is now a thin wrapper around the old body, renamed reconcileOnce. It compares the binding's leased PR keys before and after the reconcile and calls pushInterest() when they differ. This runs in a finally, so it also covers a reconcile that throws after patching lastSnapshot. Before this change, a reconcile that saw a linked PR change state never re-pushed the interest set. sendInterest already skips sending a body that hasn't changed.
  • PR bindings (source === "github") are unaffected.
  • source-contract.ts is not changed. All three copies are still byte-identical.

Testing

  • npm run typecheck && npm test in plugins/stewards: pass (7 files, 101 tests, including contract.test.ts; stewards is not in the CI matrix).
  • New tests in server.test.ts check two things. First, a ticket linked to an open, a closed, a merged and an unread PR leases only the open one and the unread one. Second, a linked PR that goes from open to merged is left out of the next github sourceSetInterest. Both fail against main. The second also fails with only the filter applied and no re-push.
  • npm test in plugins/linear: pass (6 files, 125 tests).
  • npm test in plugins/github-watcher: pass (5 files, 66 tests).
  • The three source-contract.ts copies are identical (cmp).

Out of scope per the spec: the extra line in bb github-watcher watches about stewards leases for PRs that are no longer open.

🤖 Generated with Claude Code

A ticket binding leased every pull request in its linkedPulls until the
ticket ended, so closed and merged slices stayed watched. The github
interest set now takes a ticket's linked pull requests from the stored
snapshots in lastSnapshot.pulls and leaves out the closed and merged
ones; a linked key with no snapshot yet is kept. A reconcile that
changes which linked pull requests are leased pushes the interest set
again. source-contract.ts is unchanged.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
@trotterdylan

trotterdylan commented Oct 19, 2026 •

Copy link
Copy Markdown
Collaborator Author

Independent review running in bb thread @thread:thr_r29k4c2t7g.

— from bb thread thr_gjq9micxec

@trotterdylan

Copy link
Copy Markdown
Collaborator Author

Review round 1 (GLM 5.3, at efa394f)

Owner review required: no — none of the owner-reviewed triggers apply. A narrow bug fix in a live plugin's lease logic: the github interest set becomes what it was meant to be (open linked PRs only). source-contract.ts is untouched (all three copies verified byte-identical), no store migration, no settings or dependency change, nothing user-facing.

Suggestions

  • Reopen gap (inherent to the ticket, not a defect): once a linked PR is observed closed, its lease is dropped, so github-watcher no longer rings a doorbell for it. If that PR is later reopened, the ticket binding is not re-leased for it until the next reconcile from another trigger (a linear doorbell on the ticket, the nightly pass). The system self-heals on any ticket reconcile since lastSnapshot.pulls is re-read each time, but the delay could be hours. A future tweak could keep closed-but-not-merged PRs leased (merged PRs can never reopen), if the extra doorbells ever matter.
  • Beyond the 5-PR read cap: linkedPulls() reads at most 5 unique linked PRs per reconcile, so keys 6+ never have a snapshot and are always leased. Consistent with criterion 2 and pre-existing cap behaviour, just worth knowing.
  • leasedPulls(before).join(" ") string comparison is order-sensitive: a reorder of linkedPulls with the same set triggers a spurious pushInterest(). Harmless (sendInterest dedupes on the sorted body), no action needed.

Checked

  • Ran: npm install && npm run typecheck && npm test in plugins/stewards (7 files, 101 tests, pass — stewards is not in the CI matrix, I ran it), plugins/linear (6 files, 125 tests, pass — also not in the matrix), plugins/github-watcher (5 files, 66 tests, pass). cmp confirms the three source-contract.ts copies are identical.
  • Verified both new tests fail against main's server.ts (ran vitest with the head's test file against main's implementation): 2 failed as expected, confirming they exercise the new behaviour.
  • Verified against ticket:
    • AC1: met — ticket with open/closed/merged/unread linked PRs leases only the open and unread ones (leasedPulls filters snapshots with state closed/merged, case-insensitive; PR states from github-watcher are exactly open/open (draft)/closed/merged, so drafts are correctly kept).
    • AC2: met — a key with no snapshot (null from sourceSnapshot or a failed read) stays leased.
    • AC3: met — reconcileBinding compares leased keys before/after (including in a finally, covering a reconcile that throws after patching lastSnapshot) and re-pushes; all three reconcile callsites run under serial("b:<id>") so the before/after reads are race-free.
    • AC4: met — PR bindings' entities come from the untouched open.filter(b => b.source === "github") path; leasedPulls returns [] for non-ticket kinds.
    • AC5: met — new tests in server.test.ts cover 1–3; stewards, linear and github-watcher suites including contract.test.ts all pass.

— from bb thread thr_r29k4c2t7g

@trotterdylan

Copy link
Copy Markdown
Collaborator Author

Round 1 suggestions:

  • Reopen gap: declined. The spec drops both closed and merged PRs on purpose. Any reconcile of the ticket re-reads lastSnapshot.pulls, and that includes a Linear doorbell, adding the label, or the nightly pass. A reopened PR is leased again then. Keeping closed PRs leased would bring back the leases this ticket removes. If reopen latency ever matters, it can be a separate tweak.
  • Beyond the 5-PR read cap: declined. Keys past the cap have no snapshot, so they stay leased, as criterion 2 requires. The cap was already there before this PR.
  • Order-sensitive join comparison: declined. A reordered linkedPulls with the same set only causes a debounced pushInterest(), and sendInterest skips it because the sorted body hasn't changed.

No code changed. The merge gate is met at efa394f.

— from bb thread thr_gjq9micxec

@trotterdylan
trotterdylan merged commit b0f988d into main Oct 19, 2026
16 checks passed
@trotterdylan

Copy link
Copy Markdown
Collaborator Author

Merged: no-review lane, reviewer approved efa394f, checks green. A person merged this by hand as b0f988d. Watching the bb-server build next.

— from bb thread thr_gjq9micxec

trotterdylan added a commit that referenced this pull request Nov 10, 2026
…310)

Implements [BB-278](https://linear.app/bit-complete/issue/BB-278/bb-plugins-npm-batched-mediumlow-dependabot-alerts). `plugins/review-watch/package-lock.json` is regenerated so the tree resolves:

| package | from | to | advisory |
|---|---|---|---|
| `@vitest/mocker` | 4.1.11 | 4.1.12 | [GHSA-qxg6-89mg-rqv8](https://github.com/bitcomplete/bb-plugins/security/dependabot/24) (#24), [GHSA-xp26-3454-mjgp](https://github.com/bitcomplete/bb-plugins/security/dependabot/23) (#23) |
| `hono` | 4.13.8 | 4.13.17 | [GHSA-5r4p-p66f-jhc7](https://github.com/bitcomplete/bb-plugins/security/dependabot/16) (#16) |

`@vitest/mocker` is transitive via `vitest` (whose range `^4.1.11` already allowed 4.1.12), so `vitest` moves 4.1.11 → 4.1.12 and its `@vitest/*` subtree with it (`@vitest/expect`, `@vitest/pretty-format`, `@vitest/runner`, `@vitest/snapshot`, `@vitest/spy`, `@vitest/utils`, plus `chai`, `tinyrainbow` and `@types/estree`). `hono` is a direct devDependency whose range `^4.11.9` already allowed 4.13.17. No `package.json` change was needed (no override). `vite` is unchanged at 8.3.7, already past the 8.3.3 fixed version for the alerts already trimmed from the ticket.

> **Restart note:** this merge to `bb-plugins` `main` moves the pin, builds a new `bb-server` image and stages a restart on every developer's server (at *Restart now*, or in the 03:00–05:00 ET quiet window).

## Classification
no-review: lockfile-only patch security bumps in `review-watch`, a plugin that is not deployed. No behaviour, default, contract or existing feature changes; no owner-reviewed trigger is touched.

## What changes
- `plugins/review-watch/package-lock.json` only. `package.json` is unchanged.

## Testing
- `npm install --include=dev --legacy-peer-deps` in `plugins/review-watch`: clean, lockfile unchanged.
- `npm update vitest hono` in `plugins/review-watch`: lockfile only (12 packages moved, all within existing ranges).
- `npm ls @vitest/mocker hono`: `@vitest/mocker@4.1.12` (via `vitest@4.1.12`) and `hono@4.13.17` only; `npm ls vite`: `vite@8.3.7` only.
- `npm run typecheck` in `plugins/review-watch`: pass.
- `npm test` in `plugins/review-watch`: pass (10 files, 118 tests).
- `review-watch` is in the CI matrix (`.github/workflows/plugins.yaml`), so CI runs it too.
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