Skip to content

fix(search): resolve project roles once, check MCP project filters - #455

Merged
M0Rf30 merged 1 commit into
openartifact:mainfrom
orcamedia:fix/search-project-filter-followups
Nov 9, 2026
Merged

M0Rf30 merged 1 commit into
openartifact:mainfrom
orcamedia:fix/search-project-filter-followups

Conversation

@orcamedia

Copy link
Copy Markdown
Contributor

The two non-blocking nits from the review of #454.

Resolve roles once. ProjectScope.NarrowToProjects now also returns whether the caller holds a project role (what UsesProjects reports), since it resolves the roles anyway. On a project-filtered search that is too broad, the HTTP handler and search_artifacts reuse that value for the project:<project> hint instead of calling UsesProjects again. Unfiltered too-broad searches still call UsesProjects once.

Same filter rules on MCP. search.CheckProjectFilters holds the project_role and 50-value rules. GET /api/v1/search uses it (still 400 invalid_filter), and search_artifacts now applies it before any lookup, as a tool error the model can read. Besides the cap, this also covers an unknown role on MCP, which was accepted before: project_role:Viewer silently matched nothing. docs/integrations/mcp.md now lists the qualifiers search_artifacts takes.

One small message change on HTTP: too many format / repo values is "too many format or repo filters" again (as before #454), and too many project / project_role values is "too many project or project_role filters". The code stays invalid_filter.

Tests

  • internal/search/project_filter_test.go: CheckProjectFilters (every role, unknown and wrong-case roles, 50 vs 51 values of each).
  • internal/mcp/search_projects_test.go: a project-filtered too-broad search narrows once and doesn't resolve roles again, with the hint following the narrowing's answer; an unknown role and 51 values of each are tool errors and never reach the scope. Both tests fail if the reuse or the check is removed.
  • The HTTP side follows the same pattern but isn't counted directly: the handler's unit harness can't count role lookups, and an integration test would need more than 10,000 matches. Its existing tests (400 for unknown roles and the cap, hints, the integration suite) pass unchanged.

Checked locally: make check, the unit suite with -race, the slim suite, and go test -tags integration ./internal/search/.

🤖 Generated with Claude Code

Follow-up to the review of openartifact#454:

- ProjectScope.NarrowToProjects also returns whether the caller holds a
  project role. On a project-filtered search that is too broad, the HTTP
  handler and the MCP search tool reuse it for the project:<project> hint
  instead of resolving the caller's roles a second time.
- search.CheckProjectFilters holds the project_role and 50-value rules.
  GET /api/v1/search answers them with 400 invalid_filter as before, and
  the MCP search tool now applies them too, as a tool error: an unknown
  project_role or more than 50 project: / project_role: values used to be
  accepted there (a typo silently matched nothing).
- docs/integrations/mcp.md: the qualifiers search_artifacts takes.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@M0Rf30
M0Rf30 merged commit 610fbf2 into openartifact:main Nov 9, 2026
23 checks passed
@M0Rf30 M0Rf30 mentioned this pull request Nov 9, 2026
@orcamedia
orcamedia deleted the fix/search-project-filter-followups branch November 11, 2026 10:45
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