Skip to content

feat(extractor): move the OASF extractor to utils and unify resolution for dirctl and the gateway - #2002

Merged
akijakya merged 8 commits into
mainfrom
feat/shared-extractor
Aug 11, 2026
Merged

akijakya merged 8 commits into
mainfrom
feat/shared-extractor

Conversation

@akijakya

@akijakya akijakya commented Aug 10, 2026 •

Copy link
Copy Markdown
Member

Closes #1906
Closes #2003

Summary

Makes the OASF taxonomy extractor a shared, remotely-configurable component instead of a CLI-local one: it moves to the utils module, gains a single resolution path used by every caller, and is wired into the gateway at startup.

No new endpoints and no new CLI commands. This is the foundation the extractor-backed features build on (#2001, #1905), split out so it can land and be reviewed on its own. It carries one behavioral change — the tier default below — in its own commit.

Why the extractor had to move

The shared pluggable extractor from #1904 landed in the client module — the dir gRPC SDK. The gateway needs the extractor, and importing client into server is the wrong direction:

  • the server would depend on its own SDK client, and
  • because client/extractor → client/config → the root client package, it dragged the entire SDK dependency closure (sigstore/cosign, k8s client-go, go-tuf, zitadel/oidc, ~100 modules) into the server binary.

So the SDK-agnostic core — Extractor, ResolveExtractor, the local and remote backends, Config, Provision — moves to the genuinely shared utils module as utils/extractor and utils/nlsearch. The one convenience function that reads the persisted dirctl config (ResolveConfigured) stays in client/config, where its dependency on the CLI config layer belongs.

Result: go list -deps ./server/... no longer references agntcy/dir/client at all. utils/extractor never imports client, which is what keeps the layering from regressing.

One way to resolve an extractor

Previously there were two entry points — a local-only loader and a resolver — and callers picked one, so dirctl import could not use a remote extractor even when one was configured. There is now a single path, used everywhere:

  1. remote if an address is configured, else
  2. local in-process assets (configured directory, or the dirctl init default), else
  3. an error explaining how to set one up

Consequences: the importer can now enrich against a remote OASF-SDK server (remote_addr in the import file config), each Extract call is bounded by a timeout so an unreachable server cannot stall an import, and the resolved extractor is closed when the import finishes.

Two score tiers by default (#2003)

The extractor groups matches into score tiers; the SDK returns one. That is too narrow in practice — descriptive queries miss plainly relevant classes, because in a densely populated hierarchical taxonomy the gap between the closest score group and the next often is not meaningful.

ExtractOptions.Tiers now defaults to 2, applied by the local and remote backends and by nlsearch.Decompose so the backends and the signal filter cannot disagree. Callers can still narrow (Tiers: 1) or widen per call.

This is the one part of the PR that changes existing behavior: dirctl search and routing search match more broadly, and dirctl import assigns more skills and domains to the records it writes. The enrichment half is the one worth a second opinion, since those classes are persisted into records — see #2003 for the reasoning and the questions left open (whether the number should be configurable, and whether 2 is empirically right — it was chosen from an observed failure, not from measurement).

Configuration

New server config block, consulted only when the HTTP gateway is enabled:

extractor:
  remote_addr: ""   # gRPC OASF-SDK server; empty selects the local backend
  asset_dir: ""     # local asset dir; empty uses ~/.agntcy/oasf-sdk/extractor
  oasf_url: ""      # OASF schema endpoint for local assets

Bound to DIRECTORY_SERVER_EXTRACTOR_REMOTE_ADDR, _ASSET_DIR, _OASF_URL. dirctl init can configure a remote address interactively and smoke-checks it (with a bounded timeout) before saving.

Resolution failure at startup is non-fatal — the server still starts, and extractor-backed functionality is simply unavailable until one is configured.

Note on the unused field

WithExtractor injects the resolved extractor into the AI Finder controller, but no RPC reads it yet — that is deliberate, since this PR intentionally carries no endpoints. The field is marked //nolint:unused with a pointer to the follow-up; the annotation comes off when #2001 or #1905 consumes it.

Scope

Deliberately not here: the /v1/search and /v1/extract protos and handlers, and the Helm subchart (#1907, which additionally depends on agntcy/oasf-sdk#179 to deploy the server as ClusterIP).

This branch is the salvaged foundation of #1969, which was closed after the epic (#1903) changed direction. The commits kept here are unaffected by that redesign; the search-specific ones were dropped.

Testing

  • All 6 modules build; task lint reports 0 issues (Go and Helm); task test passes with no failures
  • Unit coverage for extractor resolution, local and remote backends, nlsearch decomposition, server config binding, dirctl init, and import config
  • Verified go list -deps ./server/... contains no agntcy/dir/client packages
  • Manually exercised both backends: dirctl daemon start with local assets, and a remote OASF-SDK container via DIRECTORY_DAEMON_SERVER_EXTRACTOR_REMOTE_ADDR
  • Daemon env binding is regression-covered: the new test fails without the Viper registration and passes with it

@akijakya akijakya self-assigned this Aug 10, 2026
@akijakya
akijakya requested a review from a team as a code owner August 10, 2026 15:29
@github-actions github-actions Bot added the size/M Denotes a PR that changes 200-999 lines label Aug 10, 2026
@akijakya akijakya changed the title feat: shared extractor feat(extractor): move the OASF extractor to utils and unify resolution for dirctl and the gateway Aug 10, 2026
@codecov

codecov Bot commented Aug 10, 2026 •

Copy link
Copy Markdown

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

Moves OASF extraction into shared utilities and wires unified local/remote resolution into CLI import, search, routing, initialization, and gateway startup.

Changes:

  • Adds shared local/remote extractor implementations and configuration.
  • Adds gateway injection and server configuration.
  • Enables remote extractor use by CLI workflows with lifecycle and timeout handling.

Reviewed changes

Copilot reviewed 25 out of 37 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
utils/nlsearch/decompose.go Uses shared extractor package.
utils/nlsearch/decompose_test.go Updates extractor test dependency.
utils/go.mod Adds extractor dependencies.
utils/go.sum Updates dependency checksums.
utils/extractor/resolve.go Implements unified backend resolution.
utils/extractor/resolve_test.go Tests backend selection.
utils/extractor/remote.go Adds remote gRPC backend.
utils/extractor/remote_test.go Tests remote response mapping.
utils/extractor/provision_integration_test.go Adds provisioning integration test.
utils/extractor/local.go Adapts local SDK backend.
utils/extractor/load_test.go Tests local loading failures.
utils/extractor/extractor.go Defines shared extractor interface.
utils/extractor/config.go Defines shared configuration.
utils/extractor/config_test.go Tests configuration behavior.
utils/extractor/assets.go Adds asset detection and teardown.
utils/extractor/assets_test.go Tests asset lifecycle behavior.
server/server.go Resolves and manages gateway extractor.
server/go.mod Adds indirect extractor dependencies.
server/go.sum Updates dependency checksums.
server/controller/ai_finder.go Adds extractor dependency injection.
server/config/config.go Adds server extractor configuration.
server/config/config_test.go Tests extractor environment binding.
reconciler/go.mod Updates transitive dependencies.
reconciler/go.sum Updates dependency checksums.
client/go.mod Moves extractor dependencies to utilities.
client/extractor/load_test.go Removes relocated tests.
client/config/extractor.go Resolves persisted extractor configuration.
client/config/extractor_test.go Tests persisted resolution.
cli/cmd/search/nlsearch.go Uses shared configured resolver.
cli/cmd/routing/nlsearch.go Uses shared configured resolver.
cli/cmd/init/run.go Adds remote provisioning and smoke checks.
cli/cmd/init/run_test.go Tests remote initialization behavior.
cli/cmd/init/options.go Adds remote-address flag.
cli/cmd/import/options.go Tracks extractor lifecycle.
cli/cmd/import/import.go Closes resolved extractors.
cli/cmd/import/extractor_adapter.go Supports remote extraction with timeout.
cli/cmd/import/config.go Adds remote importer configuration.

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

Comment thread server/config/config.go Resolved
Comment thread server/server.go Resolved
Comment thread cli/cmd/import/config.go Resolved
…ntroller

Adds the WithExtractor option so the server can hand the gateway's resolved
extractor to the AI Finder controller. No RPC consumes it yet; the
extractor-backed endpoints are added on top of this wiring.

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

Close the gateway extractor after GracefulStop rather than before, release the
resolved extractor when gateway construction fails, and bound the dirctl init
remote smoke check with an explicit timeout.

Signed-off-by: András Jáky <[email protected]>
The embedded daemon uses its own Viper loader, where AutomaticEnv cannot
resolve keys that are absent from daemon.config.yaml and have no default. The
extractor keys were unregistered there, so DIRECTORY_DAEMON_SERVER_EXTRACTOR_*
was silently ignored; register all three and cover the env-only and
user-config cases with tests.

Also document remote_addr in the import config example and the CLI reference,
and drop references to endpoints this change does not add.

Signed-off-by: András Jáky <[email protected]>
Add ExtractOptions.Tiers and default it to two score groups instead of the
SDK's one, applied by both the local and remote backends and by
nlsearch.Decompose so the backends and the signal filter stay in lockstep.

One tier is too narrow in practice: descriptive queries miss classes that are
plainly relevant, because the gap between the closest score group and the next
is often not meaningful in a densely populated hierarchical taxonomy. Callers
can still narrow (Tiers: 1) or widen per call.

Closes #2003

Signed-off-by: András Jáky <[email protected]>
@akijakya
akijakya force-pushed the feat/shared-extractor branch from 08d57d5 to ef6ada5 Compare August 11, 2026 09:55
@akijakya
akijakya merged commit 71fe81b into main Aug 11, 2026
37 checks passed
@akijakya
akijakya deleted the feat/shared-extractor branch August 11, 2026 12:12
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

3 participants