Skip to content

stewards: resolve a Sentry issue when its ticket reaches Done (BB-37) - #60

Merged
trotterdylan merged 1 commit into
mainfrom
bb/bb-37-resolve-sentry-issue-on-done-bb-plugins-thr_pmnc3seimu
Oct 22, 2026
Merged

trotterdylan merged 1 commit into
mainfrom
bb/bb-37-resolve-sentry-issue-on-done-bb-plugins-thr_pmnc3seimu

Conversation

@trotterdylan

Copy link
Copy Markdown
Collaborator

Implements BB-37. Fixed Sentry issues stayed open after their ticket reached Done because the stewards plugin had no Sentry write path. With the new ops.sentry.resolveOnDone switch on, the Sentry look resolves a mapped issue whose ticket is in a completed state while Sentry still shows it unresolved.

Merging this stages a restart on every developer's server (it changes a live plugin, so the bb-server image is rebuilt and each server restarts when its owner presses Restart now or in the quiet window). The plugin's Sentry token must be re-issued by the owner with event:write in addition to project:read and event:read, supplied through the existing provide-secret need; the .bb opt-in (ops.sentry.resolveOnDone: true) lands only after that, as its own change.

Classification

owner-reviewed: it widens an existing credential (the Sentry token gains event:write) and adds a production write. Both are in the decide list's "granting or widening a credential" and "anything irreversible in production" territory; the write itself is undoable because Sentry's regression detection reopens the issue.

What changes

  • sentry.ts: SentryReader.resolve(id) — PUT /api/0/issues/{id}/ with { "status": "resolved" }, the only write in the file; a failure is returned, never thrown. TOKEN_SCOPES gains event:write. sentryResolveTargets picks the rows whose ticket is completed and whose issue is still unresolved.
  • config.ts: ops.sentry.resolveOnDone, default off.
  • server.ts (the Sentry look): with the switch on, resolves each such row once, one quiet note per resolve in the look (Resolved WEB-12 in Sentry: BB-N is Done). A 403 gives one note per look naming the missing event:write scope and skips the rest of that look's resolves; the look otherwise completes. Canceled, open and already-resolved are untouched.
  • DESIGN.md §18 and README.md: the plugin writes exactly one thing in Sentry, and the token needs event:write. The provide-secret need and bb stewards check name it through TOKEN_SCOPES.

Testing

  • npm test in plugins/stewards: pass (372 tests; not in the CI matrix — CI runs npm test for stewards, but the matrix is fixed).
  • npm run typecheck in plugins/stewards: pass.
  • New unit tests in sentry.test.ts: the PUT method/URL/body, 403 and network failures returned not thrown, no request without a token, TOKEN_SCOPES includes event:write, and sentryResolveTargets leaves Canceled/open/already-resolved alone.
  • New integration tests in server.test.ts with a fake fetch: the resolve PUT body and the note on resolve; Canceled/open/already-resolved untouched; switch off makes no write; a 403 yields one note naming event:write and skips the remaining resolves while the look completes.

— from bb thread thr_nbynwz4hxz

@trotterdylan

Copy link
Copy Markdown
Collaborator Author

Independent review running in bb thread @thread:thr_rrmdnctn9u.

— from bb thread thr_nbynwz4hxz

@trotterdylan

Copy link
Copy Markdown
Collaborator Author

Review round 1 (GLM 5.3, at 4aefce5)

Owner review required: yes — it widens an existing credential: the production Sentry token must be re-issued with event:write in addition to its read scopes, and the plugin gains its first write to production Sentry. That is the bigDecisions entry "Granting a new credential, token or cluster access … or widening what an existing one can reach" (decide: user in .bb/stewards/project.json). The ops.sentry.resolveOnDone default (off) and the opt-in landing separately in .bb are the right shape for it. @trotterdylan, this one needs your approval.

Suggestions

  • server.ts (403 note) — the note states flatly that a 403 means "the token is missing the event:write scope", but Sentry also answers 403 for issue-level access the token lacks for other reasons. The ticket's example is a token without event:write, so this is fine as written; a "most likely" or including Sentry's response detail would make it less assertive. Author's call.
  • config.ts — the outer ops .default({ targets: [], autoAdopt: [], sentry: { resolveOnDone: false } }) spells out sentry although the inner object carries its own .default(...); harmless and arguably clearer. No change needed.
  • A resolve note is quiet (notes are not actionable sentryChanges entries), so it surfaces only in a wake that happens anyway — e.g. the doorbell or requeue that carried the look. That matches the ticket's "the look notes it"; noting it here so the author can confirm it was intended.

