Skip to content

ref(events): Declare core event limits per resource type - #2379

Merged
dcramer merged 3 commits into
mainfrom
feat/event-core-flags-docs
Oct 29, 2026
Merged

dcramer merged 3 commits into
mainfrom
feat/event-core-flags-docs

Conversation

@sentry-junior

@sentry-junior sentry-junior Bot commented Oct 29, 2026 •

Copy link
Copy Markdown
Contributor

Not a breaking change. Users, plugins, saved automations, and the dashboard API see the same behavior as before. This PR changes how core decides two existing rules, and it adds docs.

What this changes

Core has its own event resource types: Workspace snapshots, timers, and Slack channel messages. Two rules apply to them:

  • Event automations cannot use Workspace snapshot or timer events.
  • watchEvents cannot watch timers (use watchTimer) or Slack channel messages (use an event automation).

Before, core hard-coded these rules as checks on the namespace strings "junior", "timer", and "slack". Now each core registration declares its rules in a limits map, keyed by resource type (EventResourceTypeLimits in chat/events/catalog.ts):

  • automation: false for workspace_snapshot and timer.
  • watch: false for timer and Slack channel. Each one also sets watchUnavailableMessage, which tells the agent what to use instead. The messages are the same as before.

The limits sit beside the resource types, not on them. So the resource type objects stay plain plugin-api PluginEventType values.

Why it is not breaking

  • Plugin API: no change. limits is on a core-only registration type. @sentry/junior-plugin-api does not change, and plugins cannot set limits.
  • Same results: the new checks accept and reject the same inputs as the old ones. All junior resource types set automation: false, so that namespace is still left out of automations. slack has only channel, so the watch rejection covers the same inputs.
  • Saved automations: availability does not change. Every place that checks it reads the same filtered catalog.
  • Dashboard API: /event-catalog returns the same shape. It builds each entry from the plugin-api resource type only, so it does not need to remove core fields. A new core limit cannot break the strict response schema.
  • Public exports: none of the changed code is exported from @sentry/junior.

Docs

  • deployment.* events: the GitHub and Vercel READMEs and the public plugin pages now say what each event means. Vercel deployment.error is the same as GitHub deployment.failed, not GitHub deployment.error.
  • chat/events/README.md: now covers eventKey, occurredAtMs, objectType, the reserved junior and slack namespaces, the limits map, and short steps to add an event type.

Part of #2362, item 5. An earlier commit added regex identifier patterns for Linear and Sentry, and a later commit removes them. #2362 item 6 is replacing regex patterns with structured identifier parts.

Merge order with #2381

#2381 deletes pluginSupportsEvent, and this PR still uses it. Whichever PR merges second must rebase onto the other and resolve that conflict.

Checks

  • pnpm typecheck and pnpm lint pass.
  • The event catalog, watch, search, snapshot, Slack channel automation, heartbeat timer, Workspace tool, and automation edit tests pass. The automation edit test covers /api/automations/event-catalog.
  • One test, "delivers the current automation card and retains its reference in web history" in event-automations.test.ts, also fails on main without this change.

via David Cramer.

--

View Junior Session [Sentry]

…mits

Replace the namespace string checks for the core `timer`, Workspace
snapshot, and Slack channel resource types with two core-only fields on
the event catalog resource type: `automation: false` and
`watchUnavailable`. The published plugin API does not change.

Add identifier patterns for the Linear issue and team and the Sentry
issue and project resource types. They fit the identifiers that the
normalizers build.

Document what each `deployment.*` event means in the GitHub and Vercel
plugins, and add `eventKey`, `occurredAtMs`, `objectType`, the reserved
namespaces, and the steps to add an event type to the events README.

Refs #2362

Co-Authored-By: David Cramer <[email protected]>
@vercel

vercel Bot commented Oct 29, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
junior-docs Ready Ready Preview Oct 29, 2026 7:22pm UTC

Request Review

@sentry-evals

sentry-evals Bot commented Oct 29, 2026 •

