Skip to content

Filter archived realms from federated search (CS-11666)#5357

Merged
lukemelia merged 3 commits into
mainfrom
cs-11666-federated-search-excludes-archived-realms-server-client
Jun 30, 2026
Merged

Filter archived realms from federated search (CS-11666)#5357
lukemelia merged 3 commits into
mainfrom
cs-11666-federated-search-excludes-archived-realms-server-client

Conversation

@lukemelia

@lukemelia lukemelia commented Jun 29, 2026

Copy link
Copy Markdown
Contributor

Summary

A federated search payload that names an archived realm must not return hits. The mechanism is the enumeration filter in fetchUserPermissions: once a realm is archived, the requester has no permission for it per the filtered enumeration, so multi-realm-authorization short-circuits the request with 403 before handle-search runs. The handler does no extra work.

This PR adds one integration test on /_federated-search that pins the contract end-to-end:

  • A payload that names an archived realm returns 403, with the archived realm URL named in the error.
  • The same request restricted to active realms returns hits normally.

The test exercises the full stack (handle-searchmulti-realm-authorizationfetchUserPermissionsrealm_metadata.archived_at), so a refactor of the enumeration layer can't silently weaken the federated-search contract.

Client-side backstop — deferred

_realm-auth doesn't carry archived realms, so the host's availableRealmURLs doesn't include them and a client-side filter is redundant. Deferred to a follow-up if a concrete reason emerges.

Test plan

  • pnpm test in packages/realm-server (server-endpoints/search-test) — requires Docker for the test PG; will verify in CI.

@lukemelia lukemelia force-pushed the cs-11666-federated-search-excludes-archived-realms-server-client branch from 18620a0 to 032f6c1 Compare June 29, 2026 17:09
@lukemelia lukemelia changed the base branch from main to cs-11665-enumeration-omits-archived-realms-from-_realm-auth-realm June 29, 2026 17:09
@lukemelia lukemelia force-pushed the cs-11666-federated-search-excludes-archived-realms-server-client branch from 032f6c1 to 8bbd247 Compare June 29, 2026 17:14
@lukemelia lukemelia force-pushed the cs-11665-enumeration-omits-archived-realms-from-_realm-auth-realm branch from 013586f to f064e56 Compare June 29, 2026 17:19
The original CS-11666 plan filtered archived realms inside handle-search.
That filter is subsumed by the enumeration filter added in CS-11665
(#5358): once a realm is archived, the requester has no permission
for it per fetchUserPermissions, so multi-realm-authorization 403s
the request before handle-search runs. Drop the redundant handler-
level filter and the bulk fetchArchivedRealmURLs helper that fed it.

Keep one integration test on the federated-search endpoint to pin the
user-facing contract: a federated search payload that names an
archived realm gets 403, and the same request restricted to active
realms still searches normally. The test exercises the full stack
(handle-search → multi-realm-auth → fetchUserPermissions →
realm_metadata.archived_at) so a future refactor of the enumeration
layer can't silently weaken it.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@lukemelia lukemelia force-pushed the cs-11666-federated-search-excludes-archived-realms-server-client branch from 8bbd247 to 894b79a Compare June 29, 2026 17:19
@github-actions

github-actions Bot commented Jun 29, 2026

Copy link
Copy Markdown
Contributor

Host Test Results

67 tests   66 ✅  2m 58s ⏱️
 1 suites   1 💤
 1 files     0 ❌

Results for commit 14bf8fa.

Realm Server Test Results

    1 files      1 suites   11m 16s ⏱️
1 687 tests 1 687 ✅ 0 💤 0 ❌
1 766 runs  1 766 ✅ 0 💤 0 ❌

Results for commit 14bf8fa.

@lukemelia lukemelia changed the base branch from cs-11665-enumeration-omits-archived-realms-from-_realm-auth-realm to main June 30, 2026 01:58
The exact-key-set assertion picked up '*: read' system-realm
permissions (boxel-homepage, catalog, openrouter, …) seeded by
migrations into the template DB, since the public-read arm of
fetchUserPermissions surfaces those for every user.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@lukemelia lukemelia marked this pull request as ready for review June 30, 2026 16:52
…arch-excludes-archived-realms-server-client

# Conflicts:
#	packages/realm-server/tests/queries-test.ts

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR pins the federated-search authorization contract that archived realms must be rejected at the auth boundary (via fetchUserPermissions’ archived-realm filter) rather than returning any search hits.

Changes:

  • Add an integration test for /_federated-search verifying that including an archived realm in the realms payload returns 403 and names the archived realm URL in the error.
  • Add a companion assertion that the same query restricted to an active realm still returns results normally.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@lukemelia lukemelia merged commit c6ca06b into main Jun 30, 2026
93 of 94 checks passed
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.

2 participants