Skip to content

Support dynamic edge size parameter for Search API#3480

Merged
kpango merged 10 commits intomainfrom
feature/search/dynamic-edge-size
Mar 16, 2026
Merged

Support dynamic edge size parameter for Search API#3480
kpango merged 10 commits intomainfrom
feature/search/dynamic-edge-size

Conversation

@Matts966
Copy link
Copy Markdown
Member

@Matts966 Matts966 commented Feb 19, 2026

Description

SSIA

Related Issue

Versions

  • Vald Version: v1.7.17
  • Go Version: v1.25.7
  • Rust Version: v1.93.0
  • Docker Version: v29.2.1
  • Kubernetes Version: v1.35.0
  • Helm Version: v4.1.0
  • NGT Version: v2.5.1
  • Faiss Version: v1.13.2

Checklist

Special notes for your reviewer

⚠️ This PR is PoC and uses feature branch of vdaas/ngt's dynamic-edge-size branch

Summary by CodeRabbit

  • New Features

    • Added edge_size (int32) to search configuration across search APIs, exposing a new search tuning parameter.
  • Documentation

    • Updated API docs, proto schema, and OpenAPI specs to document the new edge_size field.
  • Chores

    • Updated external build source for the NGT dependency.
    • Bumped several Rust crate versions.
  • Refactor

    • Normalized API schema/reference names in OpenAPI specs for consistency.

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Feb 19, 2026

Note

Reviews paused

It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • 🔍 Trigger review
📝 Walkthrough

Walkthrough

Adds an int32 edge_size search configuration across protobufs, generated Rust, docs, and Swagger; threads the parameter from gRPC handler → service → core → NGT C API; updates NGT Makefile to clone vdaas/NGT feature branch; bumps several Rust crate versions and updates tests and swagger refs.

Changes