Copy link
Copy Markdown

Sentry Evals

junior-guardian

Run Status Passed Failed Errored Cost Tokens Duration
Head Passed 94 0 0 $0.03 0 26.73s

Base commit 1a5cc18 has no eval run to compare against.

Identifier regex patterns are moving to structured identifier parts in
a separate change (#2362, item 6). Remove the new Linear and Sentry
patterns and the tests that only check them. Point the events README
step at that work instead of at patterns.

Refs #2362

Co-Authored-By: David Cramer <[email protected]>
@dcramer

dcramer commented Oct 29, 2026

Copy link
Copy Markdown
Member

Its not clear to me if this is a breaking change as the PR description requires too much context to understand

Move core-only automation and watch limits into a per-registration
limits map, keyed by resource type. Use symmetric automation?: false
and watch?: false flags, with watchUnavailableMessage kept separately.

Plugin-api resource type objects no longer carry core fields, so the
event-catalog route returns them without stripping and new core
limits cannot break its strict response schema.

Co-Authored-By: David Cramer <[email protected]>
@sentry-junior sentry-junior Bot changed the title ref(events): Use resource type flags for core watch and automation limits ref(events): Declare core event limits per resource type Oct 29, 2026
@dcramer
dcramer merged commit 6c73dc8 into main Oct 29, 2026
46 checks passed
@dcramer
dcramer deleted the feat/event-core-flags-docs branch October 29, 2026 19:49
dcramer added a commit that referenced this pull request Oct 29, 2026
Item 2 of #2362 ("Reject filters that cannot match"). Refs #2362. This
PR does not close the issue.

## What changes

Before this change, you could save a filter on a field that a selected
event never sets, such as a pull request field on a `deployment.*`
event. The trigger then never matched, and nothing told you why.

- **Plugin API:** A match-field schema can list the `events` that set
the field. `eventTriggerProblems`
(`packages/junior-plugin-api/src/event-triggers.ts`) is the one check
for a selection of resource type, events, and filters. It also reports
an unknown resource type, so core and the dashboard use the same
function. `mergeEventMatchFields` merges the match fields of resource
types that share a parent, such as a repository. It unions the `events`
lists and throws when two copies of one field have a different kind,
enum, or list.
- **Core:** Event automations (the tools and the dashboard API) and
`watchEvents` run the check (`requireValidEventTrigger` in
`chat/events/catalog.ts`) before they save. It replaces
`pluginSupportsEvent` and `requireSupportedEventMatch`, which this PR
deletes. Agent errors name the filter and its input key, such as `Filter
"base" (match.base)`, and use the plugin display name, such as "This
GitHub pull request trigger cannot be saved." Watch errors say "watch
cannot be created".
- **Core limits (#2379) are unchanged:** Event automations still run the
check against `automationEventCatalog`, so resource types with
`automation: false` (Workspace snapshots, timers) stay out of
automations and report unavailable when saved. `watchEvents` still
checks `eventWatchUnavailable` first, so `watch: false` resource types
(timers, Slack channels) keep their `watchUnavailableMessage` text.
- **Saved triggers:** A saved trigger with a problem, such as the old
`authorUsername` filter, now reports **unavailable**. The problems go to
the dashboard (`triggerProblems`), the Slack details "Needs attention"
field, and the event automation tool results (`trigger.problems`). The
SQL rule for the dashboard list ("Unavailable" filter and attention
count) matches `eventTriggerProblems`.
- **Dashboard:** The editor uses the shared check and hides filters that
the selected events do not set. The stale saved trigger keeps the "Saved
trigger · Kept unchanged" notice with its problem list. The editor and
details say "Filters", not "Only when" or "conditions".
- **GitHub:** Each match field lists the events that set it. The
repository resource type merges them with `mergeEventMatchFields`, so a
shared key such as `senderId` keeps every event that sets it. A new test
runs full webhook deliveries for every repository event (deployments,
issues, issue and pull request comments, pull request lifecycle,
reviews, review comments, and check suites) through
`normalizeGitHubEvents` and the lazy lookups in
`webhooks/pull-request-match-data.ts`. It fails when an event sets a
filter that its `events` list omits, or when a list names an event that
never sets it. Linear, Sentry, Vercel, and Slack fields need no changes.

## Decisions

- **Strict rule:** Every selected event must set a filtered field. If
one selected event does not set the field, the save fails. A loose rule
("at least one event sets it") would let a trigger silently skip some of
its events.
- **Saved triggers with problems report unavailable:** This reverses the
earlier choice to keep them available. We do not change or delete them.
They keep their stored values and stay editable. They do not work as
saved: a filter that one selected event does not set never matches that
event, and a renamed resource type no longer fits the catalog. The
dashboard, Slack, and the agent now show each problem and the events it
affects, so the owner can fix the trigger.

## Checks

The branch is rebased on `main` after #2379. Two conflicts, both
resolved:

- `chat/events/catalog.ts`: the registration type keeps both
`displayName` (this PR) and the core-only `limits` map (#2379).
- `chat/event-automations/tool-support.ts`:
`eventAutomationTriggerAvailable` uses the shared problem check, which
already runs against `automationEventCatalog`.

No `pluginSupportsEvent` or `requireSupportedEventMatch` callers remain.

- `pnpm lint`: passed
- Typecheck: passed for `junior`, `junior-plugin-api`, `junior-github`,
`junior-dashboard`, `junior-linear`, `junior-vercel`
- `junior-github` tests: 254 passed, with the new declaration test
- `junior` unit tests: 1580 passed
- `junior` integration tests for automations, watches, events,
annotation cards, and Slack details (10 files): 62 passed, 1 failed. The
failure is `event-automations` "delivers the current automation card".
It fails the same way on `main` in this sandbox, so this branch does not
cause it.
- `automation-edits` saves a renamed GitHub filter directly. It checks
that the summary reports `triggerAvailable: false` with the problem, and
that the "Unavailable" list returns the Automation.
- Dashboard automation e2e (`automations.spec.ts`): 5 passed

<!-- junior-session-footer:start -->
<!-- junior-conversation-id:agent%3A2abc167b95b6a7f447d97f23b8b73a01 -->

--

[View Junior
Session](https://junior-prod.sentry.dev/conversations/agent%3A2abc167b95b6a7f447d97f23b8b73a01)
[[Sentry]](https://sentry.sentry.io/explore/conversations/agent%3A2abc167b95b6a7f447d97f23b8b73a01/?project=4510944073809921)

<!-- junior-session-footer:end -->

---------

Co-authored-by: sentry-junior[bot] <264270552+sentry-junior[bot]@users.noreply.github.com>
Co-authored-by: David Cramer <[email protected]>
dcramer added a commit that referenced this pull request Oct 29, 2026
…2385)

Stacked on #2381. Item 4 of #2362: how event triggers show in the
dashboard and Slack.

## What changed

There is now **one shared trigger description** in
`packages/junior-plugin-api/src/event-triggers.ts`:

```ts
interface EventTriggerDescription {
  events: string[];   // "pull request opened"
  filters: string[];  // "authors includes alice", "base is main or release"
  problems: string[]; // why the saved trigger cannot work
}
```

- `describeEventTrigger(resourceTypes, selection)` builds it. It takes
the resource types of the source, like `eventTriggerProblems`.
- `problems` are the messages of #2381's `eventTriggerProblems`. So
every surface shows the same words as the save check. This includes the
unknown resource type and "The plugin for this source is not enabled."
- A `list: true` field reads "includes X". List values on a normal field
read "is X or Y".
- `eventTriggerText(resource, description)` writes one line for cards
and lists: `Pull request · pull request opened · filters: isDraft is
false`.
- Core wraps this as `describeRegisteredEventTrigger(catalog,
selection)` in `chat/events/catalog.ts`.
`describeEventAutomationTrigger(trigger, catalog)` in
`event-automations/tool-support.ts` applies the automation catalog
(`automation: false` resource types from #2379 are left out).

## API (hard cutover)

- The event automation summary now returns `trigger:
EventTriggerDescription`. It no longer returns raw `events`, `match`,
`triggerAvailable`, or `triggerProblems`.
- **`triggerAvailable` is removed** from the summary and the edit
response. A trigger is unavailable when `trigger.problems` is not empty.
No consumer of the edit response used it.
- `eventAutomationTriggerProblems` and `eventAutomationTriggerAvailable`
are replaced by `describeEventAutomationTrigger`.
- The agent tool result keeps its own `trigger.available` and
`trigger.problems`. It now gets them from the same description.

## Surfaces

All of these use the shared description now, and their old formatting
code is removed:

- **Dashboard list row**: one line from `eventTriggerText`. Unavailable
comes from `trigger.problems`.
- **Dashboard details and the read-only view**: event names plus a new
`TriggerFilters` list ("Every filter must match:", or "No filters. Runs
on every selected event."). The read-only view no longer shows a JSON
dump.
- **Dashboard status**: lists the saved trigger's problems with "Edit
the trigger to fix it."
- **Dashboard editor**: event checkboxes and list values use the shared
words. Agent guidance under events is removed. The stale-trigger notice
shows the saved trigger in words, not JSON. The text says "filter"
everywhere.
- **Dashboard version history**: each Event version shows its events and
filters with `TriggerFilters`, not raw JSON.
- **Slack card** (`eventAutomationToolResult`): `eventTriggerText`
replaces the raw `key = "json"` strings. Status and warning come from
`problems`.
- **Slack details** (`automation-details.ts`): a new **Filters** field.
Status and **Needs attention** come from `trigger.problems`.

Identifier display is out of scope. Structured identifier parts are
#2362 item 6.

## Version history

Each Event version in the version list API now also has `trigger:
EventTriggerDescription`. The server builds it with the enabled plugins.
The saved `definition` stays raw, so "make active" still posts it back
unchanged. The new `listedAutomationVersionSchema` holds one list item.
The stored `automationVersionSchema` is unchanged.

## Verification

Rebased on #2381 at `7d3ed7ed9` (after #2379 merged). CI runs only for
PRs into `main`, so these checks ran locally.

- `pnpm typecheck` and `pnpm lint` pass.
- Vitest: `unit/events/*`, `integration/api/automations`,
`integration/api/automation-edits`,
`integration/slack/automation-details-webhook`, and the dashboard suite
(320 tests) pass.
  - `unit/events/match.test.ts` has representative formatter cases.
- `integration/api/automation-edits` checks the version list
descriptions: one clean trigger and one with a problem.
- `integration/event-automations.test.ts`: 14 of 15 pass. "delivers the
current automation card" fails on the generated title in my sandbox. It
fails the same way on the bare #2381 branch, so this change does not
cause it. Its trigger-line assertion passes.
- Dashboard e2e: `automations.spec.ts` and `automation-editor.spec.ts`
pass (9 of 9). The unavailable-trigger scenario checks the problem text.

<!-- junior-request-attribution:start -->
via **David Cramer**.
<!-- junior-request-attribution:end -->

<!-- junior-session-footer:start -->
<!-- junior-conversation-id:agent%3A05172b2fc7efb1362b221426bec7e50b -->

--

[View Junior
Session](https://junior-prod.sentry.dev/conversations/agent%3A05172b2fc7efb1362b221426bec7e50b)
[[Sentry]](https://sentry.sentry.io/explore/conversations/agent%3A05172b2fc7efb1362b221426bec7e50b/?project=4510944073809921)

<!-- junior-session-footer:end -->

Co-authored-by: sentry-junior[bot] <264270552+sentry-junior[bot]@users.noreply.github.com>
Co-authored-by: David Cramer <[email protected]>

This branch was successfully deployed

1 active deployment
Preview – junior-docs — 4bd4937c Deployed Oct 29, 2026 by vercel[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

risk: high PR risk score: high

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant