Derived ids change with the Python or Node Unicode version
メンテナーはふだん 1 日以内に返信
まだ誰も着手していません。
評価
- 難易度
- 5/5
- 見積もり時間
- 1週間以上
- 初心者へのやさしさ
- 45/100
- issue の種類
- バグ
- 明瞭さ
- 明確に書かれている
- 活発さ
- 活発
- 技術スタック
- node.js, python, typescript
調査の方向性
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.
索引モデルが issue の本文から書いたものです。
説明
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.
- 主要言語
- TypeScript
- スター
- 173
- フォーク
- 58
- 平均マージ
- 6時間
- マージ済み PR(30日)
- 120
環境構築
- Dockerfile・Docker Compose ファイルなし
- プルリクエストのテンプレートあり
- コントリビューションガイドを読む
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
hydra-db/selfgraph のほかの issue
-
approved-for-pr area: cli-mcp area: errors bug effort: S P3
難易度 2/5 1〜3時間 初心者へのやさしさ 74/100
hydra-db/selfgraph#401 · コメント 2 件 ·
メンテナーはふだん 1 日以内に返信
-
approved-for-pr area: errors area: store bug effort: S P3
難易度 2/5 1〜3時間 初心者へのやさしさ 84/100
hydra-db/selfgraph#398 · コメント 2 件 ·
メンテナーはふだん 1 日以内に返信
-
approved-for-pr area: errors area: write bug effort: S P3
難易度 2/5 1〜3時間 初心者へのやさしさ 77/100
hydra-db/selfgraph#392 · コメント 2 件 ·
メンテナーはふだん 1 日以内に返信
-
approved-for-pr area: parity area: write bug effort: S P3
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
hydra-db/selfgraph#391 · コメント 2 件 ·
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 76/100
メンテナーはふだん 1 日以内に返信
hydra-db/selfgraph の issue をすべて見る
似ている issue
-
難易度 2/5 1〜3時間 初心者へのやさしさ 77/100
code-yeongyu/senpi#7139 ·
メンテナーはふだん 1 日以内に返信
-
community first-timers-only good first issue hacktoberfest help wanted low hanging fruit up-for-grabs
難易度 1/5 1〜3時間 初心者へのやさしさ 72/100
lingdojo/kana-dojo#34395 · コメント 1 件 · リアクション 5 件 ·
メンテナーはふだん 1 日以内に返信
-
bug status: needs triage
難易度 2/5 1〜3時間 初心者へのやさしさ 75/100
mastra-ai/mastra#31093 · コメント 1 件 ·
メンテナーはふだん 1 日以内に返信
-
area:web p2 product:business triage:active type:bug
難易度 1/5 1時間未満 初心者へのやさしさ 89/100
cuadrao-ai/argus#2328 ·
メンテナーはふだん 1 日以内に返信
-
bug frontend good first issue help wanted
難易度 2/5 1〜3時間 初心者へのやさしさ 88/100
nikhilb2/simple_invoicing#907 ·