Skip to content

fix(agentdb): String ID mapping for RuVectorBackend — silent data loss#115

Open
ruvnet wants to merge 1 commit intomainfrom
fix/ruvector-string-id-mapping
Open

fix(agentdb): String ID mapping for RuVectorBackend — silent data loss#115
ruvnet wants to merge 1 commit intomainfrom
fix/ruvector-string-id-mapping

Conversation

@ruvnet
Copy link
Owner

@ruvnet ruvnet commented Feb 22, 2026

Summary

  • Fixes silent data loss when using non-numeric string IDs (UUIDs, hex hashes, prefixed IDs like chunk_0) with RuVectorBackend
  • Added bidirectional idToLabel/labelToId mapping as defense-in-depth alongside the upstream fix in @ruvector/rvf@0.2.0
  • Updated ruvector dependency to ^0.1.99, bumped agentdb to 2.0.0-alpha.2.12

What changed

Method Before (bug) After (fix)
insert() Passed raw string ID to N-API → Number("uuid")NaN → silent drop Maps to sequential numeric label first
search() Returned numeric labels as IDs Returns original string IDs
remove() Number(id)NaN → silent no-op Resolves string ID → numeric label
save()/load() Metadata only Persists ID mappings in .meta.json (backward-compatible)

Test plan

  • 14 new unit tests covering UUID, prefix, hex, mixed, and numeric IDs
  • Search returns original string IDs with correct metadata
  • Remove works with string IDs
  • Batch insert works with string IDs
  • Save/load round-trips ID mappings
  • Legacy .meta.json format loads without error
  • Re-insert same ID reuses existing label
  • No regressions in existing backend tests

Closes #114

🤖 Generated with Claude Code

…ent data loss

The @ruvector/core N-API layer converts IDs via Number(), causing non-numeric
string IDs (UUIDs, hex hashes, prefixed IDs) to become NaN and be silently
dropped. Added bidirectional idToLabel/labelToId mapping in the AgentDB layer
as defense-in-depth alongside the upstream fix in @ruvector/rvf@0.2.0.

- insert(): Maps string IDs to sequential numeric labels before N-API call
- search(): Maps numeric labels back to original string IDs in results
- remove(): Resolves string ID to numeric label before N-API call
- save()/load(): Persists ID mappings in .meta.json sidecar (backward-compatible)
- Updated ruvector dependency to ^0.1.99
- Bumped version to 2.0.0-alpha.2.12

Closes #114

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
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.

RvfBackend silently drops vectors with non-numeric string IDs

1 participant