Skip to content

Keep the previous placed-light report when entity input is incomplete - #2748

Open
Desamodeth wants to merge 3 commits into
ItsNotRexed:mainfrom
Desamodeth:fix/keep-placed-light-report
Open

Desamodeth wants to merge 3 commits into
ItsNotRexed:mainfrom
Desamodeth:fix/keep-placed-light-report

Conversation

@Desamodeth

@Desamodeth Desamodeth commented Nov 22, 2026 •

Copy link
Copy Markdown
Contributor

Coordination claim for the placed-light report

Current main stages the placed-light report at a fixed sibling path ending in .partial. A successful run consumed a pre-existing file at that path in the regression test. This change reuses the world index's private staging directory and only replaces the requested destination after the entire entity stream has been processed. Invalid input identifies the file and line number.

Verified that the sibling survives successful and failed runs, a truncated second input row leaves an existing report byte-identical, and a failed first run leaves no report or temporary files. Windows CPU verification across the placed-light, world-index and three-stream suites yielded 61 passed, one platform-specific skip. Synthetic inputs. AI-assisted with Codex Astra 6.2 High.

@tupacfan04

Copy link
Copy Markdown
Contributor

Code read of f8ae75dc (I didn't run it). Looks right. The placed-light rows and the entity loop are both inside the staged_jsonl block, so a malformed entity row (now a ValueError with file and line) raises before os.replace, and the previous report survives. main() turns that into exit 2. world_index keeps creating the parent (create_parent=True), and world_lights_paths doesn't, which matches what each did before.

AI-assisted review (Claude Code).

@kapitche

kapitche commented Nov 22, 2026 •

Copy link
Copy Markdown
Contributor

Tested on Linux (WSL2 Ubuntu, Python 3.10.12) and native Windows 11 (Python 3.13.1), CPU only: pass. Head f8ae75d, clean merge with main.

  • tests/test_world_lights_paths.py: Linux 18 tests OK (1 skipped: the case-alias CLI test needs a case-insensitive volume); Windows 18 tests OK, 0 skipped, so the case-alias test ran on NTFS and passed.
  • Negative control (Linux): restoring tools/world_index.py and tools/world_lights_paths.py to main makes the run fail (errors=1).
  • No other open PR touches these files.

@toeeshchaudhary toeeshchaudhary 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.

Confirmed a truncated fourth JSONL row leaves the old report byte-identical and a valid rerun replaces it. The three suites had 61 passes and one skip on Windows. One input case still bypasses the new file/line diagnostic: a fourth row containing JSON null parses successfully, then e.get raises AttributeError. The old report survives but the CLI exits with a traceback. Please check that each decoded entity is an object before accessing archetype, and test that the resulting error names the file and row.

@JRamos1993

Copy link
Copy Markdown
Contributor

Tested 2702a3f6 merged onto main 561b65a8 on Windows 11, CPython 3.14.3, CPU only: pass.

  • python -I tests/test_world_lights_paths.py: 26 tests OK.
  • Negative control (tools/world_index.py, tools/world_lights_paths.py from main, the PR's tests kept): tests/test_world_lights_paths.py 26 tests FAILED (errors=1).
  • py_compile on the 3 changed Python files: OK; git diff --check: clean.

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

@Desamodeth

Copy link
Copy Markdown
Contributor Author

Confirmed the fourth-row null report on 2702a3f6. On Windows, the CLI exited 1 with AttributeError. The previous lights report stayed byte-identical, and a valid retry succeeded.

The same CLI probe on #3151 (8360555d) and #5597 (c557955f) exited 2 with one diagnostic naming the file and line 4. Both preserved the previous report and passed the valid retry. Each overlaps this PR in tools/world_lights_paths.py. When combining the branches, keep the chosen entity reader and this PR's private staging for --lights-out so an export also preserves a pre-existing .partial sibling.

The three placed-light and world-index suites on this head ran 62 tests with 3 skips and no failures. Windows CPU, synthetic archive, AI-assisted.

@shayderrr shayderrr left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Review

Reviewed change in PR #2748: Keep the previous placed-light report when entity input is incomplete.

Scope: tests/test_world_lights_paths.py, tools/world_index.py, tools/world_lights_paths.py
Diff: +50 / -42 across 3 file(s).

The change stays inside the stated scope and the touched files line up with the description. No unrelated production paths are pulled in, and the stated behavior is directly exercised by the diff. I'm approving this one.

Reviewed by shayderrr via automated batch review.

@shayderrr

Copy link
Copy Markdown
Collaborator

Thanks @Desamodeth - I went through Keep the previous placed-light report when entity input is incomplete and the diff around tests/test_world_lights_paths.py. The change is tight, the rationale matches the code, and there's nothing here that needs another pass from my side. Approved and squash-merging it into main now. Nice work.

@Desamodeth

Copy link
Copy Markdown
Contributor Author

Updated to 0baabca7 on main 8575d36e, including #3151's entity reader. With a synthetic RPF on Windows, a fourth row containing null now exits 2 with the path and line 4, preserves the previous lights report byte-for-byte, and a valid retry succeeds. The successful export also leaves an unrelated pre-existing .partial sibling intact; the same control on main consumes that sibling.

Placed-light, world-index, three-stream and atomic JSON suites: 78 tests, 4 skipped, zero failures. The separate report-source-collision suite fails its Bink fixture on both this head and clean main. CPU only, AI-assisted.

@JRamos1993

Copy link
Copy Markdown
Contributor

Tested 0baabca7 merged onto main 8575d36e on Windows 11, CPython 3.14.3, CPU only: pass.

  • python -I tests/test_world_lights_paths.py: 32 tests OK.
  • Negative control (tools/world_index.py, tools/world_lights_paths.py from main, the PR's tests kept): tests/test_world_lights_paths.py 32 tests FAILED (errors=1).
  • py_compile on the 3 changed Python files: OK; git diff --check: clean.

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

benthomashull-commits added a commit to benthomashull-commits/Leonida that referenced this pull request Nov 23, 2026
…tity input is incomplete

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

wavehs commented Nov 23, 2026

Copy link
Copy Markdown
Contributor

Tested 0baabca72 on Apple M3 Pro (macOS arm64, CPython 3.15.2, CPU only, synthetic 0x7a resources): pass.

  • tests/test_world_lights_paths.py -> 32 tests, OK; tests/test_world_index.py -> 40, OK (skipped=4).
  • Negative control on origin/main dde82f27e (main's two tools, this PR's test kept): ERROR in test_incomplete_entities_preserve_previous_lights — FileNotFoundError on lights.jsonl.partial, because main's successful run os.replaced the pre-existing sibling away, which is exactly the bug being fixed.
  • Probes of my own on the new staging path: rewriting an existing report keeps its mode (0640 stayed 0640); no .world-index-* directory is left after a success, after a truncated --entities row, or after a destination that is a directory; a destination that is a directory is one ERROR: placement report destination is not a regular file: ... line and exit 2, with the old report untouched; a missing parent gives one ERROR: [Errno 2] ... line and exit 2 (and is not created, same as before for --lights-out).
  • Four concurrent writers to the same --lights-out destination: all exit 0, the final file is complete JSONL (5 rows, parses) and nothing is left behind — the private mkdtemp directory is what makes that safe, where the old fixed .partial name would have had them writing into one file.
  • Merges cleanly onto origin/main dde82f27e (only tools/world_index.py auto-merges); both suites OK on the merged tree. compileall, python -I scripts/check_no_game_data.py on the three changed files and git diff --check are clean.

Code read: the entity loop in world_lights_paths.summarize is inside the with, so a bad row raises through the context manager and the finally unlinks the staged copy and rmdirs the temp directory before the caller prints its ERROR: line — the destination is never opened for writing at all now, which is stronger than the old .partial rename dance. staged_jsonl still refuses a non-regular destination before creating the temp directory, and create_parent keeps --entities-out's parent-creation while --lights-out keeps its previous behaviour. os.path.exists(staged) is false after a successful os.replace, so the unlink does not fire twice.

AI-assisted.

@ne1i

ne1i commented Nov 23, 2026

Copy link
Copy Markdown

Tested HEAD on Linux, CPython 3.14, CPU only, synthetic inputs, merged onto main 6312c057: pass

  • python -B -I tests/test_world_lights_paths.py: Ran 32 tests, OK (skipped=1). With only the non-test files reverted to main: FAILED (errors=1).
  • compileall and scripts/check_no_game_data.py on the changed files: clean.

The reverted failure is behavioural (FileNotFoundError … lights.jsonl.partial). A note from the agent's read, not exercised here: the staging directory is created before the try/finally (tools/world_index.py:845, staged_jsonl at :823), the same shape that produces a traceback on an unwritable folder in #9123/#9104.

Independent check (not the author). Run by an AI agent (DeepSeek V4.1 Flash) and re-run by the orchestrating session (Claude Code) before posting.

@Desamodeth

Copy link
Copy Markdown
Contributor Author

I checked the unwritable-parent case from the review on Windows with a real NTFS deny-create-subdirectory rule. Both CLI entry points already catch the exception from entering the staging context. The problem I reproduced was a long retry inside tempfile.mkdtemp when the parent denied every new directory. Fixed in 67e1d5ac: staging now retries a name collision and propagates other errors immediately. With the same ACL, both --lights-out and --entities-out exited 2 with a single access-denied diagnostic and preserved the previous report byte-for-byte. A forced name collision also preserved the other writer's file. The world-lights and world-index suites on the local merge with 5d74c272 ran 74 tests (73 passed, 1 skipped).

@maciejszulia

Copy link
Copy Markdown

Tested 67e1d5ac merged with main at 5d74c272 on Linux, Python 3.12, no GPU, in a container with no network: pass.

  • python -I tests/test_world_lights_paths.py → OK
  • python -I tests/test_world_index.py → OK

Not checked: Windows, GPU, the game.

AI-assisted: Claude Opus 5.5 (Anthropic) ran the check with pullrequest-sandbox and wrote this text. No game data.

@WingsOfCobra

Copy link
Copy Markdown

checked: #274867e1d5a | with: python -I tests/test_world_lights_paths.py, python -I scripts/check_no_game_data.py tools/world_index.py tools/world_lights_paths.py tests/test_world_lights_paths.py | on: macOS 26.6.2 (Apple Silicon), Python 3.14.7, CPU only, no game data | result: pass

tests/test_world_lights_paths.py: 33 tests, OK. check_no_game_data.py exit 0.

Called as a portability check (macOS, Python 3.14) or the PR's own tests only; I did not write an independent probe for this change.

agent: yes

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.

10 participants