[PR #558] [MERGED] rdna2spirv: isolate and clean up index staging files (SHADER-INDEX-ATOMIC) #604

Closed
opened 2026-11-26 20:18:26 +01:00 by 4ld0 · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/ubiquitarianism/leonida/pull/558
Author: @JiyouProt
Created: 11/24/2026
Status: ✅ Merged
Merged: 11/24/2026
Merged by: @QemmHD

Base: main ← Head: codex/shader-index-atomic


📝 Commits (3)

  • 12833b5 rdna2spirv: isolate and clean up index staging files (SHADER-INDEX-ATOMIC)
  • 62c061e rdna2spirv: preserve published index permissions
  • e4dc13b build: declare file_mode in translator dependency lists

📊 Changes

5 files changed (+155 additions, -7 deletions)

View changed files

📝 .github/workflows/runtime.yml (+2 -0)
📝 make_game.py (+1 -1)
📝 runtime/cmake/translator_deps.cmake (+1 -0)
➕ tests/test_rdna2spirv_index_write.py (+129 -0)
📝 tools/rdna2spirv.py (+22 -6)

📄 Description

Claimed in the coordination issue as: SHADER-INDEX-ATOMIC — https://github.com/ubiquitarianism/leonida/issues/14#issuecomment-7121429083

What and why

write_index used the fixed sibling <index>.tmp. An existing file at that name was overwritten, a directory at that name blocked a valid write, and concurrent writers could replace or remove each other's staging file. Failed writes also left partial staging files behind.

Use a unique temporary file in the destination directory, close it before publishing through the existing Windows-aware replace_retry, and remove it if serialization, fsync or replacement fails (including interruption). Keep fsync, sorted JSON, LF output and atomic replacement. Temporary names do not match the shard-merge glob. No shader translation rule changes.

Six synthetic regression tests reproduce the old behavior and cover an unrelated .tmp file/directory, serialization/fsync/replace failures, interruption and overlapping writers. The overlap test also checks that the shard glob sees only complete indexes.

Tested

Windows, Python 3.14.3, based on main ece4ba5b31 (current when this task started).

  • All six new tests fail against the original writer and pass with this change.
  • python -I tests/test_rdna2spirv_index_write.py: 6 passed.
  • python -I tests/test_rdna2spirv_merge.py: 30 passed.
  • python -I tests/test_text_write_line_endings.py: 3 passed.
  • Full semantic suite with SPIRV-Tools v2026.4 available: 465 files, 6,103 tests, 0 files failed (532 s, 8 jobs).
  • compileall, make_game.py --help, no-game-data scan of both changed files and git diff --check: passed.

GPUs tested: n/a — index file publication only; fixtures are synthetic dictionaries. No game files needed or used.

AI-assisted: yes, with Codex.

Checklist

  • Based on current main at task start; GitHub mergeability checked before opening.
  • One topic; follow-up work goes in a new pull request.
  • No game data, keys or decryption, including in logs or reports.
  • No translator rule added, so no contract table change needed.

🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/ubiquitarianism/leonida/pull/558 **Author:** [@JiyouProt](https://github.com/JiyouProt) **Created:** 11/24/2026 **Status:** ✅ Merged **Merged:** 11/24/2026 **Merged by:** [@QemmHD](https://github.com/QemmHD) **Base:** `main` ← **Head:** `codex/shader-index-atomic` --- ### 📝 Commits (3) - [`12833b5`](https://github.com/ubiquitarianism/leonida/commit/12833b5c2f718841887ea09bbf33f120b1727cb2) rdna2spirv: isolate and clean up index staging files (SHADER-INDEX-ATOMIC) - [`62c061e`](https://github.com/ubiquitarianism/leonida/commit/62c061e588703b9df59c7d5c4055e9c074d6046e) rdna2spirv: preserve published index permissions - [`e4dc13b`](https://github.com/ubiquitarianism/leonida/commit/e4dc13b0797a0709104d8f7dcc0fda47fb55eea3) build: declare file_mode in translator dependency lists ### 📊 Changes **5 files changed** (+155 additions, -7 deletions) <details> <summary>View changed files</summary> 📝 `.github/workflows/runtime.yml` (+2 -0) 📝 `make_game.py` (+1 -1) 📝 `runtime/cmake/translator_deps.cmake` (+1 -0) ➕ `tests/test_rdna2spirv_index_write.py` (+129 -0) 📝 `tools/rdna2spirv.py` (+22 -6) </details> ### 📄 Description Claimed in the coordination issue as: SHADER-INDEX-ATOMIC — https://github.com/ubiquitarianism/leonida/issues/14#issuecomment-7121429083 ### What and why `write_index` used the fixed sibling `<index>.tmp`. An existing file at that name was overwritten, a directory at that name blocked a valid write, and concurrent writers could replace or remove each other's staging file. Failed writes also left partial staging files behind. Use a unique temporary file in the destination directory, close it before publishing through the existing Windows-aware `replace_retry`, and remove it if serialization, fsync or replacement fails (including interruption). Keep fsync, sorted JSON, LF output and atomic replacement. Temporary names do not match the shard-merge glob. No shader translation rule changes. Six synthetic regression tests reproduce the old behavior and cover an unrelated .tmp file/directory, serialization/fsync/replace failures, interruption and overlapping writers. The overlap test also checks that the shard glob sees only complete indexes. ### Tested Windows, Python 3.14.3, based on main ece4ba5b31ebc6f345c8e29eae1261f2f780057a (current when this task started). - All six new tests fail against the original writer and pass with this change. - `python -I tests/test_rdna2spirv_index_write.py`: 6 passed. - `python -I tests/test_rdna2spirv_merge.py`: 30 passed. - `python -I tests/test_text_write_line_endings.py`: 3 passed. - Full semantic suite with SPIRV-Tools v2026.4 available: **465 files, 6,103 tests, 0 files failed** (532 s, 8 jobs). - compileall, `make_game.py --help`, no-game-data scan of both changed files and `git diff --check`: passed. GPUs tested: n/a — index file publication only; fixtures are synthetic dictionaries. No game files needed or used. AI-assisted: yes, with Codex. ### Checklist - [x] Based on current main at task start; GitHub mergeability checked before opening. - [x] One topic; follow-up work goes in a new pull request. - [x] No game data, keys or decryption, including in logs or reports. - [x] No translator rule added, so no contract table change needed. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
4ld0 2026-11-26 20:18:26 +01:00
Sign in to join this conversation.
No labels
bug
pull-request
No milestone
No project
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.

Dependencies

No dependencies set

Reference
starred/leonida#604
No description provided.