glb_inspect: diagnose broken skin joint and bind matrix references #1745

Merged
kirigayakazima merged 2 commits from upstream-pr/1745 into main 2026-11-28 14:56:23 +00:00
kirigayakazima commented 2026-11-25 11:03:59 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by kirigayakazima on 2026-11-25T11:03:59Z.


Claimed in the coordination issue as: GLB-INSPECT-SKIN-REFERENCES

What and why

A skin with duplicate joints or a broken skeleton link looked identical to a healthy skin with the same joint count. The inspector now identifies invalid joint slots, missing skeleton or accessor references, non-MAT4 accessors and insufficient matrix counts. The optional inverse bind matrix accessor can still be omitted. glTF skin specification

Tested

The synthetic fixture covers duplicate joints, malformed and unresolved node indices, missing accessors, wrong matrix types, short counts and a valid accessor with extra matrices.

  • python -I tests/test_glb_inspect.py on Windows with Python 3.14.7 ran 37 tests on this branch with one platform skip. The new tests also failed against the original inspector.
  • python -I scripts/check_no_game_data.py tools/glb_inspect.py tests/test_glb_inspect.py and git diff --check passed.
  • The shared base at bcaa13da passed 6,287 semantic tests across 488 files.

GPUs tested: N/A (CPU-only metadata inspection).
AI-assisted: Yes.

Checklist

  • Based on current upstream main.
  • One topic.
  • All test inputs are synthetic. No game data, keys or decryption.
  • Translator contract table: N/A.
<!-- greyfinch-sync:ubiquitarianism/leonida:issue:5490083181 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/1745). Originally posted by [kirigayakazima](https://github.com/kirigayakazima) on 2026-11-25T11:03:59Z. --- Claimed in the coordination issue as: [GLB-INSPECT-SKIN-REFERENCES](https://github.com/ubiquitarianism/leonida/issues/1608#issuecomment-7160388047) ### What and why A skin with duplicate joints or a broken skeleton link looked identical to a healthy skin with the same joint count. The inspector now identifies invalid joint slots, missing skeleton or accessor references, non-MAT4 accessors and insufficient matrix counts. The optional inverse bind matrix accessor can still be omitted. [glTF skin specification](https://github.com/KhronosGroup/glTF/blob/main/specification/2.0/Specification.adoc#skins) ### Tested The synthetic fixture covers duplicate joints, malformed and unresolved node indices, missing accessors, wrong matrix types, short counts and a valid accessor with extra matrices. - `python -I tests/test_glb_inspect.py` on Windows with Python 3.14.7 ran 37 tests on this branch with one platform skip. The new tests also failed against the original inspector. - `python -I scripts/check_no_game_data.py tools/glb_inspect.py tests/test_glb_inspect.py` and `git diff --check` passed. - The shared base at `bcaa13da` passed 6,287 semantic tests across 488 files. GPUs tested: N/A (CPU-only metadata inspection). AI-assisted: Yes. ### Checklist - [x] Based on current upstream main. - [x] One topic. - [x] All test inputs are synthetic. No game data, keys or decryption. - Translator contract table: N/A.
lixonik commented 2026-11-25 11:19:47 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by lixonik on 2026-11-25T11:19:47Z.

Review: COMMENTED


Independent check at "0eed8e40". Windows: 36 tests reported, 1 platform skip. The extra CLI check uncovered one invalid inverse-bind accessor that the new diagnostics miss. Details inline.

AI-assisted review and CPU-only testing with synthetic inputs.

<!-- greyfinch-sync:ubiquitarianism/leonida:review:6056670143 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/1745#pullrequestreview-6056670143). Originally posted by [lixonik](https://github.com/lixonik) on 2026-11-25T11:19:47Z. **Review:** COMMENTED --- Independent check at "0eed8e40". Windows: 36 tests reported, 1 platform skip. The extra CLI check uncovered one invalid inverse-bind accessor that the new diagnostics miss. Details inline. AI-assisted review and CPU-only testing with synthetic inputs.
lixonik commented 2026-11-25 11:19:48 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by lixonik on 2026-11-25T11:19:48Z.

Code review location: tools/glb_inspect.py; line 520

@@ -494,6 +494,39 @@ def _mesh_report(gltf: dict, index: int, mesh: dict) -> dict:
     }
 
 
