[PR #1668] gen_gdk_runtime_classes: write --out atomically #1682

Open
opened 2026-11-26 20:22:05 +01:00 by 4ld0 · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/ubiquitarianism/leonida/pull/1668
Author: @xel1uz
Created: 11/25/2026
Status: 🔄 Open

Base: main ← Head: fix/gen-gdk-runtime-classes-atomic-out


📝 Commits (1)

  • f85de7d gen_gdk_runtime_classes: write --out atomically

📊 Changes

2 files changed (+110 additions, -3 deletions)

View changed files

➕ tests/test_gen_gdk_runtime_classes.py (+85 -0)
📝 tools/gen_gdk_runtime_classes.py (+25 -3)

📄 Description

Item ID: GEN-GDK-RUNTIME-CLASSES-ATOMIC-OUT (new item; the coordination issue #14 is at GitHub's 2,500-comment cap, so the claim lives here)

Claimed as: GEN-GDK-RUNTIME-CLASSES-ATOMIC-OUT - a failed --out write truncates an existing file and leaves a partial one behind. Reproduced on 42537e7b.

What and why

The generator opened its target with open(a.out, "w") and then json.dumped into it, so the previous table was truncated the moment the file was opened; a short or failed write left partial JSON behind.

The table is now written to a temp file in the destination directory and published with os.replace; failures clean the temp file up and keep the previous table.

Tested

  • pytest tests/test_gen_gdk_runtime_classes.py -q with the tool at 42537e7b: 1 failed, 2 passed.

  • With this branch: 3 passed.

  • Repro with 128 synthetic classes, a 14-byte existing output and ulimit -f 1: the original grew the file 14 -> 1024 bytes (partial JSON); with this patch it stayed 14 bytes and no temp file remained.

  • git diff --check clean; python3 -I scripts/check_no_game_data.py clean on the changed files.

GPUs tested: n/a - CPU only, no Vulkan device involved.

AI-assisted: Yes.

Checklist

  • Based on current main (42537e7b) and merges cleanly.
  • One topic; follow-up work goes in a new pull request.
  • No game data, keys or decryption; synthetic inputs only.
  • A new translator rule in the contract table of docs/design.md - not applicable, no translator change.

🔄 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/1668 **Author:** [@xel1uz](https://github.com/xel1uz) **Created:** 11/25/2026 **Status:** 🔄 Open **Base:** `main` ← **Head:** `fix/gen-gdk-runtime-classes-atomic-out` --- ### 📝 Commits (1) - [`f85de7d`](https://github.com/ubiquitarianism/leonida/commit/f85de7d9535ef41a6b071d8f9c7f11cbf9180517) gen_gdk_runtime_classes: write --out atomically ### 📊 Changes **2 files changed** (+110 additions, -3 deletions) <details> <summary>View changed files</summary> ➕ `tests/test_gen_gdk_runtime_classes.py` (+85 -0) 📝 `tools/gen_gdk_runtime_classes.py` (+25 -3) </details> ### 📄 Description Item ID: `GEN-GDK-RUNTIME-CLASSES-ATOMIC-OUT` (new item; the coordination issue #14 is at GitHub's 2,500-comment cap, so the claim lives here) Claimed as: `GEN-GDK-RUNTIME-CLASSES-ATOMIC-OUT` - a failed `--out` write truncates an existing file and leaves a partial one behind. Reproduced on 42537e7b. ### What and why The generator opened its target with `open(a.out, "w")` and then `json.dump`ed into it, so the previous table was truncated the moment the file was opened; a short or failed write left partial JSON behind. The table is now written to a temp file in the destination directory and published with `os.replace`; failures clean the temp file up and keep the previous table. ### Tested - `pytest tests/test_gen_gdk_runtime_classes.py -q` with the tool at 42537e7b: **1 failed, 2 passed**. - With this branch: **3 passed**. - Repro with 128 synthetic classes, a 14-byte existing output and `ulimit -f 1`: the original grew the file **14 -> 1024 bytes** (partial JSON); with this patch it stayed **14 bytes** and no temp file remained. - `git diff --check` clean; `python3 -I scripts/check_no_game_data.py` clean on the changed files. GPUs tested: n/a - CPU only, no Vulkan device involved. AI-assisted: Yes. ### Checklist - [x] Based on current `main` (42537e7b) and merges cleanly. - [x] One topic; follow-up work goes in a new pull request. - [x] No game data, keys or decryption; synthetic inputs only. - [ ] A new translator rule in the contract table of `docs/design.md` - not applicable, no translator change. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
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#1682
No description provided.