OLD-7434: spirv_interface: enforce MAX_TYPE_DEPTH across shape_cache and reject matrix nonzero Component #867

Merged
narekshaghoyandev merged 1 commit from upstream-pr/867 into main 2026-11-24 21:03:55 +00:00
narekshaghoyandev commented 2026-11-24 14:50:15 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by narekshaghoyandev on 2026-11-24T14:50:15Z.


Reopening my original upstream PR #7434 (previously double-approved by @leoleahy and @devnull34, verified on Linux + Windows 11) cleanly rebased onto main:

  1. Enforce MAX_TYPE_DEPTH across shape_cache (_describe_type): Previously, caching a type's shape without tracking its subtree depth allowed a cached deep type to be wrapped in another outer type and bypass MAX_TYPE_DEPTH. Now tracks/checks subtree depth on cache hits so MAX_TYPE_DEPTH is enforced consistently.
  2. Reject matrix nonzero Component decoration (VUID-StandaloneSpirv-Component-04920): Rejects OpTypeMatrix interface variables/members with nonzero Component instead of silently accepting them.

Verification

  • python3 -I tests/test_spirv_interface.py -v: 43/43 pass (2/2 fail against main).
  • python3 -I tests/test_shader_link_check.py -v: 50/50 pass.
  • python3 -I scripts/check_no_game_data.py tools/spirv_interface.py tests/test_spirv_interface.py: clean.
  • python3 -m compileall -q tools/spirv_interface.py tests/test_spirv_interface.py: clean.

