Skip to content

test(registry-feed): filter assertions by actor to fix OR-filter flake (closes #4413)#4414

Open
bokelley wants to merge 1 commit into
mainfrom
bokelley/registry-feed-flake-fix
Open

test(registry-feed): filter assertions by actor to fix OR-filter flake (closes #4413)#4414
bokelley wants to merge 1 commit into
mainfrom
bokelley/registry-feed-flake-fix

Conversation

@bokelley
Copy link
Copy Markdown
Contributor

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

  • Local run against a fresh Postgres: `10/10 tests pass in registry-feed.test.ts` (was 9/10 with the OR test failing).
  • Typecheck clean, no other test files touched.
  • Pattern matches what the file's other tests already use, so future readers won't be surprised.

Closes #4413.

🤖 Generated with Claude Code

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>
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.

Flake: registry-feed.test.ts 'combines multiple type filters with OR' — unfiltered queryFeed picks up background crawler events

1 participant