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

Merged
leonida/mandy
Taffyyy-ops merged 1 commit from fix/gdk-table-shape into main 2026-11-29 14:37:38 +00:00

Pull request successfully merged and closed

Taffyyy-ops commented 2026-11-24 18:50:20 +00:00

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).
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 approved these changes 2026-11-24 18:56:19 +00:00
abnalstlll-byte left a comment

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.

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

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

**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

@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.

@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

#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.

#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

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.

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

@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)

@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

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.

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 description provided.