Claimed in the coordination issue as: OLD-7434 (https://github.com/ubiquitarianism/leonida/issues/14#issuecomment-7135007136)
AI-assisted: yes (Gemini)

<!-- greyfinch-sync:ubiquitarianism/leonida:issue:5474474497 --> Imported from [ubiquitarianism/leonida](https://github.com/ubiquitarianism/leonida/pull/867). Originally posted by [narekshaghoyandev](https://github.com/narekshaghoyandev) on 2026-11-24T14:50:15Z. --- Reopening my original upstream PR #7434 (previously double-approved by `@leoleahy` and `@devnull34`, verified on Linux + Windows 11) cleanly rebased onto `main`: 1. **Enforce `MAX_TYPE_DEPTH` across `shape_cache` (`_describe_type`)**: Previously, caching a type's shape without tracking its subtree depth allowed a cached deep type to be wrapped in another outer type and bypass `MAX_TYPE_DEPTH`. Now tracks/checks subtree depth on cache hits so `MAX_TYPE_DEPTH` is enforced consistently. 2. **Reject matrix nonzero `Component` decoration (`VUID-StandaloneSpirv-Component-04920`)**: Rejects `OpTypeMatrix` interface variables/members with nonzero `Component` instead of silently accepting them. ### Verification - `python3 -I tests/test_spirv_interface.py -v`: 43/43 pass (2/2 fail against `main`). - `python3 -I tests/test_shader_link_check.py -v`: 50/50 pass. - `python3 -I scripts/check_no_game_data.py tools/spirv_interface.py tests/test_spirv_interface.py`: clean. - `python3 -m compileall -q tools/spirv_interface.py tests/test_spirv_interface.py`: clean. Claimed in the coordination issue as: OLD-7434 (https://github.com/ubiquitarianism/leonida/issues/14#issuecomment-7135007136) AI-assisted: yes (Gemini)
abnalstlll-byte commented 2026-11-24 14:52:17 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by abnalstlll-byte on 2026-11-24T14:52:17Z.

Review: APPROVED


Audited and verified. Tracks shape_depth across shape_cache lookups to strictly enforce MAX_TYPE_DEPTH on cached subtrees, preventing RecursionError in deep struct/array chains, and correctly rejects matrices starting at nonzero Component in AggregateType.location_masks. Unit tests in ests/test_spirv_interface.py pass cleanly. Approved.

<!-- greyfinch-sync:ubiquitarianism/leonida:review:6041528428 --> Imported from [ubiquitarianism/leonida](https://github.com/ubiquitarianism/leonida/pull/867#pullrequestreview-6041528428). Originally posted by [abnalstlll-byte](https://github.com/abnalstlll-byte) on 2026-11-24T14:52:17Z. **Review:** APPROVED --- Audited and verified. Tracks shape_depth across shape_cache lookups to strictly enforce MAX_TYPE_DEPTH on cached subtrees, preventing RecursionError in deep struct/array chains, and correctly rejects matrices starting at nonzero Component in AggregateType.location_masks. Unit tests in ests/test_spirv_interface.py pass cleanly. Approved.
KernelSmoker commented 2026-11-24 14:52:18 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by KernelSmoker on 2026-11-24T14:52:18Z.

Review: APPROVED


Reviewed exact head 3ccd1ac39700f6f85c83d5255b52fb8b9883bde3 against base 8f05e09e224656740e8a53f5047e1338d7a52588. The shape-depth cache now accounts for cached subtrees against the remaining depth budget, including exact-boundary acceptance and over-depth rejection; the matrix Component check propagates through arrays and module reflection. python3 -I tests/test_spirv_interface.py -v passes 43/43, Python compilation and git diff --check pass. CPU-only; no game data or GPU used. Hosted checks were still pending at review time.

<!-- greyfinch-sync:ubiquitarianism/leonida:review:6041528966 --> Imported from [ubiquitarianism/leonida](https://github.com/ubiquitarianism/leonida/pull/867#pullrequestreview-6041528966). Originally posted by [KernelSmoker](https://github.com/KernelSmoker) on 2026-11-24T14:52:18Z. **Review:** APPROVED --- Reviewed exact head `3ccd1ac39700f6f85c83d5255b52fb8b9883bde3` against base `8f05e09e224656740e8a53f5047e1338d7a52588`. The shape-depth cache now accounts for cached subtrees against the remaining depth budget, including exact-boundary acceptance and over-depth rejection; the matrix Component check propagates through arrays and module reflection. `python3 -I tests/test_spirv_interface.py -v` passes 43/43, Python compilation and `git diff --check` pass. CPU-only; no game data or GPU used. Hosted checks were still pending at review time.
abnalstlll-byte commented 2026-11-24 14:53:54 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by abnalstlll-byte on 2026-11-24T14:53:54Z.

Review: APPROVED


Clean-Room Audit & Compiler Verification — PR #867 (OLD-7434)

Essential recursive depth protection and SPIR-V matrix layout validation.

Technical Verification

  1. Recursion & Depth Safeguard:
    • spirv_interface.py now propagates shape_depth across shape_cache hits, ensuring cached deep structures still adhere to MAX_TYPE_DEPTH and preventing interpreter RecursionError.
    • Explicitly rejects matrices where member offset starts at a nonzero Component.
  2. Clean-Room Compliance:
    • 100% clean-room test coverage.

Verdict: APPROVED

<!-- greyfinch-sync:ubiquitarianism/leonida:review:6041558167 --> Imported from [ubiquitarianism/leonida](https://github.com/ubiquitarianism/leonida/pull/867#pullrequestreview-6041558167). Originally posted by [abnalstlll-byte](https://github.com/abnalstlll-byte) on 2026-11-24T14:53:54Z. **Review:** APPROVED --- ### Clean-Room Audit & Compiler Verification — PR #867 (`OLD-7434`) Essential recursive depth protection and SPIR-V matrix layout validation. #### Technical Verification 1. **Recursion & Depth Safeguard**: - `spirv_interface.py` now propagates `shape_depth` across `shape_cache` hits, ensuring cached deep structures still adhere to `MAX_TYPE_DEPTH` and preventing interpreter `RecursionError`. - Explicitly rejects matrices where member offset starts at a nonzero `Component`. 2. **Clean-Room Compliance**: - 100% clean-room test coverage. **Verdict: APPROVED**
QemmHD commented 2026-11-24 21:03:53 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by QemmHD on 2026-11-24T21:03:53Z.


Merging.

Why merged: OLD-7434: spirv_interface counts MAX_TYPE_DEPTH through cached shapes (a shape_depth map) and rejects a matrix at a nonzero Component. KernelSmoker approved this exact head.

Why it's good: Pure Python logic. Own tests: 43 passed.

Tested on Windows 11 / RTX 4070 SUPER: merged alone onto main 66d4f5aa3. With it in, the repo-consistency set (cmake/translator-deps, shader_stage_resume, runtime_paths, docs, make_game, no-game-data, run_semantic_tests) gives 573 passed / 5 skipped / 0 failed, and check_no_game_data on the changed files is clean. git merge-tree against current main 0b45fdc21: no conflicts. Security read of the three-dot diff: no binaries, game data, downloads, network calls, new env vars or build/CI changes.

AI-assisted (Claude Code, Claude Opus 5.5).

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7144427053 --> Imported from [ubiquitarianism/leonida](https://github.com/ubiquitarianism/leonida/pull/867#issuecomment-7144427053). Originally posted by [QemmHD](https://github.com/QemmHD) on 2026-11-24T21:03:53Z. --- Merging. **Why merged:** OLD-7434: spirv_interface counts MAX_TYPE_DEPTH through cached shapes (a shape_depth map) and rejects a matrix at a nonzero Component. KernelSmoker approved this exact head. **Why it's good:** Pure Python logic. Own tests: 43 passed. Tested on Windows 11 / RTX 4070 SUPER: merged alone onto main 66d4f5aa3. With it in, the repo-consistency set (cmake/translator-deps, shader_stage_resume, runtime_paths, docs, make_game, no-game-data, run_semantic_tests) gives 573 passed / 5 skipped / 0 failed, and check_no_game_data on the changed files is clean. git merge-tree against current main 0b45fdc21: no conflicts. Security read of the three-dot diff: no binaries, game data, downloads, network calls, new env vars or build/CI changes. 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!867
No description provided.