+def _skin_report(gltf: dict, index: int, skin: dict) -> dict:
+    joints = skin.get("joints")
+    joint_count = len(joints) if isinstance(joints, list) else None
+    report = {"index": index, "name": _text(skin.get("name")), "joint_count": joint_count}
+    issues = []
+    if not joint_count:
+        issues.append("joints must be a non-empty array")
+    seen = set()
+    for slot, joint in enumerate(_array(joints)):
+        if _entry(gltf, "nodes", joint) is None:
+            issues.append(f"joints[{slot}] does not reference a node")
+        elif joint in seen:
+            issues.append(f"joints[{slot}] repeats node {joint}")
+        else:
+            seen.add(joint)
+    if "skeleton" in skin and _entry(gltf, "nodes", skin["skeleton"]) is None:
+        issues.append("skeleton does not reference a node")
+    if "inverseBindMatrices" in skin:
+        accessor_index = skin["inverseBindMatrices"]
+        accessor = _accessor(gltf, accessor_index)
+        if accessor is None:
+            issues.append("inverseBindMatrices does not reference an accessor")
+        else:
+            if accessor.get("type") != "MAT4":

The new check accepts an integer MAT4 as a valid inverse-bind accessor. I inspected a synthetic one-joint skin whose accessor declared type: MAT4, count: 1 and componentType: 5123. Its skin report had no issues. Could this also check componentType == 5126? Inverse bind matrices require floating-point components. glTF 2.0 skin specification

<!-- greyfinch-sync:ubiquitarianism/leonida:review-comment:4694120825 --> Imported from [ubiquitarianism/leonida](https://github.com/ubiquitarianism/leonida/pull/1745#discussion_r4694120825). Originally posted by [lixonik](https://github.com/lixonik) on 2026-11-25T11:19:48Z. **Code review location:** `tools/glb_inspect.py`; line 520 ~~~~diff @@ -494,6 +494,39 @@ def _mesh_report(gltf: dict, index: int, mesh: dict) -> dict: } +def _skin_report(gltf: dict, index: int, skin: dict) -> dict: + joints = skin.get("joints") + joint_count = len(joints) if isinstance(joints, list) else None + report = {"index": index, "name": _text(skin.get("name")), "joint_count": joint_count} + issues = [] + if not joint_count: + issues.append("joints must be a non-empty array") + seen = set() + for slot, joint in enumerate(_array(joints)): + if _entry(gltf, "nodes", joint) is None: + issues.append(f"joints[{slot}] does not reference a node") + elif joint in seen: + issues.append(f"joints[{slot}] repeats node {joint}") + else: + seen.add(joint) + if "skeleton" in skin and _entry(gltf, "nodes", skin["skeleton"]) is None: + issues.append("skeleton does not reference a node") + if "inverseBindMatrices" in skin: + accessor_index = skin["inverseBindMatrices"] + accessor = _accessor(gltf, accessor_index) + if accessor is None: + issues.append("inverseBindMatrices does not reference an accessor") + else: + if accessor.get("type") != "MAT4": ~~~~ --- The new check accepts an integer MAT4 as a valid inverse-bind accessor. I inspected a synthetic one-joint skin whose accessor declared `type: MAT4`, `count: 1` and `componentType: 5123`. Its skin report had no issues. Could this also check `componentType == 5126`? Inverse bind matrices require floating-point components. [glTF 2.0 skin specification](https://registry.khronos.org/glTF/specs/2.0/glTF-2.0.html#skins)
kirigayakazima commented 2026-11-27 12:11:43 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by kirigayakazima on 2026-11-27T12:11:43Z.

Code review location: tools/glb_inspect.py; line 520

@@ -494,6 +494,39 @@ def _mesh_report(gltf: dict, index: int, mesh: dict) -> dict:
     }
 
 
