tools/first_light: write manifest.json atomically (FIRST-LIGHT-ATOMIC-MANIFEST) #2299

Open
github-bot wants to merge 1 commit from github-bot/gh-2299 into main AGit
Owner

@⁠Ch1mpleo on GitHub · 2026-11-26 13:03 UTC · original
Ch1mpleo:fix/first-light-atomic-manifest → main · +58 −4 · 2 files · 1 commits · open

Claimed in the coordination issue as: FIRST-LIGHT-ATOMIC-MANIFEST (#1608)

What and why

Writes \manifest.json\ atomically in \ ools/first_light.py\ via _write_json_atomic\ (\os.path.realpath\ + \ empfile.mkstemp\ + \ sync\ + \published_mode\ +
eplace_retry\ with cleanup on failure), preserving symlinks and permissions. Adds a regression test in \ ests/test_first_light.py.

Tested

  • \python -m compileall -q tools/first_light.py tests/test_first_light.py\ — exit 0.
  • \python -I tests/test_first_light.py\ — 49 tests (41 passed, 8 skipped; Windows 11 x64, Python 3.14.7).
  • \python -I scripts/check_no_game_data.py tools/first_light.py tests/test_first_light.py\ — exit 0.

GPUs tested: n/a (CPU-only Python tool & unit tests)

AI-assisted: yes

Checklist

  • Based on current \main\ and merges cleanly (a conflicting pull request is labeled
    eeds rebase).
  • One topic; follow-up work goes in a new pull request.
  • No game data, keys or decryption (CONTRIBUTING.md), including in logs or reports quoted here.
  • A new translator rule is in the contract table of \docs/design.md, with how it was confirmed. (n/a — no translator change)
**@⁠Ch1mpleo** on GitHub · 2026-11-26 13:03 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/2299) `Ch1mpleo:fix/first-light-atomic-manifest` → `main` · +58 −4 · 2 files · 1 commits · open Claimed in the coordination issue as: FIRST-LIGHT-ATOMIC-MANIFEST (https://git.gtahub.st/github/ubiquitarianism--leonida/issues/1608) ### What and why Writes \manifest.json\ atomically in \ ools/first_light.py\ via \_write_json_atomic\ (\os.path.realpath\ + \ empfile.mkstemp\ + \ sync\ + \published_mode\ + \ eplace_retry\ with cleanup on failure), preserving symlinks and permissions. Adds a regression test in \ ests/test_first_light.py\. ### Tested - \python -m compileall -q tools/first_light.py tests/test_first_light.py\ — exit 0. - \python -I tests/test_first_light.py\ — 49 tests (41 passed, 8 skipped; Windows 11 x64, Python 3.14.7). - \python -I scripts/check_no_game_data.py tools/first_light.py tests/test_first_light.py\ — exit 0. GPUs tested: n/a (CPU-only Python tool & unit tests) AI-assisted: yes ### Checklist - [x] Based on current \main\ and merges cleanly (a conflicting pull request is labeled \ eeds rebase\). - [x] One topic; follow-up work goes in a new pull request. - [x] No game data, keys or decryption (CONTRIBUTING.md), including in logs or reports quoted here. - [ ] A new translator rule is in the contract table of \docs/design.md\, with how it was confirmed. (n/a — no translator change)
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 13:04:12 +00:00
Author
Owner

@⁠EdenBendheim on GitHub · 2026-11-26 21:43 UTC · original

Two findings from local verification of 04a204bc0 against main at fac8b4bb9:

  • Missed write site: run_draw() now uses _write_json_atomic, but main() still opens manifest.json directly with "w" at tools/first_light.py:1195 (1164 on main), so an interrupted regeneration there can still truncate an existing manifest.
  • Test coverage: The new test exercises _write_json_atomic directly rather than that main() call path—routing main() through _write_json_atomic and adding a synthetic regression test verifying the prior manifest survives a write/replace failure would close the gap.

Checks run on macOS 27.3 arm64 (Python 3.14.3): claim confirmed in #1608, patch applies cleanly, no overlap with #2040. On plain main, the PR's tests/test_first_light.py had 44 passed, 4 skipped, 1 error (missing helper); with the patch, test_first_light.py (45 passed, 4 skipped), test_text_write_line_endings.py (3/3), test_report_paths.py (23 passed, 1 skipped), check_no_game_data.py, and compileall all passed.

Synthetic fixtures only; no game data. GPUs tested: N/A (CPU-only). AI-assisted review.

**@⁠EdenBendheim** on GitHub · 2026-11-26 21:43 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/2299#issuecomment-7204002732) Two findings from local verification of `04a204bc0` against `main` at `fac8b4bb9`: - **Missed write site:** `run_draw()` now uses `_write_json_atomic`, but `main()` still opens `manifest.json` directly with `"w"` at `tools/first_light.py:1195` (`1164` on `main`), so an interrupted regeneration there can still truncate an existing manifest. - **Test coverage:** The new test exercises `_write_json_atomic` directly rather than that `main()` call path—routing `main()` through `_write_json_atomic` and adding a synthetic regression test verifying the prior manifest survives a write/replace failure would close the gap. Checks run on macOS 27.3 arm64 (Python 3.14.3): claim confirmed in #1608, patch applies cleanly, no overlap with #2040. On plain `main`, the PR's `tests/test_first_light.py` had 44 passed, 4 skipped, 1 error (missing helper); with the patch, `test_first_light.py` (45 passed, 4 skipped), `test_text_write_line_endings.py` (3/3), `test_report_paths.py` (23 passed, 1 skipped), `check_no_game_data.py`, and `compileall` all passed. Synthetic fixtures only; no game data. GPUs tested: N/A (CPU-only). AI-assisted review.
Author
Owner

@⁠tiguan26 on GitHub · 2026-11-27 04:41 UTC · original · approved these changes

Approving 04a204bc0.

Both writes of manifest.json go through a temp file in the same folder, fsync and replace_retry, with the repo's published_mode; on any failure the temp file is removed. An interrupted run can no longer leave a truncated manifest.

Merged onto main d1dff7949 together with #2403, #2410, #2297, #2330 and #2286 (no conflicts), on Linux with Python 3.13. tests/test_first_light.py: 45 passed, 4 skipped (main: 44). AI-assisted (Claude Code, Claude Opus 5.5).

**@⁠tiguan26** on GitHub · 2026-11-27 04:41 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/2299#pullrequestreview-6083569334) · **approved these changes** Approving 04a204bc0. Both writes of `manifest.json` go through a temp file in the same folder, fsync and `replace_retry`, with the repo's `published_mode`; on any failure the temp file is removed. An interrupted run can no longer leave a truncated manifest. Merged onto `main` `d1dff7949` together with #2403, #2410, #2297, #2330 and #2286 (no conflicts), on Linux with Python 3.13. `tests/test_first_light.py`: 45 passed, 4 skipped (main: 44). AI-assisted (Claude Code, Claude Opus 5.5).
This pull request can be merged automatically.
This branch is out-of-date with the base branch
You are not authorized to merge this pull request.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin '+refs/pull/2299/head:github-bot/gh-2299'
git switch 'github-bot/gh-2299'

Merge

Merge the changes and update on Forgejo.
git switch 'main'
git merge --no-ff 'github-bot/gh-2299'
git switch 'github-bot/gh-2299'
git rebase 'main'
git switch 'main'
git merge --ff-only 'github-bot/gh-2299'
git switch 'github-bot/gh-2299'
git rebase 'main'
git switch 'main'
git merge --no-ff 'github-bot/gh-2299'
git switch 'main'
git merge --squash 'github-bot/gh-2299'
git switch 'main'
git merge --ff-only 'github-bot/gh-2299'
git switch 'main'
git merge 'github-bot/gh-2299'
git push origin 'main'
This discussion has been locked. Commenting is limited to contributors.
No description provided.