Skip to content

feat(dir): add DB-backed SearchService.ListRecordSummaries - #2328

Merged
akijakya merged 10 commits into
mainfrom
feat/list-record-summaries
Oct 14, 2026
Merged

akijakya merged 10 commits into
mainfrom
feat/list-record-summaries

Conversation

@akijakya

Copy link
Copy Markdown
Member

Summary

Adds SearchService.ListRecordSummaries, a unary RPC that pages through records straight from the database and never pulls from the OCI store, so list-style clients (lazydir, CLIs, scripts) get the same instant paginated listing the AI Catalog UI has. To make that possible without duplicating SQL, the filtered-record query that lived inside GetCatalogEntries is extracted into a shared layer that the catalog and both counts are now built on.

Changes

  • Shared query layer (server/database/gorm/record_query.go): recordQuery(cfg) applies all RecordFilters (including exclusions and the policy gate) via handleFilterOptions; pageRecords(query, cfg, order, preloads...) adds DISTINCT, preloads, caller-supplied ordering, offset and limit+1 peek-ahead; countRecords(query) counts distinct records.
  • Refactor, no behaviour change: GetCatalogEntries, CountCatalogEntries and CountRecords are rebuilt on the shared layer. The catalog-only filters (known modules, media type, tags) live in one catalogQuery helper shared by listing and counting. Only two internal error strings changed wording ("query catalog records" → "query records", "count catalog records" → "count records"); nothing matches on them.
  • API: new ListRecordSummaries(ListRecordSummariesRequest) returns (ListRecordSummariesResponse) taking queries, limit, offset, sort_mode, returning records, has_more and total_count. RecordSummary carries cid, name, version, schema version, description, OASF created_at, and sorted authors / skill / domain / module names.
  • Server: DB method ListRecordSummaries maps preloaded rows to summaries; the controller defaults the page size to 50 and clamps it to 100, takes total_count from the existing CountRecords with the same filters, and returns gRPC context status on cancellation.
  • SearchRecords is unchanged for callers that need full records.

Why

SearchRecords resolves a page of CIDs from the database, then pulls each record from the OCI store sequentially before streaming it. Against ads.outshift.io that is ~200 ms per record (~10–12 s for 50), while CountRecords / ListFilterValues take ~165 ms and ListAgents is instant because it answers from the database only. List clients only need fields the database already indexes, so the pulls are pure overhead for them.

Testing

  • New unit tests for the shared helpers (peek-ahead boundary, JOIN dedupe for page and count, preloads, offset stability, both default orderings, usage-metric ordering), the summaries query (field mapping incl. OASF created_at, sorted non-nil lists, positive and negated filters, popularity sort, JOIN filter combined with popularity sort, policy gate, limit default/clamp) and the controller (query translation, limits, offset, sort mapping, total_count, error paths, cancelled context).
  • Existing catalog, count and policy-gate tests pass unchanged; task lint, task lint:buf and task test:unit pass.
  • Live check against a daemon built from this branch (SQLite): correct fields, has_more / offset paging, clamping and skill filtering, ~1 ms per warm call.

Notes for reviewers

  • PostgreSQL was not exercised at runtime (unit tests and the live check use SQLite). The SQL shapes match ones already running on Postgres: SELECT DISTINCT records.* with preloads as in GetCatalogEntries, and the usage-metric COALESCE expressions in the select list for popularity / provider-count ordering as in GetRecordCIDs.
  • The default SORT_MODE_RECENCY orders by when this registry indexed the record (same as SearchRecords), not by the record's OASF created_at; the request field docs say so.
  • Deployments with explicit authz rules for search methods (e.g. the OpenShift sample policies) will need to allow ListRecordSummaries.
  • The page and total_count come from two queries, so the total can drift slightly under concurrent writes, as with ListAgents.

Closes #2259

@akijakya
akijakya requested a review from a team as a code owner October 12, 2026 13:43
@akijakya akijakya added kind/feature Categorizes issue or PR as related to a new feature. area/dir/server area/dir/api labels Oct 12, 2026
@github-actions

github-actions Bot commented Oct 12, 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✅ passedOct 14, 2026, 8:04 AM

@github-actions github-actions Bot added the size/L Denotes a PR that changes 1000-1999 lines label Oct 12, 2026
@akijakya
akijakya requested a balanced review from Copilot October 12, 2026 13:52

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

