Skip to content

SDK-shape conformance test for SearchableIndex - #222

Merged
wpak-ai merged 2 commits into
cppalliance:mainfrom
timon0305:feat/searchable-index-conformance-220
Jul 15, 2026
Merged

SDK-shape conformance test for SearchableIndex#222
wpak-ai merged 2 commits into
cppalliance:mainfrom
timon0305:feat/searchable-index-conformance-220

Conversation

@timon0305

@timon0305 timon0305 commented Jul 15, 2026

Copy link
Copy Markdown
Collaborator

Closes #220.

SearchableIndex (src/types.ts) is a hand-written interface, and src/core/pinecone/indexes.ts force-casts the real SDK index onto it with as unknown as SearchableIndex, which erases type checking. The existing tests only mock our own interface, so nothing verifies the SDK index actually provides the members the code calls. A Pinecone SDK bump that renames or removes one would slip past the compiler and fail at runtime.

What this adds

A conformance test that constructs a real SDK index handle (offline — pc.index() returns a handle with no network call) and asserts the members the code relies on exist: describeIndexStats, namespace, searchRecords, query. A rename/removal in a future SDK fails this test loudly instead of at runtime. Verified against SDK 8.0.0, and confirmed a renamed member fails the test.

search is intentionally not asserted — the SDK Index has no bare search(); that call site in search.ts is a guarded fallback.

Note

I tried a compile-time assertion so signature drift would also fail at build, but the SDK types the index too loosely for it to catch drift without passing vacuously (a negative check caught two formulations doing exactly that), so this is a runtime existence check rather than ship a guard that looks like it verifies something but does not.

Summary by CodeRabbit

  • Tests
    • Added a runtime compatibility/conformance check for the Pinecone search index interface.
    • The test verifies key index and namespace operations are present and will flag breaking SDK shape changes early.

SearchableIndex is a hand-written interface and indexes.ts force-casts the SDK
index to it with as unknown as, which erases type checking; existing tests only
mock our own interface. So an SDK bump that renames or removes a method the code
calls would slip past the compiler and fail at runtime.

Assert the members the code relies on (describeIndexStats, namespace,
searchRecords, query) exist on a real SDK index handle, constructed offline with
no network. A compile-time assertion was tried but the SDK types the index too
loosely to catch drift without passing vacuously, so this is a runtime check;
verified a renamed member fails it.
@coderabbitai

coderabbitai Bot commented Jul 15, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: bb44831f-d151-4e7b-b373-1f8b4998a1e8

📥 Commits

Reviewing files that changed from the base of the PR and between 5e2c75e and c7ba174.

📒 Files selected for processing (1)
  • src/core/pinecone/searchable-index-conformance.test.ts
🚧 Files skipped from review as they are similar to previous changes (1)
  • src/core/pinecone/searchable-index-conformance.test.ts

📝 Walkthrough

Walkthrough

Adds a Vitest conformance suite that constructs a Pinecone index handle and verifies required index and namespace methods are available.

Changes

SearchableIndex conformance

Layer / File(s) Summary
SDK index shape check
src/core/pinecone/searchable-index-conformance.test.ts
Creates a Pinecone index handle with a dummy API key and verifies describeIndexStats, namespace, searchRecords, query, and namespace searchRecords are functions.

Estimated code review effort: 1 (Trivial) | ~5 minutes

Suggested reviewers: wpak-ai, jonathanmldev

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly matches the main change: adding a conformance test for SearchableIndex shape drift.
Linked Issues check ✅ Passed The new runtime test checks the SDK index and namespace members used by SearchableIndex, and it will fail in CI if the shape drifts.
Out of Scope Changes check ✅ Passed The change is limited to a conformance test and stays within the issue scope.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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

@coderabbitai coderabbitai Bot 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.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@src/core/pinecone/searchable-index-conformance.test.ts`:
- Around line 19-28: Update the conformance test to validate the nested
namespace query path used by indexes.ts: obtain the result of
index.namespace('conformance-test') and assert its query member is a function.
Remove query from REQUIRED_MEMBERS unless the top-level SDK index is
independently required to expose it, while preserving checks for the remaining
members.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: cf3a135b-8a43-426f-a684-d0df4eeb3601

📥 Commits

Reviewing files that changed from the base of the PR and between 9ce9e7b and 5e2c75e.

📒 Files selected for processing (1)
  • src/core/pinecone/searchable-index-conformance.test.ts

Comment thread src/core/pinecone/searchable-index-conformance.test.ts Outdated
@codecov

codecov Bot commented Jul 15, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
⚠️ Please upload report for BASE (main@9ce9e7b). Learn more about missing BASE report.

Additional details and impacted files
@@           Coverage Diff           @@
##             main     #222   +/-   ##
=======================================
  Coverage        ?   85.07%           
=======================================
  Files           ?       46           
  Lines           ?     2399           
  Branches        ?      826           
=======================================
  Hits            ?     2041           
  Misses          ?      357           
  Partials        ?        1           

☔ View full report in Codecov by Harness.
📢 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.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

…el (cppalliance#220 review)

The code calls query and searchRecords through index.namespace(ns) (indexes.ts
namespace(ns).query, search.ts namespace(ns).searchRecords), so probe them on the
namespace handle rather than the top-level index. describeIndexStats/namespace and
the searchRecords index-fallback stay on the top-level index. Confirmed a bogus
namespace-handle member fails the test.
@wpak-ai
wpak-ai merged commit e2a0e91 into cppalliance:main Jul 15, 2026
12 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add an SDK-shape conformance test for SearchableIndex so an SDK drift fails loudly

3 participants