Skip to content

feat(catalog): add POST /v1/extract for OASF taxonomy extraction - #2023

Merged
akijakya merged 2 commits into
mainfrom
feat/api-post-extract
Aug 14, 2026
Merged

akijakya merged 2 commits into
mainfrom
feat/api-post-extract

Conversation

@akijakya

@akijakya akijakya commented Aug 13, 2026 •

Copy link
Copy Markdown
Member

Summary

Adds POST /v1/extract to the AI Catalog gateway: free text in, the OASF skills and domains that text is closest to out, with the scores and tiers that ranked them.

Filtering the catalog by tags today assumes you already know the taxonomy. The tag filter bar matches tag names as substrings, so someone describing what they want — "analyzing customer support tickets" — finds nothing, because no tag is literally named that. The OASF extractor already solves this; it just wasn't reachable from the browser.

Against a local node with the in-process extractor:

$ curl -s -X POST localhost:8889/v1/extract -H 'Content-Type: application/json' \
    -d '{"text":"analyzing customer support tickets"}' | jq -c '.skills[], .domains[], {keywords}'
{"id":120601,"name":"business_professional/customer_support/support_operations","score":0.4577064254618,"tier":1}
{"id":1206,"name":"business_professional/customer_support","score":0.4149263584846215,"tier":2}
{"id":10703,"name":"natural_language_processing/analytical_reasoning/fact_verification","score":0.16474955703182106,"tier":5}
{"id":2001,"name":"retail_and_ecommerce/customer_experience","score":0.32395233196470585,"tier":1}
{"id":1604,"name":"telecommunications/telecom_operations","score":0.2565629784255472,"tier":2}
{"id":505,"name":"human_resources/hr_analytics","score":0.1409346399141616,"tier":9}
{"keywords":["analyzing","customer","support","tickets"]}

