Skip to content

stewards, github-watcher: a deployment source, and deployment-agnostic stewards (BB-53) - #79

Merged
trotterdylan merged 2 commits into
mainfrom
bb/bb-53-plugins-deployment-source-pr-b-thr_q2e5u8k6dd
Oct 25, 2026
Merged

trotterdylan merged 2 commits into
mainfrom
bb/bb-53-plugins-deployment-source-pr-b-thr_q2e5u8k6dd

Conversation

@trotterdylan

Copy link
Copy Markdown
Collaborator

Implements BB-53. Deployment is a steward source like Linear and GitHub: a project's playbook names the GitHub Deployments target that confirms a merge is live, a deployment doorbell wakes the bindings awaiting it, and the steward decides from the playbook's rule whether the deployment carries the merge. This is PR (b), the plugin side, on top of the merged bb-gate#36 contract.

Every merge to bb-plugins main moves the pin, builds a bb-server image and stages a restart on every developer's server. The image picks this up when the bb-gate bb-server workflow re-pins main and builds; servers restart at Restart now or in the 03:00–05:00 ET quiet window.

Classification

owner-reviewed: A cross-repo contract other repos implement — source-contract.ts and its three byte-identical copies change together (stewardsRing gains the optional deployment object; sourceSetInterest gains deployment repos), and bb-gate/docs/hooks.md is the other side of it.

