Skip to content

stewards: a sentry-project ops target, rung by bb-gate-hooks (BB-10) - #47

Merged
trotterdylan merged 4 commits into
mainfrom
bb/take-linear-ticket-bb-10-to-merged-and-shipped-b-thr_qfkuaj62it
Oct 20, 2026
Merged

trotterdylan merged 4 commits into
mainfrom
bb/take-linear-ticket-bb-10-to-merged-and-shipped-b-thr_qfkuaj62it

Conversation

@trotterdylan

@trotterdylan trotterdylan commented Oct 20, 2026 •

Copy link
Copy Markdown
Collaborator

Implements BB-10, PR 2 of 2 (PR 1, the bb-gate-hooks Sentry adapter, is bb-gate#14, merged and rolled out). An ops binding can now watch a Sentry project: { "kind": "sentry-project", "org", "project" } in ops.targets. The plugin reads it with its own Sentry token, subscribes to bb-gate-hooks for the sentry source itself, and wakes the ops steward the moment an issue is created or regresses, with the periodic look as the backstop. The Sentry issue id is the fingerprint.

Merging moves the bb-plugins pin: bb-gate's bb-server workflow re-pins main within ten minutes, builds a new image and stages a restart on every developer's server (Settings → Plugins → Team setup → Restart now, or the 03:00–05:00 US Eastern quiet window).

Classification

owner-reviewed: two "risky whatever its shape" triggers from AGENTS.md apply even though the change is additive in shape: a store migration (ALTER TABLE bindings ADD COLUMN sentry_look TEXT, appended to MIGRATIONS, nullable, unread by the previous build) and a secret (the new sentryToken secret setting on a live plugin, a credential on every developer's server). The reviewer set this lane in round 1 and it wins over the no-review reading in the first version of this body. Everything that exists keeps its meaning: k8s and Dependabot targets, their looks and wakes, source-contract.ts (untouched; contract.test.ts still passes) and the bb-server Dockerfile are as before; the ops-watch playbook template gains Sentry paragraphs and the check on an ops playbook's source now also admits sentry, and a project's existing ops-watch.md keeps working unchanged.

What changes

  • config.ts, ops.ts: the sentry-project target (slugs folded to lower case, duplicates refused), its key sentry-project/<org>/<project>, sentryTargets(), and redactLine shared with the kubectl look.
  • sentry.ts (new): the Sentry reader (project, unresolved issues, one issue, latest event; the token goes into one header and never into a log or error), issue and stack-trace parsing with redaction, sentrySightings (first seen since the last look, regressed/escalating, rung, known and still firing), the look schema, and sentryChanges (new, returned and regressed wake at once; a doorbell under an open ticket wakes once per requeue-default; a missing token wakes once so the steward files the need).
  • hooks-client.ts (new): github-watcher's subscriber copied for the sentry source, lease kinds project (org/slug, leased under the slug) and issue; no token means nothing leased, a 401 is said once per token.
  • server.ts: the settings; lookAtSentry and reconcileSentry; bindings titled Sentry watch: org/project under the ops playbook; the hooks loop (one stream, opened once a project lists a Sentry target; project leases from the project files, issue leases for fingerprints with a ticket seen within 30 days; a doorbell schedules every binding whose project or fingerprint map it names); a filed ticket leases its issue at once; the ops steward's instructions for a Sentry target; bb stewards check reads each project with the token and reports the doorbell stream's state; bb stewards list shows the last Sentry look.
  • wake.ts: formatSentryWake: per finding the short id, title, level, culprit, permalink, counts, first/last seen, substatus, why it is in the look, and the latest event's stack trace; the other unresolved issues for context; the no-token wake that names the sentryToken setting, the auth-tokens page and the scopes.
  • store.ts: bindings.sentry_look (appended migration).
  • templates.ts: ops-watch text for Sentry targets (second event is a comment, regression after Done is Returned).
  • DESIGN.md §18 "Sentry projects", README.md, skills/stewards/SKILL.md.

Testing

  • npm run typecheck and npm test in plugins/stewards: pass (266 tests; the stewards job is in the CI matrix and is green on the head). New: sentry.test.ts (parsing, stack traces and redaction, the reader including no-token and 401, sightings, changes), hooks-client.test.ts (the loop against a fake bb-gate-hooks, including no token and a refused token), and a Sentry stewards block in server.test.ts (wake content, filing and issue leases, a doorbell for a new issue, a second event as a comment under the open ticket with the once-per-requeue throttle, a regression after Done as Returned, the periodic look alone finding new and regressed issues, the no-token wake and check lines, and check with a readable and a refused project).
  • A rung issue read by id joins a look only when its permalink names the target's organization (issueInOrg), since a project slug is unique only within an organization (reviewer round 1); covered in sentry.test.ts and server.test.ts.
  • Not tested against a live Sentry or the deployed bb-gate-hooks: the Sentry internal integration and its sealed secret are the owner's manual step (noted on the ticket by slice 1), so the end-to-end doorbell path was exercised through the fake bb-gate-hooks in hooks-client.test.ts and the in-process doorbell seam in server.test.ts. The Sentry API shapes follow the public issue, issue list and latest-event endpoints.

🤖 Generated with Claude Code

@trotterdylan

Copy link
Copy Markdown
Collaborator Author

Independent review running in bb thread @thread:thr_7pckqycgn3.

_— from bb thread

@trotterdylan

Copy link
Copy Markdown
Collaborator Author

Review round 1 (GLM 5.3, at ff2cb3a)

Owner review required: yes — two "risky whatever its shape" triggers in AGENTS.md's "Change classification": a store migration (ALTER TABLE bindings ADD COLUMN sentry_look TEXT; PR #26 counted its new ops_look/ops_fingerprints columns the same way and was owner-reviewed) and a secret (the new sentryToken secret setting on a live plugin, a new credential path on every developer's server). @trotterdylan, this one needs your approval.

Blockers

  1. PR body, Classification line — it claims no-review: strictly additive, but the two triggers above apply regardless of additive shape, so the lane is owner-reviewed. As it stands the worker would merge on my approval plus green checks with no human looking at a change that adds a store migration and a credential setting. Correct the Classification line to owner-reviewed (naming the two triggers) so the merge gate waits for trotterdylan's approval. The code itself is not blocked by this; only the body is.

Suggestions

  • The PR body's Testing section says the stewards suite is "not in the CI matrix" — it is (.github/workflows/plugins.yaml lists stewards), and its check is green on this head. Fix that line while correcting the Classification.
  • Slug collision across organizations: onSentryDoorbell matches by bare project slug (as the hooks contract defines the unit, so routing cannot disambiguate), and lookAtSentry's individual read of a rung issue accepts any issue whose project slug equals the target's — so with {org: acme, project: web} and {org: org2, project: web} both watched, a doorbell for acme's issue also pulls it into org2's look, and store.sight keys fingerprints per project, so both bindings share one row. Low likelihood, and the contract itself says "two organizations' projects with the same slug are the same unit here"; the rung read could still cross-check the org (e.g. via the permalink's host) if you want the stricter side.
  • reconcileSentry is a third copy of the wake tail already duplicated between the ops and deps paths (keep/deferred/busy/deliverWake); a shared helper would keep the next fix to that logic in one place. Fine to defer.

Checked

  • Ran in plugins/stewards at ff2cb3a: npm install --include=dev --legacy-peer-deps, npm run typecheck (clean), npm test — 266/266 pass (13 files, including the new sentry.test.ts, hooks-client.test.ts and the Sentry stewards block in server.test.ts). CI's stewards job is also SUCCESS on this head (it is in the matrix, contrary to the body).
  • Verified against ticket BB-10 (spec comment) and bb-gate/docs/hooks.md "Sentry" (the contract from merged bb-gate#14):
    • New issue wakes the ops steward; the wake carries the permalink, culprit, counts, first/last seen, substatus and the latest event's redacted stack trace, with file-and-escalate instructions; fingerprint is the Sentry issue id; a filed ticket records the fingerprint and leases the issue at once — met (formatSentryWake, server.test.ts).
    • A second event under an open ticket is one comment per requeue-default, never a second ticket — met (sentryChanges, server.test.ts).
    • A regression after Done is returned and the playbook says reopen-or-file-anew — met (templates.ts, server.test.ts).
    • With bb-gate-hooks down, the periodic look lists first-seen-since-last-look and regressed issues and wakes the same way (2-minute down-sweep, 10-minute baseline) — met.
    • No token: exactly one wake, filing the provide-secret need naming the setting, page and scopes; later looks quiet; bb stewards check reports both the missing token and the unreadable target — met.
    • Lease semantics follow the contract: renew at half-life, 401 is the token (said once per token), unknown-connection reconnect, wrong-URL 404 once, rejected leases logged and surfaced in check — met.
    • Store migration is append-only at the end of MIGRATIONS, a nullable column the previous build neither reads nor writes — met.
    • Token security: the token reaches one Authorization header and one subscribe body and nothing else; no log line, error or test assertion exposes it; all ticket-bound text (titles, culprits, stack traces, event messages, context lines) passes redactLine — met.
    • source-contract.ts untouched (contract.test.ts passes) and no bb-gate Dockerfile changes, per the spec's decision — met.
  • The $BB_THREAD_ID line in formatSentryWake is valid TypeScript (backticks inside a double-quoted string inside the interpolation), same pattern as the existing wakes.

The implementation is solid; after the body correction this needs only the owner's approval, and I have no code blockers.

— from bb thread thr_7pckqycgn3

@trotterdylan

Copy link
Copy Markdown
Collaborator Author

Round 1 answered; pushed dfcd8c4.

Blocker 1 (Classification line): fixed in the PR body. The lane is owner-reviewed (store migration + the sentryToken secret setting), and the body names both triggers. The merge gate now waits for @trotterdylan's approval.

Suggestions:

  • CI-matrix line in Testing: fixed in the body (the stewards job is in the matrix and green).
  • Slug collision across organizations: taken in dfcd8c4. A rung issue read by id joins a look only when its permalink names the target's organization (issueInOrg: <org>.sentry.io or /organizations/<org>/); covered in sentry.test.ts and in the doorbell test in server.test.ts. The unit-lease routing itself stays as the hooks contract defines it.
  • A shared helper for the wake tail across the ops, deps and Sentry paths: declined for this PR. It is a refactor of code BB-10 does not otherwise touch, and the project steward asked to keep this PR to the Sentry source, its settings and tests; worth its own follow-up.

Typecheck and the 266 tests pass on dfcd8c4.

_— from bb thread

@trotterdylan

Copy link
Copy Markdown
Collaborator Author

Review round 2 (GLM 5.3, at dfcd8c4)

Owner review required: yes — a store migration (bindings.sentry_look) and a secret (the sentryToken setting), both "risky whatever its shape" (AGENTS.md, "Change classification"). @trotterdylan, this one needs your approval; with this round there are no blockers left on my side.

Blockers

None.

Resolved since round 1

  • Blocker 1 (Classification line claimed no-review): resolved by dfcd8c4 — the body now reads owner-reviewed, naming the migration and the secret setting.
  • Suggestion (stewards "not in the CI matrix"): resolved — the Testing line now says the matrix job is green on the head, which it is.
  • Suggestion (slug collision across organizations): resolved by dfcd8c4 — issueInOrg checks a rung issue's permalink (host prefix <org>. on sentry.io, /organizations/<org>/ on a self-hosted server) before it joins a look, with null/unparseable permalinks taken on trust; the dot in the host prefix and the trailing slash in the path keep acme from matching acme2. Applied on the right path only — the org-ambiguous read-by-id — while the project list is org-qualified by its URL. Unit tests cover the function, and the doorbell test shows another org's issue never reaching the wake.
  • Suggestion (shared wake-tail helper): declined with a reason (a refactor outside this PR's scope, per the project steward). Fair; dropped.

Suggestions

  • In the doorbell test in server.test.ts, issue "66" is given status: "ignored" as well as another org's permalink, so that server-level test would also pass without issueInOrg (the status filter excludes it anyway) — as written it exercises the wiring but not the org check itself. Making it unresolved would make it fail if the issueInOrg call were dropped. The sentry.test.ts unit tests already cover the function, so this is cosmetic.

Checked

  • Diffed ff2cb3a → dfcd8c4: only the issueInOrg addition with its tests, the call in the rung-id read, the import, and the PR body edits. No other behavior changed.
  • Ran in plugins/stewards at dfcd8c4: npm run typecheck (clean), npm test — 266/266 pass. CI's stewards job is SUCCESS on this head.
  • Re-classified: the lane is unchanged — owner-reviewed (store migration + secret). The verdict and this lane are for dfcd8c4.
  • All round-1 acceptance-criterion checks stand for this head (wake content and filing plumbing, second-event-as-comment throttle, regression after Done as returned, periodic-look backstop without doorbells, no-token need, lease semantics per bb-gate/docs/hooks.md "Sentry", append-only migration, token never logged, source-contract.ts untouched).

Approved on my side; the merge gate now waits on trotterdylan's approval plus green checks.

— from bb thread thr_7pckqycgn3

@trotterdylan

Copy link
Copy Markdown
Collaborator Author

Round 2 answered; head is now 91c6560 (tests only).

  • Suggestion (issue 66 in the doorbell test was ignored, so the org check was not what excluded it): taken. It is now unresolved, and the fake Sentry's project list is the organization's own as the real one is by its URL, so the server test fails without issueInOrg. 4fe0e52 was the first half of that and briefly left the suite red; 91c6560 fixes it. 266 tests and typecheck pass on 91c6560.

Reviewer approved dfcd8c4; the change since is test-only, so no new round is asked for. The gate now waits on @trotterdylan's approval (owner-reviewed: the sentry_look store migration and the sentryToken secret setting) plus green checks.

_— from bb thread

@trotterdylan

Copy link
Copy Markdown
Collaborator Author

Review round 3 (GLM 5.3, at 91c6560)

Owner review required: yes — a store migration (bindings.sentry_look) and a secret (the sentryToken setting) (AGENTS.md, "Change classification"). @trotterdylan, your approval is the remaining gate; my round-2 approval stands on this head.

Resolved since round 2

  • Suggestion (the doorbell test's issue 66 did not exercise issueInOrg): resolved by 91c6560 — issue 66 is now unresolved and the fake project list is org-scoped (as the real one is by its org-qualified URL), so only the issueInOrg call keeps it out of the look and the wake; the test now fails without it. The intermediate 4fe0e52 (red for exactly that reason) never reached review; the final head is green.

Checked

  • Diffed dfcd8c4 → 91c6560: server.test.ts only, exactly as described — no behavior change, so the round-2 verdict stands on the new head.
  • Ran in plugins/stewards at 91c6560: npm test — 266/266 pass (13 files). CI's stewards job is SUCCESS on this head.

No blockers, no new suggestions. Approved; the merge gate remains the owner's approval plus green checks.

— from bb thread thr_7pckqycgn3

trotterdylan and others added 4 commits October 20, 2026 16:40
An ops binding can now watch a Sentry project beside a Kubernetes
namespace: `{ kind: "sentry-project", org, project }` in ops.targets.
The plugin reads it with its own Sentry token (a new secret setting,
sentryToken, plus sentryApiUrl for a self-hosted server), subscribes to
bb-gate-hooks for the `sentry` source itself (hooks-client.ts, a copy of
github-watcher's without the GitHub parts) with a project lease per target
and an issue lease per issue with a ticket, and wakes the ops steward with
the issues new, regressed or rung since the last look: title, culprit,
permalink, event and user counts, first and last seen, and the latest
event's stack trace, redacted as the kubectl look's logs are. The Sentry
issue id is the fingerprint. The periodic look is the backstop with hooks
down. Without a token the steward is woken once to file the provide-secret
need. `bb stewards check` reads each project with the token and says how
doorbells arrive. The ops-watch playbook template, DESIGN.md §18, the
README and the stewards skill say so.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
…mes the target's organization (BB-10)

Review round 1: a project slug is unique only within an organization, so
an issue read by id after a doorbell is checked against the permalink
(`<org>.sentry.io`, or `/organizations/<org>/`) before it joins the look.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
…exercises issueInOrg (BB-10)

Review round 2's suggestion.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
@trotterdylan
trotterdylan force-pushed the bb/take-linear-ticket-bb-10-to-merged-and-shipped-b-thr_qfkuaj62it branch from 91c6560 to d1aec8a Compare October 20, 2026 16:41
@trotterdylan
trotterdylan merged commit 8d2189f into main Oct 20, 2026
26 of 27 checks passed
@trotterdylan
trotterdylan deleted the bb/take-linear-ticket-bb-10-to-merged-and-shipped-b-thr_qfkuaj62it branch October 20, 2026 16:48
@trotterdylan

Copy link
Copy Markdown
Collaborator Author

Merged: owner-reviewed lane. Reviewer (GLM 5.3) approved 91c6560 (round 2, confirmed round 3); the owner directed the rebase and merge from the owning bb thread (no unsigned GitHub comment, so none is recorded here); checks green on d1aec8a. Since the approved sha: rebased onto main over BB-19 (#46) and BB-20 (#48), resolving two trivial conflicts (an import line and append-only migrations, both sides kept), no change of scope or behaviour.

This moves the bb-plugins pin: bb-gate's bb-server workflow re-pins main within ten minutes, builds a new image and stages a restart on every developer's server (Settings → Plugins → Team setup → Restart now, or the 03:00–05:00 US Eastern quiet window).

_— 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