test(registry-feed): filter assertions by actor to fix OR-filter flake (closes #4413)#4414
Open
bokelley wants to merge 1 commit into
Open
test(registry-feed): filter assertions by actor to fix OR-filter flake (closes #4413)#4414bokelley wants to merge 1 commit into
bokelley wants to merge 1 commit into
Conversation
closes #4413) queryFeed has no actor filter (by design — the public feed contract doesn't expose actor). The catalog_events table is shared with the background crawler and other test files that write non-`test%` events, so the assertion-side filter is the right surface to scope to this file's seed. Brings the four `type glob filtering` assertions in line with the pattern the file's other tests already use at lines 57 and 78. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes the flake in `server/tests/integration/registry-feed.test.ts > Registry Feed Integration Tests > type glob filtering > combines multiple type filters with OR` that's been failing on `main` and every PR (example failing run on main, example on PR #4412).
Root cause
The four assertions in the `type glob filtering` describe block were checking `feed.events` length directly. `queryFeed` has no actor filter — by design, since actor isn't part of the public feed contract — so when other test files (the background crawler in particular, which the server boots at integration test start) write `property.` or `agent.` events with non-`test%` actors, those events end up in the result and skew the count.
The file already filters by actor in two earlier tests (line 57: `feed.events.filter(e => e.actor.startsWith('test'))`; line 78: `feed.events.filter(e => e.actor === 'test')`) precisely because the cleanup hook (`DELETE FROM catalog_events WHERE actor LIKE 'test%'`) is intentionally scoped — see the comments at lines 19-23 explaining sibling test files writing trigger-generated events with `actor LIKE 'trigger:%'`.
The OR-filter assertion has the lowest noise tolerance because its expected count (4) is closest to what crawler-written events can push the unfiltered total to (consistently observed as 9 = 4 seeded + 5 crawler-leaked). The narrower filter assertions in the same block (expected 1 and 3) happen to pass because their type filters don't catch the crawler's event types as aggressively.
Fix
Add an `ours` helper that filters by actor before counting, applied to all four assertions in the describe block:
```ts
const ours = (events: { actor: string }[]) =>
events.filter(e => e.actor.startsWith('test'));
```
This makes all four assertions robust to whatever the leak source is, without changing what they test — they were always testing "my seeded events + this filter", which is what the new assertions check explicitly.
Test plan
Closes #4413.
🤖 Generated with Claude Code