Skip to content

first_light: a failed redraw clears the previous draw's preview and result - #4135

Closed
mrp1no wants to merge 2 commits into
ItsNotRexed:mainfrom
mrp1no:first-light-stale-result
Closed

mrp1no wants to merge 2 commits into
ItsNotRexed:mainfrom
mrp1no:first-light-stale-result

Conversation

@mrp1no

@mrp1no mrp1no commented Nov 22, 2026

Copy link
Copy Markdown
Contributor

Fixes @Vonsek's finding: #4084 (comment). Claim: #4084 (comment)

Before running the harness, tools/first_light.py's run_draw removed only image.raw. If the harness or the --check oracle then failed, image.ppm and the manifest's result were still those of the previous successful draw in the same output folder. They looked like this draw's result.

Commits

  1. first_light: one write_manifest helper: prepare and run_draw wrote manifest.json with the same open/dump code. One helper now does it. No behaviour change.
  2. first_light: a failed redraw clears the previous draw's preview and result:
    • run_draw now also removes image.ppm and drops result from the manifest, both in memory and on disk, before the harness runs.
    • Both are written again only after a draw that passed.
    • New RedrawTests in tests/test_first_light.py uses a stand-in harness (no GPU, no package) to run four draws in one folder: success, an all-opaque frame the oracle refuses, a harness that writes nothing, then success. After each failure there is no image.ppm and no result.

Tested (Windows 11, Python 3.15, no GPU needed)

  • tests/test_first_light.py: 20 tests OK, 4 skipped (the package-gated draws).
  • test_first_light_bad_json.py and test_first_light_harness_paths.py: OK.
  • Negative control: with main's tools/first_light.py, RedrawTests fails at the second draw with the earlier preview is left as if it were this draw's.

Other open PRs touch tools/first_light.py (#3689, #2893, #2855, #2906, #3412). This one changes only the start of run_draw and the two manifest writes. If one of them lands first and conflicts, I'll rebase.

No game files. AI-assisted (Claude Code).

🤖 Generated with Claude Code

mrp1no and others added 2 commits November 23, 2026 00:36
prepare and run_draw each opened manifest.json and dumped the manifest
with the same encoding, newline and indent. One helper now does it; the
next commit needs a third write. No behaviour change.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…esult

run_draw removed only image.raw before running the harness. When the
harness or the --check oracle then failed, image.ppm and manifest.json's
"result" still described the earlier successful draw in the same folder,
as if they were this one's (@Vonsek's finding).

run_draw now also removes image.ppm and drops "result" from the manifest
(in memory and on disk) before the harness runs, so they exist only after
a draw that passed.

tests/test_first_light.py RedrawTests: a stand-in harness writes the
readback for success, an all-opaque frame the oracle refuses, no file,
then success again, all in one folder. With main's first_light.py the
test fails at the second draw ("the earlier preview is left").

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@tupacfan04

Copy link
Copy Markdown
Contributor

Tested at the head on Windows 11 / Python 3.13.0: tests/test_first_light.py 20 (4 skipped: package/GPU), bad_json 9, harness_paths 4, compileall clean. Negative control: main's tool fails RedrawTests at tests/test_first_light.py:285 ("earlier preview is left").

The cleanup is right: tools/first_light.py:501-505 unlinks only image.raw/image.ppm in its own out_dir and pops result, preserving other manifest keys, and both are rewritten only after the oracle passes.

Nits:

  • Not atomic: write_ppm opens the destination directly (:487) and write_manifest truncates in place (:540), so a crash mid-write leaves a truncated preview/manifest (never a stale pair).
  • find_harness (:496) runs before the cleanup, so a missing harness leaves the old preview and result.
  • The test does not assert that other files survive.

Approve. AI-assisted review, no game files, no GPU.

@sds-228 sds-228 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code review of df13636: no issues found. A failed redraw clears the stale preview and removes the previous result before and after the run, so a later failure cannot look like a fresh pass. Targeted suite: 20 tests OK (4 skipped).

AI-assisted (OpenCode).

@mrp1no

mrp1no commented Nov 23, 2026

Copy link
Copy Markdown
Contributor Author

Closing in favour of @Vonsek's #4136, which covers BUILD-1172. It was his finding, and I released my claim earlier. This branch now conflicts with main's tools/first_light.py, and rebasing a duplicate would only add review load. My write_manifest helper commit (b1053ff1) isn't needed for his fix. AI-assisted (Claude Code).

@mrp1no mrp1no closed this Nov 23, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants