Skip to content

test(e2e): cover POST /v1/search parity and POST /v1/extract - #2120

Merged
akijakya merged 1 commit into
mainfrom
test/post-apis-e2e
Sep 9, 2026
Merged

akijakya merged 1 commit into
mainfrom
test/post-apis-e2e

Conversation

@akijakya

@akijakya akijakya commented Sep 8, 2026 •

Copy link
Copy Markdown
Member

Adds end-to-end coverage for the two extractor-backed gateway endpoints against a real node. The handler unit tests drive a fake extractor, so they cannot catch a gateway that resolved no backend, dialed the wrong address, or ranks differently from dirctl search.

POST /v1/search — 18_ai_finder_search_test.go

  • Relevance-ranked entries for a free-text query, each identified by catalog URN, with a record matching no signal left out of the ranked set.
  • Ranking by number of signals matched. The two seeds share a description and carry names holding none of the query's keywords, so their keyword surface is identical and the only difference is whether they carry the extracted skill. Holding that equal is load-bearing: a keyword signal scores 1.0 against this skill's 0.573, so varying the descriptions instead lets an extra keyword hit outweigh the skill hit — correct behaviour, but it tells you nothing about the skill.
  • Stable ranking across repeated identical requests, guarding the tie-determinism total order.
  • Pagination: page 1 and page 2 are disjoint and reconstruct a prefix of the unpaged order, and the last page carries no continuation token.
  • Parity with dirctl search, compared over the seeded records only. The two do not see the same record universe — recordSearcher restricts candidates to KnownCatalogModuleNames() while the CLI's clientSearcher does not — so the CLI legitimately returns extra non-projectable CIDs. Scoring is per-CID, so the relative order of the shared records is preserved, and that shared ordering is the assertable contract.
  • Empty and over-long queries rejected with 400.

POST /v1/extract — 20_ai_finder_extract_test.go

  • Scored skills and domains with hierarchical names, real OASF uids, normalised scores and descending order.
  • Returned classes checked against the node's own configured OASF schema endpoint by pushing a record built from them. Verified out of band that validation does reject an unknown class (id_unknown / name_unknown), so this is a real assertion rather than a shape check. Class names are version-scoped — software_engineering/code_quality/code_review validates only under 1.1.0, its natural_language_processing/… predecessor only under 1.0.0 — and ExtractTaxonomyRequest carries no version, so the probe tries each of the four taxonomy versions the extractor draws from and requires one to accept. Only the top skill and domain are probed together: a single extraction mixes versions at lower ranks, but the best match in each list comes from the same taxonomy.
  • Empty and over-long text rejected with 400.

Where each backend is covered

Backend Environment Covers
local local:local in-process assets, plus the parity assertion
remote local:kind the OASF-SDK Service the chart wires up, added by #2118
none daemon:default both endpoints must answer 503

Both spec files run wherever the environment declares an extractor, so they exercise the local backend under local:local and the remote one under the Kind job. The parity spec skips outside local mode: under Kind the OASF-SDK Service is ClusterIP-only and the CLI cannot reach the gateway's backend, so the two rankings are not comparable.

An earlier revision of this PR added a third environment that reached a remote extractor through a plain oasf-sdk container, with no cluster. It was dropped: it duplicated the remote coverage the Kind job already provides, and the two backends were measured returning byte-identical scores, tiers and ids for the same query, so re-asserting the contract against a container added little.

For the no-extractor case, daemon/default now enables the gateway with its extractor asset dir pointed at a path that does not exist. 02_no_extractor_test.go asserts both endpoints answer 503 with the "no OASF extractor is configured" message, that GET /v1/agents still serves — so a 503 means the extractor is missing rather than the gateway being down — and that an empty query is still a 400, pinning argument validation ahead of the extractor check.

Rebase onto #2118

That PR landed overlapping Kind coverage while this was in review, and the resolution is not purely textual:

  • Collapses its remote_extractor_enabled boolean into extractor_mode, updating the single call site in 19_remote_extractor_test.go. Two fields for one fact let an environment set only one and have the specs disagree about skipping, and the mode also has to tell "local" apart from "no extractor", which a boolean cannot.
  • Numbers the extract specs 20_ so test(e2e): cover the remote extractor in Kind #2118 keeps the 19_ slot.
  • The suite-level readiness gate added here also covers Kind, so its specs no longer wait on a cold extractor pod one spec at a time.

