Skip to content

feat(api): search service to list filter values - #2121

Merged
akijakya merged 6 commits into
mainfrom
feat/searchservice-listrecordvalues
Sep 9, 2026
Merged

akijakya merged 6 commits into
mainfrom
feat/searchservice-listrecordvalues

Conversation

@akijakya

@akijakya akijakya commented Sep 8, 2026 •

Copy link
Copy Markdown
Member

SearchService had no way to enumerate the distinct values present in the registry for a record field, so a client building a filter panel had to fetch every record and aggregate them itself — exactly what pagination is meant to avoid. The only distinct-values query that existed, AIFinderService.ListTags, sat behind the AI Catalog projection and was shaped for the catalog UI.

What this adds

SearchService.ListFilterValues, reusing RecordQueryType as the field selector so no new field vocabulary is introduced.

rpc ListFilterValues(ListFilterValuesRequest) returns (ListFilterValuesResponse);

Supported fields: SKILL_NAME, MODULE_NAME, DOMAIN_NAME, AUTHOR, SCHEMA_VERSION. The name variants are used rather than the numeric *_ID types so every value is a human-meaningful string.

Values are returned verbatim in the form a RecordQuery accepts, so they feed straight back into SearchCIDs, SearchRecords, or CountRecords — a value from a filter panel can never produce an empty result, because it is there only if some record carries it. Values are registry-wide, with no catalog module restriction and no query context.

Response entries mirror the order the fields were requested in; an empty request returns every supported field ordered by ascending RecordQueryType number. Requesting an unsupported type fails with InvalidArgument naming the supported set, rather than silently omitting it.