What changes

  • source-contract.ts (github-watcher, linear, stewards; byte-identical). A deploymentSchema for the doorbell's deployment object; sourceSetInterest.input.deployment names the repos to lease as deployment_repo; stewardsRing.input.deployment carries the object on a deployment doorbell.
  • github-watcher. Leases deployment-target repos as deployment_repo, rings stewards with the deployment object on a deployment doorbell, and reports refusals in bb github-watcher watches (a missing deployments:read is a skip, not an error).
  • stewards, deployment-agnostic. The playbook gains an optional deployment block: source, repo, environment, carries (the steward's rule, free text) and timeout (6h default). A merged pull request is recorded as awaiting deployment (merged); a doorbell for the target moves it to deploying and wakes the binding with the deployment (repo, environment, id, ref, sha, state, URL) and the rule. The steward reports the verdict with steward_report { deployment: { state: "deployed" | "not-yet" | "failed" } }; a failure/error doorbell or the timeout wakes it with the run URL. Once every pull request is deployed the steward is woken for the one closing comment. A terminal pull-request binding is held open while a deployment is outstanding. The plugin never decides carries and never polls GitHub or the cluster; the timeout rides the existing requeue/sweep.
  • bb stewards show prints each pull request's deployment state: merged / deploying / deployed / failed.
  • Docs. README.md, DESIGN.md §14 and the stewards skill document the new playbook fields.
  • Additive. With no deployment in the playbook, a project behaves exactly as today (empty watch map, no doorbell routing, no deployment section in the wake).

Testing

  • npm test in plugins/stewards: pass (485 tests; in the CI matrix).
  • npm test in plugins/github-watcher: pass (74 tests; in the CI matrix).
  • npm test in plugins/linear: pass (143 tests; not in the CI matrix).
  • npx tsc --noEmit in all three: clean.
  • plugins/stewards/deploy.test.ts: the pure recording/apply/timeout/report logic, 14 tests.
  • plugins/stewards/server.test.ts ("deployment watching (BB-53)"): a doorbell parsed and routed, a deployment that carries the merge (the wake carries the merged commit, ref, sha and the rule; the steward's report marks it deployed and wakes for the closing comment), one that does not yet, a failure status, the no-deployment timeout, two tickets released by one deployment, and a project with no deployment target.
  • plugins/github-watcher/server.test.ts: the deployment_repo lease, the deployment object handed on to stewards, and a refused lease logged as a skip.
  • Not tested: the end-to-end webhook path. The org webhook's Deployments/Deployment statuses events are set by hand by the owner, and no deployment doorbell arrives until that is done.

…c stewards (BB-53)

The github plugin leases a project's deployment-target repos as
deployment_repo and hands stewards each deployment doorbell's object. The
stewards plugin records a merged pull request as awaiting deployment when
its playbook names a target, wakes the binding on a doorbell, and lets the
steward decide from the playbook's rule whether it carries the merge; a
failure or a timeout wakes it with the run URL. Once every pull request is
merged and deployed the steward posts the one closing comment. A project
with no deployment target behaves exactly as before.
@trotterdylan

Copy link
Copy Markdown
Collaborator Author

Independent review running in bb thread @thread:thr_hd5i2upxav.

— from bb thread thr_q2e5u8k6dd

@trotterdylan

Copy link
Copy Markdown
Collaborator Author

Review round 1 (GLM 5.3, at f7d9767)

Owner review required: yes — a cross-repo contract: source-contract.ts and its three byte-identical copies change together (stewardsRing gains deployment, sourceSetInterest gains deployment repos), against the merged bb-gate/docs/hooks.md side. @trotterdylan, this one needs your approval.

Blockers

  1. plugins/github-watcher/server.ts:338 — a refused deployment_repo lease is never recorded, so the new unleased reporting is dead code. The refusals.add guard is a ternary over repo / dependabot_repo / else-interestEntities; deployment_repo falls to the interestEntities branch, which never contains a bare repo name, so refusals.add("deployment_repo …") is never called. The loop at server.ts:450 that looks up refused.get(\deployment_repo ${repo}`)can therefore never fire:bb github-watcher watches/ the stewards interest view never reports a skipped deployment repo, contradicting the PR body ("reports refusals inbb github-watcher watches… a missingdeployments:readis a skip"). The server.test.ts assertion only checks the log line, which does fire. Fix: givedeployment_repoits own branch in the ternary (checkinginterestDeployment, as dependabot_repochecksinterestDependabot), and extend the existing refusal test to assert the unleased` entry in the interest view.
  2. plugins/stewards/server.ts:1793 — a binding that already began ending is neither held open nor woken while a deployment is outstanding. With life.kind === "terminal" && awaitingDeploy, the first if is skipped and the else if (b.ending !== null) early-returns — before the wake code and before keep(), so the deployment changes are not even kept as pending notes. Reachable for exactly the pre-BB-53 pattern this ticket replaces: a ticket reaches Done while its linked pull request is still open → the steward's wrap-up sets followThrough ("watch the deploy") → the pull request merges and recordMerged records the watch → the wake is swallowed; a later deployment doorbell only queues a loud note (onDeploymentDoorbell) that no reconcile ever delivers, the nightly pass skips ending !== null bindings, and followThroughRanOut ends the binding with the deployment unresolved. Pre-change, terminal && followingThrough fell through to the wake. Fix: let the else if pass when awaitingDeploy (or handle ending !== null && followingThrough(b) before it, as the first branch did), and add a test for a following-through binding woken by a merge/deployment doorbell.

Suggestions

  • plugins/stewards/deploy.ts:109/164 — the playbook timeout only covers "no deployment at all". applyDeployment sets deadlineAt: null on any non-failure state (including a bare deployment event with empty state, queued, in_progress), and a not-yet report keeps it null, so from the first doorbell on the only guaranteed wake is requeue-default (2d in the test playbook) rather than the playbook's timeout. Consider resetting deadlineAt: now + target.timeout on not-yet, and keeping a deadline while deploying, so a deployment that never gets a status still wakes within the playbook-set time.
  • plugins/stewards/wake.ts:160 — deploymentInstructions overrides every other lifecycle instruction whenever a watch is pending (adopted, reopen, detach, nightly). A freshly adopted or reopened binding with a pending deployment never sees its adoption/reopen text. Consider limiting the override to terminal/follow-through (the cases the hold exists for) or appending the deployment text to the reason's own instructions.
  • recordMerged records mergeSha = the pull request's head sha. With squash or rebase merges that commit is not on the base branch, so a "contains the merge commit" rule cannot be decided from the wake's merge <headSha> line alone. The steward can resolve it (the deployment carries ref/sha, and it can look), so not blocking — but the skill/README could say so, so a steward does not conclude "not deployed" from a failed head-sha ancestry check alone.

Checked

  • Ran: npm test + npx tsc --noEmit in plugins/stewards (485 pass), plugins/github-watcher (74 pass) — both in the CI matrix — and plugins/linear (143 pass; not in the CI matrix, I ran it). All green on this head; all 20 GitHub checks on the head now completed successfully.
  • Verified the three source-contract.ts copies are byte-identical (sha256) and stewards/contract.test.ts enforces it; the new lease kind, doorbell routing and deployment object match bb-gate/docs/hooks.md (kinds table, deployment_repo admission, states including empty-on-deployment, action not branched on).
  • Verified against ticket: deployment doorbell parsed and routed ✓ (both plugins); carries/not-yet via the steward's report, with the wake carrying the merge sha, ref/sha, state, URL and the playbook rule ✓; failure state wakes with the run URL ✓; no-deployment timeout via the existing requeue/sweep ✓; two tickets released by one deployment ✓; no-deployment-target project behaves as today ✓ (test); bb stewards show prints merged/deploying/deployed/failed per PR ✓; no new credential ✓ (only deployment_repo leases through the server's existing token, nothing posts deployments); strictly additive ✓ (optional playbook key, defaulted store column and kv fields, old rows and old builds unaffected); PR body states the restart staging ✓; no .bb edits ✓.
  • "A single-PR ticket reaches Done without any worker turn after the merge turn" is met at the plugin level (the wakes and the closing-comment instruction are tested); the end-to-end path still depends on the org webhook's Deployments events being enabled by hand, which the PR body correctly flags as not tested.
  • Noted, not blocking: deployment watches have no re-check path if a doorbell is missed during a stream gap (issue watches re-check via the sweep); the timeout wake is the backstop, which fits the ticket's "no polling" constraint.

— from bb thread thr_hd5i2upxav

- github-watcher: record a refused deployment_repo lease so the watches view
  reports it, and assert the unleased entry.
- stewards: a terminal binding already following through keeps falling through
  to the wake while a deployment is outstanding, so the deployment is not
  swallowed; test the Done-then-merged case.
- deploy: keep a fresh deadline while deploying and on a not-yet verdict, so a
  deployment with no final status still wakes within the playbook's timeout.
- wake: append the deployment instruction to the lifecycle instruction rather
  than replacing it, so adopted/reopened turns keep their own text.
- docs: the wake's merge sha is the pull request head, so decide ancestry from
  the deployment's ref/sha.
@trotterdylan

Copy link
Copy Markdown
Collaborator Author

Round 1 addressed in 2756abf.

Blockers

  1. Fixed in 2756abf — onRejected now gives deployment_repo its own branch (checks interestDeployment), so refusals.add("deployment_repo …") is reached and the unleased line reports it. The github-watcher deployment test now asserts the unleased entry (refused by bb-gate-hooks (forbidden); deployment doorbells are skipped), not only the log line.
  2. Fixed in 2756abf — the skip now applies only to a terminal binding that has not begun ending (awaitingDeploy && b.ending === null). A binding already following through falls through to the wake as before; a new test drives a ticket to Done while its pull request is open, has the steward keep it open with followThrough, then merges the pull request and asserts the deployment is recorded and the steward is woken with "A merge is awaiting deployment".

Suggestions

  • Taken. applyDeployment now keeps a fresh deadline on a non-failure state (now + target.timeout), and a not-yet verdict resets it too, so a deployment with no final status or one that does not carry the merge still wakes within the playbook's timeout. reportDeployment takes the timeout; the deploy tests assert the reset deadline and that a deploying watch times out.
  • Taken. lifecycleInstructions now appends the deployment text to the reason's own instruction instead of replacing it, so adopted, reopen, detach and nightly keep their text and still hear about the deployment.
  • Taken. The README and the stewards skill now say the wake's merge <sha> is the pull request head and that a squash or rebase merge rewrites it, so ancestry is decided from the deployment's ref/sha and the repository rather than the head sha alone.

Re-ran npm test + npx tsc --noEmit in all three plugins: stewards 486, github-watcher 74, linear 143, all green.

— from bb thread thr_q2e5u8k6dd

@trotterdylan

Copy link
Copy Markdown
Collaborator Author

Review round 2 (GLM 5.3, at 2756abf)

Owner review required: yes — a cross-repo contract: source-contract.ts and its three byte-identical copies change together (stewardsRing gains deployment, sourceSetInterest gains deployment repos), against the merged bb-gate/docs/hooks.md side. @trotterdylan, this one needs your approval.

Resolved since round 1

  • Blocker 1 (refused deployment_repo never recorded, unleased reporting dead): resolved — the guard at server.ts:338 now has a deployment_repo branch over interestDeployment, and the test asserts the unleased entry ("deployment doorbells are skipped") in the watches interest view.
  • Blocker 2 (a following-through terminal binding's deployment swallowed): resolved — the hold now requires b.ending === null, so a ticket Done with its pull request still open keeps falling through to the wake while following through, exactly the pre-change path, with the deployment changes delivered; the new test covers wrap-up → followThrough → merge → wake with "A merge is awaiting deployment".
  • Suggestion 1 (timeout only covered "no deployment at all"): taken — applyDeployment keeps a fresh deadline while deploying and not-yet resets one, with tests for both; a deployment that never reaches a final status now still wakes within the playbook's time.
  • Suggestion 2 (deployment text replaced other lifecycle instructions): taken — appended in lifecycleInstructions, so adopted/reopened/detach keep their own text.
  • Suggestion 3 (head-sha caveat): taken in README and the skill.

Checked

  • Ran on this head: npm test + npx tsc --noEmit in plugins/stewards (486 pass, one new test) and plugins/github-watcher (74 pass); plugins/linear (143 pass; not in the CI matrix, I ran it — unchanged this round). All three source-contract.ts copies still byte-identical. All GitHub checks on this head completed successfully.
  • The fixes introduce nothing new: the deadline while deploying feeds deploymentDeadline/timeoutsDue consistently into the existing requeue path, reportDeployment's new timeoutMs argument is passed from the playbook at its one call site, and the appended wake text renders in the same block.
  • No blockers remain. The three suggestions above were all addressed; nothing new to suggest.

— from bb thread thr_hd5i2upxav

@trotterdylan

Copy link
Copy Markdown
Collaborator Author

Approved 2756abf from the Stewards page

@trotterdylan
trotterdylan merged commit 581ef63 into main Oct 25, 2026
20 checks passed
@trotterdylan
trotterdylan deleted the bb/bb-53-plugins-deployment-source-pr-b-thr_q2e5u8k6dd branch October 25, 2026 19:44
@trotterdylan

Copy link
Copy Markdown
Collaborator Author

Merged: owner-reviewed, approved by trotterdylan on 2756abf (unsigned comment 2026-10-25T19:42:48Z); reviewer approved round 2 at the same sha; all checks green on 2756abf. Head did not move past the approved sha.

Squash commit 581ef63.

This merge moves the bb-plugins pin, rebuilds the bb-server image and stages a restart for every developer's server — each owner presses Restart now or is updated in the quiet window (03:00–05:00 US Eastern).

— from bb thread thr_mn2gafjx84

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