Cohort / File(s) Summary
Build & external deps
Makefile, rust/libs/algorithm/Cargo.toml, rust/libs/proto/Cargo.toml, rust/libs/kvs/Cargo.toml, rust/libs/vqueue/Cargo.toml
Makefile now clones vdaas/NGT on branch feature/search/dynamic-edge-size. Bumped Rust deps: tonic 0.14.3→0.14.4, futures-core 0.3.31→0.3.32, wincode 0.4.1→0.4.4.
Protobuf & generated Rust
apis/proto/v1/payload/payload.proto, rust/libs/proto/src/payload/v1/payload.v1.rs
Added edge_size (int32 = 12) to payload.v1.Search.Config; regenerated Rust struct includes edge_size.
API docs
apis/docs/v1/docs.md, apis/docs/v1/filter.md, apis/docs/v1/payload.md.tmpl, apis/docs/v1/search.md
Documented new edge_size field across Search.Config usages and tables for all affected RPCs.
Swagger / OpenAPI
apis/swagger/v1/discoverer/discoverer.swagger.json, apis/swagger/v1/vald/*
Added edgeSize property to search config definitions; normalized several $refs from v1XxxXxx and updated related response refs/titles.
Go core (NGT)
internal/core/algorithm/ngt/ngt.go, internal/core/algorithm/ngt/ngt_test.go
Extended NGT Search signature to accept edgeSize int32; pass edgeSize into C.ngt_search_index_as_float(...); updated tests and mocks to new signature.
Go service & handler
pkg/agent/core/ngt/service/ngt.go, pkg/agent/core/ngt/service/ngt_stateful_test.go, pkg/agent/core/ngt/handler/grpc/search.go
Propagated edgeSize through service and handler: extract req.GetConfig().GetEdgeSize() and forward to core/ngt calls; tests updated to pass edgeSize.

Sequence Diagram

sequenceDiagram
    participant Client as Client
    participant Handler as gRPC Handler
    participant Service as NGT Service
    participant Core as NGT Core
    participant CAPI as C API

    Client->>Handler: Search(req { vec, config.edge_size })
    Handler->>Handler: extract config.edge_size
    Handler->>Service: Search(ctx, vec, size, eps, radius, edgeSize)
    Service->>Core: Search(ctx, vec, size, eps, radius, edgeSize)
    Core->>CAPI: ngt_search_index_as_float(..., edgeSize)
    CAPI-->>Core: results
    Core-->>Service: []SearchResult
    Service-->>Handler: SearchResponse
    Handler-->>Client: SearchResponse
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Possibly related PRs

Suggested reviewers

  • datelier
  • kpango

Poem

🔎 A tiny edge now finds its place,
From proto, docs, through every trace,
Threaded down to C with care,
Tests adjusted, deps aware,
Search returns with steadier grace ✨

🚥 Pre-merge checks | ✅ 2 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'Support dynamic edge size parameter for Search API' directly and specifically describes the main feature added across the changeset: introducing an edge_size parameter to search configurations and propagating it through the entire API surface (protobuf, Go services, Rust implementations, Swagger specs, and NGT integration).

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch feature/search/dynamic-edge-size

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@vdaas-ci
Copy link
Copy Markdown
Collaborator

[WARNING:INTCFG] Changes in internal/config may require you to change Helm charts. Please check.

@vdaas-ci
Copy link
Copy Markdown
Collaborator

[CHATOPS:HELP] ChatOps commands.

  • 🙆‍♀️ /approve - approve
  • 🍱 /format - format codes and add licenses
  • /gen-test - generate test codes
  • 🏷️ /label - add labels
  • 🔚 2️⃣ 🔚 /label actions/e2e-deploy - run E2E deploy & integration test

@codecov
Copy link
Copy Markdown

codecov Bot commented Feb 19, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 26.04%. Comparing base (9e5e903) to head (73be3fd).
⚠️ Report is 3 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #3480      +/-   ##
==========================================
- Coverage   26.77%   26.04%   -0.74%     
==========================================
  Files         527      569      +42     
  Lines       48959    50325    +1366     
==========================================
- Hits        13110    13106       -4     
- Misses      34874    36247    +1373     
+ Partials      975      972       -3     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@cloudflare-workers-and-pages
Copy link
Copy Markdown

cloudflare-workers-and-pages Bot commented Feb 19, 2026

Deploying vald with  Cloudflare Pages  Cloudflare Pages

Latest commit: 73be3fd
Status: ✅  Deploy successful!
Preview URL: https://84f62583.vald.pages.dev
Branch Preview URL: https://feature-search-dynamic-edge.vald.pages.dev

View logs

@Matts966 Matts966 force-pushed the feature/search/dynamic-edge-size branch from 2bbcfa2 to f395008 Compare February 19, 2026 03:52
@github-actions github-actions Bot added size/M and removed size/M labels Feb 19, 2026
@Matts966
Copy link
Copy Markdown
Member Author

/format

@vdaas-ci
Copy link
Copy Markdown
Collaborator

[FORMAT] Updating license headers and formatting go codes triggered by Matts966.

Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (2)
internal/core/algorithm/ngt/ngt.go (2)

638-668: ⚠️ Potential issue | 🟠 Major

edgeSize has no zero-value fallback, unlike epsilon and radius.

Lines 651–657 apply fallbacks for both epsilon and radius when the caller passes 0:

if epsilon == 0 {
    epsilon = n.epsilon
}
if radius == 0 {
    radius = n.radius
}

edgeSize receives no equivalent treatment — a zero value is forwarded directly to C.ngt_search_index_as_float. Whether 0 is safe depends entirely on the C API's contract (e.g., "use index-configured default" vs. "disable dynamic edge sizing" vs. undefined behaviour). There is no stored edgeSize default on the ngt struct and no negative-value guard either.

At minimum, the semantics of edgeSize == 0 must be documented explicitly. If 0 is not a meaningful no-op, the pattern should mirror epsilon/radius:

💡 Proposed alignment with existing fallback pattern
+    // ces is used as the edge-size-for-creation; a dedicated search default
+    // would need a new field (e.g. n.searchEdgeSize) populated from options.
+    // For now, -1 is the NGT convention for "use index default".
+    if edgeSize == 0 {
+        edgeSize = -1 // or a stored n.searchEdgeSize default
+    }
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@internal/core/algorithm/ngt/ngt.go` around lines 638 - 668, The code forwards
edgeSize==0 directly to C.ngt_search_index_as_float while epsilon and radius
fall back to n.epsilon/n.radius; add a consistent fallback or guard for
edgeSize: either introduce a default field on the ngt struct (e.g., n.edgeSize)
and set edgeSize = n.edgeSize when edgeSize == 0, or explicitly validate and
reject zero (return an error) before calling ngt_search_index_as_float; update
the function that calls C.ngt_search_index_as_float to apply this
fallback/validation and adjust any callers/tests to use the new behavior.

660-669: ⚠️ Potential issue | 🔴 Critical

Resolve NGT API signature mismatch before merge.

The ngt_search_index_as_float call passes 9 arguments with edgeSize as the 8th parameter, but the NGT main branch signature only accepts 8 parameters and does not include edgeSize. The feature branch feature/search/dynamic-edge-size (which introduces this parameter) is inaccessible (404). This parameter-order mismatch causes silent memory corruption in CGo—the Go compiler will not detect it.

Confirm that:

  1. The NGT feature branch feature/search/dynamic-edge-size exists and is publicly accessible, or
  2. The edgeSize parameter has been merged into NGT's main branch, or
  3. Update the Go call to match the current NGT C API signature.
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@internal/core/algorithm/ngt/ngt.go` around lines 660 - 669, The call to
C.ngt_search_index_as_float in function/method using n.index is passing an extra
edgeSize argument (9 args) which doesn't match the mainline NGT C API (8 args)
and causes silent CGo memory corruption; either confirm the remote feature
branch or merged API, but most likely remove the edgeSize parameter and call
ngt_search_index_as_float with the current 8-argument signature (index, pointer
to vec, dimension, pointer to size, pointer to epsilon, pointer to radius,
results, ne.err) and update any surrounding code/comments accordingly, and run a
full build/test to ensure the Cgo signature (and any typedefs/unsafe.Pointer
casts) matches the NGT C header used at link time.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Outside diff comments:
In `@internal/core/algorithm/ngt/ngt.go`:
- Around line 638-668: The code forwards edgeSize==0 directly to
C.ngt_search_index_as_float while epsilon and radius fall back to
n.epsilon/n.radius; add a consistent fallback or guard for edgeSize: either
introduce a default field on the ngt struct (e.g., n.edgeSize) and set edgeSize
= n.edgeSize when edgeSize == 0, or explicitly validate and reject zero (return
an error) before calling ngt_search_index_as_float; update the function that
calls C.ngt_search_index_as_float to apply this fallback/validation and adjust
any callers/tests to use the new behavior.
- Around line 660-669: The call to C.ngt_search_index_as_float in
function/method using n.index is passing an extra edgeSize argument (9 args)
which doesn't match the mainline NGT C API (8 args) and causes silent CGo memory
corruption; either confirm the remote feature branch or merged API, but most
likely remove the edgeSize parameter and call ngt_search_index_as_float with the
current 8-argument signature (index, pointer to vec, dimension, pointer to size,
pointer to epsilon, pointer to radius, results, ne.err) and update any
surrounding code/comments accordingly, and run a full build/test to ensure the
Cgo signature (and any typedefs/unsafe.Pointer casts) matches the NGT C header
used at link time.

@Matts966 Matts966 force-pushed the feature/search/dynamic-edge-size branch from 794fb97 to 3cd380c Compare February 20, 2026 03:18
@Matts966
Copy link
Copy Markdown
Member Author

/format

@vdaas-ci
Copy link
Copy Markdown
Collaborator

[FORMAT] Updating license headers and formatting go codes triggered by Matts966.

vdaas-ci and others added 2 commits February 20, 2026 05:10
Signed-off-by: Vdaas CI <vald@vdaas.org>
Signed-off-by: Matts966 <matts966@vdaas.org>
@Matts966
Copy link
Copy Markdown
Member Author

/format

@vdaas-ci
Copy link
Copy Markdown
Collaborator

[FORMAT] Updating license headers and formatting go codes triggered by Matts966.

@Matts966
Copy link
Copy Markdown
Member Author

/format

@vdaas-ci
Copy link
Copy Markdown
Collaborator

[FORMAT] Updating license headers and formatting go codes triggered by Matts966.

Signed-off-by: Vdaas CI <vald@vdaas.org>
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

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


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread apis/proto/v1/payload/payload.proto
Comment thread pkg/agent/core/ngt/handler/grpc/search.go
Comment thread pkg/agent/core/ngt/handler/grpc/search.go
Comment thread internal/core/algorithm/ngt/ngt.go
@Matts966 Matts966 requested review from a team, kmrmt and kpango and removed request for a team February 25, 2026 05:55
@kpango kpango merged commit 70de684 into main Mar 16, 2026
301 of 302 checks passed
@kpango kpango deleted the feature/search/dynamic-edge-size branch March 16, 2026 04:37
vdaas-ci added a commit that referenced this pull request Mar 16, 2026
* Support dynamic edge size parameter for Search API

* 🤖 Update license headers / Format go codes and yaml files

Signed-off-by: Vdaas CI <vald@vdaas.org>

* Fix files

* Update internal/core/algorithm/ngt/ngt.go

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Signed-off-by: Matts966 <mattsmasa96604a@gmail.com>

* Fix arg order

* 🤖 Update license headers / Format go codes and yaml files

Signed-off-by: Vdaas CI <vald@vdaas.org>

* 🤖 Update license headers / Format go codes and yaml files

Signed-off-by: Vdaas CI <vald@vdaas.org>

* Upgrade and use default NGT

* 🤖 Update license headers / Format go codes and yaml files

Signed-off-by: Vdaas CI <vald@vdaas.org>

---------

Signed-off-by: Vdaas CI <vald@vdaas.org>
Signed-off-by: Matts966 <mattsmasa96604a@gmail.com>
Signed-off-by: Matts966 <matts966@vdaas.org>
Co-authored-by: Vdaas CI <vald@vdaas.org>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Matts966 added a commit that referenced this pull request Mar 23, 2026
* Support dynamic edge size parameter for Search API

* 🤖 Update license headers / Format go codes and yaml files



* Fix files

* Update internal/core/algorithm/ngt/ngt.go




* Fix arg order

* 🤖 Update license headers / Format go codes and yaml files



* 🤖 Update license headers / Format go codes and yaml files



* Upgrade and use default NGT

* 🤖 Update license headers / Format go codes and yaml files



---------

Signed-off-by: Vdaas CI <vald@vdaas.org>
Signed-off-by: Matts966 <mattsmasa96604a@gmail.com>
Signed-off-by: Matts966 <matts966@vdaas.org>
Co-authored-by: Matts966 <matts966@vdaas.org>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
@vdaas-ci
Copy link
Copy Markdown
Collaborator

vdaas-ci commented Apr 7, 2026

@vdaas-ci
Copy link
Copy Markdown
Collaborator

vdaas-ci commented Apr 7, 2026

Profile Report

typevald-agent-ngtvald-lb-gatewayvald-discoverervald-manager-index
cpu
heap
other images

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants