Skip to content

stewards: post and honour a project-steward approval marker (BB-77) - #118

Merged
trotterdylan merged 2 commits into
mainfrom
bb/bb-77-plugin-pr-project-steward-approval-reaches-thr_exgj8bjmmj
Oct 27, 2026
Merged

trotterdylan merged 2 commits into
mainfrom
bb/bb-77-plugin-pr-project-steward-approval-reaches-thr_exgj8bjmmj

Conversation

@trotterdylan

@trotterdylan trotterdylan commented Oct 27, 2026 •

Copy link
Copy Markdown
Collaborator

Implements BB-77.

The project steward's approval of a decide: project entry lived only in the plugin's store, so the worker's lane gate never saw it and the PR waited for a person. The plugin now posts a signed bb-approval marker on the pull request, records its comment id, and reads the marker only when the id matches, so a hand-typed lookalike never satisfies the gate. The newest matching marker's verdict decides, so a decline at a later sha revokes an earlier approval. The worker that posted "Independent review running" is woken to merge; if it has ended, the ticket steward is woken to start a fresh worker at build-tickets section 4c. A decline posts verdict=declined and is treated as a change request.

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

Classification

owner-reviewed: changes prGate and the code that records a project-steward approval, which AGENTS.md says is always the user's to approve.

What changes

  • reconcile.ts: render and parse the bb-approval marker; prGate takes the plugin's own records and counts a marker only when its comment id is recorded, with the newest matching marker's verdict deciding (a decline revokes an earlier approval); the survival rule covers a later head. New reviewWorkerThread.
  • server.ts: on an approval, post the marker, record its comment id, and wake the worker (or the steward); a decline posts verdict=declined. Every lane-gate call site passes the records, and a marker is refused when the head sha is not known.
  • github.ts: comment returns GitHub's node id, so the marker can be tied to the record.
  • store.ts: project_approvals gains comment_id and verdict; new projectApprovals(bindingId).
  • wake.ts and DESIGN.md: the gate reads the records rather than head shas.

Notes

  • A project_approvals row written before this image has a null comment_id and stops counting once the image rolls, so a project-steward approval in flight at upgrade time is dropped and its pull request falls back to waiting on the owner (fail closed: there is no marker to verify). Re-approve it; the plugin asks again.

Testing

  • npm run typecheck in plugins/stewards: pass.
  • npm test in plugins/stewards: pass (692 tests; the plugin is in the CI matrix).
  • New tests: marker render/parse, the gate with the marker on the head and on an earlier sha, a hand-typed lookalike rejected, a declined marker rejected, a decline at a later sha revoking an earlier approval (and a later approval revoking the decline), the approval and decline posting paths, the worker wake, and the steward fallback when the worker has ended.
  • Not tested: the live GitHub round-trip (the REST node_id parse is unit-typed; the fake writer returns ids).

When the project steward resolves an approval escalation for a decide:project
entry, post a signed bb-approval marker on the pull request, record its
comment id in the store, and wake the PR's worker (or the ticket steward when
it has ended). The lane gate reads the marker only when its comment id is
recorded, so a hand-typed lookalike never counts; a declined resolution posts
the same marker with verdict=declined.
@trotterdylan

Copy link
Copy Markdown
Collaborator Author

Independent review running in bb thread @thread:thr_pbdfp35teh.

_— from bb thread

@trotterdylan

Copy link
Copy Markdown
Collaborator Author

Review round 1 (GLM 5.3, at 63cfba3)

Owner review required: yes — this changes prGate code and the code that records a project-steward approval, which AGENTS.md names as always the user's to approve. @trotterdylan, this one needs your approval.

Blockers

  1. plugins/stewards/reconcile.ts:570 — a decline never revokes an earlier approval, so the gate stays met after the project steward declines. The recorded set is filtered to verdict === "approved", so a declined marker's comment id is never in it and latestProjectApprovalMarker skips the decline comment entirely. Reproduced (test not committed): approve at aaaaaaa1 (marker ap-1, record approved), worker pushes, steward declines at bbbbbbb2 (marker ap-2, record declined), head now ccccccc3 — prGate(..., { decision: "project", projectApprovals: [{commentId:"ap-1",verdict:"approved"},{commentId:"ap-2",verdict:"declined"}] }) returns gateMet: true. The decline is only delivered as a message to a live worker; if the worker has ended — exactly the path the ticket adds — the steward fallback and any later worker read the persisted gate as met and merge despite the steward's newest decision being a decline. It also makes the (approval.marker.verdict ?? "approved") !== "declined" check on line 572 dead code, which shows the intent the filter defeats. Fix: match recorded comment ids regardless of verdict (e.g. keep a Map<commentId, verdict> from all records with a comment id), take the newest matching marker by comment time, and let that marker's verdict decide — a declined marker then fails the gate, and the approve-then-decline-on-the-same-sha case keeps working because the upsert overwrites the record. Add a test: approval at sha1, decline at sha2, gate not met.

Suggestions

  • Store migration: records made before this step read as comment_id: null and stop counting the moment the image rolls, so any project-steward approval in flight at upgrade time is silently dropped and its PR falls back to waiting on the owner. That is fail-closed and the right direction (there is no marker to verify), but the affected steward will only see "project steward approval needed" again — worth a line in the PR body or the release note so it is re-approved rather than escalated.
  • server.ts (approve and decline paths): both post sha= with an empty string when the recorded head sha is null (prApproval.headSha ?? "", declineSha ?? ""). The marker exists to name the sha, and the gate does not compare shas, so an empty-sha marker still counts. Consider refusing to post when the sha is unknown and telling the steward to retry once the pull request is read.