Checked

  • Ran: npm run typecheck (pass) and npm test (372 tests, 15 files, pass) in plugins/stewards at 4aefce5. stewards is in the plugins workflow's CI matrix (.github/workflows/plugins.yaml), so this is a second run of what CI covers, not a fill-in.
  • Verified against ticket:
    • Switch on → resolve at the look, PUT body asserted, look notes it — met (server.test.ts: writes equals [{ path: "/api/0/issues/<id>/", body: '{"status":"resolved"}' }], wake matches Resolved WEB-12 in Sentry: ENG-50 is Done; sentry.test.ts asserts method/URL/body at the reader level).
    • Canceled / open ticket, already-resolved issue untouched — met (sentryResolveTargets unit tests plus the three-issue integration test; stateType !== "completed" excludes canceled, a null/unreadable ticket snapshot is skipped, and unresolvedById excludes what Sentry resolved).
    • Switch off (default) → no write ever — met (integration test asserts writes stays empty; config default off with its own test; the gate is read per look in reconcileSentry, so it is not cached across looks).
    • Failed PUT (403) → one note naming event:write, remaining resolves skipped, look otherwise completes — met (integration test asserts the note and that both Done issues still appear; failures are returned, never thrown, at the reader level).
    • TOKEN_SCOPES includes event:write; bb stewards check and the provide-secret need name it — met (both derive from TOKEN_SCOPES.join(" and ") at server.ts:4909 and the setting description at server.ts:520; tests updated; grep shows no stale two-scope wording anywhere in the plugin).
    • DESIGN.md §18 and README updated — met (the "never writes to Sentry" paragraph is replaced by "writes exactly one thing", scope lists updated in both). ops-watch.md is out of scope per the ticket note; not counted.
  • Also verified: the resolve loop is sequential, idempotent across looks (a resolved issue leaves the unresolved list), and safe across restarts (no persisted state involved); the token never appears in any note or error string; the new ops.sentry sub-schema is .strict() and additive, so existing project files parse unchanged; no source-contract.ts or other cross-repo contract is touched.

— from bb thread thr_rrmdnctn9u

@trotterdylan

Copy link
Copy Markdown
Collaborator Author

Round 1 at 4aefce5 — thanks. All three suggestions answered, no code change needed:

  • 403 note wording: kept as written. The ticket's acceptance criterion asks the note to name the missing scope, and a token without event:write is the case this feature exists for; the operator action is the same either way. Declined (author's call).
  • config.ts outer ops default: left as is. It is redundant with the inner .default(...), but it makes the fully-defaulted shape visible at the outer default and matches how targets and autoAdopt are spelled there. Declined (no change).
  • Quiet resolve note: confirmed intended. The note lands in look.notes, which is not an actionable sentryChanges entry, so it rides the wake that the look already produces (the returned classification when the ticket goes Done, a doorbell, or the requeue) rather than waking anyone by itself. That matches the ticket's "one quiet note per resolve in the look".

No new head; the approved sha 4aefce5 is current. Waiting on owner review (@trotterdylan) in the owner-reviewed lane.

— from bb thread thr_nbynwz4hxz

@trotterdylan

Copy link
Copy Markdown
Collaborator Author

LGTM

@trotterdylan

Copy link
Copy Markdown
Collaborator Author

Owner approved (LGTM) on 4aefce5. Gate met: reviewer verdict=approved round 1 at 4aefce5, all checks green, owner approval on the current head. Per the task, the merge is left to the owner — not merged here.

— from bb thread thr_nbynwz4hxz

@trotterdylan
trotterdylan merged commit cbcce27 into main Oct 22, 2026
20 checks passed
@trotterdylan
trotterdylan deleted the bb/bb-37-resolve-sentry-issue-on-done-bb-plugins-thr_pmnc3seimu branch October 22, 2026 20:46
@trotterdylan

Copy link
Copy Markdown
Collaborator Author

Merged: owner-reviewed, approved by trotterdylan on 4aefce5 (LGTM comment 2026-10-22T20:45:46Z), reviewer verdict=approved round 1 at 4aefce5, checks green. Head did not move past the approved sha. Squash-merged as cbcce27.

This changes a live plugin, so the bb-server image will be rebuilt and every developer's server stages a restart (owner presses Restart now, or the 03:00–05:00 US Eastern quiet window). The Sentry token still has to be re-issued with event:write by the owner before the .bb opt-in lands.

— from bb thread thr_nbynwz4hxz

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