mirror of
https://github.com/abhigyanpatwari/GitNexus.git
synced 2026-11-23 22:06:04 +00:00
* fix(embeddings): reject corrupt identities before mutation (U2) * fix(embeddings): preserve exact Unicode keys (U2) * fix(storage): validate identities before opening CSVs * fix(embeddings): validate caches before mutation * ci: gate native embedding identity benchmark * test(embeddings): run identity proofs on native OSes * docs: describe CSV identity validation pass --------- Co-authored-by: Gergo Magyar <gergomagyar0@gmail.com>
15 lines
707 B
TypeScript
15 lines
707 B
TypeScript
/** Identity columns must survive CSV encoding and address exactly one node. */
|
|
export function assertValidGraphNodeId(id: unknown, context: string): asserts id is string {
|
|
if (
|
|
typeof id === 'string' &&
|
|
id.trim().length > 0 &&
|
|
// CSV normalizes CR and strips these characters. The Unicode flag matches
|
|
// lone surrogates while preserving valid supplementary code points.
|
|
!/[\x00-\x08\x0B-\x1F\x7F\uD800-\uDFFF\uFFFE\uFFFF]/u.test(id)
|
|
)
|
|
return;
|
|
const sample = typeof id === 'string' ? JSON.stringify(id.slice(0, 120)) : typeof id;
|
|
throw new Error(
|
|
`${context}: invalid graph node ID (${sample}). Index integrity cannot be verified; rebuild with analyze --force.`,
|
|
);
|
|
}
|