Summary
String keys containing lone UTF-16 surrogates encode to UTF-8 replacement or collide after utf8.encode in kv/doc id paths — distinct strings can map to same bytes.
Audit ID: Section 4 Low — Wave 3
Location: src/lens/kv.ts:62 and shared utf8 helpers
Options
- Reject invalid Unicode in string keys/ids at API boundary (throw).
- Document that keys must be valid UTF-8 strings; surrogate pairs only.
Acceptance criteria
Summary
String keys containing lone UTF-16 surrogates encode to UTF-8 replacement or collide after
utf8.encodein kv/doc id paths — distinct strings can map to same bytes.Audit ID: Section 4 Low — Wave 3
Location:
src/lens/kv.ts:62and shared utf8 helpersOptions
Acceptance criteria