One commit, no behavior change to any existing surface. The handler reuses the extractor the gateway already resolves (#2002) — no new config, no new dependency, and nothing to turn on beyond what /v1/search will need anyway.

This is a passthrough, not a recommender

It returns what the extractor says and stops there. It does not search, does not rank records, and does not check whether any record in this registry actually carries a returned class. Consumers that need the suggestions to be actionable — #1908 is the first — should intersect against GET /v1/tags.

That boundary is what keeps the endpoint cheap to reason about: it has exactly one dependency and one failure mode.

Reviewing the tier numbers

The sample above contains a tier 5 and a tier 9 entry even though the handler asks for extractor.DefaultTiers (2). This looks like the tier ceiling is not being applied. It is — those entries come from somewhere else.

The SDK's selectCovered runs selectByTiers, which honors the ceiling, and then ensureVersionCoverage, which tops the list up until every in-scope taxonomy version has at least one covering entry. Its own comment says the top-up "may push the result past the selected tiers on purpose", so version-exclusive classes stay discoverable. The top-ups keep their true tier number.

A local asset dir provisioned from schema.oasf.outshift.com covers 0.7.0, 0.8.0, 1.0.0 and 1.1.0, so there is room for a few of them. Reading ScoredClass.Versions makes it obvious: when the tier 1–2 skills are all [1.1.0], the tier-5 entry is the one class covering [0.7.0 0.8.0 1.0.0]. Pinning the extractor to a single version makes them disappear entirely.

Two things that make the numbers look worse than they are: a tier boundary is a 3% relative score drop (defaultTierRatio = 0.97), so tier 9 is nine small steps rather than nine categories; and tiers are per-kind, so a skill tier and a domain tier are not comparable.

This is left as-is. Returning tier is what lets a consumer threshold, and dropping the top-ups here would be the endpoint editing the extractor's answer — the one thing it is supposed not to do. Note that nlsearch.Decompose does filter Tier <= maxTier, so dirctl search and POST /v1/search never see these entries while this endpoint does. That asymmetry is deliberate: search has to commit to a candidate set, this endpoint hands the decision to the caller.

Deliberate choices

  • Messages are ExtractTaxonomy{Request,Response}, not Extract{Request,Response} as [Feature]: Backend POST /v1/extract — expose OASF extractor output for tag recommendation #2001 sketched. RPC_REQUEST_STANDARD_NAME is not in buf.yaml's ignore list for this file, so the shorter name fails buf lint.
  • id and tier are uint32. protojson serializes 64-bit integer fields as JSON strings; the consumer is a browser, so a 32-bit field keeps them numbers. OASF uids are small enough that nothing is lost.
  • Keywords are returned as bare strings. They have no OASF class behind them, so there is no tier to place them in and nothing to threshold their score against. They are included for completeness; tag-oriented consumers should use skills and domains only.
  • Modules are dropped. They describe how a record is deployed rather than what it does, so they are not discovery labels and carry no catalog tag.
  • An empty result is a valid answer, not an error. This differs from POST /v1/search, which rejects a query it cannot decompose. There, zero results cannot distinguish "nothing matches" from "the query was not understood", and rephrasing fixes only the second. Here the extractor's own output is the answer, so "nothing close enough" is information rather than a dead end.
  • Text length is enforced in the handler. The service registers no protovalidate interceptor, so the proto's max_len: 1024 is not applied at runtime; enforced in code as ListAgents does with filterMaxLen, and checked before trimming so padding cannot smuggle a longer payload past it.
  • 503 when no extractor is configured, with a message naming the cause, so the UI can hide the feature rather than surface an error. Extractor failures return 503 too, with the backend detail left in the logs rather than the response.

Testing

  • 7 handler tests against a fake extractor, 10 cases counting subtests: result mapping including score and tier, empty result, modules excluded, no extractor configured, extractor failure, the four invalid-request shapes, and max-length checked before trimming
  • task lint — 0 issues across Go, Helm and buf; task test — no failures
  • JSON contract checked by posting through a grpc-gateway ServeMux, confirming id/tier emit as numbers, 400 for whitespace-only text, and 503 with no extractor wired
  • Exercised against a local dirctl daemon on :8889 with the in-process extractor backend

Not covered: extraction quality. The tests pin the mapping and the error paths, not whether the taxonomy matches are good.

Relationship to #2005

Based on main, deliberately not stacked on #2005 (POST /v1/search). The handler needs only the ext field that #2002 already wired, and nothing from the search fan-out, so the two can merge in either order.

Whichever lands second needs a small manual rebase: both branches append to the same proto service block, both rewrite the ext field and the WithExtractor doc comment in ai_finder.go, and both define a fakeExtractor in the same test package.

Closes #2001

@akijakya akijakya self-assigned this Aug 13, 2026
@akijakya
akijakya requested a review from a team as a code owner August 13, 2026 15:10
@github-actions

github-actions Bot commented Aug 13, 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✅ passedAug 13, 2026, 4:37 PM

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

codecov Bot commented Aug 13, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 45.16129% with 51 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
api/catalog/v1/ai_finder_service.pb.gw.go 0.0% 50 Missing and 1 partial ⚠️

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

Pull request overview

Adds POST /v1/extract, exposing OASF taxonomy extraction through the AI Catalog gateway.

Changes:

  • Defines the extraction RPC and HTTP route.
  • Maps extractor skills, domains, keywords, scores, and tiers.
  • Adds handler tests and generated API bindings.

Reviewed changes

Copilot reviewed 4 out of 7 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
server/controller/ai_finder.go Documents extractor injection behavior.
server/controller/ai_finder_extract.go Implements extraction and response mapping.
server/controller/ai_finder_extract_test.go Tests mapping, validation, and failures.
proto/agntcy/dir/catalog/v1/ai_finder_service.proto Defines the extraction API contract.
api/catalog/v1/ai_finder_service.pb.gw.go Adds generated HTTP gateway bindings.
api/catalog/v1/ai_finder_service.pb.go Adds generated protobuf messages.
api/catalog/v1/ai_finder_service_grpc.pb.go Adds generated gRPC bindings.
Files not reviewed (3)
  • api/catalog/v1/ai_finder_service.pb.go: Generated file
  • api/catalog/v1/ai_finder_service.pb.gw.go: Generated file
  • api/catalog/v1/ai_finder_service_grpc.pb.go: Generated file

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

Comment thread server/controller/ai_finder_extract.go Resolved
Comment thread server/controller/ai_finder_extract.go Resolved
Comment thread server/controller/ai_finder_extract.go Resolved
Comment thread server/controller/ai_finder_extract.go Resolved
@akijakya
akijakya merged commit 44d4676 into main Aug 14, 2026
34 checks passed
@akijakya
akijakya deleted the feat/api-post-extract branch August 14, 2026 13:03
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.

[Feature]: Backend POST /v1/extract — expose OASF extractor output for tag recommendation

3 participants