HarperFast / HarperFast/harper

Runtime guard on HierarchicalNavigableSmallWorld.search() options argument (follow-up to #2165)

Open Beginner friendly
#2,611 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
JavaScript
Stars
89
Forks
10
Avg merge
2d 6h
Merged PRs (30d)
200

Description

Follow-up from #2165 / PR #2187.

PR #2187 moved `customIndex.search()` to `search(condition, context, { filter, minResults })` and added a runtime `TypeError` guard to `searchByIndex` so a stale positional 5th argument fails loud instead of silently permitting a full scan. The guard is asymmetric: `HierarchicalNavigableSmallWorld.search()` still destructures a positional `filter` function as `{ filter: undefined }` and drops it silently.

This is not theoretical. While merging main into #2187, `unitTests/resources/vectorIndexPlane.test.js:81` (added on main after the branch point) called `customIndex().search(cond, ctx, filter)` positionally, auto-merged clean, and two plane tests failed until it was converted by hand.

Scope:
- `typeof options !== 'object' || options === null` guard at the top of `search()` in `resources/indexes/HierarchicalNavigableSmallWorld.ts`, mirroring the `searchByIndex` guard.
- One test asserting the positional form throws.

Related, larger question raised by @kriszyp on #2187 and deliberately left out of that PR: if the custom-index contract is to become an extension point, it needs a typed `CustomIndex` interface and a registration API instead of the hard-coded `CUSTOM_INDEXES` literal in `resources/indexes/customIndexes.ts`. That is a separate design decision, not a shim.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Contributor guide

Open the contributing guide

Research direction

Start in resources/indexes/HierarchicalNavigableSmallWorld.ts at search(), and compare its argument handling with the searchByIndex guard. Run unitTests/resources/vectorIndexPlane.test.js, then add the focused assertion for the positional form. Done means the positional options call throws a TypeError rather than being silently accepted.

Written by the indexing model from the issue text.

Assessment

Tech stack
node.js, typescript
Domain
databases
Issue type
Bug
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Active
Clarity
Clearly specified
Newbie friendliness
90/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.