Also

  • setup-dir-node gains DIRCTL_INIT_ARGS, and local:local uses it to force the in-process backend for the CLI. dirctl init inherits the machine-wide saved remote address whenever the flag is left unset, which would otherwise leave the CLI dialing an OASF-SDK server while the daemon uses local assets — and the parity spec compares the two.
  • daemon/default skips extractor provisioning, dropping an 89 MB download from three cross-platform runners that never used it.

Two deviations from the issue

  • "Empty-extraction fallback returns name-substring matches" is stale. SearchAgents now rejects an empty extraction with InvalidArgument, per TestSearchAgents_EmptyExtractionIsRejected. The invalid-input specs assert the real contract. Driving that branch through a real extractor is not possible either — every non-empty text yields keyword signals — so it stays covered by the unit test.
  • Parity is asserted only where the CLI and gateway share an extractor, which is local mode.

Verification

Suite Result
e2e:test:local:local 231 passed, 4 skipped
e2e:test:daemon:default 8 passed, 2 skipped
e2e:test:daemon:external 6 passed, 4 skipped
task test 72 packages ok
task lint 0 issues

e2e:test:local:kind was not run locally — it needs locally built images and the Kind toolchain. Its two new callers are the spec files here, which pass against the same oasf-sdk:v1.3.0 image under local:local and against a container during development of the dropped environment; CI runs the job on this PR.

Noted, not fixed

15_nl_search_test.go gates on ~/.agntcy/oasf-sdk/manifest.json, which is missing the extractor subdirectory extractor.DefaultAssetDir provisions into, so that spec has always skipped — including in CI. Correcting the path makes it run and push testdata/directory-record.json, which then contends with 14_skill_record_test.go: both use the record name org.agntcy/directory, that testdata carries a stale application/agentskill+md artifact media type where the daemon now emits application/agent-skills+md, and spec 14 resolves the name with --limit 1. Ginkgo randomises top-level containers, so the collision is order-dependent. Fixing it properly needs the testdata corrected and spec 14 taught to pick the record it means, so it is left alone here with a comment rather than half-done. The CLI free-text path is meanwhile covered by the parity spec.

Closes #1909

@akijakya
akijakya requested a review from a team as a code owner September 8, 2026 08:28
@github-actions github-actions Bot added the size/L Denotes a PR that changes 1000-1999 lines label Sep 8, 2026
@akijakya akijakya self-assigned this Sep 8, 2026
@codecov

codecov Bot commented Sep 8, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

@github-actions github-actions Bot added size/M Denotes a PR that changes 200-999 lines and removed size/L Denotes a PR that changes 1000-1999 lines labels Sep 8, 2026
@akijakya
akijakya force-pushed the test/post-apis-e2e branch 2 times, most recently from 60e1ad5 to 24c87bf Compare September 8, 2026 10:44
@akijakya
akijakya requested a balanced review from Copilot September 8, 2026 12:00

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

Local setup can inherit mismatched extractor settings, and taxonomy validation covers only top-ranked classes.

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

Pull request overview

Adds end-to-end coverage for extractor-backed gateway search and extraction across local, remote, and unavailable backends.

Changes:

  • Tests ranking, pagination, CLI parity, taxonomy extraction, and validation.
  • Adds extractor readiness and environment-mode configuration.
  • Verifies graceful 503 behavior without an extractor.
File summaries
File Description
tests/modules/Taskfile.setup-dir-node.yml Adds configurable extractor initialization.
tests/e2e/local/testenv/local/test-config.yaml Declares local extractor mode.
tests/e2e/local/testenv/local/Taskfile.testenv.yml Forces local extractor initialization.
tests/e2e/local/testenv/kind/test-config.yaml Declares remote extractor mode.
tests/e2e/local/local_suite_test.go Adds suite-level extractor readiness polling.
tests/e2e/local/config/config.go Replaces the remote flag with extractor mode.
tests/e2e/local/ai_finder_http_test.go Adds shared gateway HTTP helpers and models.
tests/e2e/local/20_ai_finder_extract_test.go Tests extraction results and validation.
tests/e2e/local/19_remote_extractor_test.go Migrates remote tests to extractor mode.
tests/e2e/local/18_ai_finder_search_test.go Tests search ranking, pagination, and CLI parity.
tests/e2e/local/15_nl_search_test.go Documents an existing skipped-test conflict.
tests/e2e/local/13_ai_finder_test.go Reuses shared HTTP helpers.
tests/e2e/daemon/testenv/default/test-config.yaml Enables no-extractor gateway coverage.
tests/e2e/daemon/testenv/default/Taskfile.testenv.yml Skips unnecessary extractor provisioning.
tests/e2e/daemon/testenv/default/dir-daemon-config.yaml Configures a gateway without extractor assets.
tests/e2e/daemon/config/config.go Adds gateway and no-extractor settings.
tests/e2e/daemon/02_no_extractor_test.go Tests degraded gateway behavior.
Review details
  • Files reviewed: 17/17 changed files
  • Comments generated: 2
  • Review effort level: Balanced

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