+def _skin_report(gltf: dict, index: int, skin: dict) -> dict:
+    joints = skin.get("joints")
+    joint_count = len(joints) if isinstance(joints, list) else None
+    report = {"index": index, "name": _text(skin.get("name")), "joint_count": joint_count}
+    issues = []
+    if not joint_count:
+        issues.append("joints must be a non-empty array")
+    seen = set()
+    for slot, joint in enumerate(_array(joints)):
+        if _entry(gltf, "nodes", joint) is None:
+            issues.append(f"joints[{slot}] does not reference a node")
+        elif joint in seen:
+            issues.append(f"joints[{slot}] repeats node {joint}")
+        else:
+            seen.add(joint)
+    if "skeleton" in skin and _entry(gltf, "nodes", skin["skeleton"]) is None:
+        issues.append("skeleton does not reference a node")
+    if "inverseBindMatrices" in skin:
+        accessor_index = skin["inverseBindMatrices"]
+        accessor = _accessor(gltf, accessor_index)
+        if accessor is None:
+            issues.append("inverseBindMatrices does not reference an accessor")
+        else:
+            if accessor.get("type") != "MAT4":

Fixed: _skin_report() now verifies accessor.get('componentType') == 5126 (FLOAT) for inverseBindMatrices. Added regression test with componentType: 5123 in tests/test_glb_inspect.py.

