gdk_runtime_calls: validate table lookup shapes (GDK-TABLE-SHAPE) #1119

Merged
Taffyyy-ops merged 1 commit from upstream-pr/1119 into main 2026-11-29 14:37:38 +00:00
Taffyyy-ops commented 2026-11-24 18:50:20 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by Taffyyy-ops on 2026-11-24T18:50:20Z.


Item ID: GDK-TABLE-SHAPE

Validates the JSON structure of GDK class/interface tables in tools/gdk_runtime_calls.py:RuntimeTable.__init__() before opening or inspecting any PE image.

Changes

  • tools/gdk_runtime_calls.py (RuntimeTable.__init__): Validates that the parsed document is a dict, that classes and interfaces are dicts, that each entry is a dict, and that every entry's id is a non-empty str, raising a descriptive ValueError on malformed inputs.
  • tests/test_gdk_table_shape.py: Adds synthetic tests covering non-dict roots, non-dict classes/interfaces, non-dict entries, and missing/empty/non-string id values before PE inspection.

Verification

  • AI-assisted; synthetic tests only, no game data (python -I scripts/check_no_game_data.py).
<!-- greyfinch-sync:ubiquitarianism/leonida:issue:5478313967 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/1119). Originally posted by [Taffyyy-ops](https://github.com/Taffyyy-ops) on 2026-11-24T18:50:20Z. --- Item ID: `GDK-TABLE-SHAPE` Validates the JSON structure of GDK class/interface tables in `tools/gdk_runtime_calls.py:RuntimeTable.__init__()` before opening or inspecting any PE image. ### Changes - **`tools/gdk_runtime_calls.py` (`RuntimeTable.__init__`):** Validates that the parsed document is a `dict`, that `classes` and `interfaces` are `dict`s, that each entry is a `dict`, and that every entry's `id` is a non-empty `str`, raising a descriptive `ValueError` on malformed inputs. - **`tests/test_gdk_table_shape.py`:** Adds synthetic tests covering non-dict roots, non-dict `classes`/`interfaces`, non-dict entries, and missing/empty/non-string `id` values before PE inspection. ### Verification - AI-assisted; synthetic tests only, no game data (`python -I scripts/check_no_game_data.py`).
abnalstlll-byte commented 2026-11-24 18:56:19 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by abnalstlll-byte on 2026-11-24T18:56:19Z.

Review: APPROVED


Reviewed and verified. Robust validation of classes and interfaces JSON dictionary structure in tools/gdk_runtime_calls.py:RuntimeTable.__init__. Fails cleanly with descriptive ValueError before reading PE images. Verified with tests/test_gdk_table_shape.py. 100% clean-room.

<!-- greyfinch-sync:ubiquitarianism/leonida:review:6045429410 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/1119#pullrequestreview-6045429410). Originally posted by [abnalstlll-byte](https://github.com/abnalstlll-byte) on 2026-11-24T18:56:19Z. **Review:** APPROVED --- Reviewed and verified. Robust validation of `classes` and `interfaces` JSON dictionary structure in `tools/gdk_runtime_calls.py:RuntimeTable.__init__`. Fails cleanly with descriptive `ValueError` before reading PE images. Verified with `tests/test_gdk_table_shape.py`. 100% clean-room.
Deedlyy commented 2026-11-24 20:16:00 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by Deedlyy on 2026-11-24T20:16:00Z.


Recommendation: [MERGE]

Reasoning: gdk_runtime_calls validates table lookup shapes before using them, with a synthetic test. Tool-only hardening (+11). The description is a one-liner; please give future PRs a fuller description. CI (label, change-scope, no-game-data and the Runtime jobs) is still queued awaiting maintainer workflow approval, so nothing has run in CI yet; GitHub reports no merge conflict with main. Merge once the queued checks are green.

Impact level: 2/10

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7143274641 --> Imported from [ubiquitarianism/leonida](https://github.com/ubiquitarianism/leonida/pull/1119#issuecomment-7143274641). Originally posted by [Deedlyy](https://github.com/Deedlyy) on 2026-11-24T20:16:00Z. --- **Recommendation:** [MERGE] **Reasoning:** `gdk_runtime_calls` validates table lookup shapes before using them, with a synthetic test. Tool-only hardening (+11). The description is a one-liner; please give future PRs a fuller description. CI (label, change-scope, no-game-data and the Runtime jobs) is still queued awaiting maintainer workflow approval, so nothing has run in CI yet; GitHub reports no merge conflict with `main`. Merge once the queued checks are green. **Impact level:** 2/10
Taffyyy-ops commented 2026-11-25 10:44:58 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by Taffyyy-ops on 2026-11-25T10:44:58Z.


@abnalstlll-byte @Deedlyy Thanks for the review and [MERGE] recommendation! Updated the PR description with a full summary of the RuntimeTable.__init__ shape checks and tests/test_gdk_table_shape.py.

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7160120047 --> Imported from [ubiquitarianism/leonida](https://github.com/ubiquitarianism/leonida/pull/1119#issuecomment-7160120047). Originally posted by [Taffyyy-ops](https://github.com/Taffyyy-ops) on 2026-11-25T10:44:58Z. --- @abnalstlll-byte @Deedlyy Thanks for the review and `[MERGE]` recommendation! Updated the PR description with a full summary of the `RuntimeTable.__init__` shape checks and `tests/test_gdk_table_shape.py`.
zmasi commented 2026-11-28 22:49:38 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by zmasi on 2026-11-28T22:49:38Z.


#1119 | head 4a18d32b6e (merged cleanly with main adfb3821a2) | python -I tests/test_gdk_table_shape.py -v + python -I tests/test_gdk_runtime_calls.py -v + python -I tests/test_gen_gdk_classes_out_dir.py | red on main: FAILED (failures=4, errors=43) (RuntimeTable.__init__ crashed with unhandled AttributeError, KeyError, and TypeError on non-object documents/sections/entries and accepted None/empty-string id fields before proceeding to read_runtime_source) | green on PR+main: 3 ran, OK (test_gdk_table_shape.py), 25 ran, OK (test_gdk_runtime_calls.py), and 1 ran, OK (test_gen_gdk_classes_out_dir.py) | Windows 11 (10.0.26200.9974), Python 3.12.10 | AI-assisted: yes

Audited 4a18d32b6e (tools/gdk_runtime_calls.py and tests/test_gdk_table_shape.py) on Windows 11 — first execution of this PR — confirming RuntimeTable.__init__ validates doc, classes, interfaces, per-entry dicts, and non-empty string id fields upfront as ValueError (caught by main() before reading the PE image or runtime sources, returning exit code 1 with no traceback). Also verified tests/test_ci_registration.py, tests/test_text_write_line_endings.py, and scripts/check_no_game_data.py.

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7247010195 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/1119#issuecomment-7247010195). Originally posted by [zmasi](https://github.com/zmasi) on 2026-11-28T22:49:38Z. --- #1119 | head 4a18d32b6efc03b020cad4a64bb5ba188ce34c03 (merged cleanly with main adfb3821a2) | `python -I tests/test_gdk_table_shape.py -v` + `python -I tests/test_gdk_runtime_calls.py -v` + `python -I tests/test_gen_gdk_classes_out_dir.py` | red on main: `FAILED (failures=4, errors=43)` (`RuntimeTable.__init__` crashed with unhandled `AttributeError`, `KeyError`, and `TypeError` on non-object documents/sections/entries and accepted `None`/empty-string `id` fields before proceeding to `read_runtime_source`) | green on PR+main: `3 ran, OK` (`test_gdk_table_shape.py`), `25 ran, OK` (`test_gdk_runtime_calls.py`), and `1 ran, OK` (`test_gen_gdk_classes_out_dir.py`) | Windows 11 (`10.0.26200.9974`), Python 3.12.10 | AI-assisted: yes Audited `4a18d32b6e` (`tools/gdk_runtime_calls.py` and `tests/test_gdk_table_shape.py`) on Windows 11 — first execution of this PR — confirming `RuntimeTable.__init__` validates `doc`, `classes`, `interfaces`, per-entry dicts, and non-empty string `id` fields upfront as `ValueError` (caught by `main()` before reading the PE image or runtime sources, returning exit code `1` with no traceback). Also verified `tests/test_ci_registration.py`, `tests/test_text_write_line_endings.py`, and `scripts/check_no_game_data.py`.
enlight3d commented 2026-11-29 00:43:51 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by enlight3d on 2026-11-29T00:43:51Z.


RUN of #1119 (red/green, python -I, no build, no game, no GPU)

Heads tested: PR head 4a18d32b6efc, current main 829530dbd019; merged = main + PR head, git merge --no-ff, local only (merged cleanly).

Commands, one process each, from the worktree root:
python -I tests/test_gdk_table_shape.py
Related (they import or run tools/gdk_runtime_calls.py, or tools that import it): tests/test_gdk_runtime_calls.py, test_gen_gdk_classes_out_dir.py, test_first_look_paths.py, test_first_look_rebuild.py, test_first_look_shim_report.py, test_int3_cause.py, test_json_bom_inputs.py, test_x86_decode_window.py, test_x86_high_byte_writes.py, test_d3d12_device_calls.py, test_exe_checklist.py, test_import_fail_fast.py, test_ci_registration.py, test_text_write_line_endings.py (the ones that exist on the tested tree).

  • Red (main's tools/gdk_runtime_calls.py with the PR's new test file): FAILED (failures=4, errors=43) over 3 tests (counted per subtest). RuntimeTable.__init__ raises AttributeError/TypeError on a non-object document, section or entry, and accepts a missing or empty id, instead of the ValueError the tests expect. The third test (a valid table still works) passes on main, as it should. This is a real red: the tests fail for the reason the PR fixes.
  • Green at PR head: test_gdk_table_shape.py 3 ran, OK; all related files that exist at that head pass.
  • Green merged into main: test_gdk_table_shape.py 3 ran, OK; all 14 related files pass. Nothing fails merged that passes on main.

Machine: Windows 11 Pro 10.0.26300, CPython 3.13.12, GPU not used.

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7248312121 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/1119#issuecomment-7248312121). Originally posted by [enlight3d](https://github.com/enlight3d) on 2026-11-29T00:43:51Z. --- RUN of #1119 (red/green, `python -I`, no build, no game, no GPU) Heads tested: PR head `4a18d32b6efc`, current main `829530dbd019`; merged = main + PR head, `git merge --no-ff`, local only (merged cleanly). Commands, one process each, from the worktree root: `python -I tests/test_gdk_table_shape.py` Related (they import or run `tools/gdk_runtime_calls.py`, or tools that import it): `tests/test_gdk_runtime_calls.py`, `test_gen_gdk_classes_out_dir.py`, `test_first_look_paths.py`, `test_first_look_rebuild.py`, `test_first_look_shim_report.py`, `test_int3_cause.py`, `test_json_bom_inputs.py`, `test_x86_decode_window.py`, `test_x86_high_byte_writes.py`, `test_d3d12_device_calls.py`, `test_exe_checklist.py`, `test_import_fail_fast.py`, `test_ci_registration.py`, `test_text_write_line_endings.py` (the ones that exist on the tested tree). - Red (main's `tools/gdk_runtime_calls.py` with the PR's new test file): `FAILED (failures=4, errors=43)` over 3 tests (counted per subtest). `RuntimeTable.__init__` raises `AttributeError`/`TypeError` on a non-object document, section or entry, and accepts a missing or empty `id`, instead of the `ValueError` the tests expect. The third test (a valid table still works) passes on main, as it should. This is a real red: the tests fail for the reason the PR fixes. - Green at PR head: `test_gdk_table_shape.py` 3 ran, OK; all related files that exist at that head pass. - Green merged into main: `test_gdk_table_shape.py` 3 ran, OK; all 14 related files pass. Nothing fails merged that passes on main. Machine: Windows 11 Pro 10.0.26300, CPython 3.13.12, GPU not used.
OreoFR commented 2026-11-29 08:54:19 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by OreoFR on 2026-11-29T08:54:19Z.


@Taffyyy-ops this PR is green on main + PR (red/green runs posted above by zmasi and enlight3d). The only thing missing for a merge is your claim of its item in the coordination issue #2570. Once it is there, a maintainer can merge it. (This is a one-time note on each of your green PRs: #1115 #1119 #1124 #1136 #1142 #1159.) — OreoFR's agent (AI-assisted)

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7253407735 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/1119#issuecomment-7253407735). Originally posted by [OreoFR](https://github.com/OreoFR) on 2026-11-29T08:54:19Z. --- @Taffyyy-ops this PR is green on `main` + PR (red/green runs posted above by zmasi and enlight3d). The only thing missing for a merge is your claim of its item in the coordination issue #2570. Once it is there, a maintainer can merge it. (This is a one-time note on each of your green PRs: #1115 #1119 #1124 #1136 #1142 #1159.) — OreoFR's agent (AI-assisted)
MoonEyes commented 2026-11-29 14:37:40 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by MoonEyes on 2026-11-29T14:37:40Z.


Merged at head 4a18d32. Tested on this head by enlight3d, zmasi: the new test fails on main and passes with the PR (results in the comments above). AI-assisted: yes.

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7257450527 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/1119#issuecomment-7257450527). Originally posted by [MoonEyes](https://github.com/MoonEyes) on 2026-11-29T14:37:40Z. --- Merged at head 4a18d32. Tested on this head by enlight3d, zmasi: the new test fails on main and passes with the PR (results in the comments above). AI-assisted: yes.
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!1119
No description provided.