Request cancellation is not propagated to database work, and documented OpenShift authorization policies omit the new RPC.

2 open findings
What changed in this PR

Adds fast, database-backed paginated record summaries without OCI pulls.

Changes:

  • Adds the ListRecordSummaries RPC and generated bindings.
  • Extracts shared filtered paging/counting queries.
  • Adds database/controller tests and documentation.
File Description
server/​types/​search.go Defines summary page limits.
server/​types/​database.go Extends the search database API.
server/​database/​gorm/​record.go Reuses shared count/order helpers.
server/​database/​gorm/​record_summaries.go Maps database records to summaries.
server/​database/​gorm/​record_summaries_test.go Tests summary listing behavior.
server/​database/​gorm/​record_query.go Implements shared paging/counting queries.
server/​database/​gorm/​record_query_test.go Tests shared query behavior.
server/​database/​gorm/​catalog.go Refactors catalog queries onto shared helpers.
server/​controller/​search.go Implements the RPC controller.
server/​controller/​search_test.go Tests request translation and errors.
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 Announces the RPC.
api/​search/​v1/​search_service.pb.go Adds generated protobuf types.
api/​search/​v1/​search_service_grpc.pb.go Adds generated gRPC bindings.
Files not reviewed (2)
  • api/search/v1/search_service.pb.go: Generated file
  • api/search/v1/search_service_grpc.pb.go: Generated file

🧠 Review effort: Balanced


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

Comment thread server/controller/search.go Resolved
@codecov

codecov Bot commented Oct 12, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 95.57522% with 5 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
server/database/gorm/record_query.go 90.6% 3 Missing ⚠️
server/database/gorm/catalog.go 91.7% 1 Missing ⚠️
server/database/gorm/record_summaries.go 97.2% 1 Missing ⚠️

📢 Thoughts on this report? Let us know!

ramizpolic
ramizpolic previously approved these changes Oct 13, 2026

@ramizpolic ramizpolic left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

LGTM

…nt queries

Add recordQuery (filters + policy gate), pageRecords (DISTINCT records.*
page with caller-supplied ordering, preloads and Limit+1 peek-ahead) and
countRecords (distinct CID count with uint32 guard). Rebuild
GetCatalogEntries, CountCatalogEntries and CountRecords on them with no
behaviour change, so later work can page records straight from the DB.

Signed-off-by: András Jáky <[email protected]>
Add a unary RPC returning paginated, database-backed record summaries
with has_more and total_count. It never pulls from the store. Generated
Go code regenerated via task api:gen.

Signed-off-by: András Jáky <[email protected]>
Add SearchDatabaseAPI.ListRecordSummaries, built on the shared record
query layer (recordQuery + pageRecords). It defaults the limit to 50 and
clamps it to 100 (exported constants in server/types), maps records to
RecordSummary using the OASF created_at, and returns sorted, non-nil
name lists. Fakes implementing the interface get stubs.

Signed-off-by: András Jáky <[email protected]>
Serve record summaries from the database only. The controller applies the
default (50) and maximum (100) page size, maps sort mode, and fills
total_count via CountRecords using the same filters without paging.

Signed-off-by: András Jáky <[email protected]>
…rify ordering docs

Map an already-cancelled context to codes.Canceled, document that recency
orders by index time rather than created_at, cover the join-filter plus
popularity-sort dedupe case, and reuse orderNeedsUsageMetrics.

Signed-off-by: András Jáky <[email protected]>
@muscariello

Copy link
Copy Markdown
Member

@akijakya can you fix the conflict ?

@akijakya
akijakya force-pushed the feat/list-record-summaries branch from 0685de5 to fbb4747 Compare October 14, 2026 08:02
@akijakya
akijakya enabled auto-merge October 14, 2026 08:41
@akijakya
akijakya added this pull request to the merge queue Oct 14, 2026
Merged via the queue into main with commit 885c147 Oct 14, 2026
36 checks passed
@akijakya
akijakya deleted the feat/list-record-summaries branch October 14, 2026 09:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/dir/api area/dir/server kind/feature Categorizes issue or PR as related to a new feature. size/L Denotes a PR that changes 1000-1999 lines

Projects

None yet

Development

Successfully merging this pull request may close these issues.

SearchService: DB-backed paginated record summaries (shared query layer under ListAgents)

4 participants