Placed on SearchService rather than the catalog for the same layering reason as CountRecords (#1939): a general capability belongs on the general API. It is immediately callable by every client, since SearchServiceClient is already embedded in client.Client. No REST endpoint is added — the HTTP gateway registers only AIFinderService.

Behavior change: GET /v1/tags no longer returns annotations

ListCatalogTags now derives tags from OASF skills and domains only. Record annotations are free-form per-deployment metadata with unbounded cardinality, which makes them noise in a discovery panel.

Annotations remain filterable: tag filters still parse annotation tags, and CatalogEntry.Tags still carries per-record annotations, so only the global discovery list is affected. No UI change was needed — the catalog UI renders whatever /v1/tags returns.

This also completes the consolidation the issue asked for. Rather than growing ListFilterValues into a superset of ListTags, dropping annotations made ListTags a subset, so both surfaces now share one distinct-values helper and cannot disagree about which values the registry holds.

Notes for review

Authors are the one field with no schema support. They are a JSON array on records rather than a child table, so they cannot be plucked with a plain DISTINCT. The array is unnested in Go rather than with SQL JSON functions, keeping one code path across the SQLite and Postgres backends instead of json_each versus jsonb_array_elements_text. DISTINCT still collapses records sharing an author list before the payloads reach Go. Unparsable payloads are logged and skipped so one malformed record cannot fail the whole call. No migration is required.

VERSION is deliberately unsupported. A record's own version is per-record identity rather than a shared facet, so a registry-wide distinct list grows with the registry and answers no question a filter panel asks. It becomes meaningful only with a query context scoping it to one record, which this RPC does not take. Removing it before release is cheap; removing it after would break callers.

LOCATOR is deliberately unsupported pending the locator refactor in agntcy/oasf#493.

Both omissions are additive to reverse: the request is a repeated enum and the response is keyed by field, so adding a field later breaks nothing.

Response size is bounded only by convention, tracked in #2124. AUTHOR is the one field whose value count grows with the registry, so a large enough registry produces a response no client can receive. It is deferred rather than fixed here because a per-field cap or page tokens are both backward-compatible additions; only a unary-to-streaming switch would be foreclosed, and streaming does not help since the limit is enforced per message and AUTHOR is a single message.

Author values now round-trip correctly, which required fixing two pre-existing defects surfaced by this RPC. The author filter compared a caller's decoded value against the raw serialized JSON array, so any author containing a character encoding/json escapes — quotes, backslashes, and by default &, <, > — matched nothing. Separately, convertGlobToLike built conditions declaring ESCAPE '\' without escaping literal backslashes in the pattern, so each escape swallowed the byte after it. Both are fixed at the filter layer, which repairs every wildcard filter rather than only authors.

Testing

Unit tests cover the DB layer (per-field distinct values, dedup across records, author flattening, records missing an optional field, empty registry, unsupported field) and the controller (field pass-through, request-order preservation, InvalidArgument before the database is touched, error wrapping).

Verified manually against a local dirctl daemon: all five fields return real values, subset requests preserve order, unsupported fields are rejected, returned values round-trip into CountRecords, and an annotated record confirms team=platform is absent from ListTags while tags="team=platform" still filters ListAgents to that record.

Closes #2012

@akijakya akijakya self-assigned this Sep 8, 2026
@akijakya
akijakya requested a review from a team as a code owner September 8, 2026 10:12
@github-actions

github-actions Bot commented Sep 8, 2026 •

Copy link
Copy Markdown
Contributor

The latest Buf updates on your PR. Results from workflow Buf CI / verify-proto (pull_request).

BuildFormatLintBreakingUpdated (UTC)
✅ passed⏩ skipped⏩ skipped✅ passedSep 9, 2026, 9:54 AM

@github-actions github-actions Bot added the size/M Denotes a PR that changes 200-999 lines label Sep 8, 2026
@codecov

codecov Bot commented Sep 8, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 32.05128% with 53 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
server/database/gorm/filter_values.go 6.0% 47 Missing ⚠️
server/database/gorm/catalog.go 0.0% 4 Missing ⚠️
server/types/search.go 0.0% 2 Missing ⚠️

📢 Thoughts on this report? Let us know!

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🟡 Changes recommended

The author round-trip bug, unbounded response, and duplicate-field amplification must be resolved.

Once you've addressed the issues Copilot identified, you can request another Copilot review.

Pull request overview

Adds registry-wide filter-value discovery to SearchService and limits catalog tag discovery to OASF skills and domains.

Changes:

  • Adds the ListFilterValues RPC and generated bindings.
  • Implements distinct-value queries for five record fields.
  • Removes annotations from catalog tag discovery.
  • Adds controller and database coverage.

Required fixes:

  • Critical (2 votes): Author values containing JSON-escaped characters do not round-trip into record queries.
  • Moderate (1 vote): The unbounded response may exceed the server’s 4 MiB message limit; add pagination, continuation, or streaming.
  • Moderate (1 vote): Duplicate requested fields cause repeated registry scans and duplicated response data; reject or deduplicate them.
File summaries
File Description
server/types/search.go Defines supported fields and result types.
server/types/database.go Extends the database interface.
server/database/gorm/filter_values.go Implements distinct-value queries and author flattening.
server/database/gorm/catalog.go Reuses distinct queries and excludes annotations.
server/database/database_test.go Tests database behavior.
server/database/catalog_test.go Updates catalog-tag expectations.
server/controller/search.go Implements and validates the RPC.
server/controller/search_test.go Tests controller behavior.
server/controller/ai_finder_test.go Updates catalog response tests.
reconciler/tasks/signature/task_test.go Updates the database test double.
proto/agntcy/dir/search/v1/search_service.proto Defines the new RPC and messages.
CHANGELOG.md Documents API and behavior changes.
api/search/v1/search_service.pb.go Updates generated protobuf messages.
api/search/v1/search_service_grpc.pb.go Updates generated gRPC bindings.
Review details

Files not reviewed (2)

  • api/search/v1/search_service.pb.go: Generated file
  • api/search/v1/search_service_grpc.pb.go: Generated file
  • Files reviewed: 12/14 changed files
  • Comments generated: 3
  • Review effort level: Balanced

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread server/database/gorm/filter_values.go Resolved
Comment thread server/controller/search.go Resolved
Authors are stored JSON-encoded, so encoding/json escapes quotes, backslashes
and, by default, &, < and >. Two defects meant a value could be listed by
ListFilterValues but match no record when fed back into a query.

The author filter compared a caller's decoded value against the raw serialized
array, so `Jane "JJ" Doe` and `A & B Corp` never matched. The pattern is now
JSON-encoded first, against the same representation the column stores.
Wildcards survive the encoding untouched, so pattern semantics are unchanged.

convertGlobToLike built conditions declaring ESCAPE '\' but never escaped
literal backslashes in the pattern, so each escape swallowed the following byte
and & degraded to u0026. Fixed there rather than at the call site, which
repairs every wildcard filter rather than just authors.

Both defects predate ListFilterValues; surfacing values that then match nothing
is what made them reachable.

Also reject duplicate fields in ListFilterValues with InvalidArgument. Each
repeat cost another registry scan and another copy of that field's values, and
requesting the same facet twice has no meaning.

Refs #2012

Signed-off-by: András Jáky <[email protected]>
@akijakya
akijakya force-pushed the feat/searchservice-listrecordvalues branch from 81bcf14 to 2dc0d6f Compare September 9, 2026 09:54
@akijakya
akijakya enabled auto-merge (squash) September 9, 2026 09:54
@akijakya
akijakya merged commit 6e57846 into main Sep 9, 2026
34 checks passed
@akijakya
akijakya deleted the feat/searchservice-listrecordvalues branch September 9, 2026 10:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size/M Denotes a PR that changes 200-999 lines

Projects

None yet

Development

Successfully merging this pull request may close these issues.

SearchService: add ListRecordValues RPC for distinct filter values

3 participants