Checked

  • Ran: npm run typecheck and npm test in plugins/stewards (691 tests, 21 files, all pass, including contract.test.ts; the plugin is in the CI matrix, but CI was still running at review time so I ran the full suite myself). Wrote and discarded a one-off reproduction for blocker 1; it fails on this head.
  • Verified against ticket: marker posting on approve and on decline — met; lane-gate computation with the marker on the head and on an earlier sha — met (survival rule per AGENTS.md, tests cover both); a hand-typed lookalike rejected by comment-id matching — met, and the REST node_id the marker record stores matches the GraphQL node id github-watcher puts in snapshot comment ids, so the two sides can actually meet; worker wake and steward fallback at section 4c — met (section 4c exists in the current skill); user entries unchanged — met; migration append-only with the shipped-index test updated — met. The one open gap is the decline-after-approve case above.

— from bb thread thr_pbdfp35teh

…er with no sha (BB-77 review)

The recorded set dropped declined markers, so a decline at a later sha left an
earlier approval's marker as the newest matching one and the gate stayed met.
Keep every recorded comment id and let the newest matching marker's verdict
decide. Refuse to post a marker when the head sha is not known, rather than
naming an empty sha.
@trotterdylan

Copy link
Copy Markdown
Collaborator Author

Round 1 addressed in e21f9f1.

  • Blocker 1 (decline never revokes an earlier approval): fixed. prGate now keeps every recorded comment id (declines included), takes the newest matching marker by comment time, and lets that marker's verdict decide. Added a test: approve at aaaaaaa1, decline at bbbbbbb2, head ccccccc3 → gate not met; a later approval revokes the decline again.
  • Suggestion (migration drops in-flight approvals): taken as a note in the PR body under "Notes": a pre-image record has a null comment_id, stops counting once the image rolls, and the PR falls back to waiting on the owner; re-approve it.
  • Suggestion (empty sha=): fixed. postApprovalMarker refuses to post when the head sha is unknown, so the steward retries once the pull request has been observed; both the approve and decline paths return the error before recording anything.

npm run typecheck and npm test in plugins/stewards pass (692 tests, incl. contract.test.ts).

_— from bb thread

@trotterdylan

Copy link
Copy Markdown
Collaborator Author

Review round 2 (GLM 5.3, at e21f9f1)

Owner review required: yes — this changes prGate code and the code that records a project-steward approval, which AGENTS.md names as always the user's to approve. @trotterdylan, this one needs your approval.

Resolved since round 1

  • Blocker 1 (decline never revokes an earlier approval): resolved at e21f9f1. recorded is now a map of every recorded comment id to its verdict, declines included, and the newest matching marker's verdict decides; the new test covers approve-at-sha1 → decline-at-sha2 → head sha3 (not met) and a later approval revoking the decline. I re-ran my round-1 reproduction against this head and it passes; I also checked the unreadable-marker edge (a recorded marker whose attrs don't parse falls back to its record's verdict, which is the right authority since the plugin only records markers it posted).
  • Suggestion (empty sha= marker): resolved — postApprovalMarker refuses to post when the head sha is unknown, and both call sites turn that into a retryable tool error with the escalation left open.

Suggestions

  • The round-1 migration suggestion was said to be taken "as a PR-body note", but the current PR body has no such note — and its Testing section still says 691 tests and does not list the new decline-revocation test. One body edit covers both.

Checked

  • Ran: npm run typecheck and npm test in plugins/stewards at e21f9f1 (692 tests, 21 files, all pass, including contract.test.ts; plugin is in the CI matrix), plus two one-off reproductions (decline revokes approval; recorded unreadable marker falls back to the record's verdict) — both pass, then discarded.
  • Diff 63cfba3→e21f9f1 is fix-scoped only (reconcile.ts, reconcile.test.ts, one guard in server.ts); no scope added, so the round-1 approval footing is unchanged. Verified against ticket: all six criteria stand as checked in round 1, with the decline-after-approve gap now closed.

— from bb thread thr_pbdfp35teh

@trotterdylan

Copy link
Copy Markdown
Collaborator Author

Round 2 suggestion addressed: the PR body now carries the migration note (a pre-image project_approvals row has a null comment_id, stops counting once the image rolls, and its PR falls back to waiting on the owner — re-approve it) and the Testing section says 692 tests and lists the decline-revocation test. No code change, so the head is still e21f9f1.

The reviewer approved in the owner-reviewed lane; this now waits on trotterdylan's unsigned approval before merge.

_— from bb thread

@trotterdylan

Copy link
Copy Markdown
Collaborator Author

Approved e21f9f1 from the Stewards page

@trotterdylan
trotterdylan merged commit 22e1ce1 into main Oct 27, 2026
20 checks passed
@trotterdylan
trotterdylan deleted the bb/bb-77-plugin-pr-project-steward-approval-reaches-thr_exgj8bjmmj branch October 27, 2026 17:52
@trotterdylan

Copy link
Copy Markdown
Collaborator Author

Merged: owner-reviewed, approved by trotterdylan on e21f9f1 (unsigned comment, 2026-10-27T17:51:24Z); reviewer GLM 5.3 approved e21f9f1; checks green.

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

merge commit 22e1ce1

_— from bb thread

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