<!-- greyfinch-sync:ubiquitarianism/leonida:review-comment:4719209999 --> Imported from [ubiquitarianism/leonida](https://github.com/ubiquitarianism/leonida/pull/1745#discussion_r4719209999). Originally posted by [kirigayakazima](https://github.com/kirigayakazima) on 2026-11-27T12:11:43Z. **Code review location:** `tools/glb_inspect.py`; line 520 ~~~~diff @@ -494,6 +494,39 @@ def _mesh_report(gltf: dict, index: int, mesh: dict) -> dict: } +def _skin_report(gltf: dict, index: int, skin: dict) -> dict: + joints = skin.get("joints") + joint_count = len(joints) if isinstance(joints, list) else None + report = {"index": index, "name": _text(skin.get("name")), "joint_count": joint_count} + issues = [] + if not joint_count: + issues.append("joints must be a non-empty array") + seen = set() + for slot, joint in enumerate(_array(joints)): + if _entry(gltf, "nodes", joint) is None: + issues.append(f"joints[{slot}] does not reference a node") + elif joint in seen: + issues.append(f"joints[{slot}] repeats node {joint}") + else: + seen.add(joint) + if "skeleton" in skin and _entry(gltf, "nodes", skin["skeleton"]) is None: + issues.append("skeleton does not reference a node") + if "inverseBindMatrices" in skin: + accessor_index = skin["inverseBindMatrices"] + accessor = _accessor(gltf, accessor_index) + if accessor is None: + issues.append("inverseBindMatrices does not reference an accessor") + else: + if accessor.get("type") != "MAT4": ~~~~ --- Fixed: `_skin_report()` now verifies `accessor.get('componentType') == 5126` (`FLOAT`) for `inverseBindMatrices`. Added regression test with `componentType: 5123` in `tests/test_glb_inspect.py`.
lixonik commented 2026-11-27 15:50:22 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by lixonik on 2026-11-27T15:50:22Z.

Review: COMMENTED


Re-verified at 2d8bce897 (merged cleanly onto main ec91d695c).

  • Confirmed the prior finding is resolved: _skin_report() now requires componentType == 5126 (FLOAT) on inverseBindMatrices accessors and rejects integer MAT4 accessors (verified with componentType: 5123 and 5126, plus the new regression test).
  • Windows 11, Python 3.12: python -I -B tests/test_glb_inspect.py -v passed (37 tests, 1 expected Windows POSIX-permission skip); scripts/check_no_game_data.py and git diff --check clean.
  • No remaining findings.

AI-assisted.

<!-- greyfinch-sync:ubiquitarianism/leonida:review:6090597024 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/1745#pullrequestreview-6090597024). Originally posted by [lixonik](https://github.com/lixonik) on 2026-11-27T15:50:22Z. **Review:** COMMENTED --- Re-verified at `2d8bce897` (merged cleanly onto `main` `ec91d695c`). - Confirmed the prior finding is resolved: `_skin_report()` now requires `componentType == 5126` (`FLOAT`) on `inverseBindMatrices` accessors and rejects integer `MAT4` accessors (verified with `componentType: 5123` and `5126`, plus the new regression test). - Windows 11, Python 3.12: `python -I -B tests/test_glb_inspect.py -v` passed (37 tests, 1 expected Windows POSIX-permission skip); `scripts/check_no_game_data.py` and `git diff --check` clean. - No remaining findings. AI-assisted.
zmasi commented 2026-11-28 11:25:15 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by zmasi on 2026-11-28T11:25:15Z.


#1745 | head 2d8bce8970 (merged cleanly with main 4a54aedcb) | python -I tests/test_glb_inspect.py | red on main: FAILED (errors=2, skipped=6) (KeyError: 'issues' on broken skin joint, skeleton, and inverseBindMatrices references) | green on PR+main: 38 tests OK (skipped=6) | Windows 11, Python 3.12.10 | AI-assisted: yes

Audited _skin_report and format_report in tools/glb_inspect.py (validating non-empty joints, missing/duplicate joint node indices, skeleton node index, and inverseBindMatrices accessor MAT4 type, FLOAT (5126) componentType, and count >= joint_count). Also verified clean merge (0 conflicts) and combined execution with #1744 (39 tests OK (skipped=6)), plus tests/test_ci_registration.py (18 OK), tests/test_text_write_line_endings.py (3 OK), and scripts/check_no_game_data.py.

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7238539262 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/1745#issuecomment-7238539262). Originally posted by [zmasi](https://github.com/zmasi) on 2026-11-28T11:25:15Z. --- #1745 | head 2d8bce8970019cb87afce5cd6c7dbe3a2434f8f4 (merged cleanly with main 4a54aedcb) | `python -I tests/test_glb_inspect.py` | red on main: `FAILED (errors=2, skipped=6)` (`KeyError: 'issues'` on broken skin joint, skeleton, and inverseBindMatrices references) | green on PR+main: `38 tests OK (skipped=6)` | Windows 11, Python 3.12.10 | AI-assisted: yes Audited `_skin_report` and `format_report` in `tools/glb_inspect.py` (validating non-empty `joints`, missing/duplicate joint node indices, `skeleton` node index, and `inverseBindMatrices` accessor `MAT4` type, `FLOAT (5126)` componentType, and `count >= joint_count`). Also verified clean merge (`0` conflicts) and combined execution with #1744 (`39 tests OK (skipped=6)`), plus `tests/test_ci_registration.py` (`18 OK`), `tests/test_text_write_line_endings.py` (`3 OK`), and `scripts/check_no_game_data.py`.
MoonEyes commented 2026-11-28 14:56:20 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by MoonEyes on 2026-11-28T14:56:20Z.


Red/green: pytest tests/test_glb_inspect.py fails on main (2 failed, 30 passed, 6 skipped, 7 subtests passed) and passes on head 2d8bce8970 merged with main (32 passed, 6 skipped, 7 subtests passed).
Targeted batch (PR tests, tests importing the changed modules, docs tests, translator when touched) merged on main d48a957bb in GitHub Actions: no new failure.
AI-assisted (Claude Code, Claude Opus 5.5)

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7241052688 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/1745#issuecomment-7241052688). Originally posted by [MoonEyes](https://github.com/MoonEyes) on 2026-11-28T14:56:20Z. --- Red/green: `pytest tests/test_glb_inspect.py` fails on main (2 failed, 30 passed, 6 skipped, 7 subtests passed) and passes on head 2d8bce897001 merged with main (32 passed, 6 skipped, 7 subtests passed). Targeted batch (PR tests, tests importing the changed modules, docs tests, translator when touched) merged on main d48a957bb in GitHub Actions: no new failure. AI-assisted (Claude Code, Claude Opus 5.5)
Sign in to join this conversation.
No reviewers
No labels
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Reference
ProjectLeonida/mandy!1745
No description provided.