@github-actions github-actions Bot added size/L Denotes a PR that changes 1000-1999 lines and removed size/M Denotes a PR that changes 200-999 lines labels Sep 8, 2026
Adds end-to-end coverage for the two extractor-backed gateway endpoints
against a real node. The handler unit tests drive a fake extractor, so
they cannot catch a gateway that resolved no backend, dialed the wrong
address, or ranks differently from `dirctl search`.

POST /v1/search (18_ai_finder_search_test.go):
  - relevance-ranked entries for a free-text query, entries identified by
    catalog URN, and a record matching no signal left out
  - ranking by number of signals matched, asserted with two seeds that
    share a description and differ only in carrying the extracted skill,
    so the keyword surface is held equal
  - stable ranking across repeated identical requests
  - disjoint pages that reconstruct a prefix of the unpaged order, and no
    continuation token on the last page
  - parity with `dirctl search`, compared over the seeded records only:
    the gateway restricts candidates to catalog-projectable records and
    the CLI does not, so the shared ordering is the assertable contract
  - empty and over-long queries rejected with 400

POST /v1/extract (20_ai_finder_extract_test.go):
  - scored skills and domains with hierarchical names, OASF uids, and
    descending score
  - every returned class checked against the node's own OASF schema
    endpoint by pushing a record carrying it, tried across the four
    taxonomy versions the extractor draws from. One class per record: a
    single response holds classes no one version accepts together, since
    OASF renamed whole trees between 1.0.0 and 1.1.0, and for this phrase
    the skills and the domains each straddle that boundary
  - empty and over-long text rejected with 400

Both spec files run wherever the environment declares an extractor, so
the local backend is covered by local:local and the remote backend by the
Kind job #2118 added. The parity spec skips outside local mode, where the
CLI and the gateway load the same assets; under Kind the OASF-SDK Service
is ClusterIP-only and the CLI cannot reach the gateway's backend.

For the case with no extractor at all, daemon/default now enables the
gateway with its extractor asset dir pointed at a path that does not
exist. 02_no_extractor_test.go asserts both endpoints answer 503, that
GET /v1/agents still serves — so a 503 means the extractor is missing
rather than the gateway being down — and that an empty query is still a
400, pinning argument validation ahead of the extractor check.

Rebased onto #2118, which landed overlapping Kind coverage:
  - collapses its remote_extractor_enabled boolean into extractor_mode
    and updates the single call site in 19_remote_extractor_test.go. Two
    fields for one fact let an environment set only one and have the
    specs disagree about skipping, and the mode also has to tell "local"
    apart from "no extractor", which a boolean cannot
  - numbers the extract specs 20_ so #2118 keeps the 19_ slot
  - the suite-level readiness gate added here also covers Kind, so its
    specs no longer wait on a cold extractor pod one spec at a time

Also:
  - setup-dir-node gains DIRCTL_INIT_ARGS, and local:local uses it to pin
    the CLI to the extractor the daemon resolves. `dirctl init` fills
    every extractor flag left unset from the machine-wide saved config —
    asset dir, OASF URL and remote address alike — so on a machine
    carrying custom saved values the CLI would load a different extractor
    than the daemon uses, and both the readiness gate and the parity spec
    depend on the two agreeing
  - daemon/default skips extractor provisioning, dropping an 89 MB
    download from three cross-platform runners that never used it

Signed-off-by: András Jáky <[email protected]>
@akijakya
akijakya enabled auto-merge (squash) September 9, 2026 09:35
@akijakya
akijakya merged commit 4d98735 into main Sep 9, 2026
34 checks passed
@akijakya
akijakya deleted the test/post-apis-e2e branch September 9, 2026 09:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size/L Denotes a PR that changes 1000-1999 lines

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Test]: e2e for POST /v1/search parity and POST /v1/extract

3 participants