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

Merged
Ch1mpleo merged 1 commit from upstream-pr/2299 into main 2026-11-28 10:48:40 +00:00
Ch1mpleo commented 2026-11-26 13:03:28 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by Ch1mpleo on 2026-11-26T13:03:28Z.


Claimed in the coordination issue as: FIRST-LIGHT-ATOMIC-MANIFEST (https://github.com/ubiquitarianism/leonida/issues/1608#issuecomment-7192791901)

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)
<!-- greyfinch-sync:ubiquitarianism/leonida:issue:5510522990 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/2299). Originally posted by [Ch1mpleo](https://github.com/Ch1mpleo) on 2026-11-26T13:03:28Z. --- Claimed in the coordination issue as: FIRST-LIGHT-ATOMIC-MANIFEST (https://github.com/ubiquitarianism/leonida/issues/1608#issuecomment-7192791901) ### 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)
EdenBendheim commented 2026-11-26 21:43:42 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by EdenBendheim on 2026-11-26T21:43:42Z.


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.

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7204002732 --> Imported from [ubiquitarianism/leonida](https://github.com/ubiquitarianism/leonida/pull/2299#issuecomment-7204002732). Originally posted by [EdenBendheim](https://github.com/EdenBendheim) on 2026-11-26T21:43:42Z. --- 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.
tiguan26 commented 2026-11-27 04:41:20 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by tiguan26 on 2026-11-27T04:41:20Z.

Review: APPROVED


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

<!-- greyfinch-sync:ubiquitarianism/leonida:review:6083569334 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/2299#pullrequestreview-6083569334). Originally posted by [tiguan26](https://github.com/tiguan26) on 2026-11-27T04:41:20Z. **Review:** APPROVED --- 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).
MSedgeMC commented 2026-11-27 15:23:39 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by MSedgeMC on 2026-11-27T15:23:39Z.

Review: COMMENTED


Verified on the PR branch: python3 -m unittest tests.test_first_light -v -> 49 tests OK (4 skips), including the new atomic manifest write cases. Not approving yet: the branch is 450 commits behind current main, so a rebase is needed before the final diff can be reviewed.

<!-- greyfinch-sync:ubiquitarianism/leonida:review:6090305278 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/2299#pullrequestreview-6090305278). Originally posted by [MSedgeMC](https://github.com/MSedgeMC) on 2026-11-27T15:23:39Z. **Review:** COMMENTED --- Verified on the PR branch: python3 -m unittest tests.test_first_light -v -> 49 tests OK (4 skips), including the new atomic manifest write cases. Not approving yet: the branch is 450 commits behind current main, so a rebase is needed before the final diff can be reviewed.
sodove commented 2026-11-28 10:12:51 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by sodove on 2026-11-28T10:12:51Z.


#2299 | head 04a204bc0e7b57153e04cdad34b79038d9eae9e1 | python3 -I tests/test_first_light.py -v | red: 49 run, 1 error, 4 skips | green: 45 passed, 4 skipped | Baseline exception → pass

On main the new atomic writer was missing. Three checks requiring a First Light fixture directory and one optional native harness check skipped on both sides.

Pinned main 33db04a7010e81c40a7a6a15624525aa0c4a3a58, merged into this PR head. Ubuntu 26.04.1 (WSL2), Python 3.14.4. Full suite: not run. AI-assisted: OpenAI Codex. Batch claim.

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7237748416 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/2299#issuecomment-7237748416). Originally posted by [sodove](https://github.com/sodove) on 2026-11-28T10:12:51Z. --- #2299 | head `04a204bc0e7b57153e04cdad34b79038d9eae9e1` | `python3 -I tests/test_first_light.py -v` | red: 49 run, 1 error, 4 skips | green: 45 passed, 4 skipped | **Baseline exception → pass** On main the new atomic writer was missing. Three checks requiring a First Light fixture directory and one optional native harness check skipped on both sides. Pinned main `33db04a7010e81c40a7a6a15624525aa0c4a3a58`, merged into this PR head. Ubuntu 26.04.1 (WSL2), Python 3.14.4. Full suite: not run. AI-assisted: OpenAI Codex. [Batch claim](https://github.com/ProjectLeonida/mandy/issues/1608#issuecomment-7237628300).
DadaCap commented 2026-11-28 10:48:42 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by DadaCap on 2026-11-28T10:48:42Z.


Merged, thank you @Ch1mpleo!

What it does: tools/first_light: write manifest.json atomically (FIRST-LIGHT-ATOMIC-MANIFEST)

How it was checked: sodove tested this PR at head 04a204bc0 on main 33db04a70: the PR's own test fails on main and passes with this PR merged in (his result is linked from the batch summary in #1608). We then re-ran the same test locally on Windows 11 and got the same verdict: on main, red (1 error); with the PR, green (49 OK, 8 skips).

CI: the red jobs on this PR fail the same way on main, or on the older main it was built on (the cs_dpp_cmp.asm translator fixture, since fixed on main, and the Windows runner's Visual Studio setup), so none comes from this change.

Merged one by one with 20 other PRs of the same reviewed batch, pinned to the tested head.

AI-assisted (Claude Code, Claude Opus 5.5), posted for the maintainers.

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7238137343 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/2299#issuecomment-7238137343). Originally posted by [DadaCap](https://github.com/DadaCap) on 2026-11-28T10:48:42Z. --- Merged, thank you @Ch1mpleo! **What it does:** tools/first_light: write manifest.json atomically (FIRST-LIGHT-ATOMIC-MANIFEST) **How it was checked:** sodove tested this PR at head `04a204bc0` on main `33db04a70`: the PR's own test fails on main and passes with this PR merged in (his result is linked from the batch summary in #1608). We then re-ran the same test locally on Windows 11 and got the same verdict: on main, red (1 error); with the PR, green (49 OK, 8 skips). **CI:** the red jobs on this PR fail the same way on main, or on the older main it was built on (the `cs_dpp_cmp.asm` translator fixture, since fixed on main, and the Windows runner's Visual Studio setup), so none comes from this change. Merged one by one with 20 other PRs of the same reviewed batch, pinned to the tested head. AI-assisted (Claude Code, Claude Opus 5.5), posted for the maintainers.
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!2299
No description provided.