Derived ids change with the Python or Node Unicode version
Los mantenedores suelen responder en 1 día
Nadie ha tomado este issue todavía.
Evaluación
- Dificultad
- 5/5
- Tiempo estimado
- Más de una semana
- Aptitud para principiantes
- 45/100
- Tipo de issue
- Error
- Claridad
- Bien especificado
- Estado de actividad
- Activo
- Stack tecnológico
- node.js, python, typescript
Línea de trabajo
Read src/selfgraph/ids.py, src/selfgraph/retrieval.py, typescript/src/ids.ts, and typescript/src/internal/casefold.ts, then inspect the conformance suite. The issue proposes pinning letter and digit classes plus lowercase and casefold tables to one Unicode version shared by both SDKs. Done means derived IDs, relation types, and retrieval tokens no longer vary with Python or Node Unicode versions, with conformance coverage for the reported cases.
Escrito por el modelo de indexación a partir del texto del issue.
Descripción
docs/resources.md says combining marks come "from one fixed list, the marks of Unicode 15.0, so an id does not depend on the Python or Node version." Only the marks are pinned. Letters, digits, and case still come from the runtime: \w and str.lower() in Python, \p{L}/\p{N} and toLowerCase() in TypeScript. A character the runtime does not know yet is treated as punctuation and dropped from the id. So the same name derives a different id depending on the Python minor version, and Python and Node disagree whenever their Unicode versions differ.
Tested at 5a277c9 (current main), using the ids.py from that commit under each interpreter, and the TypeScript entityId from the same commit on Node 26.12.
Reproduce
from selfgraph import entity_id
for name in ["王\U0002EBF0", "王\U0002EBF1", "王\U000323B0", "Таня \u1C89а"]:
print(ascii(entity_id("Person", name)))
The first two names use CJK Extension I ideographs (Unicode 15.1), the third an Extension J ideograph (Unicode 17.0), and the fourth Cyrillic capital TJE (Unicode 16.0).
| runtime | Unicode | 王 + U+2EBF0 | 王 + U+2EBF1 | 王 + U+323B0 | Таня + U+1C89 а |
|---|---|---|---|---|---|
| Python 3.11 | 14.0 | person:王 |
person:王 |
person:王 |
person:таня-а |
| Python 3.12 | 15.0 | person:王 |
person:王 |
person:王 |
person:таня-а |
| Python 3.13 | 15.1 | person:王 |
person:王 |
person:王 |
person:таня-а |
| Python 3.14 | 16.0 | person:王 |
person:王 |
person:王 |
person:таня-а |
| Python 3.15 | 17.0 | person:王 |
person:王 |
person:王 |
person:таня-а |
| Node 26 (ICU 78) | 17.0 | person:王 |
person:王 |
person:王 |
person:таня-а |
Two things go wrong:
- On an older runtime, different names merge. On Python 3.12,
王and王are one entity,person:王, and so is a plain王. - Upgrading Python changes ids. A graph built on Python 3.12 holds
person:王. After moving to 3.13, inserting the same name derivesperson:王, which no longer matches the stored entity, so a duplicate appears and lookups by the derived id miss the old one. Relation ids derived from those entity ids change with them.
Scanning every code point with entity_id("Person", "Ann " + c + "x"), the number that derive a different id between consecutive Python versions is:
| upgrade | code points |
|---|---|
| 3.10 to 3.11 | 525 |
| 3.11 to 3.12 | 4,388 |
| 3.12 to 3.13 | 622 |
| 3.13 to 3.14 | 4,382 |
| 3.14 to 3.15 | 4,657 |
That is 14,574 between 3.10 and 3.15. normalize_rel_type and the retrieval tokens are built from the same classes and case mappings, so they shift with the runtime too.
The two SDKs also disagree today on the same machine. Python 3.14 (Unicode 16.0) and Node 26 (Unicode 17.0) derive different entity_id, normalize_rel_type, and retrieval tokens for 4,657 code points. That breaks the byte-for-byte id agreement between the SDKs, and the conformance suite does not catch it.
TypeScript is also inconsistent with itself. casefold in typescript/src/internal/casefold.ts is pinned to the Unicode 15.0 tables, while entityId uses the runtime's toLowerCase. On Node 26, entityId("Person", "ama") gives person:ɤama (U+A7CB, Unicode 16.0, lowercased by ICU), but tokenList("ama") gives ["ama"], so a query for "ɤama" does not seed it. Python 3.14 folds both.
Cause
- Python:
_PUNCTand_NON_IDENT(src/selfgraph/ids.py:208-209) use\w, andslugand_canonical_nameusestr.lower()(src/selfgraph/ids.py:309,:311). Both followunicodedata.unidata_version, which is 13.0 on Python 3.10 and 17.0 on 3.15. Retrieval's_fold(src/selfgraph/retrieval.py:161) usesstr.casefold(), which follows it too. - TypeScript:
PUNCTandNON_IDENT(typescript/src/ids.ts:27-28) usePY_WORD_CLASS = "\p{L}\p{N}_"(typescript/src/internal/py.ts:6), andslug,canonicalName, andnormalizeRelTypeusetoLowerCase()/toUpperCase()(typescript/src/ids.ts:126,:131,:202). All of these follow the ICU bundled with Node.
MARK_CLASS and the TypeScript casefold table are pinned to Unicode 15.0. The letter and digit classes and the case mappings are not.
Pinning those too would make ids independent of the runtime, in line with the docs: a fixed letter/digit class (like MARK_CLASS) and fixed lowercase and casefold tables from one Unicode version, shared by both SDKs. Changing the pinned version later would then be an explicit, migrated change rather than a side effect of upgrading Python or Node.
Related: #312 and #337 are other cases where case mapping in the id and token code produces keys that do not match.
- Lenguaje dominante
- TypeScript
- Estrellas
- 173
- Forks
- 58
- Merge medio
- 6 h
- PR fusionados (30 d)
- 120
Preparar el entorno
- Sin Dockerfile ni archivo de Docker Compose
- Tiene una plantilla de pull request
- Leer la guía de contribución
Primeros pasos
- Lee el issue completo y luego la guía de contribución del proyecto.
- Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
- Haz un fork del repositorio y trabaja en una rama.
- Abre un pull request que haga referencia al número del issue.
Más de hydra-db/selfgraph
-
approved-for-pr area: cli-mcp area: errors bug effort: S P3
Dificultad 2/5 1-3 horas Aptitud para principiantes 74/100
hydra-db/selfgraph#401 · 2 comentarios ·
Los mantenedores suelen responder en 1 día
-
approved-for-pr area: errors area: store bug effort: S P3
Dificultad 2/5 1-3 horas Aptitud para principiantes 84/100
hydra-db/selfgraph#398 · 2 comentarios ·
Los mantenedores suelen responder en 1 día
-
approved-for-pr area: errors area: write bug effort: S P3
Dificultad 2/5 1-3 horas Aptitud para principiantes 77/100
hydra-db/selfgraph#392 · 2 comentarios ·
Los mantenedores suelen responder en 1 día
-
approved-for-pr area: parity area: write bug effort: S P3
Dificultad 2/5 1-3 horas Aptitud para principiantes 78/100
hydra-db/selfgraph#391 · 2 comentarios ·
Los mantenedores suelen responder en 1 día
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 76/100
Los mantenedores suelen responder en 1 día
Todos los issues de hydra-db/selfgraph
Issues similares
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 77/100
code-yeongyu/senpi#7139 ·
Los mantenedores suelen responder en 1 día
-
community first-timers-only good first issue hacktoberfest help wanted low hanging fruit up-for-grabs
Dificultad 1/5 1-3 horas Aptitud para principiantes 72/100
lingdojo/kana-dojo#34395 · 1 comentario · 5 reacciones ·
Los mantenedores suelen responder en 1 día
-
bug status: needs triage
Dificultad 2/5 1-3 horas Aptitud para principiantes 75/100
mastra-ai/mastra#31093 · 1 comentario ·
Los mantenedores suelen responder en 1 día
-
area:web p2 product:business triage:active type:bug
Dificultad 1/5 Menos de una hora Aptitud para principiantes 89/100
cuadrao-ai/argus#2328 ·
Los mantenedores suelen responder en 1 día
-
bug frontend good first issue help wanted
Dificultad 2/5 1-3 horas Aptitud para principiantes 88/100
nikhilb2/simple_invoicing#907 ·